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 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); }
protected async override Task <object> ExecuteAsync(AsyncCodeActivityContext context) { var status = new string[] { "failed", "successful", "abandoned", "retry", "processing" }; var files = Files.Get <string[]>(context); var t = Workitem.Get(context); var ex = Exception.Get(context); var ignoremaxretries = IgnoreMaxretries.Get(context); if (t == null) { throw new Exception("Missing Workitem"); } t.success_wiq = Success_wiq.Get <string>(context); t.failed_wiq = Failed_wiq.Get <string>(context); if (State != null && State.Expression != null) { var state = State.Get(context); if (!string.IsNullOrEmpty(state)) { t.state = state; } } if (ex != null) { while (ex.InnerException != null) { ex = ex.InnerException; } t.errormessage = ex.Message; t.errortype = "application"; t.errorsource = ex.Source; if (ex is BusinessRuleException) { t.errortype = "business"; } } t.state = t.state.ToLower(); if (!status.Contains(t.state)) { throw new Exception("Illegal state on Workitem, must be failed, successful, abandoned or retry"); } await RobotInstance.instance.WaitForSignedIn(TimeSpan.FromSeconds(10)); var result = await global.webSocketClient.UpdateWorkitem <Workitem>(t, files, ignoremaxretries); return(result); }
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); }