using System; using System.Diagnostics; using System.IO; using System.Threading; namespace Seikactl { class Program { static int Main(string[] args) { Opts opt = new Opts(args); WCFClient scc =new WCFClient(); if (opt.isActive) { if (opt.isASWaitBoot) { if (0 < opt.ASWaitTime) { int times = 0; for (times = 0; times < opt.ASWaitTime; times++) { try { scc.Version(); break; } catch (Exception) { Thread.Sleep(1000); } } if (times == opt.ASWaitTime) { Console.WriteLine("not alive"); return 8; } } else { Console.WriteLine(@"value {0} is invalid.", opt.ASWaitTime); return 8; } } if (opt.isProdScan) { try { scc.ProductScan(); } catch (Exception e) { Console.WriteLine("fail. {0}", e.Message); return 8; } } if (opt.isBootHttpSrv) { try { scc.BootHttpService(); } catch (Exception e) { Console.WriteLine("fail. {0}", e.Message); return 8; } } if (opt.isASStartup) { try { var ps = new Process(); ps.StartInfo.UseShellExecute = false; ps.StartInfo.WorkingDirectory = Path.GetFullPath(opt.ASBootPath); ps.StartInfo.FileName = Path.Combine( opt.ASBootPath, "AssistantSeika.exe"); ps.Start(); } catch (Exception e) { Console.WriteLine("fail. {0}", e.Message); return 8; } } if (opt.isASShutdown) { try { scc.Shutdown(); } catch (Exception e) { Console.WriteLine("fail. {0}", e.Message); return 8; } } } return 0; } } }