Exemple #1
0
        private void btnDA_Click(object sender, EventArgs e)
        {
            var ds  = new AWDataSet();
            var dta = new ProductTableAdapter();

            dta.Adapter.SelectCommand = new SqlCommand("SELECT ProductID, Name, ProductNumber, MakeFlag, FinishedGoodsFlag, Color, SafetyStockLevel, ReorderPoint, StandardCost, ListPrice, Size, SizeUnitMeasureCode, WeightUnitMeasureCode, Weight, DaysToManufacture, ProductLine, Class, Style, ProductSubcategoryID, ProductModelID, SellStartDate, SellEndDate, DiscontinuedDate, rowguid, ModifiedDate FROM Production.Product where ProductSubcategoryID is not null");
            dta.Fill(ds.Product);
            consola.Text = "";
            foreach (var rslt in ds.Product
                     .Where(p => p.ProductSubcategoryID == int.Parse(productCategoryIDLabel1.Text))
                     .Take(10)
                     .Select(p => new { id = p.ProductID, nombre = p.Name })
                     )
            {
                consola.Text += $"{rslt.id}\t{rslt.nombre}\n";
            }
            //ds.Product.AddProductRow()
//            var ds = new AWDataSet();
//            var dta = new ProductTableAdapter();
//            var dt = new DataTable();
//            var da = new SqlDataAdapter("SELECT ProductID, Name, ProductNumber, MakeFlag, FinishedGoodsFlag, Color, SafetyStockLevel, ReorderPoint, StandardCost, ListPrice, Size, SizeUnitMeasureCode, WeightUnitMeasureCode, Weight, DaysToManufacture, ProductLine, Class, Style, ProductSubcategoryID, ProductModelID, SellStartDate, SellEndDate, DiscontinuedDate, rowguid, ModifiedDate FROM Production.Product where ProductSubcategoryID is not null",
//                Settings.Default.AWConnectionString
//                );
//            da.Fill(dt);
//            consola.Text = "";
//            foreach(DataRow rslt in dt.Rows
//                //.Where(p => p.ProductSubcategoryID == int.Parse(productCategoryIDLabel1.Text))
//                //.Take(10)
//                //.Select(p => new { id = p.ProductID, nombre = p.Name})
//                ) {
//                    consola.Text += $"{rslt[0]}\t{rslt[1]}\n";
////                    consola.Text += $"{rslt.id}\t{rslt.nombre}\n";
//            }
//            //ds.Product.AddProductRow()
        }
