Exemplo n.º 1
0
		//-- There are not any NodeAttribute with Currency datatype

		public CurrencyExpression(PropertyType property, ValueOperator op, decimal? value)
		{
			if (property == null)
				throw new ArgumentNullException("property");
			if (property.DataType != DataType.Currency)
				throw GetWrongPropertyDataTypeException("property", DataType.Currency);
			_binExp = new BinaryExpression(property, BinaryExpression.GetOperator(op), value);
		}
Exemplo n.º 2
0
		public DateTimeExpression(PropertyType property, ValueOperator op, DateTimeAttribute value)
		{
			if (property == null)
				throw new ArgumentNullException("property");
			if (property.DataType != DataType.DateTime)
				throw new ArgumentOutOfRangeException("property", "The DataType of 'property' must be DataType.DateTime");
			_binExp = new BinaryExpression(property, BinaryExpression.GetOperator(op), BinaryExpression.GetNodeAttribute(value));
		}
Exemplo n.º 3
0
		public DateTimeExpression(DateTimeAttribute property, ValueOperator op, PropertyType value)
		{
			if (value == null)
				throw new ArgumentNullException("value");
			if (value.DataType != DataType.DateTime)
				throw GetWrongPropertyDataTypeException("value", DataType.DateTime);
			_binExp = new BinaryExpression((NodeAttribute)property, BinaryExpression.GetOperator(op), value);
		}
Exemplo n.º 4
0
		public IntExpression(PropertyType property, ValueOperator op, IntAttribute value)
		{
			if (property == null)
				throw new ArgumentNullException("property");
			if (property.DataType != DataType.Int)
				throw GetWrongPropertyDataTypeException("property", DataType.Int);
			_binExp = new BinaryExpression(property, BinaryExpression.GetOperator(op), BinaryExpression.GetNodeAttribute(value));
		}
Exemplo n.º 5
0
        public TestResult(string lossFunctionName, double rawValue, double factor, bool lowerIsBetter, ValueOperator valueOperator)
        {
            LossFunctionName = lossFunctionName;
            RawValue         = rawValue;
            Factor           = factor;
            Operator         = valueOperator;
            LowerIsBetter    = lowerIsBetter;

            FinalValue = CalculateFinalValue();
        }
Exemplo n.º 6
0
        public static bool Compare(Attrib attrib1, Attrib attrib2, ValueOperator valueOperator)
        {
            if (attrib1.DataType != attrib2.DataType)
            {
                return(false);
            }

            if (attrib1.IsPresent != attrib2.IsPresent)
            {
                return(false);
            }

            if (!attrib1.IsPresent && !attrib2.IsPresent)
            {
                return(true);
            }

            if (attrib1.Values.Count != attrib2.Values.Count)
            {
                return(false);
            }

            IEnumerable <object> values1;
            IEnumerable <object> values2;

            switch (attrib1.DataType)
            {
            case AttributeType.String:
                values1 = attrib1.Values.OfType <Value>().Select(t => t.ToString()).Cast <object>();
                values2 = attrib2.Values.OfType <Value>().Select(t => t.ToString()).Cast <object>();
                break;

            case AttributeType.Integer:
                values1 = attrib1.Values.OfType <Value>().Select(t => t.ToInteger()).Cast <object>();
                values2 = attrib2.Values.OfType <Value>().Select(t => t.ToInteger()).Cast <object>();
                break;

            case AttributeType.Binary:
                values1 = attrib1.Values.OfType <Value>().Select(t => t.ToBinary()).Cast <object>();
                values2 = attrib2.Values.OfType <Value>().Select(t => t.ToBinary()).Cast <object>();
                break;

            case AttributeType.Boolean:
                values1 = attrib1.Values.OfType <Value>().Select(t => t.ToBoolean()).Cast <object>();
                values2 = attrib2.Values.OfType <Value>().Select(t => t.ToBoolean()).Cast <object>();
                break;

            case AttributeType.Undefined:
            default:
                throw new UnknownOrUnsupportedDataTypeException();
            }

            return(values1.ContainsSameElements(values2));
        }
Exemplo n.º 7
0
        public void CompareLongAndTest()
        {
            ValueOperator valueOperator    = ValueOperator.And;
            long          actualValue      = 514L;
            long          matchingValue    = 2L;
            long          nonMatchingValue = 5L;

            Assert.AreEqual(true, ComparisonEngine.CompareLong(actualValue, matchingValue, valueOperator));

            Assert.AreEqual(false, ComparisonEngine.CompareLong(actualValue, nonMatchingValue, valueOperator));
        }
