protected override void MessageReceived(object sender, Shared.Communication.Message message) { base.MessageReceived(sender, message); switch (message.Title) { case StringConstants.LOAD_CLIENT_DETAILS: message.Title = StringConstants.CREATE_SETTINGS; message.Contents = ServerBaseControl.ConvertToJson <ServiceSettings>(_serviceSettings); MessageRespond(message); message.Contents = ServerBaseControl.ConvertToJson <ServiceSettings>(_SmtpServer); MessageRespond(message); message.Title = StringConstants.LOAD_CLIENT_DETAILS; break; case StringConstants.Service.SERVICE_SETTINGS_SAVE: SaveServiceSettings(ServerBaseControl.ConvertFromJson <ServiceSettings>(message.Contents)); return; case StringConstants.Service.SERVICE_EMAIL_SETTINGS_SAVE: SaveEmailSettings(ServerBaseControl.ConvertFromJson <ServiceSettings>(message.Contents)); return; } _pluginManager.ProcessMessage(message); }
private void btnCancelReplication_Click(object sender, EventArgs e) { #if DEBUG Shared.EventLog.Debug("Sync " + System.Reflection.MethodBase.GetCurrentMethod().Name); #endif Shared.Communication.Message msg = new Shared.Communication.Message("CANCELREPLICATION", "true", MessageType.Command); SendMessage(msg); }
private void btnHardConfirm_Click(object sender, EventArgs e) { #if DEBUG Shared.EventLog.Debug("Sync " + System.Reflection.MethodBase.GetCurrentMethod().Name); #endif Shared.Communication.Message msg = new Shared.Communication.Message("FORCEHARDCOUNT", "true", MessageType.Command); SendMessage(msg); }
private void btnPreventReplication_Click(object sender, EventArgs e) { #if DEBUG Shared.EventLog.Debug("Sync " + System.Reflection.MethodBase.GetCurrentMethod().Name); #endif Shared.Communication.Message msg = new Shared.Communication.Message("PREVENT", "", MessageType.Command); SendMessage(msg); }
private void SendToTCPClients(Int64 oldID, Int64 newID, string location) { #if DEBUG Shared.EventLog.Debug("RepThread " + System.Reflection.MethodBase.GetCurrentMethod().Name); #endif Shared.Communication.Message msg = new Shared.Communication.Message("IDCHANGED", String.Format("{0}${1}${2}", oldID, newID, location), MessageType.Command); UpdateBackupReplication.INSTANCE.SendMessage(msg); }
private void contextMenuThreadsRefresh_Click(object sender, EventArgs e) { #if DEBUG Shared.EventLog.Debug("Sync " + System.Reflection.MethodBase.GetCurrentMethod().Name); #endif Shared.Communication.Message msg = new Shared.Communication.Message("THREAD_USAGE", "", MessageType.Command); SendMessage(msg); }
private void SendMessage(Shared.Communication.Message message) { if (cmbClient.SelectedIndex > -1) { message.Title = String.Format("{0}@{1}", message.Title, (string)cmbClient.SelectedItem); } _client.SendMessage(message); }
public void MessageRespond(Shared.Communication.Message message) { if (message == null) { throw new ArgumentNullException(nameof(message)); } MessageSend(message, false); }
public void BroadCastMessage(Shared.Communication.Message message) { if (message == null) { throw new ArgumentNullException(nameof(message)); } MessageSend(message, true); }
private void SynchClient_FormClosing(object sender, FormClosingEventArgs e) { #if DEBUG Shared.EventLog.Debug("Sync " + System.Reflection.MethodBase.GetCurrentMethod().Name); #endif Shared.Communication.Message msg = new Shared.Communication.Message("ALLOWCONFIRMCOUNTS", Convert.ToString(true), MessageType.Command); SendMessage(msg); if (_client != null && _client.IsRunning) { _client.StopListening(); } }
private void SendToTCPClients(string Text) { #if DEBUG Shared.EventLog.Debug("RepThread " + System.Reflection.MethodBase.GetCurrentMethod().Name); Shared.EventLog.Debug("RepThread " + Text); #endif try { Shared.Communication.Message msg = new Shared.Communication.Message( String.Format("Replication Engine@{0}", _databaseConnection.Name), Text, MessageType.Info); UpdateBackupReplication.INSTANCE.SendMessage(msg); } catch (Exception err) { Shared.EventLog.Add(err); } }
private void btnBackupDatabase_Click(object sender, EventArgs e) { Shared.Communication.Message msg = new Shared.Communication.Message("FORCE_BACKUP", "", MessageType.Command); SendMessage(msg); }
void _client_MessageReceived(object sender, Shared.Communication.Message message) { #if DEBUG Shared.EventLog.Debug("Sync " + System.Reflection.MethodBase.GetCurrentMethod().Name); string msgAsString = new string(Shared.Communication.Message.MessageToStringArray(message)); Shared.EventLog.Debug("Sync " + msgAsString); #endif try { if (this.InvokeRequired) { MessageReceivedEventHandler mreh = new MessageReceivedEventHandler(_client_MessageReceived); this.Invoke(mreh, new object[] { sender, message }); } else { if (message.Title == "REPLICATION_CLIENTS") { cmbClient.Items.Clear(); cmbClient.Items.Add("All"); string[] clients = message.Contents.Split('#'); foreach (string client in clients) { if (String.IsNullOrEmpty(client.Trim())) { continue; } cmbClient.Items.Add(client); } if (cmbClient.Items.Count > 0) { cmbClient.SelectedIndex = 0; } return; } else if (message.Title.StartsWith("THREAD_USAGE")) { UpdateThreadData(message.Contents); return; } else if (message.Title == "THREAD_CPU_CHANGED") { decimal value = Shared.Utilities.StrToDecimal(message.Contents, 0); tsCPU.Text = String.Format("CPU {0}%", Math.Round(value, 2)); return; } else if (message.Title == "CONFIGURATION_CHANGED") { SendMessage(new Shared.Communication.Message("REPLICATION_CLIENTS", String.Empty, MessageType.Command)); SendMessage(new Shared.Communication.Message("REPLICATION_RUNNING", String.Empty, MessageType.Command)); SendMessage(new Shared.Communication.Message("REPLICATION_RUNTIME", String.Empty, MessageType.Command)); SendMessage(new Shared.Communication.Message("REPLICATION_ENABLED", String.Empty, MessageType.Command)); SendMessage(new Shared.Communication.Message("THREAD_USAGE", String.Empty, MessageType.Command)); return; } bool addMessage = true; string[] clientHeader = message.Title.Split('@'); if (cmbClient.SelectedIndex > 0 && clientHeader[1] != (string)cmbClient.SelectedItem) { return; } if (clientHeader[0] == "REPLICATION_RUNNING") { _replicationRunning = message.Contents.ToUpper() == "TRUE"; if (_replicationRunning) { tsLabelTimeTillRun.Text = "Replicating "; } addMessage = false; } else if (clientHeader[0] == "REPLICATION_ENABLED") { _replicationEnabled = message.Contents.ToUpper() == "TRUE"; btnCancelReplication.Enabled = _replicationEnabled; btnForceReplication.Enabled = _replicationEnabled; btnPreventReplication.Enabled = _replicationEnabled; btnHardConfirm.Enabled = _replicationEnabled; if (!_replicationEnabled) { tsLabelTimeTillRun.Text = "Replication Disabled"; } addMessage = false; } else if (clientHeader[0] == "FORCEHARDCOUNT") { addMessage = false; } else if (clientHeader[0] == "REPLICATION_RUNTIME") { Int64 time = Shared.Utilities.StrToInt64(message.Contents, 0); _replicationStartTime = DateTime.FromFileTimeUtc(time); addMessage = false; } if (message.Contents.StartsWith("#STATUS#")) { if (message.Contents.Contains(";")) { tsStatus.Text = message.Contents.Substring(message.Contents.IndexOf(";") + 2); } else { tsStatus.Text = message.Contents.Replace("#STATUS#", ""); } } else if (message.Contents.StartsWith("#MISSING#")) { tsMissingCount.Text = String.Format("Missing Records: {0} ", message.Contents.Replace("#MISSING#", "")); } else if (message.Contents.StartsWith("Sleeping, time until next run")) { if (cmbClient.SelectedIndex == 0) { tsLabelTimeTillRun.Text = String.Empty; } else if (_replicationEnabled) { tsLabelTimeTillRun.Text = String.Format("Next Run: {0}", message.Contents.Substring(30)); } else { tsLabelTimeTillRun.Text = "Replication Disabled"; } tsLabelTimeTillRun.Invalidate(); } else if (message.Contents.StartsWith("Run Replication")) { _replicationRunning = true; _replicationStartTime = DateTime.Now; tsLabelTimeTillRun.Text = "Replicating "; int idx = lstReplicationMessages.Items.Add(message.Contents); //lstReplicationMessages.SelectedIndex = idx; if (cbAutoScroll.Checked) { lstReplicationMessages.SelectedIndex = idx; } } else if (message.Contents.Contains("Replication End")) { _replicationRunning = false; tsLabelTimeTillRun.Text = ""; tsMissingCount.Text = ""; tsStatus.Text = ""; int idx = lstReplicationMessages.Items.Add(message.Contents); //lstReplicationMessages.SelectedIndex = idx; if (cbAutoScroll.Checked) { lstReplicationMessages.SelectedIndex = idx; } } else { if (addMessage) { int idx = lstReplicationMessages.Items.Add(message.Contents); //lstReplicationMessages.SelectedIndex = idx; if (cbAutoScroll.Checked) { lstReplicationMessages.SelectedIndex = idx; } System.Threading.Thread.Sleep(1); Application.DoEvents(); } } } } catch (Exception err) { int idx = lstReplicationMessages.Items.Add(err.Message); lstReplicationMessages.SelectedIndex = idx; } }