Exemple #2
0
        //retrieve data using TableAdapter
        public static string GetProductNameByID(int ID)
        {
            //initialize tableadapter
            ProductTableAdapter productsAdapter = new ProductTableAdapter();

            string returnedValue = "";

            try
            {
                //access data from database
                string result = "Hello World";

                //get data from database using the tableadapter
                //commented out temporarily until the database is accessible
                // result = (string)productsAdapter.GetProductNameByID(ID);

                if (result != null)
                {
                    returnedValue = result;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Could not retrieve data for ID: '{0}'. Error: '{1}'", ID, e);
            }

            return(returnedValue);
        }
Exemple #3
0
        protected void btnAddItem_Click(object sender, EventArgs e)
        {
            try
            {
                DataRow Inventorydata = dsInventory.Product.NewRow(); // Create a new row of service_order table in memory
                                                                      //update record with user's input

                Inventorydata[1] = this.txtProduct.Text;
                Inventorydata[3] = this.ddlBrand.SelectedValue;

                Inventorydata[2] = this.txtDescription.Text;


                ProductTableAdapter ProductTable = new ProductTableAdapter();
                dsInventory.Product.Rows.Add(Inventorydata); // add the rows to the dataset


                ProductTable.Update(Inventorydata);
                // Call update method on the service adapter so it updates the table in memory ( All changes made are applied - CRUD)
                dsInventory.AcceptChanges();
                // Call accept method on the dataset so it update the chanmges to the database
                lblMessage.Text = "Created 1";

                //Refresh the page to show the record being deleted
                Response.Redirect("Default.aspx"); // Redirect the user to dexpage on to show created data

                lblMessage.Text = "Created";
            }
            catch
            {
                lblMessage.Text = "Failed";
            }
        }
Exemple #4
0
        private void FormProduct_Load(object sender, EventArgs e)
        {
            string        conn_str = "Server=.;Database=MiniMart;Integrated Security=true;";
            SqlConnection conn     = new SqlConnection(conn_str);

            cate_adapter            = new CategoryTableAdapter();
            cate_adapter.Connection = conn;
            cate_adapter.Fill(invent.Category);

            unit_adapter            = new UnitTypeTableAdapter();
            unit_adapter.Connection = conn;
            unit_adapter.Fill(invent.UnitType);

            pro_adapter            = new ProductTableAdapter();
            pro_adapter.Connection = conn;
            pro_adapter.Fill(invent.Product);

            //bind to controls
            cboCategory.DisplayMember = invent.Category.NameColumn.ColumnName;
            cboCategory.ValueMember   = invent.Category.IDColumn.ColumnName;
            cboCategory.DataSource    = invent.Category;

            cboUnitType.DisplayMember = invent.UnitType.NameColumn.ColumnName;
            cboUnitType.ValueMember   = invent.UnitType.IDColumn.ColumnName;
            cboUnitType.DataSource    = invent.UnitType;

            dataGridView1.DataSource = invent.Product;
            (dataGridView1.Columns[invent.Product.ImageColumn.ColumnName]  as DataGridViewImageColumn).ImageLayout = DataGridViewImageCellLayout.Zoom;

            lblTotal.Text = "Total: " + invent.Product.Rows.Count.ToString();
        }
        // this class is used to create objects from the data in the database, using the dataset
        private DatabaseController()
        {
            this.DataSet                     = new KantoorInrichtingDataSet();
            this.TableAdapterManager         = new KantoorInrichtingDataSetTableAdapters.TableAdapterManager();
            this.CategoryTableAdapter        = new KantoorInrichtingDataSetTableAdapters.categoryTableAdapter();
            this.ProductTableAdapter         = new KantoorInrichtingDataSetTableAdapters.productTableAdapter();
            this.PlacementTableAdapter       = new KantoorInrichtingDataSetTableAdapters.placementTableAdapter();
            this.RoleTableAdapter            = new KantoorInrichtingDataSetTableAdapters.roleTableAdapter();
            this.SpaceTableAdapter           = new KantoorInrichtingDataSetTableAdapters.spaceTableAdapter();
            this.StaticPlacementTableAdapter = new KantoorInrichtingDataSetTableAdapters.static_placementTableAdapter();
            this.StaticProductTableAdapter   = new KantoorInrichtingDataSetTableAdapters.static_productTableAdapter();
            this.UserTableAdapter            = new KantoorInrichtingDataSetTableAdapters.userTableAdapter();

            CategoryTableAdapter.Fill(DataSet.category);
            ProductTableAdapter.Fill(DataSet.product);
            PlacementTableAdapter.Fill(DataSet.placement);
            RoleTableAdapter.Fill(DataSet.role);
            SpaceTableAdapter.Fill(DataSet.space);
            StaticPlacementTableAdapter.Fill(DataSet.static_placement);
            StaticProductTableAdapter.Fill(DataSet.static_product);
            UserTableAdapter.Fill(DataSet.user);


            GetCategories_FromDatabase();
            GetProducts_FromDatabase();
            GetStaticProducts_FromDatabase();
            GetSpaces_FromDatabase();
        }
Exemple #6
0
 private void Form1_Load(object sender, EventArgs e)
 {
     BalanceTableAdapter.Fill(stockDataSet.Остатки);
     TaxingTableAdapter.Fill(stockDataSet.Таксировка);
     TaxTableAdapter.Fill(stockDataSet.Налоги);
     BankTableAdapter.Fill(stockDataSet.Банк);
     OrganizationTableAdapter.Fill(stockDataSet.Организация);
     InvoiceTableAdapter.Fill(stockDataSet.Накладные);
     MoveProductTableAdapter.Fill(stockDataSet.Движение_товара);
     DivisionsTableAdapter.Fill(stockDataSet.Подразделения);
     ProductTableAdapter.Fill(stockDataSet.Товар);
     CategoryTableAdapter.Fill(stockDataSet.Категории_товара);
 }
 /// <summary>
 /// GetDestinationNotes
 /// Function of Get Destination Notes
 /// </summary>
 /// <param name="destID">Destination ID</param>
 /// <param name="session">Session object</param>
 /// <returns>List of Destination Notes</returns>
 public static List <DAL.ProductRow> GetProducts(ISession session, String VersionNo = "")
 {
     try
     {
         ProductTableAdapter ta = new ProductTableAdapter();
         ta.CurrentConnection = session;
         return(ta.GetData().Select().Cast <DAL.ProductRow>().ToList());
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Exemple #8
0
        static DataModel()
        {
            // Create the data model and the table adapters.
            DataModel.dataSet = new DataSet();
            DataModel.customerTableAdapter = new CustomerTableAdapter();
            DataModel.licenseTableAdapter  = new LicenseTableAdapter();
            DataModel.productTableAdapter  = new ProductTableAdapter();

            // Load in the data from the SQL Server.
            DataModel.productTableAdapter.Fill(DataModel.dataSet.Product);
            DataModel.customerTableAdapter.Fill(DataModel.dataSet.Customer);
            DataModel.licenseTableAdapter.Fill(DataModel.dataSet.License);
        }
Exemple #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!User.Identity.IsAuthenticated)  //if not logged in
            {
                Response.Redirect("/");
            }

            if (this.IsPostBack)
            {
                return;
            }
            InventoryLookUpTableAdapter daInventory = new InventoryLookUpTableAdapter();
            ProductTableAdapter         daProduct   = new ProductTableAdapter();

            daInventory.Fill(dsInventory.InventoryLookUp);
            daProduct.Fill(dsInventory.Product);
        }
Exemple #10
0
        protected void myModal_Load(object sender, EventArgs e)
        {
            var id = this.Request.Params["idPN"];

            DS = new DataSetEcommerce();
            DS.EnforceConstraints = false;
            PTA = new ProductTableAdapter();

            PTA.FillByProductID(DS.Product, /*Int32.Parse(id)*/ 4).ToString();

            StringBuilder SB = new StringBuilder();

            foreach (DataSetEcommerce.ProductRow item in DS.Product)
            {
                SB.Append(item.Name);
            }

            cookieID.InnerHtml = SB.ToString() + " (Réf:" +/* id.ToString()*/ 4 + ")";
        }
Exemple #11
0
        private string GetImagePath(long id, ProductTableAdapter productAdapter)
        {
            var imagePath    = "";
            var productTable = new DBProduct.ProductDataTable();

            try
            {
                productAdapter.FillById(productTable, id);
                if (productTable.Rows.Count > 0)
                {
                    imagePath = productTable.Rows[0]["ImagePath"].ToString();
                }
            }
            catch (Exception exception)
            {
                Log.Error(id + exception.ToString());
            }
            return(imagePath);
        }
Exemple #12
0
        protected void ddlProducts_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.ddlProducts.SelectedValue == "new_item")
            {
                Response.Redirect("NewProduct.aspx");
            }

            ProductTableAdapter daInventory = new ProductTableAdapter();

            id = Convert.ToInt32(this.ddlProducts.SelectedValue);

            rows = dsInventory.Product.Select();

            foreach (DataRow r in rows)
            {
                if (Convert.ToInt32(r.ItemArray[0].ToString()) == id)
                {
                    this.txtBrand.Text       = r.ItemArray[3].ToString();
                    this.txtDescription.Text = r.ItemArray[2].ToString();
                }
            }
        }