Exemplo n.º 8
0
        public void CompareStringNotPresentTest()
        {
            ValueOperator valueOperator    = ValueOperator.NotPresent;
            string        actualValue      = null;
            string        matchingValue    = null;
            string        nonMatchingValue = null;

            Assert.AreEqual(true, ComparisonEngine.CompareString(actualValue, matchingValue, valueOperator));

            actualValue = "abds";
            Assert.AreEqual(false, ComparisonEngine.CompareString(actualValue, nonMatchingValue, valueOperator));
        }
Exemplo n.º 9
0
 public ORUP_USER SaveUser(ORUP_USER user)
 {
     if (0 == user.ID)
     {
         user.ID = ValueOperator.CreatePk("ORUP_USER");
     }
     using (ORMHandler orm = Zxl.Data.DatabaseManager.ORMHandler)
     {
         orm.Save(user);
         return(user);
     }
 }
Exemplo n.º 10
0
 public ORUP_ORGANIZATION SaveOrg(ORUP_ORGANIZATION org)
 {
     if (0 == org.ID)
     {
         org.ID = ValueOperator.CreatePk("ORUP_ROLE");
     }
     using (ORMHandler orm = Zxl.Data.DatabaseManager.ORMHandler)
     {
         orm.Save(org);
         return(org);
     }
 }
Exemplo n.º 11
0
 public ORUP_ROLE SaveRole(ORUP_ROLE role)
 {
     if (0 == role.ID)
     {
         role.ID = ValueOperator.CreatePk("ORUP_ROLE");
     }
     using (ORMHandler orm = Zxl.Data.DatabaseManager.ORMHandler)
     {
         orm.Save(role);
         return(role);
     }
 }
Exemplo n.º 12
0
 public SYS_BUSINESSFORM SaveBusinessForm(SYS_BUSINESSFORM form)
 {
     if (0 == form.ID)
     {
         form.ID = ValueOperator.CreatePk("SYS_BUSINESSFORM");
     }
     using (ORMHandler orm = Zxl.Data.DatabaseManager.ORMHandler)
     {
         orm.Save(form);
         return(form);
     }
 }
Exemplo n.º 13
0
 public SYS_BUSINESSPROCESS SaveBusinessProcess(SYS_BUSINESSPROCESS process)
 {
     if (0 == process.ID)
     {
         process.ID = ValueOperator.CreatePk("SYS_BUSINESSPROCESS");
     }
     using (ORMHandler orm = Zxl.Data.DatabaseManager.ORMHandler)
     {
         orm.Save(process);
         return(process);
     }
 }
Exemplo n.º 14
0
 public SYS_BUSINESSROLE SaveBusinessRole(SYS_BUSINESSROLE role)
 {
     if (0 == role.ID)
     {
         role.ID = ValueOperator.CreatePk("SYS_BUSINESSROLE");
     }
     using (ORMHandler orm = Zxl.Data.DatabaseManager.ORMHandler)
     {
         orm.Save(role);
         return(role);
     }
 }
Exemplo n.º 15
0
 public SYS_BUSINESSMATERIAL SaveBusinessMaterial(SYS_BUSINESSMATERIAL material)
 {
     if (0 == material.ID)
     {
         material.ID = ValueOperator.CreatePk("SYS_BUSINESSMATERIAL");
     }
     using (ORMHandler orm = Zxl.Data.DatabaseManager.ORMHandler)
     {
         orm.Save(material);
         return(material);
     }
 }
Exemplo n.º 16
0
 public SYS_BUSINESS SaveBusiness(SYS_BUSINESS business)
 {
     if (0 == business.ID)
     {
         business.ID = ValueOperator.CreatePk("SYS_BUSINESS");
     }
     using (ORMHandler orm = Zxl.Data.DatabaseManager.ORMHandler)
     {
         orm.Save(business);
     }
     return(business);
 }
Exemplo n.º 17
0
 public SYS_SYSTEMCONFIG SaveConfig(SYS_SYSTEMCONFIG config)
 {
     if (0 == config.ID)
     {
         config.ID = ValueOperator.CreatePk("SYS_SYSTEMCONFIG");
     }
     using (ORMHandler orm = Zxl.Data.DatabaseManager.ORMHandler)
     {
         orm.Save(config);
         return(config);
     }
 }
Exemplo n.º 18
0
        public SYS_BUSINESSDATA AddBusinessData(string Name, string Description)
        {
            SYS_BUSINESSDATA result = new SYS_BUSINESSDATA();

            result.ID          = ValueOperator.CreatePk("SYS_BUSINESSDATA");
            result.NAME        = Name;
            result.DESCRIPTION = Description;
            using (ORMHandler orm = Zxl.Data.DatabaseManager.ORMHandler)
            {
                orm.Save(result);
            }
            return(result);
        }
