コード例 #1
0
        private UPMContactTimesGroup GroupFromResult(UPCRMResult result)
        {
            this.contextResult = result;
            if (!this.FieldControl.FunctionNames().Keys.Contains("TYPE"))
            {
                this.FillGroupVrianteWithoutType(this.contextResult);
            }
            else
            {
                this.FillGroupVrianteWithType(this.contextResult);
            }

            for (int weekDay = 0; weekDay < 7; weekDay++)
            {
                int weekDayU7 = this.weekDayArray[weekDay];
                if (weekDayU7 > 1)
                {
                    weekDayU7--;
                }
                else
                {
                    weekDayU7 = 7;
                }

                foreach (string timeType in this.contactTimesGroup.TimeTypeTitleSortedKeys)
                {
                    var contactTimes = this.contactTimesGroup.ContactTimeForWeekDayTimeType(weekDayU7, timeType);
                    if (contactTimes.Count < 1)
                    {
                        UPMContactTime contactTime  = new UPMContactTime(weekDayU7, timeType, null, null);
                        UPMContactTime contactTime2 = new UPMContactTime(weekDayU7, timeType, null, null);
                        this.contactTimesGroup.AddChild(contactTime);
                        this.contactTimesGroup.AddChild(contactTime2);
                    }
                    else if (contactTimes.Count < 2)
                    {
                        UPMContactTime contactTime = new UPMContactTime(weekDayU7, timeType, null, null);
                        this.contactTimesGroup.AddChild(contactTime);
                    }
                }
            }

            this.contactTimesGroup.Name = "EDIT";
            return(this.contactTimesGroup);
        }
コード例 #2
0
        private void FillTimesVrianteWithTypeFromResultRowTimeType(UPCRMResultRow resultRow, string timeType)
        {
            if (string.IsNullOrEmpty(this.contactTimesGroup.TimeTypeTitleForTimeType(timeType)))
            {
                return;
            }

            var                  valuesWithFunctions = resultRow.ValuesWithFunctions();
            DateTime             fromDate;
            DateTime             toDate;
            UPMDateTimeEditField fromTime;
            UPMDateTimeEditField toTime;
            UPMContactTime       contactTime;
            string               from          = "FROM";
            string               to            = "TO";
            string               afternoonFrom = "AFTERNOONFROM";
            string               afternoonTo   = "AFTERNOONTO";
            int                  weekDay       = ((string)valuesWithFunctions.ValueOrDefault("DAYOFWEEK")).ToInt();

            if (weekDay < 7)
            {
                weekDay++;
            }
            else
            {
                weekDay = 1;
            }

            if ((valuesWithFunctions.ValueOrDefault(from) != null && ((string)valuesWithFunctions.ValueOrDefault(from)).ToInt() > 0) ||
                (valuesWithFunctions.ValueOrDefault(to) != null && ((string)valuesWithFunctions.ValueOrDefault(to)).ToInt() > 0))
            {
                fromDate = ((string)valuesWithFunctions.ValueOrDefault(from)).TimeFromCrmValue();
                toDate   = ((string)valuesWithFunctions.ValueOrDefault(to)).TimeFromCrmValue();
                fromTime = new UPMDateTimeEditField(StringIdentifier.IdentifierWithStringId("fromTime"))
                {
                    Type      = DateTimeType.Time,
                    DateValue = fromDate
                };
                toTime = new UPMDateTimeEditField(StringIdentifier.IdentifierWithStringId("toTime"))
                {
                    Type      = DateTimeType.Time,
                    DateValue = toDate
                };
                contactTime = new UPMContactTime(weekDay, timeType, fromTime, toTime)
                {
                    RecordIdentification = resultRow.RecordIdentificationAtFieldIndex(0)
                };
                this.contactTimesGroup.AddChild(contactTime);
            }

            if ((valuesWithFunctions.ValueOrDefault(afternoonFrom) != null && ((string)valuesWithFunctions.ValueOrDefault(afternoonFrom)).ToInt() > 0) ||
                (valuesWithFunctions.ValueOrDefault(afternoonTo) != null && ((string)valuesWithFunctions.ValueOrDefault(afternoonTo)).ToInt() > 0))
            {
                fromDate = ((string)valuesWithFunctions.ValueOrDefault(afternoonFrom)).TimeFromCrmValue();
                toDate   = ((string)valuesWithFunctions.ValueOrDefault(afternoonTo)).TimeFromCrmValue();
                fromTime = new UPMDateTimeEditField(StringIdentifier.IdentifierWithStringId("fromTime"))
                {
                    Type      = DateTimeType.Time,
                    DateValue = fromDate
                };
                toTime = new UPMDateTimeEditField(StringIdentifier.IdentifierWithStringId("toTime"))
                {
                    Type      = DateTimeType.Time,
                    DateValue = toDate
                };
                contactTime = new UPMContactTime(weekDay, timeType, fromTime, toTime)
                {
                    RecordIdentification = resultRow.RecordIdentificationAtFieldIndex(0)
                };
                this.contactTimesGroup.AddChild(contactTime);
            }
        }
