protected override async Task <Action <AsyncCodeActivityContext> > ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken)
        {
            // Inputs
            var string1 = String1.Get(context);
            var string2 = String2.Get(context);

            double in_percent = new double();
            string a          = string1;
            string b          = string2;

            char[] turkishChars = { 'ý', 'ð', 'Ý', 'Ð', 'ç', 'Ç', 'þ', 'Þ', 'ö', 'Ö', 'ü', 'Ü' };
            char[] englishChars = { 'i', 'g', 'I', 'G', 'c', 'C', 's', 'S', 'o', 'O', 'u', 'U' };
            // Match char
            for (int i = 0; i < turkishChars.Length; i++)
            {
                a = a.Replace(turkishChars[i], englishChars[i]);
                b = b.Replace(turkishChars[i], englishChars[i]);
            }
            a = a.ToLower().ToUpper();
            b = b.ToLower().ToUpper();



            if (string.IsNullOrEmpty(a))
            {
                in_percent = b.Length;
            }
            if (string.IsNullOrEmpty(b))
            {
                in_percent = a.Length;
            }
            int lengthA   = a.Length;
            int lengthB   = b.Length;
            var distances = new int[lengthA + 1, lengthB + 1];

            for (int i = 0; i <= lengthA; distances[i, 0] = i++)
            {
                ;
            }
            for (int j = 0; j <= lengthB; distances[0, j] = j++)
            {
                ;
            }
            for (int i = 1; i <= lengthA; i++)
            {
                for (int j = 1; j <= lengthB; j++)
                {
                    int cost = b[j - 1] == a[i - 1] ? 0 : 1;
                    distances[i, j] = Math.Min(Math.Min(distances[i - 1, j] + 1, distances[i, j - 1] + 1), distances[i - 1, j - 1] + cost);
                }
                in_percent = distances[lengthA, lengthB];
                in_percent = (1.0 - ((double)in_percent / (double)Math.Max(a.Length, b.Length))) * 100;
            }

            // Outputs
            return((ctx) => {
                Percentage.Set(ctx, in_percent);
            });
        }
        protected override void Execute(CodeActivityContext context)
        {
            string string1 = String1.Get(context);
            string string2 = String2.Get(context);

            Int32 result = FuzzySharp.Fuzz.Ratio(string1, string2);

            Result.Set(context, result);
        }
Beispiel #3
0
        /// <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));
        }
Beispiel #4
0
        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 string1 = String1.Get(context);
            string string2 = String2.Get(context);
            string joiner  = Joiner.Get(context);

            string joinedString = string.Join(joiner, string1, string2);

            JoinedString.Set(context, joinedString);
        }
Beispiel #5
0
        protected override void Execute(CodeActivityContext executionContext)
        {
            ITracingService tracer = executionContext.GetExtension <ITracingService>();

            try
            {
                string string1 = String1.Get(executionContext);
                string string2 = String2.Get(executionContext);
                string joiner  = Joiner.Get(executionContext);

                string joinedString = System.String.Join(joiner, string1, string2);

                JoinedString.Set(executionContext, joinedString);
            }
            catch (Exception ex)
            {
                tracer.Trace("Exception: {0}", ex.ToString());
            }
        }