Exemplo n.º 1
0
 private void PrepareZipFile(string filename)
 {
     if (string.IsNullOrEmpty(filename) || (filename.Length == 0))
     {
         chkFlag.Checked = false;
         txtPTXml.Text   = string.Empty;
     }
     else
     {
         filename = Path.Combine(_dataPath, filename);
         if (!File.Exists(filename))
         {
             chkFlag.Checked = false;
             txtPTXml.Text   = string.Empty;
         }
         else
         {
             ImportAdapter importer = TransferHelper.GetImporter(dropImportVersions.SelectedValue, new object[0]);
             string        str      = importer.PrepareDataFiles(new object[] { filename });
             object[]      objArray = importer.ParseIndexes(new object[] { str });
             lblVersion.Text             = (string)objArray[0];
             lblQuantity.Text            = objArray[1].ToString();
             chkIncludeCostPrice.Checked = (bool)objArray[2];
             chkIncludeStock.Checked     = (bool)objArray[3];
             chkIncludeImages.Checked    = (bool)objArray[4];
             txtPTXml.Text   = (string)objArray[5];
             chkFlag.Checked = true;
         }
     }
 }
        private void btnImport_Click(object sender, System.EventArgs e)
        {
            if (!this.CheckItems())
            {
                return;
            }
            string            text          = this.dropFiles.SelectedValue;
            string            text2         = System.IO.Path.Combine(this._dataPath, System.IO.Path.GetFileNameWithoutExtension(text));
            ImportAdapter     importer      = TransferHelper.GetImporter(this.dropImportVersions.SelectedValue, new object[0]);
            int               value         = this.dropCategories.SelectedValue.Value;
            int               value2        = this.dropProductLines.SelectedValue.Value;
            int?              selectedValue = this.dropBrandList.SelectedValue;
            ProductSaleStatus saleStatus    = ProductSaleStatus.OnStock;

            text = System.IO.Path.Combine(this._dataPath, text);
            if (!System.IO.File.Exists(text))
            {
                this.ShowMsg("选择的数据包文件有问题!", false);
                return;
            }
            importer.PrepareDataFiles(new object[]
            {
                text
            });
            text2 = text2.ToLower().Replace("cpage\\supplier\\" + Hidistro.Membership.Context.HiContext.Current.User.UserId, "data");
            object[] array = importer.ParseProductData(new object[]
            {
                text2
            });
            Methods.Supplier_PtImportProducts((System.Data.DataTable)array[0], value, value2, selectedValue, saleStatus, false);
            System.IO.File.Delete(text);
            System.IO.Directory.Delete(text2, true);
            this.BindFiles();
            this.ShowMsg("此次商品批量导入操作已成功!", true);
        }
Exemplo n.º 3
0
        private void PrepareZipFile(string filename)
        {
            if (string.IsNullOrEmpty(filename) || filename.Length == 0)
            {
                this.chkFlag.Checked = false;
                this.txtPTXml.Text   = string.Empty;
                return;
            }
            filename = System.IO.Path.Combine(this._dataPath, filename);
            if (!System.IO.File.Exists(filename))
            {
                this.chkFlag.Checked = false;
                this.txtPTXml.Text   = string.Empty;
                return;
            }
            ImportAdapter importer = TransferHelper.GetImporter(this.dropImportVersions.SelectedValue, new object[0]);
            string        text     = importer.PrepareDataFiles(new object[]
            {
                filename
            });

            object[] array = importer.ParseIndexes(new object[]
            {
                text
            });
            this.lblVersion.Text             = (string)array[0];
            this.lblQuantity.Text            = array[1].ToString();
            this.chkIncludeCostPrice.Checked = (bool)array[2];
            this.chkIncludeStock.Checked     = (bool)array[3];
            this.chkIncludeImages.Checked    = (bool)array[4];
            this.txtPTXml.Text   = (string)array[5];
            this.chkFlag.Checked = true;
        }
