private void SetConfigData(LogNotifierDataSet dataSet) { if (dataSet == null) { return; } textBoxFiltersInclude.Text = String.Join(Environment.NewLine, dataSet.IncludeItems); textBoxFiltersExclude.Text = String.Join(Environment.NewLine, dataSet.ExcludeItems); textBoxSMTPEmail.Text = dataSet.EmailAccount; textBoxServer.Text = dataSet.EmailServer; textBoxPort.Text = dataSet.EmailPort; textBoxCell.Text = dataSet.CellNumber; comboBoxService.SelectedItem = dataSet.CellProvider; textBoxSendToEmail.Text = dataSet.SendToEmailAccount; radioButtonText.Checked = dataSet.SendText; radioButtonEmail.Checked = !dataSet.SendText; checkBoxEnabled.Checked = dataSet.Enabled; checkBoxStopNotifications.Checked = dataSet.StopNotifications; checkBoxPlaySound.Checked = dataSet.Playsound; }
private void WriteConfigData() { string fileName = GetConfigPath(); try { Directory.CreateDirectory(System.IO.Path.GetDirectoryName(fileName)); TextWriter WriteFileStream = new StreamWriter(fileName, false); XmlSerializer SerializerObj = new XmlSerializer(typeof(LogNotifierDataSet)); LogNotifierDataSet set = GetConfigData(); SerializerObj.Serialize(WriteFileStream, set); WriteFileStream.Close(); } catch (Exception e) { System.Diagnostics.Trace.WriteLine(e.ToString()); } }
private void ReadConfigData() { string fileName = GetConfigPath(); try { FileStream ReadFileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read); XmlSerializer SerializerObj = new XmlSerializer(typeof(LogNotifierDataSet)); LogNotifierDataSet loadedData = (LogNotifierDataSet)SerializerObj.Deserialize(ReadFileStream); SetConfigData(loadedData); ReadFileStream.Close(); } catch (Exception e) { SetConfigData(null); System.Diagnostics.Trace.WriteLine(e.ToString()); } }
LogNotifierDataSet GetConfigData() { LogNotifierDataSet dataSet = new LogNotifierDataSet(); dataSet.IncludeItems = Enumerable.ToList(GetTextBoxStringAsArray(ref textBoxFiltersInclude)); dataSet.ExcludeItems = Enumerable.ToList(GetTextBoxStringAsArray(ref textBoxFiltersExclude)); dataSet.EmailAccount = textBoxSMTPEmail.Text; dataSet.EmailServer = textBoxServer.Text; dataSet.EmailPort = textBoxPort.Text; dataSet.CellNumber = textBoxCell.Text; dataSet.CellProvider = comboBoxService.SelectedItem.ToString(); dataSet.SendToEmailAccount = textBoxSendToEmail.Text; dataSet.SendText = radioButtonText.Checked; dataSet.Enabled = checkBoxEnabled.Checked; dataSet.StopNotifications = checkBoxStopNotifications.Checked; dataSet.Playsound = checkBoxPlaySound.Checked; return(dataSet); }
LogNotifierDataSet GetConfigData() { LogNotifierDataSet dataSet = new LogNotifierDataSet(); dataSet.IncludeItems = Enumerable.ToList(GetTextBoxStringAsArray(ref textBoxFiltersInclude)); dataSet.ExcludeItems = Enumerable.ToList(GetTextBoxStringAsArray(ref textBoxFiltersExclude)); dataSet.EmailAccount = textBoxSMTPEmail.Text; dataSet.EmailServer = textBoxServer.Text; dataSet.EmailPort = textBoxPort.Text; dataSet.CellNumber = textBoxCell.Text; dataSet.CellProvider = comboBoxService.SelectedItem.ToString(); dataSet.SendToEmailAccount = textBoxSendToEmail.Text; dataSet.SendText = radioButtonText.Checked; dataSet.Enabled = checkBoxEnabled.Checked; dataSet.StopNotifications = checkBoxStopNotifications.Checked; dataSet.Playsound = checkBoxPlaySound.Checked; return dataSet; }