public void FattanToSql(PropertyProduct propertyData) { foreach (var VARIABLE in propertyData.Properties) { string propertyName = propertyData.Category + ":" + VARIABLE.Key; long propertyID = CommonConvert.CrcProductID(propertyName); bool bOk = this.sqlDbProperties.RunQuery("sp_Property_Ins", CommandType.StoredProcedure, new[] { SqlDb.CreateParamteterSQL("CategoryID", propertyData.CategoryId, SqlDbType.BigInt), SqlDb.CreateParamteterSQL("CategoryName", propertyData.Category, SqlDbType.NVarChar), SqlDb.CreateParamteterSQL("ProperyID", propertyID, SqlDbType.BigInt), SqlDb.CreateParamteterSQL("ProperyValue", VARIABLE.Value, SqlDbType.NVarChar), SqlDb.CreateParamteterSQL("CompanyID", propertyData.CompanyID, SqlDbType.BigInt), SqlDb.CreateParamteterSQL("ProductID", propertyData.ProductId, SqlDbType.BigInt), SqlDb.CreateParamteterSQL("PropertyName", propertyName, SqlDbType.NVarChar), }); } }
public async void UpdateCategoryId() { var filter = new BsonDocument(); var count = 0; using (var cursor = await _colPropertiesData.FindAsync(filter)) { while (await cursor.MoveNextAsync()) { var batch = cursor.Current; foreach (var document in batch) { var propertyData = BsonSerializer.Deserialize <PropertyProduct>(document); if (propertyData != null) { if (propertyData.ProductId == 0) { this._colPropertiesData.DeleteOne(document); this._log.Info(string.Format("Delete item")); } else { propertyData.CategoryId = CommonConvert.CrcProductID(propertyData.Category); var update = Builders <BsonDocument> .Update .Set("category_id", propertyData.CategoryId) .CurrentDate("lastModified"); this._colPropertiesData.UpdateOne(document, update); _log.Info(string.Format("Updated for item {0} {1}", propertyData._id, propertyData.ProductId)); } } else { _log.Info("ProductData null"); } _log.Info(string.Format("Process {0} items ", count)); count++; } } } }
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); }); }
public PropertyProduct ParseData(HtmlDocument document) { PropertyProduct propertyData = new PropertyProduct(); propertyData.Category = ""; propertyData.Domain = _configPropertyNomal.Domain; propertyData.CategoryId = CommonConvert.CrcProductID(propertyData.Category); var nodeRows = document.DocumentNode.SelectNodes(_configPropertyNomal.XPath); dynamic configOtherData = JObject.Parse(_configPropertyNomal.JSonOtherConfig); string colH = configOtherData.IndexColHeader.ToString(); string colB = configOtherData.IndexColData.ToString(); if (nodeRows != null) { foreach (var variable in nodeRows) { var nodeCell = variable.SelectNodes("./td"); if (nodeCell != null) { try { if (!string.IsNullOrEmpty(nodeCell[Convert.ToInt32(colH)].InnerText.Trim()) && !string.IsNullOrEmpty(nodeCell[Convert.ToInt32(colB)].InnerText.Trim())) { propertyData.Properties.Add( nodeCell[Convert.ToInt32(colH)].InnerText.Trim(), nodeCell[Convert.ToInt32(colB)].InnerText.Trim()); } } catch (Exception ex) { // ignored } } } } return(propertyData); }