public static void ExportProduct(String AID_PART) { String ConnStr = String.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Persist Security Info=True", Settings.GetValue("WebSpiderDB")); OleDbConnection OleConn = new OleDbConnection(ConnStr); FinalTableManager finalTableManager = new FinalTableManager(ConnStr); AdiChildManager adiChildManager = new AdiChildManager(ConnStr); AdiInventoryDetailsManager adiExportInventoryDetailsManager = new AdiInventoryDetailsManager(ConnStr); AdiInventoryManager adiInventoryManager = new AdiInventoryManager(ConnStr); String DateFormat = Settings.GetValue("DateFormat"); #region [ Product Specification ] adiChildManager.Delete(AID_PART); //List<WebSpider.Objects.AdiGlobal.ADIChild> productSpecification = adiProductSpecificationManager.GetDataByPartNumber(AID_PART); //foreach (var ps in productSpecification) //{ // var child = new WebSpider.Objects.AdiExport.ADI_Child() // { // PART_NUM = ps.PART_NUM, // PropertyName = ps.PropertyName, // PropertyValue = ps.PropertyValue // }; // adiChildManager.Save(child); //} #region [ Bulk Insert ] DataTable prdSpecs = adiProductSpecificationManager.GetDataTableByPartNumber(AID_PART); string SQLps = "SELECT * FROM ADIChild WHERE ID IS NULL"; string INSERTps = "INSERT INTO ADIChild (PART_NUM, PropertyName, PropertyValue)" + " VALUES (@PART_NUM, @PropertyName, @PropertyValue)"; OleDbDataAdapter OleAdpPs = new OleDbDataAdapter(SQLps, OleConn); DataTable dtPs = new DataTable(); OleAdpPs.Fill(dtPs); foreach (DataRow dRow in prdSpecs.Rows) { dtPs.Rows.Add(dtPs.NewRow().ItemArray = dRow.ItemArray); } OleAdpPs.InsertCommand = new OleDbCommand(INSERTps); OleAdpPs.InsertCommand.Parameters.Add("@PART_NUM", OleDbType.VarChar, 255, "PART_NUM"); OleAdpPs.InsertCommand.Parameters.Add("@PropertyName", OleDbType.VarChar, 255, "PropertyName"); OleAdpPs.InsertCommand.Parameters.Add("@PropertyValue", OleDbType.VarChar, 4000, "PropertyValue"); OleAdpPs.InsertCommand.Connection = OleConn; OleAdpPs.InsertCommand.Connection.Open(); OleAdpPs.Update(dtPs); OleAdpPs.InsertCommand.Connection.Close(); #endregion #endregion #region [ Inventory Details ] adiExportInventoryDetailsManager.Delete(AID_PART); //List<ADIInventoryDetails> inventoryDetails = adiInventoryDetailsManager.GetDataByPartNumber(AID_PART); //foreach (ADIInventoryDetails detail in inventoryDetails) //{ // adiExportInventoryDetailsManager.Save(AID_PART, detail.id, detail.dc, detail.region, detail.storeName // , detail.address1, detail.address2, detail.address3, detail.country, detail.city, detail.state // , detail.stateName, detail.zip, detail.phone, detail.fax, detail.lat, detail.lon, detail.inventory // , detail.manager, detail.responseCode, detail.responseMessage, detail.IsHub, detail.LastUpdate); //} #region [ Bulk Insert ] DataTable inventoryDetails = adiInventoryDetailsManager.GetDataTableByPartNumber(AID_PART); string SQLid = "SELECT * FROM AdiInventoryDetails WHERE 1=0;"; string INSERTid = "INSERT INTO AdiInventoryDetails (AdiNumber, id, dc, region, storeName, address1, address2, address3, country, city, state, stateName, zip, phone, fax, lat, lon, inventory, manager, responseCode, responseMessage, IsHub, LastUpdate)" + " VALUES (@AdiNumber, @id, @dc, @region, @storeName, @address1, @address2, @address3, @country, @city, @state, @stateName, @zip, @phone, @fax, @lat, @lon, @inventory, @manager, @responseCode, @responseMessage, @IsHub, @LastUpdate )"; OleDbDataAdapter OleAdpId = new OleDbDataAdapter(SQLid, OleConn); DataTable dtId = new DataTable(); OleAdpId.Fill(dtId); foreach (DataRow dRow in inventoryDetails.Rows) { dtId.Rows.Add(dtId.NewRow().ItemArray = dRow.ItemArray); } OleAdpId.InsertCommand = new OleDbCommand(INSERTid); OleAdpId.InsertCommand.Parameters.Add("@AdiNumber", OleDbType.VarChar, 255, "AdiNumber"); OleAdpId.InsertCommand.Parameters.Add("@id", OleDbType.VarChar, 255, "id"); OleAdpId.InsertCommand.Parameters.Add("@dc", OleDbType.VarChar, 255, "dc"); OleAdpId.InsertCommand.Parameters.Add("@region", OleDbType.VarChar, 255, "region"); OleAdpId.InsertCommand.Parameters.Add("@storeName", OleDbType.VarChar, 255, "storeName"); OleAdpId.InsertCommand.Parameters.Add("@address1", OleDbType.VarChar, 255, "address1"); OleAdpId.InsertCommand.Parameters.Add("@address2", OleDbType.VarChar, 255, "address2"); OleAdpId.InsertCommand.Parameters.Add("@address3", OleDbType.VarChar, 255, "address3"); OleAdpId.InsertCommand.Parameters.Add("@country", OleDbType.VarChar, 255, "country"); OleAdpId.InsertCommand.Parameters.Add("@city", OleDbType.VarChar, 255, "city"); OleAdpId.InsertCommand.Parameters.Add("@state", OleDbType.VarChar, 255, "state"); OleAdpId.InsertCommand.Parameters.Add("@stateName", OleDbType.VarChar, 255, "stateName"); OleAdpId.InsertCommand.Parameters.Add("@zip", OleDbType.VarChar, 255, "zip"); OleAdpId.InsertCommand.Parameters.Add("@phone", OleDbType.VarChar, 255, "phone"); OleAdpId.InsertCommand.Parameters.Add("@fax", OleDbType.VarChar, 255, "fax"); OleAdpId.InsertCommand.Parameters.Add("@lat", OleDbType.Single, 8, "lat"); OleAdpId.InsertCommand.Parameters.Add("@lon", OleDbType.Single, 8, "lon"); OleAdpId.InsertCommand.Parameters.Add("@inventory", OleDbType.VarChar, 255, "inventory"); OleAdpId.InsertCommand.Parameters.Add("@manager", OleDbType.VarChar, 255, "manager"); OleAdpId.InsertCommand.Parameters.Add("@responseCode", OleDbType.VarChar, 255, "responseCode"); OleAdpId.InsertCommand.Parameters.Add("@responseMessage", OleDbType.VarChar, 255, "responseMessage"); OleAdpId.InsertCommand.Parameters.Add("@IsHub", OleDbType.Boolean, 8, "IsHub"); OleAdpId.InsertCommand.Parameters.Add("@LastUpdate", OleDbType.VarChar, 255, "LastUpdate"); OleAdpId.InsertCommand.Connection = OleConn; OleAdpId.InsertCommand.Connection.Open(); OleAdpId.Update(dtId); OleAdpId.InsertCommand.Connection.Close(); #endregion #endregion #region [ Inventory Export ] ADIInventoryExport inventoryExport = adiInventoryExportManager.GetDataByProduct(AID_PART); if (!ReferenceEquals(inventoryExport, null)) { adiInventoryManager.Save(inventoryExport.ID, inventoryExport.PART_NUM, inventoryExport.TotalInventory, inventoryExport.Dallas , inventoryExport.DC_AtlantaHub, inventoryExport.DC_Dallas_Hub, inventoryExport.DC_Elk_Grove_Hub, inventoryExport.DC_Feura_Bush , inventoryExport.DC_Louisville_Hub, inventoryExport.DC_Reno_Hub, inventoryExport.DC_Richmond_Dist_Ctr, inventoryExport.Oklahama , inventoryExport.RemainingBranches, inventoryExport.LastUpdate); } #endregion #region [ Product ] List<AdiProduct> productList = adiProductManager.GetDataByPartNum(AID_PART); foreach (var p in productList) { //finalTableManager.SaveAdiPart(0, "", p.AdiNumber, p.ProductDescription, p.ProductImagePath // , p.ProductID, p.AdiNumber, (decimal)(p.Price == null ? 0 : p.Price), p.BigImage, p.SmallImage, p.VendorName, "0", p.LastUpdateDatetime.ToString(DateFormat)); //finalTableManager.UpdateFlagsByAdiProduct(p.AdiNumber, p.ClearanceZone, p.HotDeals, p.OnlineSpecials, p.SaleCenter, p.InStock, p.LastUpdateDatetime.ToString(DateFormat)); String inv = "0"; if (!ReferenceEquals(inventoryExport, null) && inventoryExport.TotalInventory != null) { //finalTableManager.UpdateInvBYPartNO(inventoryExport.TotalInventory.ToString(), DateTime.Now.ToString(Settings.GetValue("DateFormat")), inventoryExport.PART_NUM); inv = inventoryExport.TotalInventory.ToString(); } finalTableManager.SaveAdiPart(0, "", p.AdiNumber, p.ProductDescription, p.ProductImagePath , p.ProductID, p.AdiNumber, (decimal)(p.Price == null ? 0 : p.Price), p.BigImage, p.SmallImage, p.VendorName, inv , p.ClearanceZone, p.HotDeals, p.OnlineSpecials, p.SaleCenter, p.InStock, p.LastUpdateDatetime.ToString(DateFormat)); } #endregion }
public static void SaveFinalTableWithInventory(AdiProduct product, double totalInventory) { FinalTableManager fadapter = new FinalTableManager(finalcon); int count = fadapter.GetDataByAdiPart(product.AdiNumber).Count; if (count == 1) { fadapter.UpdateInvBYPartNO(totalInventory.ToString(), DateTime.Now.ToString(Settings.GetValue("DateFormat")), product.AdiNumber); } }