Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }