Esempio n. 1
0
        private void Initialize(OperandType operandType, Type type, Type dataType, Int32 length, string xmlPath, PropertyInfo propertyInstance, ComparisonMethod comparisonMethod, object value,
                                bool isSelect, Expression expression)
        {
            // need to do a check there if it is a expression
            if (expression == Expression.None)
            {
                if (type == null)
                {
                    throw new ApplicationException("Could not initialize selection criterion; type is null!");
                }
                if (propertyInstance == null)
                {
                    throw new ApplicationException(string.Format("Could not initialize selection criterion; property ({0}) does not exist!", m_OriginalPropertyName));
                }
            }

            m_Type             = type;
            m_DataType         = dataType;
            m_Length           = length;
            m_XmlPath          = xmlPath;
            m_OperandType      = operandType;
            m_Property         = propertyInstance;
            m_ComparisonMethod = comparisonMethod;
            if (isSelect && value is string)
            {
                value = (value as string).Replace("'", "''");
            }
            m_Value      = value;
            m_Expression = expression;
        }
Esempio n. 2
0
        /// <summary>
        /// Calculates the ΔE of two colors, using the specified comparison method.
        /// This value represents the perceptual difference between the two colors.
        /// </summary>
        /// <param name="color1">The first color</param>
        /// <param name="color2">The second color</param>
        /// <param name="method">
        /// The algorith to use for the comparison.
        /// There is an efficiency/accuracy trade-off between the different methods.</param>
        /// <returns>ΔE value representing the perceived difference between the two colors.</returns>
        public static double Compare(ColorSpace color1, ColorSpace color2, ComparisonMethod method = ComparisonMethod.Cie2000)
        {
            if (color1 == null || color2 == null)
            {
                throw new NullReferenceException("Neither color1 or color2 may be null");
            }

            switch (method)
            {
            case ComparisonMethod.Cie1976:
                return(CompareCie1976(color1, color2));

            case ComparisonMethod.Cie1994:
                return(CompareCie1994(color1, color2));

            case ComparisonMethod.Cie2000:
                return(CompareCie2000(color1, color2));

            case ComparisonMethod.Cmc1984:
                return(CompareCmc1984(color1, color2));

            default:
                throw new ArgumentException("Unrecognized comparison method", nameof(method));
            }
        }
Esempio n. 3
0
        /// <summary>
        ///  Compare images
        /// </summary>
        /// <param name="image1"> 1st image</param>
        /// <param name="image2"> 2nd image</param>
        /// <param name="method"> method</param>
        /// <returns>Similarity % )</returns>
        public static double CompareImages(Image image1, Image image2, ComparisonMethod method)
        {
            double sim = 0;

            try
            {
                var mat1 = BitmapConverter.ToMat(new Bitmap(image1));
                var mat2 = BitmapConverter.ToMat(new Bitmap(image2));

                sim = CompareImages(mat1, mat2, method);

                mat1.Dispose();
                mat2.Dispose();
            }
            catch (System.AccessViolationException)
            {
                //Console.Error.WriteLine("Access Error  => CompareImages {0} : \n{1}", method, e);
            }
            catch (OutOfMemoryException)
            {
                //The file does not have a valid image format.
                //-or- GDI+ does not support the pixel format of the file
                //Console.Error.WriteLine("Memory Error  => CompareImages {0} : \n{1}", method, e);
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("Error  => CompareImages {0} : \n{1}", method, e);
            }
            return(sim);
        }
Esempio n. 4
0
        private void IsSolutionOrAssemblyExistingInTargetEnv()
        {
            WorkAsync(new WorkAsyncInfo
            {
                Message = $"Checking if the {ComparisonMethod.Name} name exists in the target environment...",
                Work    = (bw, e) =>
                {
                    e.Result = ComparisonMethod.ExistsInTarget(Controller.DataManager, SolutionAssemblyPluginStepsName);
                },
                PostWorkCallBack = e =>
                {
                    if (e.Error != null)
                    {
                        Log.LogData(EventType.Exception, ComparisonMethod.LogActionOnExistsInTarget, e.Error);
                        MessageBox.Show(this, e.Error.Message, @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    if ((bool)e.Result)
                    {
                        MessageBox.Show($@"The {ComparisonMethod.Name} doesn't exist in the Target environment. \rThe compare function will return a ""Perfect match"" in this case.\r\r You will still have the possibility to copy steps from the Source to Target environment.", @"Information", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                },
                ProgressChanged = e => { SetWorkingMessage(e.UserState.ToString()); }
            });
        }
Esempio n. 5
0
 public WhereCondition(string columnName, ComparisonMethod comparisonMethod, object value, Predicate predicate)
 {
     ColumnName = columnName;
     Comparator = comparisonMethod;
     Value      = value;
     Predicate  = predicate;
 }
Esempio n. 6
0
 public override string ToString()
 {
     return(string.Format("[SelectionCriteria] - Type: {0}, OperandType: {1}, Property: {2}, Comparison: {3}, Value: {4}",
                          (Type != null) ? Type.ToString() : "null",
                          OperandType.ToString(),
                          (Property != null) ? Property.Name : "null",
                          ComparisonMethod.ToString(),
                          (Value != null) ? Value.ToString() : "null"));
 }
		private void CompareWithDump (ComparisonMethod cm, string dump, bool testTrue)
		{
			string testDump = CharCategoryUtils.GenerateDump (cm, testTrue);

//			string filename = Assembly.GetAssembly (typeof (Char)).Location + "/resources/" + dumpfile;
//			StreamReader sr = new StreamReader (filename);
//			dump = sr.ReadToEnd ();
//			sr.Close ();
			Assert.AreEqual (dump, testDump);
		}
Esempio n. 8
0
        /// <summary>
        ///  Compare images
        /// </summary>
        /// <param name="image_name1"> 1st image</param>
        /// <param name="image_name2"> 2nd image</param>
        /// <param name="method"> method</param>
        /// <returns>Similarity % )</returns>
        public static double CompareImages(string image_name1, string image_name2, ComparisonMethod method)
        {
            var image1 = Image.FromFile(image_name1, true);
            var image2 = Image.FromFile(image_name2, true);
            var sim    = CompareImages(image1, image2, method);

            image1.Dispose();
            image2.Dispose();

            return(sim);
        }
Esempio n. 9
0
        /// <summary>
        /// Evaluates the named count against the value using the comparison specified
        /// </summary>
        /// <param name="name"></param>
        /// <param name="value"></param>
        /// <param name="method"></param>
        /// <param name="modifier"></param>
        /// <returns></returns>
        public static bool EvaluateCountCondition(string name, int value, ComparisonMethod method, ComparisonModifier modifier)
        {
            var currentCount = ProfileCountProvider.Instance.GetCount(name);
            var result =
                (method.HasFlag(ComparisonMethod.Equal) && currentCount == value) ||
                (method.HasFlag(ComparisonMethod.GreaterThan) && currentCount > value) ||
                (method.HasFlag(ComparisonMethod.GreaterThanOrEqual) && currentCount >= value) ||
                (method.HasFlag(ComparisonMethod.LessThan) && currentCount < value) ||
                (method.HasFlag(ComparisonMethod.LessThanOrEqual) && currentCount <= value);

            return modifier == ComparisonModifier.Not ? !result : result;
        }
Esempio n. 10
0
        /// <summary>
        /// Evaluates the named count against the value using the comparison specified
        /// </summary>
        /// <param name="name"></param>
        /// <param name="value"></param>
        /// <param name="method"></param>
        /// <param name="modifier"></param>
        /// <returns></returns>
        public static bool EvaluateCountCondition(string name, int value, ComparisonMethod method, ComparisonModifier modifier)
        {
            var currentCount = ProfileCountProvider.Instance.GetCount(name);
            var result       =
                (method.HasFlag(ComparisonMethod.Equal) && currentCount == value) ||
                (method.HasFlag(ComparisonMethod.GreaterThan) && currentCount > value) ||
                (method.HasFlag(ComparisonMethod.GreaterThanOrEqual) && currentCount >= value) ||
                (method.HasFlag(ComparisonMethod.LessThan) && currentCount < value) ||
                (method.HasFlag(ComparisonMethod.LessThanOrEqual) && currentCount <= value);

            return(modifier == ComparisonModifier.Not ? !result : result);
        }
Esempio n. 11
0
        public FilterCondition(string filterText, ComparisonMethod comparisonMethod, string targetPropertyName)
        {
            if (string.IsNullOrEmpty(targetPropertyName))
            {
                TargetProperty = ComparisonTargetInfo.AllTargetComparison;
            }
            else
            {
                TargetPropertyId = targetPropertyName;
            }

            FilterText       = filterText ?? Localisation.UninstallListEditor_NewCondition;
            ComparisonMethod = comparisonMethod;
        }
        public void Search(string searchStr, ComparisonMethod method, string targetPropertyName = null, bool negate = false)
        {
            _targetFilterCondition.ComparisonMethod = method;
            _targetFilterCondition.InvertResults    = negate;
            _targetFilterCondition.FilterText       = searchStr;
            _targetFilterCondition.TargetPropertyId = targetPropertyName;

            searchBox1.SearchTextChanged -= searchBox1_SearchTextChanged;
            searchBox1.Search(searchStr);
            searchBox1.SearchTextChanged += searchBox1_SearchTextChanged;

            RefreshEditor();
            OnComparisonMethodChanged(this, EventArgs.Empty);
        }
		private void CompareWithDump (ComparisonMethod cm, string dump, bool testTrue)
		{
			StringWriter sw = new StringWriter ();
			int total = 0;

			for (int i = 0; i <= Char.MaxValue; i++) {
				if (cm ((char) i) == testTrue) {
					sw.Write (i.ToString ("x"));
					sw.Write (' ');
					total++;
				}
			}
			sw.Write ("found " + total + " chars.");

//			string filename = Assembly.GetAssembly (typeof (Char)).Location + "/resources/" + dumpfile;
//			StreamReader sr = new StreamReader (filename);
//			dump = sr.ReadToEnd ();
//			sr.Close ();
			AssertEquals (dump, sw.ToString ());
		}
Esempio n. 14
0
        private void CompareWithDump(ComparisonMethod cm, string dump, bool testTrue)
        {
            StringWriter sw    = new StringWriter();
            int          total = 0;

            for (int i = 0; i <= Char.MaxValue; i++)
            {
                if (cm((char)i) == testTrue)
                {
                    sw.Write(i.ToString("x"));
                    sw.Write(' ');
                    total++;
                }
            }
            sw.Write("found " + total + " chars.");

//			string filename = Assembly.GetAssembly (typeof (Char)).Location + "/resources/" + dumpfile;
//			StreamReader sr = new StreamReader (filename);
//			dump = sr.ReadToEnd ();
//			sr.Close ();
            Assert.AreEqual(dump, sw.ToString());
        }
Esempio n. 15
0
        private void LoadItems()
        {
            WorkAsync(new WorkAsyncInfo
            {
                Message = $"Loading CRM {ComparisonMethod.PluralName.Capitalize()}...",
                Work    = (bw, e) =>
                {
                    if (!Controller.DataManager.UserHasPrivilege(ComparisonMethod.RequiredPrivilege, Controller.DataManager.WhoAmI()))
                    {
                        MessageBox.Show($@"Make sure your user has the '{ComparisonMethod.RequiredPrivilege}' privilege to load the {ComparisonMethod.PluralName}.{Environment.NewLine}Aborting action.");
                        return;
                    }
                    e.Result = ComparisonMethod.GetNames(Controller.DataManager);
                },

                PostWorkCallBack = e =>
                {
                    if (e.Error != null)
                    {
                        Log.LogData(EventType.Exception, ComparisonMethod.LogActionOnLoadItems, e.Error);
                        MessageBox.Show(this, e.Error.Message, @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    var values = (string[])e.Result;

                    comboBoxSolutionsAssembliesList.Items.Clear();
                    Log.LogData(EventType.Event, $"{ComparisonMethod.PluralName.Capitalize()} retrieved");
                    if (values != null)
                    {
                        comboBoxSolutionsAssembliesList.Items.AddRange(values.Cast <object>().ToArray());
                    }

                    Log.LogData(EventType.Event, ComparisonMethod.LogActionOnLoadItems);
                },
                ProgressChanged = e => { SetWorkingMessage(e.UserState.ToString()); }
            });
        }
Esempio n. 16
0
        private void Initialize(OperandType operandType, Type type, Type dataType, Int32 length, string xmlPath, string propertyName, string wtName, ComparisonMethod comparisonMethod, object value)
        {
            if (propertyName == null)
            {
                throw new ApplicationException("Could not initialize SelectionCriterion; property name is null!");
            }

            PropertyInfo property;

            if (dataType == null)
            {
                property = GetProperty(type, propertyName);
            }
            else
            {
                char[]   delimiter   = { '.' };
                string[] xmlProperty = propertyName.Split(delimiter);
                property = GetProperty(type, xmlProperty[0]);
            }

            m_OriginalPropertyName = propertyName;
            m_WorkTypeName         = wtName;
            Initialize(operandType, type, dataType, length, xmlPath, property, comparisonMethod, value, false, Expression.None);
        }
Esempio n. 17
0
 public static string ComparisonTextForParameters(DataObjectBroker dob, ComparisonMethod comparisonMethod, ref object value, int counter)
 {
     return(dob.ConnectionInfo.ComparisonTextForParameters(comparisonMethod, ref value, counter));
 }
Esempio n. 18
0
 public Pair(TLeft left, TRight right, ComparisonMethod comparison)
 {
     Left       = left;
     Right      = right;
     Comparison = comparison;
 }
Esempio n. 19
0
        private static BinaryExpression GetBinaryExpression(ComparisonMethod comparisonMethod, MemberExpression memberExpression, ConstantExpression constantExpression)
        {
            switch (comparisonMethod)
            {
            case ComparisonMethod.Equal:
                return(Expression.Equal(memberExpression, constantExpression));

            case ComparisonMethod.LessThan:
                return(Expression.LessThan(memberExpression, constantExpression));

            case ComparisonMethod.GreaterThan:
                return(Expression.GreaterThan(memberExpression, constantExpression));

            case ComparisonMethod.NotEqual:
                return(Expression.NotEqual(memberExpression, constantExpression));

            case ComparisonMethod.GreaterThanEqual:
                return(Expression.GreaterThanOrEqual(memberExpression, constantExpression));

            case ComparisonMethod.LessThanEqual:
                return(Expression.LessThanOrEqual(memberExpression, constantExpression));

            case ComparisonMethod.IsNullOrEmpty:
                MethodInfo method = typeof(DynamicQueryExtensions).GetMethod(nameof(DynamicQueryIsNullOrEmpty), BindingFlags.NonPublic | BindingFlags.Static);
                return(Expression.MakeBinary(ExpressionType.Equal, memberExpression, constantExpression, false, method));

            case ComparisonMethod.IsNotNullOrEmpty:
                MethodInfo method0 = typeof(DynamicQueryExtensions).GetMethod(nameof(DynamicQueryIsNotNullOrEmpty), BindingFlags.NonPublic | BindingFlags.Static);
                return(Expression.MakeBinary(ExpressionType.Equal, memberExpression, constantExpression, false, method0));

            case ComparisonMethod.Contains:
                MethodInfo method1 = typeof(DynamicQueryExtensions).GetMethod(nameof(DynamicQueryContains), BindingFlags.NonPublic | BindingFlags.Static);
                return(Expression.MakeBinary(ExpressionType.Equal, memberExpression, constantExpression, false, method1));

            case ComparisonMethod.DoesNotContain:
                MethodInfo method2 = typeof(DynamicQueryExtensions).GetMethod(nameof(DynamicQueryDoesNotContain), BindingFlags.NonPublic | BindingFlags.Static);
                return(Expression.MakeBinary(ExpressionType.Equal, memberExpression, constantExpression, false, method2));

            case ComparisonMethod.StartsWith:
                MethodInfo method3 = typeof(DynamicQueryExtensions).GetMethod(nameof(DynamicQueryStartsWith), BindingFlags.NonPublic | BindingFlags.Static);
                return(Expression.MakeBinary(ExpressionType.Equal, memberExpression, constantExpression, false, method3));

            case ComparisonMethod.DoesNotStartWith:
                MethodInfo method4 = typeof(DynamicQueryExtensions).GetMethod(nameof(DynamicQueryDoesNotStartWith), BindingFlags.NonPublic | BindingFlags.Static);
                return(Expression.MakeBinary(ExpressionType.Equal, memberExpression, constantExpression, false, method4));

            case ComparisonMethod.EndsWith:
                MethodInfo method5 = typeof(DynamicQueryExtensions).GetMethod(nameof(DynamicQueryEndsWith), BindingFlags.NonPublic | BindingFlags.Static);
                return(Expression.MakeBinary(ExpressionType.Equal, memberExpression, constantExpression, false, method5));

            case ComparisonMethod.DoesNotEndWith:
                MethodInfo method6 = typeof(DynamicQueryExtensions).GetMethod(nameof(DynamicQueryDoesNotEndWith), BindingFlags.NonPublic | BindingFlags.Static);
                return(Expression.MakeBinary(ExpressionType.Equal, memberExpression, constantExpression, false, method6));

            case ComparisonMethod.Like:
                MethodInfo method7 = typeof(DynamicQueryExtensions).GetMethod(nameof(DynamicQueryLike), BindingFlags.NonPublic | BindingFlags.Static);
                return(Expression.MakeBinary(ExpressionType.Equal, memberExpression, constantExpression, false, method7));

            case ComparisonMethod.NotLike:
                MethodInfo method8 = typeof(DynamicQueryExtensions).GetMethod(nameof(DynamicQueryNotLike), BindingFlags.NonPublic | BindingFlags.Static);
                return(Expression.MakeBinary(ExpressionType.Equal, memberExpression, constantExpression, false, method8));

            default:
                return(null);
            }
        }
Esempio n. 20
0
 /// <summary>
 /// Comparisons the text.
 /// </summary>
 /// <param name="method">The method.</param>
 /// <param name="value">The value.</param>
 /// <returns></returns>
 //private string ComparisonText(ComparisonMethod method, object value)
 public static string ComparisonText(DataObjectBroker dob, ComparisonMethod method, object value, Type type)
 {
     return(dob.ConnectionInfo.ComparisonText(method, GetValueString(dob, value), type));
 }
Esempio n. 21
0
 public SelectionCriterion(OperandType operandType, Type type, Type dataType, Int32 length, string xmlPath, string propertyName, string workTypeName, ComparisonMethod comparisonMethod, object value)
 {
     Initialize(operandType, type, dataType, length, xmlPath, propertyName, workTypeName, comparisonMethod, value);
 }
Esempio n. 22
0
 public SelectionCriterion(OperandType operandType, Type type, Type dataType, Int32 length, string xmlPath, PropertyInfo propertyInstance, ComparisonMethod comparisonMethod, object value)
 {
     Initialize(operandType, type, dataType, length, xmlPath, propertyInstance, comparisonMethod, value, false, Expression.None);
 }
Esempio n. 23
0
 /// <summary>
 /// Calculates the ΔE of this color compared to another color, using the specified comparison method.
 /// This value represents the perceptual difference between the two colors.
 /// </summary>
 /// <param name="other">The color to compare to this color</param>
 /// <param name="method">
 /// The algorith to use for the comparison.
 /// There is an efficiency/accuracy trade-off between the different methods.
 /// </param>
 /// <returns>
 /// ΔE value representing the perceived difference between this color and the comparison color.
 /// </returns>
 public double Compare(ColorSpace other, ComparisonMethod method = ComparisonMethod.Cie2000)
 {
     return(Compare(this, other, method));
 }
Esempio n. 24
0
        /// <summary>
        /// Adds single criterion to the filter expression.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="combineInstruction">The combine instruction.</param>
        /// <param name="propertyName">Name of the property.</param>
        /// <param name="compareMethod">The compare method.</param>
        /// <param name="value">The value.</param>
        ///

        public FilterCriteria AddFilter(Type type, OperandType combineInstruction, string propertyName, ComparisonMethod compareMethod, object value)
        {
            return(AddXmlFilter(type, null, 0, string.Empty, combineInstruction, propertyName, compareMethod, value));
        }
Esempio n. 25
0
        /// <summary>
        /// Sorts an array using specified comparison method for comparing keys in reverse order.
        /// </summary>
        /// <param name="ctx">Current runtime context.</param>
        /// <param name="array">The array to be sorted.</param>
        /// <param name="comparisonMethod">The method to be used for comparison of keys.</param>
        /// <remarks>Resets <paramref name="array"/>'s intrinsic enumerator.</remarks>
        /// <returns>True on success, False on failure.</returns>
        public static bool krsort(Context ctx, [In, Out] PhpArray array, ComparisonMethod comparisonMethod = ComparisonMethod.Regular)
        {
            if (array == null)
            {
                //PhpException.ReferenceNull("array");
                //return false;
                throw new ArgumentNullException();
            }

            array.Sort(GetComparer(ctx, comparisonMethod, SortingOrder.Descending, true));
            array.RestartIntrinsicEnumerator();

            return true;
        }
Esempio n. 26
0
		/// <summary>
		/// Gets an instance of PHP comparer parametrized by specified method, order, and compared item type.
		/// </summary>
		/// <param name="method">The <see cref="ComparisonMethod"/>.</param>
		/// <param name="order">The <see cref="SortingOrder"/>.</param>
		/// <param name="keyComparer">Whether to compare keys (<B>false</B> for value comparer).</param>
		/// <returns>A comparer (either a new instance or existing singleton instance).</returns>
		public static IComparer<KeyValuePair<IntStringKey, object>>/*!*/ GetComparer(ComparisonMethod method, SortingOrder order, bool keyComparer)
		{
			if (keyComparer)
			{
				switch (method)
				{
					case ComparisonMethod.Numeric:
						return (order == SortingOrder.Descending) ? KeyComparer.ReverseNumeric : KeyComparer.Numeric;

					case ComparisonMethod.String:
						return (order == SortingOrder.Descending) ? KeyComparer.ReverseString : KeyComparer.String;

					case ComparisonMethod.LocaleString:
						return new KeyComparer(Locale.GetStringComparer(false), order == SortingOrder.Descending);

					default:
						return (order == SortingOrder.Descending) ? KeyComparer.Reverse : KeyComparer.Default;
				}
			}
			else
			{
				switch (method)
				{
					case ComparisonMethod.Numeric:
						return (order == SortingOrder.Descending) ? ValueComparer.ReverseNumeric : ValueComparer.Numeric;

					case ComparisonMethod.String:
						return (order == SortingOrder.Descending) ? ValueComparer.ReverseString : ValueComparer.String;

					case ComparisonMethod.LocaleString:
						return new ValueComparer(Locale.GetStringComparer(false), order == SortingOrder.Descending);

					default:
						return (order == SortingOrder.Descending) ? ValueComparer.Reverse : ValueComparer.Default;
				}
			}
		}
Esempio n. 27
0
 public Pair(ComparisonMethod comparison) : this(default(TLeft), default(TRight), comparison)
 {
 }
Esempio n. 28
0
 public SelectionCriterion(OperandType operandType, Type type, Type dataType, Int32 length, string xmlPath, string propertyName, ComparisonMethod comparisonMethod, object value)
     : this(operandType, type, dataType, length, xmlPath, propertyName, null, comparisonMethod, value)
 {
 }
		public static String GenerateDump (ComparisonMethod cm, bool testTrue)
		{
			StringWriter sw = new StringWriter ();
			int total = 0;

			for (int i = 0; i <= Char.MaxValue; i++) {
				if (cm ((char) i) == testTrue) {
					sw.Write (i.ToString ("x"));
					sw.Write (' ');
					total++;
				}
			}

			sw.Write ("found " + total + " chars.");
			return sw.ToString();
		}
 public WhereCondition(string columnName, ComparisonMethod comparator, object value)
 {
     ColumnName = columnName;
     Comparator = comparator;
     Value      = value;
 }
Esempio n. 31
0
 public FilterCriteria AddXmlFilter(Type type, Type dataType, Int32 length, string xmlPath, OperandType combineInstruction, string propertyName, ComparisonMethod compareMethod, object value)
 {
     return(AddXmlFilter(type, dataType, length, xmlPath, combineInstruction, propertyName, null, compareMethod, value));
 }
Esempio n. 32
0
        private void Compare()
        {
            if (ComparisonMethod.RequiresItemSelection &&
                SolutionAssemblyPluginStepsName == null)
            {
                MessageBox.Show($@"Please select a {ComparisonMethod.Name} first.");
                return;
            }

            string[] diffCrmSourceTarget = null;
            string[] diffCrmTargetSource = null;

            StepsCrmSource.Clear();
            StepsCrmTarget.Clear();

            WorkAsync(new WorkAsyncInfo
            {
                Message = $"Comparing the 2 {ComparisonMethod.PluralName.Capitalize()}...",
                Work    = (bw, e) =>
                {
                    SendMessageToStatusBar?.Invoke(this, new StatusBarMessageEventArgs(0, "Fetching steps from source environment..."));
                    StepsCrmSource = ComparisonMethod.GetSteps(SourceService, Settings, SolutionAssemblyPluginStepsName);
                    SendMessageToStatusBar?.Invoke(this, new StatusBarMessageEventArgs(30, "Fetching steps from target environment..."));
                    StepsCrmTarget = ComparisonMethod.GetSteps(TargetService, Settings, SolutionAssemblyPluginStepsName);
                    foreach (var step in StepsCrmTarget)
                    {
                        step.Environment = "Target";
                    }

                    SendMessageToStatusBar?.Invoke(this, new StatusBarMessageEventArgs(60, "Comparing steps..."));

                    Comparer.Compare(StepsCrmSource, StepsCrmTarget);
                    SendMessageToStatusBar?.Invoke(this, new StatusBarMessageEventArgs(90, "Finding Differences..."));
                    diffCrmSourceTarget = StepsCrmSource.Select(x => x.StepName).Except(StepsCrmTarget.Select(x => x.StepName)).ToArray();
                    diffCrmTargetSource = StepsCrmTarget.Select(x => x.StepName).Except(StepsCrmSource.Select(x => x.StepName)).ToArray();
                    SendMessageToStatusBar?.Invoke(this, new StatusBarMessageEventArgs(100, "Done!"));
                },
                PostWorkCallBack = e =>
                {
                    if (e.Error != null)
                    {
                        Log.LogData(EventType.Exception, ComparisonMethod.LogActionOnCompare, e.Error);
                        MessageBox.Show(this, e.Error.Message, @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        toolStripButtonExport.Enabled = false;
                        return;
                    }

                    toolStripButtonExport.Enabled = true;

                    if (diffCrmSourceTarget.Length == 0)
                    {
                        listViewSourceTarget.Items.Clear();
                        labelSourceTargetMatch.Visible = true;
                    }
                    else // there are steps in source but not target
                    {
                        labelSourceTargetMatch.Visible = false;
                        listViewSourceTarget.Visible   = true;
                        FillListViewItems(listViewSourceTarget, StepsCrmSource, diffCrmSourceTarget);
                    }

                    if (diffCrmTargetSource.Count() == 0)
                    {
                        listViewTargetSource.Items.Clear();
                        labelTargetSourceMatch.Visible = true;
                    }
                    else // there are steps in source but not target
                    {
                        labelTargetSourceMatch.Visible = false;
                        listViewTargetSource.Visible   = true;
                        FillListViewItems(listViewTargetSource, StepsCrmTarget, diffCrmTargetSource);
                    }

                    Log.LogData(EventType.Event, ComparisonMethod.LogActionOnCompare);
                },
                ProgressChanged = e =>
                {
                    SetWorkingMessage(e.UserState.ToString());
                }
            });
        }
Esempio n. 33
0
        public FilterCriteria AddXmlFilter(Type type, Type dataType, Int32 length, string xmlPath, OperandType combineInstruction, string propertyName, string workTypeName, ComparisonMethod compareMethod, object value)
        {
            // Create a new SelectionCriterion object.
            SelectionCriterion selectionCriterion = new SelectionCriterion(combineInstruction, type, dataType, length, xmlPath, propertyName, workTypeName, compareMethod, value);

            m_Criteria.AddCriteria(selectionCriterion);
            ValidateCriteria(m_Criteria);
            return(this);
        }
Esempio n. 34
0
        /// <summary>
        /// Removes duplicate values from an array.
        /// </summary>
        /// <param name="ctx">Current runtime context.</param>
        /// <param name="array">The array which duplicate values to remove.</param>
        /// <param name="sortFlags">Specifies how the values are compared to be identical.</param>
        /// <returns>A copy of <paramref name="array"/> without duplicated values.</returns>
        /// <remarks>
        /// Values are compared using string comparison method (<see cref="ValueComparer.String"/>).  
        /// </remarks>
        /// <exception cref="PhpException"><paramref name="array"/> is a <B>null</B> reference.</exception>
        //[return: PhpDeepCopy]
        public static PhpArray array_unique(Context ctx, PhpArray array, ComparisonMethod sortFlags = ComparisonMethod.String)
        {
            if (array == null)
            {
                //PhpException.ArgumentNull("array");
                //return null;
                throw new ArgumentNullException();
            }

            IComparer<PhpValue> comparer;
            switch (sortFlags)
            {
                case ComparisonMethod.Regular:
                    comparer = PhpComparer.Default; break;
                case ComparisonMethod.Numeric:
                    comparer = PhpNumericComparer.Default; break;
                case ComparisonMethod.String:
                    comparer = new PhpStringComparer(ctx); break;
                case ComparisonMethod.LocaleString:
                //comparer = new PhpLocaleStringComparer(ctx); break;
                default:
                    //PhpException.ArgumentValueNotSupported("sortFlags", (int)sortFlags);
                    //return null;
                    throw new ArgumentException(nameof(sortFlags));
            }

            var result = new PhpArray(array.Count);

            var/*!*/identitySet = new HashSet<object>();

            // get only unique values - first found
            using (var enumerator = array.GetFastEnumerator())
                while (enumerator.MoveNext())
                {
                    if (identitySet.Add(enumerator.CurrentValue.GetValue()))
                    {
                        result.Add(enumerator.Current);
                    }
                }

            //result.InplaceCopyOnReturn = true;
            return result;
        }
Esempio n. 35
0
        /// <summary>
        ///  Compare images
        /// </summary>
        /// <param name="image1"> 1st image</param>
        /// <param name="image2"> 2nd image</param>
        /// <param name="method"> method</param>
        /// <returns>Similarity % )</returns>
        public static double CompareImages(Mat image1, Mat image2, ComparisonMethod method)
        {
            double sim = 0;

            switch (method)
            {
            case ComparisonMethod.None:
                break;

            case ComparisonMethod.TopColors:
                var bmp1 = (Image)BitmapConverter.ToBitmap(image1);
                var bmp2 = (Image)BitmapConverter.ToBitmap(image2);
                sim = Images.ColorExtract.CompareTop(bmp1, bmp2);
                bmp1.Dispose();
                bmp2.Dispose();
                break;

            case ComparisonMethod.MainColor:
                bmp1 = (Image)BitmapConverter.ToBitmap(image1);
                bmp2 = (Image)BitmapConverter.ToBitmap(image2);
                var main1 = Images.ColorExtract.MainColor(bmp1);
                var main2 = Images.ColorExtract.MainColor(bmp2);
                sim = Images.ColorExtract.Compare(main1, main2);
                bmp1.Dispose();
                bmp2.Dispose();
                break;

            case ComparisonMethod.PixelsDifference:
                sim = ComparePixels(image1, image2);
                break;

            case ComparisonMethod.PixelsDifferenceSorted:
                sim = ComparePixelsSorted(image1, image2);
                break;

            case ComparisonMethod.PixelsDistance:
                sim = ComparePixelsDistance(image1, image2);
                break;

            case ComparisonMethod.PixelsDistanceSorted:
                sim = ComparePixelsDistanceSorted(image1, image2);
                break;

            case ComparisonMethod.Feature:
                double feature;
                double matchs;
                Bitmap view;
                try
                {
                    sim = CompareFeatures(image1, image2, out feature, out matchs, out view);
                }
                catch (System.AccessViolationException e)
                {
                    Console.Error.WriteLine("Access Error  => CompareImages {0} : \n{1}", method, e);
                }
                catch (Exception e)
                {
                    Console.Error.WriteLine("Error  => CompareImages {0} : \n{1}", method, e);
                }
                break;

            case ComparisonMethod.RGBHistogramHash:
                sim = Images.ImageHistogramHash.Compare(image1, image2);
                break;

            default:
                break;
            }

            return(sim);
        }
Esempio n. 36
0
		public static bool KeyReverseSort([PhpRw] PhpArray array, ComparisonMethod comparisonMethod)
		{
			if (array == null) { PhpException.ReferenceNull("array"); return false; }

			array.Sort(GetComparer(comparisonMethod, SortingOrder.Descending, true));
			array.RestartIntrinsicEnumerator();

            return true;
		}
Esempio n. 37
0
 public FilterCriteria AddXmlFilter(Type type, Type dataType, string xmlPath, string propertyName, ComparisonMethod compareMethod, object value)
 {
     return(AddXmlFilter(type, dataType, 0, xmlPath, OperandType.None, propertyName, compareMethod, value));
 }