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);
        }
Exemple #2
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      monthsToAdd  = MonthsToAdd.Get(context);

            DateTime updatedDate = originalDate.AddMonths(monthsToAdd);

            UpdatedDate.Set(context, updatedDate);
        }
        protected override void Execute(CodeActivityContext executionContext)
        {
            ITracingService tracer = executionContext.GetExtension <ITracingService>();

            try
            {
                DateTime originalDate = OriginalDate.Get(executionContext);
                int      monthsToAdd  = MonthsToAdd.Get(executionContext);

                DateTime updatedDate = originalDate.AddMonths(monthsToAdd);

                UpdatedDate.Set(executionContext, updatedDate);
            }
            catch (Exception ex)
            {
                tracer.Trace("Exception: {0}", ex.ToString());
            }
        }
        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);
        }