Ejemplo n.º 1
0
        public override bool Validate(BusinessObject businessObject)
        {
            try
            {
                bool deleted = Convert.ToBoolean(businessObject.GetType().GetProperty("Deleted").GetValue(businessObject, null));

                if (deleted) return true;

                string scheduledStringStartExecutionDate = businessObject.GetType().GetProperty(PropertyName).GetValue(businessObject, null).ToString();
                int jobId = Convert.ToInt32(businessObject.GetType().GetProperty(OtherPropertyName).GetValue(businessObject, null));

                var job = context.Jobs.SingleOrDefault(x => x.JobId == jobId && !x.Deleted);

                DateTime scheduledStartExecutionDate = DateTime.Parse(scheduledStringStartExecutionDate);
                DateTime now = DateTime.Now;

                // Se le suma un minuto sino genera error
                if (job.JobType == JobType.Automático && scheduledStartExecutionDate.AddMinutes(1) >= now)
                    return true;

                if (job.JobType == JobType.Manual && scheduledStartExecutionDate.Date >= now.Date)
                    return true;

                return false;
            }
            catch{
                ErrorMessage = "El objeto Trigger no contiene la referencia la objeto Job al que pertenece.(Técnico)\r\n";
                return false;
            }
        }
Ejemplo n.º 2
0
        public override bool Validate(BusinessObject businessObject)
        {
            try
            {
                int keyId = Convert.ToInt32(businessObject.GetType().GetProperty(base.PropertyName).GetValue(businessObject, null));

                // Aún no se ha creado el trigger en la BD, y este es autonumérico.
                if (keyId == 0)
                    return true;

                var deleted = Convert.ToBoolean(businessObject.GetType().GetProperty("Deleted").GetValue(businessObject, null));

                if (deleted)
                {
                    var deletedBy = businessObject.GetType().GetProperty("DeletedBy").GetValue(businessObject, null).ToString();

                    DateTime? deletedDate = null;

                    if (businessObject.GetType().GetProperty("DeletedDate").GetValue(businessObject, null) != null)
                        deletedDate = Convert.ToDateTime(businessObject.GetType().GetProperty("DeletedDate").GetValue(businessObject, null));

                    if (!String.IsNullOrEmpty(deletedBy) && deletedDate.HasValue)
                        return true;
                }

                return false;
            }
            catch{
                ErrorMessage = "El objeto Trigger no pudo ser encontrado.(Técnico)\r\n";
                return false; }
        }
Ejemplo n.º 3
0
 public override bool Validate(BusinessObject businessObject)
 {
     try
     {
         return GetPropertyValue(businessObject).ToString().Length > 0;
     }
     catch
     {
         return false;
     }
 }
Ejemplo n.º 4
0
        public override bool Validate(BusinessObject businessObject)
        {
            try
            {
                string value = GetPropertyValue(businessObject).ToString();

                switch (DataType)
                {
                    case ValidationDataType.Integer:

                        int imin = int.Parse(Min.ToString());
                        int imax = int.Parse(Max.ToString());
                        int ival = int.Parse(value);

                        return (ival >= imin && ival <= imax);

                    case ValidationDataType.Double:
                        double dmin = double.Parse(Min.ToString());
                        double dmax = double.Parse(Max.ToString());
                        double dval = double.Parse(value);

                        return (dval >= dmin && dval <= dmax);

                    case ValidationDataType.Decimal:
                        decimal cmin = decimal.Parse(Min.ToString());
                        decimal cmax = decimal.Parse(Max.ToString());
                        decimal cval = decimal.Parse(value);

                        return (cval >= cmin && cval <= cmax);

                    case ValidationDataType.Date:
                        DateTime tmin = DateTime.Parse(Min.ToString());
                        DateTime tmax = DateTime.Parse(Max.ToString());
                        DateTime tval = DateTime.Parse(value);

                        return (tval >= tmin && tval <= tmax);

                    case ValidationDataType.String:

                        string smin = Min.ToString();
                        string smax = Max.ToString();

                        int result1 = string.Compare(smin, value);
                        int result2 = string.Compare(value, smax);

                        return result1 >= 0 && result2 <= 0;
                }
                return false;
            }
            catch { return false; }
        }
Ejemplo n.º 5
0
 public override bool Validate(BusinessObject businessObject)
 {
     return Regex.Match(GetPropertyValue(businessObject).ToString(), Pattern).Success;
 }
