public static Appointment AppointmentFindByCaseId(AppointmentPnDbContext dbContext, string sdkCaseId) { try { // using (var db = GetContextO()) // { Microting.AppointmentBase.Infrastructure.Data.Entities.AppointmentSite appointmentSite = dbContext.AppointmentSites.SingleOrDefault(x => x.SdkCaseId == sdkCaseId); if (appointmentSite == null) { return(null); } Microting.AppointmentBase.Infrastructure.Data.Entities.Appointment _appo = appointmentSite.Appointment; Appointment appointment = new Appointment() { }; // Appointment appo = new Appointment(_appo.global_id, (DateTime)_appo.start_at, (int)_appo.duration, _appo.subject, _appo.processing_state, _appo.body, (_appo.color_rule == 0 ? false : true), _appo.id); // AppoinntmentSite appo_site = new AppoinntmentSite((int)_appo_site.id, _appo_site.microting_site_uid, _appo_site.processing_state, _appo_site.sdk_case_id); // appo.AppointmentSites.Add(appo_site); return(appointment); // } } catch (Exception ex) { // log.LogException(t.GetMethodName("SQLController"), "failed", ex, false); return(null); } }
public bool CalendarItemReflecting(string globalId) { try { #region appointment = 'find one'; Microting.AppointmentBase.Infrastructure.Data.Entities.Appointment appointment = null; string Categories = null; if (globalId == null) { appointment = Appointment.AppointmentsFindOne(_dbContext, 0); } //else // appointment = sqlController.AppointmentsFind(globalId); if (appointment == null) //double checks status if no new found { appointment = Appointment.AppointmentsFindOne(_dbContext, 0); } #endregion if (appointment == null) { return(false); } // log.LogVariable(t.GetMethodName("OutlookOnlineController"), nameof(appointments), appointment.ToString()); Event item = AppointmentItemFind(appointment.GlobalId, appointment.StartAt.Value.AddHours(-36), appointment.StartAt.Value.AddHours(36)); // TODO! if (item != null) { item.Location.DisplayName = appointment.ProcessingState; #region item.Categories = 'workflowState'... switch (appointment.ProcessingState) { 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(_userEmailAddress, 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"); Appointment.AppointmentsReflected(_dbContext, appointment.GlobalId); // 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); } }