Exemplo n.º 4
0
 private void btnImport_Click(object sender, System.EventArgs e)
 {
     if (this.CheckItems())
     {
         string              selectedValue = this.dropFiles.SelectedValue;
         string              path          = System.IO.Path.Combine(this._dataPath, System.IO.Path.GetFileNameWithoutExtension(selectedValue));
         ImportAdapter       importer      = TransferHelper.GetImporter(this.dropImportVersions.SelectedValue, new object[0]);
         System.Data.DataSet mappingSet    = null;
         if (this.txtMappedTypes.Text.Length > 0)
         {
             XmlDocument document = new XmlDocument();
             document.LoadXml(this.txtMappedTypes.Text);
             mappingSet = (importer.CreateMapping(new object[]
             {
                 document,
                 path
             })[0] as System.Data.DataSet);
             ProductHelper.EnsureMapping(mappingSet);
         }
         bool includeCostPrice    = this.chkIncludeCostPrice.Checked;
         bool includeStock        = this.chkIncludeStock.Checked;
         bool includeImages       = this.chkIncludeImages.Checked;
         int  categoryId          = this.dropCategories.SelectedValue.Value;
         int? bandId              = this.dropBrandList.SelectedValue;
         ProductSaleStatus delete = ProductSaleStatus.Delete;
         if (this.radInStock.Checked)
         {
             delete = ProductSaleStatus.OnStock;
         }
         if (this.radUnSales.Checked)
         {
             delete = ProductSaleStatus.UnSale;
         }
         if (this.radOnSales.Checked)
         {
             delete = ProductSaleStatus.OnSale;
         }
         ProductHelper.ImportProducts((System.Data.DataSet)importer.ParseProductData(new object[]
         {
             mappingSet,
             path,
             includeCostPrice,
             includeStock,
             includeImages
         })[0], categoryId, 0, bandId, delete, includeCostPrice, includeStock, includeImages);
         System.IO.File.Delete(System.IO.Path.Combine(this._dataPath, selectedValue));
         System.IO.Directory.Delete(path, true);
         this.chkFlag.Checked        = false;
         this.txtMappedTypes.Text    = string.Empty;
         this.txtProductTypeXml.Text = string.Empty;
         this.txtPTXml.Text          = string.Empty;
         this.OutputProductTypes();
         this.BindFiles();
         this.ShowMsg("此次商品批量导入操作已成功!", true);
     }
 }
Exemplo n.º 5
0
 protected void btnImport_Click(object sender, EventArgs e)
 {
     //try
     //{
     if (CheckItems())
     {
         string        selectedValue = dropFiles.SelectedValue;
         string        path          = Path.Combine(_dataPath, Path.GetFileNameWithoutExtension(selectedValue));
         ImportAdapter importer      = TransferHelper.GetImporter(dropImportVersions.SelectedValue, new object[0]);
         DataSet       mappingSet    = null;
         if (txtMappedTypes.Text.Length > 0)
         {
             XmlDocument document = new XmlDocument();
             document.LoadXml(txtMappedTypes.Text);
             mappingSet = importer.CreateMapping(new object[] { document, path })[0] as DataSet;
             ProductHelper.EnsureMapping(mappingSet);
         }
         bool includeCostPrice    = chkIncludeCostPrice.Checked;
         bool includeStock        = chkIncludeStock.Checked;
         bool includeImages       = chkIncludeImages.Checked;
         int  categoryId          = dropCategories.SelectedValue.Value;
         int  lineId              = dropProductLines.SelectedValue.Value;
         int? bandId              = dropBrandList.SelectedValue;
         ProductSaleStatus delete = ProductSaleStatus.Delete;
         if (radInStock.Checked)
         {
             delete = ProductSaleStatus.OnStock;
         }
         if (radUnSales.Checked)
         {
             delete = ProductSaleStatus.UnSale;
         }
         if (radOnSales.Checked)
         {
             delete = ProductSaleStatus.OnSale;
         }
         ProductHelper.ImportProducts((DataSet)importer.ParseProductData(new object[] { mappingSet, path, includeCostPrice, includeStock, includeImages })[0], categoryId, lineId, bandId, delete, includeCostPrice, includeStock, includeImages);
         if (chkDeleteFiles.Checked)
         {
             File.Delete(Path.Combine(_dataPath, selectedValue));
             Directory.Delete(path, true);
         }
         chkFlag.Checked        = false;
         txtMappedTypes.Text    = string.Empty;
         txtProductTypeXml.Text = string.Empty;
         txtPTXml.Text          = string.Empty;
         OutputProductTypes();
         BindFiles();
         ShowMsg("此次商品批量导入操作已成功!", true);
     }
     //}
     //catch (Exception ex)
     //{
     //    ShowMsg("导入失败,请检查数据包格式是否正确",false);
     // }
 }
