Exemple #1
0
 /// <inheritdoc />
 protected override void Execute(Context context)
 {
     Result.Set(context, new DateTime(
                    Year.Get(context),
                    Month.Get(context),
                    Day.Get(context),
                    Hour.Get(context),
                    Minute.Get(context),
                    Second.Get(context),
                    Millisecond.Get(context)
                    ));
 }
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 dateToUpdate = DateToUpdate.Get(context);
            int      hour         = Hour.Get(context);

            if (hour > 23 || hour < 0)
            {
                throw new InvalidPluginExecutionException("Invalid hour");
            }

            int minute = Minute.Get(context);

            if (minute > 59 || minute < 0)
            {
                throw new InvalidPluginExecutionException("Invalid minute");
            }

            int second = Second.Get(context);

            if (second > 59 || second < 0)
            {
                throw new InvalidPluginExecutionException("Invalid second");
            }

            DateTime updatedDate = new DateTime(dateToUpdate.Year, dateToUpdate.Month, dateToUpdate.Day, hour, minute, second);

            UpdatedDate.Set(context, updatedDate);
        }
Exemple #3
0
        // Module defining this command


        // Optional custom code for this activity


        /// <summary>
        /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
        /// </summary>
        /// <param name="context">The NativeActivityContext for the currently running activity.</param>
        /// <returns>A populated instance of Sytem.Management.Automation.PowerShell</returns>
        /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
        protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
        {
            System.Management.Automation.PowerShell invoker       = global::System.Management.Automation.PowerShell.Create();
            System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);

            // Initialize the arguments

            if (Date.Expression != null)
            {
                targetCommand.AddParameter("Date", Date.Get(context));
            }

            if (Year.Expression != null)
            {
                targetCommand.AddParameter("Year", Year.Get(context));
            }

            if (Month.Expression != null)
            {
                targetCommand.AddParameter("Month", Month.Get(context));
            }

            if (Day.Expression != null)
            {
                targetCommand.AddParameter("Day", Day.Get(context));
            }

            if (Hour.Expression != null)
            {
                targetCommand.AddParameter("Hour", Hour.Get(context));
            }

            if (Minute.Expression != null)
            {
                targetCommand.AddParameter("Minute", Minute.Get(context));
            }

            if (Second.Expression != null)
            {
                targetCommand.AddParameter("Second", Second.Get(context));
            }

            if (Millisecond.Expression != null)
            {
                targetCommand.AddParameter("Millisecond", Millisecond.Get(context));
            }

            if (DisplayHint.Expression != null)
            {
                targetCommand.AddParameter("DisplayHint", DisplayHint.Get(context));
            }

            if (UFormat.Expression != null)
            {
                targetCommand.AddParameter("UFormat", UFormat.Get(context));
            }

            if (Format.Expression != null)
            {
                targetCommand.AddParameter("Format", Format.Get(context));
            }


            return(new ActivityImplementationContext()
            {
                PowerShellInstance = invoker
            });
        }