1+ using CommandLine ;
2+ using DIFacility ;
3+ using FsBaseExecSvc . Client ;
4+ using FsBaseExecSvc . Interface ;
5+ using Lamar ;
6+ using Microsoft . Win32 ;
7+ using System ;
8+ using System . Collections . Generic ;
9+ using System . Diagnostics ;
10+ using System . IO ;
11+ using System . Reflection ;
12+ using System . Security ;
13+ using System . Threading ;
14+ using System . Threading . Tasks ;
15+
16+ namespace ClientExample
17+ {
18+ class EntraceOption
19+ {
20+ [ Option ( "config" , Required = true , HelpText = "Config file name" ) ]
21+ public string ConfigFile { get ; set ; } = "" ;
22+ [ Option ( "update" , Required = false , HelpText = "Update the tool" ) ]
23+ public bool Update { get ; set ; }
24+
25+ [ Option ( "node" , Required = false , HelpText = "Node to run, note the config file is still current node local" ) ]
26+ public string Node { get ; set ; } = System . Net . Dns . GetHostName ( ) ;
27+
28+ private readonly static string ServiceName = "FileWatcherProcessService" ;
29+ public bool VerifyInput ( )
30+ {
31+ if ( ! Directory . Exists ( Path . Combine ( Path . GetDirectoryName ( Assembly . GetExecutingAssembly ( ) . Location ) , ServiceName ) ) )
32+ {
33+ Console . WriteLine ( $@ "Incomplete version of file. Please copy again") ;
34+ return false ;
35+ }
36+ if ( ! this . Update && ! File . Exists ( this . ConfigFile ) )
37+ {
38+ Console . WriteLine ( $@ "Config file { this . ConfigFile } not exist") ;
39+ return false ;
40+ }
41+ return true ;
42+ }
43+
44+ public string Run ( )
45+ {
46+ var factory = ClientEntraceFactory . GetClientEntrance ( new RPCClientTokenProvider ( ) ) ;
47+ LogLevelService . SetVerboseOn ( ) ;
48+
49+ IFsRPCBase fsDemoRPC = factory . GetRPCClient ( "itest" ) ;
50+ var result = fsDemoRPC . RunOnNode ( "rwsam16" , "time=11111" , 3 ) ;
51+
52+ if ( this . Update )
53+ {
54+ fsDemoRPC . UpdateServiceCred ( this . Node ) ;
55+ fsDemoRPC . UpdateServiceBinary ( this . Node ) ;
56+ return "Update Completes" ;
57+ }
58+ else
59+ {
60+ //example for reboot continue, just an example, you should build your own criteria for reboot-continue
61+ if ( this . ConfigFile . Contains ( "12345" ) )
62+ {
63+ result = fsDemoRPC . RunAfterRebootOnNode ( this . Node , File . ReadAllText ( this . ConfigFile ) ) ;
64+ return result . output ;
65+ }
66+ else
67+ {
68+ result = fsDemoRPC . RunOnNode ( this . Node , File . ReadAllText ( this . ConfigFile ) ) ;
69+ return result . output ;
70+ }
71+ }
72+ }
73+ }
74+ }
0 commit comments