Exemplo n.º 6
0
        private void btnImport_Click(object sender, System.EventArgs e)
        {
            if (!this.CheckItems())
            {
                return;
            }
            string        selectedValue = this.dropFiles.SelectedValue;
            string        text          = System.IO.Path.Combine(this._dataPath, System.IO.Path.GetFileNameWithoutExtension(selectedValue));
            ImportAdapter importer      = TransferHelper.GetImporter(this.dropImportVersions.SelectedValue, new object[0]);

            text = text.ToLower().Replace("cpage\\supplier\\" + Hidistro.Membership.Context.HiContext.Current.User.UserId, "data");
            System.Data.DataSet dataSet = null;
            if (this.txtMappedTypes.Text.Length > 0)
            {
                System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument();
                xmlDocument.LoadXml(this.txtMappedTypes.Text);
                dataSet = (importer.CreateMapping(new object[]
                {
                    xmlDocument,
                    text
                })[0] as System.Data.DataSet);
                ProductHelper.EnsureMapping(dataSet);
            }
            bool @checked       = this.chkIncludeCostPrice.Checked;
            bool checked2       = this.chkIncludeStock.Checked;
            bool checked3       = this.chkIncludeImages.Checked;
            int  value          = this.dropCategories.SelectedValue.Value;
            int  value2         = this.dropProductLines.SelectedValue.Value;
            int? selectedValue2 = this.dropBrandList.SelectedValue;

            object[] array = importer.ParseProductData(new object[]
            {
                dataSet,
                text,
                @checked,
                checked2,
                checked3
            });
            Methods.Supplier_PtImportProducts((System.Data.DataSet)array[0], value, value2, selectedValue2, ProductSaleStatus.OnStock, @checked, checked2, checked3);
            System.IO.File.Delete(System.IO.Path.Combine(this._dataPath, selectedValue));
            System.IO.Directory.Delete(text, true);
            this.chkFlag.Checked        = false;
            this.txtMappedTypes.Text    = string.Empty;
            this.txtProductTypeXml.Text = string.Empty;
            this.txtPTXml.Text          = string.Empty;
            this.OutputProductTypes();
            this.BindFiles();
            this.ShowMsg("此次商品批量导入操作已成功!", true);
        }
Exemplo n.º 7
0
        private void btnImport_Click(object sender, System.EventArgs e)
        {
            if (!this.CheckItems())
            {
                return;
            }
            string            text          = this.dropFiles.SelectedValue;
            string            text2         = System.IO.Path.Combine(this._dataPath, System.IO.Path.GetFileNameWithoutExtension(text));
            ImportAdapter     importer      = TransferHelper.GetImporter(this.dropImportVersions.SelectedValue, new object[0]);
            int               value         = this.dropCategories.SelectedValue.Value;
            int?              selectedValue = this.dropBrandList.SelectedValue;
            ProductSaleStatus saleStatus    = ProductSaleStatus.Delete;

            if (this.radInStock.Checked)
            {
                saleStatus = ProductSaleStatus.OnStock;
            }
            if (this.radUnSales.Checked)
            {
                saleStatus = ProductSaleStatus.UnSale;
            }
            if (this.radOnSales.Checked)
            {
                saleStatus = ProductSaleStatus.OnSale;
            }
            text = System.IO.Path.Combine(this._dataPath, text);
            if (!System.IO.File.Exists(text))
            {
                this.ShowMsg("选择的数据包文件有问题!", false);
                return;
            }
            this.PrepareDataFiles(text2, text);
            try
            {
                object[] array = importer.ParseProductData(new object[]
                {
                    text2
                });
                ProductHelper.ImportProducts((System.Data.DataTable)array[0], value, 0, selectedValue, saleStatus, true);
                System.IO.File.Delete(text);
                System.IO.Directory.Delete(text2, true);
                this.BindFiles();
                this.ShowMsg("此次商品批量导入操作已成功!", true);
            }
            catch (System.Exception)
            {
                this.ShowMsg("选择的数据包文件有问题!", false);
            }
        }
Exemplo n.º 8
0
 private void btnImport_Click(object sender, System.EventArgs e)
 {
     if (this.CheckItems())
     {
         string            selectedValue = this.dropFiles.SelectedValue;
         string            path          = System.IO.Path.Combine(this._dataPath, System.IO.Path.GetFileNameWithoutExtension(selectedValue));
         ImportAdapter     importer      = TransferHelper.GetImporter(this.dropImportVersions.SelectedValue, new object[0]);
         int               categoryId    = this.dropCategories.SelectedValue.Value;
         int?              brandId       = this.dropBrandList.SelectedValue;
         ProductSaleStatus delete        = ProductSaleStatus.Delete;
         if (this.radInStock.Checked)
         {
             delete = ProductSaleStatus.OnStock;
         }
         if (this.radUnSales.Checked)
         {
             delete = ProductSaleStatus.UnSale;
         }
         if (this.radOnSales.Checked)
         {
             delete = ProductSaleStatus.OnSale;
         }
         selectedValue = System.IO.Path.Combine(this._dataPath, selectedValue);
         if (!System.IO.File.Exists(selectedValue))
         {
             this.ShowMsg("选择的数据包文件有问题!", false);
         }
         else
         {
             importer.PrepareDataFiles(new object[] { selectedValue });
             try
             {
                 ProductHelper.ImportProducts((System.Data.DataTable)importer.ParseProductData(new object[] { path })[0], categoryId, 0, brandId, delete, false);
                 System.IO.File.Delete(selectedValue);
                 System.IO.Directory.Delete(path, true);
                 this.BindFiles();
                 this.ShowMsg("此次商品批量导入操作已成功!", true);
             }
             catch
             {
                 System.IO.File.Delete(selectedValue);
                 System.IO.Directory.Delete(path, true);
                 this.ShowMsg("选择的数据包文件有问题!", false);
             }
         }
     }
 }