Exemple #13
0
        public void AfficherCategorie()
        {
            var CategorieID = this.Request.Params["categoryId"];

            DS = new DataSetEcommerce();
            DS.EnforceConstraints = false;
            PTA = new ProductTableAdapter();

               PTA.FillByCategoryID(DS.Product, Convert.ToInt32(CategorieID));

            StringBuilder SBproduct = new StringBuilder();

            foreach (DataSetEcommerce.ProductRow item in DS.Product)
            {
                PICTA = new Product_Picture_MappingTableAdapter();
                int PictureID1 = PICTA.FillByGetPictureID(DS.Product_Picture_Mapping, item.Id);

                SBproduct.AppendFormat("<section><h1>{0} (Réf: {1})</h1><img src=\"a.imgg?Productid={1}\" alt=\"image du produit {0}\" height=\"150\" width=\"250\"><p>{2}</p><p><input type=\"button\" class=\"btn btn-info\" onclick='RequeteAjax({1})' value=\"Plus d'information\" /><p id=\"fullDescriptionProduit\"></p><p>Prix: {3}<button type=\"button\" class=\"btn btn-success\" data-toggle=\"modal\" data-target=\"#myModal\"><span class=\"glyphicon glyphicon-shopping-cart\" aria-hidden=\"true\"></span> Dans mon panier</button></p></section><hr/>", item.Name, item.Id, item.ShortDescription, item.Price);
            }

            ProduitsAff.InnerHtml = SBproduct.ToString();
        }
