コード例 #1
0
 /// <summary>
 /// Applies the time zone.
 /// </summary>
 /// <param name="timeZone">
 /// The time zone.
 /// </param>
 public override void ApplyTimeZone(UPCRMTimeZone timeZone)
 {
     foreach (var cond in this.Conditions)
     {
         cond.ApplyTimeZone(timeZone);
     }
 }
コード例 #2
0
        /// <summary>
        /// Wholes the day condition for time zone.
        /// </summary>
        /// <param name="startDate">
        /// The Start date.
        /// </param>
        /// <param name="timeZone">
        /// The time zone.
        /// </param>
        /// <returns>
        /// The <see cref="UPInfoAreaCondition"/>.
        /// </returns>
        public UPInfoAreaCondition WholeDayConditionForTimeZone(DateTime startDate, UPCRMTimeZone timeZone)
        {
            var infoAreaId = this.InfoAreaMetaInfo.InfoAreaId;
            var timeString = timeZone.GetAdjustedCurrentMMTime(startDate);

            if (timeString == "0000")
            {
                return(new UPInfoAreaConditionLeaf(
                           infoAreaId,
                           this.DateFieldId,
                           timeZone.GetAdjustedCurrentMMDate(startDate)));
            }

            var date1 = new UPInfoAreaConditionLeaf(
                infoAreaId,
                this.DateFieldId,
                timeZone.GetAdjustedCurrentMMDate(startDate));
            var time1 = new UPInfoAreaConditionLeaf(infoAreaId, this.TimeFieldId, ">=", timeString);
            var date2 = new UPInfoAreaConditionLeaf(
                infoAreaId,
                this.DateFieldId,
                timeZone.GetAdjustedCurrentMMDate(startDate.AddSeconds(60 * 60 * 24)));
            var time2         = new UPInfoAreaConditionLeaf(infoAreaId, this.TimeFieldId, "<", timeString);
            var fromCondition = date1.InfoAreaConditionByAppendingAndCondition(time1);
            var toCondition   = date2.InfoAreaConditionByAppendingAndCondition(time2);

            return(fromCondition.InfoAreaConditionByAppendingOrCondition(toCondition));
        }
コード例 #3
0
        /// <summary>
        /// Afters the date condition including time zone.
        /// </summary>
        /// <param name="date">
        /// The date.
        /// </param>
        /// <param name="including">
        /// if set to <c>true</c> [including].
        /// </param>
        /// <param name="timeZone">
        /// The time zone.
        /// </param>
        /// <returns>
        /// The <see cref="UPInfoAreaCondition"/>.
        /// </returns>
        public UPInfoAreaCondition AfterDateCondition(DateTime date, bool including, UPCRMTimeZone timeZone)
        {
            string limitTime = timeZone.GetAdjustedCurrentMMTime(date);
            string limitDate = timeZone.GetAdjustedCurrentMMDate(date);

            if (limitTime == "0000" && including)
            {
                return(new UPInfoAreaConditionLeaf(this.InfoAreaMetaInfo.InfoAreaId, this.DateFieldId, ">=", limitDate));
            }
            else if (limitTime == "2359" && !including)
            {
                return(new UPInfoAreaConditionLeaf(this.InfoAreaMetaInfo.InfoAreaId, this.DateFieldId, ">", limitDate));
            }

            var timeCondition = new UPInfoAreaConditionLeaf(
                this.InfoAreaMetaInfo.InfoAreaId,
                this.TimeFieldId,
                including ? ">=" : ">",
                limitTime);

            var dateCondition = new UPInfoAreaConditionLeaf(this.InfoAreaMetaInfo.InfoAreaId, this.DateFieldId, limitDate);

            var afterDateCondition = new UPInfoAreaConditionLeaf(this.InfoAreaMetaInfo.InfoAreaId, this.DateFieldId, ">", limitDate);
            var cond = timeCondition.InfoAreaConditionByAppendingAndCondition(dateCondition);

            return(cond.InfoAreaConditionByAppendingOrCondition(afterDateCondition));
        }
