public override int GetHashCode() { unchecked { return((Text.GetHashCode() * 397) ^ CaseSensitive.GetHashCode() ^ ColumnFilters.GetHashCode()); } }
protected override void Execute(CodeActivityContext executionContext) { ITracingService tracer = executionContext.GetExtension <ITracingService>(); try { string stringToSearch = StringToSearch.Get(executionContext); string searchFor = SearchFor.Get(executionContext); bool caseSensitive = CaseSensitive.Get(executionContext); if (!caseSensitive) { stringToSearch = stringToSearch.ToUpper(); searchFor = searchFor.ToUpper(); } bool containsString = stringToSearch.Contains(searchFor); ContainsString.Set(executionContext, containsString); } catch (Exception ex) { tracer.Trace("Exception: {0}", ex.ToString()); } }
protected override void ExecuteCrmWorkFlowActivity(CodeActivityContext context, LocalWorkflowContext localContext) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (localContext == null) { throw new ArgumentNullException(nameof(localContext)); } string stringToSearch = StringToSearch.Get(context); string searchFor = SearchFor.Get(context); bool caseSensitive = CaseSensitive.Get(context); if (!caseSensitive) { stringToSearch = stringToSearch.ToUpper(); searchFor = searchFor.ToUpper(); } bool containsString = stringToSearch.Contains(searchFor); ContainsString.Set(context, containsString); }
public override int GetHashCode() { unchecked { int hashCode = 13; hashCode = (hashCode * 17) ^ TypeOfFileSearch.GetHashCode(); hashCode = (hashCode * 17) ^ FilePattern?.GetHashCode() ?? 5; hashCode = (hashCode * 17) ^ IgnoreFilePattern?.GetHashCode() ?? 5; hashCode = (hashCode * 17) ^ TypeOfSearch.GetHashCode(); hashCode = (hashCode * 17) ^ SearchFor?.GetHashCode() ?? 5; hashCode = (hashCode * 17) ^ ReplaceWith?.GetHashCode() ?? 5; hashCode = (hashCode * 17) ^ CaseSensitive.GetHashCode(); hashCode = (hashCode * 17) ^ WholeWord.GetHashCode(); hashCode = (hashCode * 17) ^ Multiline.GetHashCode(); hashCode = (hashCode * 17) ^ Singleline.GetHashCode(); hashCode = (hashCode * 17) ^ BooleanOperators.GetHashCode(); hashCode = (hashCode * 17) ^ IncludeSubfolders.GetHashCode(); hashCode = (hashCode * 17) ^ IncludeHidden.GetHashCode(); hashCode = (hashCode * 17) ^ IncludeBinary.GetHashCode(); hashCode = (hashCode * 17) ^ MaxSubfolderDepth.GetHashCode(); hashCode = (hashCode * 17) ^ UseGitignore.GetHashCode(); hashCode = (hashCode * 17) ^ SkipRemoteCloudStorageFiles.GetHashCode(); hashCode = (hashCode * 17) ^ IncludeArchive.GetHashCode(); hashCode = (hashCode * 17) ^ FollowSymlinks.GetHashCode(); hashCode = (hashCode * 17) ^ CodePage.GetHashCode(); hashCode = (hashCode * 17) ^ ApplyFileSourceFilters.GetHashCode(); hashCode = (hashCode * 17) ^ ApplyFilePropertyFilters.GetHashCode(); hashCode = (hashCode * 17) ^ ApplyContentSearchFilters.GetHashCode(); return(hashCode); } }
protected override void StartLoop(NativeActivityContext context) { // var match = Element.Get(context); var wordlimit = WordLimit.Get(context); var lang = Config.local.ocrlanguage; var casesensitive = CaseSensitive.Get(context); string basepath = Interfaces.Extensions.DataDirectory; string path = System.IO.Path.Combine(basepath, "tessdata"); ocr.TesseractDownloadLangFile(path, Config.local.ocrlanguage); ocr.TesseractDownloadLangFile(path, "osd"); var ele = Element.Get(context); // ele.element.Save(@"c:\temp\dump.png", System.Drawing.Imaging.ImageFormat.Png); // var result = ocr.GetTextcomponents(path, Config.local.ocrlanguage, ele.element); // var result = ocr.GetTextcomponents(path, Config.local.ocrlanguage, @"c:\temp\dump.png"); 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()); } context.SetValue(Result, result); IEnumerator <ImageElement> _enum = result.ToList().GetEnumerator(); context.SetValue(_elements, _enum); bool more = _enum.MoveNext(); if (more) { IncIndex(context); SetTotal(context, result.Length); context.ScheduleAction(Body, _enum.Current, OnBodyComplete); } }
protected override void Execute(CodeActivityContext executionContext) { var text = Text.Get <string>(executionContext); var old = Old.Get <string>(executionContext); var @new = New.Get <string>(executionContext); if (@new == null) { @new = String.Empty; } var result = string.Empty; if (!CaseSensitive.Get <bool>(executionContext)) { if (!String.IsNullOrEmpty(text) && !String.IsNullOrEmpty(old)) { result = text.Replace(old, @new); } } else { result = CompareAndReplace(text, old, @new, StringComparison.CurrentCultureIgnoreCase); } Result.Set(executionContext, result); }
public override int GetHashCode() { unchecked { int hashCode = 13; hashCode = (hashCode * 17) ^ TypeOfFileSearch.GetHashCode(); hashCode = (hashCode * 17) ^ FileNames?.GetHashCode() ?? 5; hashCode = (hashCode * 17) ^ IgnoreFilePattern?.GetHashCode() ?? 5; hashCode = (hashCode * 17) ^ TypeOfSearch.GetHashCode(); hashCode = (hashCode * 17) ^ SearchPattern?.GetHashCode() ?? 5; hashCode = (hashCode * 17) ^ ReplacePattern?.GetHashCode() ?? 5; hashCode = (hashCode * 17) ^ CaseSensitive.GetHashCode(); hashCode = (hashCode * 17) ^ WholeWord.GetHashCode(); hashCode = (hashCode * 17) ^ Multiline.GetHashCode(); hashCode = (hashCode * 17) ^ Singleline.GetHashCode(); hashCode = (hashCode * 17) ^ BooleanOperators.GetHashCode(); hashCode = (hashCode * 17) ^ IncludeSubfolders.GetHashCode(); hashCode = (hashCode * 17) ^ IncludeHiddenFiles.GetHashCode(); hashCode = (hashCode * 17) ^ IncludeBinaryFiles.GetHashCode(); hashCode = (hashCode * 17) ^ MaxSubfolderDepth.GetHashCode(); hashCode = (hashCode * 17) ^ UseGitignore.GetHashCode(); hashCode = (hashCode * 17) ^ IncludeArchive.GetHashCode(); hashCode = (hashCode * 17) ^ FollowSymlinks.GetHashCode(); hashCode = (hashCode * 17) ^ CodePage.GetHashCode(); return(hashCode); } }
public Dictionary <string, string> ExportSettings(bool suppressWarnings) { Dictionary <string, string> SettingsDict = new Dictionary <string, string>(); SettingsDict.Add("WordList", WordList); SettingsDict.Add("WordWindowLeft", WordWindowLeft.ToString()); SettingsDict.Add("WordWindowRight", WordWindowRight.ToString()); SettingsDict.Add("CaseSensitive", CaseSensitive.ToString()); return(SettingsDict); }
public override int GetHashCode() { unchecked { int result = Text == null ? 0 : Text.GetHashCode(); result = (result * 397) ^ CaseSensitive.GetHashCode(); result = (result * 397) ^ ColumnFilters.GetHashCode(); result = (result * 397) ^ ColumnSorts.GetHashCode(); return(result); } }
/// <inheritdoc /> protected override void Execute(Context context) { var settings = new StringComparisonSettings { CaseSensitive = CaseSensitive.Get(context), AccentSensitive = AccentSensitive.Get(context) }; var result = StringComparisons.JaroWinklerDistance(String1.Get(context), String2.Get(context), settings); Result.Set(context, (int)Math.Round(result * 100)); }
public override int GetHashCode() { unchecked { var hashCode = (Name != null ? Name.GetHashCode() : 0); hashCode = (hashCode * 397) ^ ColumnOrdinal; hashCode = (hashCode * 397) ^ (DataTypeName != null ? DataTypeName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ PrimaryKey.GetHashCode(); hashCode = (hashCode * 397) ^ Generated.GetHashCode(); hashCode = (hashCode * 397) ^ CaseSensitive.GetHashCode(); return(hashCode); } }
/// <summary> /// Serves as a hash function for a particular type. /// </summary> /// <returns> /// A hash code for the current <see cref = "T:System.Object" />. /// </returns> /// <filterpriority>2</filterpriority> public override int GetHashCode() { unchecked { int result = FilterType.GetHashCode(); result = (result * 397) ^ ApplyToFileName.GetHashCode(); result = (result * 397) ^ ApplyToPath.GetHashCode(); result = (result * 397) ^ ApplyToFile.GetHashCode(); result = (result * 397) ^ ApplyToDirectory.GetHashCode(); result = (result * 397) ^ CaseSensitive.GetHashCode(); result = (result * 397) ^ (_text != null ? _text.GetHashCode() : 0); return(result); } }
public Type FindWrapperType(string path) { var key = string.Join( "/", path.Split(new[] { '/' }) .Where(s => !string.IsNullOrEmpty(s)) ); if (!CaseInsensitive.TryGetValue(key, out var wrapperType)) { CaseSensitive.TryGetValue(key, out wrapperType); } return(wrapperType); }
private int GetSearchHash() { unchecked { int hashCode = 13; hashCode = (hashCode * 397) ^ SampleText?.GetHashCode() ?? 5; hashCode = (hashCode * 397) ^ SearchFor?.GetHashCode() ?? 5; hashCode = (hashCode * 397) ^ TypeOfSearch.GetHashCode(); hashCode = (hashCode * 397) ^ CaseSensitive.GetHashCode(); hashCode = (hashCode * 397) ^ WholeWord.GetHashCode(); hashCode = (hashCode * 397) ^ Multiline.GetHashCode(); hashCode = (hashCode * 397) ^ Singleline.GetHashCode(); hashCode = (hashCode * 397) ^ BooleanOperators.GetHashCode(); hashCode = (hashCode * 397) ^ HighlightCaptureGroups.GetHashCode(); return(hashCode); } }
protected override void Execute(CodeActivityContext executionContext) { try { string stringToSearch = StringToSearch.Get(executionContext); string searchFor = SearchFor.Get(executionContext); bool caseSensitive = CaseSensitive.Get(executionContext); bool startsWithString = stringToSearch.StartsWith(searchFor, (caseSensitive) ? StringComparison.CurrentCulture : StringComparison.CurrentCultureIgnoreCase); StartsWithString.Set(executionContext, startsWithString); } catch (Exception e) { throw new InvalidPluginExecutionException(e.Message); } }
protected override void Execute(CodeActivityContext executionContext) { ITracingService tracer = executionContext.GetExtension <ITracingService>(); try { string stringToSearch = StringToSearch.Get(executionContext); string searchFor = SearchFor.Get(executionContext); bool caseSensitive = CaseSensitive.Get(executionContext); bool endsWithString = stringToSearch.EndsWith(searchFor, (caseSensitive) ? StringComparison.CurrentCulture : StringComparison.CurrentCultureIgnoreCase); EndsWithString.Set(executionContext, endsWithString); } catch (Exception ex) { tracer.Trace("Exception: {0}", ex.ToString()); } }
protected override void ExecuteCrmWorkFlowActivity(CodeActivityContext context, LocalWorkflowContext localContext) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (localContext == null) { throw new ArgumentNullException(nameof(localContext)); } string stringToSearch = StringToSearch.Get(context); string searchFor = SearchFor.Get(context); bool caseSensitive = CaseSensitive.Get(context); bool endsWithString = stringToSearch.EndsWith(searchFor, (caseSensitive) ? StringComparison.CurrentCulture : StringComparison.CurrentCultureIgnoreCase); EndsWithString.Set(context, endsWithString); }
public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("{"); sb.Append("TableName="); sb.Append(TableName); sb.Append(",CaseSensitive="); sb.Append(CaseSensitive.ToString()); sb.Append(",Columns=["); if (Columns != null && Columns.Length > 0) { sb.Append(Columns[0]); for (int i = 1; i < Columns.Length; i++) { sb.Append(","); sb.Append(Columns[i].ToString()); } } sb.Append("],PrimaryKey=["); if (PrimaryKey != null && PrimaryKey.Length > 0) { sb.Append(PrimaryKey[0]); for (int i = 1; i < PrimaryKey.Length; i++) { sb.Append(PrimaryKey[i]); } } sb.Append("],Rows=["); if (Rows != null && Rows.Length > 0) { sb.Append(Rows[0].ToString()); for (int i = 1; i < Rows.Length; i++) { sb.Append(","); sb.Append(Rows[i].ToString()); } } sb.Append("]"); OnWriteToStringContent(sb); sb.Append("}"); return(sb.ToString()); }
protected override void Execute(CodeActivityContext executionContext) { #region "Load CRM Service from context" Common objCommon = new Common(executionContext); objCommon.tracingService.Trace("Load CRM Service from context --- OK"); #endregion #region "Read Parameters" String inputText = this.InputText.Get(executionContext); bool capitalizeAllWords = this.CapitalizeAllWords.Get(executionContext); string padCharacter = this.PadCharacter.Get(executionContext); bool padontheLeft = this.PadontheLeft.Get(executionContext); int finalLengthwithPadding = this.FinalLengthwithPadding.Get(executionContext); string replaceOldValue = this.ReplaceOldValue.Get(executionContext); string replaceNewValue = this.ReplaceNewValue.Get(executionContext); if (replaceNewValue == null) { replaceNewValue = ""; } bool caseSensitive = this.CaseSensitive.Get(executionContext); bool fromLefttoRight = this.FromLefttoRight.Get(executionContext); int startIndex = this.StartIndex.Get(executionContext); int subStringLength = this.SubStringLength.Get(executionContext); string regularExpression = this.RegularExpression.Get(executionContext); #endregion string capitalizedText = ""; if (capitalizeAllWords) { // All words capitalizedText = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(inputText); } else { // First Letter only capitalizedText = inputText.Substring(0, 1).ToUpper() + inputText.Substring(1); } //padding string paddedText = ""; if (padCharacter == "") { padCharacter = " "; } if (padontheLeft) { paddedText = inputText.PadLeft(finalLengthwithPadding, padCharacter.ToCharArray()[0]); } else { paddedText = inputText.PadRight(finalLengthwithPadding, padCharacter.ToCharArray()[0]); } //replace string string replacedText = ""; if (!CaseSensitive.Get <bool>(executionContext)) { if (!String.IsNullOrEmpty(inputText) && !String.IsNullOrEmpty(replaceOldValue)) { replacedText = inputText.Replace(replaceOldValue, replaceNewValue); } } else { replacedText = CompareAndReplace(inputText, replaceOldValue, replaceNewValue, StringComparison.CurrentCultureIgnoreCase); } //substring string subStringText = ""; if (subStringLength <= 0 || startIndex < 0) { subStringText = String.Empty; } else { if (!fromLefttoRight) { startIndex = inputText.Length - subStringLength - startIndex; } subStringText = inputText.Substring(startIndex, subStringLength); } //regex string regexText = ""; bool regexSuccess = false; if (regularExpression != "") { Regex regex = new Regex(regularExpression); Match match = regex.Match(inputText); if (match.Success) { regexSuccess = true; regexText = match.Value; } } this.CapitalizedText.Set(executionContext, capitalizedText); this.TextLength.Set(executionContext, capitalizedText.Length); this.PaddedText.Set(executionContext, paddedText); this.ReplacedText.Set(executionContext, replacedText); this.SubstringText.Set(executionContext, subStringText); this.TrimmedText.Set(executionContext, inputText.Trim()); this.RegexSuccess.Set(executionContext, regexSuccess); this.RegexText.Set(executionContext, regexText); }
public void removeFromArray(string category, string key, string value, CaseSensitive isCS = CaseSensitive.YES) { RemoveAllFromArray(File, category, key, value, isCS); }
/******************** * Remove string from string array ********************/ public static void RemoveFromArray(string iniFile, string category, string key, string value, CaseSensitive isCS = CaseSensitive.YES) { string[] values = GetStringArray(iniFile, category, key, ""); string[] newValue = new string[values.Length]; int j = 0; bool found = false; for (int i = 0; i < values.Length; i++) { if ((isCS == CaseSensitive.NO && !values[i].ToUpper().Equals(value.ToUpper()) && !values[i].Equals("")) || found) { newValue[j] += values[i]; j++; } else if (isCS == CaseSensitive.YES && !values[i].Equals(value) && !values[i].Equals("")) { newValue[j] += values[i]; j++; } else { found = true; } } string[] result = new string[j]; for (int i = 0; i < j; i++) { result[i] = newValue[i]; } Write(iniFile, category, key, result); }
// Module defining this command // Optional custom code for this activity /// <summary> /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run. /// </summary> /// <param name="context">The NativeActivityContext for the currently running activity.</param> /// <returns>A populated instance of System.Management.Automation.PowerShell</returns> /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks> protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context) { System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create(); System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName); // Initialize the arguments if (InputObject.Expression != null) { targetCommand.AddParameter("InputObject", InputObject.Get(context)); } if (Pattern.Expression != null) { targetCommand.AddParameter("Pattern", Pattern.Get(context)); } if (Path.Expression != null) { targetCommand.AddParameter("Path", Path.Get(context)); } if (LiteralPath.Expression != null) { targetCommand.AddParameter("LiteralPath", LiteralPath.Get(context)); } if (SimpleMatch.Expression != null) { targetCommand.AddParameter("SimpleMatch", SimpleMatch.Get(context)); } if (CaseSensitive.Expression != null) { targetCommand.AddParameter("CaseSensitive", CaseSensitive.Get(context)); } if (Quiet.Expression != null) { targetCommand.AddParameter("Quiet", Quiet.Get(context)); } if (List.Expression != null) { targetCommand.AddParameter("List", List.Get(context)); } if (Include.Expression != null) { targetCommand.AddParameter("Include", Include.Get(context)); } if (Exclude.Expression != null) { targetCommand.AddParameter("Exclude", Exclude.Get(context)); } if (NotMatch.Expression != null) { targetCommand.AddParameter("NotMatch", NotMatch.Get(context)); } if (AllMatches.Expression != null) { targetCommand.AddParameter("AllMatches", AllMatches.Get(context)); } if (Encoding.Expression != null) { targetCommand.AddParameter("Encoding", Encoding.Get(context)); } if (Context.Expression != null) { targetCommand.AddParameter("Context", Context.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
protected override void Execute(NativeActivityContext context) { // var match = Element.Get(context); var wordlimit = WordLimit.Get(context); var lang = Config.local.ocrlanguage; var casesensitive = CaseSensitive.Get(context); var isfrontside = IsFrontSide.Get(context); string basepath = Interfaces.Extensions.DataDirectory; string path = System.IO.Path.Combine(basepath, "tessdata"); //ocr.TesseractDownloadLangFile(path, Config.local.ocrlanguage); //ocr.TesseractDownloadLangFile(path, "osd"); var ele = Element.Get(context); // ele.element.Save(@"c:\temp\dump.png", System.Drawing.Imaging.ImageFormat.Png); // var result = ocr.GetIdTextcomponents(path, Config.local.ocrlanguage, ele.element); // var result = ocr.GetIdTextcomponents(path, Config.local.ocrlanguage, @"c:\temp\dump.png"); ImageElement[] result; // 百度OCR var _ocr = new Baidu.Aip.Ocr.Ocr(ocr.API_KEY, ocr.SECRET_KEY); _ocr.Timeout = 60000;//设置超时时间 //_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); } 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); context.SetValue(Result, word_results["words_result"]); var image_status = word_results["image_status"].ToString(); context.SetValue(OcrStatus, image_status); //IEnumerator<ImageElement> _enum = result.ToList().GetEnumerator(); //context.SetValue(_elements, _enum); //bool more = _enum.MoveNext(); //if (more) //{ // context.ScheduleAction(Body, _enum.Current, OnBodyComplete); //} }
public override string ToString() => CaseSensitive .Forward(c => c ? string.Empty : " (case insensitive)") .Forward(c => $"New line after {Occurences} {Text}'s{c}");