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); // } }
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); } }
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); }