C#.NET + MS SQL Server : Nach INSERT direkt die Auto-Increment ID erhalten ohne zweite Abfrage

Problem

Um die Auto-Increment ID zu erhalten werden desöfteren 2 Statements abgesetzt, obwohl das INSERT-Statement direkt die Auto-Increment ID zurückgeben kann

Ansatz – Approach

Anstelle von comm.ExecuteNonQuery() sollte man lieber comm.ExecuteScalar() mit SELECT SCOPE_IDENTITY() kombinieren.

Lösung – Solution

public string insertMainTherapyData(string serial_no
                    ,string therapy_start
                    ,string machine_type
                    ,string file_source
                    ,string dialog_version
                    ,string tlc_version
                    ,string versions
                    ,DateTime uploaded_on
                    ,string uploaded_by
                    ,bool processed
                    ,string user_original_file
                    ,string user_country
                    ,string user_comment
                    ,string user_upload_reason
                    ,string user_location)
{
    string sqlStatement=@"
        INSERT INTO [dbo].[therapy]
                    ([serial_no]
                    ,[therapy_start]
                    ,[machine_type]
                    ,[file_source]
                    ,[dialog_version]
                    ,[tlc_version]
                    ,[versions]
                    ,[uploaded_on]
                    ,[uploaded_by]
                    ,[processed]
                    ,[user_original_file]
                    ,[user_country]
                    ,[user_comment]
                    ,[user_upload_reason]
                    ,[user_location])
        VALUES
                    (@serial_no
                    ,@therapy_start
                    ,@machine_type
                    ,@file_source
                    ,@dialog_version
                    ,@tlc_version
                    ,@versions
                    ,@uploaded_on
                    ,@uploaded_by
                    ,@processed
                    ,@user_original_file
                    ,@user_country
                    ,@user_comment
                    ,@user_upload_reason
                    ,@user_location);
            SELECT SCOPE_IDENTITY()
            ";
    int myID = -1;
    SqlConnection conn = new SqlConnection(MyConfigurationManager.prdSqlServerString);
    try
    {
        conn.Open();
        SqlCommand comm = new SqlCommand();
        comm.Connection = conn;
        comm.CommandText = sqlStatement;
        comm.Parameters.AddWithValue("serial_no", serial_no);
        comm.Parameters.AddWithValue("therapy_start", therapy_start);
        comm.Parameters.AddWithValue("machine_type", machine_type);
        comm.Parameters.AddWithValue("file_source", file_source);
        comm.Parameters.AddWithValue("dialog_version", dialog_version);
        comm.Parameters.AddWithValue("tlc_version", tlc_version);
        comm.Parameters.AddWithValue("versions", versions);
        comm.Parameters.AddWithValue("uploaded_on", uploaded_on);
        comm.Parameters.AddWithValue("uploaded_by", uploaded_by);
        comm.Parameters.AddWithValue("processed", processed);
        comm.Parameters.AddWithValue("user_original_file", user_original_file);
        comm.Parameters.AddWithValue("user_country", user_country);
        comm.Parameters.AddWithValue("user_comment", user_comment);
        comm.Parameters.AddWithValue("user_upload_reason", user_upload_reason);
        comm.Parameters.AddWithValue("user_location", user_location);
        myID = Convert.ToInt32(comm.ExecuteScalar());
    }
    catch (Exception ex)
    {
        return "ERROR: "+ex.Message;
    }
    finally
    {
        conn.Close();
    }

    return myID.ToString();
}

Javascript: Read URL GET Parameter from the browsers address bar that have been passed / commited

Problem

A javascript should read the browsers address bar to get GET Üarameters that have been appended to the adress bar.

Approach – Ansatz

Usage of decodeURIComponent

Solution

var getUrlParameter = function getUrlParameter(sParam) {
	var sPageURL = decodeURIComponent(window.location.search.substring(1)),
		sURLVariables = sPageURL.split('&'),
		sParameterName,
		i;

	for (i = 0; i < sURLVariables.length; i++) {
		sParameterName = sURLVariables[i].split('=');

		if (sParameterName[0] === sParam) {
			return sParameterName[1] === undefined ? true : sParameterName[1];
		}
	}
};

var myMap = getUrlParameter("map");
if (myMap) {
	diagramType = myMap;
}

You can call now the script like this:
http://webseite.html?map=Test

Intersector for Instagram: Which persons do I follow that aren’t following me back?

Hi!

I wanted to write a simple DIFF Tool, that shows the intersection of my followers and people who i am following. But after reading Instagrams review conditions it seems like to me, they are only giving support for companies. The client that is calling the REST API needs to request a permission „follower_list“ but they do not accept applications any longer for review.

