Пример #1
0
        public static void ExportProductUpdate(String AID_PART)
        {
            String ConnStr = String.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Persist Security Info=True", Settings.GetValue("FinalTable"));
            OleDbConnection OleConn = new OleDbConnection(ConnStr);
            UpdateFinalTableManager finalTableManager = new UpdateFinalTableManager(ConnStr);
            AdiChildManager adiChildManager = new AdiChildManager(ConnStr);
            String DateFormat = Settings.GetValue("DateFormat");

            List<AdiProduct> productList = adiProductManager.GetDataByPartNum(AID_PART);
            foreach (var p in productList)
                finalTableManager.SaveAdiPart(0, "", p.PartNumber, 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));

            //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 [ Product Specification]
            adiProductSpecificationManager.Delete(AID_PART);

            #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, 255, "PropertyValue");
            OleAdpPs.InsertCommand.Connection = OleConn;
            OleAdpPs.InsertCommand.Connection.Open();
            OleAdpPs.Update(dtPs);
            OleAdpPs.InsertCommand.Connection.Close();
            #endregion
            #endregion

            //List<ADIInventoryDetails> inventoryDetails = adiInventoryDetailsManager.GetDataByPartNumber(AID_PART);

            //ADIInventoryExport inventoryExport = adiInventoryExportManager.GetDataByProduct(AID_PART);
        }