public string ToFileString()
        {
            string strStart = "";
            string strEnd   = "";
            string str      = "";

            if (IsBonding)
            {
                str = "Str2Date('14/'+copy(mplusstr((appdate),1),4,7))";
            }
            else
            {
                if (IsBusinessDays && DaysToAdd != 0)
                {
                    strStart = "addworkingdays(";
                    strEnd   = "," + DaysToAdd + ")";
                }
                else
                {
                    //then deal with "normal" days
                    if (DaysToAdd > 0)
                    {
                        strEnd += "+" + DaysToAdd.ToString();
                    }
                    //strictly this next step is not necessary as you could just have date +-7 which would generate the right result but would not be user friendly to read
                    if (DaysToAdd < 0)
                    {
                        strEnd += "-" + (DaysToAdd * -1).ToString();
                    }
                }
                if (MonthsToAdd != 0)
                {
                    strStart += "MPLUS(";
                    strEnd    = "," + MonthsToAdd.ToString() + ")" + strEnd;
                }

                //add the date and tie it all together
                if (BaseDate.CodeName.ToLower() == "startdate")
                {
                    str = strStart + "start" + strEnd;
                }
                else
                {
                    str = strStart + BaseDate.CodeName + strEnd;
                }
            }

            return(str);
        }
        protected override void Execute(CodeActivityContext executionContext)
        {
            ITracingService tracer = executionContext.GetExtension <ITracingService>();

            try
            {
                DateTime originalDate = OriginalDate.Get(executionContext);
                int      daysToAdd    = DaysToAdd.Get(executionContext);

                DateTime updatedDate = originalDate.AddDays(daysToAdd);

                UpdatedDate.Set(executionContext, updatedDate);
            }
            catch (Exception ex)
            {
                tracer.Trace("Exception: {0}", ex.ToString());
            }
        }
Exemple #3
0
        protected override void ExecuteCrmWorkFlowActivity(CodeActivityContext context, LocalWorkflowContext localContext)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (localContext == null)
            {
                throw new ArgumentNullException(nameof(localContext));
            }

            DateTime originalDate = OriginalDate.Get(context);
            int      daysToAdd    = DaysToAdd.Get(context);

            DateTime updatedDate = originalDate.AddDays(daysToAdd);

            UpdatedDate.Set(context, updatedDate);
        }
        protected override void Execute(CodeActivityContext executionContext)
        {
            TimeSpan?begin = DateUtilities.ParseTimeSpan(BusinessTimeStart.Get <string>(executionContext));
            TimeSpan?end   = DateUtilities.ParseTimeSpan(BusinessTimeEnd.Get <string>(executionContext));

            var rules = DateUtilities.GetRules(executionContext);

            //Change the result based on the rules such as Check OnlyLastDay, etc.
            var result = DateUtilities.ModifyDateTime(rules,
                                                      CheckOnlyLastDay.Get <bool>(executionContext),
                                                      StartDate.Get <DateTime>(executionContext),
                                                      Operations.Add,
                                                      DaysToAdd.Get <int>(executionContext),
                                                      HoursToAdd.Get <int>(executionContext),
                                                      MinutesToAdd.Get <int>(executionContext), begin, end);

            Result.Set(executionContext, result);
        }
        protected override void Execute(CodeActivityContext executionContext)
        {
            var result = new DateTime();
            var start  = StartDate.Get <DateTime>(executionContext);

            if (start != DateTime.MinValue)
            {
                result = start;
            }

            if (start != DateTime.MinValue && DaysToAdd.Get <int>(executionContext) != 0)
            {
                result = start.AddYears(YearsToAdd.Get <int>(executionContext))
                         .AddMonths(MonthsToAdd.Get <int>(executionContext))
                         .AddDays((7 * WeeksToAdd.Get <int>(executionContext)) +
                                  DaysToAdd.Get <int>(executionContext))
                         .AddHours(HoursToAdd.Get <int>(executionContext))
                         .AddMinutes(MinutesToAdd.Get <int>(executionContext));
            }

            Result.Set(executionContext, result);
        }