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; } }
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); }
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); }
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); }
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); }
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); }
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); }