private void RegisterWpiService() { lock (_lockRegisterWpiService) { try { ChannelServices.RegisterChannel(new TcpChannel(), true); } catch (System.Exception) { //ignor } if (null == RemotingConfiguration.IsWellKnownClientType(typeof(WPIServiceContract))) { RemotingConfiguration.RegisterWellKnownClientType(typeof(WPIServiceContract), string.Format("tcp://localhost:{0}/WPIServiceContract", WPIServiceContract.PORT)); } try { WPIServiceContract client = new WPIServiceContract(); client.Ping(); } catch (Exception) { //unable to connect //try to restart service KillWpiService(); //StartWpiService(); } } }
public string GetWPIStatus() { try { Log.WriteStart("GetWPIStatus"); RegisterWpiService(); WPIServiceContract client = new WPIServiceContract(); string status = client.GetStatus(); Log.WriteEnd("GetWPIStatus"); return(status); //OK } catch (Exception ex) { // done or error if (_WpiServiceExe == null || _WpiServiceExe.HasExited) { // reset WpiHelper for refresh status wpi = null; return(""); //OK } Log.WriteError("GetWPIStatus", ex); return(ex.ToString()); } }
public void InstallWPIProducts(string[] products) { try { Log.WriteStart("InstallWPIProducts"); StartWpiService(); RegisterWpiService(); WPIServiceContract client = new WPIServiceContract(); client.Initialize(_feeds); client.BeginInstallation(products); Log.WriteEnd("InstallWPIProducts"); } catch (Exception ex) { Log.WriteError("InstallWPIProducts", ex); throw; } }
public string WpiGetLogFileDirectory() { try { Log.WriteStart("WpiGetLogFileDirectory"); RegisterWpiService(); WPIServiceContract client = new WPIServiceContract(); string result = client.GetLogFileDirectory(); Log.WriteEnd("WpiGetLogFileDirectory"); return(result); //OK } catch (Exception ex) { Log.WriteError("WpiGetLogFileDirectory", ex); //throw; return(string.Empty); } }