// 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 System.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(InputObject.Expression != null) { targetCommand.AddParameter("InputObject", InputObject.Get(context)); } if(FilePath.Expression != null) { targetCommand.AddParameter("FilePath", FilePath.Get(context)); } if(LiteralPath.Expression != null) { targetCommand.AddParameter("LiteralPath", LiteralPath.Get(context)); } if(Append.Expression != null) { targetCommand.AddParameter("Append", Append.Get(context)); } if(Variable.Expression != null) { targetCommand.AddParameter("Variable", Variable.Get(context)); } return new ActivityImplementationContext() { PowerShellInstance = invoker }; }
// 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 System.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(InputObject.Expression != null) { targetCommand.AddParameter("InputObject", InputObject.Get(context)); } if(Delimiter.Expression != null) { targetCommand.AddParameter("Delimiter", Delimiter.Get(context)); } if(UseCulture.Expression != null) { targetCommand.AddParameter("UseCulture", UseCulture.Get(context)); } if(NoTypeInformation.Expression != null) { targetCommand.AddParameter("NoTypeInformation", NoTypeInformation.Get(context)); } return new ActivityImplementationContext() { PowerShellInstance = invoker }; }
// 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 System.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(Add.Expression != null) { targetCommand.AddParameter("Add", Add.Get(context)); } if(Remove.Expression != null) { targetCommand.AddParameter("Remove", Remove.Get(context)); } if(Replace.Expression != null) { targetCommand.AddParameter("Replace", Replace.Get(context)); } if(InputObject.Expression != null) { targetCommand.AddParameter("InputObject", InputObject.Get(context)); } if(Property.Expression != null) { targetCommand.AddParameter("Property", Property.Get(context)); } return new ActivityImplementationContext() { PowerShellInstance = invoker }; }
void InternalExecute(NativeActivityContext context, ActivityInstance completedInstance) { CompensationExtension compensationExtension = context.GetExtension<CompensationExtension>(); if (compensationExtension == null) { throw FxTrace.Exception.AsError(new InvalidOperationException(SR.ConfirmWithoutCompensableActivity(this.DisplayName))); } CompensationToken token = Target.Get(context); CompensationTokenData tokenData = token == null ? null : compensationExtension.Get(token.CompensationId); Fx.Assert(tokenData != null, "CompensationTokenData must be valid"); if (tokenData.ExecutionTracker.Count > 0) { if (this.onChildConfirmed == null) { this.onChildConfirmed = new CompletionCallback(InternalExecute); } this.toConfirmToken.Set(context, new CompensationToken(tokenData.ExecutionTracker.Get())); Fx.Assert(Body != null, "Body must be valid"); context.ScheduleActivity(Body, this.onChildConfirmed); } }
private void OnExecuteBodyCompleted(NativeActivityContext context, ActivityInstance instance) { var vars = ComputationContext.GetVariables(context, this); vars.Set(IterationNoVarName, vars.Get<int>(IterationNoVarName) + 1); context.ScheduleActivity(Condition, OnExecuteConditionCompleted); }
// 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 System.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 (To.Expression != null) { targetCommand.AddParameter("To", To.Get(context)); } if (Content.Expression != null) { targetCommand.AddParameter("Content", Content.Get(context)); } if (Path.Expression != null) { targetCommand.AddParameter("Path", Path.Get(context)); } if (LiteralPath.Expression != null) { targetCommand.AddParameter("LiteralPath", LiteralPath.Get(context)); } if (OutFile.Expression != null) { targetCommand.AddParameter("OutFile", OutFile.Get(context)); } return new ActivityImplementationContext() { PowerShellInstance = invoker }; }
/// <summary> /// The execute. /// </summary> /// <param name="context"> /// The context. /// </param> protected override void Execute(NativeActivityContext context) { context.CreateBookmark( this.BookmarkName.Get(context), (activityContext, bookmark, value) => activityContext.ResumeBookmark(new Bookmark(this.BookmarkName.Get(activityContext)), null)); }
public void Exit(NativeActivityContext context) { context.ThrowIfDisposed(); ThrowIfUninitialized(); context.ExitNoPersist(this); }
protected override void Execute(NativeActivityContext context) { if (this.Activities.Count > 0) { Bookmark bm = context.Properties.Find(Constants._ContainsChildWizard) as Bookmark; if (bm != null) { context.ResumeBookmark(bm, true); } Bookmark parentbm = context.Properties.Find(Constants._ResumeParent) as Bookmark; if (parentbm != null) { this.ResumeParent.Set(context, parentbm); } Bookmark ResumeParent = context.CreateBookmark(ResumeParentCallBack, BookmarkOptions.NonBlocking | BookmarkOptions.MultipleResume); context.Properties.Update(Constants._ResumeParent, ResumeParent); FindStepAndSchedule(context); } }
protected override void Execute(NativeActivityContext context) { //Access to the current transaction in Workflow is through the GetCurrentTransaction method on a RuntimeTransactionHandle RuntimeTransactionHandle rth = new RuntimeTransactionHandle(); rth = context.Properties.Find(rth.ExecutionPropertyName) as RuntimeTransactionHandle; Console.WriteLine(" TransactionID: " + rth.GetCurrentTransaction(context).TransactionInformation.LocalIdentifier.ToString()); }
// 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 System.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(Path.Expression != null) { targetCommand.AddParameter("Path", Path.Get(context)); } if(LiteralPath.Expression != null) { targetCommand.AddParameter("LiteralPath", LiteralPath.Get(context)); } if(IncludeTotalCount.Expression != null) { targetCommand.AddParameter("IncludeTotalCount", IncludeTotalCount.Get(context)); } if(Skip.Expression != null) { targetCommand.AddParameter("Skip", Skip.Get(context)); } if(First.Expression != null) { targetCommand.AddParameter("First", First.Get(context)); } return new ActivityImplementationContext() { PowerShellInstance = invoker }; }
protected override void Execute(NativeActivityContext context) { if (this.Child != null) { context.ScheduleActivity(Child, this.onChildComplete); } }
// 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 System.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(Name.Expression != null) { targetCommand.AddParameter("Name", Name.Get(context)); } if(Force.Expression != null) { targetCommand.AddParameter("Force", Force.Get(context)); } if(SecurityDescriptorSddl.Expression != null) { targetCommand.AddParameter("SecurityDescriptorSddl", SecurityDescriptorSddl.Get(context)); } if(SkipNetworkProfileCheck.Expression != null) { targetCommand.AddParameter("SkipNetworkProfileCheck", SkipNetworkProfileCheck.Get(context)); } if(NoServiceRestart.Expression != null) { targetCommand.AddParameter("NoServiceRestart", NoServiceRestart.Get(context)); } return new ActivityImplementationContext() { PowerShellInstance = invoker }; }
// 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 System.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(SourceIdentifier.Expression != null) { targetCommand.AddParameter("SourceIdentifier", SourceIdentifier.Get(context)); } if(SubscriptionId.Expression != null) { targetCommand.AddParameter("SubscriptionId", SubscriptionId.Get(context)); } if(Force.Expression != null) { targetCommand.AddParameter("Force", Force.Get(context)); } return new ActivityImplementationContext() { PowerShellInstance = invoker }; }
public static GenericVariableCollection GetVariables(NativeActivityContext context, Activity activity) { Contract.Requires(context != null); Contract.Requires(activity != null); return GetVariables(context, activity.Id); }
// 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 System.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(InputObject.Expression != null) { targetCommand.AddParameter("InputObject", InputObject.Get(context)); } if(Depth.Expression != null) { targetCommand.AddParameter("Depth", Depth.Get(context)); } if(Compress.Expression != null) { targetCommand.AddParameter("Compress", Compress.Get(context)); } return new ActivityImplementationContext() { PowerShellInstance = invoker }; }
protected override void Execute(NativeActivityContext context) { if (this.Body != null) { context.ScheduleActivity(this.Body, new CompletionCallback(OnBodyComplete)); } }
// 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 System.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(Uri.Expression != null) { targetCommand.AddParameter("Uri", Uri.Get(context)); } if(Class.Expression != null) { targetCommand.AddParameter("Class", Class.Get(context)); } if(Namespace.Expression != null) { targetCommand.AddParameter("Namespace", Namespace.Get(context)); } if(Credential.Expression != null) { targetCommand.AddParameter("Credential", Credential.Get(context)); } if(UseDefaultCredential.Expression != null) { targetCommand.AddParameter("UseDefaultCredential", UseDefaultCredential.Get(context)); } return new ActivityImplementationContext() { PowerShellInstance = invoker }; }
private void Continue(NativeActivityContext context, Bookmark bookmark, object obj) { var args = (object[])obj; var userID = (int)args[0]; UserID.Set(context, userID); var result = 0; var id = ID.Get(context); var item = ProjectProcessService.GetById(id); ProjectProcessService.LoadReference(item, i => i.Owner); var appraisalResult = ProjectProcessService.GetAppraisalResult(item); var userCount = UserService.Count(); if (appraisalResult.Item1 + appraisalResult.Item2 < userCount * 0.8)//投票人数未达到所有人的 80% { result = 0; } else { if (appraisalResult.Item1 > appraisalResult.Item2 * 2)//同意的人数大于不同意人数的两倍 { result = 1; InboxService.Create(UserRoleEnum.全员, item.ID, RedirectType.项目流程查看, InboxService.APPRAISAL_FINISH_PROCESS_PROJECT, item.ID.ToString(), appraisalResult.Item1.ToString(), appraisalResult.Item2.ToString(), "通过", item.Owner.NickName); InboxService.Create(UserRoleEnum.运营组成员, item.ID, RedirectType.项目流程处理, InboxService.DESIGN_PROCESS_PROJECT, item.ID.ToString(), item.Owner.NickName); } else { result = -1; InboxService.Create(UserRoleEnum.全员, item.ID, RedirectType.项目流程查看, InboxService.APPRAISAL_FINISH_PROCESS_PROJECT, item.ID.ToString(), appraisalResult.Item1.ToString(), appraisalResult.Item2.ToString(), "不通过", item.Owner.NickName); } } Rusult.Set(context, result); }
// 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 System.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 (String.Expression != null) { targetCommand.AddParameter("String", String.Get(context)); } if (AsPlainText.Expression != null) { targetCommand.AddParameter("AsPlainText", AsPlainText.Get(context)); } if (Force.Expression != null) { targetCommand.AddParameter("Force", Force.Get(context)); } if (SecureKey.Expression != null) { targetCommand.AddParameter("SecureKey", SecureKey.Get(context)); } if (Key.Expression != null) { targetCommand.AddParameter("Key", Key.Get(context)); } return new ActivityImplementationContext() { PowerShellInstance = invoker }; }
// 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 System.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(ProviderName.Expression != null) { targetCommand.AddParameter("ProviderName", ProviderName.Get(context)); } if(WinEventId.Expression != null) { targetCommand.AddParameter("Id", WinEventId.Get(context)); } if(Version.Expression != null) { targetCommand.AddParameter("Version", Version.Get(context)); } if(Payload.Expression != null) { targetCommand.AddParameter("Payload", Payload.Get(context)); } return new ActivityImplementationContext() { PowerShellInstance = invoker }; }
protected override void OnExecute(NativeActivityContext context, object objectToValidate, ValidationContext objectToValidateContext) { bool foundMultiple; ActivityWithResult boundExpression; LocationReference locationReference; ActivityWithResult activity = (ActivityWithResult)objectToValidate; foreach (RuntimeArgument runtimeArgument in activity.RuntimeArguments) { boundExpression = runtimeArgument.BoundArgument.Expression; if (boundExpression != null && boundExpression is ILocationReferenceWrapper) { locationReference = ((ILocationReferenceWrapper)boundExpression).LocationReference; if (locationReference != null) { foundMultiple = FindLocationReferencesFromEnvironment(objectToValidateContext.Environment, locationReference.Name); if (foundMultiple) { Constraint.AddValidationError(context, new ValidationError(SR.AmbiguousVBVariableReference(locationReference.Name))); } } } } }
// 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 System.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(HotFixId.Expression != null) { targetCommand.AddParameter("Id", HotFixId.Get(context)); } if(Description.Expression != null) { targetCommand.AddParameter("Description", Description.Get(context)); } if(Credential.Expression != null) { targetCommand.AddParameter("Credential", Credential.Get(context)); } if(GetIsComputerNameSpecified(context) && (PSRemotingBehavior.Get(context) == RemotingBehavior.Custom)) { targetCommand.AddParameter("ComputerName", PSComputerName.Get(context)); } return new ActivityImplementationContext() { PowerShellInstance = invoker }; }
protected override void Execute(NativeActivityContext context) { var bookmark = context.CreateBookmark(BookmarkName.Get(context), BookmarkResumed); var extension = context.GetExtension<Helpers.WorkflowInstanceExtensionHelper>(); //extension.WaitSome(bookmark); }
// 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 System.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(SourceIdentifier.Expression != null) { targetCommand.AddParameter("SourceIdentifier", SourceIdentifier.Get(context)); } if(Sender.Expression != null) { targetCommand.AddParameter("Sender", Sender.Get(context)); } if(EventArguments.Expression != null) { targetCommand.AddParameter("EventArguments", EventArguments.Get(context)); } if(MessageData.Expression != null) { targetCommand.AddParameter("MessageData", MessageData.Get(context)); } return new ActivityImplementationContext() { PowerShellInstance = invoker }; }
protected override void Cancel(NativeActivityContext context) { Bookmark bookmark = this.timerBookmark.Get(context); this.GetTimerExtension(context).CancelTimer(bookmark); context.RemoveBookmark(bookmark); context.MarkCanceled(); }
// 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 System.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(PSProvider.Expression != null) { targetCommand.AddParameter("PSProvider", PSProvider.Get(context)); } if(PSDrive.Expression != null) { targetCommand.AddParameter("PSDrive", PSDrive.Get(context)); } if(Stack.Expression != null) { targetCommand.AddParameter("Stack", Stack.Get(context)); } if(StackName.Expression != null) { targetCommand.AddParameter("StackName", StackName.Get(context)); } return new ActivityImplementationContext() { PowerShellInstance = invoker }; }
// 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 System.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(Adjust.Expression != null) { targetCommand.AddParameter("Adjust", Adjust.Get(context)); } if(DisplayHint.Expression != null) { targetCommand.AddParameter("DisplayHint", DisplayHint.Get(context)); } return new ActivityImplementationContext() { PowerShellInstance = invoker }; }
// 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 System.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(Path.Expression != null) { targetCommand.AddParameter("Path", Path.Get(context)); } if(ChildPath.Expression != null) { targetCommand.AddParameter("ChildPath", ChildPath.Get(context)); } if(Resolve.Expression != null) { targetCommand.AddParameter("Resolve", Resolve.Get(context)); } if(Credential.Expression != null) { targetCommand.AddParameter("Credential", Credential.Get(context)); } return new ActivityImplementationContext() { PowerShellInstance = invoker }; }
private void Begin(NativeActivityContext context) { var vars = ComputationContext.GetVariables(context, this); if (!vars.Exists(IterationsVarName)) { vars.Set(IterationsVarName, 0); } if (!vars.Exists(ItemCountVarName)) { // ItemCount is not yet determined. ScheduleGetItemCount(context); return; } if (!vars.Exists(StrategyVarName)) { context.ScheduleFunc(GetBatchingStrategyFactory, OnGetBatchingStrategyFactoryCompleted); } else { ScheduleGetNextVectors(context); } }
// 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 (Name.Expression != null) { targetCommand.AddParameter("Name", Name.Get(context)); } if (Path.Expression != null) { targetCommand.AddParameter("Path", Path.Get(context)); } if (Category.Expression != null) { targetCommand.AddParameter("Category", Category.Get(context)); } if (Component.Expression != null) { targetCommand.AddParameter("Component", Component.Get(context)); } if (Functionality.Expression != null) { targetCommand.AddParameter("Functionality", Functionality.Get(context)); } if (Role.Expression != null) { targetCommand.AddParameter("Role", Role.Get(context)); } if (Detailed.Expression != null) { targetCommand.AddParameter("Detailed", Detailed.Get(context)); } if (Full.Expression != null) { targetCommand.AddParameter("Full", Full.Get(context)); } if (Examples.Expression != null) { targetCommand.AddParameter("Examples", Examples.Get(context)); } if (Parameter.Expression != null) { targetCommand.AddParameter("Parameter", Parameter.Get(context)); } if (Online.Expression != null) { targetCommand.AddParameter("Online", Online.Get(context)); } if (ShowWindow.Expression != null) { targetCommand.AddParameter("ShowWindow", ShowWindow.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
protected override void Cancel(NativeActivityContext context) { // Suppress Cancel }
/// <inheritdoc /> /// <summary> /// The execute method that is called when the activity is executed at run time and will hold all the logic of the activity /// </summary> protected override void OnExecute(NativeActivityContext context) { var dataObject = context.GetExtension <IDSFDataObject>(); ExecuteTool(dataObject, 0); }
protected override void Cancel(NativeActivityContext context) { }
protected override void Execute(NativeActivityContext context) { DTrace.WriteLine(Text.Get(context)); DTrace.AutoFlush = true; DTrace.Flush(); }
protected override void Execute(NativeActivityContext context) { string username = Email.Get(context); //发送端账号 string password = Password.Get(context); //发送端密码(这个客户端重置后的密码) string server = Server.Get(context); //邮件服务器 Int32 port = Port.Get(context); //端口号 Int32 counts = Counts.Get(context); //检索邮件数 string mainFolder = MainFolder.Get(context); //邮件文件夹 string mailTopicKey = MailTopicKey.Get(context); string mailSenderKey = MailSenderKey.Get(context); string mailTextBodyKey = MailTextBodyKey.Get(context); List <object> configList = new List <object>(); List <MimeMessage> emails = new List <MimeMessage>(); ImapClient client = new ImapClient(); SearchQuery query; IList <UniqueId> uidss; try { client.CheckCertificateRevocation = false; client.ServerCertificateValidationCallback = (s, c, h, e) => true; client.Connect(server, port, SecureConnection); client.Authenticate(username, password); if (OnlyUnreadMessages || _AllUnreadMessages) { query = SearchQuery.NotSeen; } else { query = SearchQuery.All; } List <IMailFolder> mailFolderList = client.GetFolders(client.PersonalNamespaces[0]).ToList(); IMailFolder folder = client.GetFolder(mainFolder); folder.Open(FolderAccess.ReadWrite); emails = new List <MimeMessage>(); if (_AllUnreadMessages) { query = SearchQuery.NotSeen; uidss = folder.Search(query); for (int i = uidss.Count - 1; i >= 0; i--) { MimeMessage message = folder.GetMessage(new UniqueId(uidss[i].Id)); emails.Add(message); if (MarkAsRead) { folder.AddFlags(new UniqueId(uidss[i].Id), MessageFlags.Seen, true);//如果设置为true,则不会发出MessageFlagsChanged事件 } if (DeleteMessages) { folder.AddFlags(new UniqueId(uidss[i].Id), MessageFlags.Deleted, true);//如果设置为true,则不会发出MessageFlagsChanged事件 } } } else { uidss = folder.Search(query); for (int i = uidss.Count - 1, j = 0; i >= 0 && j < counts; i--, j++) { MimeMessage message = folder.GetMessage(new UniqueId(uidss[i].Id)); InternetAddressList Sender = message.From; string SenderStr = Sender.Mailboxes.First().Address; string Topic = message.Subject; if (mailTopicKey != null && mailTopicKey != "") { if (Topic == null || Topic == "") { j--; continue; } if (!Topic.Contains(mailTopicKey)) { j--; continue; } } if (mailSenderKey != null && mailSenderKey != "") { if (SenderStr == null || SenderStr == "") { j--; continue; } if (!SenderStr.Contains(mailSenderKey)) { j--; continue; } } if (mailTextBodyKey != null && mailTextBodyKey != "") { if (message.TextBody == null || message.TextBody == "") { j--; continue; } if (!message.TextBody.Contains(mailTextBodyKey)) { j--; continue; } } emails.Add(message); if (MarkAsRead) { folder.AddFlags(new UniqueId(uidss[i].Id), MessageFlags.Seen, true);//如果设置为true,则不会发出MessageFlagsChanged事件 } if (DeleteMessages) { folder.AddFlags(new UniqueId(uidss[i].Id), MessageFlags.Deleted, true);//如果设置为true,则不会发出MessageFlagsChanged事件 } } } //获取搜索结果的摘要信息(我们需要UID和BODYSTRUCTURE每条消息,以便我们可以提取文本正文和附件)(获取全部邮件) //var items = folder.Fetch(uidss, MessageSummaryItems.UniqueId | MessageSummaryItems.BodyStructure); MailMsgList.Set(context, emails); client.Disconnect(true); configList.Add(server); configList.Add(port); configList.Add(SecureConnection); configList.Add(username); configList.Add(password); configList.Add(mainFolder); } catch (Exception e) { client.Disconnect(true); SharedObject.Instance.Output(SharedObject.enOutputType.Error, "获取IMAP邮件失败", e.Message); } if (Body != null) { object[] buff = configList.ToArray(); context.ScheduleAction(Body, emails, client, buff); } }
private void onComplete(NativeActivityContext context, ActivityInstance completedInstance) { }
protected override void OnExecute(NativeActivityContext context) { throw new NotImplementedException("WebSite"); }
/// <summary> /// Restores the handler fn. /// </summary> private void RestoreHandlerFn(NativeActivityContext context) { var activity = (DataFunc.Handler as IDev2ActivityIOMapping); if (activity != null) { if (operationalData.InnerActivity.OrigCodedInputs != null) { //MO - CHANGE:This is to be reinstated for restoring actives back to state with star #region Coded Activity var tmp = (operationalData.InnerActivity.InnerActivity as DsfActivityAbstract <string>); // this is wrong, we need the last index ;) int idx = operationalData.IterationCount; //Handle csv and range differently ;) if (ForEachType == enForEachType.InCSV || ForEachType == enForEachType.InRange) { Int32.TryParse(_inputsToken, out idx); } if (tmp != null) { // Restore Inputs ;) IList <DsfForEachItem> data = tmp.GetForEachInputs(); IList <Tuple <string, string> > updates = new List <Tuple <string, string> >(); // amend inputs ;) foreach (DsfForEachItem d in data) { string input = d.Value; input = input.Replace("(" + idx + ")", "(*)"); updates.Add(new Tuple <string, string>(d.Value, input)); } // push updates for Inputs tmp.UpdateForEachInputs(updates, context); // Restore Outputs ;) data = tmp.GetForEachInputs(); updates = new List <Tuple <string, string> >(); // amend inputs ;) foreach (DsfForEachItem d in data) { string input = d.Value; input = input.Replace("(" + idx + ")", "(*)"); updates.Add(new Tuple <string, string>(d.Value, input)); } // push updates for Inputs tmp.UpdateForEachOutputs(updates, context); } else { var tmp2 = (operationalData.InnerActivity.InnerActivity as DsfActivityAbstract <bool>); // Restore Inputs ;) if (tmp2 != null) { IList <DsfForEachItem> data = tmp2.GetForEachInputs(); IList <Tuple <string, string> > updates = new List <Tuple <string, string> >(); // amend inputs ;) foreach (DsfForEachItem d in data) { string input = d.Value; input = input.Replace("(" + idx + ")", "(*)"); updates.Add(new Tuple <string, string>(d.Value, input)); } // push updates for Inputs tmp2.UpdateForEachInputs(updates, context); // Restore Outputs ;) data = tmp2.GetForEachInputs(); updates = new List <Tuple <string, string> >(); // amend inputs ;) foreach (DsfForEachItem d in data) { string input = d.Value; input = input.Replace("(" + idx + ")", "(*)"); updates.Add(new Tuple <string, string>(d.Value, input)); } // push updates for Inputs tmp2.UpdateForEachOutputs(updates, context); } } #endregion } else { activity.InputMapping = operationalData.InnerActivity.OrigInnerInputMapping; activity.OutputMapping = operationalData.InnerActivity.OrigInnerOutputMapping; } } else { throw new Exception("DsfForEachActivity - RestoreHandlerFunction has encountered a null Function"); } }
public override void UpdateForEachOutputs(IList <Tuple <string, string> > updates, NativeActivityContext context) { throw new NotImplementedException(); }
protected override void OnExecute(NativeActivityContext context) { _debugInputs = new List <DebugItem>(); _debugOutputs = new List <DebugItem>(); IDSFDataObject dataObject = context.GetExtension <IDSFDataObject>(); IDataListCompiler compiler = DataListFactory.CreateDataListCompiler(); dataObject.ForEachNestingLevel++; ErrorResultTO allErrors = new ErrorResultTO(); ErrorResultTO errors; Guid executionId = DataListExecutionID.Get(context); InitializeDebug(dataObject); try { ForEachBootstrapTO exePayload = FetchExecutionType(dataObject, executionId, compiler, out errors); if (errors.HasErrors()) { allErrors.MergeErrors(errors); return; } if (dataObject.IsDebugMode()) { DispatchDebugState(context, StateType.Before); } dataObject.ParentInstanceID = UniqueID; allErrors.MergeErrors(errors); string error; ForEachInnerActivityTO innerA = GetInnerActivity(out error); allErrors.AddError(error); exePayload.InnerActivity = innerA; operationalData = exePayload; // flag it as scoped so we can use a single DataList dataObject.IsDataListScoped = true; dataObject.IsDebugNested = true; if (exePayload.InnerActivity != null && exePayload.IndexIterator.HasMore()) { int idx = exePayload.IndexIterator.FetchNextIndex(); if (exePayload.ForEachType != enForEachType.NumOfExecution) { IterateIOMapping(idx, context); } else { dataObject.IsDataListScoped = false; } // schedule the func to execute ;) dataObject.ParentInstanceID = UniqueID; context.ScheduleFunc(DataFunc, string.Empty, ActivityCompleted); } } catch (Exception e) { Dev2Logger.Log.Error("DSFForEach", e); allErrors.AddError(e.Message); } finally { // Handle Errors if (allErrors.HasErrors()) { DisplayAndWriteError("DsfForEachActivity", allErrors); compiler.UpsertSystemTag(dataObject.DataListID, enSystemTag.Dev2Error, allErrors.MakeDataListReady(), out errors); dataObject.ParentInstanceID = _previousParentId; } if (dataObject.IsDebugMode()) { DispatchDebugState(context, StateType.After); } } }
protected override void Execute(NativeActivityContext context) { //HACK:节点执行时首先设置当前节点索引 context.GetExtension <DataFieldExtension>().SetCurrentNode(this.FlowNodeIndex); base.Execute(context); }
protected override void Execute(NativeActivityContext context) { XPObjectSpace xpObjectSpace = (XPObjectSpace)GetObjectSpace(context); xpObjectSpace.Session.ExecuteSproc("StoredProcName"); }
/// <summary> /// Iterates the IO mapping. /// </summary> private void IterateIOMapping(int idx, NativeActivityContext context) { string newInputs = string.Empty; string newOutputs = string.Empty; bool updateInputToken = false; bool updateOutputToken = false; // Now mutate the mappings ;) //Bug 8725 do not mutate mappings if (operationalData.InnerActivity.OrigInnerInputMapping != null) { // (*) == ({idx}) ;) newInputs = operationalData.InnerActivity.OrigInnerInputMapping; newInputs = _inputItr.IterateMapping(newInputs, idx); newInputs = newInputs.Replace("(*)", "(" + idx + ")"); } else { // coded activity #region Coded Activity IO ManIP var tmp = (operationalData.InnerActivity.InnerActivity as DsfActivityAbstract <string>); if (_previousInputsIndex != -1) { if (_inputsToken != "*") { _inputsToken = (_previousInputsIndex).ToString(CultureInfo.InvariantCulture); } } if (_previousOutputsIndex != -1) { if (_outputsToken != "*") { _outputsToken = (_previousOutputsIndex).ToString(CultureInfo.InvariantCulture); } } if (tmp != null) { IList <DsfForEachItem> data = tmp.GetForEachInputs(); IList <Tuple <string, string> > updates = new List <Tuple <string, string> >(); if (AmendInputs(idx, data, _inputsToken, updates)) { updateInputToken = true; } // push updates for Inputs tmp.UpdateForEachInputs(updates, context); if (idx == 1) { operationalData.InnerActivity.OrigCodedInputs = updates; } operationalData.InnerActivity.CurCodedInputs = updates; // Process outputs data = tmp.GetForEachOutputs(); updates = new List <Tuple <string, string> >(); if (AmendOutputs(idx, data, _outputsToken, updates)) { updateOutputToken = true; } // push updates tmp.UpdateForEachOutputs(updates, context); if (idx == 1) { operationalData.InnerActivity.OrigCodedOutputs = updates; } operationalData.InnerActivity.CurCodedOutputs = updates; } else { var tmp2 = (operationalData.InnerActivity.InnerActivity as DsfActivityAbstract <bool>); if (tmp2 != null && !(tmp2 is DsfForEachActivity)) { IList <DsfForEachItem> data = tmp2.GetForEachInputs(); IList <Tuple <string, string> > updates = new List <Tuple <string, string> >(); if (AmendInputs(idx, data, _inputsToken, updates)) { updateInputToken = true; } // push updates tmp2.UpdateForEachInputs(updates, context); if (idx == 1) { operationalData.InnerActivity.OrigCodedInputs = updates; } operationalData.InnerActivity.CurCodedInputs = updates; // Process outputs data = tmp2.GetForEachOutputs(); updates = new List <Tuple <string, string> >(); if (AmendOutputs(idx, data, _outputsToken, updates)) { updateOutputToken = true; } // push updates tmp2.UpdateForEachOutputs(updates, context); if (idx == 1) { operationalData.InnerActivity.OrigCodedOutputs = updates; } operationalData.InnerActivity.CurCodedOutputs = updates; } } #endregion } //Bug 8725 do not mutate mappings if (operationalData.InnerActivity.OrigInnerOutputMapping != null) { // (*) == ({idx}) ;) newOutputs = operationalData.InnerActivity.OrigInnerOutputMapping; newOutputs = _inputItr.IterateMapping(newOutputs, idx); } var dev2ActivityIoMapping = DataFunc.Handler as IDev2ActivityIOMapping; if (dev2ActivityIoMapping != null) { dev2ActivityIoMapping.InputMapping = newInputs; } var activityIoMapping = DataFunc.Handler as IDev2ActivityIOMapping; if (activityIoMapping != null) { activityIoMapping.OutputMapping = newOutputs; } if (updateInputToken) { _inputsToken = idx.ToString(CultureInfo.InvariantCulture); } if (updateOutputToken) { _outputsToken = idx.ToString(CultureInfo.InvariantCulture); } }
protected override void OnExecute(NativeActivityContext context) { }
protected override void OnBeforeExecute(NativeActivityContext context) { var dataObject = context.GetExtension <IDSFDataObject>(); _previousParentId = dataObject.ParentInstanceID; }
protected override void Execute(NativeActivityContext context) { InternalExecute(context, null); }
protected virtual IObjectSpace GetObjectSpace(NativeActivityContext context) { return((IObjectSpace)context.Properties.Find(ObjectSpaceTransactionScope.ObjectSpacePropertyName)); }
private void onComplete(NativeActivityContext context, ActivityInstance completedInstance) { Console.WriteLine("ClickActivity onComplete"); }
// 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 (Namespace.Expression != null) { targetCommand.AddParameter("Namespace", Namespace.Get(context)); } if (Credential.Expression != null) { targetCommand.AddParameter("Credential", Credential.Get(context)); } if (ComputerName.Expression != null) { targetCommand.AddParameter("ComputerName", ComputerName.Get(context)); } if (Class.Expression != null) { targetCommand.AddParameter("Class", Class.Get(context)); } if (Query.Expression != null) { targetCommand.AddParameter("Query", Query.Get(context)); } if (Timeout.Expression != null) { targetCommand.AddParameter("Timeout", Timeout.Get(context)); } if (SourceIdentifier.Expression != null) { targetCommand.AddParameter("SourceIdentifier", SourceIdentifier.Get(context)); } if (Action.Expression != null) { targetCommand.AddParameter("Action", Action.Get(context)); } if (MessageData.Expression != null) { targetCommand.AddParameter("MessageData", MessageData.Get(context)); } if (SupportEvent.Expression != null) { targetCommand.AddParameter("SupportEvent", SupportEvent.Get(context)); } if (Forward.Expression != null) { targetCommand.AddParameter("Forward", Forward.Get(context)); } if (MaxTriggerCount.Expression != null) { targetCommand.AddParameter("MaxTriggerCount", MaxTriggerCount.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
void OnBookmarkCallback(NativeActivityContext context, Bookmark bookmark, object obj) { try { bool waitforcompleted = WaitForCompleted.Get(context); if (!waitforcompleted) { return; } // keep bookmark, incase workflow dies, and need to pickup data after being restarted // context.RemoveBookmark(bookmark.Name); var instance = obj as WorkflowInstance; if (instance == null) { throw new Exception("Bookmark returned a non WorkflowInstance"); } var workflow = RobotInstance.instance.GetWorkflowByIDOrRelativeFilename(this.workflow.Get(context)); var name = "The invoked workflow failed with "; if (workflow != null && !string.IsNullOrEmpty(workflow.name)) { name = workflow.name; } if (workflow != null && !string.IsNullOrEmpty(workflow.ProjectAndName)) { name = workflow.ProjectAndName; } if (instance.Exception != null) { throw new Exception(name + " failed with " + instance.Exception.Message, instance.Exception); } if (instance.hasError) { throw new Exception(name + " failed with " + instance.errormessage); } if (Arguments == null || Arguments.Count == 0) { foreach (var prop in instance.Parameters) { var myVar = context.DataContext.GetProperties().Find(prop.Key, true); if (myVar != null) { myVar.SetValue(context.DataContext, prop.Value); //if (myVar.PropertyType.Name == "DataTable") //{ // var json = prop.ToString(); // if(!string.IsNullOrEmpty(json)) // { // var jarray = JArray.Parse(json); // myVar.SetValue(context.DataContext, jarray.ToDataTable()); // } // else // { // myVar.SetValue(context.DataContext, null); // } //} //else //{ // //var myValue = myVar.GetValue(context.DataContext); // myVar.SetValue(context.DataContext, prop.Value); //} } else { Log.Debug("Recived property " + prop.Key + " but no variable exists to save the value in " + prop.Value); } } } else { Dictionary <string, object> arguments = (from argument in Arguments where argument.Value.Direction != ArgumentDirection.In select argument).ToDictionary((KeyValuePair <string, Argument> argument) => argument.Key, (KeyValuePair <string, Argument> argument) => argument.Value.Get(context)); foreach (var a in arguments) { if (instance.Parameters.ContainsKey(a.Key)) { Arguments[a.Key].Set(context, instance.Parameters[a.Key]); } else { try { if (Arguments[a.Key].ArgumentType.IsValueType) { Arguments[a.Key].Set(context, Activator.CreateInstance(Arguments[a.Key].ArgumentType)); } else { Arguments[a.Key].Set(context, null); } } catch (Exception ex) { Log.Error("Error setting " + a.Key + ": " + ex.Message); } } } } } catch (Exception ex) { Log.Error(ex.ToString()); throw; } }
protected override void StartLoop(NativeActivityContext context) { var SelectorString = Selector.Get(context); SelectorString = OpenRPA.Interfaces.Selector.Selector.ReplaceVariables(SelectorString, context.DataContext); var sel = new SAPSelector(SelectorString); var timeout = Timeout.Get(context); if (Timeout == null || Timeout.Expression == null) { timeout = TimeSpan.FromSeconds(3); } var maxresults = MaxResults.Get(context); var minresults = MinResults.Get(context); var flatternguitree = FlatternGuiTree.Get(context); //var from = From.Get(context); SAPElement from = null; if (maxresults < 1) { maxresults = 1; } if (timeout.Minutes > 5 || timeout.Hours > 1) { Activity _Activity = null; try { var strProperty = context.GetType().GetProperty("Activity", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); var strGetter = strProperty.GetGetMethod(nonPublic: true); _Activity = (Activity)strGetter.Invoke(context, null); } catch (Exception) { } if (_Activity != null) { Log.Warning("Timeout for Activity " + _Activity.Id + " is above 5 minutes, was this the intention ? calculated value " + timeout.ToString()); } else { Log.Warning("Timeout for on of your SAP.GetElements is above 5 minutes, was this the intention ? calculated value " + timeout.ToString()); } } SAPElement[] elements = { }; var sw = new Stopwatch(); sw.Start(); do { var selector = new SAPSelector(SelectorString); elements = SAPSelector.GetElementsWithuiSelector(selector, from, 0, maxresults, flatternguitree); } while (elements.Count() == 0 && sw.Elapsed < timeout); Log.Debug(string.Format("OpenRPA.SAP::GetElement::found {1} elements in {0:mm\\:ss\\.fff}", sw.Elapsed, elements.Count())); if (elements.Count() > maxresults) { elements = elements.Take(maxresults).ToArray(); } if (elements.Count() < minresults) { Log.Selector(string.Format("Windows.GetElement::Failed locating " + minresults + " item(s) {0:mm\\:ss\\.fff}", sw.Elapsed)); throw new ElementNotFoundException("Failed locating " + minresults + " item(s)"); } context.SetValue(Elements, elements); IEnumerator <SAPElement> _enum = elements.ToList().GetEnumerator(); context.SetValue(_elements, _enum); bool more = _enum.MoveNext(); if (more) { IncIndex(context); SetTotal(context, elements.Length); context.ScheduleAction(Body, _enum.Current, OnBodyComplete); } }
// 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 (Path.Expression != null) { targetCommand.AddParameter("Path", Path.Get(context)); } if (LiteralPath.Expression != null) { targetCommand.AddParameter("LiteralPath", LiteralPath.Get(context)); } if (Filter.Expression != null) { targetCommand.AddParameter("Filter", Filter.Get(context)); } if (Include.Expression != null) { targetCommand.AddParameter("Include", Include.Get(context)); } if (Exclude.Expression != null) { targetCommand.AddParameter("Exclude", Exclude.Get(context)); } if (Recurse.Expression != null) { targetCommand.AddParameter("Recurse", Recurse.Get(context)); } if (Depth.Expression != null) { targetCommand.AddParameter("Depth", Depth.Get(context)); } if (Force.Expression != null) { targetCommand.AddParameter("Force", Force.Get(context)); } if (Name.Expression != null) { targetCommand.AddParameter("Name", Name.Get(context)); } if (Attributes.Expression != null) { targetCommand.AddParameter("Attributes", Attributes.Get(context)); } if (Directory.Expression != null) { targetCommand.AddParameter("Directory", Directory.Get(context)); } if (File.Expression != null) { targetCommand.AddParameter("File", File.Get(context)); } if (Hidden.Expression != null) { targetCommand.AddParameter("Hidden", Hidden.Get(context)); } if (ReadOnly.Expression != null) { targetCommand.AddParameter("ReadOnly", ReadOnly.Get(context)); } if (System.Expression != null) { targetCommand.AddParameter("System", System.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
protected override void Execute(NativeActivityContext context) { bool waitforcompleted = WaitForCompleted.Get(context); string WorkflowInstanceId = context.WorkflowInstanceId.ToString(); // IDictionary<string, object> _payload = new System.Dynamic.ExpandoObject(); var param = new Dictionary <string, object>(); if (Arguments == null || Arguments.Count == 0) { var vars = context.DataContext.GetProperties(); foreach (dynamic v in vars) { var value = v.GetValue(context.DataContext); if (value != null) { //_payload.Add(v.DisplayName, value); try { var test = new { value }; if (value.GetType() == typeof(System.Data.DataView)) { continue; } if (value.GetType() == typeof(System.Data.DataRowView)) { continue; } //if (value.GetType() == typeof(System.Data.DataTable)) //{ // if (value != null) param[v.DisplayName] = ((System.Data.DataTable)value).ToJArray(); //} //else //{ // var asjson = JObject.FromObject(test); // param[v.DisplayName] = value; //} // var asjson = JObject.FromObject(test); param[v.DisplayName] = value; } catch (Exception) { } } else { param[v.DisplayName] = value; } } } else { Dictionary <string, object> arguments = (from argument in Arguments where argument.Value.Direction != ArgumentDirection.Out select argument).ToDictionary((KeyValuePair <string, Argument> argument) => argument.Key, (KeyValuePair <string, Argument> argument) => argument.Value.Get(context)); foreach (var a in arguments) { var value = a.Value; if (value != null) { if (value.GetType() == typeof(System.Data.DataView)) { continue; } if (value.GetType() == typeof(System.Data.DataRowView)) { continue; } //if (value.GetType() == typeof(System.Data.DataTable)) //{ // if (value != null) param[a.Key] = ((System.Data.DataTable)value).ToJArray(); //} //else //{ // param[a.Key] = a.Value; //} param[a.Key] = a.Value; } else { param[a.Key] = null; } } } try { var workflow = RobotInstance.instance.GetWorkflowByIDOrRelativeFilename(this.workflow.Get(context)); IWorkflowInstance instance = null; Views.WFDesigner designer = null; GenericTools.RunUI(() => { designer = RobotInstance.instance.GetWorkflowDesignerByIDOrRelativeFilename(this.workflow.Get(context)) as Views.WFDesigner; if (designer != null) { designer.BreakpointLocations = null; instance = workflow.CreateInstance(param, null, null, designer.IdleOrComplete, designer.OnVisualTracking); } else { instance = workflow.CreateInstance(param, null, null, RobotInstance.instance.Window.IdleOrComplete, null); } instance.caller = WorkflowInstanceId; }); Log.Verbose("InvokeOpenRPA: Run Instance ID " + instance._id); if (waitforcompleted) { context.CreateBookmark(instance._id, new BookmarkCallback(OnBookmarkCallback)); if (instance.Bookmarks == null) { instance.Bookmarks = new Dictionary <string, object>(); } instance.Bookmarks.Add(instance._id, null); //((WorkflowInstance)instance).wfApp.Persist(); } GenericTools.RunUI(() => { if (designer != null) { designer.Run(designer.VisualTracking, designer.SlowMotion, instance); } else { instance.Run(); } }); } catch (Exception ex) { Log.Error(ex.ToString()); throw; } }
protected override void Execute(NativeActivityContext context) { Result.Set(context, ResultToSet); }
public static bool TryGetCallbackCorrelationHandle(this Collection <CorrelationInitializer> correlationInitializers, NativeActivityContext context, out CorrelationHandle correlationHandle) { correlationHandle = CorrelationHandle.GetExplicitCallbackCorrelation(context, correlationInitializers); return(correlationHandle != null); }
private void resumeCallBack(NativeActivityContext context, Bookmark bookmark, object value) { context.SetValue(Result, (T)value); }
void bookmarkCallback(NativeActivityContext context, Bookmark bookmark, object obj) { this.Result.Set(context, (string)obj); }
static void OnPersistComplete(NativeActivityContext context, Bookmark bookmark, object value) { // No-op. This is here to keep the activity from completing. }
private void OnCompleted(NativeActivityContext context, ActivityInstance completedInstance) { Cleanup(); }