Exemplo n.º 1
0
        void wcProductInfo_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
        {
            PromptForm prompt = e.UserState as PromptForm;

            string      xml    = Encoding.UTF8.GetString(e.Result);
            XmlDocument xmldoc = new XmlDocument();

            xmldoc.LoadXml(xml);
            XmlNodeList nlProducts = xmldoc.SelectNodes(".//product");

            if (null == nlProducts || nlProducts.Count <= 0)
            {
                return;
            }

            foreach (XmlNode nodeProduct in nlProducts)
            {
                string id        = nodeProduct.Attributes.GetNamedItem("id").Value;
                string brand     = nodeProduct.Attributes.GetNamedItem("brand").Value;
                string name      = nodeProduct.Attributes.GetNamedItem("name").Value;
                string shortname = nodeProduct.Attributes.GetNamedItem("shortname").Value;
                string keywords  = nodeProduct.Attributes.GetNamedItem("keywords").Value;
                ProductInfo.ProductInfos.Add(new ProductInfo(id, brand, name, shortname, keywords));
            }

            prompt.Messages[prompt.Messages.Count - 1].Content = string.Format("成功下载{0}个产品信息.", ProductInfo.ProductInfos.Count);
            prompt.RefreshDisplay();

            StartDownloadOrders(prompt);
        }
Exemplo n.º 2
0
        void wcDownloadOrders_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
        {
            PromptForm prompt = e.UserState as PromptForm;
            string     xml    = Encoding.UTF8.GetString(e.Result);

            LoadOrdersFormXmlStream(xml, prompt);
        }
Exemplo n.º 3
0
        void wcDownloadStockHistory_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
        {
            PromptForm prompt = e.UserState as PromptForm;

            prompt.OKEnabled = true;

            string xml = Encoding.UTF8.GetString(e.Result);

            _history = GetStockHistory(xml);
            RefreshHistoryList(_history);
            RefreshStockList(_history);

            //int c = 0;
            //foreach (StockHistoryRecord r in _history)
            //{
            //    if (r.DateTime < new DateTime(2014, 02, 10))
            //        continue;
            //    if (!r.FromTo.Equals("德诺"))
            //        continue;
            //    if (!r.ProductId.Equals("001-0005"))
            //        continue;
            //    c += r.Count;
            //}
            //System.Diagnostics.Trace.WriteLine(c);
        }
Exemplo n.º 4
0
        void wcDhlOrders_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
        {
            PromptForm prompt = e.UserState as PromptForm;

            prompt.Messages[prompt.Messages.Count - 1].Content = string.Format("正在下载订单DHL数据...{0}%", e.ProgressPercentage);
            prompt.RefreshDisplay();
        }
Exemplo n.º 5
0
        void StartDownload()
        {
            PromptForm prompt = new PromptForm();

            prompt.Owner = this;
            prompt.Show(this);

            StartDownloadProductInfos(prompt);
        }
Exemplo n.º 6
0
        private void PreparationQueryForm_Load(object sender, EventArgs e)
        {
            PromptForm prompt = new PromptForm();

            prompt.MaxLine = 2;
            prompt.Owner   = this;
            prompt.Show(this);
            StartDownloadPrepareHistory(prompt);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        void wcDownloadStockHistory_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
        {
            PromptForm prompt = e.UserState as PromptForm;

            prompt.OKEnabled = true;

            _stockHistoryXml = Encoding.UTF8.GetString(e.Result);
            Stat(_stockHistoryXml);
        }
Exemplo n.º 11
0
        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);
        }
Exemplo n.º 12
0
        void StartDownload()
        {
            PromptForm prompt = new PromptForm();

            prompt.MaxLine = 2;
            prompt.Owner   = this;
            prompt.Show(this);

            StartDownloadDhlOrders(prompt);
        }
Exemplo n.º 13
0
        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);
        }
Exemplo n.º 14
0
        void wcProductInfo_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
        {
            PromptForm prompt = e.UserState as PromptForm;

            string xml = Encoding.UTF8.GetString(e.Result);

            BrandInfo.InitializeBrands(xml);
            ProductInfo.InitializeProducts(xml);

            prompt.Messages[prompt.Messages.Count - 1].Content = string.Format("成功下载{0}个产品信息.", ProductInfo.Products.Count);
            prompt.RefreshDisplay();

            StartDownloadStockHistory(prompt);
        }