This is the only output i can get from the API:

WordPress Plugin: Supported Languages of SyntaxHighlighter Evolved

Problem

It is unknown which [LANGUAGE][/LANGUAGE]-Tags are supported by the wordpress syntax highnlighting plugin.

Lösung – Solution

  • actionscript3
  • bash
  • clojure
  • coldfusion
  • cpp
  • csharp
  • css
  • delphi
  • diff
  • erlang
  • fsharp
  • go
  • groovy
  • html
  • java
  • javafx
  • javascript
  • latex (you can also render LaTeX)
  • matlab (keywords only)
  • objc
  • perl
  • php
  • powershell
  • python
  • r
  • ruby
  • scala
  • sql
  • text
  • vb
  • xml
\sum_{n=0}^{3}n=6

MS SQL Server: Last Index Of / lastIndexOf / Get last Index Of

Problem

There is no SQL Function to get the last index of a string.

Ansatz – Approach

The first two lines only declare a variable myString with content SER-SOP-12 to Test the combined SQL Functions.
The SELECT-Clause returns the lastIndex of (can be used in standard MS SQL Statements)

Lösung – Solution

Just copy it to the MS SQL Server Management Studio in a query window to test and press F5:

DECLARE @myString AS varchar(255)
SET @myString ='SER-SOP-12'
SELECT LEN(@myString )-CHARINDEX('-', REVERSE(@myString )) 

20 Buzzwords / Catchwords / Schlagwörter, die Sie 2018 möglichst oft in Besprechungen erwähnen sollten (Gartner und Forrester)

