public static void SetValue <T>(this System.Activities.Presentation.Model.ModelItem model, string name, T value) { if (model.Properties[name] != null) { model.Properties[name].SetValue(value); } }
public static void SetValueInArg <T>(this System.Activities.Presentation.Model.ModelItem model, string name, T value) { model.SetValue(name, new System.Activities.InArgument <T>() { Expression = new System.Activities.Expressions.Literal <T>(value) }); }
public static T GetValue <T>(this System.Activities.Presentation.Model.ModelItem model, string name) { T result = default(T); if (model.Properties[name] != null) { if (model.Properties[name].Value == null) { return(result); } if (model.Properties[name].Value.Properties["Expression"] != null) { result = model.Properties[name].Value.Properties["Expression"].ComputedValue.TryCast <T>(); if (result == null) { var outresult = model.Properties[name].Value.Properties["Expression"].ComputedValue.TryCast <VisualBasicReference <T> >(); result = outresult.ExpressionText.TryCast <T>(); } if (result == null) { var inresult = model.Properties["Value"].Value.Properties["Expression"].ComputedValue.TryCast <System.Activities.Expressions.Literal <T> >(); result = inresult.Value.TryCast <T>(); } return(result); } result = model.Properties[name].ComputedValue.TryCast <T>(); return(result); } return(result); }
public void SetModelItemMSDeployExecutionTypeValue(System.Activities.Presentation.Model.ModelItem modelItem, string modelItemPropertyName, MSDeployExecutionType value) { var newExpression = new Microsoft.VisualBasic.Activities.VisualBasicValue <MSDeployExecutionType>(typeof(MSDeployExecutionType).FullName + "." + value.ToString()); var newValue = new InArgument <MSDeployExecutionType>(newExpression); modelItem.Properties[modelItemPropertyName].SetValue(newValue); }
public static void SetValueOutArg <T>(this System.Activities.Presentation.Model.ModelItem model, string name, string value) { model.SetValue(name, new System.Activities.OutArgument <T>() { Expression = new Microsoft.VisualBasic.Activities.VisualBasicReference <T>(value) }); // model.SetValue(name, new System.Activities.OutArgument<T>() { Expression = new Microsoft.VisualBasic.Activities.VisualBasicValue<T>(value) }); }
public void AddKey(vKey _key, System.Activities.Presentation.Model.ModelItem lastinsertedmodel) { if (_keys == null) { _keys = new List <vKey>(); } _keys.Add(_key); result = ""; for (var i = 0; i < _keys.Count; i++) { string val = ""; var key = _keys[i]; if (key.up == false && (i + 1) < _keys.Count) { if (key.KeyCode == _keys[i + 1].KeyCode && _keys[i + 1].up) { i++; val = "{" + key.KeyCode.ToString() + "}"; if (key.KeyCode.ToString().StartsWith("KEY_")) { val = key.KeyCode.ToString().Substring(4).ToLower(); } if (key.KeyCode == FlaUI.Core.WindowsAPI.VirtualKeyShort.SPACE) { val = " "; } } } if (string.IsNullOrEmpty(val)) { if (key.up == false) { val = "{" + key.KeyCode.ToString() + " down}"; } else { val = "{" + key.KeyCode.ToString() + " up}"; } } result += val; } //Text = result; if (result == null) { result = ""; } if (lastinsertedmodel != null) { lastinsertedmodel.Properties["Text"].SetValue(new InArgument <string>(result)); } }
public static Newtonsoft.Json.Linq.JObject Execute(IElement ele, System.Activities.Presentation.Model.ModelItem model) { var wordlimit = model.GetValue <string>("WordLimit"); var casesensitive = model.GetValue <bool>("CaseSensitive"); var isfrontside = model.GetValue <bool>("IsFrontSide"); var lang = Config.local.ocrlanguage; string basepath = Interfaces.Extensions.DataDirectory; ImageElement[] result = null; var _ocr = new Baidu.Aip.Ocr.Ocr(ocr.API_KEY, ocr.SECRET_KEY); _ocr.Timeout = 60000;//设置超时时间 // OpenRPA.Interfaces.Image.Util.SaveImageStamped(ele.element, "OCR"); Bitmap sourceimg = null; if (ele is ImageElement) { sourceimg = ((ImageElement)ele).element; } else { sourceimg = Interfaces.Image.Util.Screenshot(ele.Rectangle.X, ele.Rectangle.Y, ele.Rectangle.Width, ele.Rectangle.Height); } String idCardSide; if (isfrontside) { idCardSide = "front"; } else { idCardSide = "back"; } MemoryStream ms = new MemoryStream(); sourceimg.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp); byte[] imageBytes = ms.GetBuffer(); ms.Close(); var word_results = _ocr.Idcard(imageBytes, idCardSide); Log.Debug("adding element cords to results: " + word_results); return(word_results); }
public static ImageElement[] Execute(IElement ele, System.Activities.Presentation.Model.ModelItem model) { var wordlimit = model.GetValue <string>("WordLimit"); var casesensitive = model.GetValue <bool>("CaseSensitive"); var lang = Config.local.ocrlanguage; string basepath = Interfaces.Extensions.DataDirectory; string path = System.IO.Path.Combine(basepath, "tessdata"); ocr.TesseractDownloadLangFile(path, Config.local.ocrlanguage); ocr.TesseractDownloadLangFile(path, "osd"); ImageElement[] result; var _ocr = new Emgu.CV.OCR.Tesseract(path, lang.ToString(), Emgu.CV.OCR.OcrEngineMode.TesseractLstmCombined); _ocr.Init(path, lang.ToString(), Emgu.CV.OCR.OcrEngineMode.TesseractLstmCombined); _ocr.PageSegMode = Emgu.CV.OCR.PageSegMode.SparseText; // OpenRPA.Interfaces.Image.Util.SaveImageStamped(ele.element, "OCR"); Bitmap sourceimg = null; if (ele is ImageElement) { sourceimg = ((ImageElement)ele).element; } else { sourceimg = Interfaces.Image.Util.Screenshot(ele.Rectangle.X, ele.Rectangle.Y, ele.Rectangle.Width, ele.Rectangle.Height); } using (var img = new Emgu.CV.Image <Emgu.CV.Structure.Bgr, byte>(sourceimg)) { result = ocr.OcrImage2(_ocr, img.Mat, wordlimit, casesensitive); } Log.Debug("adding element cords to results: " + ele.Rectangle.ToString()); foreach (var R in result) { var rect = new System.Drawing.Rectangle(R.Rectangle.X + ele.Rectangle.X, R.Rectangle.Y + ele.Rectangle.Y, R.Rectangle.Width, R.Rectangle.Height); R.Rectangle = rect; Log.Debug("Found: '" + R.Text + "' at " + R.Rectangle.ToString()); } return(result); }
public static T GetValue <T>(this System.Activities.Presentation.Model.ModelItem model, string name) { T result = default; if (model.Properties[name] != null) { if (model.Properties[name].Value == null) { return(result); } if (model.Properties[name].Value.Properties["Expression"] != null) { result = model.Properties[name].Value.Properties["Expression"].ComputedValue.TryCast <T>(); return(result); } result = model.Properties[name].ComputedValue.TryCast <T>(); return(result); } return(result); }
public MSDeployExecutionType?GetModelItemMSDeployExecutionTypeValue(System.Activities.Presentation.Model.ModelItem modelItem, string modelItemPropertyName) { if (modelItem.Properties[modelItemPropertyName] != null && modelItem.Properties[modelItemPropertyName].Value != null) { var currentValue = modelItem.Properties[modelItemPropertyName].Value.GetCurrentValue(); if (currentValue is InArgument <MSDeployExecutionType> && ((InArgument <MSDeployExecutionType>)currentValue).Expression is VisualBasicValue <MSDeployExecutionType> ) { string expressionText = ((VisualBasicValue <MSDeployExecutionType>)((InArgument <MSDeployExecutionType>)currentValue).Expression).ExpressionText; //Enum.Parse doesn't like this if (expressionText == string.Format("{0}.{1}", typeof(MSDeployExecutionType).FullName, MSDeployExecutionType.Cmd.ToString())) { return(MSDeployExecutionType.Cmd); } else if (expressionText == string.Format("{0}.{1}", typeof(MSDeployExecutionType).FullName, MSDeployExecutionType.Exe.ToString())) { return(MSDeployExecutionType.Exe); } } } return(null); }