public bool CalendarItemReflecting(string globalId) { try { #region appointment = 'find one'; appointments appointment = null; if (globalId == null) { appointment = sqlController.AppointmentsFindOne(0); } else { appointment = sqlController.AppointmentsFind(globalId); } if (appointment == null) //double check status if no new found { appointment = sqlController.AppointmentsFindOne(1); } if (appointment == null) { return(false); } #endregion Outlook.AppointmentItem item = AppointmentItemFind(appointment.global_id, appointment.start_at.Value); item.Location = appointment.workflow_state; #region item.Categories = 'workflowState'... switch (appointment.workflow_state) { case "Planned": item.Categories = null; break; case "Processed": item.Categories = "Processing"; break; case "Created": item.Categories = "Processing"; break; case "Sent": item.Categories = "Sent"; break; case "Retrived": item.Categories = "Retrived"; break; case "Completed": item.Categories = "Completed"; break; case "Canceled": item.Categories = "Canceled"; break; case "Revoked": item.Categories = "Revoked"; break; case "Failed_to_expection": item.Categories = "Error"; break; case "Failed_to_intrepid": item.Categories = "Error"; break; default: item.Categories = "Error"; break; } #endregion item.Body = appointment.body; #region item.Body = appointment.expectionString + item.Body + appointment.response ... if (!string.IsNullOrEmpty(appointment.response)) { if (t.Bool(sqlController.SettingRead(Settings.responseBeforeBody))) { item.Body = "<<< Response: Start >>>" + Environment.NewLine + Environment.NewLine + appointment.response + Environment.NewLine + Environment.NewLine + "<<< Response: End >>>" + Environment.NewLine + Environment.NewLine + item.Body; } else { item.Body = item.Body + Environment.NewLine + Environment.NewLine + "<<< Response: Start >>>" + Environment.NewLine + Environment.NewLine + appointment.response + Environment.NewLine + Environment.NewLine + "<<< Response: End >>>"; } } if (!string.IsNullOrEmpty(appointment.expectionString)) { item.Body = "<<< Exception: Start >>>" + Environment.NewLine + Environment.NewLine + appointment.expectionString + Environment.NewLine + Environment.NewLine + "<<< Exception: End >>>" + Environment.NewLine + Environment.NewLine + item.Body; } #endregion item.Save(); sqlController.AppointmentsReflected(appointment.global_id); return(true); } catch (Exception ex) { throw new Exception(t.GetMethodName() + " failed", ex); } }
public bool CalendarItemReflecting(string globalId) { try { #region appointment = 'find one'; appointments appointment = null; string Categories = null; if (globalId == null) { appointment = sqlController.AppointmentsFindOne(0); } //else // appointment = sqlController.AppointmentsFind(globalId); if (appointment == null) //double checks status if no new found { appointment = sqlController.AppointmentsFindOne(1); } #endregion if (appointment == null) { return(false); } log.LogVariable(t.GetMethodName("OutlookOnlineController"), nameof(appointments), appointment.ToString()); Event item = AppointmentItemFind(appointment.global_id, appointment.start_at.Value.AddHours(-36), appointment.start_at.Value.AddHours(36)); // TODO! if (item != null) { item.Location.DisplayName = appointment.processing_state; #region item.Categories = 'workflowState'... switch (appointment.processing_state) { case "Planned": Categories = null; break; case "Processed": Categories = CalendarItemCategory.Processing.ToString(); break; case "Created": Categories = CalendarItemCategory.Processing.ToString(); break; case "Sent": Categories = CalendarItemCategory.Sent.ToString(); break; case "Retrived": Categories = CalendarItemCategory.Retrived.ToString(); break; case "Completed": Categories = CalendarItemCategory.Completed.ToString(); break; case "Canceled": Categories = CalendarItemCategory.Revoked.ToString(); break; case "Revoked": Categories = CalendarItemCategory.Revoked.ToString(); break; case "Exception": Categories = CalendarItemCategory.Error.ToString(); break; case "Failed_to_intrepid": Categories = CalendarItemCategory.Error.ToString(); break; default: Categories = CalendarItemCategory.Error.ToString(); break; } #endregion item.BodyPreview = appointment.body; #region item.Body = appointment.expectionString + item.Body + appointment.response ... if (!string.IsNullOrEmpty(appointment.response)) { if (t.Bool(sqlController.SettingRead(Settings.responseBeforeBody))) { item.BodyPreview = "<<< Response: Start >>>" + Environment.NewLine + Environment.NewLine + appointment.response + Environment.NewLine + Environment.NewLine + "<<< Response: End >>>" + Environment.NewLine + Environment.NewLine + item.BodyPreview; } else { item.BodyPreview = item.BodyPreview + Environment.NewLine + Environment.NewLine + "<<< Response: Start >>>" + Environment.NewLine + Environment.NewLine + appointment.response + Environment.NewLine + Environment.NewLine + "<<< Response: End >>>"; } } if (!string.IsNullOrEmpty(appointment.exceptionString)) { item.BodyPreview = "<<< Exception: Start >>>" + Environment.NewLine + Environment.NewLine + appointment.exceptionString + Environment.NewLine + Environment.NewLine + "<<< Exception: End >>>" + Environment.NewLine + Environment.NewLine + item.BodyPreview; } #endregion Event eresult = outlookExchangeOnlineAPIClient.UpdateEvent(userEmailAddess, item.Id, CalendarItemUpdateBody(item.BodyPreview, item.Location.DisplayName, Categories)); if (eresult == null) { return(false); } else { log.LogStandard(t.GetMethodName("OutlookOnlineController"), "globalId:'" + appointment.global_id + "' reflected in calendar"); } } else { log.LogWarning(t.GetMethodName("OutlookOnlineController"), "globalId:'" + appointment.global_id + "' no longer in calendar, so hence is considered to be reflected in calendar"); } sqlController.AppointmentsReflected(appointment.global_id); log.LogStandard(t.GetMethodName("OutlookOnlineController"), "globalId:'" + appointment.global_id + "' reflected in database"); return(true); } catch (Exception ex) { throw new Exception(t.GetMethodName("OutlookOnlineController") + " failed", ex); } }