Exemple #14
0
        private static void ADOShowProducts()
        {
            int    counter      = 0;
            string prompt_input = "";

            if (DataADO.Product.Rows.Count == 0)
            {
                using (ProductTableAdapter ProdTabAdpt = new ProductTableAdapter())
                {
                    ProdTabAdpt.Fill(DataADO.Product);
                }
            }

            foreach (ADOM9Dataset.ProductRow Producto in DataADO.Product.Rows)
            {
                Console.WriteLine("ID: {0} " +
                                  "- Nombre producto {1}",
                                  Producto.ProductID,
                                  Producto.IsNull("Name") ? "----" : Producto.Name);
                counter++;

                if (counter % 10 == 0)
                {
                    Console.Write("Introduzca X para salir. Si quiere 10 elementos siguientes, pulse una tecla: ");
                    prompt_input = Console.ReadLine();

                    if (prompt_input.ToLower() == "x")
                    {
                        break;
                    }
                    else
                    {
                        continue;
                    }
                }
            }
        }
Exemple #15
0
 private void UpdateImagePathProduct(ImageProductInfo imageProductInfo, ProductTableAdapter productAdapter, JobClient historyJobClient, JobClient updateRedisJobClient)
 {
     while (_isRunning)
     {
         try
         {
             if (productAdapter.Connection.State == ConnectionState.Closed)
             {
                 productAdapter.Connection.Open();
             }
             productAdapter.UpdateImagePathAndValidAndIsNews(imageProductInfo.ImagePath, imageProductInfo.Id);
             Log.Info(string.Format("ProductId {0} : Update ImagePath And Valid success.", imageProductInfo.Id));
             break;
         }
         catch (Exception exception)
         {
             Log.Error(string.Format("ProductId {0} : Update ImagePath And Valid error.", imageProductInfo.Id), exception);
             Thread.Sleep(60000);
         }
     }
     SendMessageToServiceInsertHistoryDownload(new LogHistoryImageProduct
     {
         DateLog      = imageProductInfo.DownloadedTime,
         IsDownloaded = true,
         ErrorName    = string.Empty,
         ProductId    = imageProductInfo.Id,
         NewsToValid  = imageProductInfo.IsNew
     }, historyJobClient);
     if (imageProductInfo.IsNew)
     {
         SendMessageToServiceUpdateSolrAndRedis(imageProductInfo.Id);
     }
     else
     {
         SendMessageToServiceUpdateRedis(imageProductInfo.Id, updateRedisJobClient);
     }
 }
