Obecná propojka přes RDP

Nahoru  Předchozí  Další

Tato propojka funguje obdobně jako Obecná propojka, s tím rozdílem, že se používá výhradně při připojení přes RDP (remote desktop protocol).

 

Příklady:

CliniView
Sidexis

 

Potřebné kroky ke zprovznění propojky, příklad CliniView:

1.V DENTIST+ je potřeba nadefinovat Obecnou propojku pro RDP:
a.Název spustitelného souboru na klientském počítači: CliniView.vbs
b.Maska pre argumenty: "{RC}" "{Prijmeni}" "{Jmeno}"
(argumenty je nutné uzavřít do úvozovek)
2.Na straně RDP klienta:
a.Nainatalovat CGM RDP Client, instalační balíček se dá stáhnout ze stránek Ke stažení (CgmRdpClient.msi)
(instalace nezabere na případné již existující RDP připojení)
b.do adresáře "C:\Program Files (x86)\CGM.RdpDvcClient\Scripts" nakopírovat CliniView.vbs
(nutné v něm upravit cesty k EXE a INI souborům)

 

Obsah CliniView.vbs

Option Explicit

 

Dim fso, iniFile, args, patid, patlname, patfname

Dim section, lines, line, foundSection, i, key

Dim iniPath, exePath

 

' Paths

iniPath = "C:\Aaa\CliniView\Ini\CliniView.ini"

exePath = "C:\Aaa\CliniView\CliniView.exe"

 

Set args = WScript.Arguments

If args.Count < 3 Then

    WScript.Echo "Usage: CliniView.vbs PATID PATLNAME PATFNAME"

    WScript.Quit 1

End If

 

patid = args(0)

patlname = args(1)

patfname = args(2)

 

section = "[PracticeManagementInterface]"

 

Set fso = CreateObject("Scripting.FileSystemObject")

 

If fso.FileExists(iniPath) Then

    Set iniFile = fso.OpenTextFile(iniPath, 1, False)

    lines = Split(iniFile.ReadAll, vbCrLf)

    iniFile.Close

Else

    lines = Array()

End If

 

' Prepare new key-values

Dim newValues

Set newValues = CreateObject("Scripting.Dictionary")

newValues.Add "USE_PRACTICE_MANAGEMENT", "1"

newValues.Add "CLEAR_PRACTICE_MANAGEMENT_AUTOMATICALLY", "1"

newValues.Add "PATID", patid

newValues.Add "PATLNAME", patlname

newValues.Add "PATFNAME", patfname

 

foundSection = False

 

' Rebuild file line by line

Dim resultLines()

ReDim resultLines(0)

Dim resultCount : resultCount = 0

 

For i = 0 To UBound(lines)

    line = lines(i)

    

    If Trim(UCase(line)) = UCase(section) Then

        foundSection = True

        resultLines(resultCount) = section

        resultCount = resultCount + 1

        ReDim Preserve resultLines(resultCount)

        

        ' Add new values instead of reading existing

        For Each key In newValues.Keys

            resultLines(resultCount) = key & "=" & newValues(key)

            resultCount = resultCount + 1

            ReDim Preserve resultLines(resultCount)

        Next

        

        ' Skip old section content

        Do While i + 1 <= UBound(lines)

            If Left(Trim(lines(i + 1)), 1) = "[" Then

                resultLines(resultCount) = "" ' blank line between sections

                resultCount = resultCount + 1

                ReDim Preserve resultLines(resultCount)

                Exit Do

            End If

            i = i + 1

        Loop

        

    Else

        resultLines(resultCount) = line

        resultCount = resultCount + 1

        ReDim Preserve resultLines(resultCount)

    End If

Next

 

If Not foundSection Then

    resultLines(resultCount) = section

    resultCount = resultCount + 1

    ReDim Preserve resultLines(resultCount)

 

    For Each key In newValues.Keys

        resultLines(resultCount) = key & "=" & newValues(key)

        resultCount = resultCount + 1

        ReDim Preserve resultLines(resultCount)

    Next

End If

 

' Write back to file

Set iniFile = fso.OpenTextFile(iniPath, 2, True)

For i = 0 To resultCount - 1

    If i = resultCount - 1 Then

        iniFile.Write resultLines(i) ' without ending CRLF

    Else

        iniFile.WriteLine resultLines(i)

    End If

Next

iniFile.Close

 

' Run the CliniView executable

Dim shell

Set shell = CreateObject("WScript.Shell")

shell.Run """" & exePath & """", 1, False

 

 

Příklad použití Obecné propojení pro RDP s programem Sidexis:

