/// <summary> /// stop tracing command /// </summary> internal void StopTracing() { if (this.CaptureScreenShots) // create html report also if no tracing was active perhaps someone finds this functionality in itself useful { var htmlReportGenerator = new HtmlReportGenerator(this.ScreenshotDirectory); htmlReportGenerator.GenerateReport(); } StopData = new ViewModelFrozenData(this) { TraceStopFullCommandLine = LocalTraceSettings.TraceStopFullCommandLine, TraceStopNotExpanded = LocalTraceSettings.TraceStop, TraceFileName = TraceFileName, TraceStartTime = this._TraceStartTime, }; if (this.LocalTraceEnabled) { LocalTraceSettings.TraceStates = TraceStates.Stopping; // stop tracing asynchronously so we do not need to wait until local trace collection has stopped (while blocking the UI) Task.Factory.StartNew <Tuple <int, string> >(() => LocalTraceControler.ExecuteWPRCommand(StopData.TraceStopFullCommandLine)) .ContinueWith((t) => LocalTraceSettings.ProcessStopCommand(t.Result), UISheduler); } if (this.ServerTraceEnabled) { ServerTraceSettings.TraceStates = TraceStates.Stopping; var command = WCFHost.CreateExecuteWPRCommand(StopData.TraceStopFullCommandLine); command.Completed = (output) => ServerTraceSettings.ProcessStopCommand(output); command.Execute(); } this.TraceFileCounter++; }
protected override void OnStop() { (new Thread(() => { WCFHost.CloseHost(); })).Start(); }
public static void Start() { TestService.Start(); WCFHost host = new WCFHost(); host.open(); }
protected override void OnStart(string[] args) { TestService.Start(); WCFHost host = new WCFHost(); host.open(); Log4netHelper.Debug("OnStart", "服务开始"); }
public void Dispose() { try { WCFHost?.Stop(); WCFClient?.Dispose(); } catch { } }
/// <summary> /// Cancel Tracing command /// </summary> private void CancelTracing() { if (this.LocalTraceEnabled) { var output = LocalTraceControler.ExecuteWPRCommand(LocalTraceSettings.TraceCancel); LocalTraceSettings.ProcessCancelCommand(output); } if (this.ServerTraceEnabled) { var command = WCFHost.CreateExecuteWPRCommand(ServerTraceSettings.TraceCancel); command.Completed = (output) => ServerTraceSettings.ProcessCancelCommand(output); command.Execute(); } }
protected override void OnStart(string[] args) { (new Thread(() => { if (args.Length > 0) { if (System.IO.Directory.Exists(args[0])) { fileSystemWatcher.Path = args[0]; FileSaverWorker.WriteFolderWatcherPath(args[0]); lomf.ResetList(); } } WCFHost.DoWork(); })).Start(); }
public static void EnableHttps() { lock (Https_EnableOneAtATime) { Logger.Log("Enabling Https (Secure) Host on Port " + OPCBackEnd.Config.Https_Port + "..."); WCFHost_Https = new WCFHost <OPCBrowserContract, iOPCBrowserContract>(OPCBackEnd.Config.Https_Port, HostProtocolType.HTTPS, OPCBackEnd.Config.RequireAPIBasicAuthentication); if (OPCBackEnd.Config.RequireAPIBasicAuthentication) { Logger.Log("Enabling Username and Password Authentication for Https Secure Host..."); WCFHost_Https.EnableUserAuthentication = true; WCFHost_Https.OnValidatingUsernamePassword = (UN, PW) => { return(UN.ToLower() == OPCBackEnd.Config.Username_ForAPIBasicAuthentication.ToLower() && PW == OPCBackEnd.Config.Password_ForAPIBasicAuthentication); }; } WCFHost_Https.Start(); } }
public static void EnableHttp() { lock (Http_EnableOneAtATime) { Logger.Log("Enabling Http Host on Port " + OPCBackEnd.Config.Http_Port + "..."); WCFHost_Http = new WCFHost <OPCBrowserContract, iOPCBrowserContract>(OPCBackEnd.Config.Http_Port, HostProtocolType.HTTP, OPCBackEnd.Config.RequireAPIBasicAuthentication); if (OPCBackEnd.Config.RequireAPIBasicAuthentication) { Logger.Log("Enabling Username and Password Authentication for Http Host..."); WCFHost_Http.EnableUserAuthentication = true; WCFHost_Http.OnValidatingUsernamePassword = (string UN, string PW, out UserBase User) => { User = null; return(UN.ToLower() == OPCBackEnd.Config.Username_ForAPIBasicAuthentication.ToLower() && PW == OPCBackEnd.Config.Password_ForAPIBasicAuthentication); }; } WCFHost_Http.Start(); } }
/// <summary> /// Start Tracing /// </summary> private void StartTracing() { if (!this.LocalTraceEnabled && !this.ServerTraceEnabled) { MessageBoxDisplay.ShowMessage("Please enable tracing at the remote host and/or on your local machine.", "Warning"); return; } this.Hooker.ResetId(); if (this.LocalTraceEnabled) // start async to allow the web service to start tracing simultanously on the target host { _TraceStartTime = DateTime.Now; LocalTraceSettings.TraceStates = TraceStates.Starting; if (File.Exists(TraceFileName)) { try { File.Delete(TraceFileName); } catch (Exception ex) { MessageBoxDisplay.ShowMessage($"Could not delete old trace file {TraceFileName}. Is the file still open in WPA? Full error: {ex}", "Error"); LocalTraceSettings.TraceStates = TraceStates.Stopped; return; } } Task.Factory.StartNew <Tuple <int, string> >(() => LocalTraceControler.ExecuteWPRCommand(LocalTraceSettings.TraceStartFullCommandLine)) .ContinueWith(t => LocalTraceSettings.ProcessStartCommand(t.Result), UISheduler); } if (this.ServerTraceEnabled) { ServerTraceSettings.TraceStates = TraceStates.Starting; var command = WCFHost.CreateExecuteWPRCommand(ServerTraceSettings.TraceStartFullCommandLine); command.Completed = (output) => ServerTraceSettings.ProcessStartCommand(output); command.Execute(); } }
public OPCBackEnd() { Logger.ClearLogs(); if (!Global.Product.TryLoadConfigFile()) { throw new CustomException("FATAL ERROR: Unable to load Config File '" + Global.Product.ConfigFilePath + "'"); } OPCBackEnd.Config = (OPCBackEndConfig)Global.Product.Config; Logger.EnableLogger(); Thread.Sleep(100); Logger.Log("***************************************************"); Thread.Sleep(100); Logger.Log("VLIX OPC (BACK END) STARTED"); Thread.Sleep(100); Logger.Log("***************************************************"); Thread.Sleep(100); Logger.Log("Log Path = '" + Global.Product.LogFilePath + "'"); OPCBackEnd.OPCClassicBrowserEngine = new OPCClassicBrowserEngine(); OPCBackEnd.OPCUABrowserEngine = new OPCUABrowserEngine(); //************************************************* // REPORT NUMBER OF CALLS PER MINUTE //************************************************* (new Thread(async() => { while (true) { DateTime DTGate = DateTime.UtcNow.AddMinutes(-1); int TotalCallsLastMinute = TotalAPICalls.Count(C => C > DTGate); Logger.Log("Total API Calls Last Minute = " + TotalCallsLastMinute); try { TotalAPICalls.RemoveWhere(C => C < DTGate); } catch { } await Task.Delay(30000); } })).Start(); //************************************************* // ENABLE NAMED PIPE FOR CONFIGURATION FRONT END //************************************************* string LocalPipeName = Global.GetLocalPipeName(); WCFHost_Pipe = new WCFHost <VlixOPCContract, iVlixOPCContract>(LocalPipeName, ""); WCFHost_Pipe.Start(); //**************************************** // ENABLE HTTP //**************************************** if (OPCBackEnd.Config.EnableAPI_Http) { OPCBackEnd.EnableHttp(); } else { Logger.Log("Http API not Enabled"); } //**************************************** // ENABLE HTTPS //**************************************** if (OPCBackEnd.Config.EnableAPI_Https) { OPCBackEnd.EnableHttps(); } else { Logger.Log("Https Secure API not Enabled"); } }
/// <summary> /// THe main Class for the OPC Back End /// </summary> /// <param name="LocalPipeName">Use for OPC Admin Communication</param> public OPCBackEnd(string LocalPipeName = null) { Logger.ClearLogs(); if (!Global.Product.TryLoadConfigFile()) { throw new CustomException("FATAL ERROR: Unable to load Config File '" + Global.Product.ConfigFilePath + "'"); } OPCBackEnd.Config = (OPCBackEndConfig)Global.Product.Config; Logger.EnableLogger(); Thread.Sleep(100); Logger.Log("***************************************************"); Thread.Sleep(100); Logger.Log("VLIX OPC (BACK END) STARTED"); Thread.Sleep(100); Logger.Log("***************************************************"); Thread.Sleep(100); Logger.Log("Log Path = '" + Global.Product.LogFilePath + "'"); OPCBackEnd.OPCClassicBrowserEngine = new OPCClassicBrowserEngine(); OPCBackEnd.OPCUABrowserEngine = new OPCUABrowserEngine(); //************************************************* // REPORT NUMBER OF CALLS PER MINUTE //************************************************* (new Thread(async() => { while (true) { DateTime DTGate = DateTime.UtcNow.AddMinutes(-1); int TotalCallsLastMinute = TotalAPICalls.Count(C => C > DTGate); Logger.Log("Total API Calls Last Minute = " + TotalCallsLastMinute); try { TotalAPICalls.RemoveWhere(C => C < DTGate); } catch { } await Task.Delay(120000); } })).Start(); //************************************************* // ENABLE NAMED PIPE AND NET TCP FOR CONFIGURATION FRONT END //************************************************* if (LocalPipeName.IsNullOrWhiteSpace()) { LocalPipeName = "VlixOPC"; } //string LocalPipeName = GlobalWCF.GetLocalPipeName(); WCFHost_Pipe = new WCFHost <OPCServiceContract, iOPCServiceContract>(LocalPipeName, ""); WCFHost_Pipe.Start(); WCFHost_Tcp = new WCFHost <OPCServiceContract, iOPCServiceContract>(OPCBackEnd.Config.Tcp_Port, HostProtocolType.NetTCPSecure, OPCBackEnd.Config.Enable_Tcp_Authentication) { OnValidatingUsernamePassword = (string UN, string PW, out UserBase user) => { user = null; return(string.Equals(UN, OPCBackEnd.Config.Tcp_Username, StringComparison.OrdinalIgnoreCase) && PW == OPCBackEnd.Config.Tcp_Password); } }; WCFHost_Tcp.Start(); //**************************************** // ENABLE HTTP //**************************************** if (OPCBackEnd.Config.Enable_WebAPI_Http) { OPCBackEnd.EnableHttp(); } else { Logger.Log("Http API not Enabled"); } //**************************************** // ENABLE HTTPS //**************************************** if (OPCBackEnd.Config.Enable_WebAPI_Https) { OPCBackEnd.EnableHttps(); } else { Logger.Log("Https Secure API not Enabled"); } }