Exemplo n.º 19
0
        public void CompareBinaryNoPresenceTest()
        {
            ValueOperator valueOperator = ValueOperator.NotPresent;

            byte[] actualValue      = null;
            byte[] matchingValue    = new byte[] { 0, 1, 2, 3 };
            byte[] nonMatchingValue = new byte[] { 0, 1, 2, 4 };

            Assert.AreEqual(true, ComparisonEngine.CompareBinary(actualValue, matchingValue, valueOperator));

            actualValue = new byte[] { 0, 1, 2, 3, 4 };
            Assert.AreEqual(false, ComparisonEngine.CompareBinary(actualValue, matchingValue, valueOperator));
        }
Exemplo n.º 20
0
        public void CompareDateTimeLessThanOrEqTest()
        {
            ValueOperator valueOperator    = ValueOperator.LessThanOrEq;
            DateTime      actualValue      = DateTime.Parse("1/1/1999");
            DateTime      matchingValue    = DateTime.Parse("1/1/2000");
            DateTime      nonMatchingValue = DateTime.Parse("1/1/1989");

            Assert.AreEqual(true, ComparisonEngine.CompareDateTime(actualValue, matchingValue, valueOperator));

            matchingValue = DateTime.Parse("1/1/1999");
            Assert.AreEqual(true, ComparisonEngine.CompareDateTime(actualValue, matchingValue, valueOperator));

            Assert.AreEqual(false, ComparisonEngine.CompareDateTime(actualValue, nonMatchingValue, valueOperator));
        }
Exemplo n.º 21
0
        public ORUP_USERORGANIZATION SaveUserOrg(int UserId, int OrgId)
        {
            ORUP_USERORGANIZATION uo = new ORUP_USERORGANIZATION();

            uo.ID             = ValueOperator.CreatePk("ORUP_USERORGANIZATION");
            uo.USERID         = UserId;
            uo.ORGANIZATIONID = OrgId;

            using (ORMHandler orm = Zxl.Data.DatabaseManager.ORMHandler)
            {
                orm.Save(uo);
                return(uo);
            }
        }
Exemplo n.º 22
0
        public ORUP_USERROLE SaveUserRole(int UserId, int RoleId)
        {
            ORUP_USERROLE ur = new ORUP_USERROLE();

            ur.ID     = ValueOperator.CreatePk("ORUP_USERROLE");
            ur.UserID = UserId;
            ur.RoleID = RoleId;

            using (ORMHandler orm = Zxl.Data.DatabaseManager.ORMHandler)
            {
                orm.Save(ur);
                return(ur);
            }
        }
Exemplo n.º 23
0
        public void CompareLongLessThanOrEqTest()
        {
            ValueOperator valueOperator    = ValueOperator.LessThanOrEq;
            long          actualValue      = 10L;
            long          matchingValue    = 20L;
            long          nonMatchingValue = 5L;

            Assert.AreEqual(true, ComparisonEngine.CompareLong(actualValue, matchingValue, valueOperator));

            matchingValue = 10L;
            Assert.AreEqual(true, ComparisonEngine.CompareLong(actualValue, matchingValue, valueOperator));

            Assert.AreEqual(false, ComparisonEngine.CompareLong(actualValue, nonMatchingValue, valueOperator));
        }
Exemplo n.º 24
0
 public NullableValueParam(T value, ValueOperator valueOperator)
 {
     if (typeof(T).IsClass && value == null)
     {
         FOperator = ValueOperator.EqualsNull;
         IsNull    = false;
         return;
     }
     FOperator = valueOperator;
     FValue    = value;
     if (valueOperator == ValueOperator.EqualsNull)
     {
         IsNull = false;
     }
 }
Exemplo n.º 25
0
        public SYS_BUSINESSDATADETAIL AddBusinessDataDetail(int REF_BUSINESSDATA_ID, int REF_METADATA_ID, int PARENTID)
        {
            SYS_BUSINESSDATADETAIL result = new SYS_BUSINESSDATADETAIL();

            result.ID = ValueOperator.CreatePk("SYS_BUSINESSDATADETAIL");
            result.REF_BUSINESSDATA_ID = REF_BUSINESSDATA_ID;
            result.REF_METADATA_ID     = REF_METADATA_ID;
            result.PARENTID            = PARENTID;

            using (ORMHandler orm = Zxl.Data.DatabaseManager.ORMHandler)
            {
                orm.Save(result);
            }
            return(result);
        }