コード例 #3
0
        private void FillTimesVrianteWithoutTypeFromResultRowTimeTypePrefix(UPCRMResultRow resultRow, string timeType, string prefix)
        {
            var                  valuesWithFunctions = resultRow.ValuesWithFunctions();
            DateTime             fromDate;
            DateTime             toDate;
            UPMDateTimeEditField fromTime;
            UPMDateTimeEditField toTime;
            UPMContactTime       contactTime;
            var                  from          = $"{prefix}FROM";
            var                  to            = $"{prefix}TO";
            var                  afternoonFrom = $"{prefix}AFTERNOONFROM";
            var                  afternoonTo   = $"{prefix}AFTERNOONTO";
            int                  weekDay       = ((string)valuesWithFunctions.ValueOrDefault("DAYOFWEEK")).ToInt();

            if (weekDay < 7)
            {
                weekDay++;
            }
            else
            {
                weekDay = 1;
            }

            if (valuesWithFunctions.ValueOrDefault(to) != null && ((string)valuesWithFunctions.ValueOrDefault(to)).ToInt() > 0)
            {
                fromDate = (valuesWithFunctions.ValueOrDefault(from) as string).TimeFromCrmValue();
                toDate   = (valuesWithFunctions.ValueOrDefault(to) as string).TimeFromCrmValue();
                fromTime = new UPMDateTimeEditField(StringIdentifier.IdentifierWithStringId("fromTime"))
                {
                    Type      = DateTimeType.Time,
                    DateValue = fromDate
                };

                toTime = new UPMDateTimeEditField(StringIdentifier.IdentifierWithStringId("toTime"))
                {
                    Type      = DateTimeType.Time,
                    DateValue = toDate
                };

                contactTime = new UPMContactTime(weekDay, timeType, fromTime, toTime)
                {
                    RecordIdentification = resultRow.RecordIdentificationAtFieldIndex(0)
                };
                this.contactTimesGroup.AddChild(contactTime);
            }
            else
            {
                contactTime = new UPMContactTime(weekDay, timeType, null, null);
                this.contactTimesGroup.AddChild(contactTime);
            }

            if (valuesWithFunctions.ValueOrDefault(afternoonTo) != null && ((string)valuesWithFunctions.ValueOrDefault(afternoonTo)).ToInt() > 0)
            {
                fromDate = (valuesWithFunctions.ValueOrDefault(afternoonFrom) as string).TimeFromCrmValue();
                toDate   = (valuesWithFunctions.ValueOrDefault(afternoonTo) as string).TimeFromCrmValue();
                fromTime = new UPMDateTimeEditField(StringIdentifier.IdentifierWithStringId("fromTime"))
                {
                    Type      = DateTimeType.Time,
                    DateValue = fromDate
                };
                toTime = new UPMDateTimeEditField(StringIdentifier.IdentifierWithStringId("toTime"))
                {
                    Type      = DateTimeType.Time,
                    DateValue = toDate
                };
                contactTime = new UPMContactTime(weekDay, timeType, fromTime, toTime)
                {
                    RecordIdentification = resultRow.RecordIdentificationAtFieldIndex(0)
                };
                this.contactTimesGroup.AddChild(contactTime);
            }
            else
            {
                contactTime = new UPMContactTime(weekDay, timeType, null, null)
                {
                    RecordIdentification = resultRow.RecordIdentificationAtFieldIndex(0)
                };
                this.contactTimesGroup.AddChild(contactTime);
            }
        }