Exemple #16
0
        private void BtnCategory_Click(object sender, EventArgs e)
        {
            Button btnCategory = sender as Button;

            dataset.Product.Clear();
            ProductTableAdapter pro_adapter = new ProductTableAdapter();

            pro_adapter.Connection = Program.Connection;
            pro_adapter.FillByCategoryID(dataset.Product, Convert.ToInt32(btnCategory.Tag));
            //add to flowlayoutpanel_products
            flowLayoutPanel_Products.Controls.Clear();
            foreach (var pro in dataset.Product)
            {
                UserControl_Product uc_product = new UserControl_Product();
                uc_product.Label_Price.Text               = pro.UnitPrice.ToString();
                uc_product.Label_Product_Name.Text        = pro.Name;
                uc_product.PictureBox_Product_Image.Image = this.ConvertImageFromBytes(pro.Image);

                uc_product.PictureBox_Product_Image.Tag    = pro.ID;
                uc_product.PictureBox_Product_Image.Click += PictureBox_Product_Image_Click;

                flowLayoutPanel_Products.Controls.Add(uc_product);
            }
        }
Exemple #17
0
        public static void BuildCategory(string connProductString)
        {
            try
            {
                var productTableAdapter = new ProductTableAdapter
                {
                    Connection = { ConnectionString = connProductString }
                };
                var companyTableAdapter = new CompanyTableAdapter()
                {
                    Connection = { ConnectionString = connProductString }
                };
                var companyDataTable = companyTableAdapter.GetAllCompanies();

                for (int companyRowIndex = 0; companyRowIndex < companyDataTable.Rows.Count; companyRowIndex++)
                {
                    var companyRow = companyDataTable[companyRowIndex];
                    try
                    {
                        var startTime        = DateTime.Now;
                        var companyID        = companyRow.ID;
                        var productDataTable = productTableAdapter.GetAllProductName(companyID);
                        List <KeyValuePair <long, int> > productCategoryMap = new List <KeyValuePair <long, int> >();
                        for (int productRowIndex = 0; productRowIndex < productDataTable.Rows.Count; productRowIndex++)
                        {
                            var productRow = productDataTable[productRowIndex];
                            if (productRow["Name"] == DBNull.Value)
                            {
                                continue;
                            }
                            int categoryID = GetCategory(productRow.Name);
                            if (categoryID >= 0)
                            {
                                productCategoryMap.Add(new KeyValuePair <long, int>(productRow.ID, categoryID));
                            }
                            if (productCategoryMap.Count >= 1000)
                            {
                                var database = RedisManager.GetRedisServer("redisProductCategory").GetDatabase(0);
                                database.StringSet(productCategoryMap.Select(x => new KeyValuePair <RedisKey, RedisValue>(string.Format(productCategoryKeyFormat, x.Key), x.Value)).ToArray());
                                productCategoryMap.Clear();
                            }
                            //Thread.Sleep(10);
                        }
                        if (productCategoryMap.Count > 0)
                        {
                            var database = RedisManager.GetRedisServer("redisProductCategory").GetDatabase(0);
                            database.StringSet(productCategoryMap.Select(x => new KeyValuePair <RedisKey, RedisValue>(string.Format(productCategoryKeyFormat, x.Key), x.Value)).ToArray());
                        }
                        Log.InfoFormat("Insert MerchantProductCategory - Company [{0}/{1}]. {2} products", companyRowIndex, companyDataTable.Rows.Count, productDataTable.Rows.Count);
                        var totalTime = (DateTime.Now - startTime).TotalSeconds;
                        Log.InfoFormat("Time: {0} s", totalTime);
                    }
                    catch (Exception innerException)
                    {
                        Log.Error("Insert MerchantProductCategory. Company: " + companyRow.ID, innerException);
                    }
                }
            }
            catch (Exception exception)
            {
                Log.Error("Insert MerchantProductCategory", exception);
            }
        }
