void StartDownloadDhlOrders(PromptForm prompt) { prompt.AddMessage("正在下载订单DHL数据...0%"); WebClient wc = new WebClient(); wc.DownloadProgressChanged += new DownloadProgressChangedEventHandler(wcDhlOrders_DownloadProgressChanged); wc.DownloadDataCompleted += new DownloadDataCompletedEventHandler(wcDhlOrders_DownloadDataCompleted); wc.DownloadDataAsync(new Uri(Common.URL_DHL), prompt); }
void StartDownloadProductInfos(PromptForm prompt) { prompt.AddMessage("正在下载产品信息...0%"); WebClient wc = new WebClient(); wc.DownloadProgressChanged += new DownloadProgressChangedEventHandler(wcProductInfo_DownloadProgressChanged); wc.DownloadDataCompleted += new DownloadDataCompletedEventHandler(wcProductInfo_DownloadDataCompleted); wc.DownloadDataAsync(new Uri(URL_PRODUCTS), prompt); }
void StartDownloadStockHistory(PromptForm prompt) { prompt.AddMessage("正在下载出入库数据...0%"); WebClient wcDownloadStockHistory = new WebClient(); wcDownloadStockHistory.DownloadProgressChanged += new DownloadProgressChangedEventHandler(wcDownloadStockHistory_DownloadProgressChanged); wcDownloadStockHistory.DownloadDataCompleted += new DownloadDataCompletedEventHandler(wcDownloadStockHistory_DownloadDataCompleted); wcDownloadStockHistory.DownloadDataAsync(new Uri(_databasePath), prompt); }
void StartDownloadPrepareHistory(PromptForm prompt) { prompt.AddMessage("正在下载出单记录...0%"); WebClient wcDownloadPrepareHistory = new WebClient(); wcDownloadPrepareHistory.DownloadDataCompleted += new DownloadDataCompletedEventHandler(wcDownloadPrepareHistory_DownloadDataCompleted); wcDownloadPrepareHistory.DownloadProgressChanged += new DownloadProgressChangedEventHandler(wcDownloadPrepareHistory_DownloadProgressChanged); wcDownloadPrepareHistory.DownloadDataAsync(new Uri(Common.URL_PREPARE_HISTORY), prompt); }
private void StartDownloadRefunds() { PromptForm prompt = new PromptForm(); prompt.Owner = this; prompt.Show(this); prompt.AddMessage("正在下载退货记录..."); WebClient wc = new WebClient(); wc.DownloadProgressChanged += new DownloadProgressChangedEventHandler(wc_DownloadProgressChanged); wc.DownloadDataCompleted += new DownloadDataCompletedEventHandler(wc_DownloadDataCompleted); wc.DownloadDataAsync(new Uri(Common.URL_REFUND), prompt); }
private void tsbtnImportOrders_Click(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; try { if (null != _orders) { DialogResult dr = MessageBox.Show( this, "重新导入订单将会覆盖未同步到服务器的数据(例如出单状态).\n是否继续导入?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); if (DialogResult.No == dr) { return; } } OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "XML Files (*.xml)|*.xml"; ofd.Multiselect = false; ofd.ShowReadOnly = false; if (DialogResult.OK == ofd.ShowDialog(this)) { PromptForm dof = new PromptForm(); dof.Owner = this; dof.AddMessage("正在解析订单..."); dof.Show(); Application.DoEvents(); XmlDocument doc = new XmlDocument(); doc.Load(ofd.FileName); LoadOrdersFormXmlStream(doc.OuterXml, dof); } } catch (Exception ex) { MessageBox.Show(this, ex.ToString(), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } finally { Cursor.Current = Cursors.Default; } }
void StartDownloadOrders(PromptForm prompt) { prompt.AddMessage("正在下载订单...0%"); WebClient wcDownloadOrders = new WebClient(); wcDownloadOrders.DownloadDataCompleted += new DownloadDataCompletedEventHandler(wcDownloadOrders_DownloadDataCompleted); wcDownloadOrders.DownloadProgressChanged += new DownloadProgressChangedEventHandler(wcDownloadOrders_DownloadProgressChanged); wcDownloadOrders.DownloadDataAsync(new Uri(URL_ORDERS), prompt); //HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(string.Format(URL_DATA_CENTER, "getallorders")); //request.Method = "GET"; //request.ContentType = "text/xml"; //WebResponse response = request.GetResponse(); //StreamReader reader = new StreamReader(response.GetResponseStream()); ////Trace.WriteLine(reader.ReadToEnd()); ////Trace.WriteLine(""); //string xml = reader.ReadToEnd(); //reader.Close(); }
void StartDownloadStockHistory(PromptForm prompt) { string dbfilename = string.Empty; switch (_stockLocation) { case OrderLib.ShippingOrigins.Shanghai: dbfilename = Common.URL_STOCK_SH; break; case OrderLib.ShippingOrigins.Ningbo: dbfilename = Common.URL_STOCK_NINGBO; break; } prompt.AddMessage("正在下载出入库记录...0%"); WebClient wcDownloadStockHistory = new WebClient(); wcDownloadStockHistory.DownloadProgressChanged += new DownloadProgressChangedEventHandler(wcDownloadStockHistory_DownloadProgressChanged); wcDownloadStockHistory.DownloadDataCompleted += new DownloadDataCompletedEventHandler(wcDownloadStockHistory_DownloadDataCompleted); wcDownloadStockHistory.DownloadDataAsync(new Uri(dbfilename), prompt); }
private void StockStatForm_Shown(object sender, EventArgs e) { //HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(string.Format(MainForm.URL_DATA_CENTER, "getstockhistorysh")); //request.Method = "GET"; //request.ContentType = "text/xml"; //WebResponse response = request.GetResponse(); //StreamReader reader = new StreamReader(response.GetResponseStream()); ////Trace.WriteLine(reader.ReadToEnd()); ////Trace.WriteLine(""); PromptForm prompt = new PromptForm(); prompt.Owner = this; prompt.Show(this); prompt.AddMessage("正在下载出入库数据..."); WebClient wc = new WebClient(); wc.DownloadProgressChanged += new DownloadProgressChangedEventHandler(wc_DownloadProgressChanged); wc.DownloadDataCompleted += new DownloadDataCompletedEventHandler(wc_DownloadDataCompleted); wc.DownloadDataAsync(new Uri(Common.URL_STOCK_SH), prompt); }
void LoadOrdersFormXmlStream(string xml, PromptForm prompt) { _downloadedOrderXml = xml; List <Order> orders = Order.LoadXmlStream(_downloadedOrderXml, true); //// temp statistics. //int xx = 0, jj = 0, su = 0, ruyi = 0, yoyo = 0; //foreach (Order o in orders) //{ // if (o.Remark.ToLower().Contains("@xx")) // xx++; // if (o.Remark.ToLower().Contains("@俊俊")) // jj++; // if (o.Remark.ToLower().Contains("@小苏")) // su++; // if (o.Remark.ToLower().Contains("@如意")) // ruyi++; // if (o.Remark.ToLower().Contains("@yoyo") || o.Remark.ToLower().Contains("#yoyo")) // yoyo++; //} //Trace.Write(string.Format("xx={0}, jj={1}, su={2}, ruyi={3}, yoyo={4}", xx, jj, su, ruyi, yoyo)); if (null == orders || orders.Count <= 0) { MessageBox.Show( this, "数据下载(导入)成功, 但是解析失败, 没有解析到任何订单信息.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } prompt.Messages[prompt.Messages.Count - 1].Content = string.Format("成功下载(导入){0}个订单.", orders.Count); prompt.RefreshDisplay(); prompt.AddMessage("正在显示订单..."); _filterBuyer = string.Empty; txtKeyword.Text = string.Empty; Reload(); // Get last modified date and time. XmlDocument xmldoc = new XmlDocument(); xmldoc.LoadXml(xml); string lastModified = "Unknown"; //xmldoc.DocumentElement.Attributes.GetNamedItem("last_modified").Value; if (null != xmldoc.DocumentElement.Attributes.GetNamedItem("last_modified")) { lastModified = xmldoc.DocumentElement.Attributes.GetNamedItem("last_modified").Value; } prompt.Messages[prompt.Messages.Count - 1].Content = string.Format("成功显示{0}个订单.\n", _filteredOrders.Count); prompt.AddMessage(string.Format("服务器订单数据最后更新时间: {0}", lastModified)); DateTime startDate = DateTime.MaxValue, endDate = DateTime.MinValue; foreach (Order o in _orders) { if (o.DealTime < startDate) { startDate = o.DealTime; } if (o.DealTime > endDate) { endDate = o.DealTime; } } prompt.AddMessage(string.Format("已下载订单起止时间(按拍下时间): {0} ~ {1}", startDate.ToString("yyyy-MM-dd HH:mm:ss"), endDate.ToString("yyyy-MM-dd HH:mm:ss"))); prompt.OKEnabled = true; }