-
Notifications
You must be signed in to change notification settings - Fork 0
/
EssBaseWF.vbs
1126 lines (945 loc) · 40.2 KB
/
EssBaseWF.vbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
window.ReSizeTo 1200,900
' WebServices
Function getSVXMLAnswer (vCurrURL,vCurrRequest)
On Error Goto 0 'Resume next
set objServerXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP")
Dim lResolve,lConnect,lSend,lReceive
objServerXMLHTTP.open "POST", vCurrURL,false
objServerXMLHTTP.setRequestHeader "Content-Type", "text/xml; charset=UTF-8"
objServerXMLHTTP.setRequestHeader "Content-Length", Len(vCurrRequest)
objServerXMLHTTP.send vCurrRequest
Dim objDOMDocument
Set objDOMDocument = CreateObject("MSXML.DOMDocument")
objDOMDocument.loadXML Trim(Replace(objServerXMLHTTP.responseXML.xml, vbCrLf, ""))
set objServerXMLHTTP = nothing
set getSVXMLAnswer = objDOMDocument
set objDOMDocument = nothing
End Function
Dim objServerXMLHTTPASync
Dim vCalcCurrScriptName
Dim vPreviousScriptName
Function writeCalcStatus ( )
if (4 <> objServerXMLHTTPASync.readyState ) then
getSleepy
exit Function
end if
dim strHTML
strHTML = OutStatusCalculation.InnerHTML
Dim objDOMDocument
Set objDOMDocument = CreateObject("MSXML.DOMDocument")
objDOMDocument.loadXML Trim(Replace(objServerXMLHTTPASync.responseXML.xml, vbCrLf, ""))
set objServerXMLHTTPASync = nothing
Dim strStatusCalculation
strStatusCalculation = getXMLValue(objDOMDocument,"/vScriptName")
set objDOMDocument = nothing
if ( Instr(strStatusCalculation,"11") > 0 ) then
dim strHTML2,objDivID
if (len (vPreviousScriptName) > 0 ) then
Set objDivID = document.getElementById("btnRun" & vPreviousScriptName )
else
Set objDivID = document.getElementById("btnRun" & vCalcCurrScriptName )
end if
objDivID.innerHTML = objDivID.innerHTML & " <div class=""description"">               Finished : " & Time & "</div> " ' <div class=""item""> <div class=""content"">
runStatus.InnerHTML = ""
if len (vPreviousScriptName) > 0 then
WriteLog vCalcCurrScriptName & ";" & " finish"
else
WriteLog vConnApp & "." & vConnDb & "." & vCalcCurrScriptName & ";" & " finish"
end if
else
strHTML = strHTML & "<br>" & Time & " " & vCalcCurrScriptName & " calc status <BR> " & strStatusCalculation
end if
'alert strHTML
OutStatusCalculation.InnerHTML = strHTML
getSleepy
call setButtonOnFinish
doHttpOnReadyStateChange=0
if len (vPreviousScriptName) > 0 then
vGlobalRunnedCSCID=vGlobalRunnedCSCID + 1
call runCurrentRuleByID (vGlobalRunnedCSCID)
end if
end Function
sub setButtonOnFinish
runbutton.disabled = false
hideCsCbutton.disabled = false
loadCsCbutton.disabled = false
fScheduleFormName.cscRUN.disabled = false
end sub
Sub getSVXMLAnswerAsyncCalc (vCurrURL,vCurrRequest,vCurrCalcScriptName,vCurrPreviousScriptName)
On Error Goto 0 'Resume next
strHTML = OutStatusCalculation.InnerHTML
vCalcCurrScriptName = vCurrCalcScriptName
vPreviousScriptName = vCurrPreviousScriptName
set objServerXMLHTTPASync = CreateObject("MSXML2.ServerXMLHTTP")
objServerXMLHTTPASync.setTimeouts 5000, 5000, 15000, 10000000
objServerXMLHTTPASync.OnReadyStateChange = GetRef("writeCalcStatus")
objServerXMLHTTPASync.open "POST", vCurrURL,true
objServerXMLHTTPASync.setRequestHeader "Content-Type", "text/xml; charset=UTF-8"
objServerXMLHTTPASync.setRequestHeader "Content-Length", Len(vCurrRequest)
objServerXMLHTTPASync.send vCurrRequest
End Sub
Function getXMLNodeValue (vCurrobjDOMDocument,vNodeAddress)
On Error Resume Next
dim objCurrNode
Set objCurrNode = vCurrobjDOMDocument.selectSingleNode(vNodeAddress)
getXMLNodeValue = objCurrNode.text
set objCurrNode = nothing
On Error Goto 0
end function
Function getXMLValue (vCurrobjDOMDocument,vNodeAddress)
On Error Resume Next
getXMLValue = vCurrobjDOMDocument.lastchild.xml
On Error Goto 0
end function
function getSID ( vURL,vCurrUserName,vCurrPassword)
On Error Goto 0
Dim vRequest
vRequest = "<req_ConnectToProvider> " _
& " <usr>" & vCurrUserName & "</usr>" _
& " <pwd>" & vCurrPassword & "</pwd>" _
& "</req_ConnectToProvider>"
Dim objDOMDocument
Set objDOMDocument = getSVXMLAnswer(vURL,vRequest)
getSID = getXMLNodeValue(objDOMDocument,"/res_ConnectToProvider/sID")
Set objDOMDocument = Nothing
if 0 = len(getSID) Then
pErrorHandler "getSID error" ,1
end if
end function
function getSSO ( vURL,vCurrSID )
On Error Goto 0
Dim vRequest
vRequest = "<req_GetSSOToken> " _
& " <sID>" & vCurrSID &"</sID>" _
& "</req_GetSSOToken>"
Dim objDOMDocument
Set objDOMDocument = getSVXMLAnswer(vURL,vRequest)
getSSO = getXMLNodeValue(objDOMDocument,"/res_GetSSOToken/sso")
Set objDOMDocument = Nothing
if 0 = len(getSSO) Then
pErrorHandler "getSSO error" ,1
end if
end function
function getOpennedApplication ( vCurURL,vCurrSID,vCurrSSO,vCurrEssbaseServer,vCurrAppName )
On Error Goto 0
Dim vRequest
vRequest = "<req_OpenApplication> " _
& " <sID>" & vCurrSID & "</sID> " _
& " <srv>" & vCurrEssbaseServer & "</srv> " _
& " <app>" & vCurrAppName & "</app> " _
& " <sso>" & vCurrSSO & "</sso> " _
& "</req_OpenApplication>"
'alert vRequest
Dim objDOMDocument
Set objDOMDocument = getSVXMLAnswer(vCurURL,vRequest)
getOpennedApplication = getXMLNodeValue(objDOMDocument,"/res_OpenApplication")
Set objDOMDocument = Nothing
if 0 = len(getOpennedApplication) Then
pErrorHandler "getOpennedApplication error" ,1
end if
end function
function getOpennedCube ( vURL,vCurrSID,vCurrSSO,vEssbaseServer,vCurrAppName,vCurrCubeName )
On Error Goto 0
Dim vRequest
vRequest = "<req_OpenCube> " _
& " <sID>" & vCurrSID & "</sID> " _
& " <srv>" & vEssbaseServer & "</srv> " _
& " <app>" & vCurrAppName & "</app> " _
& " <cube>"& vCurrCubeName & "</cube> " _
& " <sso>" & vCurrSSO & "</sso> " _
& "</req_OpenCube>"
Dim objDOMDocument
Set objDOMDocument = getSVXMLAnswer(vURL,vRequest)
getOpennedCube = getXMLNodeValue(objDOMDocument,"/res_OpenCube")
Set objDOMDocument = Nothing
end function
function getCubeVariables ( vURL,vCurrSID,vCurrAppName,vCurrCubeName )
On Error Goto 0
Dim vRequest
vRequest = "<req_GetSubVar> " _
& " <sID>" & vCurrSID & "</sID> " _
& " <app>" & vCurrAppName & "</app> " _
& " <cube>" & vCurrCubeName & "</cube> " _
& " <VarName></VarName>" _
& "</req_GetSubVar>"
Dim objDOMDocument
Set objDOMDocument = getSVXMLAnswer(vURL,vRequest)
getCubeVariables = getXMLValue(objDOMDocument,"/")
Set objDOMDocument = Nothing
if 0 = len(getCubeVariables) Then
pErrorHandler "getCubeVariables error" ,1
end if
end function
function getCubeVariablesList ( vURL,vCurrSID,vCurrAppName,vCurrCubeName )
On Error Goto 0
Dim vStr,vStr1,vStr2,vArr
vStr = getCubeVariables( vURL,vCurrSID,vCurrAppName,vCurrCubeName )
vArr = split(vStr,"VarNames>")
vStr1 = vArr(1)
vStr1 = replace(vStr1,"</","")
vArr = split(vStr,"VarVals>")
vStr2 = vArr(1)
vStr2 = replace(vStr2,"</","")
getCubeVariablesList = vStr1 & "#" & vStr2
end function
function getCubeScripts ( vURL,vCurrSID,vCurrAppName,vCurrCubeName )
On Error Goto 0
Dim vRequest
vRequest = "<req_EnumBusinessRules> " _
& " <sID>" & vCurrSID & "</sID> " _
& " <app>" & vCurrAppName & "</app> " _
& " <cube>" & vCurrCubeName & "</cube> " _
& "</req_EnumBusinessRules>"
Dim objDOMDocument
Set objDOMDocument = getSVXMLAnswer(vURL,vRequest)
getCubeScripts = getXMLValue(objDOMDocument,"/res_EnumBusinessRules")
Set objDOMDocument = Nothing
if 0 = len(getCubeScripts) Then
pErrorHandler "getCubeScripts error" ,1
end if
end function
function getScript ( vURL,vCurrSID,vCurrCalcScriptName )
On Error Goto 0
Dim vRequest
vRequest = "<req_GetCalcScriptAsString> " _
& " <calcScriptName>" & vCurrCalcScriptName & "</calcScriptName>" _
& " <type>csc</type> " _
& " <sID>" & vCurrSID & "</sID> " _
& "</req_GetCalcScriptAsString>"
Dim objDOMDocument
Set objDOMDocument = getSVXMLAnswer(vURL,vRequest)
'alert &objDOMDocument
jsScriptBody = getXMLNodeValue(objDOMDocument,"/res_ExecuteCalcScriptAsString/calcScriptContent")
'alert jsScriptBody
if (len (jsScriptBody) > 10 ) then
jsBeautify
jsScriptBody = replace (jsScriptBody," -> ","->")
jsScriptBody = replace (jsScriptBody,"-> ","->")
jsScriptBody = replace (jsScriptBody,"-> ","->")
jsScriptBody = replace (jsScriptBody,"-> ","->")
jsScriptBody = replace (jsScriptBody,"-> ","->")
jsScriptBody = replace (jsScriptBody,"-> ","->")
jsScriptBody = replace (jsScriptBody, "> 0 ) ","> 0 )" & chr(13) & chr(9)& chr(9) )
jsScriptBody = replace (jsScriptBody, "= 0 ) ","> 0 )" & chr(13) & chr(9)& chr(9) )
jsScriptBody = replace (jsScriptBody, "/*13.9.9*/","/*13.9.9*/" & chr(13) & chr(9)& chr(9) )
end if
getScript = jsScriptBody
Set objDOMDocument = Nothing
if 0 = len(getScript) Then
pErrorHandler "getScript error" ,1
end if
end function
'HypExecuteCalcScriptEx2
'HypExecuteCalcScriptString
'HypGetCalcScript
Dim vSVsID,vSVSSO
Dim vConnAps,vConnEsb
Dim vConnDb,vConnApp
Dim vAppSID,vCubeSID
Dim vConnUser,vConnPass
Sub setCopyRight
On Error Goto 0
Dim strHTML
strHTML = OutCopyRight.InnerHTML
strHTML = strHTML & "<a href=""https://www.linkedin.com/in/essbaseru""> © </a> "
OutCopyRight.InnerHTML = strHTML
End Sub
Dim arrVariblesName,arrVariblesValues
function setSubsVariable ( vURL,vCurrSID,vCurrAppName,vCurrCubeName ,vCurrVaribleName,vCurrVaribleValue)
On Error Goto 0
Dim vRequest
vRequest = "<req_SetSubVar> " _
& " <sID>" & vCurrSID & "</sID> " _
& " <app>" & vCurrAppName & "</app> " _
& " <cube>" & vCurrCubeName & "</cube> " _
& " <VarName>" & vCurrVaribleName & "</VarName>" _
& " <VarVal>" & vCurrVaribleValue & "</VarVal>" _
& "</req_SetSubVar>"
Dim objDOMDocument
Set objDOMDocument = getSVXMLAnswer(vURL,vRequest)
setSubsVariable = getXMLValue(objDOMDocument,"/")
Set objDOMDocument = Nothing
if 0 = len(setSubsVariable) Then
pErrorHandler "setSubsVariable error" ,1
end if
end function
sub setSubsVariables
On Error Goto 0
' Set objDivID = document.getElementById("btnRun" & vCalcCurrScriptName)
' getElementsByTagName("input").item(1).value
OutChangeVariables.innerHTML=""
dim strHTML
For j = 0 To UBound(arrVariblesName)
if ((instr("1234567890",Left(arrVariblesName (j),1)) = 0 ) and (instr(arrVariblesName (j),"CUBE_NAME") = 0 ) ) then
Set objDivID = document.getElementById("txt" & arrVariblesName (j))
if ( objDivID.value <> arrVariblesValues(j) ) then
strHTML=strHTML & setSubsVariable (vConnAps,vAppSID,vConnApp,vConnDb,arrVariblesName (j),objDivID.value)
arrVariblesValues(j)=objDivID.value
end if
end if
Next
Set objDivID = Nothing
call reloadVariables
end sub
function getVariablseForm
Dim strHTML
strHTML= "<div > <table> " '<div style=""height:200px;border:1px ;overflow:auto;"">
vCubeScriptXML = getCubeVariablesList(vConnAps,vAppSID,vConnApp,vConnDb)
if ( len(vCubeScriptXML)>5 ) then
arrRules3 = Split (vCubeScriptXML,"#")
arrVariblesValues = Split (arrRules3(1),"|")
arrVariblesName = Split (arrRules3(0),"|")
set arrRules3 = nothing
For j = 0 To UBound(arrVariblesName)
if ((instr("1234567890",Left(arrVariblesName (j),1)) = 0 ) and (instr(arrVariblesName (j),"CUBE_NAME") = 0 ) ) then
arrVariblesValues (j) = replace(arrVariblesValues (j),"""","")
strHTML = strHTML & "<tr> <td align=""left"" width=""50"" class=""ui label""> &."
strHTML = strHTML & arrVariblesName (j)
strHTML = strHTML & "</td> <td width=""50"" >"
strHTML = strHTML & " <input id=""txt" & arrVariblesName (j) & """ type=""text"" value="""& arrVariblesValues (j)& """> "
strHTML = strHTML & "</td> </tr> "
end if
Next
end if
getVariablseForm = strHTML & "</table> </div> "
end function
sub reloadVariables
On Error Goto 0
OUTVaribleFORM.innerHTML=getVariablseForm
fVariables.btnSetVariables.disabled = false
fVariables.btnHideVariables.disabled = false
end sub
sub hideVariables
On Error Goto 0
OUTVaribleFORM.innerHTML=""
fVariables.btnSetVariables.disabled = true
fVariables.btnHideVariables.disabled = true
end sub
sub setCSCScripsForm
OUTScriptsFORM.innerHTML=getScriptsForm
runbutton.disabled = false
' runExpButton.disabled = false
loadCsCbutton.disabled = true
hideCsCbutton.disabled = false
end sub
sub runExpClose
outTabRuleBody.InnerHTML = "" 'jsScriptBody
END sub
sub hideCSCScrips
OUTScriptsFORM.innerHTML=""
outTabRuleBody.InnerHTML = ""
runbutton.disabled = true
' runExpButton.disabled = true
loadCsCbutton.disabled = false
hideCsCbutton.disabled = true
end sub
function getFirstSegmnet
Dim strHTML
Dim arrEssbSrv,vCurrEsbServer
vCurrEsbServer=""
strHTML= "<div class=""ui segment"">"
strHTML= strHTML & "<b class=""ui basic""> Database list: </b> <br> <br> "
For i = 0 to (Ubound(arrConnections) )
if (len(arrConnections (i,1)) > 5 ) then
if ( len (vCurrEsbServer) = 0) then
vCurrEsbServer = arrConnections (i,4)
arrEssbSrv=split (vCurrEsbServer,".")
strHTML= strHTML & "<b class=""ui basic"">@"& arrEssbSrv(0)&"</b> <br>"
' arrEssbSrv = Nothing
end if
if ( instr(arrConnections (i,4),vCurrEsbServer) = 0 ) then
vCurrEsbServer = arrConnections (i,4)
arrEssbSrv=split (vCurrEsbServer,".")
strHTML= strHTML & "<b class=""ui basic"">@"& arrEssbSrv(0)&"</b> <br>"
' arrEssbSrv = Nothing
end if
if ( instr(arrConnections (i,5),vConnApp) = 0 and instr(arrConnections (i,5),vConnDb) = 0 ) then
strHTML= strHTML & "<a class=""ui basic"" id=""" & i & """ onclick=""vbscript:Call changeCurrentCube(window.event.srcelement.id,1)"" href=""#"" >" &_
" "& lcase( arrConnections (i,5) & "." & arrConnections (i,6)) &"</a> <br> "
strHTML = strHTML & "<div style=""height: 5px;""> </div>"
end if
end if
next
strHTML= strHTML & "</div>"
getFirstSegmnet = strHTML
end function
function getScriptsForm
Dim strHTML
Dim arrRules1,arrRules2
strHTML=""
strHTML = getCubeScripts(vConnAps,vAppSID,vConnApp,vConnDb ) 'vConnApp '
'alert strHTML
arrRules1 = Split (strHTML,"rtp=""0"">")
if Ubound (arrRules1) < 1 then
alert strHTML
end if
strHTML = "<div width=""width:600px;border:1px ;overflow:auto;"" ><table> <tr > <td>"
For J = 1 To UBound(arrRules1)
arrRules2 = Split(arrRules1(j),"</rule>")
if j = 12 or j = 24 then
strHTML = strHTML & "</td><td> </td><td>"
end if
if (instr(ucase(arrRules2(0)),"Z") <> 1 ) and (instr(ucase(arrRules2(0)),"T") <> 1 )then
strHTML = strHTML & "<div class=""field"">"
strHTML = strHTML & "<div class=""ui radio checkbox"">"
strHTML = strHTML & "<input type=""radio"" name=""CalcOption"" value=""" & vConnApp & "." & vConnDb & "." & arrRules2(0) & """> " & _
" >     <a id=""" & vConnApp &"."& vConnDb &"."& arrRules2(0) & """ onclick=""vbscript:Call setScheduleForm(window.event.srcelement.id)"" href=""#"" > " & arrRules2(0) & "</a> <div id=""btnRun" & arrRules2(0) & """ ></div> "
strHTML = strHTML & "</div>"
strHTML = strHTML & "</div>"
end if
Next
getScriptsForm= "</td> </tr> </table> " & strHTML & " </div>"
'alert strHTML
end function
Dim vArrSceduleRules (100)
Dim vArrSceduleRulesID
sub setScheduleForm (vCurrScriptName)
Dim strHTML ,i
strHTML = 0
For i = 0 To UBound(vArrSceduleRules)
if (instr(vArrSceduleRules(i),vCurrScriptName) > 0 ) then
strHTML = 1
end if
next
if (strHTML <1 ) then
' alert vArrSceduleRules (0)
vArrSceduleRulesID = vArrSceduleRulesID + 1
i = vArrSceduleRulesID
vArrSceduleRules (i) = vCurrScriptName
strHTML=OUTScheduleForm.innerHTML
strHTML = strHTML & "<div class=""field"">"
strHTML = strHTML & "<div class=""ui radio checkbox"">"
strHTML = strHTML & "<input type=""radio"" name=""ScheduleOption"" value=""" & vCurrScriptName & """> " & _
" >     <a id=""" & vCurrScriptName & "#" & i & """ onclick=""vbscript:Call delScriptFromForm(window.event.srcelement.id)"" href=""#"" > " & vCurrScriptName& "</a> "
strHTML = strHTML & "</div>"
strHTML = strHTML & "</div>"
OUTScheduleForm.innerHTML = strHTML
else
alert vCurrScriptName & " is already added"
end if
end sub
Dim vIsDeletedRule
sub delScriptFromForm (vCurrScriptID)
Dim Arr
arr=split(vCurrScriptID,"#")
vArrSceduleRules (arr(1)) = ""
vIsDeletedRule = true
drawScheduleForm
end sub
sub drawScheduleForm
dim vArrClearRules(100)
if vIsDeletedRule then
j=0
for i = 0 To UBound(vArrSceduleRules)
if ( len(vArrSceduleRules(i)) > 3 ) then
vArrClearRules(j)=vArrSceduleRules(i)
j=j+1
end if
Next
for i = 0 To UBound(vArrSceduleRules)
vArrSceduleRules(i)=""
vArrSceduleRules(i)=vArrClearRules(i)
Next
end if
Dim strHTML ,i
strHTML = ""
For i = 0 To UBound(vArrSceduleRules)
if ( len(vArrSceduleRules(i)) > 3 ) then
strHTML = strHTML & "<div class=""field"">"
strHTML = strHTML & "<div class=""ui radio checkbox"">"
strHTML = strHTML & "<input type=""radio"" name=""ScheduleOption"" value=""" & vArrSceduleRules(i) & """> " & _
" >     <a id=""" & vArrSceduleRules(i) & "#" & i & """ onclick=""vbscript:Call delScriptFromForm(window.event.srcelement.id)"" href=""#"" > " & vArrSceduleRules(i) & "</a> <div id=""btnRun" & vArrSceduleRules(i) & """ ></div> "
strHTML = strHTML & "</div>"
strHTML = strHTML & "</div>"
end if
Next
OUTScheduleForm.innerHTML = strHTML
end sub
Dim objSelectedCSC
sub upCSCScrip
On Error Goto 0
Dim objButton
Dim Arr,vSTr,vIsmoved
'alert ScheduleOption
vIsmoved=0
For Each objButton in fScheduleFormName.ScheduleOption
If ( objButton.Checked ) Then
For i = 1 To UBound(vArrSceduleRules)
if vIsmoved=0 then
if (instr(vArrSceduleRules(i),objButton.value) > 0 and len(vArrSceduleRules(i))>1 ) then
vSTr=vArrSceduleRules (i-1)
vArrSceduleRules (i-1)=vArrSceduleRules (i)
vArrSceduleRules (i) = vSTr
vIsmoved=1
end if
end if
next
End If
Next
drawScheduleForm
END sub
sub downCSCScrip
On Error Goto 0
Dim objButton
Dim Arr,vSTr,vIsmoved
'alert ScheduleOption
vIsmoved=0
For Each objButton in fScheduleFormName.ScheduleOption
If ( objButton.Checked ) Then
For i = 0 To UBound(vArrSceduleRules)-1
if vIsmoved=0 then
if (instr(vArrSceduleRules(i),objButton.value) > 0 and len(vArrSceduleRules(i))>1 ) then
vSTr=vArrSceduleRules (i+1)
vArrSceduleRules (i+1)=vArrSceduleRules (i)
vArrSceduleRules (i) = vSTr
vIsmoved=1
end if
end if
next
End If
Next
drawScheduleForm
END sub
sub setButtonOnRun
runbutton.disabled = true
hideCsCbutton.disabled = true
loadCsCbutton.disabled = true
fScheduleFormName.cscRUN.disabled = true
end sub
sub runCurrentRuleByID (i)
dim strAttr
dim vIsFound
if ( len(vArrSceduleRules(i))>1 ) then
strAttr = split ( vArrSceduleRules(i) ,".")
vIsFound = 0
For j = 0 To UBound(arrConnections )
if ( vIsFound = 0 ) then
'alert (arrConnections(j,0))&arrConnections(j,5)&arrConnections(j,6)
If (instr (strAttr(0),arrConnections(j,5)) > 0 and instr (strAttr(1),arrConnections(j,6)) > 0 ) then
call getLoginSID (j)
vIsFound = 1
end if
end if
next
if (vIsFound = 1 ) then
call runExpClose
call setButtonOnRun
'alert vArrSceduleRules(i)
Set objDivID = document.getElementById("btnRun" & vArrSceduleRules(i) )
objDivID.innerHTML = objDivID.innerHTML & " <div class=""description"">               Started :    " & Time & "</div> " ' <div class=""item""> <div class=""content"">
runStatus.InnerHTML = "<div class=""description""> " & vArrSceduleRules(i) &" have started at " & Time & "</div> " ' <div class=""item""> <div class=""content"">
WriteLog vArrSceduleRules(i) & ";" & " start"
getSleepy
if ( instr(ucase( strAttr(2)),"DEFAULT") = 0 ) then
strHTML = "<req_LaunchBusinessRule> " _
& " <sID>" & vSVsID & "</sID> " _
& " <cube>" & vConnDb & "</cube> " _
& " <rule>" & strAttr(2) & "</rule> " _
& "</req_LaunchBusinessRule>"
Call getSVXMLAnswerAsyncCalc(vConnAps,strHTML,strAttr(2),vArrSceduleRules(i))
end if
else
alert " Can not find connection for " & vArrSceduleRules(i)
end if
end if
end sub
sub runCalcLaunch
On Error Goto 0
Dim objButton
Dim strHTML,objDivID
Dim strAttr ,vIsFound
dim vIsRunning
vIsRunning = 0
For Each objButton in CalcOption
If ( objButton.Checked and instr(ucase( objButton.Value),"DEFAULT") = 0 ) Then
'alert objButton.Value
strAttr = split ( objButton.Value ,".")
vIsRunning = 1
call getLoginSID (vGlobalCubeID)
call runExpClose
call setButtonOnRun
Set objDivID = document.getElementById("btnRun" & strAttr(2) )
objDivID.innerHTML = objDivID.innerHTML & " <div class=""description"">               Started :    " & Time & "</div> " ' <div class=""item""> <div class=""content"">
runStatus.InnerHTML = "<div class=""description""> " & strAttr(2)&" have started at " & Time & "</div> " ' <div class=""item""> <div class=""content"">
WriteLog vConnApp & "." & vConnDb & "." & strAttr(2) & ";" & " start"
getSleepy
End If
Next
if (vIsRunning = 1) then
For Each objButton in CalcOption
If objButton.Checked Then
if ( instr(ucase(strAttr(2)),"DEFAULT") = 0 ) then
strHTML = "<req_LaunchBusinessRule> " _
& " <sID>" & vSVsID & "</sID> " _
& " <cube>" & vConnDb & "</cube> " _
& " <rule>" & strAttr(2) & "</rule> " _
& "</req_LaunchBusinessRule>"
' alert vConnAps
' alert strHTML
Call getSVXMLAnswerAsyncCalc(vConnAps,strHTML,strAttr(2),"")
end if
End If
Next
else
alert "Please select the rule before run "
end if
END sub
function getSecondtSegmnet
Dim strHTML
strHTML = "<table > <tr> <td width=""652"" >"
strHTML = strHTML & " <div class=""ui list""> <div class=""item""> <i class=""folder icon""></i> <div class=""content""> <div class=""header"">" & lcase(vConnApp & "." & vConnDb) & "</div> "
strHTML = strHTML & " <div class=""list""> <div class=""item""> <i class=""folder icon""></i> <div class=""content""> <div class=""header""> Variables</div> "
strHTML = strHTML & "<form class=""span6"" id=fVariables > "
strHTML = strHTML & "<div id=""OUTVaribleFORM"" style=""height:150px;border:1px ;overflow:auto;"" >" & "</div>" 'getVariablseForm &
strHTML = strHTML & "<br>"
strHTML = strHTML & "<input style=""width: 75px;"" class=""mini ui button"" id=btnSetVariables type=""button"" value=""set"" onClick=""vbscript:setSubsVariables"">"
strHTML = strHTML & "<input style=""width: 75px;"" class=""mini ui button"" id=btnReloadVariables type=""button"" value=""load"" onClick=""vbscript:reloadVariables"">"
strHTML = strHTML & "<input style=""width: 75px;"" class=""mini ui button"" id=btnHideVariables type=""button"" value=""hide"" onClick=""vbscript:hideVariables"">"
strHTML = strHTML & " </form> "
strHTML = strHTML & "<div id=""OutChangeVariables"" align=""left""> </div></div></div></div> "
strHTML = strHTML & " <div class=""list""> <div class=""item""> <i class=""folder icon""></i> <div class=""content""> <div class=""header""> Calculations</div> "
strHTML = strHTML & "<div class=""ui form"">"
strHTML = strHTML & "<div class=""grouped fields"">"'
strHTML = strHTML & "<div id=""OUTScriptsFORM"" style=""height:300px;width:500px;border:1px ;overflow:auto;"" align=""left""></div>"
strHTML = strHTML & "<br>"
strHTML = strHTML & "<div style=""height: 5px;""> </div>"
strHTML = strHTML & "<input style=""width: 75px;"" id=loadCsCbutton class=""mini ui button"" type=""button"" value=""load"" name=""set_calc"" onClick=""vbscript:setCSCScripsForm""> "
strHTML = strHTML & "<input style=""width: 75px;"" id=hideCsCbutton class=""mini ui button"" type=""button"" value=""hide"" name=""hide_calc"" onClick=""vbscript:hideCSCScrips""> "
'strHTML = strHTML & "<input style=""width: 75px;"" id=runExpButton class=""mini ui button"" type=""button"" value=""view"" name=""exp_calc"" onClick=""vbscript:runExportScript""> "
'strHTML = strHTML & "<br>"
'strHTML = strHTML & "<div style=""height: 15px;""> </div>"
strHTML = strHTML & "<input style=""width: 75px;"" id=runbutton class=""ui button"" type=""button"" value="" run"" name=""run_Calc"" onClick=""vbscript:runCalcLaunch""> "
strHTML = strHTML & "<input style=""width: 75px;"" id=showLog class=""ui button"" type=""button"" value="" log"" name=""show_Log"" onClick=""vbscript:showLog""> "
strHTML = strHTML & " </div> "
strHTML = strHTML & " </div> "
strHTML = strHTML & " </div></div></div></div> "
strHTML = strHTML & " </div></div></div></div> "
strHTML = strHTML & "</td > </tr> </table >"
getSecondtSegmnet = strHTML
end function
function getThirdSegmnet
Dim strHTML
strHTML = ""
strHTML = strHTML & "<form class=""span6"" id=""fScheduleFormID"" name=""fScheduleFormName"" > "
strHTML = strHTML & "<div id=""OUTScheduleForm"" style=""height:485px;border:1px ;overflow:auto;"" align=""left""></div>"
strHTML = strHTML & "<div style=""height: 35px;""> </div>"
strHTML = strHTML & "<input style=""width: 75px;"" id=cscUP class=""mini ui button"" type=""button"" value="" up"" name=""up_calc"" onClick=""vbscript:upCSCScrip""> "
strHTML = strHTML & "<input style=""width: 75px;"" id=cscDown class=""mini ui button"" type=""button"" value=""down"" name=""down_calc"" onClick=""vbscript:downCSCScrip""> "
strHTML = strHTML & "<br>"
strHTML = strHTML & "<div style=""height: 15px;""> </div>"
strHTML = strHTML & "<input style=""width: 75px;"" id=cscRUN class=""ui button"" type=""button"" value=""run"" name=""run_seq"" onClick=""vbscript:runCSCScrip""> "
strHTML = strHTML & "<input style=""width: 75px;"" id=saveCsCbutton class=""ui button"" type=""button"" value=""save"" name=""save_calc"" onClick=""vbscript:saveCSCScrips""> "
strHTML = strHTML & "<input style=""width: 75px;"" id=clearCsCbutton class=""ui button"" type=""button"" value=""clear"" name=""clear_calc"" onClick=""vbscript:clearCSCScrips""> "
strHTML = strHTML & "<br>"
strHTML = strHTML & "</form>"
getThirdSegmnet = strHTML
end function
Dim vGlobalRunnedCSCID
sub runCSCScrip
call WriteCookie
vGlobalRunnedCSCID=0
call runCurrentRuleByID (0)
end sub
sub saveCSCScrips
call WriteCookie
end sub
sub clearCSCScrips
For i = 0 To UBound(vArrSceduleRules)
vArrSceduleRules(i) = ""
Next
call WriteCookie
call ReadCookie
end sub
Sub getForm
Dim strHTML
strHTML = "<table> <tr> <td width=""150"" >"
strHTML = strHTML & " <div class=""ui segment"" style=""height:760px;border:1px ;overflow:auto;"" >"
' first segment
strHTML = strHTML & getFirstSegmnet
strHTML = strHTML & "</div> </td> <td width=""1"" bgcolor=""#CFEDFF""> </td> <td width=""652""> "
strHTML = strHTML & " <div class=""ui segment"" style=""height:760px;width=652px;border:1px ;overflow:auto;"" >"
' second segment
strHTML = strHTML & getSecondtSegmnet
strHTML = strHTML & "</div> </td> <td width=""1"" bgcolor=""#CFEDFF""> </td> <td width=""396"" align=""top"" > "
strHTML = strHTML & " <div class=""ui segment"" style=""height:760px;border:1px ;overflow:auto;"" >"
' third segment
strHTML = strHTML & "<table valign=""top""> <tr valign=""top"" > <td> <div style=""height: 50;""> <b> Calcualtion sequence </b> </div> </td> </tr> <tr> <td> "
strHTML = strHTML & getThirdSegmnet
strHTML = strHTML & " </td> </tr> </table>"
strHTML = strHTML & "</div> </td> </tr> <tr> <td bgcolor=""#CFEDFF""> </td><td bgcolor=""#CFEDFF""> </td><td bgcolor=""#CFEDFF""> </td><td bgcolor=""#CFEDFF""> </td> <td bgcolor=""#CFEDFF""> </td> </tr>"
strHTML = strHTML & "</table>"
strHTML = strHTML & " <div id=""runStatus""></div> "
outFormCalcLaunch.InnerHTML = strHTML
OUTScriptsFORM.innerHTML= ""
outTabRuleBody.InnerHTML= ""
OUTVaribleFORM.innerHTML= ""
fVariables.btnSetVariables.disabled = true
fVariables.btnHideVariables.disabled = true
runbutton.disabled = true
' runExpButton.disabled = true
loadCsCbutton.disabled = false
hideCsCbutton.disabled = true
End Sub
function getScriptList ()
Dim strHTML,vCubeScriptXML
Dim xmlNodes,xmlObject
Dim arrRules1,arrRules2,arrRules3,i
vCubeScriptXML = getCubeScripts(vConnAps,vAppSID,vConnApp,vConnDb )
arrRules1 = Split (vCubeScriptXML,"rtp=""0"">")
i=0
For J = 1 To UBound(arrRules1)
arrRules2 = Split(arrRules1(j),"</rule>")
if (instr(ucase(arrRules2(0)),"Z") <> 1 ) and (instr(ucase(arrRules2(0)),"T") <> 1 )then
arrRules3 = arrRules3 &";"& arrRules2(0)
i=i+1
end if
Next
getScriptList = arrRules3
End function
sub runExportScript
dim strHTML
For Each objButton in CalcOption
If ( objButton.Checked and instr(ucase( objButton.Value),"DEFAULT") = 0 ) Then
' runExpButton.disabled = true
strHTML = getScript(vConnAps,vSVsID,objButton.Value)
strHTML = "<div class=""ui form""> " & _
" <div class=""field""> " & _
"<input class=""ui button"" type=""button"" value=""" & objButton.Value & """ name=""close"" onClick=""runExpClose""> "& _
"<textarea rows=""30"" cols=""60"" > " & strHTML & " </textarea> " & _
"</div>" & _
"</div>"
outTabRuleBody.InnerHTML = strHTML 'jsScriptBody
End If
Next
' runExpButton.disabled = false
END sub
sub showLog
dim strHTML
strHTML = getLog
strHTML = "<div class=""ui form""> " & _
" <div class=""field""> " & _
"<input class=""ui button"" type=""button"" value=""Close"" name=""close"" onClick=""runExpClose""> "& _
"<textarea rows=""30"" cols=""60"" > " & strHTML & " </textarea> " & _
"</div>" & _
"</div>"
outTabRuleBody.InnerHTML = strHTML 'jsScriptBody
END sub
Dim arrConnections (100,11)
Sub getLoginArray
' maget login parameters from commnad line
Dim strHTML1,strHTML2
Dim arrLine,arrCurrConnect
For i = 0 to (Ubound(arrConnections) )
arrConnections (i,0) = -100
next
' alert objEssCSCLNCH.commandLine
arrCommands = Split(objEssCSCLNCH.commandLine, "conn=")
strHTML=replace(arrCommands(1),"""","")
arrCommands=Split(strHTML, " csc=")
strHTML1=replace(arrCommands(0),"""","")
strHTML2=""
if ubound(arrCommands)>0 then
strHTML2=replace(arrCommands(1),"""","")
end if
arrCommands=Split(strHTML1, "|")
'rulyubimir'rulyubimir'http://wedcb786.frmon.danet:13080/aps/SmartView'wedcb785.frmon.danet:1424'Kz1TTCST'Kz1TTCST
For i = 0 to (Ubound(arrCommands) )
arrCurrConnect = split (arrCommands(i),"'")
if ( ubound (arrCurrConnect) >4 ) then
arrConnections (i,0) = 0
'alert arrCurrConnect(0)
arrConnections (i,1) = arrCurrConnect(0) 'login
arrConnections (i,2) = arrCurrConnect(1) 'pass
arrConnections (i,3) = arrCurrConnect(2) 'aps
arrConnections (i,4) = arrCurrConnect(3) 'esb
arrConnections (i,5) = UCASE(arrCurrConnect(4)) 'app
arrConnections (i,6) = UCASE(arrCurrConnect(5)) 'db
end if
next
arrCommands=Split(strHTML2, "|")
'BY3TTCST.BY3TTCST.FRC_CALC_TTCST|BY3TTCST.BY3TTCST.ACT_CALC_TTCST
if ( ubound (arrCommands) >0 ) then
For i = 0 To UBound(vArrSceduleRules)
vArrSceduleRules(i) = ""
Next
For i = 0 to (Ubound(arrCommands) )
arrConnections (i,0) = 0
'alert arrCurrConnect(0)
vArrSceduleRules(i) = arrCommands(i)
next
WriteCookie
end if
' alert arrConnections (0,1)
end Sub
sub getLoginSID (i)
' initialisate corrent connection
if (0=arrConnections (i,0)) then
arrConnections (i,7) = getSID(arrConnections (i,3),arrConnections (i,1),arrConnections (i,2))
arrConnections (i,8) = getSSO(arrConnections (i,3),arrConnections (i,7))
arrConnections (i,9) = getOpennedApplication(arrConnections (i,3),arrConnections (i,7),arrConnections (i,8) ,arrConnections (i,4),arrConnections (i,5))
arrConnections (i,10) = getOpennedCube(arrConnections (i,3),arrConnections (i,7),arrConnections (i,8) ,arrConnections (i,4),arrConnections (i,5),arrConnections (i,6))
arrConnections (i,0) = 1
end if
vConnUser = arrConnections (i,1)
vConnPass = arrConnections (i,2)
vConnAps = arrConnections (i,3)
vConnEsb = arrConnections (i,4)
vConnApp = arrConnections (i,5)
vConnDb = arrConnections (i,6)
vSVsID = arrConnections (i,7)
vSVSSO = arrConnections (i,8)
vAppSID = arrConnections (i,9)
vCubeSID = arrConnections (i,10)
end Sub
function getCookieFile
Dim objFolders
Set objFolders = CreateObject("WScript.Shell").SpecialFolders
getCookieFile = objFolders("mydocuments") & "\essribon.csc"
set objFolders = Nothing
end function
function getlogFile
Dim objFolders
Set objFolders = CreateObject("WScript.Shell").SpecialFolders
getlogFile = objFolders("mydocuments") & "\essribon.log"
set objFolders = Nothing
end function
function getLog
Dim objFSO,objFile,vStrFileName
Set objFSO=CreateObject("Scripting.FileSystemObject")
vStrFileName = getlogFile
if objFSO.FileExists(vStrFileName) then
set objFile = objFSO.OpenTextFile(vStrFileName, 1)
vStrFileName = ""
Do Until objFile.AtEndOfStream
vStrFileName = vStrFileName & objFile.ReadLine
Loop
set objFile = Nothing
else
vStrFileName = ""
end if
set objFSO = Nothing
getLog = vStrFileName
end function
sub WriteLog (LogMessage )
Dim objFSO,objFile,vStrFileName
Set objFSO=CreateObject("Scripting.FileSystemObject")
vStrFileName = getlogFile
if objFSO.FileExists(vStrFileName) then
set objFile = objFSO.OpenTextFile(vStrFileName, 8, True)', TristateTrue )
else
set objFile = objFSO.CreateTextFile(vStrFileName,true)
end if
LogMessage = LogMessage & ";" & Year (Now)
if ( Month (Now) < 10 ) then
LogMessage = LogMessage &"0" & Month (Now)
else
LogMessage = LogMessage & Month (Now)
end if
if ( Day (Now) < 10 ) then
LogMessage = LogMessage &"0" & Day (Now)
else
LogMessage = LogMessage & Day (Now)
end if
LogMessage = LogMessage & " " & Time
'alert LogMessage
objFile.WriteLine LogMessage
objFile.Close
set objFSO = Nothing
set objFile = Nothing