@ -2,6 +2,7 @@ import psutil
import datetime
import datetime
import logging
import logging
import os
import os
import json
lProcessName = " OpenRPA_RobotRDPActive.exe "
lProcessName = " OpenRPA_RobotRDPActive.exe "
lStartFilePath = os . path . join ( os . getcwd ( ) , " .. \\ Utils \\ RobotRDPActive \\ pyOpenRPA.Tools.RobotRDPActive_x64.cmd " )
lStartFilePath = os . path . join ( os . getcwd ( ) , " .. \\ Utils \\ RobotRDPActive \\ pyOpenRPA.Tools.RobotRDPActive_x64.cmd " )
def RenderRobotRDPActive ( inGlobalConfiguration ) :
def RenderRobotRDPActive ( inGlobalConfiguration ) :
@ -20,7 +21,7 @@ def RenderRobotRDPActive(inGlobalConfiguration):
lResultDict = {
lResultDict = {
" HeaderLeftText " : " Keep active RDP sessions " ,
" HeaderLeftText " : " Keep active RDP sessions " ,
" HeaderRightText " : " Tech " ,
" HeaderRightText " : " Tech " ,
" DataStorageKey " : " RobotRDPActive " , #Use key for set current dict in mGlobal.DataStorage["D t aaStorageKey"] on client side
" DataStorageKey " : " RobotRDPActive " , #Use key for set current dict in mGlobal.DataStorage["D at aStorageKey"] on client side
" SubheaderText " : lSubheaderRunFalseText ,
" SubheaderText " : lSubheaderRunFalseText ,
" BodyKeyValueList " : [
" BodyKeyValueList " : [
{ " Key " : " Session list " , " Value " : " " }
{ " Key " : " Session list " , " Value " : " " }
@ -42,16 +43,29 @@ def RenderRobotRDPActive(inGlobalConfiguration):
for lItem in lRDPList :
for lItem in lRDPList :
#Lable that session has fullscreen
#Lable that session has fullscreen
lLabelSessionFullScreen = " "
lLabelSessionFullScreen = " "
lLabelIsIgnored = " "
#Link set full screen
#Link set full screen
##############################
lOnClickSetFullScreen = f " mGlobal.Processor.ServerValueSet([ ' Storage ' , ' RobotRDPActive ' , ' OrchestratorToRobotStorage ' , ' FullScreenSessionIndex ' ], { lRDPListIndex } ); "
lOnClickSetFullScreen = f " mGlobal.Processor.ServerValueSet([ ' Storage ' , ' RobotRDPActive ' , ' OrchestratorToRobotStorage ' , ' FullScreenSessionIndex ' ], { lRDPListIndex } ); "
lSetFullScreenA = f ' <a onclick= " { lOnClickSetFullScreen } " style= \" color:blue \" >Set fullscreen</a> '
lSetFullScreenA = f ' <a onclick= " { lOnClickSetFullScreen } " style= \" color:blue \" >Set fullscreen</a> '
if lRDPListIndex == lFullScreenSessionIndex :
if lRDPListIndex == lFullScreenSessionIndex :
lLabelSessionFullScreen = ' <span style= \" color:blue \" >Fullscreen</span> '
lLabelSessionFullScreen = ' <span style= \" color:blue \" >[Fullscreen]</span> '
lOnClickSetFullScreen = f " mGlobal.Processor.ServerValueSet([ ' Storage ' , ' RobotRDPActive ' , ' OrchestratorToRobotStorage ' , ' FullScreenSessionIndex ' ],null); "
lSetFullScreenA = f ' <a onclick= " { lOnClickSetFullScreen } " style= \" color:blue \" >Set minimized</a> '
#################################
lIgnoreIndexListOnClick = " $.ajax( { type: ' POST ' , url: ' RobotRDPActive/IgnoreIndexListAppend ' , data: ' " + str ( lRDPListIndex ) + " ' , success: function(lData,l2,l3) {} , dataType: ' text ' }); "
lIgnoreIndexListLink = f ' <a onclick= " { lIgnoreIndexListOnClick } " style= \" color:red \" >Ignore</a> '
#Check if in ignore
if lRDPListIndex in inGlobalConfiguration . get ( " Storage " , { } ) . get ( " RobotRDPActive " , { } ) . get ( " OrchestratorToRobotStorage " , { } ) . get ( " IgnoreIndexList " , [ ] ) :
lLabelIsIgnored = ' <span style= \" color:red \" >[Ignored]</span> '
lIgnoreIndexListOnClick = " $.ajax( { type: ' POST ' , url: ' RobotRDPActive/IgnoreIndexListRemove ' , data: ' " + str ( lRDPListIndex ) + " ' , success: function(lData,l2,l3) {} , dataType: ' text ' }); "
lIgnoreIndexListLink = f ' <a onclick= " { lIgnoreIndexListOnClick } " style= \" color:red \" >Unignore</a> '
################################
#Session state
#Session state
lItemSessionState = ' <span style= \" color:red \" >Disconnected</span> '
lItemSessionState = ' <span style= \" color:red \" >Disconnected</span> '
if lItem . get ( " FlagSessionIsActive " , False ) :
if lItem . get ( " FlagSessionIsActive " , False ) :
lItemSessionState = ' <span style= \" color:green \" >Connected</span> '
lItemSessionState = ' <span style= \" color:green \" >Connected</span> '
lResultDict [ " BodyKeyValueList " ] . append ( { " Key " : f " [ { str ( lRDPListIndex ) } ] { lLabelSessionFullScreen } { lItem . get ( ' Host ' , ' localhost ' ) } : { lItem . get ( ' Port ' , ' -- ' ) } " , " Value " : f " { lItem . get ( ' Login ' , ' -- ' ) } , { lItem . get ( ' SessionHex ' , ' -- ' ) } , State { lItemSessionState } , { lSetFullScreenA } " } )
lResultDict [ " BodyKeyValueList " ] . append ( { " Key " : f " [ { str ( lRDPListIndex ) } ] { lLabelSessionFullScreen } { l LabelIsIgnored} { l Item. get ( ' Host ' , ' localhost ' ) } : { lItem . get ( ' Port ' , ' -- ' ) } " , " Value " : f " { lItem . get ( ' Login ' , ' -- ' ) } , { lItem . get ( ' SessionHex ' , ' -- ' ) } , State { lItemSessionState } , { lSetFullScreenA } , { lIgnoreIndexListLink } " } )
lRDPListIndex = lRDPListIndex + 1
lRDPListIndex = lRDPListIndex + 1
#Check if process running
#Check if process running
if CheckIfProcessRunning ( " OpenRPA_RobotRDPActive " ) :
if CheckIfProcessRunning ( " OpenRPA_RobotRDPActive " ) :
@ -59,7 +73,32 @@ def RenderRobotRDPActive(inGlobalConfiguration):
#Process not running
#Process not running
lResultDict [ " FooterText " ] = f ' Last update: { datetime . datetime . now ( ) . strftime ( " % H: % M: % S %d . % m. % Y " ) } '
lResultDict [ " FooterText " ] = f ' Last update: { datetime . datetime . now ( ) . strftime ( " % H: % M: % S %d . % m. % Y " ) } '
return lResultDict
return lResultDict
#Add to ignore list
def IgnoreIndexListAppend ( inRequest , inConfiguration ) :
lIgnoreList = inConfiguration [ " Storage " ] [ " RobotRDPActive " ] [ " OrchestratorToRobotStorage " ] [ " IgnoreIndexList " ]
lIgnoreIndex = { }
if inRequest . headers . get ( ' Content-Length ' ) is not None :
lInputByteArrayLength = int ( inRequest . headers . get ( ' Content-Length ' ) )
lInputByteArray = inRequest . rfile . read ( lInputByteArrayLength )
#Превращение массива байт в объект
lIgnoreIndex = int ( lInputByteArray . decode ( ' utf8 ' ) )
#check if index not in list
if lIgnoreIndex not in lIgnoreList :
#append to list
lIgnoreList . append ( lIgnoreIndex )
#remove from Ignore list
def IgnoreIndexListRemove ( inRequest , inConfiguration ) :
lIgnoreList = inConfiguration [ " Storage " ] [ " RobotRDPActive " ] [ " OrchestratorToRobotStorage " ] [ " IgnoreIndexList " ]
lIgnoreIndex = { }
if inRequest . headers . get ( ' Content-Length ' ) is not None :
lInputByteArrayLength = int ( inRequest . headers . get ( ' Content-Length ' ) )
lInputByteArray = inRequest . rfile . read ( lInputByteArrayLength )
#Превращение массива байт в объект
lIgnoreIndex = int ( lInputByteArray . decode ( ' utf8 ' ) )
#check if index not in list
if lIgnoreIndex in lIgnoreList :
#append to list
lIgnoreList . remove ( lIgnoreIndex ) #Remove delete the element lIgnoreIndex
def CheckIfProcessRunning ( processName ) :
def CheckIfProcessRunning ( processName ) :
'''
'''
Check if there is any running process that contains the given name processName .
Check if there is any running process that contains the given name processName .
@ -81,6 +120,26 @@ def SettingsUpdate(inDict):
#Default structure
#Default structure
inDict [ " Storage " ] [ " RobotRDPActive " ] = {
inDict [ " Storage " ] [ " RobotRDPActive " ] = {
" OrchestratorToRobotResetStorage " : { " SafeTurnOff " : False } ,
" OrchestratorToRobotResetStorage " : { " SafeTurnOff " : False } ,
" OrchestratorToRobotStorage " : { " FullScreenSessionIndex " : None }
" OrchestratorToRobotStorage " : {
" FullScreenSessionIndex " : None ,
" IgnoreIndexList " : [ ]
}
}
}
#Add methods
inDict [ " Server " ] [ " URLList " ] . append (
{
" Method " : " POST " ,
" URL " : " /RobotRDPActive/IgnoreIndexListAppend " , #URL of the request
" MatchType " : " Equal " , #"BeginWith|Contains|Equal|EqualCase",
" ResponseDefRequestGlobal " : IgnoreIndexListAppend #Function with str result
}
)
inDict [ " Server " ] [ " URLList " ] . append (
{
" Method " : " POST " ,
" URL " : " /RobotRDPActive/IgnoreIndexListRemove " , #URL of the request
" MatchType " : " Equal " , #"BeginWith|Contains|Equal|EqualCase",
" ResponseDefRequestGlobal " : IgnoreIndexListRemove #Function with str result
}
)
return inDict
return inDict