Exemplo n.º 15
0
        void wcDhlOrders_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
        {
            PromptForm prompt = e.UserState as PromptForm;

            string      xml    = Encoding.UTF8.GetString(e.Result);
            XmlDocument xmldoc = new XmlDocument();

            xmldoc.LoadXml(xml);
            XmlNodeList nodeDhlOrders = xmldoc.SelectNodes(".//order");

            if (null == nodeDhlOrders || nodeDhlOrders.Count <= 0)
            {
                return;
            }

            foreach (XmlNode nodeDhlOrder in nodeDhlOrders)
            {
                string   orderId        = nodeDhlOrder.Attributes.GetNamedItem("order_id").Value;
                string   buyer          = nodeDhlOrder.Attributes.GetNamedItem("buyer").Value;
                string   shipmentNumber = nodeDhlOrder.Attributes.GetNamedItem("shipment_number").Value;
                string   payingTime     = nodeDhlOrder.Attributes.GetNamedItem("paying_time").Value;
                string   pdfTime        = nodeDhlOrder.Attributes.GetNamedItem("pdf_time").Value;
                string   pickupTime     = nodeDhlOrder.Attributes.GetNamedItem("pickup_time").Value;
                string   resendTime     = nodeDhlOrder.Attributes.GetNamedItem("resend_time").Value;
                DhlOrder o = new DhlOrder(orderId, buyer, shipmentNumber);

                DateTime dt = DateTime.MinValue;
                if (DateTime.TryParse(payingTime, out dt))
                {
                    o.PayingTime = dt;
                }
                if (DateTime.TryParse(pdfTime, out dt))
                {
                    o.PdfTime = dt;
                }
                if (DateTime.TryParse(pickupTime, out dt))
                {
                    o.PickedupTime = dt;
                }
                if (DateTime.TryParse(resendTime, out dt))
                {
                    o.ResendTime = dt;
                }
                DhlOrder.DhlOrders.Add(o);
            }

            prompt.Messages[prompt.Messages.Count - 1].Content = string.Format("成功下载{0}个订单的DHL数据.", DhlOrder.DhlOrders.Count);
            prompt.RefreshDisplay();
            prompt.OKEnabled = true;
        }
Exemplo n.º 16
0
        void wc_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
        {
            PromptForm prompt = e.UserState as PromptForm;

            prompt.OKEnabled = true;

            string      xml = Encoding.UTF8.GetString(e.Result);
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xml);

            XmlNodeList nlRefunds = doc.SelectNodes(".//refund");

            if (null == nlRefunds || nlRefunds.Count <= 0)
            {
                return;
            }

            _refunds = new List <Refund>();

            foreach (XmlNode nodeRefund in nlRefunds)
            {
                string op         = nodeRefund.Attributes.GetNamedItem("operator").Value;
                string date       = nodeRefund.Attributes.GetNamedItem("date").Value;
                string shipmentNo = nodeRefund.Attributes.GetNamedItem("shipment_no").Value;
                string src        = nodeRefund.Attributes.GetNamedItem("src").Value;
                string item       = nodeRefund.Attributes.GetNamedItem("item").Value;
                string comment    = nodeRefund.Attributes.GetNamedItem("comment").Value;
                _refunds.Add(new Refund(op, DateTime.Parse(date), shipmentNo, src, item, comment));
            }

            if (null == _refunds || _refunds.Count <= 0)
            {
                return;
            }

            prompt.Messages[prompt.Messages.Count - 1].Content = string.Format("下载退货记录完成: 共下载{0}条退货记录%", _refunds.Count);
            prompt.RefreshDisplay();

            lvwRefunds.Items.Clear();

            foreach (Refund r in _refunds)
            {
                RefundListViewItem ritem = new RefundListViewItem(r);
                lvwRefunds.Items.Add(ritem);
                //ritem.EnsureVisible();
            }
        }
Exemplo n.º 17
0
        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;
            }
        }
Exemplo n.º 18
0
        void wcDownloadPrepareHistory_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
        {
            MemoryStream ms     = new MemoryStream(e.Result);
            StreamReader reader = new StreamReader(ms);
            string       xml    = reader.ReadToEnd();

            //Trace.WriteLine(xml);
            reader.Close();
            ms.Close();

            int c = PrepareHistory.Load(xml);

            PromptForm prompt = e.UserState as PromptForm;

            prompt.Messages[prompt.Messages.Count - 1].Content = string.Format("成功下载{0}条出单记录.", c);
            prompt.RefreshDisplay();
            prompt.OKEnabled = true;
        }
Exemplo n.º 19
0
        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.MaxLine = 2;
            prompt.Owner   = this;
            prompt.Show(this);

            StartDownloadProductInfos(prompt);
        }
Exemplo n.º 20
0
        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();
        }
Exemplo n.º 21
0
        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);
        }
Exemplo n.º 22
0
        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);
        }
Exemplo n.º 23
0
        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;
        }