// DEPRECATION WARNING!!! THIS WILL BE REMOVED IN A LATER VERSION private void _fileWatcher_Created(object sender, FileSystemEventArgs e) { if (!fileNames.Contains(e.Name)) { LogEvent("_fileWatcher_Created called for file :" + e.Name); fileNames.Add(e.Name); char[] delimiter = { '_' }; int siteId = int.Parse(e.Name.Split(delimiter)[0]); string navId = e.Name.Split(delimiter)[1].Replace(".xml", ""); string rawXml = ""; foreach (string line in File.ReadLines(e.FullPath)) { rawXml += line; } eFormData.MainElement mainElement = sdkCore.TemplateFromXml(rawXml); int template_id = sdkCore.TemplateCreate(mainElement); // We read the MainElement from db, since we need our own ids. mainElement = sdkCore.TemplateRead(template_id); List <int> siteIds = new List <int>(); siteIds.Add(siteId); List <string> mtUid = sdkCore.CaseCreate(mainElement, "", siteIds, navId); string newEnding = "_" + mtUid.First().ToString() + ".xml"; string newFileName = e.FullPath.Replace("inbound", "parsed").Replace(".xml", newEnding); File.Move(e.FullPath, newFileName); LogEvent(String.Format("File created: Path {0}, Name: {1}", e.FullPath, e.Name)); } }
public void CaseCompleted(object sender, EventArgs args) { eFormShared.Case_Dto trigger = (eFormShared.Case_Dto)sender; check_lists check_list = sqlController.CheckListRead(trigger.CheckListId); List <fields> fields = sqlController.FieldsOnCheckList(check_list.id); if (fields != null) { List <eFormData.FieldValue> caseFieldValues = new List <eFormData.FieldValue>(); if (sqlController.CheckListRead(trigger.CheckListId) != null) { List <eFormShared.Field_Dto> eFormFields = sdkCore.Advanced_TemplateFieldReadAll(trigger.CheckListId); List <int> field_ids = new List <int>(); foreach (eFormShared.Field_Dto f in eFormFields) { field_ids.Add(f.Id); } foreach (fields field in fields) { if (field_ids.Contains((int)field.sdk_field_id)) { eFormData.FieldValue fv = sdkCore.Advanced_FieldValueReadList((int)field.sdk_field_id, 1)[0]; caseFieldValues.Add(fv); } } } bool shouldSkipValues = false; foreach (eFormData.FieldValue fv in caseFieldValues) { if (fv.FieldId == check_list.reset_values_field_id) { if (fv.Value == "checked") { shouldSkipValues = true; } } } sdkCore.CaseDelete(trigger.CheckListId, trigger.SiteUId); eFormData.MainElement eform = sdkCore.TemplateRead(trigger.CheckListId); if (!shouldSkipValues) { SetDefaultValue(eform.ElementList, caseFieldValues); } eform.EndDate = DateTime.Now.AddYears(1); sdkCore.CaseCreate(eform, "", trigger.SiteUId); } }
#pragma warning disable 1998 public async Task Handle(AppointmentCreatedInOutlook message) { try { Appointment Appo = sqlController.AppointmentsFind(message.Appo.GlobalId); if (Appo.ProcessingState == ProcessingStateOptions.Processed.ToString()) { bool sqlUpdate = sqlController.AppointmentsUpdate(Appo.GlobalId, ProcessingStateOptions.Created, Appo.Body, "", "", Appo.Completed, Appo.Start, Appo.End, Appo.Duration); if (sqlUpdate) { bool updateStatus = outlookOnlineController.CalendarItemUpdate(Appo.GlobalId, (DateTime)Appo.Start, ProcessingStateOptions.Created, Appo.Body); } else { throw new Exception("Unable to update Appointment in AppointmentCreatedInOutlookHandler"); } //log.LogEverything("Not Specified", "outlookController.SyncAppointmentsToSdk() L623"); } eFormData.MainElement mainElement = sdkCore.TemplateRead((int)Appo.TemplateId); if (mainElement == null) { log.LogEverything("Not Specified", "outlookController.SyncAppointmentsToSdk() L625 mainElement is NULL!!!"); } mainElement.Repeated = 1; DateTime startDt = new DateTime(Appo.Start.Year, Appo.Start.Month, Appo.Start.Day, 0, 0, 0); DateTime endDt = new DateTime(Appo.End.AddDays(1).Year, Appo.End.AddDays(1).Month, Appo.End.AddDays(1).Day, 23, 59, 59); //mainElement.StartDate = ((DateTime)appo.Start).ToUniversalTime(); mainElement.StartDate = startDt; //mainElement.EndDate = ((DateTime)appo.End.AddDays(1)).ToUniversalTime(); mainElement.EndDate = endDt; //log.LogEverything("Not Specified", "outlookController.SyncAppointmentsToSdk() L629"); #region fill eForm if (Appo.AppointmentPrefillFieldValues.Count > 0) { SetDefaultValue(mainElement.ElementList, Appo.AppointmentPrefillFieldValues); string description = ""; foreach (AppointmentPrefillFieldValue pfv in Appo.AppointmentPrefillFieldValues) { eFormData.Field field = sdkCore.Advanced_FieldRead(pfv.FieldId); string fieldValue = pfv.FieldValue; if (field.FieldType == eFormShared.Constants.FieldTypes.EntitySelect) { fieldValue = sdkCore.EntityItemReadByMicrotingUUID(pfv.FieldValue).Name; } description = description + "<b>" + field.Label + ":</b> " + fieldValue + "<br>"; } eFormShared.CDataValue cDataValue = new eFormShared.CDataValue(); cDataValue.InderValue = description; mainElement.ElementList[0].Description = cDataValue; } #endregion log.LogEverything("Not Specified", "outlookController.SyncAppointmentsToSdk() StartDate is " + mainElement.StartDate); log.LogEverything("Not Specified", "outlookController.SyncAppointmentsToSdk() EndDate is " + mainElement.EndDate); bool allGood = false; List <AppoinntmentSite> appoSites = Appo.AppointmentSites; if (appoSites == null) { log.LogEverything("Not Specified", "outlookController.SyncAppointmentsToSdk() L635 appoSites is NULL!!! for appo.GlobalId" + Appo.GlobalId); } else { foreach (AppoinntmentSite appo_site in appoSites) { log.LogEverything("Not Specified", "outlookController.foreach AppoinntmentSite appo_site is : " + appo_site.MicrotingSiteUid); string resultId; if (appo_site.MicrotingUuId == null) { resultId = sdkCore.CaseCreate(mainElement, "", appo_site.MicrotingSiteUid); log.LogEverything("Not Specified", "outlookController.foreach resultId is : " + resultId); } else { resultId = appo_site.MicrotingUuId; } if (!string.IsNullOrEmpty(resultId)) { int localCaseId = (int)sdkCore.CaseLookupMUId(resultId).CaseId; //appo_site.MicrotingUuId = resultId; sqlController.AppointmentSiteUpdate((int)appo_site.Id, localCaseId.ToString(), ProcessingStateOptions.Sent); allGood = true; } else { log.LogEverything("Not Specified", "outlookController.SyncAppointmentsToSdk() L656"); allGood = false; } } if (allGood) { //log.LogEverything("Not Specified", "outlookController.SyncAppointmentsToSdk() L663"); bool updateStatus = outlookOnlineController.CalendarItemUpdate(Appo.GlobalId, (DateTime)Appo.Start, ProcessingStateOptions.Sent, Appo.Body); if (updateStatus) { //log.LogEverything("Not Specified", "outlookController.SyncAppointmentsToSdk() L667"); sqlController.AppointmentsUpdate(Appo.GlobalId, ProcessingStateOptions.Sent, Appo.Body, "", "", Appo.Completed, Appo.Start, Appo.End, Appo.Duration); } } else { //log.LogEverything("Not Specified", "outlookController.SyncAppointmentsToSdk() L673"); //syncAppointmentsToSdkRunning = false; } } //} } catch (Exception ex) { log.LogEverything("Exception", "Got the following exception : " + ex.Message + " and stacktrace is : " + ex.StackTrace); throw ex; } }