Example #1
0
        private void BuildProperties(String Properties)
        {
            this.Children.NotifyListChanged = false;

            // Build Properties
            String[] proparray = Properties.Split(new char[1] {
                ','
            });

            foreach (String prop in proparray)
            {
                if (this.ItemType.HasPropertyType(prop))
                {
                    Model.PropertyType proptype = this.ItemType.PropertyType(prop);

                    this.PropertyCache[proptype] = this.Session.CreateProperty(proptype, false);
                    this.Children.Add(this.PropertyCache[proptype]);
                }
                else
                {
                    throw new Model.Exceptions.ArgumentException("Invalid Property: " + prop);
                }
            }

            // Run After Build Properties
            this.AfterBuildProperties();

            this.Children.NotifyListChanged = true;
        }
Example #2
0
 public Property(Manager.Session Session, Model.PropertyType PropertyType)
     : this(Session)
 {
     this.UpdatingBinding     = false;
     this.IntermediateChanges = false;
     this.PropertyType        = PropertyType;
     this.Label = PropertyType.Label;
 }
Example #3
0
        public Column AddColumn(Model.PropertyType PropertyType, Model.Query Query)
        {
            Column ret = null;

            switch (PropertyType.GetType().Name)
            {
            case "Boolean":
                ret = this.AddBooleanColumn(PropertyType.Name, PropertyType.Label, PropertyType.ColumnWidth);
                break;

            case "Date":
                ret = this.AddDateColumn(PropertyType.Name, PropertyType.Label, PropertyType.ColumnWidth);
                break;

            case "Decimal":
                ret = this.AddDecimalColumn(PropertyType.Name, PropertyType.Label, PropertyType.ColumnWidth);
                break;

            case "Federated":
                ret = this.AddFederatedColumn(PropertyType.Name, PropertyType.Label, PropertyType.ColumnWidth);
                break;

            case "Integer":
                ret = this.AddIntegerColumn(PropertyType.Name, PropertyType.Label, PropertyType.ColumnWidth);
                break;

            case "Item":
                ret = this.AddItemColumn(PropertyType.Name, PropertyType.Label, PropertyType.ColumnWidth, Query);
                break;

            case "List":
                ret = this.AddListColumn(PropertyType.Name, PropertyType.Label, PropertyType.ColumnWidth);
                break;

            case "Sequence":
                ret = this.AddSequenceColumn(PropertyType.Name, PropertyType.Label, PropertyType.ColumnWidth);
                break;

            case "String":
                ret = this.AddStringColumn(PropertyType.Name, PropertyType.Label, PropertyType.ColumnWidth);
                break;

            case "Text":
                ret = this.AddTextColumn(PropertyType.Name, PropertyType.Label, PropertyType.ColumnWidth);
                break;

            default:
                throw new Model.Exceptions.ArgumentException("PropertyType not implemented: " + PropertyType.GetType().Name);
            }

            return(ret);
        }
Example #4
0
        private String ConditionSQL(Model.Condition Condition)
        {
            switch (Condition.GetType().Name)
            {
            case "And":

                String andsql = "(";

                for (int i = 0; i < Condition.Children.Count(); i++)
                {
                    andsql += this.ConditionSQL(Condition.Children.ElementAt(i));

                    if (i < (Condition.Children.Count() - 1))
                    {
                        andsql += " and ";
                    }
                }

                andsql += ")";

                return(andsql);

            case "Or":

                String orsql = "(";

                for (int i = 0; i < Condition.Children.Count(); i++)
                {
                    orsql += this.ConditionSQL(Condition.Children.ElementAt(i));

                    if (i < (Condition.Children.Count() - 1))
                    {
                        orsql += " or ";
                    }
                }

                orsql += ")";

                return(orsql);

            case "Property":
                Model.Conditions.Property propcondition = (Model.Conditions.Property)Condition;
                Model.PropertyType        proptype      = this.ItemType.PropertyType(propcondition.Name);
                return("(" + this.Session.Table(proptype.ItemType).Name + "." + proptype.Name.ToLower() + this.OperatorSQL(propcondition.Operator) + this.ValueSQL(proptype, propcondition.Value) + ")");

            default:
                throw new NotImplementedException("Condition Type not implemented: " + Condition.GetType().Name);
            }
        }