コード例 #4
0
        /// <summary>
        /// Applies the time zone.
        /// </summary>
        /// <param name="timeZone">
        /// The time zone.
        /// </param>
        /// <param name="addedFields">
        /// The added fields.
        /// </param>
        public void ApplyTimeZone(UPCRMTimeZone timeZone, List <UPContainerFieldMetaInfo> addedFields)
        {
            if (this.Fields != null)
            {
                var currentFields = new List <UPContainerFieldMetaInfo>(this.Fields);

                foreach (var fieldMetaInfo in currentFields)
                {
                    if (fieldMetaInfo.IsDateField && fieldMetaInfo.OtherDateTimeField == null)
                    {
                        var timeFieldId = fieldMetaInfo.CrmFieldInfo.TimeFieldId;
                        if (timeFieldId < 0)
                        {
                            continue;
                        }

                        var field = new UPCRMField(timeFieldId, this.InfoAreaId);
                        if (field.FieldInfo == null)
                        {
                            continue;
                        }

                        var otherInfo = new UPContainerFieldMetaInfo(field);
                        this.AddNewFieldToArray(otherInfo, addedFields);
                    }
                    else if (fieldMetaInfo.IsTimeField && fieldMetaInfo.OtherDateTimeField == null)
                    {
                        var dateFieldId = fieldMetaInfo.CrmFieldInfo?.DateFieldId ?? 0;
                        if (dateFieldId == 0)
                        {
                            continue;
                        }

                        var field = new UPCRMField(dateFieldId, this.InfoAreaId);
                        if (field.FieldInfo == null)
                        {
                            continue;
                        }

                        var otherInfo = new UPContainerFieldMetaInfo(field);
                        this.AddNewFieldToArray(otherInfo, addedFields);
                    }
                }
            }

            var dateTimeCondition = this.Condition?.DateTimeConditionForInfoAreaParent(this, null);

            dateTimeCondition?.ApplyTimeZone(timeZone);

            if (this.subTables == null)
            {
                return;
            }

            foreach (var subInfos in this.subTables)
            {
                subInfos?.ApplyTimeZone(timeZone, addedFields);
            }
        }