Exemple #18
0
        public static void BuildNameHash(string connProductString)
        {
            try
            {
                var productTableAdapter = new ProductTableAdapter
                {
                    Connection = { ConnectionString = connProductString }
                };
                var companyTableAdapter = new CompanyTableAdapter()
                {
                    Connection = { ConnectionString = connProductString }
                };
                var companyDataTable = companyTableAdapter.GetAllCompanies();

                for (int companyRowIndex = 0; companyRowIndex < companyDataTable.Rows.Count; companyRowIndex++)
                {
                    var startTime  = DateTime.Now;
                    var companyRow = companyDataTable[companyRowIndex];
                    var companyID  = companyRow.ID;
                    try
                    {
                        //Calculate Hash
                        HashSet <ProductSign> insertedProducts = new HashSet <ProductSign>(new ProductSignComparer());
                        var productDataTable = productTableAdapter.GetAllProductName(companyID);
                        for (int productRowIndex = 0; productRowIndex < productDataTable.Rows.Count; productRowIndex++)
                        {
                            var productSign = new ProductSign();
                            var productRow  = productDataTable[productRowIndex];
                            if (productRow["Name"] == DBNull.Value)
                            {
                                continue;
                            }
                            productSign.Name = productRow.Name;
                            if (productRow["Price"] == DBNull.Value)
                            {
                                productSign.Price = productRow.Price;
                            }
                            if (productRow["ImageUrls"] == DBNull.Value)
                            {
                                productSign.ImageUrl = productRow.ImageUrls;
                            }
                            if (insertedProducts.Contains(productSign))
                            {
                                continue;
                            }
                            int rootID = 0;
                            if (productRow["ProductID"] != DBNull.Value)
                            {
                                rootID = productRow.ProductID;
                            }
                            ProductNameHashBAL.InsertProductNameHash(productRow.ID, productRow.Name, companyID, rootID, productRow.Price);
                            insertedProducts.Add(productSign);
                        }
                        Log.InfoFormat("Insert MerchantProductHash - Company [{0}/{1}]. {2} products", companyRowIndex, companyDataTable.Rows.Count, productDataTable.Rows.Count);
                        var totalTime = (DateTime.Now - startTime).TotalSeconds;
                        Log.InfoFormat("Time: {0} s", totalTime);
                    }
                    catch (Exception innerException)
                    {
                        Log.Error("BuildNameHash. CompanyID: " + companyID, innerException);
                    }
                }
            }
            catch (Exception exception)
            {
                Log.Error("BuildNameHash", exception);
            }
        }
