示例#1
0
        private void FrmProperties_Load(object sender, EventArgs e)
        {
            string Query = @"select a.ProductID,
                                    a.ID,
                                    a.PropertiesID,
                                    a.PropertiesGroupID,
                                    a.PropertiesValueID,
                                    b.Name,
                                    c.Value,
                                    b.Unit,
                                    a.Valid
                                     from Product_Properties a
                                     inner join Properties b 
                                     on a.PropertiesID = b.ID
                                     inner join PropertiesValue c 
                                     on a.PropertiesValueID = c.ID where a.ProductID = @ProductID order by a.STT";

            using (IDbConnection db = new SqlConnection(_connectionString))
            {
                Dictionary <string, string> dicRootProperties = new Dictionary <string, string>();
                var lstPropertyRoot = db.Query <Property>(Query, new { ProductID = _rootId }).ToList();
                foreach (var item in lstPropertyRoot)
                {
                    dicRootProperties.Add(item.Name, item.Value);
                }
                var lstProduct = db.Query <Product>("Select ID from product where ProductID = @ProductID", new { ProductID = _rootId }).ToList();
                foreach (var product in lstProduct)
                {
                    var lstPropertyProduct = _cacheMan.Get <List <KeyValuePair <string, string> > >("prs:" + product.ID.ToString(), true);
                    if (lstPropertyProduct != null)
                    {
                        foreach (var productProperties in lstPropertyProduct)
                        {
                            if (!dicRootProperties.ContainsKey(productProperties.Key))
                            {
                                lstPropertyRoot.Add(new Property {
                                    Valid = false, Name = productProperties.Key, Value = productProperties.Value
                                });
                            }
                        }
                    }
                }

                gridControlProperties.DataSource = lstPropertyRoot;
                dicRootProperties.Clear();
            }
        }
示例#2
0
        public void MapData(string domain)
        {
            this.database  = RedisManager.GetRedisServer("redisPropertiesProduct").GetDatabase(1);
            this._cacheMan = CacheManager.GetCacheServer("redisPropertiesProduct");

            int    i             = 0;
            string PropertyName  = "";
            string PropertyValue = "";
            long   PropertyID    = 0;
            long   companyID     = LibExtra.CommonConvert.Obj2Int64(this.sqldb.GetTblData(string.Format("Select ID from Company where Domain = '{0}'", domain)).Rows[0]["ID"]);

            this.sqldb.ProcessDataTableLarge(string.Format("select ID,ClassificationID from product where company = {0} order by ID", companyID), 1000, (obj, iRow) =>
            {
                long ProductID        = CommonConvert.Obj2Int64(obj["ID"]);
                long ClassificationID = CommonConvert.Obj2Int64(obj["ClassificationID"]);

                string ClassificationName = this.sqldb.GetTblData(string.Format("Select Name from Classification where ID = {0}", ClassificationID)).Rows[0]["Name"].ToString();

                var lstProperties = _cacheMan.Get <List <KeyValuePair <string, string> > >("prs:" + ProductID, true);
                if (lstProperties != null && lstProperties.Count > 0)
                {
                    foreach (var item in lstProperties)
                    {
                        PropertyName  = ClassificationName + ":" + item.Key.ToString();
                        PropertyValue = item.Value.ToString();
                        PropertyID    = CommonConvert.CrcProductID(PropertyName);
                    }
                    string querytest = string.Format("Insert into PropertyItem (PropertyID, ProductID, Value) values ({0},{1},N'{2}')", PropertyID, ProductID, PropertyValue);
                    sqldbProperties.RunQuery(string.Format("Insert into Category (ID, Name, CompanyID) values ({0},N'{1}',{2})", ClassificationID, ClassificationName, companyID), CommandType.Text, new System.Data.SqlClient.SqlParameter[] { });
                    sqldbProperties.RunQuery(string.Format("Insert into Properties (ID,CategoryID, Name, CompanyID) values ({0},{1},N'{2}',{3})", PropertyID, ClassificationID, PropertyName, companyID), CommandType.Text, new System.Data.SqlClient.SqlParameter[] { });
                    sqldbProperties.RunQuery(string.Format("Insert into Product_PropertyCategory (ID, CompanyId, Name,Property_Id,CategoryID) values ({0},{1},N'{2}',{3},{4})", ProductID, companyID, PropertyName, PropertyID, ClassificationID), CommandType.Text, new System.Data.SqlClient.SqlParameter[] { });
                    sqldbProperties.RunQuery(querytest, CommandType.Text, new System.Data.SqlClient.SqlParameter[] { });
                }
                i++;
                log.InfoFormat("{0} {1}", i, ProductID);
                return(true);
            });
        }