Exemplo n.º 26
0
        /// <summary>
        /// Compares two values of the specified ExtendedAttributeType
        /// </summary>
        /// <param name="actualValue">The value to test</param>
        /// <param name="expectedValue">The expected value</param>
        /// <param name="valueOperator">The operator to use</param>
        /// <param name="type">The data type of the values to compare</param>
        /// <returns>True if the values are the same</returns>
        public static bool Compare(object actualValue, object expectedValue, ValueOperator valueOperator, ExtendedAttributeType type)
        {
            switch (type)
            {
            case ExtendedAttributeType.Binary:
                return(CompareBinary(TypeConverter.ConvertData <byte[]>(actualValue),
                                     TypeConverter.ConvertData <byte[]>(expectedValue),
                                     valueOperator));

            case ExtendedAttributeType.Boolean:
                return(CompareBoolean(TypeConverter.ConvertData <bool>(actualValue),
                                      TypeConverter.ConvertData <bool>(expectedValue),
                                      valueOperator));

            case ExtendedAttributeType.Integer:
                return(CompareLong(TypeConverter.ConvertData <long>(actualValue),
                                   TypeConverter.ConvertData <long>(expectedValue),
                                   valueOperator));

            case ExtendedAttributeType.DateTime:
                return(CompareDateTime(TypeConverter.ConvertData <DateTime>(actualValue),
                                       TypeConverter.ConvertData <DateTime>(expectedValue),
                                       valueOperator));

            case ExtendedAttributeType.Reference:
                return(CompareString(TypeConverter.ConvertData <Guid>(actualValue).ToString(),
                                     TypeConverter.ConvertData <Guid>(expectedValue).ToString(),
                                     valueOperator));

            case ExtendedAttributeType.String:
                return(CompareString(TypeConverter.ConvertData <string>(actualValue),
                                     TypeConverter.ConvertData <string>(expectedValue),
                                     valueOperator));

            default:
            case ExtendedAttributeType.Undefined:
                throw new UnknownOrUnsupportedDataTypeException();
            }
        }
Exemplo n.º 27
0
		public static Operator GetOperator(ValueOperator op)
		{
			switch (op)
			{
				case ValueOperator.Equal:
					return Operator.Equal;
				case ValueOperator.NotEqual:
					return Operator.NotEqual;
				case ValueOperator.LessThan:
					return Operator.LessThan;
				case ValueOperator.GreaterThan:
					return Operator.GreaterThan;
				case ValueOperator.LessThanOrEqual:
					return Operator.LessThanOrEqual;
				case ValueOperator.GreaterThanOrEqual:
					return Operator.GreaterThanOrEqual;
				default:
					throw new NotImplementedException(String.Format(CultureInfo.CurrentCulture, SR.Exceptions.Search.Msg_UnknownValueOperator_1, op));
			}
		}
Exemplo n.º 28
0
        protected static Graph2D OperateBackwards(Graph2D g0, Graph2D g1, ValueOperator func)
        {
            if (g0.Length == 0 || g1.Length == 0)
            {
                return new Graph2D(new float[0], new float[0]) { Offset = 0 };
            }
            float[] x = new float[g0.Length + g1.Length];
            float[] fx = new float[x.Length];

            int p0 = 0; int p1 = 0; int pCount = 0;
            if (g0.X[0] > g1.X[0])
            {
                p0 = g0.GetLastBelowX(g1.X[0]) + 1;
            }
            if (g1.X[0] > g0.X[0])
            {
                p1 = g1.GetLastBelowX(g0.X[0]) + 1;
            }

            float maxX = Math.Min(g0.X[g0.Length - 1], g1.X[g1.Length - 1]);
            // Interleave
            while (p0 < g0.Length && p1 < g1.Length)
            {
                float v0 = p0 < g0.Length ? g0.X[p0] : float.MaxValue;
                float v1 = p1 < g1.Length ? g1.X[p1] : float.MaxValue;

                if (v0 > v1)
                {
                    x[pCount] = v0;
                    fx[pCount] = func(g1.Sample(v0), g0.Fx[p0]);
                    p0++;
                }
                if (v0 < v1)
                {
                    x[pCount] = v1;
                    fx[pCount] = func(g1.Fx[p1], g0.Sample(v1));
                    p1++;
                }
                if (v0 == v1)
                {
                    x[pCount] = v0;
                    fx[pCount] = func(g1.Fx[p1], g0.Fx[p0]);
                    p0++; p1++;
                }

                ++pCount;
            }
            if (pCount < x.Length)
            {
                Array.Resize(ref x, pCount);
                Array.Resize(ref fx, pCount);
            }
            return new Graph2D(x, fx);
        }
Exemplo n.º 29
0
		public DateTimeExpression(DateTimeAttribute property, ValueOperator op, DateTimeAttribute value)
		{
			_binExp = new BinaryExpression((NodeAttribute)property, BinaryExpression.GetOperator(op), BinaryExpression.GetNodeAttribute(value));
		}
Exemplo n.º 30
0
		public IntExpression(IntAttribute property, ValueOperator op, IntAttribute value)
		{
			_binExp = new BinaryExpression((NodeAttribute)property, BinaryExpression.GetOperator(op), BinaryExpression.GetNodeAttribute(value));
		}