Esempio n. 1
0
        protected decimal RoundValue(CodeActivityContext context, decimal input)
        {
            decimal roundedValue = input;

            if (this.DecimalPlaces.Get(context) != null && this.DecimalPlaces.Get(context).Value != 222540099)
            {
                int decimalPlaces = this.DecimalPlaces.Get(context).Value - 222540000;
                roundedValue = new NumericManipulator().RoundToDecimalPlaces(roundedValue, decimalPlaces);
            }

            if (this.SignificantDigits.Get(context) != null && this.SignificantDigits.Get(context).Value != 222540099)
            {
                int significantDigits = this.SignificantDigits.Get(context).Value - 222540000;
                roundedValue = new NumericManipulator().RoundToSignificantDigits(roundedValue, significantDigits);
            }
            return(roundedValue);
        }
Esempio n. 2
0
        protected override void Execute(CodeActivityContext context)
        {
            var workflowContext = context.GetExtension <IWorkflowContext>();
            var service         = this.RetrieveOrganizationService(context);

            decimal value1 = this.DecimalValue1.Get(context);
            decimal value2 = this.DecimalValue2.Get(context);

            if (value1 <= 0 || value2 <= 0)
            {
                this.RatioEvaluated.Set(context, false);
                //this.RatioExpression.Set(context, "N/A");
            }
            else
            {
                // Evaluate VALUE:1 ratio
                decimal ratioExpressionPart1 = value1 / value2;
                decimal ratioExpressionPart2 = value2 / value1;

                if (this.DecimalPlaces.Get(context) != null && this.DecimalPlaces.Get(context).Value != 222540099)
                {
                    int decimalPlaces = this.DecimalPlaces.Get(context).Value - 222540000;
                    ratioExpressionPart2 = new NumericManipulator().RoundToDecimalPlaces(ratioExpressionPart2, decimalPlaces);
                    ratioExpressionPart1 = new NumericManipulator().RoundToDecimalPlaces(ratioExpressionPart1, decimalPlaces);
                }

                if (this.SignificantDigits.Get(context) != null && this.SignificantDigits.Get(context).Value != 222540099)
                {
                    int significantDigits = this.SignificantDigits.Get(context).Value - 222540000;
                    ratioExpressionPart2 = new NumericManipulator().RoundToSignificantDigits(ratioExpressionPart2, significantDigits);
                    ratioExpressionPart1 = new NumericManipulator().RoundToSignificantDigits(ratioExpressionPart2, significantDigits);
                }
                this.RatioEvaluated.Set(context, true);


                this.RatioValueToOne.Set(context, ratioExpressionPart1);
                this.RatioExpressionValueToOne.Set(context, ($"{ratioExpressionPart1}:1"));

                this.RatioOneToValue.Set(context, ratioExpressionPart2);
                this.RatioExpressionOneToValue.Set(context, ($"1:{ratioExpressionPart2}"));
            }
        }