private void Window_Closing(object sender, CancelEventArgs e) { if (!closeApplication) { if (hostComm != null) { hostComm.ShutDown(); hostComm = null; } ShutdownACSServer(); var hwnd = new WindowInteropHelper(this).Handle; SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_SYSMENU); e.Cancel = true; Thread SaveCaseListThread = new Thread(new ParameterizedThreadStart(delegate { SaveCaseListThreadMethod(e); })); SaveCaseListThread.Start(); } else { e.Cancel = false; } }
private void StartApplicationThreadMethod() { try { if (hostComm == null) { hostComm = new HostComm(); hostComm.ConnectedToHostEvent += new HostComm.ConnectedToHostHandler(m_HostComm_Impl_ConnectedToHostEvent); hostComm.StartUp(); } acsServer = new ACSServer(hostComm, log, _localCaseListPath, out caseList); acsServer.CaseListUpdateEvent += new ACSServer.CaseListUpdateHandler(UpdateCaseList); acsServer.StartUp(); log.PrintLine("Network service (re)started."); if (caseList.FullSyncStarted) { FullSyncMenuItem.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { FullSyncMenuItem.Header = "Stop Sync"; })); } } catch (Exception exp) { log.PrintInfoLine("StartApplicationThreadMethod exp: " + exp); } }
public ACSServer(HostComm hostComm, L3.Cargo.Communications.Common.Logger log, string localCaseListPath, out CaseList caseList) { string uri = (String)ConfigurationManager.AppSettings["ConnectionUri"]; string AllowedIPList = (String)ConfigurationManager.AppSettings["AllowedIPList"]; string path = localCaseListPath; string caseListSource = (path == null ? (String)ConfigurationManager.AppSettings["CaseListSource"] : "File System" ); string Alias = (String)ConfigurationManager.AppSettings["ServerName"]; m_ProfilesFolder = ConfigurationManager.AppSettings["UserProfiles"]; bool isReference; if (ConfigurationManager.AppSettings["ACSMode"].Equals("Archive")) { isReference = false; if (path == null) path = ConfigurationManager.AppSettings["CaseListFileSystemPath"]; } else { isReference = true; if (path == null) path = ConfigurationManager.AppSettings["ReferenceFileSystemPath"]; } if (caseListSource == "File System") caseList = new FSCaseList(log, path, isReference); else caseList = new DBCaseList(log, path, isReference); caseList.configFullSync(); base.Subscribe(caseList); base.caseList = caseList; bool loginRequired = Boolean.Parse(ConfigurationManager.AppSettings["LoginRequired"]); acsCommHost = new NetworkHost(this, new Uri(uri), Alias, AllowedIPList, loginRequired); acsCommHost.SendTimeoutMin = int.Parse(ConfigurationManager.AppSettings["WcfTcpBindingSendTimeoutMin"]); acsCommHost.ReceiveTimeoutMin = int.Parse(ConfigurationManager.AppSettings["WcfTcpBindingReceiveTimeoutMin"]); EnableArchiveDecision = Boolean.Parse(ConfigurationManager.AppSettings["EnableArchiveDecision"]); caseList.List.CaseListTable.CaseListTableRowChanged += new CaseListDataSet.CaseListTableRowChangeEventHandler(CaseListTable_RowChanged); caseList.List.CaseListTable.CaseListTableRowDeleting += new CaseListDataSet.CaseListTableRowChangeEventHandler(CaseListTable_RowChanged); m_HostComm = hostComm; m_HostComm.ConnectedToHostEvent += new HostComm.ConnectedToHostHandler(hostComm_ConnectedToHostEvent); m_WSCallbacks = new Dictionary<String, ICaseRequestManagerCallback>(); m_WSLastPing = new Dictionary<String, DateTime>(); ClientConnThread = new Thread(new ThreadStart(ClientConnState)); }
public ACSServer(HostComm hostComm, L3.Cargo.Communications.Common.Logger log, string localCaseListPath, out CaseList caseList) { string uri = (String)ConfigurationManager.AppSettings["ConnectionUri"]; string AllowedIPList = (String)ConfigurationManager.AppSettings["AllowedIPList"]; string path = localCaseListPath; string caseListSource = (path == null ? (String)ConfigurationManager.AppSettings["CaseListSource"] : "File System" ); string Alias = (String)ConfigurationManager.AppSettings["ServerName"]; m_ProfilesFolder = ConfigurationManager.AppSettings["UserProfiles"]; bool isReference; if (ConfigurationManager.AppSettings["ACSMode"].Equals("Archive")) { isReference = false; if (path == null) { path = ConfigurationManager.AppSettings["CaseListFileSystemPath"]; } } else { isReference = true; if (path == null) { path = ConfigurationManager.AppSettings["ReferenceFileSystemPath"]; } } if (caseListSource == "File System") { caseList = new FSCaseList(log, path, isReference); } else { caseList = new DBCaseList(log, path, isReference); } caseList.configFullSync(); base.Subscribe(caseList); base.caseList = caseList; bool loginRequired = Boolean.Parse(ConfigurationManager.AppSettings["LoginRequired"]); acsCommHost = new NetworkHost(this, new Uri(uri), Alias, AllowedIPList, loginRequired); acsCommHost.SendTimeoutMin = int.Parse(ConfigurationManager.AppSettings["WcfTcpBindingSendTimeoutMin"]); acsCommHost.ReceiveTimeoutMin = int.Parse(ConfigurationManager.AppSettings["WcfTcpBindingReceiveTimeoutMin"]); EnableArchiveDecision = Boolean.Parse(ConfigurationManager.AppSettings["EnableArchiveDecision"]); caseList.List.CaseListTable.CaseListTableRowChanged += new CaseListDataSet.CaseListTableRowChangeEventHandler(CaseListTable_RowChanged); caseList.List.CaseListTable.CaseListTableRowDeleting += new CaseListDataSet.CaseListTableRowChangeEventHandler(CaseListTable_RowChanged); m_HostComm = hostComm; m_HostComm.ConnectedToHostEvent += new HostComm.ConnectedToHostHandler(hostComm_ConnectedToHostEvent); m_WSCallbacks = new Dictionary <String, ICaseRequestManagerCallback>(); m_WSLastPing = new Dictionary <String, DateTime>(); ClientConnThread = new Thread(new ThreadStart(ClientConnState)); }