Exemple #1
0
        private void ToolStripMenuItemViewMessage_Click(object sender, EventArgs e)
        {
            int    rowIdx          = this.dataGridViewPostSale.CurrentRow.Index;
            String orderLineItemId = this.dataGridViewPostSale.Rows[rowIdx].Cells[PostSaleDgv_OrderLineItemIdIdx].Value.ToString();

            EbayTransactionType trans = EbayTransactionDAL.GetOneTransaction(orderLineItemId);

            if (trans == null)
            {
                return;
            }

            AccountType account = AccountUtil.GetAccount(trans.SellerName);

            if (account == null)
            {
                MessageBox.Show(String.Format("此账号{0}未绑定到系统", trans.SellerName),
                                "抱歉", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            FrmUserMessage frmUserMessage = new FrmUserMessage();

            frmUserMessage.EbayTransaction = trans;
            frmUserMessage.Account         = account;
            frmUserMessage.ShowDialog();

            if (frmUserMessage.SentMessage || frmUserMessage.MarkMsgAsReplied)
            {
                LoadPostSaleData();
            }
        }
Exemple #2
0
        // Upload tracking number to ebay.
        // While uploading tracking number, ebay requires two fields:
        //  - tracking number
        //  - carrier
        // Use Ebay API CompleteSale to fulfill this task, see page:
        // https://developer.ebay.com/DevZone/XML/docs/Reference/ebay/CompleteSale.html
        private void ToolStripMenuItemUploadTrackingNum_Click(object sender, EventArgs e)
        {
            DataGridViewSelectedRowCollection selectedRows = this.dataGridViewAllOrders.SelectedRows;

            if (selectedRows.Count != 1)
            {
                return;
            }

            String orderLineItemId    = selectedRows[0].Cells[OrderDgv_OrderLineItemIndex].Value.ToString();
            EbayTransactionType trans = EbayTransactionDAL.GetOneTransaction(orderLineItemId);

            if (trans == null)
            {
                return;
            }

            if (trans.ShippingTrackingNo != "")
            {
                MessageBox.Show("该订单已经上传跟踪号", "抱歉", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            FrmUploadTrackingNumber frmUploadTrackingNumber = new FrmUploadTrackingNumber();

            frmUploadTrackingNumber.account   = AccountUtil.GetAccount(trans.SellerName);
            frmUploadTrackingNumber.ebayTrans = trans;
            frmUploadTrackingNumber.Show();

            trans = EbayTransactionDAL.GetOneTransaction(orderLineItemId);
            selectedRows[0].Cells[OrderDgv_TrackingNoIndex].Value = trans.ShippingTrackingNo;
        }
Exemple #3
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);
        }
        //
        // http://developer.ebay.com/DevZone/XML/docs/Reference/ebay/AddOrder.html
        //  Only incomplete transactions can be combined, otherwise there will be error message:
        //      "Some transactions have already been completed, you can only combine incomplete transactions".
        //
        public static bool MergeOrders(List <String> transactionIds)
        {
            if (transactionIds.Count < 2)
            {
                return(false);
            }

            // Verify that all transactions are between same buyer and seller.
            String buyer  = "";
            String seller = "";
            Double total  = 0.0;

            foreach (String tranId in transactionIds)
            {
                EbayTransactionType trans = EbayTransactionDAL.GetOneTransactonById(tranId);
                if (trans == null)
                {
                    return(false);
                }

                if (buyer != "" && buyer != trans.BuyerName)
                {
                    return(false);
                }

                if (seller != "" && seller != trans.SellerName)
                {
                    return(false);
                }

                buyer  = trans.BuyerName;
                seller = trans.SellerName;

                total += trans.ItemPrice * trans.SaleQuantity;
            }

            AccountType account = AccountUtil.GetAccount(seller);

            if (account == null)
            {
                return(false);
            }

            AddOrderCall addOrderCall = new AddOrderCall(account.SellerApiContext);
            OrderType    orderType    = new eBay.Service.Core.Soap.OrderType();

            orderType = new eBay.Service.Core.Soap.OrderType();
            orderType.CreatingUserRole = TradingRoleCodeType.Seller;
            orderType.PaymentMethods   = new eBay.Service.Core.Soap.BuyerPaymentMethodCodeTypeCollection();
            orderType.PaymentMethods.Add(BuyerPaymentMethodCodeType.PayPal);
            orderType.Total            = new eBay.Service.Core.Soap.AmountType();
            orderType.Total.Value      = total;
            orderType.Total.currencyID = CurrencyCodeType.USD;
            orderType.TransactionArray = new eBay.Service.Core.Soap.TransactionTypeCollection();

            foreach (String tranId in transactionIds)
            {
                EbayTransactionType trans = EbayTransactionDAL.GetOneTransactonById(tranId);
                if (trans == null)
                {
                    return(false);
                }

                TransactionType tranType = new TransactionType();
                tranType.Item          = new ItemType();
                tranType.Item.ItemID   = trans.ItemId;
                tranType.TransactionID = trans.EbayTransactionId;
                orderType.TransactionArray.Add(tranType);
            }

            String orderId = addOrderCall.AddOrder(orderType);

            return(true);
        }
Exemple #5
0
        private void SendMessageAsync(object sender, DoWorkEventArgs e)
        {
            object[]  paramArr      = e.Argument as object[];
            DataTable dtOrders      = (DataTable)paramArr[0];
            String    messageToSend = (String)paramArr[1];

            int curIdx = 0;

            foreach (DataRow row in dtOrders.Rows)
            {
                curIdx++;

                String sellerName      = StringUtil.GetSafeString(row["SellerName"]);
                String buyerId         = StringUtil.GetSafeString(row["BuyerId"]);
                String itemId          = StringUtil.GetSafeString(row["ItemId"]);
                String orderLineItemId = StringUtil.GetSafeString(row["OrderLineItemId"]);

                EbayTransactionType transLoc = EbayTransactionDAL.GetOneTransaction(orderLineItemId);
                if (transLoc == null)
                {
                    continue;
                }

                String subject = String.Format("{0} sent a message on item {1} with itemId {2}",
                                               sellerName,
                                               buyerId,
                                               itemId);

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

                String labelHintStr = String.Format("正在向买家 {0} 发送消息.... 进度 {1} / {2}",
                                                    buyerId, curIdx, dtOrders.Rows.Count);
                int progressBarValue = (int)((double)(curIdx) / dtOrders.Rows.Count * 100);
                frmProgress.SetLabelHintAndProgressBarValue(labelHintStr, progressBarValue);

                if (frmProgress.Cancel)
                {
                    e.Cancel = true;
                    e.Result = curIdx;
                    return;
                }

                messageToSend = replaceMessageMacros(messageToSend, transLoc);

                bool result = EbayMessageBiz.SendMessageToBuyer(account,
                                                                buyerId,
                                                                itemId,
                                                                subject,
                                                                messageToSend,
                                                                true /*emailCopyToSender*/,
                                                                eBay.Service.Core.Soap.QuestionTypeCodeType.General);

                if (result)
                {
                    DateTime startTime = DateTime.Now;
                    DateTime endTime   = startTime;
                    startTime = startTime.Subtract(new TimeSpan(0, 5, 0));

                    startTime = startTime.ToUniversalTime();
                    endTime   = endTime.ToUniversalTime();

                    // Get all message ids within this five minutes.
                    StringCollection msgIds = EbayMessageBiz.GetAllMessageIds(account, startTime, endTime);

                    // Skip the messages we have retrieved.
                    StringCollection newMsgIds = new StringCollection();
                    {
                        foreach (String msgId in msgIds)
                        {
                            EbayMessageType existedMessage = EbayMessageDAL.GetOneMessage(msgId);
                            if (existedMessage != null)
                            {
                                continue;
                            }

                            newMsgIds.Add(msgId);
                        }
                    }

                    List <EbayMessageType> newMessages = EbayMessageBiz.GetAllMessageByIds(account, newMsgIds);

                    Logger.WriteSystemLog(String.Format("Retrieved new messages count={0}", newMsgIds.Count));

                    foreach (EbayMessageType messageType in newMessages)
                    {
                        // We are pretty sure the message didn't exist.
                        EbayMessageDAL.InsertOneMessage(messageType);

                        // Update the transaction message status.
                        String recipientUserId = messageType.RecipientUserId;
                        String senderName      = messageType.Sender;
                        String sellerNameLoc   = messageType.SellerName;
                        String buyerIdLoc      = sellerNameLoc == senderName ? recipientUserId : senderName;

                        // [ZHI_TODO]
                        TransactionMessageStatus messageStatus = EbayMessageDAL.GetTransactionMessageStatus(buyerIdLoc, sellerNameLoc, messageType.ItemID);

                        List <EbayTransactionType> transList = EbayTransactionDAL.GetTransactionsBySellerBuyerItem(sellerNameLoc, buyerIdLoc, messageType.ItemID);
                        foreach (EbayTransactionType trans in transList)
                        {
                            EbayTransactionDAL.UpdateTransactionMessageStatus(trans.TransactionId, messageStatus);
                        }
                    }
                }
                else
                {
                    Logger.WriteSystemUserLog("发送消息失败!");
                }
            }
            e.Result = OrdersDataTable.Rows.Count;
        } // SendMessageAsync