Exemplo n.º 1
0
        internal Table(Session Session, Model.ItemType ItemType)
        {
            this.Session  = Session;
            this.ItemType = ItemType;

            // Set Name
            this._name = this.ItemType.Name.ToLower().Replace('.', '_');

            // Load Columns
            this.CheckColumns();
        }
Exemplo n.º 2
0
        private void Insert(IItem Item, Model.ItemType ItemType, Transaction Transaction)
        {
            // Insert into base table

            if (ItemType.BaseItemType != null)
            {
                this.Insert(Item, ItemType.BaseItemType, Transaction);
            }

            // Insert into Table
            this.TableCache[ItemType].Insert(Item, Transaction);
        }
Exemplo n.º 3
0
 private void cmbCategories_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cmbCategories.SelectedIndex != -1)
     {
         Model.ItemType selectedType = (Model.ItemType)Enum.Parse(typeof(Model.ItemType), cmbCategories.SelectedItem.ToString());
         dgvItemsList.DataSource = Database.db_Items.currentItems.Items.Where(x => x.Type == selectedType).ToList();
     }
     else
     {
         ResetList();
     }
 }
Exemplo n.º 4
0
        public Item(Manager.Session Session, Model.ItemType ItemType, String Properties)
            : base(Session)
        {
            // Create Property Cache
            this.PropertyCache = new Dictionary <Model.PropertyType, Property>();

            // Store ItemType
            this.ItemType = ItemType;

            // Build Properties
            this.BuildProperties(Properties);
        }
Exemplo n.º 5
0
        public void Create(Model.ItemType ItemType)
        {
            if (!this.TableCache.ContainsKey(ItemType))
            {
                if (ItemType.Name.Equals(RootItemTypeName))
                {
                    this.RootItemType = ItemType;
                }
                else if (ItemType.Name.Equals(RootFileTypeName))
                {
                    this.RootFileType = ItemType;
                }

                this.TableCache[ItemType]       = new Table(this, ItemType);
                this.ItemTypeCache[ItemType.ID] = ItemType;
            }
        }
Exemplo n.º 6
0
        public IItem Get(Model.ItemType ItemType, Guid BranchID)
        {
            this.Load();

            if (this.ItemCache.ContainsKey(ItemType))
            {
                foreach (Item item in this.ItemCache[ItemType].Values)
                {
                    if (item.Superceded == -1 && item.BranchID == BranchID)
                    {
                        return(item);
                    }
                }
            }

            return(null);
        }
Exemplo n.º 7
0
        public async Task <ObjectResult> Post([FromBody] PostRequestDto postRequestDto)
        {
            var itemType =
                new Model.ItemType(
                    id: Guid.NewGuid(),
                    code: postRequestDto.Code);

            await _itemTypeRepository.SaveAsync(itemType, DateTimeOffset.UtcNow);

            var dto = new ItemTypeDto
            {
                Id   = itemType.Id,
                Code = itemType.Code
            };

            var url = Url.Action(nameof(Get), new { id = itemType.Id });

            return(Created(url, dto));
        }
Exemplo n.º 8
0
        public void JsonSchema_Multiple_Properties_Same_Numeric_Type_Multiplicity_1()
        {
            var model = new CogsModel();

            var type = new Model.ItemType();

            type.Name        = "Reusable1";
            type.Description = "Description One";

            var property1 = new Model.Property();

            property1.Name        = "Property1";
            property1.Description = "Description One";
            property1.DataType    = new Model.DataType {
                Name = "int"
            };
            property1.MinCardinality = "0";
            property1.MaxCardinality = "1";
            type.Properties.Add(property1);

            var property2 = new Model.Property();

            property2.Name        = "Property2";
            property2.Description = "Description Two";
            property2.DataType    = new Model.DataType {
                Name = "int"
            };
            property2.MinCardinality = "0";
            property2.MaxCardinality = "1";
            type.Properties.Add(property2);


            model.ItemTypes.Add(type);

            var jsonPublisher = new JsonPublisher();

            jsonPublisher.TargetDirectory = Environment.CurrentDirectory;
            jsonPublisher.Publish(model);

            Assert.True(true);
        }
Exemplo n.º 9
0
 public IItem Get(Model.ItemType ItemType, Guid BranchID)
 {
     return(this.TableCache[ItemType].Select(BranchID));
 }
Exemplo n.º 10
0
 internal Table Table(Model.ItemType ItemType)
 {
     return(this.TableCache[ItemType]);
 }
Exemplo n.º 11
0
 public void Create(Model.ItemType ItemType)
 {
     this.ItemTypeCache[ItemType.Name] = ItemType;
 }
Exemplo n.º 12
0
        private void SetItemProperties(Item Item, SqlDataReader Reader, int StartIndex)
        {
            int cnt = StartIndex;

            foreach (Model.PropertyType proptype in this.ItemType.PropertyTypes)
            {
                switch (proptype.Type)
                {
                case Model.PropertyTypeValues.Boolean:

                    if (Reader.IsDBNull(cnt))
                    {
                        Item.AddProperty(new Property(Item, proptype, null));
                    }
                    else
                    {
                        Item.AddProperty(new Property(Item, proptype, Reader.GetBoolean(cnt)));
                    }

                    break;

                case Model.PropertyTypeValues.Double:

                    if (Reader.IsDBNull(cnt))
                    {
                        Item.AddProperty(new Property(Item, proptype, null));
                    }
                    else
                    {
                        Item.AddProperty(new Property(Item, proptype, Reader.GetDouble(cnt)));
                    }

                    break;

                case Model.PropertyTypeValues.Item:

                    if (Reader.IsDBNull(cnt))
                    {
                        Item.AddProperty(new Property(Item, proptype, null));
                    }
                    else
                    {
                        Guid           branchid = Reader.GetGuid(cnt);
                        Model.ItemType itemtype = ((Model.PropertyTypes.Item)proptype).PropertyItemType;
                        Item.AddProperty(new Property(Item, proptype, branchid));
                    }

                    break;

                case Model.PropertyTypeValues.String:

                    if (Reader.IsDBNull(cnt))
                    {
                        Item.AddProperty(new Property(Item, proptype, null));
                    }
                    else
                    {
                        Item.AddProperty(new Property(Item, proptype, Reader.GetString(cnt)));
                    }

                    break;

                case Model.PropertyTypeValues.DateTime:

                    if (Reader.IsDBNull(cnt))
                    {
                        Item.AddProperty(new Property(Item, proptype, null));
                    }
                    else
                    {
                        Item.AddProperty(new Property(Item, proptype, Reader.GetDateTime(cnt).ToLocalTime()));
                    }

                    break;

                case Model.PropertyTypeValues.List:

                    if (Reader.IsDBNull(cnt))
                    {
                        Item.AddProperty(new Property(Item, proptype, null));
                    }
                    else
                    {
                        Item.AddProperty(new Property(Item, proptype, Reader.GetInt32(cnt)));
                    }

                    break;

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

                cnt++;
            }
        }