From ee176b4e24ce72b157cea048d030dc7a3a12f2e0 Mon Sep 17 00:00:00 2001 From: admin Date: Sat, 19 Dec 2020 13:04:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AF=BC=E5=85=A5=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- U8AppMain/App.config | 5 + U8AppMain/Bom/ComponentBody.cs | 2 +- U8AppMain/FrmMain.Designer.cs | 216 +++++++++++++++---------- U8AppMain/FrmMain.cs | 229 +++++++++++++++++++-------- U8AppMain/FrmMain.resx | 3 + U8AppMain/ResultEnity/Item.cs | 23 +++ U8AppMain/ResultEnity/ufinterface.cs | 29 ++++ U8AppMain/U8AppMain.csproj | 22 +-- U8AppMain/XmlHelper.cs | 26 ++- U8AppMain/packages.config | 1 + 10 files changed, 383 insertions(+), 173 deletions(-) create mode 100644 U8AppMain/ResultEnity/Item.cs create mode 100644 U8AppMain/ResultEnity/ufinterface.cs diff --git a/U8AppMain/App.config b/U8AppMain/App.config index 8227adb..30b8937 100644 --- a/U8AppMain/App.config +++ b/U8AppMain/App.config @@ -3,4 +3,9 @@ + + + + + diff --git a/U8AppMain/Bom/ComponentBody.cs b/U8AppMain/Bom/ComponentBody.cs index 051914a..47df1f8 100644 --- a/U8AppMain/Bom/ComponentBody.cs +++ b/U8AppMain/Bom/ComponentBody.cs @@ -7,7 +7,7 @@ using System.Xml.Serialization; namespace U8AppMain.Bom { - + public class ComponentBody { public ComponentEnity Component { get; set; } = new ComponentEnity(); diff --git a/U8AppMain/FrmMain.Designer.cs b/U8AppMain/FrmMain.Designer.cs index 619d374..2ee14e2 100644 --- a/U8AppMain/FrmMain.Designer.cs +++ b/U8AppMain/FrmMain.Designer.cs @@ -29,118 +29,160 @@ namespace U8AppMain /// private void InitializeComponent() { - this.panel1 = new System.Windows.Forms.Panel(); - this.BtnBomImport = new System.Windows.Forms.Button(); - this.panel2 = new System.Windows.Forms.Panel(); - this.kryptonDataGridView1 = new ComponentFactory.Krypton.Toolkit.KryptonDataGridView(); - this.BtnImportExcel = new System.Windows.Forms.Button(); - this.textBox1 = new System.Windows.Forms.TextBox(); - this.button1 = new System.Windows.Forms.Button(); - this.panel1.SuspendLayout(); - this.panel2.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.kryptonDataGridView1)).BeginInit(); + this.menuStrip1 = new System.Windows.Forms.MenuStrip(); + this.操作ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.BtnReadExcel = new System.Windows.Forms.ToolStripMenuItem(); + this.导入ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.ImportBom = new System.Windows.Forms.ToolStripMenuItem(); + this.BtnPurchaseImport = new System.Windows.Forms.ToolStripMenuItem(); + this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.richTextBox1 = new System.Windows.Forms.RichTextBox(); + this.dataGridView1 = new System.Windows.Forms.DataGridView(); + this.menuStrip1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); + this.splitContainer1.Panel1.SuspendLayout(); + this.splitContainer1.Panel2.SuspendLayout(); + this.splitContainer1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); this.SuspendLayout(); // - // panel1 + // menuStrip1 // - this.panel1.Controls.Add(this.button1); - this.panel1.Controls.Add(this.BtnImportExcel); - this.panel1.Controls.Add(this.BtnBomImport); - this.panel1.Dock = System.Windows.Forms.DockStyle.Top; - this.panel1.Location = new System.Drawing.Point(0, 0); - this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(800, 42); - this.panel1.TabIndex = 0; + this.menuStrip1.Font = new System.Drawing.Font("Segoe UI", 9F); + this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.操作ToolStripMenuItem, + this.导入ToolStripMenuItem}); + this.menuStrip1.Location = new System.Drawing.Point(0, 0); + this.menuStrip1.Name = "menuStrip1"; + this.menuStrip1.Padding = new System.Windows.Forms.Padding(9, 4, 0, 4); + this.menuStrip1.Size = new System.Drawing.Size(1200, 27); + this.menuStrip1.TabIndex = 0; + this.menuStrip1.Text = "menuStrip1"; // - // BtnBomImport + // 操作ToolStripMenuItem // - this.BtnBomImport.Location = new System.Drawing.Point(108, 12); - this.BtnBomImport.Name = "BtnBomImport"; - this.BtnBomImport.Size = new System.Drawing.Size(75, 23); - this.BtnBomImport.TabIndex = 0; - this.BtnBomImport.Text = "Bom导入"; - this.BtnBomImport.UseVisualStyleBackColor = true; - this.BtnBomImport.Click += new System.EventHandler(this.BtnBomImport_Click); + this.操作ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.BtnReadExcel}); + this.操作ToolStripMenuItem.Name = "操作ToolStripMenuItem"; + this.操作ToolStripMenuItem.Size = new System.Drawing.Size(45, 19); + this.操作ToolStripMenuItem.Text = "文件"; // - // panel2 + // BtnReadExcel // - this.panel2.Controls.Add(this.textBox1); - this.panel2.Controls.Add(this.kryptonDataGridView1); - this.panel2.Dock = System.Windows.Forms.DockStyle.Fill; - this.panel2.Location = new System.Drawing.Point(0, 42); - this.panel2.Name = "panel2"; - this.panel2.Size = new System.Drawing.Size(800, 408); - this.panel2.TabIndex = 1; + this.BtnReadExcel.Name = "BtnReadExcel"; + this.BtnReadExcel.Size = new System.Drawing.Size(180, 22); + this.BtnReadExcel.Text = "读取Excel"; + this.BtnReadExcel.Click += new System.EventHandler(this.BtnReadExcel_Click); // - // kryptonDataGridView1 + // 导入ToolStripMenuItem // - this.kryptonDataGridView1.AllowUserToAddRows = false; - this.kryptonDataGridView1.AllowUserToDeleteRows = false; - this.kryptonDataGridView1.AllowUserToResizeRows = false; - this.kryptonDataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.kryptonDataGridView1.Dock = System.Windows.Forms.DockStyle.Fill; - this.kryptonDataGridView1.Location = new System.Drawing.Point(0, 0); - this.kryptonDataGridView1.Name = "kryptonDataGridView1"; - this.kryptonDataGridView1.ReadOnly = true; - this.kryptonDataGridView1.RowTemplate.Height = 23; - this.kryptonDataGridView1.Size = new System.Drawing.Size(800, 408); - this.kryptonDataGridView1.TabIndex = 0; + this.导入ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.ImportBom, + this.BtnPurchaseImport}); + this.导入ToolStripMenuItem.Name = "导入ToolStripMenuItem"; + this.导入ToolStripMenuItem.Size = new System.Drawing.Size(45, 19); + this.导入ToolStripMenuItem.Text = "导入"; // - // BtnImportExcel + // ImportBom // - this.BtnImportExcel.Location = new System.Drawing.Point(12, 12); - this.BtnImportExcel.Name = "BtnImportExcel"; - this.BtnImportExcel.Size = new System.Drawing.Size(75, 23); - this.BtnImportExcel.TabIndex = 1; - this.BtnImportExcel.Text = "读取Exel"; - this.BtnImportExcel.UseVisualStyleBackColor = true; - this.BtnImportExcel.Click += new System.EventHandler(this.BtnImportExcel_Click); + this.ImportBom.Name = "ImportBom"; + this.ImportBom.Size = new System.Drawing.Size(180, 22); + this.ImportBom.Text = "BOM"; + this.ImportBom.Click += new System.EventHandler(this.ImportBom_Click); // - // textBox1 + // BtnPurchaseImport // - this.textBox1.Dock = System.Windows.Forms.DockStyle.Bottom; - this.textBox1.Location = new System.Drawing.Point(0, 147); - this.textBox1.Multiline = true; - this.textBox1.Name = "textBox1"; - this.textBox1.Size = new System.Drawing.Size(800, 261); - this.textBox1.TabIndex = 1; + this.BtnPurchaseImport.Name = "BtnPurchaseImport"; + this.BtnPurchaseImport.Size = new System.Drawing.Size(180, 22); + this.BtnPurchaseImport.Text = "请购单"; + this.BtnPurchaseImport.Click += new System.EventHandler(this.BtnPurchaseImport_Click); // - // button1 + // splitContainer1 // - this.button1.Location = new System.Drawing.Point(211, 12); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(75, 23); - this.button1.TabIndex = 2; - this.button1.Text = "请购单导入"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.button1_Click); + this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer1.Location = new System.Drawing.Point(0, 27); + this.splitContainer1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.splitContainer1.Name = "splitContainer1"; + this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; + // + // splitContainer1.Panel1 + // + this.splitContainer1.Panel1.Controls.Add(this.dataGridView1); + // + // splitContainer1.Panel2 + // + this.splitContainer1.Panel2.Controls.Add(this.richTextBox1); + this.splitContainer1.Size = new System.Drawing.Size(1200, 722); + this.splitContainer1.SplitterDistance = 450; + this.splitContainer1.TabIndex = 0; + // + // richTextBox1 + // + this.richTextBox1.BackColor = System.Drawing.Color.White; + this.richTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.richTextBox1.Dock = System.Windows.Forms.DockStyle.Fill; + this.richTextBox1.Location = new System.Drawing.Point(0, 0); + this.richTextBox1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.richTextBox1.Name = "richTextBox1"; + this.richTextBox1.ReadOnly = true; + this.richTextBox1.Size = new System.Drawing.Size(1200, 268); + this.richTextBox1.TabIndex = 0; + this.richTextBox1.Text = ""; + this.richTextBox1.TextChanged += new System.EventHandler(this.richTextBox1_TextChanged); + // + // dataGridView1 + // + this.dataGridView1.AllowUserToAddRows = false; + this.dataGridView1.AllowUserToDeleteRows = false; + this.dataGridView1.AllowUserToOrderColumns = true; + this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.ButtonHighlight; + this.dataGridView1.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.dataGridView1.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single; + this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill; + this.dataGridView1.GridColor = System.Drawing.SystemColors.ActiveBorder; + this.dataGridView1.Location = new System.Drawing.Point(0, 0); + this.dataGridView1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.dataGridView1.Name = "dataGridView1"; + this.dataGridView1.ReadOnly = true; + this.dataGridView1.RowTemplate.Height = 23; + this.dataGridView1.Size = new System.Drawing.Size(1200, 450); + this.dataGridView1.TabIndex = 0; // // FrmMain // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Controls.Add(this.panel2); - this.Controls.Add(this.panel1); + this.ClientSize = new System.Drawing.Size(1200, 749); + this.Controls.Add(this.splitContainer1); + this.Controls.Add(this.menuStrip1); + this.Font = new System.Drawing.Font("微软雅黑", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.MainMenuStrip = this.menuStrip1; + this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.Name = "FrmMain"; - this.Text = "Form1"; - this.panel1.ResumeLayout(false); - this.panel2.ResumeLayout(false); - this.panel2.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.kryptonDataGridView1)).EndInit(); + this.Text = "U8导入"; + this.menuStrip1.ResumeLayout(false); + this.menuStrip1.PerformLayout(); + this.splitContainer1.Panel1.ResumeLayout(false); + this.splitContainer1.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); + this.splitContainer1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); this.ResumeLayout(false); + this.PerformLayout(); } #endregion - - private System.Windows.Forms.Panel panel1; - private System.Windows.Forms.Button BtnBomImport; - private System.Windows.Forms.Panel panel2; - private ComponentFactory.Krypton.Toolkit.KryptonDataGridView kryptonDataGridView1; - private System.Windows.Forms.Button BtnImportExcel; - private System.Windows.Forms.TextBox textBox1; - private System.Windows.Forms.Button button1; + private System.Windows.Forms.MenuStrip menuStrip1; + private System.Windows.Forms.ToolStripMenuItem 操作ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem BtnReadExcel; + private System.Windows.Forms.ToolStripMenuItem 导入ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem ImportBom; + private System.Windows.Forms.ToolStripMenuItem BtnPurchaseImport; + private System.Windows.Forms.SplitContainer splitContainer1; + private System.Windows.Forms.RichTextBox richTextBox1; + private System.Windows.Forms.DataGridView dataGridView1; } } diff --git a/U8AppMain/FrmMain.cs b/U8AppMain/FrmMain.cs index 61eea13..6a8d08f 100644 --- a/U8AppMain/FrmMain.cs +++ b/U8AppMain/FrmMain.cs @@ -10,6 +10,8 @@ using System.Threading.Tasks; using System.Windows.Forms; using System.Xml.Serialization; using System.IO; +using System.Configuration; + namespace U8AppMain { public partial class FrmMain : Form @@ -19,56 +21,69 @@ namespace U8AppMain InitializeComponent(); } - private DataTable dataTable; - private async void BtnBomImport_Click(object sender, EventArgs e) + + private void PrintLog(ResultEnity.ufinterface info) { - - var bomLookup = new Dictionary(); - foreach (DataRow row in this.dataTable.Rows) + this.richTextBox1.SelectionColor = Color.Black; + this.richTextBox1.AppendText($"单据:{info.requestroottag} 操作:{info.proc} \r\n"); + + foreach (var item in info.Items) { - var bom = new Bom.ufinterface(); - var comp = new Bom.ComponentBody(); - bom.Bom.Version.Version = Convert.ToInt32(row["版本号"]); - bom.Bom.Version.VersionDesc = row.Field("版本说明"); - bom.Bom.Parent.InvCode = row.Field("母件编码"); - bom.Bom.Version.VersionEffDate = DateTime.Parse(row["版本生效日"].ToString()); - //bom.Bom.Version.BomType ="1" row.Field("BOM类别"); - bom.Bom.Parent.ParentScrap = decimal.Parse(row["母件损耗率"].ToString()); - var strKey = $"{bom.Bom.Parent.InvCode}-{bom.Bom.Version.Version}"; - if (bomLookup.ContainsKey(strKey)) + string tag; + if (item.succeed == "0") { - bom = bomLookup[strKey]; + this.richTextBox1.SelectionColor = Color.Green; + tag = "成功"; } else { - bomLookup.Add(strKey, bom); + this.richTextBox1.SelectionColor = Color.Red; + tag = "出错"; } - comp.Component.OpComponentId = bom.Bom.ComponentBodies.Count; - comp.Component.EffBegDate = bom.Bom.Version.VersionEffDate; - comp.Component.InvCode = row.Field("子件编码"); - comp.Component.SortSeq = row.Field("行号"); - comp.Component.OptionsId = bom.Bom.ComponentBodies.Count; - comp.Component.BaseQtyN = decimal.Parse(row["基本用量分子"].ToString()); - comp.Component.BaseQtyD = decimal.Parse(row["基础数量分母"].ToString()); - comp.Component.CompScrap = decimal.Parse(row["子件损耗率"].ToString()); - comp.ComponentOpt.WIPType = row["供应类型"].ToString(); - comp.ComponentOpt.OptionsId = bom.Bom.ComponentBodies.Count; - bom.Bom.ComponentBodies.Add(comp); - } - foreach (var item in bomLookup.Values) - { - - var strbody = XmlHelper.XmlSerialize(item, Encoding.UTF8); - var response = await HttpHelper.Post("", strbody); - this.textBox1.Text += response; + this.richTextBox1.AppendText($"[{tag}] 单号:({item.key}),信息:{item.dsc} \r\n"); } + this.richTextBox1.SelectionColor = Color.Black; + this.richTextBox1.AppendText($"---------------------------------------------------------------------------------------\r\n"); + } - private void BtnImportExcel_Click(object sender, EventArgs e) + + private async Task HttpPost(string body) + { + try + { + + var response = await HttpHelper.Post(url, body); + return XmlHelper.XmlDeserialize(response, Encoding.UTF8); + // var strResult = $"单据:{result.requestroottag} 操作:{result.proc} \r\n"; + //foreach (var item in result.Items) + //{ + // strResult += $" 单号:{item.key} 单号:{item.u8key} ------------执行结果: {item.dsc} \r\n"; + //} + + // return strResult; + } + catch (Exception err) + { + this.richTextBox1.Text = err.Message; + return null; + //return err.Message; + } + + } + + private string url = ConfigurationManager.AppSettings.Get("url"); + private DataTable dataTable; + + + + + + private void BtnReadExcel_Click(object sender, EventArgs e) { var opentFileDlg = new OpenFileDialog { - Filter = "EXCEL2003|*.xls|EXCLE2007|*.xlsx" + Filter = "EXCEL文件(*.xls;*.xlsx)|*.xls;*.xlsx" }; if (opentFileDlg.ShowDialog() == DialogResult.OK) @@ -77,50 +92,130 @@ namespace U8AppMain using (var file = new FileStream(opentFileDlg.FileName, FileMode.Open)) { dataTable = ExcelHelper.ExcelToDataTable(file); - this.kryptonDataGridView1.DataSource = dataTable; + this.dataGridView1.DataSource = dataTable; } } return; } - private async void button1_Click(object sender, EventArgs e) + private async void ImportBom_Click(object sender, EventArgs e) { - - - var bomLookup = new Dictionary(); - foreach (DataRow row in this.dataTable.Rows) + if (this.dataTable == null || this.dataTable.Rows.Count == 0) { - var purchase = new Purchase.ufinterface(); - var body = new Purchase.entry(); - purchase.purchaseapp.header.code = row["请购单号"].ToString(); - purchase.purchaseapp.header.date = row["请购日"].ToString(); - purchase.purchaseapp.header.departmentcode = row["部门编码"].ToString(); - purchase.purchaseapp.header.personcode = row["请购人"].ToString(); - purchase.purchaseapp.header.purchasetypecode = row["采购类型编号"].ToString(); - purchase.purchaseapp.header.maker = row["制单人"].ToString(); - var strKey = purchase.purchaseapp.header.code; - if (bomLookup.ContainsKey(strKey)) - { - purchase = bomLookup[strKey]; - } - else - { - bomLookup.Add(strKey, purchase); - } - body.inventorycode = row["存货编码"].ToString(); - body.requiredate = purchase.purchaseapp.header.date; - body.quantity = decimal.Parse(row["数量"].ToString()); - - purchase.purchaseapp.body.Add(body); + return; } + + var bomLookup = new Dictionary(); + try + { + foreach (DataRow row in this.dataTable.Rows) + { + var bom = new Bom.ufinterface(); + var comp = new Bom.ComponentBody(); + bom.Bom.Version.Version = Convert.ToInt32(row["版本号"]); + bom.Bom.Version.VersionDesc = row.Field("版本说明"); + bom.Bom.Parent.InvCode = row.Field("母件编码"); + bom.Bom.Version.VersionEffDate = DateTime.Parse(row["版本生效日"].ToString()); + bom.Bom.Parent.ParentScrap = decimal.Parse(row["母件损耗率"].ToString()); + var strKey = $"{bom.Bom.Parent.InvCode}-{bom.Bom.Version.Version}"; + if (bomLookup.ContainsKey(strKey)) + { + bom = bomLookup[strKey]; + } + else + { + bomLookup.Add(strKey, bom); + } + comp.Component.OpComponentId = bom.Bom.ComponentBodies.Count; + comp.Component.EffBegDate = bom.Bom.Version.VersionEffDate; + comp.Component.InvCode = row.Field("子件编码"); + comp.Component.SortSeq = row.Field("行号"); + comp.Component.OptionsId = bom.Bom.ComponentBodies.Count; + comp.Component.BaseQtyN = decimal.Parse(row["基本用量分子"].ToString()); + comp.Component.BaseQtyD = decimal.Parse(row["基础数量分母"].ToString()); + comp.Component.CompScrap = decimal.Parse(row["子件损耗率"].ToString()); + comp.ComponentOpt.WIPType = row["供应类型"].ToString(); + comp.ComponentOpt.OptionsId = bom.Bom.ComponentBodies.Count; + bom.Bom.ComponentBodies.Add(comp); + } + } + catch (Exception err) + { + + this.richTextBox1.SelectionColor = Color.Red; + this.richTextBox1.AppendText("读取数据出错\r\n"); + return; + } + + foreach (var item in bomLookup.Values) + { + + var strbody = XmlHelper.XmlSerialize(item, Encoding.UTF8); + var response = await this.HttpPost(strbody); + + PrintLog(response); + Application.DoEvents(); + } + } + + private async void BtnPurchaseImport_Click(object sender, EventArgs e) + { + if (this.dataTable == null || this.dataTable.Rows.Count == 0) + { + return; + } + var bomLookup = new Dictionary(); + try + { + foreach (DataRow row in this.dataTable.Rows) + { + var purchase = new Purchase.ufinterface(); + var body = new Purchase.entry(); + purchase.purchaseapp.header.code = row["请购单号"].ToString(); + purchase.purchaseapp.header.date = row["请购日"].ToString(); + purchase.purchaseapp.header.departmentcode = row["部门编码"].ToString(); + purchase.purchaseapp.header.personcode = row["请购人"].ToString(); + purchase.purchaseapp.header.purchasetypecode = row["采购类型编号"].ToString(); + purchase.purchaseapp.header.maker = row["制单人"].ToString(); + var strKey = purchase.purchaseapp.header.code; + if (bomLookup.ContainsKey(strKey)) + { + purchase = bomLookup[strKey]; + } + else + { + bomLookup.Add(strKey, purchase); + } + body.inventorycode = row["存货编码"].ToString(); + body.requiredate = purchase.purchaseapp.header.date; + body.quantity = decimal.Parse(row["数量"].ToString()); + purchase.purchaseapp.body.Add(body); + } + } + catch (Exception) + { + + this.richTextBox1.SelectionColor = Color.Red; + this.richTextBox1.AppendText("读取数据出错\r\n"); + return; + } + foreach (var item in bomLookup.Values) { var strbody = XmlHelper.XmlSerialize(item, Encoding.UTF8); - var response = await HttpHelper.Post("", strbody); - this.textBox1.Text += response; + var response = await this.HttpPost(strbody); + PrintLog(response); + Application.DoEvents(); } } + + private void richTextBox1_TextChanged(object sender, EventArgs e) + { + richTextBox1.SelectionStart = richTextBox1.Text.Length; + //滚动到光标位置 + richTextBox1.ScrollToCaret(); + } } } diff --git a/U8AppMain/FrmMain.resx b/U8AppMain/FrmMain.resx index 1af7de1..d5494e3 100644 --- a/U8AppMain/FrmMain.resx +++ b/U8AppMain/FrmMain.resx @@ -117,4 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + \ No newline at end of file diff --git a/U8AppMain/ResultEnity/Item.cs b/U8AppMain/ResultEnity/Item.cs new file mode 100644 index 0000000..36e0ffb --- /dev/null +++ b/U8AppMain/ResultEnity/Item.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; +namespace U8AppMain.ResultEnity +{ + public class Item + { + //  + + [XmlAttribute] + public string key { get; set; } + [XmlAttribute] + + public string succeed { get; set; } + [XmlAttribute] + public string dsc { get; set; } + [XmlAttribute] + public string u8key { get; set; } + } +} diff --git a/U8AppMain/ResultEnity/ufinterface.cs b/U8AppMain/ResultEnity/ufinterface.cs new file mode 100644 index 0000000..3ab5bad --- /dev/null +++ b/U8AppMain/ResultEnity/ufinterface.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; +namespace U8AppMain.ResultEnity +{ + public class ufinterface + { + // + //     + // + [XmlAttribute] + public string roottag { get; set; } + [XmlAttribute] + public string docid { get; set; } + [XmlAttribute] + public string proc { get; set; } + [XmlAttribute] + public string receiver { get; set; } + [XmlAttribute(attributeName: "request-roottag")] + public string requestroottag { get; set; } + + [XmlElement(Type = typeof(Item),ElementName ="item")] + public List Items { get; set; } = new List(); + } +} diff --git a/U8AppMain/U8AppMain.csproj b/U8AppMain/U8AppMain.csproj index 598b998..2643e9d 100644 --- a/U8AppMain/U8AppMain.csproj +++ b/U8AppMain/U8AppMain.csproj @@ -36,23 +36,8 @@ ..\packages\Portable.BouncyCastle.1.8.6\lib\net40\BouncyCastle.Crypto.dll - - ..\packages\Krypton.Components.Suite.4.5.9\lib\net20\ComponentFactory.Krypton.Design.dll - - - ..\packages\Krypton.Components.Suite.4.5.9\lib\net20\ComponentFactory.Krypton.Docking.dll - - - ..\packages\Krypton.Components.Suite.4.5.9\lib\net20\ComponentFactory.Krypton.Navigator.dll - - - ..\packages\Krypton.Components.Suite.4.5.9\lib\net20\ComponentFactory.Krypton.Ribbon.dll - - - ..\packages\Krypton.Components.Suite.4.5.9\lib\net20\ComponentFactory.Krypton.Toolkit.dll - - - ..\packages\Krypton.Components.Suite.4.5.9\lib\net20\ComponentFactory.Krypton.Workspace.dll + + ..\packages\Dapper.1.60.6\lib\net451\Dapper.dll ..\packages\SharpZipLib.1.2.0\lib\net45\ICSharpCode.SharpZipLib.dll @@ -70,6 +55,7 @@ ..\packages\NPOI.2.5.2\lib\net45\NPOI.OpenXmlFormats.dll + @@ -105,6 +91,8 @@ + + FrmMain.cs diff --git a/U8AppMain/XmlHelper.cs b/U8AppMain/XmlHelper.cs index 5a8f285..df7f639 100644 --- a/U8AppMain/XmlHelper.cs +++ b/U8AppMain/XmlHelper.cs @@ -53,7 +53,31 @@ namespace U8AppMain } } - + /// + /// + /// + /// + /// + /// + /// + public static T XmlDeserialize(string s, Encoding encoding) + { + if (string.IsNullOrEmpty(s)) + throw new ArgumentNullException("s"); + if (encoding == null) + throw new ArgumentNullException("encoding"); + + XmlSerializer mySerializer = new XmlSerializer(typeof(T)); + s = s.Replace(" ", " "); + using (MemoryStream ms = new MemoryStream(encoding.GetBytes(s))) + { + using (StreamReader sr = new StreamReader(ms, encoding)) + { + return (T)mySerializer.Deserialize(sr); + } + } + } + } } diff --git a/U8AppMain/packages.config b/U8AppMain/packages.config index ad70d18..543b7d0 100644 --- a/U8AppMain/packages.config +++ b/U8AppMain/packages.config @@ -1,5 +1,6 @@  +