private void Form1_Load(object sender, EventArgs e) { var xM = new XmlMiddleware <NotiferModel>(NotifierFileInfo.FilePath, NotifierFileInfo.FileName, NotifierFileInfo.RootNodeName); NotiferModel currentModel = xM.Read(); dtpExpiration.Value = currentModel.GetExpirationDate(); tbxMessage.Text = currentModel.Message; }
static void Main(string[] args) { DateTime triggerDate = DateTime.Parse(System.Configuration.ConfigurationManager.AppSettings["TriggerDateTime"]); IMiddleware <NotiferModel> xM = new XmlMiddleware <NotiferModel>(NotifierFileInfo.FilePath, NotifierFileInfo.FileName, NotifierFileInfo.RootNodeName); NotiferModel readData = xM.Read(); NotiferModel currentModel = readData == null ? new NotiferModel() : readData; if (currentModel.GetExpirationDate() < triggerDate) { MessageBox.Show(currentModel.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); NotiferModel newModel = currentModel; newModel.Expiration = DateTime.Now.AddDays(1).ToShortDateString(); xM.Write(newModel); } }
private void btnSave_Click(object sender, EventArgs e) { try { NotiferModel model = new NotiferModel() { Expiration = dtpExpiration.Value.ToShortDateString(), Message = tbxMessage.Text }; var xM = new XmlMiddleware <NotiferModel>(NotifierFileInfo.FilePath, NotifierFileInfo.FileName, NotifierFileInfo.RootNodeName); xM.Write(model); lblError.Visible = false; } catch { lblError.Text = "Error has occured"; lblError.Visible = true; } }