コード例 #5
0
        /// <summary>
        /// Applies the time zone.
        /// </summary>
        /// <param name="timeZone">
        /// The time zone.
        /// </param>
        public override void ApplyTimeZone(UPCRMTimeZone timeZone)
        {
            if (this.DateCondition != null && this.TimeCondition != null)
            {
                var date = timeZone.DateFromClientDataMMDateStringTimeString(this.DateCondition.FirstValue, this.TimeCondition.FirstValue);
                if (date != null)
                {
                    this.DateCondition.ReplaceValue(timeZone.GetAdjustedCurrentMMDate(date.Value));
                    this.TimeCondition.ReplaceValue(timeZone.GetAdjustedCurrentMMTime(date.Value));
                }
            }
            else if (this.DateCondition != null)
            {
                var startDate = timeZone.DateFromClientDataMMDateStringTimeString(this.DateCondition.FirstValue, "0000");
                var endDate   = timeZone.DateFromClientDataMMDateStringTimeString(this.DateCondition.FirstValue, "2359")?.AddMinutes(60);

                if (startDate == DateTime.MinValue || endDate == DateTime.MinValue)
                {
                    return;
                }

                if (startDate != null && endDate != null)
                {
                    UPInfoAreaCondition replaceCondition;
                    if (this.DateCondition.CompareOperator == ">=")
                    {
                        replaceCondition = this.AfterDateCondition(startDate.Value, true, timeZone);
                    }
                    else if (this.DateCondition.CompareOperator == ">")
                    {
                        replaceCondition = this.AfterDateCondition(endDate.Value, false, timeZone);
                    }
                    else if (this.DateCondition.CompareOperator == "<=")
                    {
                        replaceCondition = this.BeforeDateCondition(endDate.Value, false, timeZone);
                    }
                    else if (this.DateCondition.CompareOperator == "<")
                    {
                        replaceCondition = this.BeforeDateCondition(startDate.Value, false, timeZone);
                    }
                    else if (this.DateCondition.CompareOperator == "<>")
                    {
                        var cond1 = this.BeforeDateCondition(startDate.Value, false, timeZone);
                        var cond2 = this.AfterDateCondition(endDate.Value, true, timeZone);
                        replaceCondition = cond1.InfoAreaConditionByAppendingOrCondition(cond2);
                    }
                    else
                    {
                        replaceCondition = this.WholeDayConditionForTimeZone(startDate.Value, timeZone);
                    }

                    if (replaceCondition != null)
                    {
                        this.ParentCondition.ReplaceConditionWithCondition(this.DateCondition, replaceCondition);
                    }
                }
            }
        }
        /// <summary>
        /// Applies the time zone record.
        /// </summary>
        /// <param name="timeZone">
        /// The time zone.
        /// </param>
        /// <param name="record">
        /// The record.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool ApplyTimeZoneRecord(UPCRMTimeZone timeZone, UPCRMRecord record)
        {
            DateTime?oldDate = null;
            DateTime?date    = null;

            if (this.DateFieldValue != null)
            {
                if (this.TimeFieldValue != null)
                {
                    if (!string.IsNullOrEmpty(this.DateFieldValue.OldValue) && !string.IsNullOrEmpty(this.TimeFieldValue.OldValue))
                    {
                        oldDate = timeZone.DateFromCurrentDataMMDateStringTimeString(
                            this.DateFieldValue.OldValue,
                            this.TimeFieldValue.OldValue);
                    }

                    if (!string.IsNullOrEmpty(this.DateFieldValue.Value) && !string.IsNullOrEmpty(this.TimeFieldValue.Value))
                    {
                        date = timeZone.DateFromCurrentDataMMDateStringTimeString(
                            this.DateFieldValue.Value,
                            this.TimeFieldValue.Value);
                    }
                }
                else if (!string.IsNullOrEmpty(this.DateFieldValue.TimeOriginalValue))
                {
                    if (!string.IsNullOrEmpty(this.DateFieldValue.OldValue))
                    {
                        oldDate = timeZone.DateFromCurrentDataMMDateStringTimeString(
                            this.DateFieldValue.OldValue,
                            this.DateFieldValue.TimeOriginalValue);
                    }

                    if (!string.IsNullOrEmpty(this.DateFieldValue.Value))
                    {
                        date = timeZone.DateFromCurrentDataMMDateStringTimeString(
                            this.DateFieldValue.Value,
                            this.DateFieldValue.TimeOriginalValue);
                    }
                }
            }
            else if (!string.IsNullOrEmpty(this.TimeFieldValue.DateOriginalValue))
            {
                /* -> dateFieldValue == nil && timeFieldValue != nil */
                if (!string.IsNullOrEmpty(this.TimeFieldValue.OldValue))
                {
                    oldDate = timeZone.DateFromCurrentDataMMDateStringTimeString(
                        this.TimeFieldValue.DateOriginalValue,
                        this.TimeFieldValue.OldValue);
                }

                if (!string.IsNullOrEmpty(this.TimeFieldValue.Value))
                {
                    date = timeZone.DateFromCurrentDataMMDateStringTimeString(
                        this.TimeFieldValue.DateOriginalValue,
                        this.TimeFieldValue.Value);
                }
            }

            string changedOldDate = null;

            if (oldDate != null)
            {
                changedOldDate = timeZone.GetAdjustedClientDataMMDate(oldDate.Value);
                var changedOldTime = timeZone.GetAdjustedClientDataMMTime(oldDate.Value);
                if (!string.IsNullOrEmpty(this.DateFieldValue?.OldValue))
                {
                    this.DateFieldValue.OldValue = changedOldDate;
                }

                if (!string.IsNullOrEmpty(this.TimeFieldValue?.OldValue))
                {
                    this.TimeFieldValue.OldValue = changedOldTime;
                }
            }

            if (date != null)
            {
                var changedDate = timeZone.GetAdjustedClientDataMMDate(date.Value);
                var changedTime = timeZone.GetAdjustedClientDataMMTime(date.Value);
                if (!string.IsNullOrEmpty(this.DateFieldValue?.Value))
                {
                    this.DateFieldValue.ChangeValue = changedDate;
                }
                else if (this.DateFieldValue == null && !string.IsNullOrEmpty(changedOldDate) &&
                         !string.IsNullOrEmpty(changedDate) && !changedOldDate.Equals(changedDate))
                {
                    var v = new UPCRMFieldValue(
                        changedDate,
                        changedOldDate,
                        this.TimeFieldValue.InfoAreaId,
                        this.DateFieldId,
                        this.TimeFieldValue.OnlyOffline);
                    record.AddValue(v);
                }

                if (string.IsNullOrEmpty(this.TimeFieldValue.Value))
                {
                    this.TimeFieldValue.ChangeValue = changedTime;
                }
            }

            return(true);
        }
コード例 #7
0
 /// <summary>
 /// Applies the time zone.
 /// </summary>
 /// <param name="timeZone">
 /// The time zone.
 /// </param>
 public virtual void ApplyTimeZone(UPCRMTimeZone timeZone)
 {
 }