public static sObjectUtils CreateUtilsByType(Type i_ObjectType = null, AppointmentBookingData i_ABData = null, string i_UtilClassName = null)
        {
            sObjectUtils objectUtils;

            if (i_UtilClassName != null)
            {
                return(createUtilsByClassName(i_UtilClassName, i_ABData));
            }

            //TODO: check the value of Name in managed package
            switch (i_ObjectType.Name)
            {
            case "Work_Rule__c":
                objectUtils = new WorkRuleUtils();
                break;

            case "Scheduling_Policy_Goal__c":
                objectUtils = new ObjectiveUtils();
                break;

            case "ServiceAppointment":
                objectUtils = new ServiceAppointmentUtils(i_ABData);
                break;

            case "Time_Dependency__c":
                objectUtils = new TimeDependencyUtils();
                break;

            case "ServiceTerritoryMember":
                objectUtils = new STMUtils(i_ABData);
                break;

            case "OperatingHours":
                objectUtils = new OperatingHoursUtils(i_ABData);
                break;

            case "ServiceResource":
                objectUtils = new ServiceResourceUtils(i_ABData);
                break;

            default:
                objectUtils = null;
                break;
            }

            return(objectUtils);
        }
        public override void Deserialize(string i_QueryResult, AppointmentBookingData i_ABData,
                                         AdditionalObjectsUtils.eAdditionalObjectQuery i_AdditionalObjQuery = default, bool async = false)
        {
            DeserializedQueryResult deserializedQuery =
                JsonConvert.DeserializeObject <DeserializedQueryResult>(i_QueryResult);

            ServiceAppointmentUtils serviceUtils = new ServiceAppointmentUtils(i_ABData);
            Dictionary <string, ServiceAppointment> deserializedServices = serviceUtils.parseAdditionalData(deserializedQuery.records);

            foreach (KeyValuePair <string, List <Time_Dependency__c> > dependencyTreeByRoot in i_ABData.TimeDependeciesByRootId)
            {
                foreach (Time_Dependency__c dependency in dependencyTreeByRoot.Value)
                {
                    if (!i_ABData.ServicesById.ContainsKey(dependency.Service_Appointment_1__c))
                    {
                        i_ABData.ServicesById[dependency.Service_Appointment_1__c] = deserializedServices[dependency.Service_Appointment_1__c];
                    }

                    dependency.Service_Appointment_1__r = deserializedServices[dependency.Service_Appointment_1__c];

                    if (!i_ABData.ServicesById.ContainsKey(dependency.Service_Appointment_2__c))
                    {
                        i_ABData.ServicesById[dependency.Service_Appointment_2__c] = deserializedServices[dependency.Service_Appointment_2__c];
                    }

                    dependency.Service_Appointment_2__r = deserializedServices[dependency.Service_Appointment_2__c];

                    if (dependency.Service_Appointment_1__c == dependency.Root_Service_Appointment__c)
                    {
                        dependency.Root_Service_Appointment__r = deserializedServices[dependency.Service_Appointment_1__c];
                    }

                    if (dependency.Service_Appointment_2__c == dependency.Root_Service_Appointment__c)
                    {
                        dependency.Root_Service_Appointment__r = deserializedServices[dependency.Service_Appointment_2__c];
                    }
                }
            }
        }
Exemple #3
0
        private List <Work_Rule__c> initiateRulesWithRelvanceGroupList(
            Dictionary <string, List <Work_Rule__c> > i_RulesByDevName, ServiceAppointment i_Service)
        {
            List <Work_Rule__c> rulesFilteredByRelevanceGroup = new List <Work_Rule__c>();

            foreach (List <Work_Rule__c> rules in i_RulesByDevName.Values)
            {
                foreach (Work_Rule__c rule in rules.Where(rule => rule.Object_Group_Field__c == null || ServiceAppointmentUtils.getBooleanField(i_Service, rule.Object_Group_Field__c)))
                {
                    rulesFilteredByRelevanceGroup.Add(rule);
                }
            }

            return(rulesFilteredByRelevanceGroup);
        }