V DENTIST+ je třeba nadefinovat Obecné propojení pro RDP:
oNázev spustitelného souboru na klientském počítači: Sidexis.vbs.
oMaska pro argumenty: "{RC}" "{Příjmení}" "{Jméno}" "{DatNar:dd.MM.yyyy}" "{SexMF}" "{Doktor}" (argumenty je třeba uzavřít do uvozovek).
Na straně RDP klienta:
oNainatalovat CGM RDP Client, instalační balíček se dá stáhnout ze stránek Ke stažení (CgmRdpClient.msi)
(instalace nezabere na případné existující RDP připojení)
oDo adresáře "C:\Program Files (x86)\CGM.RdpDvcClient\Scripts" nakopírovat Sidexis.vbs (je třeba v něm upravit cesty k EXE a SDX souborům).

 

Obsah Sidexis.vbs

Option Explicit

 

' ======= Nastavenie =======

Dim sdxPath : sdxPath = "C:\SIDEXIS\Propoj.sdx"  ' <- upravit podle potřeby

Dim exePath : exePath = "C:\SIDEXIS\Sidexis.exe" ' <- upravit podle potřeby

 

' ======= Vstupné argumenty =======

If WScript.Arguments.Count < 6 Then

    WScript.Echo "Použití: Sidexis.vbs <rodneCislo> <priezvisko> <meno> <datumNarodenia> <pohlavie> <doctor>"

    WScript.Quit 1

End If

 

Dim rodneCislo : rodneCislo = WScript.Arguments(0)

Dim priezvisko : priezvisko = WScript.Arguments(1)

Dim meno       : meno       = WScript.Arguments(2)

Dim datumNar   : datumNar   = WScript.Arguments(3)

Dim pohlavie   : pohlavie   = UCase(WScript.Arguments(4))

Dim doctor     : doctor     = WScript.Arguments(5)

 

' ======= Úprava parametrov =======

If Len(priezvisko) > 32 Then priezvisko = Left(priezvisko, 32)

If Len(meno) > 32 Then meno = Left(meno, 32)

 

If Len(rodneCislo) > 20 Then

    WScript.Echo "Patient ID too long"

    WScript.Quit 2

End If

 

If pohlavie <> "M" And pohlavie <> "F" Then pohlavie = ""

 

If Len(doctor) > 12 Then doctor = Left(doctor, 12)

 

Dim station : station = CreateObject("WScript.Network").ComputerName

If Len(station) = 0 Then

    WScript.Echo "Cannot determine machine name"

    WScript.Quit 3

End If

If Len(station) > 20 Then station = Left(station, 20)

 

Dim sender : sender = "\\" & station & "\DENTIST+"

Dim receiver : receiver = "\\*\SIDEXIS"

 

Dim nowDate : nowDate = Now

Dim dateOfCall : dateOfCall = Right("0" & Day(nowDate), 2) & "." & _

                                Right("0" & Month(nowDate), 2) & "." & Year(nowDate)

Dim timeOfCall : timeOfCall = Right("0" & Hour(nowDate), 2) & ":" & _

                                Right("0" & Minute(nowDate), 2) & ":" & _

                                Right("0" & Second(nowDate), 2)

 

' ======= Zostavenie záznamov =======

Dim recordN

recordN = Chr(0) & "N" & Chr(0) & _

          priezvisko & Chr(0) & meno & Chr(0) & datumNar & Chr(0) & _

          rodneCislo & Chr(0) & pohlavie & Chr(0) & doctor & Chr(0) & _

          sender & Chr(0) & receiver & vbCrLf

 

Dim recordA

recordA = Chr(0) & "A" & Chr(0) & _

          priezvisko & Chr(0) & meno & Chr(0) & datumNar & Chr(0) & _

          rodneCislo & Chr(0) & station & Chr(0) & dateOfCall & Chr(0) & _

          timeOfCall & Chr(0) & sender & Chr(0) & receiver & vbCrLf

 

' ======= Zápis do súboru =======

Dim stream

Set stream = CreateObject("ADODB.Stream")

stream.Type = 2 ' adTypeText

stream.Charset = "cp852"

stream.Open

 

stream.writetext Chr(Len(recordN) + 1)

stream.WriteText recordN

stream.writetext Chr(Len(recordA) + 1)

stream.WriteText recordA

 

stream.SaveToFile sdxPath, 2 ' adSaveCreateOverWrite

stream.Close

 

' ======= Spustenie Sidexis =======

Dim shell

Set shell = CreateObject("WScript.Shell")

shell.Run """" & exePath & """", 1, False