Exemple #1
0
        private void ToolStripMenuItemLeaveFeedback_Click(object sender, EventArgs e)
        {
            DataGridViewSelectedRowCollection selectedRows = this.dataGridViewAllOrders.SelectedRows;

            foreach (DataGridViewRow row in selectedRows)
            {
                String orderLineItemId    = row.Cells[OrderDgv_OrderLineItemIndex].Value.ToString();
                EbayTransactionType trans = EbayTransactionDAL.GetOneTransaction(orderLineItemId);
                if (trans == null)
                {
                    continue;
                }

                AccountType account = AccountUtil.GetAccount(trans.SellerName);
                if (account == null)
                {
                    continue;
                }

                EbayTransactionBiz.LeaveFeedback(account, trans.OrderId, trans.BuyerId, trans.ItemId, trans.EbayTransactionId);

                EbayTransactionDAL.UpdateTransactionSellerLeftFeedback(trans.TransactionId, true);

                row.Cells[OrderDgv_SellerLeftFeedbackIndex].Value = 1;
            }

            MessageBox.Show("留好评成功", "恭喜", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        private void buttonUploadTrackingNumber_Click(object sender, EventArgs e)
        {
            if (ebayTrans == null || account == null)
            {
                return;
            }

            string sellerName = ebayTrans.SellerName;

            if (null == sellerName)
            {
                return;
            }

            string shippingCarrier        = textBoxCarrier.Text.Trim();
            string shipmentTrackingNumber = textBoxTrackingNumber.Text.Trim();

            if (shippingCarrier == "" || shipmentTrackingNumber == "")
            {
                MessageBox.Show("输入错误!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            EbayTransactionBiz.UploadTrackingNumber(account, ebayTrans.ItemId, ebayTrans.EbayTransactionId,
                                                    shippingCarrier, shipmentTrackingNumber);
            MessageBox.Show("上传跟踪号成功!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information);

            EbayTransactionDAL.UpdateTransactionShippingTrackingNo(ebayTrans.TransactionId, shipmentTrackingNumber);
        }
Exemple #3
0
        private void ToolStripMenuItemMergeOrders_Click(object sender, EventArgs e)
        {
            List <String> tranIdList = new List <String>();

            DataGridViewSelectedRowCollection selectedRows = this.dataGridViewAllOrders.SelectedRows;

            foreach (DataGridViewRow row in selectedRows)
            {
                String transId = row.Cells[OrderDgv_TransactionIdIndex].Value.ToString();
                tranIdList.Add(transId);
            }

            EbayTransactionBiz.MergeOrders(tranIdList);
        }
        //
        // User selected transactions and clicked "mark as shipped".
        //
        private void ToolStripMenuItemMarkAsShipped_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("你确认发货么?\r\n发货后,ebay会标记成已发货状态。",
                                "确认发货?",
                                MessageBoxButtons.YesNo,
                                MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
            {
                DataGridViewSelectedRowCollection selectedRows = this.dataGridViewAllOrders.SelectedRows;

                // First check if every transaction item has a related sku.
                foreach (DataGridViewRow row in selectedRows)
                {
                    String orderLineItemId = row.Cells[OrderDgv_OrderLineItemIndex].Value.ToString();

                    EbayTransactionType trans = EbayTransactionDAL.GetOneTransaction(orderLineItemId);
                    if (trans == null)
                    {
                        return;
                    }

                    if (trans.IsPaid == false)
                    {
                        MessageBox.Show("有些商品没有付款,不能发货!", "失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    if (trans.IsShipped == true)
                    {
                        MessageBox.Show("有些商品已经发货,不能重新发货!", "失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    if (trans.ItemSKU == null || trans.ItemSKU.Trim() == "")
                    {
                        MessageBox.Show("有些商品没有指定SKU!", "失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }

                List <String> handledOrderIds = new List <String>();

                foreach (DataGridViewRow row in selectedRows)
                {
                    String orderLineItemId = row.Cells[OrderDgv_OrderLineItemIndex].Value.ToString();

                    EbayTransactionType trans = EbayTransactionDAL.GetOneTransaction(orderLineItemId);
                    if (trans == null)
                    {
                        return;
                    }

                    if (trans.IsPaid == false || trans.IsShipped == true)
                    {
                        MessageBox.Show("商品未付款或者已经发货!", "失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        continue;
                    }

                    String orderId = trans.OrderId;

                    if (handledOrderIds.Contains(orderId))
                    {
                        continue;
                    }

                    AccountType        account     = null;
                    List <AccountType> allAccounts = AccountUtil.GetAllAccounts();
                    foreach (AccountType accountType in allAccounts)
                    {
                        if (accountType.ebayAccount == trans.SellerName)
                        {
                            account = accountType;
                            break;
                        }
                    }

                    if (account == null || account.SellerApiContext == null)
                    {
                        MessageBox.Show("账号没有初始化!", "失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    EbayTransactionBiz.CompleteSale(account, trans.OrderId, trans.BuyerId, trans.ItemId, trans.EbayTransactionId,
                                                    false, true, true, true /*isShipped*/);

                    handledOrderIds.Add(orderId);

                    StringCollection orderIds = new StringCollection();
                    orderIds.Add(trans.OrderId);
                    TimeFilter timeFilter = new TimeFilter();
                    timeFilter.TimeFrom = this.dateTimePickerStartTime.Value;
                    timeFilter.TimeTo   = this.dateTimePickerEndTime.Value;
                    List <EbayTransactionType> transList = EbayTransactionBiz.GetAllOrders(account, timeFilter, orderIds);
                    if (transList.Count != 1)
                    {
                        MessageBox.Show("交易在ebay系统中不存在!", "失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        continue;
                    }
                    if (transList[0].IsShipped == false)
                    {
                        MessageBox.Show(string.Format("该交易没有在ebay系统中标记成功! 用户id={0}", trans.BuyerId), "失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        continue;
                    }

                    // ZHI_TODO
                    //ItemDAL.ShipItem(trans.ItemSKU, trans.SaleQuantity);

                    // Update transaction shipped date.
                    EbayTransactionDAL.UpdateTransactionShippedStatus(trans.TransactionId, true /*shipped*/, transList[0].ShippedDate);

                    Logger.WriteSystemUserLog(string.Format("标记交易已发货成功: userId={0}, 商品名={1}", trans.BuyerId, trans.ItemTitle));

                    row.DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#90EE90");
                }

                MessageBox.Show("标记成发货成功!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemple #5
0
        // Get the orders asynchronously.
        //  Returns number of orders updated.
        private int GetOrdersAsync(DateTime startDate, DateTime endDate, out bool canceled)
        {
            canceled = false;
            int ordersFetched = 0;

            List <AccountType> allAccounts = AccountUtil.GetAllAccounts();

            foreach (AccountType account in allAccounts)
            {
                StringCollection orderIds    = EbayTransactionBiz.GetAllOrderIds(account, startDate, endDate);
                StringCollection newOrderIds = new StringCollection();
                foreach (String orderId in orderIds)
                {
                    newOrderIds.Add(orderId);
                }

                int orderNumRetrievePerTime = 1;

                int  apiCallTimes  = newOrderIds.Count / orderNumRetrievePerTime;
                bool needExtraCall = (newOrderIds.Count % orderNumRetrievePerTime) != 0;
                if (needExtraCall)
                {
                    apiCallTimes += 1;
                }

                List <EbayTransactionType> allTrans = new List <EbayTransactionType>();

                for (int ii = 0; ii < apiCallTimes; ++ii)
                {
                    StringCollection orderIdsLoc = new StringCollection();
                    for (int jj = ii * orderNumRetrievePerTime; jj < ii * orderNumRetrievePerTime + orderNumRetrievePerTime; ++jj)
                    {
                        if (jj > newOrderIds.Count - 1)
                        {
                            break;
                        }
                        orderIdsLoc.Add(newOrderIds[jj]);
                    }

                    TimeFilter timeFilter = new TimeFilter();
                    timeFilter.TimeFrom = startDate;
                    timeFilter.TimeTo   = endDate;

                    List <EbayTransactionType> transList = EbayTransactionBiz.GetAllOrders(account, timeFilter, orderIdsLoc);
                    foreach (EbayTransactionType trans in transList)
                    {
                        allTrans.Add(trans);
                    }

                    // Update the description and progress on the modal form
                    // using Control.Invoke.  Invoke will run the anonymous
                    // function to set the label's text on the UI thread.
                    // Since it's illegal to touch the UI control on the worker
                    // thread that we're on right now.

                    int retrievedCount = (ii + 1) * orderNumRetrievePerTime;
                    if (retrievedCount > newOrderIds.Count)
                    {
                        retrievedCount = newOrderIds.Count;
                    }

                    String labelHintStr = string.Format("正在从Ebay获取交易信息, 账号 {0}, 共{1}个订单, 已获得{2}个订单信息",
                                                        account.ebayAccount,
                                                        newOrderIds.Count,
                                                        retrievedCount);
                    int progressBarValue = (int)((double)(ii + 1) / apiCallTimes * 100);
                    frmProgress.SetLabelHintAndProgressBarValue(labelHintStr, progressBarValue);

                    foreach (EbayTransactionType trans in allTrans)
                    {
                        bool result = EbayTransactionDAL.InsertOrUpdateOneTransaction(trans);
                        if (result == false)
                        {
                            canceled = true;
                            return(ordersFetched);
                        }
                    }

                    // Periodically check for a Cancellation
                    // If the user clicks the cancel button, or tries to close
                    // the progress form the m_fmProgress.Cancel flag will be set to true.
                    if (frmProgress.Cancel)
                    {
                        canceled = true;
                        return(ordersFetched);
                    }
                }   // for (int ii = 0; ii < apiCallTimes; ++ii)

                ordersFetched += newOrderIds.Count;
            }   // foreach (AccountType account in AllAccounts)

            canceled = false;
            return(ordersFetched);
        }   // GetOrdersAsync