Exemple #19
0
        private static void ADOAddQuoteDetail(int OrdHeaderID)
        {
            int     ProdID    = 0;
            short   ProdQty   = 0;
            decimal ProdPrice = 0M;

            ADOM9Dataset.SalesOrderDetailRow Row;
            //ADOM9Dataset.SalesOrderHeaderRow HeaderRow;

            //Creamos fila vacía con configuraciones a partir de definición de tabla.
            Row = DataADO.SalesOrderDetail.NewSalesOrderDetailRow();
            //Console.WriteLine("Estado de fila recien creada: {0}", Row.RowState);

            //Relacionamos el pedido y datos por defecto.
            Row.SalesOrderID = OrdHeaderID;

            //Restriccion clave compuesta producto y descuento producto

            /*ALTER TABLE [Sales].[SalesOrderDetail]  WITH CHECK
             * ADD  CONSTRAINT [FK_SalesOrderDetail_SpecialOfferProduct_SpecialOfferIDProductID] FOREIGN KEY([SpecialOfferID], [ProductID])
             * REFERENCES [Sales].[SpecialOfferProduct] ([SpecialOfferID], [ProductID])
             * GO*/

            //Implicitamente, asumimos que si no exist en la tabla de configuración de descuentos, no existira producto.
            //Por eso no peta de forma directa si metemos IDProducto mal
            Row.SpecialOfferID    = 1;
            Row.UnitPriceDiscount = 0M;
            Row.rowguid           = Guid.NewGuid();
            Row.ModifiedDate      = DateTime.Today;

            do
            {
                Console.Write("Introduzca ID producto: ");
            }while (!int.TryParse(Console.ReadLine(), out ProdID));
            Row.ProductID = ProdID;

            //Comprobación forzada de producto
            if (DataADO.Product.Rows.Count == 0)
            {
                using (ProductTableAdapter ProdTabAdpt = new ProductTableAdapter())
                {
                    ProdTabAdpt.Fill(DataADO.Product);

                    if (DataADO.Product.FindByProductID(ProdID) == null)
                    {
                        Console.WriteLine("Producto no existe");
                        Row.RejectChanges();
                        return;
                    }
                }
            }

            do
            {
                Console.Write("Introduzca cantidad: ");
            }while (!short.TryParse(Console.ReadLine(), out ProdQty));
            Row.OrderQty = ProdQty;

            do
            {
                Console.Write("Introduzca precio unitario: ");
            }while (!decimal.TryParse(Console.ReadLine(), out ProdPrice));
            Row.UnitPrice = ProdPrice;

            Console.WriteLine("Estado de fila antes de incluir: {0}", Row.RowState);
            //Añadimos la fila instanciada al dataset/tabla para poder disponer de esta tanto en local como en remoto
            try
            {
                DataADO.SalesOrderDetail.AddSalesOrderDetailRow(Row);
            }
            catch (ConstraintException e)
            {
                Console.WriteLine("ERROR: Violación de restricción en comando Add. Detalle: {0}", e.Message);
                return;
            }
            catch (NoNullAllowedException e)
            {
                Console.WriteLine("ERROR: No se admite valor nulo de campo en comando Add. Detalle: {0}", e.Message);
                return;
            }

            Console.WriteLine("Estado de fila recien atachada: {0}", Row.RowState);
            //Recalculamos precio total de cabecera de pedido
            //Lo hace el trigger al editar detalle
            //HeaderRow = DataADO.SalesOrderHeader.FindBySalesOrderID(OrdHeaderID);
            //HeaderRow.SubTotal += ProdPrice * ProdQty;
            //SendSalesOrderHeader(HeaderRow);
            SendSalesOrderDetail(Row);

            Console.WriteLine("Estado de fila al final de comando: {0}", Row.RowState);
        }
Exemple #20
0
        private void RootProductAnalyzed(byte[] rootProductByte)
        {
            var jsonListProduct = UtilZipFile.Unzip(rootProductByte);
            var result          = JsonConvert.DeserializeObject <List <RootProductAnalyzedObject> >(jsonListProduct);
            var dataNameCode    = new Dictionary <long, List <RootProductAnalyzedObject> >();

            foreach (var rootItem in result)
            {
                if (dataNameCode.ContainsKey(rootItem.RootProductId))
                {
                    dataNameCode[rootItem.RootProductId].Add(rootItem);
                }
                else
                {
                    dataNameCode.Add(rootItem.RootProductId, new List <RootProductAnalyzedObject>()
                    {
                        rootItem
                    });
                }
            }
            var rootAdapter = new RootProductsTableAdapter();

            rootAdapter.Connection.ConnectionString = _connectionStringIndi;

            var solrRootProductClient =
                SolrRootProductClient.GetClient(SolrClientManager.GetSolrClient("solrRootProducts"));

            DBProductTableAdapters.ProductTableAdapter productAdapter = new ProductTableAdapter();
            productAdapter.Connection.ConnectionString = _connectionProduct;
            foreach (var rootItem in dataNameCode)
            {
                try
                {
                    var rootProductSql = new RootProductSql()
                    {
                        RootId      = rootItem.Key,
                        Name        = rootItem.Value[0].Name,
                        WebsiteId   = rootItem.Value[0].WebsiteId,
                        NumMerchant = rootItem.Value.Count,
                        CategoryId  = rootItem.Value[0].CategoryId
                    };
                    rootProductSql.LocalPath =
                        Websosanh.Core.Common.BAL.UrlUtilities.GetRootProductLocalPath(rootProductSql.RootId,
                                                                                       rootProductSql.Name);
                    long minprice = 0;
                    rootProductSql.ProductIdList = new List <long>();
                    var imagePath = "";
                    foreach (var item in rootItem.Value)
                    {
                        rootProductSql.ProductIdList.Add(item.Id);
                        if (!(minprice > 0 && minprice < item.Price))
                        {
                            minprice = item.Price;
                        }
                        if (string.IsNullOrEmpty(imagePath))
                        {
                            imagePath = GetImagePath(item.Id, productAdapter);
                        }
                    }
                    rootProductSql.MinPrice = minprice;
                    rootProductSql.Image    = imagePath;

                    rootProductSql.ProductIdListString = rootProductSql.GetProductIdListString();
                    if (InsertSQlRootProduct(ref rootProductSql, rootAdapter))
                    {
                        InsertSolrRootProduct(rootProductSql, solrRootProductClient);
                    }
                }
                catch (Exception exception)
                {
                    Log.Error(exception);
                }
            }
        }
