Add Two Decimal Digit

Add Two Decimal Digit

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities;
using Microsoft.Crm;
using Microsoft.Crm.Sdk.Messages;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Xrm.Sdk.Workflow;
using Microsoft.Xrm.Sdk.Workflow.Activities;
using Microsoft.Xrm.Sdk.Client;
using Microsoft.Xrm.Sdk.Messages;

namespace glt_WorkflowActivities
{

    public sealed class addTwoDecimals : CodeActivity
    {
        [RequiredArgument]
        [Input("First Decimal")]
        public InArgument<Decimal> FirstDecimal { get; set; }

        [RequiredArgument]
        [Input("Second Decimal")]
        public InArgument<Decimal> SecondDecimal { get; set; }

        [RequiredArgument]
        [Input("Third Decimal")]
        public InArgument<Decimal> ThirdDecimal { get; set; }

        [RequiredArgument]
        [Input("First Whole Number")]
        public InArgument<int> FirstWhole { get; set; }

        [RequiredArgument]
        [Input("Second Whole Number")]
        public InArgument<int> SecondWhole { get; set; }

        [RequiredArgument]
        [Input("Third Whole Number")]
        public InArgument<int> ThirdWhole { get; set; }

        [Output("Output Decimal")]
        public OutArgument<Decimal> outDecimal { get; set; }

        [Output("Output Whole Number")]
        public OutArgument<int> outWhole { get; set; }

        protected override void Execute(CodeActivityContext executionContext)
        {
            decimal tmpTotal = 0m;
            decimal? tmpHrs = this.FirstDecimal.Get(executionContext);
            tmpTotal += (tmpHrs ?? 0);

            tmpHrs = this.SecondDecimal.Get(executionContext);
            tmpTotal += (tmpHrs ?? 0);

            tmpHrs = this.ThirdDecimal.Get(executionContext);
            tmpTotal += (tmpHrs ?? 0);

            tmpHrs = this.FirstWhole.Get(executionContext);
            tmpTotal += (tmpHrs ?? 0);

            tmpHrs = this.SecondWhole.Get(executionContext);
            tmpTotal += (tmpHrs ?? 0);

            tmpHrs = this.ThirdWhole.Get(executionContext);
            tmpTotal += (tmpHrs ?? 0);

            this.outDecimal.Set(executionContext, tmpTotal);
            this.outWhole.Set(executionContext, Convert.ToInt16(tmpTotal));
        }
    }
}

Comments

Popular posts from this blog

Workflow Activity Input and Output Parameters and Data Types in MS CRM 2013/15/16

Get Workflow Guid in Javascript using OData query

Convert Plugin to Sandbox mode,