public ForwardOptions Clone(ForwardOptions options) { // // Don't serialize a null object, simply return the default for that object // if (Object.ReferenceEquals(options, null)) { return(null); } if (!options.GetType().IsSerializable) { throw new ArgumentException("The type must be serializable.", "source"); } IFormatter formatter = new BinaryFormatter(); Stream stream = new MemoryStream(); using (stream) { formatter.Serialize(stream, options); stream.Seek(0, SeekOrigin.Begin); return((ForwardOptions)formatter.Deserialize(stream)); } }
public void SaveOptions() { _View.UpdateSettings(); if (_Settings != null) { _Settings.SetAddInCustomData <ForwardOptions>(_addinName, _customDataName, _View.Options); _Settings.Save(); } _Options = _View.Options; }
public void RunView(ForwardManagerConfigurationView view, AdvancedSettings settings) { ForwardOptions clonedOptions; _View = view; _Settings = settings; if (!DataAccessServices.IsDataAccessServiceRegistered <IAeManagementDataAccessAgent>()) { throw new InvalidOperationException(typeof(IAeManagementDataAccessAgent).Name + " is not registered."); } _AccessAgent = DataAccessServices.GetDataAccessService <IAeManagementDataAccessAgent>(); if (settings != null) { try { _Options = _Settings.GetAddInCustomData <ForwardOptions>(_addinName, _customDataName); if (_Options == null) { _Options = new ForwardOptions(); _Settings.SetAddInCustomData <ForwardOptions>(_addinName, _customDataName, _Options); _Settings.Save(); } } catch (Exception e) { Logger.Global.Exception("Forwarder", e); if (_Options == null) { _Options = new ForwardOptions(); } } clonedOptions = Clone(_Options); _View.Initialize(clonedOptions); _View.Enabled = false; } _View.SetAeTitles(_AccessAgent.GetAeTitles()); _View.Forward += new EventHandler <ForwardMessageEventArgs>(View_Forward); _View.Clean += new EventHandler <SendMessageEventArgs>(View_Clean); _View.Reset += new EventHandler <ResetEventArgs>(View_Reset); _View.SettingsChanged += new EventHandler(View_SettingsChanged); #if LEADTOOLS_V18_OR_LATER _View.CancelForward += new EventHandler <EventArgs>(View_CancelForward); _View.CancelClean += new EventHandler <EventArgs>(View_CancelClean); #endif // #if LEADTOOLS_V18_OR_LATER EventBroker.Instance.Subscribe <ClientAddedEventArgs>(new EventHandler <ClientAddedEventArgs>(OnClientAdded)); EventBroker.Instance.Subscribe <ClientRemovedEventArgs>(new EventHandler <ClientRemovedEventArgs>(OnClientRemoved)); EventBroker.Instance.Subscribe <ClientUpdatedEventArgs>(new EventHandler <ClientUpdatedEventArgs>(OnClientUpdated)); }
public void Initialize(ForwardOptions options) { _Options = options; if (_Options == null) { return; } InitializeSchedule(_Options.Forward, schedulerControlForward); InitializeSchedule(_Options.Clean, schedulerControlClean); InitializeInterval(); if (options.Forward != null && options.Forward.ExpirationTime < DateTime.Now) { checkBoxForwardEnable.Checked = false; } else { checkBoxForwardEnable.Checked = options.Forward != null; } if (options.Clean != null && options.Clean.ExpirationTime < DateTime.Now) { checkBoxCleanEnable.Checked = false; } else { checkBoxCleanEnable.Checked = options.Clean != null; } EnableForward(checkBoxForwardEnable.Checked); EnableClean(checkBoxCleanEnable.Checked); comboBoxHoldInterval.Items.Clear(); comboBoxHoldInterval.Items.Add(HoldInterval.Days); comboBoxHoldInterval.Items.Add(HoldInterval.Months); comboBoxHoldInterval.Items.Add(HoldInterval.Years); comboBoxHoldInterval.SelectedItem = _Options.HoldInterval; checkBoxVerify.Checked = _Options.Verify; if (_Options.ImageHold != null) { numericUpDownHoldAmount.Value = Convert.ToDecimal(_Options.ImageHold); } checkBoxCustomAE.Checked = _Options.UseCustomAE; textBoxCustomAE.Text = _Options.CustomAE; checkBoxCustomAE_CheckedChanged(checkBoxCustomAE, EventArgs.Empty); comboBoxReset.Text = "Today"; comboBoxReset_SelectionChangeCommitted(comboBoxReset, EventArgs.Empty); dateTimePickerResetEnd_ValueChanged(dateTimePickerResetEnd, EventArgs.Empty); InitializeDataAccess(); }
public void UpdateSettings(AdvancedSettings settings) { ForwardOptions clonedOptions; _Settings = settings; try { _Options = _Settings.GetAddInCustomData <ForwardOptions>(_addinName, _customDataName); if (_Options == null) { _Options = new ForwardOptions(); _Settings.SetAddInCustomData <ForwardOptions>(_addinName, _customDataName, _Options); _Settings.Save(); } } catch (Exception e) { Logger.Global.Exception("Forwarder", e); if (_Options == null) { _Options = new ForwardOptions(); } } clonedOptions = Clone(_Options); _View.Initialize(clonedOptions); _View.Enabled = true; if (_AccessAgent == null) { _AccessAgent = DataAccessServices.GetDataAccessService <IAeManagementDataAccessAgent>(); } _View.SetAeTitles(_AccessAgent.GetAeTitles()); }