Exemple #21
0
 private void DownloadImageCompany(long idCompany, ProducerBasic producerUpdateImageIdSql, bool redownloadAll)
 {
     try
     {
         var start = DateTime.Now;
         var productTableAdapter = new ProductTableAdapter();
         productTableAdapter.Connection.ConnectionString = _connectionString;
         var productTable = new DBImage.ProductDataTable();
         if (idCompany == 6619858476258121218)
         {
             productTableAdapter.FillBy_RootProduct(productTable);
         }
         else if (idCompany == 1)
         {
             productTableAdapter.FillAllImageIdNull(productTable);
         }
         else if (redownloadAll)
         {
             productTableAdapter.FillAllBy_Company(productTable, idCompany);
         }
         else
         {
             productTableAdapter.FillBy_CompanyAndImageIdNull(productTable, idCompany);
         }
         if (productTable.Rows.Count > 0)
         {
             List <long> listIdFail = new List <long>();
             int         success    = 0;
             int         fail       = 0;
             for (int i = 0; i < productTable.Rows.Count; i++)
             {
                 ImageProductInfo product = new ImageProductInfo();
                 product.Id        = Common.Obj2Int64(productTable.Rows[i]["ID"]);
                 product.ImageUrls = productTable.Rows[i]["ImageUrls"].ToString();
                 if (idCompany == 6619858476258121218)
                 {
                     if (DownloadImageRootProduct(product, producerUpdateImageIdSql))
                     {
                         success++;
                     }
                     else
                     {
                         fail++;
                         listIdFail.Add(product.Id);
                     }
                 }
                 else
                 {
                     if (DownloadImageProduct(product, producerUpdateImageIdSql))
                     {
                         success++;
                     }
                     else
                     {
                         fail++;
                         listIdFail.Add(product.Id);
                     }
                 }
             }
             Log.Info(string.Format("CompanyId = {0} downloaded {1}/{2} image", idCompany, success, productTable.Count));
             var end = DateTime.Now;
             #region Insert History donwloadimage Company
             try
             {
                 History_DownloadImageCompanyTableAdapter historyCompanyAdapter = new History_DownloadImageCompanyTableAdapter();
                 historyCompanyAdapter.Connection.ConnectionString = _connectionString;
                 historyCompanyAdapter.Insert(idCompany, productTable.Count, success, fail, start, end, string.Join(",", listIdFail));
             }
             catch (Exception ex)
             {
                 Log.Error(string.Format("Insert log error companyId = {1}", idCompany), ex);
             }
             #endregion
         }
         else
         {
             Log.Info(string.Format("CompanyId {0} 0 product download image", idCompany));
         }
     }
     catch (Exception exception)
     {
         Log.Error(string.Format("CompanyId: ID = {0} ERROR: ", idCompany), exception);
     }
 }