Ejemplo n.º 6
0
        public override bool Validate(BusinessObject businessObject)
        {
            try
            {
                string propValue1 = businessObject.GetType().GetProperty(PropertyName).GetValue(businessObject, null).ToString();
                string propValue2 = businessObject.GetType().GetProperty(OtherPropertyName).GetValue(businessObject, null).ToString();

                switch(DataType)
                {
                    case ValidationDataType.Integer:

                        int ival1 = int.Parse(propValue1);
                        int ival2 = int.Parse(propValue2);

                        switch(Operator)
                        {
                            case ValidationOperator.Equal: return ival1 == ival2;
                            case ValidationOperator.NotEqual: return ival1 != ival2;
                            case ValidationOperator.GreaterThan: return ival1 > ival2;
                            case ValidationOperator.GreaterThanEqual: return ival1 >= ival2;
                            case ValidationOperator.LessThan: return ival1 < ival2;
                            case ValidationOperator.LessThanEqual: return ival1 <= ival2;
                        }
                        break;

                    case ValidationDataType.Double:

                        double dval1 = double.Parse(propValue1);
                        double dval2 = double.Parse(propValue2);

                        switch(Operator)
                        {
                            case ValidationOperator.Equal: return dval1 == dval2;
                            case ValidationOperator.NotEqual: return dval1 != dval2;
                            case ValidationOperator.GreaterThan: return dval1 > dval2;
                            case ValidationOperator.GreaterThanEqual: return dval1 >= dval2;
                            case ValidationOperator.LessThan: return dval1 < dval2;
                            case ValidationOperator.LessThanEqual: return dval1 <= dval2;
                        }
                        break;

                    case ValidationDataType.Decimal:

                        decimal cval1 = decimal.Parse(propValue1);
                        decimal cval2 = decimal.Parse(propValue2);

                        switch(Operator)
                        {
                            case ValidationOperator.Equal: return cval1 == cval2;
                            case ValidationOperator.NotEqual: return cval1 != cval2;
                            case ValidationOperator.GreaterThan: return cval1 > cval2;
                            case ValidationOperator.GreaterThanEqual: return cval1 >= cval2;
                            case ValidationOperator.LessThan: return cval1 < cval2;
                            case ValidationOperator.LessThanEqual: return cval1 <= cval2;
                        }
                        break;

                    case ValidationDataType.Date:

                        DateTime tval1 = DateTime.Parse(propValue1);
                        DateTime tval2 = DateTime.Parse(propValue2);

                        switch(Operator)
                        {
                            case ValidationOperator.Equal: return tval1 == tval2;
                            case ValidationOperator.NotEqual: return tval1 != tval2;
                            case ValidationOperator.GreaterThan: return tval1 > tval2;
                            case ValidationOperator.GreaterThanEqual: return tval1 >= tval2;
                            case ValidationOperator.LessThan: return tval1 < tval2;
                            case ValidationOperator.LessThanEqual: return tval1 <= tval2;
                        }
                        break;

                    case ValidationDataType.String:

                        int result = string.Compare(propValue1, propValue2, StringComparison.CurrentCulture);

                        switch(Operator)
                        {
                            case ValidationOperator.Equal: return result == 0;
                            case ValidationOperator.NotEqual: return result != 0;
                            case ValidationOperator.GreaterThan: return result > 0;
                            case ValidationOperator.GreaterThanEqual: return result >= 0;
                            case ValidationOperator.LessThan: return result < 0;
                            case ValidationOperator.LessThanEqual: return result <= 0;
                        }
                        break;

                }
                return false;
            }
            catch{ return false; }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Gets value for given business object's property using reflection.
 /// </summary>
 /// <param name="businessObject"></param>
 /// <param name="propertyName"></param>
 /// <returns></returns>
 protected object GetPropertyValue(BusinessObject businessObject)
 {
     return businessObject.GetType().GetProperty(PropertyName).GetValue(businessObject, null);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Validation method. To be implemented in derived classes.
 /// </summary>
 /// <param name="businessObject"></param>
 /// <returns></returns>
 public abstract bool Validate(BusinessObject businessObject);
Ejemplo n.º 9
0
 public override bool Validate(BusinessObject businessObject)
 {
     int length = GetPropertyValue(businessObject).ToString().Length;
     return length >= _min && length <= _max;
 }