//-------------------------------------------------------------------------------- /// <summary> /// Constructor /// </summary> public FormMainSetup() { InitializeComponent(); m_settings.Load(); foreach (SyncItem item in m_settings.SyncItems) { item.FileInfoEvent += new FileInfoHandler(item_FileInfoEvent); } m_updateThread = new Thread(new ThreadStart(UpdateThread)); m_updateThread.IsBackground = true; Globals.StarterProcess.Exited += new EventHandler(StarterProcess_Exited); try { if (SvcGlobals.CreateServiceHost()) { this.labelListening.Text = "Listening"; (SvcGlobals.SvcHost.SingletonInstance as SynchroService).SynchroHostEvent += new SynchroHostEventHandler(Form1_SynchroHostEvent); } } catch (Exception ex) { if (ex != null) { } } }
//-------------------------------------------------------------------------------- /// <summary> /// Updates the activity list box /// </summary> /// <param name="text"></param> private void UpdateActivityList(string text, DateTime date) { text = string.Format("{0} - {1}", DateTime.Now.ToString("dd MMM yyyy HH:mm"), text); this.listBoxActivity.Items.Insert(0, text); if (SvcGlobals.CreateServiceClient()) { SvcGlobals.SvcClient.SendStatusMessageEx(text, date); } }
//-------------------------------------------------------------------------------- public FormMain() { InitializeComponent(); try { if (SvcGlobals.CreateServiceHost()) { //SvcGlobals.SynchroHostEvent += new SynchroHostEventHandler(SvcGlobals_SynchroHostEvent); //SynchroService host = SvcGlobals.SvcHost.SingletonInstance as SynchroService; (SvcGlobals.SvcHost.SingletonInstance as SynchroService).SynchroHostEvent += new SynchroHostEventHandler(Form1_SynchroHostEvent); } } catch (Exception ex) { if (ex != null) { } } }
//-------------------------------------------------------------------------------- /// <summary> /// Updates the activity list box /// </summary> /// <param name="text"></param> private void UpdateActivityList(string text, DateTime date) { string dateFormat = "dd MMM yyyy HH:mm"; string errorTemplate = "{0} - Exception: {1}"; string errorText = ""; string connectStatus = "Server Not Found"; text = string.Format("{0} - {1}", date.ToString(dateFormat), text); this.listBoxActivity.Items.Insert(0, text); try { if (SvcGlobals.CreateServiceClient()) { SvcGlobals.SvcClient.SendStatusMessageEx(text, date); connectStatus = "Connected"; } } catch (EndpointNotFoundException) { errorText = "No endpoint found."; } catch (CommunicationObjectFaultedException) { errorText = "WCF client object is faulted."; } catch (Exception ex) { errorText = ex.Message; } if (!string.IsNullOrEmpty(errorText)) { this.listBoxActivity.Items.Insert(0, string.Format(errorTemplate, date.ToString(dateFormat), errorText)); } labelConnected.Text = connectStatus; }
//-------------------------------------------------------------------------------- /// <summary> /// Updates the activity list box /// </summary> /// <param name="text"></param> private void UpdateActivityList(string text, DateTime date) { //string dateFormat = "dd MMM yyyy HH:mm"; //string errorText = ""; //DateTime now = DateTime.Now; //text = string.Format("{0} - {1}", date.ToString(dateFormat), text); string errorText = ""; DateTime now = DateTime.Now; try { if (SvcGlobals.CreateServiceClient()) { SvcGlobals.SvcClient.SendStatusMessageEx(text, date); } } catch (EndpointNotFoundException) { errorText = "No endpoint found."; } catch (CommunicationObjectFaultedException) { errorText = "WCF client object is faulted."; } catch (Exception ex) { errorText = ex.Message; } if (!string.IsNullOrEmpty(errorText)) { m_log.SendErrorToLog(errorText); m_log.SendToLog(text, AppLog.LogLevel.Noise); } }