protected async override Task <object> ExecuteAsync(AsyncCodeActivityContext context) { var files = Files.Get <string[]>(context); var t = new Workitem(); t.wiqid = wiqid.Get <string>(context); t.wiq = wiq.Get <string>(context); t.name = Name.Get <string>(context); t.priority = Priority.Get <int>(context); t.nextrun = NextRun.Get <DateTime?>(context); t.success_wiq = Success_wiq.Get <string>(context); t.failed_wiq = Failed_wiq.Get <string>(context); if (t.payload == null) { t.payload = new Dictionary <string, object>(); } foreach (var item in Payload) { t.payload.Add(item.Key, item.Value.Get(context)); } Workitem result = null; await RobotInstance.instance.WaitForSignedIn(TimeSpan.FromSeconds(10)); result = await global.webSocketClient.AddWorkitem <Workitem>(t, files); return(result); }
protected override void Execute(NativeActivityContext context) { var db = context.GetExtension <Db>(); var button = new ButtonEntry() { Id = Guid.NewGuid(), Name = Name.Get(context), Priority = Priority.Get(context), Style = Style.Get(context) }; if (string.IsNullOrEmpty(button.Style)) { button.Style = "btn-default"; } var userTaskId = (Guid)context.DataContext.GetProperties()["__UserTaskId"].GetValue(context.DataContext); var userTask = db.UserTasks.Find(userTaskId); userTask.Buttons.Add(button); buttonId.Set(context, button.Id); context.CreateBookmark(button.Id.ToString(), OnClick); }
protected async override Task <object> ExecuteAsync(AsyncCodeActivityContext context) { var files = Files.Get <string[]>(context); var t = new OpenRPA.Workitem(); t.wiqid = wiqid.Get <string>(context); t.wiq = wiq.Get <string>(context); t.name = Name.Get <string>(context); t.priority = Priority.Get <int>(context); t.nextrun = NextRun.Get <DateTime?>(context); t.success_wiq = Success_wiq.Get <string>(context); t.failed_wiq = Failed_wiq.Get <string>(context); if (t.payload == null) { t.payload = new Dictionary <string, object>(); } foreach (var item in Payload) { t.payload.Add(item.Key, item.Value.Get(context)); } Workitem result = null; if (string.IsNullOrEmpty(Config.local.wsurl)) { await t.Save(false); } else { result = await global.webSocketClient.AddWorkitem <Workitem>(t, files); } return(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 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 (Attachments.Expression != null) { targetCommand.AddParameter("Attachments", Attachments.Get(context)); } if (Bcc.Expression != null) { targetCommand.AddParameter("Bcc", Bcc.Get(context)); } if (Body.Expression != null) { targetCommand.AddParameter("Body", Body.Get(context)); } if (BodyAsHtml.Expression != null) { targetCommand.AddParameter("BodyAsHtml", BodyAsHtml.Get(context)); } if (Encoding.Expression != null) { targetCommand.AddParameter("Encoding", Encoding.Get(context)); } if (Cc.Expression != null) { targetCommand.AddParameter("Cc", Cc.Get(context)); } if (DeliveryNotificationOption.Expression != null) { targetCommand.AddParameter("DeliveryNotificationOption", DeliveryNotificationOption.Get(context)); } if (From.Expression != null) { targetCommand.AddParameter("From", From.Get(context)); } if (SmtpServer.Expression != null) { targetCommand.AddParameter("SmtpServer", SmtpServer.Get(context)); } if (Priority.Expression != null) { targetCommand.AddParameter("Priority", Priority.Get(context)); } if (Subject.Expression != null) { targetCommand.AddParameter("Subject", Subject.Get(context)); } if (To.Expression != null) { targetCommand.AddParameter("To", To.Get(context)); } if (Credential.Expression != null) { targetCommand.AddParameter("Credential", Credential.Get(context)); } if (UseSsl.Expression != null) { targetCommand.AddParameter("UseSsl", UseSsl.Get(context)); } if (Port.Expression != null) { targetCommand.AddParameter("Port", Port.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
protected async override Task <object> ExecuteAsync(AsyncCodeActivityContext context) { var _wiqid = wiqid.Get(context); var _wiq = wiq.Get(context); var dt = DataTable.Get(context); var priority = Priority.Get <int>(context); var bulksize = BulkSize.Get <int>(context); if (bulksize < 1) { bulksize = 50; } var nextrun = NextRun.Get <DateTime?>(context); var items = new List <OpenRPA.Interfaces.AddWorkitem>(); var filefields = Filefields.Get <string[]>(context); if (filefields == null) { filefields = new string[] { } } ; for (var i = 0; i < filefields.Length; i++) { filefields[i] = filefields[i].ToLower(); } var counter = 0; var bulkcounter = 0; if (dt == null) { Log.Warning("BulkAddWorkitems: Datatable is null"); return(null); } if (dt.Rows == null) { Log.Warning("BulkAddWorkitems: Datatable contains no rows"); return(null); } foreach (DataRow row in dt.Rows) { counter++; bulkcounter++; var wi = new Interfaces.AddWorkitem(); wi.name = "Bulk added item " + counter.ToString(); wi.priority = priority; wi.nextrun = nextrun; wi.payload = new Dictionary <string, object>(); var _files = new List <MessageWorkitemFile>(); foreach (DataColumn field in dt.Columns) { if (string.IsNullOrEmpty(field.ColumnName)) { continue; } var columnname = field.ColumnName.ToLower(); wi.payload.Add(columnname, row[field.ColumnName]); if (columnname == "name") { wi.name = row[field.ColumnName].ToString(); } if (filefields.Contains(columnname)) { if (field.DataType == typeof(string)) { _files.Add(new MessageWorkitemFile() { filename = row[field.ColumnName].ToString() }); } } } wi.files = _files.ToArray(); items.Add(wi); if (bulkcounter >= bulksize) { await global.webSocketClient.AddWorkitems(_wiqid, _wiq, items.ToArray()); items.Clear(); } } if (items.Count > 0) { await global.webSocketClient.AddWorkitems(_wiqid, _wiq, items.ToArray(), Success_wiq.Get <string>(context), null, Failed_wiq.Get <string>(context), null); } return(null); }