Die folgenden Wörter sollten möglichst oft in Besprechungen erwähnt werden, da sie die Kompetenz des Erwähners attestieren:

  1. Digitalisierung / Digitale Tranformation
  2. Internet of things (IoT) / Digital Twins
  3. Artificial Intelligence / Intelligent things
  4. Machine Learning / Deep learning
  5. Industrie 4.0
  6. Block Chain
  7. Cloud to the edge / Edge Computing
  8. Bit Coin
  9. Device Mesh
  10. Big Data / Data Warehouse / Data Mining / Information Retrieval
  11. Micro Services
  12. Zero Trust / Adaptive Sicherheitssysteme / Cybersecurity
  13. Customer Experience ( Aufbau einer emotionalen Bindung zwischen Anwender und Produkt oder Anbieter)
  14. Infrastructure as Service / Infrastructure as code (Cloud- und Softwaredefinierte Infrastruktur – https://en.wikipedia.org/wiki/Infrastructure_as_Code)
  15. BYOD – Bring your own device
  16. Green-Field-Ansatz (wir schmeissen alles weg und machens neu – soll die Strategie bei SAP S/4 HANA sein)
  17. Brute-Force-Methode (zur Problemlösung: alle möglichen Lösungen durchprobieren)
  18. Wow-Effekt (Begeisterungsauslöser)
  19. proaktiv (aus eigener Initiative getrieben)
  20. Bimodale IT (Schatten-IT vs. Kern-IT)

Nachfolgend ein Beispiel für die analoge Transformation des Snowman Lifecycles in Zeiten der voranschreitenden Digitalisierung, welche in einem Green-Field-Ansatz resultieren wird.

Get Microsoft Jet 4.0 Driver working on 64-Bit Windows Server

Problem

The Microsoft JET 4.0 Driver, which can open .MDB / Access Files, is only available for 32-Bit Systems

Ansatz – Approach

Register the DLLs for the operating system

Lösung – Solution

Solution 1 (Especially for IIS)

In IIS 7.x click on the app pool of your application -> advanced settings and look at the „General“ Section. The second Attribute is „Run in 32 Bit mode“. Check this.
Restart IIS.
If it is still not working, go on with Solution 2.

Im IIS Manager markiert man den AppPool der Anwendung und kann rechts auf „Advanced Settings“ (Erweiterte Einstellungen) klicken. Im „General“-Abschnitt (Allgemein) kann man im 2. Attribut sagen, man möchte im 32-Bit-Modus starten. Danach sollte der JET Treiber auch gehen.

Solution 2 (Especially for local applications)

The solution is to manually register those DLLs.

go to Start->Run and type cmd
this starts the Command Prompt
(also available from Start->Programs->Accessories->Command Prompt)

type cd .. and press return
type cd .. and press return again (keep doing this until the prompt shows :\> )

now you need to go to a special folder which might be c:\windows\system32 or it might be c:\winnt\system32 or it might be c:\windows\sysWOW64
try typing each of these eg
cd c:\windows\sysWOW64
(if it says The system cannot find the path specified, try the next one)
cd c:\windows\system32
cd c:\winnt\system32
when one of those doesn’t cause an error, stop, you’ve found the correct folder.

now you need to register the OLE DB 4.0 DLLs by typing these commands and pressing return after each

regsvr32 Msjetoledb40.dll
regsvr32 Msjet40.dll
regsvr32 Mswstr10.dll
regsvr32 Msjter40.dll
regsvr32 Msjint40.dll

GoJS: Conditional Binding / Bind to another attribute when binding not exists

Problem

When an attribute is not appearing in the diagram model (nodeArray), a different property should be selected

Ansatz – Approach

The third paramater of the Binding Constructor can be used to declare a function that handles the nodeData.

Lösung – Solution

// the node template describes how each Node should be constructed
      diagram.nodeTemplate =
        $(go.Node, "Auto",  // the Shape automatically fits around the TextBlock
          new go.Binding("location", "loc", go.Point.parse),
          $(go.Shape, "RoundedRectangle",  // use this kind of figure for the Shape
            // bind Shape.fill to Node.data.color
            new go.Binding("fill", "color")),
          $(go.TextBlock,
            { margin: 5, width: 100 },  // some room around the text
            // bind TextBlock.text to Node.data.key

            new go.Binding("text", "", 
              function(data) 
              { 
                return (data.text) ? data.text : data.key; 
              }
           ))
          );

Toyota Touch 2 ohne Go / Navi mit neuerem Samsung Handy verbinden / Screenmirror / Mirrorlink

Problem

Wer sich einen neuen Toyota kauft, bekommt meistens das Toyota Touch 2 als Radio und Multimedia-Display in der Mittelkonsole ausgeliefert. Möchte man daraus ein Android-Smartgerät machen, um das nicht vorhandene Navigationssystem (z.B. mit Google Maps oder der Sygic App) zu kompensieren, stößt man auf die Seit 2011 bekannte veraltete Mirrorlink 1.0 Version. Neuere Android-Geräte (älter als Galaxy S3 mit Android 4.3) unterstützen nur noch Mirrorlink 1.1, was bis dato (Februar 2018) nicht behoben wurde.

Ansatz

Es kann ein normales Micro-USB-Ladekabel/Datenkabel genutzt werden um das Handy mit dem Toyota Touch 2 zu verbinden.

Mögliche Lösungen

LG MirrorDrive auf auf Samsung Geräten installieren

1. LG MirrorDrive auf Samsung Smartphone installieren
2. in den Einstellungen/Töne und Benachrichtigungen/Anwendungsbenachrichtigungen/LG Mirrordrive/ die Benachrichtungen nicht zulassen
3. Button Savior für die Home Taste installieren
4. optional kann man den Nova Launcher oder ähnliche installieren
5. Samsung Smartphone anschließen und LG MirrorDrive starten

Altes Handy kaufen

Ein altes Galaxy S3 kann für 80 EUR bei Amazon erworben werden. Dies ist das einzige offiziell unterstützte Gerät. Anschließend lädt man DriveLink runter.

Toyota Touch 2 Update auf Mirrorlink 1.1

Toyota kündigt seit längerer Zeit (5 Jahre) in teilweise sehr widersprüchlichen Aussagen die Veröffentlichung einer Touch2-Software mit Mirrorlink 1.1. an. Evtl. muss man immer wieder nachhaken damit sie wirklich kommt.

Hab mich erst unter www.toyota-tech.eu registriert und angemeldet.

Anschließend unter folgendem Link:

http://www.toyota-tech.eu/CAL/VINDecode.aspx

Meine Fahrgestellnummer eingegeben und dann noch die Nummer vom Bulletin BE-0044T-0415

HDMI Verbindung – A/V Input

Es gibt ein Kabel-KIT, was allerdings erst nach Ausbauen des Gerätes an der Rückseite angebracht werden kann und einen HDMI-Input bietet. Nachteil ist, das man dann das Touchdisplay nicht für Eingaben verwenden kann.

Sygic Navigation App

Einige Nutzer berichten, es sei möglich die Sygic Navigation App mit einem Toyota Touch 2 zu verbinden. Auf der Website wird allerdings beschrieben, das man Mirrorlink 1.1. benötigt um sie zu nutzen.

Meine Lösung

Ich persönlich habe mir das alte Galaxy S3 von einer Bekannten geben lassen und die Drive Link App aus dem PlayStore installiert. Anschließend muss man nur noch das S3 per USB mit der USB-Buchse im Auto verbinden und auf die Erde/Telefon rechts klicken.

Wenn man die DriveLink App dann startet und kurz wartet erscheint unter dem „E-Mail“-Symbol das Icon für „Drive Link“:

Wenn es gestartet ist und man die Home-Taste auf dem Handy klickt kommt man in den Bildschirm:

Nach ein paar Sekunden öffnet sich wieder die DriveLink App:

Angeblich kann man den Background-Prozess, der die DriveLink-App aus Sicherheitsgründen immer wieder in den Vordergrund holt beenden. Ich habe noch nicht herausgefunden wie.

Idee

Raspberry Pi Projekt, was einen Mirrorlink 1.0 Server (Smartphone) emuliert

Der Aufbau von Mirrorlink-Anwendungen ist einfach – es gibt eine Anwendung, die auf die Funktionalitäten des Autos über die MirrorLink Common API zugreift. Die MirrorLink Common API sowie der MirrorLink Server ist Teil des Betriebssystems des Telefons. Das Telefon agiert als Server und die Head Unit (also das Toyota Touch 2) als Client, was die Dienste des Telefons in Anspruch nimmt. Ich habe in einem Artikel sogar gelesen, dass das VNC Protokoll (RealVNC) zum Einsatz kommt um die Bildschirminhalte zu übertragen.

Mein Kontakt mit Toyota

Auf meine Anfrage, ob es irgendwelche Boxen o.ä. für das Toyota Touch 2 ohne Go gäbe und wie ich die Head-Unit dazu bewegen kann Mirrorlink 1.1. fähig zu sein antwortete Toyota Großbritannien (wo auch der Avensis von Toyota produziert wird):

Mirrorlink is owned by a US Company and has no affiliation with 
Toyota. It is an Android compatible feature that allows compatible 
handsets to display approved apps from your phone on your cars 
infotainment system.

Mirrorlink has 2 versions currently (1.0 and 1.1), and a 3rd (1.2) 
is being developed and as such we have no timings or details of what 
it will contain or do. No version is compatible with the others. For 
instance if your car was version 1.0 and your phone was 1.1, they 
would not work together.

Apple do not currently support Mirrorlink.

The Toyota Touch 2 with Go system on software versions 4.1.1, 4.2.0, 
4.2.1, 4.3.0, 4.4.1 and 4.5.0 are Mirrorlink 1.0 compatible.

The Toyota Touch 2 with Go system on software versions 6 or later as 
well as the X-Nav and X-Toyota are Mirrorlink 1.1 compatible.

The only phone that was compatible with the Mirrorlink 1.0 system was 
the Samsung Galaxy S3.

Most modern Android (post 2015) phones running Android software 6 or 
later are compatible with Mirrorlink 1.1.

To use Mirrorlink with your car you need to have the phone connected 
via bluetooth with the car, and then connected via USB.

If your phone is Mirrorlink 1.0 you will need to download the 
Samsung DriveLink App from the App Store. If your phone is 
Mirrorlink 1.1 compatible you can enable Mirrorlink within the 
settings menu of the phone.

Once Mirrorlink is enabled you will be able to access the compatible 
Apps on your phone via the infotainment screen. To view compatible 
phones and applications please visit:

www.mirrorlink.com has very few apps are compatible, and if no 
compatible app is installed on your phone all you will see is a 
blank screen.

We are not aware of any additional boxes required to enable the 
Mirrorlink facility. Your vehicle will need to have a satellite 
navigation to be able to access the Mirrorlink facility through the 
Toyota Online Menu.

We would advise contacting the Toyota Head Office in Germany for 
further assistance as they will have knowledge of your vehicle 
specifications.

I hope this information helps.

Eine Anfrage bei Samsung ergab verwies auf den Autohersteller.

Eine weitere Anfrage direkt bei dem Toyota-Händler, bei dem ich den Avensis gekauft habe, führte zu einer erneuten Anfrage auf die der Mutterkonzert nicht antwortet.

Hallo Hr. XXXXX
 
Es wurde am 07.05.2018  eine Anfrage an Toyota Deutschland
 
per E-Mail von uns getätigt, bezüglich Ihrer Anfrage.(Sa. 05.05.18)
 
Wir haben aber noch keine Rückmeldung erhalten.
 
Sobald wir eine Antwort bekommen, werden wir uns umgehend bei Ihnen melden.
 
 
MfG. XXXXXX
 
Autodienst XXXX GmbH
Toyota Servicehändler
XXXX

by Björn Karpenstein