Deeplinking in eine WinForms-Anwendung

Preview:

DESCRIPTION

 

Citation preview

www.inqu.de

.NET User Group Dresden

Real World Scenario

Deeplinking in eine WinForms-Anwendung

01.03.2012

InQu Informatics GmbH

Marco Wagner

www.inqu.de

Marco Wagner | InQu Informatics GmbH | http://inqu.de | http://raumwolken.de

die vorhandene Anwendung

unternehmensinternes Bestellsystem WinForms-Client auf Terminalserver

www.inqu.de

Marco Wagner | InQu Informatics GmbH | http://inqu.de | http://raumwolken.de

das Ziel

Migration ins Web neue Features Einsparung Terminalserver

www.inqu.de

Marco Wagner | InQu Informatics GmbH | http://inqu.de | http://raumwolken.de

das (Zwischen)Ergebnis

Bestellansicht

www.inqu.de

Marco Wagner | InQu Informatics GmbH | http://inqu.de | http://raumwolken.de

Herausforderung

2 Systeme Medienbruch Win/Web „nicht aus einem Guß“

Mindestanforderung: Navigation zwischen beiden Systemen

www.inqu.de

Marco Wagner | InQu Informatics GmbH | http://inqu.de | http://raumwolken.de

Navigation zwischen Win & Web

von\nach Win Web

Win Nav zw. Modulen Hyperlink

Web ? Hyperlink

www.inqu.de

Marco Wagner | InQu Informatics GmbH | http://inqu.de | http://raumwolken.de

Nachrichten vom Web ins Win?

Skype? MSDN?

www.inqu.de

Marco Wagner | InQu Informatics GmbH | http://inqu.de | http://raumwolken.de

Custom URL Protocol

eigenen URL-Protokollhandler registrieren und implementieren

http:// ms-help:// skype://

shop://

MSDN: http://msdn.microsoft.com/en-us/library/ie/aa767914(v=vs.85).aspx

www.inqu.de

Marco Wagner | InQu Informatics GmbH | http://inqu.de | http://raumwolken.de

URL-Protokoll registrieren

siehe shop.reg in MessageDispatcher.csproj

www.inqu.de

Marco Wagner | InQu Informatics GmbH | http://inqu.de | http://raumwolken.de

Windows Registry

HKEY_CLASSES_ROOT COM-Registrierung; Dateitypen / Erweiterungen

HKEY_CURRENT_USER Profil aktueller User

HKEY_LOCAL_MACHINE Nutzerübergreifende Einstellungen

HKEY_USERS Nutzerstamm

HKEY_CURRENT_CONFIG Profil aktuelle Hardware

www.inqu.de

Marco Wagner | InQu Informatics GmbH | http://inqu.de | http://raumwolken.de

Kommunikation über Prozessgrenzen hinweg

Problem Prozesse haben separate Adressräume

Lösungen Pipes Events / Nachrichten Funktionsaufrufe / Remote Procedure Calls Shared Memory

www.inqu.de

Marco Wagner | InQu Informatics GmbH | http://inqu.de | http://raumwolken.de

Navigation von Web nach Win (auch) per Hyperlink

www.inqu.de

Marco Wagner | InQu Informatics GmbH | http://inqu.de | http://raumwolken.de

Demo Prototyp

siehe Solution

www.inqu.de

Marco Wagner | InQu Informatics GmbH | http://inqu.de | http://raumwolken.de

Übersicht Prototyp

www.inqu.de

Marco Wagner | InQu Informatics GmbH | http://inqu.de | http://raumwolken.de

Pause?

www.inqu.de

Marco Wagner | InQu Informatics GmbH | http://inqu.de | http://raumwolken.de

URL

shop://component=Bestellungen;id=2

www.inqu.de

Marco Wagner | InQu Informatics GmbH | http://inqu.de | http://raumwolken.de

URL via Dispatcher weiterreichen (Nachricht senden)

vgl. MessageDispatcher.Program

SendMessage schickt direkt ans Ziel und wartet bis Abarbeitung (Message Loop; synchron)

PostMessage legt Message in Queue und kehrt sofort zurück (Message Queue; asynchron)

[DllImport("user32.dll")] public static extern int SendMessage( IntPtr hWnd, int Msg, IntPtr wParam, ref WndMessage lParam);

www.inqu.de

Marco Wagner | InQu Informatics GmbH | http://inqu.de | http://raumwolken.de

URL/ Parameter im Legacy Shop verarbeiten (Nachricht empfangen)

siehe WndProc in LegacyShop

protected override void WndProc(ref Message m) … var messageData = (WndMessage)Marshal .PtrToStructure(m.LParam, typeof(WndMessage)); var message = Marshal.PtrToStringUni(messageData.lpData);

www.inqu.de

Marco Wagner | InQu Informatics GmbH | http://inqu.de | http://raumwolken.de

proprietäre Nachrichteninterpretation

var formatPattern = @"shop://component=(?<componentKey>\w+);id=(?<id>\d+)"; var match = Regex.Match(message, formatPattern); var componentKey = match.Groups["componentKey"].Value; var idText = match.Groups["id"].Value;

shop://component=Bestellungen;id=2

www.inqu.de

Marco Wagner | InQu Informatics GmbH | http://inqu.de | http://raumwolken.de

Fragen?

www.inqu.de

Marco Wagner | InQu Informatics GmbH | http://inqu.de | http://raumwolken.de

Slides & Code

demnächst auf http://raumwolken.de http://dd-dotnet.de/

Fragen marco.wagner@inqu.de

Recommended