public SqlController(string connectionString) { connectionStr = connectionString.ToLower(); if (!connectionStr.Contains("server=")) { msSql = true; } else { msSql = false; } #region migrate if needed try { using (var db = GetContextO()) { db.Database.CreateIfNotExists(); var match = db.settings.Count(); } } catch { MigrateDb(); } #endregion //region set default for settings if needed if (SettingCheckAll().Count > 0) { SettingCreateDefaults(); } sdkSqlCon = new eFormSqlController.SqlController(SettingRead(Settings.microtingDb)); }
public bool CalendarItemIntrepid() { try { bool AllIntrepid = false; #region var DateTime checkLast_At = DateTime.Parse(sqlController.SettingRead(Settings.checkLast_At)); double checkPreSend_Hours = double.Parse(sqlController.SettingRead(Settings.checkPreSend_Hours)); double checkRetrace_Hours = double.Parse(sqlController.SettingRead(Settings.checkRetrace_Hours)); int checkEvery_Mins = int.Parse(sqlController.SettingRead(Settings.checkEvery_Mins)); bool includeBlankLocations = bool.Parse(sqlController.SettingRead(Settings.includeBlankLocations)); DateTime timeOfRun = DateTime.Now; DateTime tLimitTo = timeOfRun.AddHours(+checkPreSend_Hours); DateTime tLimitFrom = checkLast_At.AddHours(-checkRetrace_Hours); #endregion #region process appointments foreach (Outlook.AppointmentItem item in GetCalendarItems(tLimitTo, tLimitFrom)) { if (!item.IsRecurring) //is NOT recurring, otherwise ignore { if (tLimitFrom <= item.Start && item.Start <= tLimitTo) { #region location "planned"? string location = item.Location; if (location == null) { if (includeBlankLocations) { location = "planned"; } else { location = ""; } } location = location.ToLower(); #endregion if (location.ToLower() == "planned") #region ... { if (item.Body != null) { if (item.Body.Contains("<<< ")) { if (item.Body.Contains("End >>>")) { item.Body = t.LocateReplaceAll(item.Body, "<<< ", "End >>>", ""); item.Body = item.Body.Replace("<<< End >>>", ""); item.Body = item.Body.Trim(); } } } item.Save(); Appointment appo = new Appointment(item.GlobalAppointmentID, item.Start, item.Duration, item.Subject, item.Location, item.Body, t.Bool(sqlController.SettingRead(Settings.colorsRule)), true, sqlController.Lookup); if (appo.Location == null) { if (includeBlankLocations) { appo.Location = "planned"; } else { appo.Location = ""; } } if (appo.Location.ToLower() == "planned") { if (sqlController.OutlookEfromCreate(appo)) { CalendarItemUpdate(appo, WorkflowState.Processed, false); } else { CalendarItemUpdate(appo, WorkflowState.Failed_to_expection, false); } } else { CalendarItemUpdate(appo, WorkflowState.Failed_to_intrepid, false); } AllIntrepid = true; } #endregion if (location.ToLower() == "cancel") #region ... { Appointment appo = new Appointment(item.GlobalAppointmentID, item.Start, item.Duration, item.Subject, item.Location, item.Body, t.Bool(sqlController.SettingRead(Settings.colorsRule)), true, sqlController.Lookup); if (sqlController.OutlookEformCancel(appo)) { CalendarItemUpdate(appo, WorkflowState.Canceled, false); } else { CalendarItemUpdate(appo, WorkflowState.Failed_to_intrepid, false); } AllIntrepid = true; } #endregion if (location.ToLower() == "check") #region ... { eFormSqlController.SqlController sqlMicroting = new eFormSqlController.SqlController(sqlController.SettingRead(Settings.microtingDb)); eFormCommunicator.Communicator com = new eFormCommunicator.Communicator(sqlMicroting); var temp = sqlController.AppointmentsFind(item.GlobalAppointmentID); var list = sqlMicroting.InteractionCaseListRead(int.Parse(temp.microting_uid)); foreach (var aCase in list) { com.CheckStatusUpdateIfNeeded(aCase.microting_uid); } CalendarItemReflecting(item.GlobalAppointmentID); AllIntrepid = true; } #endregion } } } #endregion sqlController.SettingUpdate(Settings.checkLast_At, timeOfRun.ToString()); log.LogVariable("Not Specified", "Settings.checkLast_At", Settings.checkLast_At.ToString()); return(AllIntrepid); } catch (Exception ex) { throw new Exception(t.GetMethodName() + " failed", ex); } }