예제 #1
0
        protected override void Execute(CodeActivityContext context)
        {
            string text = Text.Get(context);

            System.Drawing.Bitmap image = Image.Get(context);
            try
            {
                System.Threading.Thread staThread = new System.Threading.Thread(() =>
                {
                    if (!string.IsNullOrEmpty(text))
                    {
                        System.Windows.Clipboard.SetDataObject(text, true);
                    }
                    if (image != null)
                    {
                        System.Windows.Clipboard.SetDataObject(image, true);
                    }
                });
                staThread.SetApartmentState(System.Threading.ApartmentState.STA);
                staThread.Start();
                staThread.Join();
            }
            catch (Exception ex)
            {
                if (IgnoreErrors.Get(context))
                {
                    Log.Debug(ex.Message);
                    return;
                }
                throw;
            }
        }
예제 #2
0
        protected async override Task <JObject[]> ExecuteAsync(AsyncCodeActivityContext context)
        {
            var ignoreErrors = IgnoreErrors.Get(context);
            var collection   = Collection.Get(context);
            var querystring  = QueryString.Get(context);
            var projection   = Projection.Get(context);
            var top          = Top.Get(context);
            var skip         = Skip.Get(context);

            if (top < 1)
            {
                top = 100;
            }
            if (skip < 0)
            {
                skip = 0;
            }
            var orderby = Orderby.Get(context);

            if (string.IsNullOrEmpty(collection))
            {
                collection = "entities";
            }
            JObject[] result = null;
            result = await global.webSocketClient.Query <JObject>(collection, querystring, projection, top, skip, orderby);

            System.Windows.Forms.Application.DoEvents();
            return(result);
        }
예제 #3
0
        protected async override Task <object> ExecuteAsync(AsyncCodeActivityContext context)
        {
            var filename     = Filename.Get(context);
            var id           = _id.Get(context);
            var ignoreerrors = IgnoreErrors.Get(context);

            var q = "{\"_id\": \"" + id + "\"}";

            if (!string.IsNullOrEmpty(filename))
            {
                q = "{\"filename\":\"" + filename + "\"}";
            }
            // await global.webSocketClient.DeleteOne("files", q);
            var rows = await global.webSocketClient.Query <JObject>("fs.files", q);

            if (rows.Length == 0)
            {
                if (!ignoreerrors)
                {
                    throw new Exception("File not found");
                }
                return(42);
            }
            foreach (var row in rows)
            {
                var _id = row["_id"].ToString();
                await global.webSocketClient.DeleteOne("fs.files", _id);
            }
            return(42);
        }
예제 #4
0
        protected async override Task <JObject> ExecuteAsync(AsyncCodeActivityContext context)
        {
            var ignoreErrors = IgnoreErrors.Get(context);
            var encrypt      = EncryptFields.Get(context);

            if (encrypt == null)
            {
                encrypt = "";
            }
            var collection = Collection.Get(context);

            if (string.IsNullOrEmpty(collection))
            {
                collection = "entities";
            }
            var     type   = Type.Get(context);
            JObject result = null;
            var     o      = Item.Get(context);

            if (o.GetType() != typeof(JObject))
            {
                var t = Task.Factory.StartNew(() =>
                {
                    result = JObject.FromObject(o);
                });
                t.Wait();
            }
            else
            {
                result = (JObject)o;
            }

            if (!string.IsNullOrEmpty(encrypt))
            {
                result["_encrypt"] = encrypt;
            }
            var name = result.GetValue("name", StringComparison.OrdinalIgnoreCase)?.Value <string>();

            result["name"] = name;
            if (!string.IsNullOrEmpty(type))
            {
                result["_type"] = type;
            }
            var id = result.GetValue("_id");

            if (id != null)
            {
                var _id = id.ToString();
                result = await global.webSocketClient.UpdateOne(collection, 1, false, result);
            }
            else
            {
                result = await global.webSocketClient.InsertOne(collection, 1, false, result);
            }
            System.Windows.Forms.Application.DoEvents();
            return(result);
        }
예제 #5
0
        protected async override Task <JObject[]> ExecuteAsync(AsyncCodeActivityContext context)
        {
            var ignoreErrors = IgnoreErrors.Get(context);
            var encrypt      = EncryptFields.Get(context);

            if (encrypt == null)
            {
                encrypt = "";
            }
            var collection = Collection.Get(context);

            if (string.IsNullOrEmpty(collection))
            {
                collection = "entities";
            }
            var type       = Type.Get(context);
            var uniqueness = Uniqueness.Get(context);
            // JObject[] result = null;
            var results = new List <JObject>();
            var items   = Items.Get(context);

            foreach (var o in items)
            {
                JObject result = null;
                if (o.GetType() != typeof(JObject))
                {
                    var t = Task.Factory.StartNew(() =>
                    {
                        result = JObject.FromObject(o);
                    });
                    t.Wait();
                }
                else
                {
                    result = (JObject)o;
                }

                if (!string.IsNullOrEmpty(encrypt))
                {
                    result["_encrypt"] = encrypt;
                }
                var name = result.GetValue("name", StringComparison.OrdinalIgnoreCase)?.Value <string>();
                result["name"] = name;
                if (!string.IsNullOrEmpty(type))
                {
                    result["_type"] = type;
                }
                results.Add(result);
            }

            var _result = await global.webSocketClient.InsertOrUpdateMany(collection, 1, false, uniqueness, SkipResult.Get(context), results.ToArray());

            System.Windows.Forms.Application.DoEvents();
            return(_result);
        }
예제 #6
0
파일: Query.cs 프로젝트: zergmk2/openrpa
        protected async override Task <JObject[]> ExecuteAsync(AsyncCodeActivityContext context)
        {
            var ignoreErrors = IgnoreErrors.Get(context);
            var collection   = Collection.Get(context);
            var querystring  = QueryString.Get(context);

            if (string.IsNullOrEmpty(collection))
            {
                collection = "entities";
            }
            JObject[] result = null;
            result = await global.webSocketClient.Query <JObject>(collection, querystring);

            System.Windows.Forms.Application.DoEvents();
            return(result);
        }
예제 #7
0
파일: DeleteOne.cs 프로젝트: mdda/openrpa
        protected async override Task <bool> ExecuteAsync(AsyncCodeActivityContext context)
        {
            var ignoreErrors = IgnoreErrors.Get(context);
            var collection   = Collection.Get(context);

            if (string.IsNullOrEmpty(collection))
            {
                collection = "entities";
            }
            JObject result = null;
            var     o      = Item.Get(context);
            string  id     = null;

            if (o != null)
            {
                if (o.GetType() != typeof(JObject))
                {
                    var t = Task.Factory.StartNew(() =>
                    {
                        result = JObject.FromObject(o);
                    });
                    t.Wait();
                }
                else
                {
                    result = (JObject)o;
                }
                var tempid = result.GetValue("_id");
                if (tempid != null)
                {
                    id = tempid.ToString();
                }
                if (string.IsNullOrEmpty(id))
                {
                    throw new Exception("object has no _id field");
                }
            }
            else
            {
                id = _id.Get(context);
            }
            await global.webSocketClient.DeleteOne(collection, id);

            System.Windows.Forms.Application.DoEvents();
            return(true);
        }