Example #5
0
        private String ValueSQL(Model.PropertyType PropertyType, Object Value)
        {
            if (Value == null)
            {
                return("NULL");
            }
            else
            {
                switch (PropertyType.Type)
                {
                case Model.PropertyTypeValues.Double:
                case Model.PropertyTypeValues.List:
                    return(Value.ToString());

                case Model.PropertyTypeValues.Item:

                    if (Value is plmOS.Model.Item)
                    {
                        return("'" + ((plmOS.Model.Item)Value).BranchID.ToString() + "'");
                    }
                    else
                    {
                        return("'" + Value.ToString() + "'");
                    }

                case Model.PropertyTypeValues.String:
                    return("'" + Value.ToString().Replace("'", "''") + "'");

                case Model.PropertyTypeValues.DateTime:
                    return("'" + ((System.DateTime)Value).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fff") + "'");

                case Model.PropertyTypeValues.Boolean:

                    if ((Boolean)Value)
                    {
                        return("1");
                    }
                    else
                    {
                        return("0");
                    }

                default:
                    throw new NotImplementedException("Invalid PropertyType: " + PropertyType.Type);
                }
            }
        }
Example #6
0
        private Model.Condition Condition(Model.PropertyType PropertyType)
        {
            switch (PropertyType.GetType().Name)
            {
            case "String":
            case "Sequence":
            case "Text":
                return(Aras.Conditions.Like(PropertyType.Name, "%" + this.QueryString.Value + "%"));

            case "Integer":
                System.Int32 int32value = 0;

                if (System.Int32.TryParse(this.QueryString.Value, out int32value))
                {
                    return(Aras.Conditions.Eq(PropertyType.Name, int32value));
                }
                else
                {
                    return(null);
                }

            case "Decimal":
                System.Decimal decimalvalue = 0;

                if (System.Decimal.TryParse(this.QueryString.Value, out decimalvalue))
                {
                    return(Aras.Conditions.Eq(PropertyType.Name, decimalvalue));
                }
                else
                {
                    return(null);
                }

            default:
                return(null);
            }
        }
Example #7
0
        private Boolean MatchCondition(Model.Condition Condition)
        {
            switch (Condition.GetType().Name)
            {
            case "Property":

                Model.PropertyType proptype = this.ItemType.PropertyType(((Model.Conditions.Property)Condition).Name);
                Property           property = (Property)this.Property(proptype);

                switch (property.PropertyType.Type)
                {
                case Model.PropertyTypeValues.String:
                    String propvalue      = (String)property.Object;
                    String conditionvalue = (String)(((Model.Conditions.Property)Condition).Value);

                    switch (((Model.Conditions.Property)Condition).Operator)
                    {
                    case Model.Conditions.Operators.eq:
                        return(String.Compare(propvalue, conditionvalue, true) == 0);

                    case Model.Conditions.Operators.ge:
                        return((String.Compare(propvalue, conditionvalue, true) == 1) || (String.Compare(propvalue, conditionvalue, true) == 0));

                    case Model.Conditions.Operators.gt:
                        return(String.Compare(propvalue, conditionvalue, true) == 1);

                    case Model.Conditions.Operators.le:
                        return((String.Compare(propvalue, conditionvalue, true) == -1) || (String.Compare(propvalue, conditionvalue, true) == 0));

                    case Model.Conditions.Operators.lt:
                        return(String.Compare(propvalue, conditionvalue, true) == -1);

                    case Model.Conditions.Operators.ne:
                        return(String.Compare(propvalue, conditionvalue, true) != 0);

                    default:
                        throw new NotImplementedException("Condition Operator not implemeted: " + ((Model.Conditions.Property)Condition).Operator);
                    }

                case Model.PropertyTypeValues.Boolean:
                    Boolean boolvalue          = (Boolean)property.Object;
                    Boolean boolconditionvalue = (Boolean)(((Model.Conditions.Property)Condition).Value);

                    switch (((Model.Conditions.Property)Condition).Operator)
                    {
                    case Model.Conditions.Operators.eq:
                        return(boolvalue == boolconditionvalue);

                    case Model.Conditions.Operators.ne:
                        return(boolvalue != boolconditionvalue);

                    default:
                        throw new NotImplementedException("Condition Operator not implemeted: " + ((Model.Conditions.Property)Condition).Operator);
                    }

                default:
                    throw new NotImplementedException("PropertyType not implemented: " + property.PropertyType.Type);
                }

            default:
                throw new NotImplementedException("Condition Type not implemneted: " + Condition.GetType().Name);
            }
        }
Example #8
0
 public IProperty Property(Model.PropertyType PropertyType)
 {
     return(this._properties[PropertyType]);
 }
Example #9
0
        private void Read(FileInfo XMLFile)
        {
            // Load XML
            XmlDocument doc = new XmlDocument();

            doc.Load(XMLFile.FullName);

            // Get Item Node
            XmlNode item = doc.SelectSingleNode("Item");

            // Load Item Attributes
            this.ReadItemAttributes(doc, item);

            // Load Properties
            this._properties = new Dictionary <Model.PropertyType, Property>();

            XmlNode properties = item.SelectSingleNode("Properties");

            foreach (XmlNode property in properties.ChildNodes)
            {
                Model.PropertyType proptype = this.ItemType.PropertyType(property.Attributes["Name"].Value);
                Object             value    = null;

                if (property.Attributes["Value"].Value != null)
                {
                    switch (proptype.Type)
                    {
                    case Model.PropertyTypeValues.DateTime:

                        if (!String.IsNullOrEmpty(property.Attributes["Value"].Value))
                        {
                            value = DateTime.Parse(property.Attributes["Value"].Value).ToLocalTime();
                        }

                        break;

                    case Model.PropertyTypeValues.Double:
                        value = Double.Parse(property.Attributes["Value"].Value);
                        break;

                    case Model.PropertyTypeValues.Item:
                        value = Guid.Parse(property.Attributes["Value"].Value);
                        break;

                    case Model.PropertyTypeValues.String:
                        value = property.Attributes["Value"].Value;
                        break;

                    case Model.PropertyTypeValues.List:
                        value = Int32.Parse(property.Attributes["Value"].Value);
                        break;

                    case Model.PropertyTypeValues.Boolean:
                        value = Boolean.Parse(property.Attributes["Value"].Value);
                        break;

                    default:
                        throw new NotImplementedException("Propertype not implemented: " + proptype.Type.ToString());
                    }
                }

                this._properties[proptype] = new Property(this, proptype, value);
            }
        }
Example #10
0
        public ViewModel.Property CreateProperty(Model.PropertyType PropertyType, System.Boolean SubstitueStringForText)
        {
            ViewModel.Property viewmodelproperty = null;

            switch (PropertyType.GetType().Name)
            {
            case "String":
                viewmodelproperty = new Properties.String(this, (Model.PropertyTypes.String)PropertyType);
                break;

            case "Federated":
                viewmodelproperty = new Properties.Federated(this, (Model.PropertyTypes.Federated)PropertyType);
                break;

            case "Integer":
                viewmodelproperty = new Properties.Integer(this, (Model.PropertyTypes.Integer)PropertyType);
                break;

            case "Float":
                viewmodelproperty = new Properties.Float(this, (Model.PropertyTypes.Float)PropertyType);
                break;

            case "Sequence":
                viewmodelproperty = new Properties.Sequence(this, (Model.PropertyTypes.Sequence)PropertyType);
                break;

            case "Item":
                viewmodelproperty = new Properties.Item(this, (Model.PropertyTypes.Item)PropertyType);
                break;

            case "Decimal":
                viewmodelproperty = new Properties.Decimal(this, (Model.PropertyTypes.Decimal)PropertyType);
                break;

            case "Date":
                viewmodelproperty = new Properties.Date(this, (Model.PropertyTypes.Date)PropertyType);
                break;

            case "Text":

                if (SubstitueStringForText)
                {
                    viewmodelproperty = new Properties.String(this, (Model.PropertyTypes.Text)PropertyType);
                }
                else
                {
                    viewmodelproperty = new Properties.Text(this, (Model.PropertyTypes.Text)PropertyType);
                }

                break;

            case "Boolean":
                viewmodelproperty = new Properties.Boolean(this, (Model.PropertyTypes.Boolean)PropertyType);
                break;

            case "List":
                viewmodelproperty = new Properties.List(this, (Model.PropertyTypes.List)PropertyType);
                break;

            default:
                throw new Model.Exceptions.ArgumentException("PropertyType not implmented: " + PropertyType.GetType().Name);
            }

            return(viewmodelproperty);
        }
Example #11
0
 public Column AddColumn(Model.PropertyType PropertyType)
 {
     return(this.AddColumn(PropertyType, null));
 }
Example #12
0
 internal Property(Item Item, Model.PropertyType PropertyType, Object Object)
 {
     this.Item         = Item;
     this.PropertyType = PropertyType;
     this.Object       = Object;
 }