Saturday, April 16, 2016

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));
        }
    }
}

No comments:

Post a Comment

Get files of last hour in Azure Data Factory

  Case I have a Data Factory pipeline that should run each hour and collect all new files added to the data lake since the last run. What is...