private void CheckTasks() { UltraCalendarInfo ultraCalendarInfo = new UltraCalendarInfo(); ultraCalendarInfo.AllowRecurringAppointments = true; TaskSchedulesDAO lTaskSchedulesDAO = new TaskSchedulesDAO(); SettingsDAO lSettingsDAO = new SettingsDAO(); Appointment appointment; object rawAppointmentData; try { foreach (DataRow row in lTaskSchedulesDAO.GetAllAppointments().Rows) { rawAppointmentData = row["_APPOINTMENTDATA"]; if (rawAppointmentData is byte[] == false) { continue; } appointment = Appointment.FromBytes(rawAppointmentData as byte[]); appointment.DataKey = row[0]; ultraCalendarInfo.Appointments.Add(appointment); } string strLastReportRunTime = lSettingsDAO.GetSetting("LastTaskReportRun", false); DateTime lLastReportRunDateTime = (strLastReportRunTime == "") ? DateTime.MinValue : Convert.ToDateTime(strLastReportRunTime); DateTime lReportRunTime = DateTime.Now; AppointmentsSubsetCollection expiredAppointments = ultraCalendarInfo.GetAppointmentsInRange(lLastReportRunDateTime, lReportRunTime); lSettingsDAO.SetSetting("LastTaskReportRun", DateTime.Now.ToString(), false); foreach (Appointment expiredAppointment in expiredAppointments) { // need to re-check that this appointment is between the LastTaskReportRun date and DateTime.Now // there is a hole in the ultraCalendarInfo.GetAppointmentsInRange logic above if ((lLastReportRunDateTime < expiredAppointment.StartDateTime) && (lReportRunTime > expiredAppointment.StartDateTime)) { string lSubject = String.Format("The following task is due at {0}." + Environment.NewLine + Environment.NewLine + expiredAppointment.Subject, expiredAppointment.StartDateTime.ToString()); DesktopAlert.ShowDesktopAlertForTasks(lSubject, (int)expiredAppointment.DataKey); NewsFeed.AddNewsItem(NewsFeed.Priority.Information, "Task due: " + expiredAppointment.Subject); } } } catch (Exception ex) { logger.Error(ex.Message); } }
private string CheckNewVersionAvailable() { string alertMsg = ""; try { string lLastAlertedVersion = new SettingsDAO().GetSetting("LatestVersionAlert", false); AuditWizardWebService.CustomerWebService lWebService = new AuditWizardWebService.CustomerWebService(); string lNewVersion = lWebService.GetLatestVersionNumber(); if (lNewVersion.Equals(lLastAlertedVersion)) { return(alertMsg); } string[] lLatestAppVersion = lNewVersion.Split('.'); string[] lCurrentAppVersion = Application.ProductVersion.Split('.'); bool lNewVersionAvailable = Convert.ToInt32(lLatestAppVersion[0]) > Convert.ToInt32(lCurrentAppVersion[0]); if (!lNewVersionAvailable) { lNewVersionAvailable = (Convert.ToInt32(lLatestAppVersion[0]) == Convert.ToInt32(lCurrentAppVersion[0])) && (Convert.ToInt32(lLatestAppVersion[1]) > Convert.ToInt32(lCurrentAppVersion[1])); } if (!lNewVersionAvailable) { lNewVersionAvailable = (Convert.ToInt32(lLatestAppVersion[0]) == Convert.ToInt32(lCurrentAppVersion[0])) && (Convert.ToInt32(lLatestAppVersion[1]) == Convert.ToInt32(lCurrentAppVersion[1]) && (Convert.ToInt32(lLatestAppVersion[2]) > Convert.ToInt32(lCurrentAppVersion[2]))); } if (lNewVersionAvailable) { new SettingsDAO().SetSetting("LatestVersionAlert", lNewVersion, false); NewsFeed.AddNewsItem(NewsFeed.Priority.Information, String.Format("AuditWizard version {0} is now available.", lNewVersion)); return(String.Format("AuditWizard version {0} is now available. Click here to download the latest version.", lNewVersion)); } } catch (Exception) { } return(alertMsg); }