示例#1
0
        public void CaseCompleted(object sender, EventArgs args)
        {
            eFormShared.Case_Dto trigger = (eFormShared.Case_Dto)sender;

            string CaseId = trigger.CaseId.ToString();

            MarkAppointmentCompleted(CaseId);
        }
示例#2
0
        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);
            }
        }
示例#3
0
        private void CoreThread(string sdkCoreConnectionString)
        {
            bool firstRun = true;

            coreThreadRunning = true;

            log.LogEverything(t.GetMethodName("Core"), "initiated");
            try
            {
                #region warm up
                if (firstRun)
                {
                    outlookOnlineController.CalendarItemConvertRecurrences();
                    int?currentId = null;
                    int appoId    = 0;
                    while (firstRun)
                    {
                        if (sdkCore == null)
                        {
                            startSdkCoreSqlOnly(sdkCoreConnectionString);
                        }
                        log.LogEverything(t.GetMethodName("Core"), "checking Appointments which are sent and currentId is now " + currentId.ToString());
                        Appointment appo = sqlController.AppointmentsFindOne(ProcessingStateOptions.Sent, false, currentId);
                        if (appo != null)
                        {
                            currentId = appo.Id;
                            foreach (AppoinntmentSite appo_site in appo.AppointmentSites)
                            {
                                log.LogEverything(t.GetMethodName("Core"), "checking appointment_site with MicrotingUuId : " + appo_site.MicrotingUuId.ToString());
                                eFormShared.Case_Dto kase = sdkCore.CaseReadByCaseId(int.Parse(appo_site.MicrotingUuId));
                                if (kase == null)
                                {
                                    log.LogEverything(t.GetMethodName("Core"), "kase IS NULL!");
                                    //firstRun = false;
                                }

                                if (kase.Stat == "Retrived")
                                {
                                    MarkAppointmentRetrived(kase.CaseId.ToString());
                                }
                                else if (kase.Stat == "Completed")
                                {
                                    MarkAppointmentCompleted(kase.CaseId.ToString());
                                }
                                //else
                                //{
                                //    currentId = appo_site.Id;
                                //}
                            }
                        }
                        else
                        {
                            firstRun = false;
                        }
                    }

                    log.LogStandard(t.GetMethodName("Core"), "warm up completed");
                }
                #endregion

                Thread syncOutlookConvertThread
                    = new Thread(() => SyncOutlookConvert());
                syncOutlookConvertThread.Start(); // This thread takes recurring events and convert the needed ones into single events.

                Thread syncOutlookAppsThread
                    = new Thread(() => SyncOutlookApps());
                syncOutlookAppsThread.Start(); // This thread takes single events and create the corresponding Appointment

                #region TODO
                //Thread syncAppointmentsToSdk
                //    = new Thread(() => SyncAppointmentsToSdk(sdkCoreConnectionString));
                //syncAppointmentsToSdk.Start();
                #endregion

                Thread.Sleep(2500);
            }
            catch (ThreadAbortException)
            {
                log.LogWarning(t.GetMethodName("Core"), "catch of ThreadAbortException");
            }
            catch (Exception ex)
            {
                throw ex;
                //FatalExpection(t.GetMethodName() + "failed", ex);
            }
        }