Forum
Forum
 |    |  |  | |  |  | |  |  | |  |  | |  | |
 | | |
| Re: Upgrading the BankHoliday with time (Germany) |
|
|
Calrouting scripts in v6.10 are still able to access the local hard disk. You have to change the script, however, because it uses PBXUser.Datafolder as root path to find the text file. In v6.10 PBXUser.Datafolder points to a temporary folder.
Change the script to use a fixed location on the hard disk and make sure that the file is located on a shared folder so that it can be accessed from a client PC. Martin HüserProduct Manager, Scrum Product Owner, Swyx Solutions AG |
|
|
|  |  | | |
| Re: Upgrading the BankHoliday with time (Germany) |
|
|
Hi everbody,
is there an updated way to realise this script with 6.10 (6.11) ? I couldnt get it to work with this vbs-code:
' FileOpen iomode Values
Const fsoForReading = 1
Const fsoForWriting = 2
Const fsoForAppending = 8
' Bankholiday Filename
Const sBHFilename = "bankholiday.txt"
Function IsBankHoliday ( vDate )
Dim wsh, fso, file
Dim sDir, sFile, sLine
Dim bReturn, nPos
bReturn = False
' get share path by extracting it from user folder
sDir = C:\
nPos = InStrRev(sDir, "\")
sDir = Left(sDir, nPos-1)
nPos = InStrRev(sDir, "\")
sDir = Left(sDir, nPos)
' Build file name. Textfile will be located within the global script directory, e.g.
' --> C:\Program Files\SwyxWare\Share\Data\PhoneClient\Scripts\bankholiday.txt
sFile = sDir & "holiday\" & sBHFilename
' Create FileSystemObejct
Set fso = CreateObject("Scripting.FileSystemObject")
' Open text file
Set file = fso.OpenTextFile(sFile, fsoForReading)
do while (not (file.AtEndOfStream)) and (not bReturn)
sLine = file.ReadLine
if IsDate(sLine) then
if DateDiff("d", vDate, CDate(sLine)) = 0 then bReturn = True
end if
loop
file.Close
Set file = Nothing
Set fso = Nothing
IsBankHoliday = bReturn
End Function
C:\holiday and the file within it is just for testing purposes, it exists on the server and the client as well, but the script just wont work (even worse: when this script is active, other scripts wont run either...very strange)
Best regards,
Marco |
|
|
|  |  | | |
| Re: Upgrading the BankHoliday with time (Germany) |
|
|
The reason why other scripts also seizes to work is easy: your current script causes a runtime error which ends the call automatically.
Suggestion: replace all the following code
' get share path by extracting it from user folder
sDir = C:\
nPos = InStrRev(sDir, "\")
sDir = Left(sDir, nPos-1)
nPos = InStrRev(sDir, "\")
sDir = Left(sDir, nPos)
' Build file name. Textfile will be located within the global script directory, e.g.
' --> C:\Program Files\SwyxWare\Share\Data\PhoneClient\Scripts\bankholiday.txt
sFile = sDir & "holiday\" & sBHFilename
by
sFile = "C:\holiday.txt"
Further more make sure, that the user the SwyxServer service is running under has at least read access to this file.
Tom Wellige
(Lead Solution Consultant, Swyx)
I learned very early the difference between knowing the name of something and knowing something.
Richard P. Feynman
|
|
|
|  |  | | |
| Re: Upgrading the BankHoliday with time (Germany) |
|
|
This solution works, thanks!
Marco |
|
|
|  |  | | |
| Re: Upgrading the BankHoliday with time (Germany) |
|
|
You're welcome 
The reason for the replaced code was that in the past the file was located in the global sript folder. So the path needed to be calculated.
As there is no global script folder from v6.10 on the file needs to be located somewhere else. Of course it was also previously possible to do so. The idea behind using the global script folder was to keep all things related to each other together at one place.
Regards, Tom.
Tom Wellige
(Lead Solution Consultant, Swyx)
I learned very early the difference between knowing the name of something and knowing something.
Richard P. Feynman
|
|
|
|  |  | | |
| Re: Upgrading the BankHoliday with time (Germany) |
|
|
This makes sense. Im glad of having a database since 6.10 :-) And thanks for the pretty fast reply as well! :-) |
|
|
|  |  | | |
| Re: Upgrading the BankHoliday with time (Italy) |
|
|
Hello everybody,
I'm trying to use the script on a 6.12 version, but I always have disconnected. I have done the modify in the VB code of Start block as suggested by Tom, but nothing has changed. I'll copy here the actual VB code, please tell me where's the error if possible, thanks:
' FileOpen iomode Values
Const fsoForReading = 1
Const fsoForWriting = 2
Const fsoForAppending = 8
Function IsBankHoliday ( vDate )
Dim wsh, fso, file
Dim sDir, sFile, sLine
Dim bReturn, nPos
bReturn = False
sFile = "C:\holiday.txt"
' Create FileSystemObejct
Set fso = CreateObject("Scripting.FileSystemObject")
' Open text file
Set file = fso.OpenTextFile(sFile, fsoForReading)
do while (not (file.AtEndOfStream)) and (not bReturn)
sLine = file.ReadLine
if IsDate(sLine) then
if DateDiff("d", vDate, CDate(sLine)) = 0 then bReturn = True
end if
loop
file.Close
Set file = Nothing
Set fso = Nothing
IsBankHoliday = bReturn
End Function
And the text file content:
31.10.2008
Seems if like the rule is skipped...any idea?
Thanks
thomas |
|
|
|  |  | | |
| Re: Upgrading the BankHoliday with time (Germany) |
|
|
Take a look into the Windows Event Log or the Swyx Server trace file. What kind of error message do you find there ?
Just a shot into the dark: make sure the regional settings of the server machine (in terms of date format) match the date format given in the BankHoliday.txt file.
I had a case lately from Italy where the regional setting was configured to DD/MM/YYYY, but the dates given in the text file where DD.MM.YYYY. Just modify the content of the text file to match the regional settings of the server machine.
Tom.
Tom Wellige
(Lead Solution Consultant, Swyx)
I learned very early the difference between knowing the name of something and knowing something.
Richard P. Feynman
|
|
|
|  |  | | |
| Re: Upgrading the BankHoliday with time (Italy) |
|
|
Möchte mich schon vorab für die verwendete Sprache entschuldigen, mein Englisch reicht leider nicht...
Bin grad fleissig beim Testen und Probieren mit diesem schönen Skript, ich hätte es gerne dahingehend erweitert, dass in der Zeile der Feiertage hinten eine Rufnummer stehen kann, auf die dann entsprechend weitergeleitet wird. Wir haben in unserer Firma abwechselnd Bereitschaftsdienst und planen dies immer bereits für ein ganzes Jahr voraus, es wäre supertoll, wenn Swyx dahingehend vollautomatisiert werden könnte, ohne dass jeweils die Nummer, auf die umgeleitet wird, geändert werden muss.
Andere Frage: wo finde ich das TraceLog, um evtl. Fehler im Skript zu finden?
Schon mal vielen Dank im Voraus! |
|
|
|  |  | | |
| Re: Upgrading the BankHoliday with time (Germany) |
|
|
| Supra wrote
ich hätte es gerne dahingehend erweitert, dass in der Zeile der Feiertage hinten eine Rufnummer stehen kann, auf die dann entsprechend weitergeleitet wird.
|
- haenge einfach die weitere Nummer mittels Semikolon getrennt hinten an jedes Zeile
- im Script wird jedes Zeile ja per ReadLine in eine Variable eingelesen und anschliessend
- per Split in die einzelnen Bestandteile zerlegt.
- die Nummer auf die Du zustellen willst, steht jetzt in aRange(2)
- achte aber drauf, dass jetzt auf alle Faelle auch immer die Datums und Uhrzeit Angaben in der Textdatei gesetzt sind, sonst geht das schief
- ich wuerde mit jetzt eine globale Variable anlegen und die Nummer dort hinein kopieren (Dim sDurchstellen)
- innerhalb des Durchstellen Block kannst Du die jetzt direkt verwenden: = sDurchstellen
Supra wrote
Andere Frage: wo finde ich das TraceLog, um evtl. Fehler im Skript zu finden?
|
Script Tracing landet im Server Trace. Und zwar muss dazu das Trace Modul SrvScript auf Info3 (= 6) stehen. Weitere Infos zum Thema Tracing findet Du hier:
Hoffe, das hilft erstmal weiter.
Viele Gruesse, Tom.
Tom Wellige
(Lead Solution Consultant, Swyx)
I learned very early the difference between knowing the name of something and knowing something.
Richard P. Feynman
|
|
|
|  |  | | |
| Re: Upgrading the BankHoliday with time (Italy) |
|
|
Vielen Dank, so ähnlich bzw. genauso hatte ich das auch probiert, aber offensichtlich sind die Scripts so "empfindlich", dass beim kleinsten Fehler nichts mehr geht (ist ja auch klar), wie könnte man solche Scripts ausserhalb con Swyx testen bzw. welche Software/Debugger würdest Du empfehlen? |
|
|
|  |  | | |
| Re: Upgrading the BankHoliday with time (Germany) |
|
|
Speicher den VBScript Code aus dem Start Block einfach als VBS Datei ab, und nimm anstelle von PBXScript.OutputTrace -> WScript.Echo. Dann kannst Du das ganze normal von der Konsole aus starten (natuerlich musst Du in der VBS Datei auch irgendwo die Funktion IsBankHoliday einmal von Hand aufrufen) und bei Bedarf auch den Microsoft Script Debugger mit dran haengen.
Darueber hinaus findet Du am Ende des folgenden KB Artikels auch ein paar Hinweise zum Thema "Fehlerbehandlung in Call Routing Skripten":
Tom Wellige
(Lead Solution Consultant, Swyx)
I learned very early the difference between knowing the name of something and knowing something.
Richard P. Feynman
|
|
|
|  |  | | |
| Re: Upgrading the BankHoliday with time (Germany) |
|
|
Man kann sich das Ändern der Ausgabestatements zu WScript.Echo auch sparen, indem man eine eigene Implementierung von PBXScript für externe Tests baut:
option explicit
' stub for the PBXScript object
' implements tracing and CreateObject functions only
class PBXScriptClass
private currentTraceLevel
public Sub PBXScriptClass_Initialize
currentTraceLevel = 4
end sub
public property let TraceLevel(value)
currentTraceLevel = value
end property
public property get TraceLevel
TraceLevel = currentTraceLevel
end property
sub OutputTrace(msg)
WScript.Echo msg
end sub
sub OutputTraceEx(level, msg)
if currentTraceLevel >= level then
WScript.Echo msg
end if
end sub
function CreateObject(o)
CreateObject = WScript.CreateObject(o)
end function
end class
dim PBXScript
set PBXScript = new PBXScriptClass
PBXScript.TraceLevel = 4
' load test code
PBXScript.OutputTrace "Testing custom VBScript " & WScript.Arguments(0)
dim oFSO
set oFSO = WScript.CreateObject("Scripting.Filesystemobject")
dim oFile
set oFile = oFSO.OpenTextFile(WScript.Arguments(0))
dim scriptToExecute
scriptToExecute = oFile.ReadAll
ExecuteGlobal scriptToExecute
PBXScript.OutputTrace "Done"
Diesen Code speichert man als ecrtest.vbs ab. Sein eigenes Script testet man dann mit
cscript.exe ecrtest.vbs myscript.vbs Martin HüserProduct Manager, Scrum Product Owner, Swyx Solutions AG |
|
|
|  |  | | |
| Re: Upgrading the BankHoliday with time (Italy) |
|
|
Beides sehr hilfreiche Tips, bin schon mal einen großen Schritt weiter... Danke! |
|
|
|  |  | | |
| Re: Upgrading the BankHoliday with time (Italy) |
|
|
Das Script hätte ich soweit:
Const sBuildNo = "1.0.1"
' FileOpen iomode Values
Const fsoForReading = 1
Const fsoForWriting = 2
Const fsoForAppending = 8
' Bankholiday Filename
Const sBHFilename = "BankHoliday.txt"
' use global script folder (oder users script folder ?
Const bGlobal = True
Function IsHotline ( vDate )
PBXScript.OutputTrace "--------> IsHotline ( " & CStr(vDate) & " ) - v" & sBuildNo
Dim wsh, fso, file
Dim sFile, sLine
Dim bReturn, nPos
Dim bRange, aRange, vStart, vEnd
Dim HotlineNummer
bReturn = False
if bGlobal then
sFile = "e:\swyx\ecr\hotline.txt"
else
sFile = "e:\swyx\ecr\hotline.txt"
end if
PBXScript.OutputTrace sFile
' Create FileSystemObejct
Set fso = CreateObject("Scripting.FileSystemObject")
' Open text file
Set file = fso.OpenTextFile(sFile, fsoForReading)
do while (not (file.AtEndOfStream)) and (not bReturn)
sLine = file.ReadLine
PBXScript.OutputTrace "sLine: " & sLine
bRange = False
aRange = Split(sLine, ";")
if IsDate(aRange(0)) then
vStart = CDate(aRange(0))
PBXScript.OutputTrace "vStart: " & CStr(vStart)
if UBound(aRange) > 0 then
if IsDate(aRange(1)) then
bRange = True
vEnd = CDate(aRange(1))
PBXScript.OutputTrace "vEnd: " & CStr(vEnd)
else
PBXScript.OutputTrace "invalid end date!"
end if
end if
if not bRange then
if (DateDiff("d", vDate, vStart) = 0) then bReturn = True
else
if (DateDiff("n", vStart, vDate) >= 0) and _
(DateDiff("n", vEnd, vDate) <= 0) then bReturn = True
end if
else
PBXScript.OutputTrace "invalid start date!"
end if
loop
HotlineNummer = aRange(2)
if HotlineNummer = "Supra1" then
HotlineNummer = "0348xxx"
end if
PBXScript.OutputTrace "Hotlinenummer: " & HotlineNummer
file.Close
Set file = Nothing
Set fso = Nothing
IsHotline = bReturn
PBXScript.OutputTrace "<-------- IsHotline returns: " & CStr(bReturn)
End Function
Genügt es aber, wenn ich beim Durchstellen-Block nun Ruf durchstellen für 90 Sekunden zu: =HotlineNummer schreibe?
Leider funktioniert mir das schon bei einer Mail-Benachrichtigung nicht, also mache ich da wohl etwas falsch. |
|
|
|  |  | | |
| Re: Upgrading the BankHoliday with time (Germany) |
|
|
| Supra wrote
Genügt es aber, wenn ich beim Durchstellen-Block nun Ruf durchstellen für 90 Sekunden zu: =HotlineNummer schreibe?
|
Wichtig ist, dass Du die Variable HotlineNummer nicht innerhalb des Variable Blocks definiert, sondern tatsaechlich per
Dim HotlineNummer
im VBScript Code als globale Variable. Das hat was damit zu tun, wie der GSE den VBScript Code generiert. Variablen die Du im grafischen Teil des Skriptes definiert hast, sind im VBSCript Code des Startblocks nicht sichtbar !
Grund: der GSE erzeugt eine VBScript Funktion aus dem grafischen Skript. Alle dort verwendeten Variablen werden als lokale Variablen dieser Funktion definiert. Dein VBScript Code aus dem Start Block wird einfach vor diese Funktionsdefinition kopiert. Damit kann er nicht auf lokale Variablen der GSE Funktion zugreifen. Anders herum klappt das aber einwandfrei: Variablen, die Du global in Deinem VBScript Code im Start Block definierst sind problemlos im kompletten Skript ansprechbar.
Davon abgesehen: ja, es reicht aus in den Durchstellen Block einfach = HotlineNummer zu schreiben.
| Supra wrote
Leider funktioniert mir das schon bei einer Mail-Benachrichtigung nicht, also mache ich da wohl etwas falsch.
|
Ich vermute mal, dass das an dem zuvor geschilderten liegt, richtig ?
Gruss, Tom.
Tom Wellige
(Lead Solution Consultant, Swyx)
I learned very early the difference between knowing the name of something and knowing something.
Richard P. Feynman
|
|
|
|  |  | | |
| Re: Upgrading the BankHoliday with time (Italy) |
|
|
Jepp, das wars, es ist also wichtig, WO dieses Dim HotlineNummer steht....
Tausend Dank, wieder ein Problem gelöst, heute ist ein guter Tag :-) |
|
|
|  |  | | |
| Re: Upgrading the BankHoliday with time (Germany) |
|
|
| Supra wrote
Jepp, das wars, es ist also wichtig, WO dieses Dim HotlineNummer steht....
|
Wichtig zu wissen ist, dass Du auf Variablen die Du im grafischen Teil des Skriptes definiert hast, im VB Skript Teil im Start Block keinen Zugriff hast. Die Loesung dafuer sind entweder global im Start Block definierte Variablen oder aber man uebergibt alles als Funktionsparameter bzw. Funktionsrueckgabewerte.
Ich gebe zu, da kann man schonmal leicht drueber stolpern.
Wenn es Dich interessiert solltest Du Dir aus der Datenbank mal Deine Regel (ruleXXX.vbs) exportieren und Dir den Code darin ansehen. Da wird das dann sehr schnell ersichtich.
Viele Gruesse, Tom.
Tom Wellige
(Lead Solution Consultant, Swyx)
I learned very early the difference between knowing the name of something and knowing something.
Richard P. Feynman
|
|
|
|  |  | | |
| Re: Upgrading the BankHoliday with time (Germany) |
|
|
| Hallo zusammen,funktioniert das Script denn auch noch unter 2011 R2 ? |
|
|
|  |  | | |
| Re: Upgrading the BankHoliday with time (Germany) |
|
| |
|
|  |  | |  |  | |  |  | |  |
|
Forum PolicyThe discussion forums at Swyx Forum are dedicated to the discussion of Swyx, SwyxWare and related topics. For the benefit of the community and to protect the integrity of swyx-form, please observe the following posting guidelines: - No Advertising. This includes promotion of commercial products and non-commercial products which are not directly related to SwyxWare, it's OEM versions.
- No Flaming or Trolling.
- No Profanity, Racism, or Prejudice.
- Furthermore, make sure your posts comply to our Terms of Use.
- Newest development in German law defines online forums as journalistic content, making the forum owner and all posters to journalists. With this statement the forum owner declares that neither he nor his users are journalists with all legal consequences.
- The German Jugendmedienschutz-Staatsvertrag (JMStV) (Protection of Minors) defines a disclosure of online medias which are not suitable for minors below the age of 18. The Swyx Forum webseite does not provide any such content and underlies therefore not this disclosure. Please see further details including the responsible person for the protection of minors and direct contact data in the Imprint.
- The forums are currently unmoderated, meaning all postings will appear immediately after submission. If this turns out not working due to massive abuse all forums will switch to moderated mode, meaning a posting must be approved after submission my a moderator before appearing.
- You can use any language you like (except for the project forums) but keep in mind that by using english you will reach the largest audience.
- Within the project forums english language is mandatory.
|
|
 | |  | | 
The default language in the forums is english, but feel free to use your mother tongue. Just keep in mind that by using english you will reach the largest audience. | | | | | | | |
|