Exemplo n.º 9
0
        private void button3_Click(object sender, EventArgs e)
        {
            ImportCredentialsConfig config = new ImportCredentialsConfig();

            config.host       = "127.0.0.1";
            config.port       = 3306;
            config.username   = "******";
            config.password   = "******";
            config.scriptPath = "D:\\MyStuff\\desktop\\anime.sql";
            ImportAdapter adapter = new ImportAdapter(config);

            adapter.ImportComplete += onImportCompleteHandler;
            adapter.ImportError    += onImportErrorHandler;
            adapter.ImportInit     += onImportInitHandler;
            adapter.ImportProgress += onImportProgressHandler;
            adapter.executeScript();
        }
Exemplo n.º 10
0
 private void btnImport_Click(object sender, EventArgs e)
 {
     if (CheckItems())
     {
         string            selectedValue = dropFiles.SelectedValue;
         string            path          = Path.Combine(_dataPath, Path.GetFileNameWithoutExtension(selectedValue));
         ImportAdapter     importer      = TransferHelper.GetImporter(dropImportVersions.SelectedValue, new object[0]);
         int               categoryId    = dropCategories.SelectedValue.Value;
         int               lineId        = dropProductLines.SelectedValue.Value;
         int?              brandId       = dropBrandList.SelectedValue;
         ProductSaleStatus delete        = ProductSaleStatus.Delete;
         if (radInStock.Checked)
         {
             delete = ProductSaleStatus.OnStock;
         }
         if (radUnSales.Checked)
         {
             delete = ProductSaleStatus.UnSale;
         }
         if (radOnSales.Checked)
         {
             delete = ProductSaleStatus.OnSale;
         }
         selectedValue = Path.Combine(_dataPath, selectedValue);
         if (!File.Exists(selectedValue))
         {
             ShowMsg("选择的数据包文件有问题!", false);
         }
         else
         {
             importer.PrepareDataFiles(new object[] { selectedValue });
             ProductHelper.ImportProducts((DataTable)importer.ParseProductData(new object[] { path })[0], categoryId, lineId, brandId, delete);
             if (chkDeleteFiles.Checked)
             {
                 File.Delete(selectedValue);
                 Directory.Delete(path, true);
             }
             BindFiles();
             ShowMsg("此次商品批量导入操作已成功!", true);
         }
     }
 }
Exemplo n.º 11
0
 private void btnImport_Click(object sender, EventArgs e)
 {
     if (this.CheckItems())
     {
         string            selectedValue  = this.dropFiles.SelectedValue;
         string            text           = Path.Combine(this._dataPath, Path.GetFileNameWithoutExtension(selectedValue));
         ImportAdapter     importer       = TransferHelper.GetImporter(this.dropImportVersions.SelectedValue);
         int               value          = this.dropCategories.SelectedValue.Value;
         int?              selectedValue2 = this.dropBrandList.SelectedValue;
         ProductSaleStatus saleStatus     = ProductSaleStatus.Delete;
         if (this.radInStock.Checked)
         {
             saleStatus = ProductSaleStatus.OnStock;
         }
         if (this.radUnSales.Checked)
         {
             saleStatus = ProductSaleStatus.UnSale;
         }
         if (this.radOnSales.Checked)
         {
             saleStatus = ProductSaleStatus.OnSale;
         }
         selectedValue = Path.Combine(this._dataPath, selectedValue);
         if (!File.Exists(selectedValue))
         {
             this.ShowMsg("选择的数据包文件有问题!", false);
         }
         else
         {
             this.PrepareDataFiles(text, selectedValue);
             object[] array = importer.ParseProductData(text);
             ProductHelper.ImportProducts((DataTable)array[0], value, selectedValue2, saleStatus, true);
             File.Delete(selectedValue);
             Directory.Delete(text, true);
             this.BindFiles();
             this.ShowMsg("此次商品批量导入操作已成功!", true);
         }
     }
 }