示例#1
0
        public static CatalogModel GetCBOMV2CatalogModel(string salesOrg, string cbomOrg, string companyId)
        {
            // 1. Get all records include Root, catalogs, components from DB
            List <CBOMV2Model.CBOMV2Catalog> catalogRecords = CBOMV2Model.GetCBOMV2CatalogRecords(salesOrg, cbomOrg, companyId);

            CBOMV2Model.CBOMV2Catalog rootRecord = catalogRecords.Where(d => d.CatalogName.Equals(cbomOrg + "_Root")).FirstOrDefault();
            catalogRecords.RemoveAll(d => d.CatalogType == CatalogType.Component && !isPartOrdereable((d.CatalogName.Contains("/") ? d.CatalogName.Split('/')[0] : d.CatalogName), salesOrg));

            // 2. Convert DB records to standard ViewModel CatalogModel
            CatalogModel rootModel = new CatalogModel(rootRecord.Id, "", "", 2, salesOrg, cbomOrg, rootRecord.CatalogName, "", CatalogType.Root, rootRecord.HieId);

            if (catalogRecords != null && catalogRecords.Count > 0)
            {
                CBOMV2CatalogData2Model(catalogRecords, rootModel);
            }

            return(rootModel);
        }
示例#2
0
        public static ConfiguratorModel GetCBOMV2ConfiguratorModel(string rootId, string salesOrg, string cbomOrg)
        {
            // 1. Get all records include Root, categories, components from DB
            List <CBOMV2Model.CBOMV2Category> categoryRecords = CBOMV2Model.GetCBOMV2CategoryData(rootId, salesOrg, cbomOrg);

            CBOMV2Model.CheckSharedCategory(new List <String>(), ref categoryRecords);
            categoryRecords.RemoveAll(item => (item.CategoryType == CategoryType.Component || item.CategoryType == CategoryType.SharedComponent) && !isPartOrdereable(item.CategoryName, salesOrg));
            CBOMV2Model.CBOMV2Category rootRecord = (from q in categoryRecords where (q.Id.Equals(rootId) || q.Level == 2) select q).ToList().FirstOrDefault();

            // 2. Convert DB records to ConfiguratorRecord which contains whole tree structure
            ConfiguratorRecord rootNode = new ConfiguratorRecord(rootRecord.Id, rootRecord.CategoryName, rootRecord.CategoryDesc, 0, CategoryType.Root, 1, 1, true, false, true, false, rootRecord.HieId);

            CBOMV2ConfiguratorData2Model(categoryRecords, rootNode);

            // 3. Add rootNode to standard ViewModel ConfiguratorModel
            ConfiguratorModel rootModel = new ConfiguratorModel(salesOrg, cbomOrg, 2, "", "", rootNode);

            return(rootModel);
        }