Ejemplo n.º 1
1
        public static List<EbayTransactionType> GetAllOrders(AccountType account, TimeFilter timeFilter, StringCollection orderIds)
        {
            List<EbayTransactionType> transList = new List<EbayTransactionType>();

            GetOrdersCall getOrdersApiCall = new GetOrdersCall(account.SellerApiContext);
            getOrdersApiCall.IncludeFinalValueFee = true;
            DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] { DetailLevelCodeType.ReturnAll };
            getOrdersApiCall.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels);
            if (orderIds != null)
                getOrdersApiCall.OrderIDList = orderIds;

            try
            {
                OrderTypeCollection orders = getOrdersApiCall.GetOrders(timeFilter, TradingRoleCodeType.Seller, OrderStatusCodeType.All);

                foreach (OrderType order in orders)
                {
                    AddressType addressType = order.ShippingAddress;
                    String shippingAddress = GetShippingAddressString(addressType);
                    String shippingAddressCompact = GetShippingAddressCompactString(addressType);

                    bool completed = order.OrderStatus == OrderStatusCodeType.Completed;

                    foreach (TransactionType trans in order.TransactionArray)
                    {
                        #region Process each ebay transaction
                        // Check if this transaction has already be recorded in system.
                        String transId = trans.TransactionID;
                        if (transId == null || transId == "")
                        {
                            Logger.WriteSystemLog("GetAllOrders: Invalid transaction id, skip and continue.");
                            continue;
                        }

                        EbayTransactionType ebayTrans = new EbayTransactionType();
                        ebayTrans.SellerName = account.ebayAccount;
                        ebayTrans.OrderId = order.OrderID;
                        ebayTrans.OrderLineItemId = trans.OrderLineItemID;
                        ebayTrans.EbayTransactionId = trans.TransactionID;
                        ebayTrans.EbayRecordId = order.ShippingDetails.SellingManagerSalesRecordNumberSpecified ? order.ShippingDetails.SellingManagerSalesRecordNumber : -1;
                        ebayTrans.BuyerId = order.BuyerUserID;

                        GetUserCall getUserApiCall = new GetUserCall(account.SellerApiContext);
                        getUserApiCall.UserID = order.BuyerUserID;
                        UserType user = getUserApiCall.GetUser();

                        // BuyerRating
                        if (user.FeedbackScoreSpecified)
                            ebayTrans.BuyerRating = user.FeedbackScore;
                        else
                            ebayTrans.BuyerRating = -1;

                        // BuyerCountryEbayCode
                        ebayTrans.BuyerCountryEbayCode = addressType.Country.ToString();
                        // BuyerCountry4PXCode
                        ebayTrans.BuyerCountry4PXCode = "";

                        // BuyerCountry
                        ebayTrans.BuyerCountry = addressType.CountryName;
                        // BuyerCompanyName
                        ebayTrans.BuyerCompanyName = StringUtil.GetSafeString(addressType.CompanyName);
                        // BuyerName
                        ebayTrans.BuyerName = addressType.Name;
                        // BuyerStateOrProvince
                        ebayTrans.BuyerStateOrProvince = addressType.StateOrProvince;
                        // BuyerCity
                        ebayTrans.BuyerCity = addressType.CityName;
                        // BuyerTel
                        ebayTrans.BuyerTel = addressType.Phone;
                        // BuyerMail
                        ebayTrans.BuyerMail = trans.Buyer.Email;
                        // BuyerPostalCode
                        ebayTrans.BuyerPostalCode = addressType.PostalCode;

                        // BuyerAddress
                        ebayTrans.BuyerAddress = shippingAddress;
                        // BuyerAddressCompact
                        ebayTrans.BuyerAddressCompact = shippingAddressCompact;
                        // BuyerAddressLine1
                        ebayTrans.BuyerAddressLine1 = addressType.Street1;
                        // BuyerAddressLine2
                        ebayTrans.BuyerAddressLine2 = addressType.Street2;
                        // BuyerPayPal
                        ebayTrans.BuyerPayPal = trans.Buyer.Email;

                        // ItemId
                        ebayTrans.ItemId = trans.Item.ItemID;

                        // What is the valid way to determine if there is a variation.
                        if (trans.Variation != null && trans.Variation.VariationTitle != null && trans.Variation.VariationTitle.Trim() != "")
                        {
                            // ItemTitle
                            ebayTrans.ItemTitle = trans.Variation.VariationTitle;
                            // ItemSKU
                            ebayTrans.ItemSKU = trans.Variation.SKU;
                        }
                        else
                        {
                            // ItemTitle
                            ebayTrans.ItemTitle = trans.Item.Title;
                            // ItemSKU
                            ebayTrans.ItemSKU = trans.Item.SKU;
                        }

                        // ItemPrice
                        if (trans.TransactionPrice != null)
                            ebayTrans.ItemPrice = trans.TransactionPrice.Value;
                        // SaleQuantity
                        ebayTrans.SaleQuantity = trans.QuantityPurchased;

                        if (trans.TransactionPrice != null)
                        {
                            // SalePrice
                            ebayTrans.SalePrice = trans.TransactionPrice.Value * trans.QuantityPurchased;
                            // TotalPrice
                            ebayTrans.TotalPrice = trans.TransactionPrice.Value * trans.QuantityPurchased;
                        }

                        // TODO: there may be multiple transactions in one order.
                        if (order.Total != null)
                        {
                            ebayTrans.TotalPrice = order.Total.Value;
                            ebayTrans.CurrencyId = order.Total.currencyID.ToString();
                        }
                        else
                        {
                            // Set a default value.
                            ebayTrans.TotalPrice = 0.0;
                            ebayTrans.CurrencyId = "";
                        }

                        // SaleDate
                        ebayTrans.SaleDate = order.CreatedTime;
                        // SaleDateCN
                        ebayTrans.SaleDateCN = order.CreatedTime.ToLocalTime();
                        // IsPaid
                        ebayTrans.IsPaid = order.PaidTimeSpecified;

                        // order.AmountPaid
                        // order.CheckoutStatus
                        //      ebayPaymentStatus
                        //      Status
                        // orderStatus
                        if (ebayTrans.IsPaid == false)
                        {
                            // Some payment is paid using credit card, and while PayPal is processing the payment,
                            // the transaction is marked as unpaid. we should view it as paid.
                            if (order.OrderStatusSpecified && order.OrderStatus == OrderStatusCodeType.Completed)
                                ebayTrans.IsPaid = true;
                        }

                        if (ebayTrans.IsPaid == false)
                        {
                            if (order.CheckoutStatus.StatusSpecified && order.CheckoutStatus.Status == CompleteStatusCodeType.Complete)
                                ebayTrans.IsPaid = true;
                        }

                        // PaidDate
                        ebayTrans.PaidDate = StringUtil.GetSafeDateTime(order.PaidTime);
                        // IsShipped
                        ebayTrans.IsShipped = order.ShippedTimeSpecified;
                        if (order.ShippedTimeSpecified)
                            ebayTrans.ShippedDate = StringUtil.GetSafeDateTime(order.ShippedTime);
                        else
                            ebayTrans.ShippedDate = DateTime.Now.AddYears(-10);

                        // Store the shippedDate as the local date time.
                        ebayTrans.ShippedDate = ebayTrans.ShippedDate.ToLocalTime();

                        // ShippingServiceCode
                        ebayTrans.ShippingServiceCode = "";
                        // ShippingService
                        ebayTrans.ShippingService = "";
                        // ShippingTrackingNo
                        ebayTrans.ShippingTrackingNo = "";
                        // ShippingCost
                        ebayTrans.ShippingCost = 0.0;
                        // FinalValueFee
                        if (trans.FinalValueFee != null)
                            ebayTrans.FinalValueFee = trans.FinalValueFee.Value;
                        else
                            ebayTrans.FinalValueFee = 0.0;
                        // PayPalFee
                        ebayTrans.PayPalFee = 0.034 * ebayTrans.TotalPrice + 0.3;

                        // IsReceived
                        ebayTrans.IsReceived = false;
                        ebayTrans.IsBuyerLeftFeedback = false;
                        ebayTrans.IsSellerLeftFeedback = false;
                        ebayTrans.IsNeedAttention = false;
                        ebayTrans.MessageStatus = TransactionMessageStatus.NoMessage;
                        ebayTrans.IsContactedBuyer = false;
                        ebayTrans.LastContactedBuyerDate = DateTime.Now.AddYears(-10);
                        ebayTrans.IsResendReplacement = false;
                        ebayTrans.UserComment = "";

                        GetFeedbackCall getFeedbackApiCall = new GetFeedbackCall(account.SellerApiContext);
                        //DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] { DetailLevelCodeType.ReturnAll };
                        getFeedbackApiCall.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels);
                        getFeedbackApiCall.OrderLineItemID = trans.OrderLineItemID;
                        FeedbackDetailTypeCollection feedbacks = getFeedbackApiCall.GetFeedback();
                        foreach (FeedbackDetailType feedback in feedbacks)
                        {
                            if (feedback.CommentingUser == account.ebayAccount)
                                ebayTrans.IsSellerLeftFeedback = true;

                            if (feedback.CommentingUser == ebayTrans.BuyerId)
                                ebayTrans.IsBuyerLeftFeedback = true;
                        }

                        if (trans.ShippingDetails != null)
                        {
                            if (trans.ShippingDetails.ShipmentTrackingDetails.Count == 1)
                            {
                                ShipmentTrackingDetailsType shipmentDetails = trans.ShippingDetails.ShipmentTrackingDetails[0];
                                ebayTrans.ShippingTrackingNo = shipmentDetails.ShipmentTrackingNumber;
                            }
                        }

                        transList.Add(ebayTrans);

                        #endregion
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.WriteSystemLog(string.Format("Unexpected expection : {0}", ex.Message));
            }

            return transList;
        }
Ejemplo n.º 2
1
        // Send a message to buyer.
        //  Note we can send a message to multiple users in single API call.
        //  See reference: AddMemberMessageAAQToPartner
        //      http://developer.ebay.com/DevZone/XML/docs/Reference/eBay/AddMemberMessageAAQToPartner.html
        //
        public static bool SendMessageToBuyer(AccountType account, String buyerId, String itemId,
            String subject, String body, bool emailCopyToSender, QuestionTypeCodeType questionType)
        {
            if (account == null || account.SellerApiContext == null)
                return false;

            AddMemberMessageAAQToPartnerCall apiCall = new AddMemberMessageAAQToPartnerCall(account.SellerApiContext);
            apiCall.ItemID = itemId;
            apiCall.MemberMessage = new MemberMessageType();
            apiCall.MemberMessage.EmailCopyToSender = emailCopyToSender;
            apiCall.MemberMessage.QuestionType = questionType;
            StringCollection recipientIds = new StringCollection();
            recipientIds.Add(buyerId);
            apiCall.MemberMessage.RecipientID = recipientIds;
            apiCall.MemberMessage.Subject = "";
            apiCall.MemberMessage.Body = body;

            bool result = false;
            try
            {
                apiCall.AddMemberMessageAAQToPartner(apiCall.ItemID, apiCall.MemberMessage);
                result = true;
            }
            catch (System.Exception ex)
            {
                Logger.WriteSystemUserLog(string.Format("Error when sending message to buyer, msg={0}", ex.Message));
            }

            Logger.WriteSystemLog(String.Format("Successfully sent message to buyer = {0}", buyerId));
            return result;
        }
Ejemplo n.º 3
0
        // Complete a order: e.g.,
        //    1) mark item as paid,
        //    2) mark item as shipped,
        //    3) leave feedback for user
        //  Unique identifier for an eBay order line item (transaction).
        //  The TransactionID can be paired up with the corresponding ItemID and used in the CompleteSale request
        //  to identify a single line item order.
        //  Unless an OrderLineItemID is used to identify a single line item order,
        //  or the OrderID is used to identify a single or multiple line item order,
        //  the ItemID/TransactionID pair must be specified.
        //  For a multiple line item order, OrderID must be used.
        //  If OrderID or OrderLineItemID are specified, the ItemID/TransactionID pair is ignored if present in the same request.
        public static bool CompleteSale(AccountType account, string orderId, string buyerId, string itemId, string ebayTransId,
                                        bool setIsPaid, bool isPaid, bool setIsShipped, bool isShipped)
        {
            Logger.WriteSystemLog(string.Format("buyerId={0} orderId={1} :Mark item as shipped.", buyerId, orderId));

            FeedbackInfoType feedback = new FeedbackInfoType();
            feedback.CommentText = "Great Buyer, fast payment, thanks for purchasing!";
            feedback.CommentType = CommentTypeCodeType.Positive;
            feedback.TargetUser = buyerId;

            CompleteSaleCall completeSaleApiCall = new CompleteSaleCall(account.SellerApiContext);
            completeSaleApiCall.FeedbackInfo = feedback;

            if (setIsPaid)
                completeSaleApiCall.Paid = isPaid;
            if (setIsShipped)
                completeSaleApiCall.Shipped = isShipped;

            //completeSaleApiCall.ItemID = itemId;
            //completeSaleApiCall.TransactionID = ebayTransId;
            completeSaleApiCall.OrderID = orderId;

            completeSaleApiCall.Execute();

            return true;
        }
Ejemplo n.º 4
0
        public FrmReplyBuyerMessage(AccountType account, EbayTransactionType trans, EbayMessageType message)
        {
            InitializeComponent();

            mTransaction = trans;
            mAccount = account;
            mMessage = message;
        }
Ejemplo n.º 5
0
        // Ebay API: GetItem
        //  http://developer.ebay.com/DevZone/XML/docs/Reference/eBay/GetItem.html
        //  Use this call to retrieve the data for a single item listed on an eBay site
        public static bool GetEbayItem(AccountType account)
        {
            GetItemCall getItemApiCall = new GetItemCall(account.SellerApiContext);
            getItemApiCall.ItemID = "130824387148";

            DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] { DetailLevelCodeType.ReturnSummary };
            getItemApiCall.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels);

            ItemType itemType = getItemApiCall.GetItem("130824387148");

            return true;
        }
Ejemplo n.º 6
0
        private void btnAddOrUpdateAccount_Click(object sender, EventArgs e)
        {
            string ebayAccount = this.textBoxEbayAccount.Text;
            if (ebayAccount.Trim() == "")
            {
                MessageBox.Show("请输入Ebay账号", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            string ebayToken = this.textBoxEbayToken.Text;
            if (ebayToken.Trim() == "")
            {
                MessageBox.Show("请输入Ebay Token", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            AccountType account = new AccountType();
            account.ebayAccount = ebayAccount;
            account.ebayToken = ebayToken;
            account.paypalAccount = this.textBoxPayPalAccount.Text.Trim();
            account.paypalUsername = this.textBoxPayPalUsername.Text.Trim();
            account.paypalPassword = this.textBoxPayPalPassword.Text.Trim();
            account.paypalSignature = this.textBoxPayPalSignature.Text.Trim();

            bool update = false;

            AccountType existedAccount = AccountUtil.GetAccountByEbayUsername(ebayAccount);
            if (existedAccount != null)
            {
                if (existedAccount.isEqual(account))
                {
                    MessageBox.Show("无任何信息需要更新!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                update = true;
            }

            if (update)
            {
                AccountUtil.UpdateOneAccount(account);
                MessageBox.Show("更新账号信息成功!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                AccountUtil.AddOneAccount(account);
                this.listBoxAllAccounts.Items.Add(account);

                MessageBox.Show("添加账号信息成功!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 7
0
        private void buttonFinish_Click(object sender, EventArgs e)
        {
            AccountType account = new AccountType();
            account.ebayAccount = UserName;
            account.ebayToken = Token;

            AccountType existedAccount = AccountUtil.GetAccountByEbayUsername(UserName);
            if (existedAccount != null)
            {
                MessageBox.Show("已存在此账号token,需先删除已有账号!", "抱歉", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            AccountUtil.AddOneAccount(account);
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Ejemplo n.º 8
0
        public bool isEqual(AccountType other)
        {
            if (other == null)
                return false;

            if (other.ebayAccount != ebayAccount)
                return false;
            if (other.ebayToken != ebayToken)
                return false;
            if (other.paypalAccount != paypalAccount)
                return false;
            if (other.paypalUsername != paypalUsername)
                return false;
            if (other.paypalPassword != paypalPassword)
                return false;
            if (other.paypalSignature != paypalSignature)
                return false;

            return true;
        }
Ejemplo n.º 9
0
        //
        // GetAccount
        //  http://developer.ebay.com/DevZone/XML/docs/Reference/eBay/GetAccount.html
        //
        public static string GetAccount(AccountType account)
        {
            if (account.SellerApiContext == null)
                return null;

            GetAccountCall getAccountApiCall = new GetAccountCall(account.SellerApiContext);
            DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] { DetailLevelCodeType.ReturnSummary };
            getAccountApiCall.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels);

            getAccountApiCall.AccountEntrySortType = AccountEntrySortTypeCodeType.AccountEntryCreatedTimeAscending;
            //  AccountHistorySelection
            //      - BetweenSpecifiedDates, BeginDate/EndDate must be used.
            //      - CustomCode
            //      - LastInvoice
            //      - SpecifiedInvoice, InvoiceDate must be used.
            getAccountApiCall.AccountHistorySelection = AccountHistorySelectionCodeType.LastInvoice;
            getAccountApiCall.BeginDate = new System.DateTime(2012, 10, 30);
            getAccountApiCall.EndDate = DateTime.Now;
            getAccountApiCall.ExcludeBalance = false;
            getAccountApiCall.ExcludeSummary = false;
            getAccountApiCall.Pagination = new eBay.Service.Core.Soap.PaginationType();
            getAccountApiCall.Pagination.PageNumber = 1;
            getAccountApiCall.Pagination.EntriesPerPage = 10;
            getAccountApiCall.Version = "705";
            getAccountApiCall.StartTimeFilter = new eBay.Service.Core.Soap.TimeFilter();
            getAccountApiCall.StartTimeFilter.TimeFrom = new System.DateTime(2012, 10, 30);
            getAccountApiCall.StartTimeFilter.TimeTo = DateTime.Now;

            //AccountHistorySelectionCodeType accountHistorySelectionCodeType = AccountHistorySelectionCodeType.BetweenSpecifiedDates;
            getAccountApiCall.GetAccount(AccountHistorySelectionCodeType.LastInvoice);

            AccountEntriesType accountEntriesType = getAccountApiCall.AccountEntries;
            AccountSummaryType accountSummary = getAccountApiCall.AccountSummary;

            return null;
        }
Ejemplo n.º 10
0
        // Private.
        private static List<AccountType> ReadAllAccounts()
        {
            List<AccountType> accounts = new List<AccountType>();

            XmlNodeList dbConnNodeList = XmlDoc.SelectNodes("/Settings/Accounts/Account");
            foreach (XmlNode node in dbConnNodeList)
            {
                AccountType account = new AccountType();
                account.ebayAccount = node.SelectSingleNode("ebayAccount").InnerText;
                account.ebayToken = node.SelectSingleNode("ebayToken").InnerText;
                account.paypalAccount = node.SelectSingleNode("paypalAccount").InnerText;
                account.paypalUsername = node.SelectSingleNode("paypalUsername").InnerText;
                account.paypalPassword = node.SelectSingleNode("paypalPassword").InnerText;
                account.paypalSignature = node.SelectSingleNode("paypalSignature").InnerText;
                accounts.Add(account);
            }

            return accounts;
        }
Ejemplo n.º 11
0
        public static bool UpdateOneAccount(AccountType account)
        {
            bool found = false;

            string ebayAccount = account.ebayAccount;
            XmlNodeList accountNodeList = XmlDoc.SelectNodes("/Settings/Accounts/Account");
            foreach (XmlNode node in accountNodeList)
            {
                string nodeEbayAccount = node.SelectSingleNode("ebayAccount").InnerText;
                if (string.Compare(ebayAccount, nodeEbayAccount) == 0)
                {
                    found = true;

                    node.SelectSingleNode("ebayToken").InnerText = account.ebayToken;
                    node.SelectSingleNode("paypalAccount").InnerText = account.paypalAccount;
                    node.SelectSingleNode("paypalUsername").InnerText = account.paypalUsername;
                    node.SelectSingleNode("paypalPassword").InnerText = account.paypalPassword;
                    node.SelectSingleNode("paypalSignature").InnerText = account.paypalSignature;
                }
            }

            if (found)
            {
                XmlDoc.Save(EbayConstants.SystemSettingsXmlPath);
                ReloadAllAccounts();
            }

            return found;
        }
Ejemplo n.º 12
0
        public static AccountType GetAccountByEbayUsername(string ebayAccount)
        {
            AccountType account = null;

            XmlNodeList accountNodeList = XmlDoc.SelectNodes("/Settings/Accounts/Account");
            foreach (XmlNode node in accountNodeList)
            {
                string nodeEbayAccount = node.SelectSingleNode("ebayAccount").InnerText;
                if (string.Compare(ebayAccount, nodeEbayAccount) != 0)
                    continue;

                account = new AccountType();
                account.ebayAccount = nodeEbayAccount;
                account.ebayToken = node.SelectSingleNode("ebayToken").InnerText;
                account.paypalAccount = node.SelectSingleNode("paypalAccount").InnerText;
                account.paypalUsername = node.SelectSingleNode("paypalUsername").InnerText;
                account.paypalPassword = node.SelectSingleNode("paypalPassword").InnerText;
                account.paypalSignature = node.SelectSingleNode("paypalSignature").InnerText;
            }

            return account;
        }
Ejemplo n.º 13
0
        //
        // GetMyMessages
        //  Returns information about the threaded messages sent to a user's My Messages mailbox.
        //      http://developer.ebay.com/DevZone/XML/docs/Reference/eBay/GetMyMessages.html
        // For maximum efficiency, make sure your application can first call GetMyMessages
        // with DetailLevel set to ReturnHeaders.
        //
        //  With a detail level of ReturnHeaders or ReturnMessages,
        //  GetMyMessages only accepts 10 unique message ID values, per request.
        //
        // GetMemberMessages
        //      http://developer.ebay.com/DevZone/XML/docs/Reference/eBay/GetMemberMessages.html
        // You can get all the messages sent within a specific time range
        // by providing StartCreationTime and EndCreationTime in your request.
        // Or you can specify an item's ItemID to get messages about an item.
        // After calling GetMemberMessages, inspect the children of the MemberMessages container.
        // For instance, if you want to know whether a message was previously answered, inspect the MessageStatus field.
        public static StringCollection GetAllMessageIds(AccountType account, DateTime startTime, DateTime endTime)
        {
            GetMyMessagesCall getMyMessageApiCall = new GetMyMessagesCall(account.SellerApiContext);
            getMyMessageApiCall.StartTime = startTime;
            getMyMessageApiCall.EndTime = endTime;

            DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] { DetailLevelCodeType.ReturnHeaders };
            getMyMessageApiCall.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels);

            StringCollection msgIds = new StringCollection();
            for (int folderId = 0; folderId <= 1; folderId++)
            {
                getMyMessageApiCall.FolderID = folderId;
                getMyMessageApiCall.GetMyMessages();
                MyMessagesMessageTypeCollection messages = getMyMessageApiCall.MessageList;

                foreach (MyMessagesMessageType msg in messages)
                {
                    msgIds.Add(msg.MessageID);
                }
            }

            return msgIds;
        }
Ejemplo n.º 14
0
        }  // GetAllMessageIds

        public static List <EbayMessageType> GetAllMessageByIds(AccountType account, StringCollection msgIds)
        {
            List <EbayMessageType> messageList = new List <EbayMessageType>();

            if (msgIds.Count > 10)
            {
                Logger.WriteSystemLog("[GetAllMessageByIds]: can only get at most 10 messages once.");
                return(messageList);
            }

            GetMyMessagesCall getMyMessageApiCall = new GetMyMessagesCall(account.SellerApiContext);

            getMyMessageApiCall.MessageIDList = msgIds;
            DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] { DetailLevelCodeType.ReturnMessages };
            getMyMessageApiCall.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels);
            getMyMessageApiCall.GetMyMessages();
            MyMessagesMessageTypeCollection messages = getMyMessageApiCall.MessageList;

            foreach (MyMessagesMessageType msg in messages)
            {
                // See if this message has already existed.
                String msgId = msg.MessageID;

                EbayMessageType tmpEbayMsg = EbayMessageDAL.GetOneMessage(msgId);
                if (tmpEbayMsg != null && tmpEbayMsg.EbayMessageId != "")
                {
                    Logger.WriteSystemLog(string.Format("[GetAllMessageByIds]: message with id={0} has already existed, skip and continue.", msgId));
                    continue;
                }

                EbayMessageType ebayMsg = new EbayMessageType();
                ebayMsg.EbayMessageId     = msg.MessageID;
                ebayMsg.SellerName        = account.ebayAccount;
                ebayMsg.MessageType       = msg.MessageType.ToString();
                ebayMsg.QuestionType      = msg.QuestionType.ToString();
                ebayMsg.IsRead            = msg.Read;
                ebayMsg.IsReplied         = msg.Replied;
                ebayMsg.IsResponseEnabled = msg.ResponseDetails != null ? msg.ResponseDetails.ResponseEnabled : false;
                ebayMsg.ResponseURL       = msg.ResponseDetails != null ? msg.ResponseDetails.ResponseURL : "";
                ebayMsg.UserResponseDate  = msg.ResponseDetails != null ? msg.ResponseDetails.UserResponseDate : DateTime.MinValue;
                ebayMsg.ReceiveDate       = msg.ReceiveDate;
                //ebayMsg.RecipientUserId = msg.RecipientUserID;
                ebayMsg.RecipientUserId = msg.SendToName;
                ebayMsg.Sender          = msg.Sender;
                ebayMsg.Subject         = msg.Subject;
                ebayMsg.IsHighPriority  = msg.HighPriority;
                // The message body. Plain text.
                ebayMsg.Content = msg.Content;
                // This field contains message content, and can contain a threaded message.
                // Max length: 2 megabytes in size.
                ebayMsg.Text = msg.Text;
                ebayMsg.ExternalMessageId = msg.ExternalMessageID;
                ebayMsg.FolderId          = msg.Folder != null ? msg.Folder.FolderID : -1;
                ebayMsg.ItemID            = msg.ItemID;
                ebayMsg.ItemTitle         = msg.ItemTitle;
                ebayMsg.ItemEndTime       = msg.ItemEndTime;
                ebayMsg.ListingStatus     = msg.ListingStatus.ToString();

                messageList.Add(ebayMsg);
            }

            return(messageList);
        }  // GetAllMessageByIds
Ejemplo n.º 15
0
        // Leave feedback for an order.
        public static bool LeaveFeedback(AccountType account, string orderId, string buyerId, string itemId, string ebayTransId)
        {
            CompleteSaleCall completeSaleApiCall = new CompleteSaleCall(account.SellerApiContext);

            FeedbackInfoType feedback = new FeedbackInfoType();
            feedback.CommentText = "Great Buyer, fast payment, thanks for purchasing!";
            feedback.CommentType = CommentTypeCodeType.Positive;
            feedback.TargetUser = buyerId;

            completeSaleApiCall.FeedbackInfo = feedback;

            completeSaleApiCall.ItemID = itemId;
            completeSaleApiCall.TransactionID = ebayTransId;

            completeSaleApiCall.Execute();

            return true;
        }
Ejemplo n.º 16
0
        public static string GetMyEbaySelling(AccountType account)
        {
            if (account.SellerApiContext == null)
                return null;

            GetMyeBaySellingCall getMyeBaySellingApiCall = new GetMyeBaySellingCall(account.SellerApiContext);
            DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] { DetailLevelCodeType.ReturnSummary };
            getMyeBaySellingApiCall.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels);

            getMyeBaySellingApiCall.SellingSummary = new eBay.Service.Core.Soap.ItemListCustomizationType();
            getMyeBaySellingApiCall.SellingSummary.Include = true;

            getMyeBaySellingApiCall.ActiveList = new eBay.Service.Core.Soap.ItemListCustomizationType();
            getMyeBaySellingApiCall.ActiveList.Include = true;
            getMyeBaySellingApiCall.ActiveList.IncludeNotes = true;
            getMyeBaySellingApiCall.ActiveList.ListingType = ListingTypeCodeType.FixedPriceItem;
            getMyeBaySellingApiCall.ActiveList.Pagination = new PaginationType();
            getMyeBaySellingApiCall.ActiveList.Pagination.EntriesPerPage = 10;
            getMyeBaySellingApiCall.ActiveList.Pagination.PageNumber = 1;

            getMyeBaySellingApiCall.GetMyeBaySelling();

            AmountType amountLimitRemaining = getMyeBaySellingApiCall.Summary.AmountLimitRemaining;
            long quantityLimitRemaining = getMyeBaySellingApiCall.Summary.QuantityLimitRemaining;

            PaginatedItemArrayType paginatedItemArray = getMyeBaySellingApiCall.ActiveListReturn;

            return null;
        }
Ejemplo n.º 17
0
        // Get all messages between buyers and sellers.
        public static bool GetAllMessages(AccountType account, DateTime startTime, DateTime endTime)
        {
            GetMyMessagesCall getMyMessageApiCall = new GetMyMessagesCall(account.SellerApiContext);
            getMyMessageApiCall.StartTime = startTime;
            getMyMessageApiCall.EndTime = endTime;

            DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] { DetailLevelCodeType.ReturnHeaders };
            getMyMessageApiCall.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels);
            getMyMessageApiCall.GetMyMessages();
            MyMessagesMessageTypeCollection messages = getMyMessageApiCall.MessageList;

            foreach (MyMessagesMessageType msg in messages)
            {
                string msgId = msg.MessageID;
                GetMyMessagesCall getMyMessageApiCall2 = new GetMyMessagesCall(account.SellerApiContext);

                StringCollection msgIds = new StringCollection();
                msgIds.Add(msgId);
                getMyMessageApiCall2.MessageIDList = msgIds;
                detailLevels = new DetailLevelCodeType[] { DetailLevelCodeType.ReturnMessages };
                getMyMessageApiCall2.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels);
                getMyMessageApiCall2.GetMyMessages();

                MyMessagesMessageType msg2 = getMyMessageApiCall2.MessageList[0];

                EbayMessageType ebayMsg = new EbayMessageType();
                ebayMsg.EbayMessageId = msgId;
                ebayMsg.SellerName = account.ebayAccount;
                ebayMsg.MessageType = msg2.MessageType.ToString();
                ebayMsg.QuestionType = msg2.QuestionType.ToString();
                ebayMsg.IsRead = msg2.Read;
                ebayMsg.IsReplied = msg2.Replied;
                ebayMsg.IsResponseEnabled = msg2.ResponseDetails != null ? msg2.ResponseDetails.ResponseEnabled : false;
                ebayMsg.ResponseURL = msg2.ResponseDetails != null ? msg2.ResponseDetails.ResponseURL : "";
                ebayMsg.UserResponseDate = msg2.ResponseDetails != null ? msg2.ResponseDetails.UserResponseDate : DateTime.MinValue;
                ebayMsg.ReceiveDate = msg2.ReceiveDate;
                ebayMsg.RecipientUserId = msg2.RecipientUserID;
                ebayMsg.Sender = msg2.Sender;
                ebayMsg.Subject = msg2.Subject;
                ebayMsg.IsHighPriority = msg2.HighPriority;
                ebayMsg.Content = msg2.Content;
                ebayMsg.Text = msg2.Text;
                ebayMsg.ExternalMessageId = msg2.ExternalMessageID;
                ebayMsg.FolderId = msg2.Folder != null ? msg2.Folder.FolderID : -1;
                ebayMsg.ItemID = msg2.ItemID;
                ebayMsg.ItemTitle = msg2.ItemTitle;
                ebayMsg.ItemEndTime = msg2.ItemEndTime;
                ebayMsg.ListingStatus = msg2.ListingStatus.ToString();

                EbayMessageDAL.InsertOneMessage(ebayMsg);
            }

            return true;
        }
Ejemplo n.º 18
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
Ejemplo n.º 19
0
 // GetAllOrders: Get all orders for a seller in the time period user specified.
 // Future enhancement: add multiple users support.
 // API call ref: http://developer.ebay.com/DevZone/xml/docs/Reference/ebay/GetOrders.html
 public static List<EbayTransactionType> GetAllOrders(AccountType account, DateTime startDate, DateTime endDate)
 {
     TimeFilter timeFilter = new TimeFilter();
     timeFilter.TimeFrom = startDate;
     timeFilter.TimeTo = endDate;
     return GetAllOrders(account, timeFilter, null);
 }
Ejemplo n.º 20
0
        // Given a time period specified by startDate and endDate, returns all the order ids created in that period.
        public static StringCollection GetAllOrderIds(AccountType account, DateTime startDate, DateTime endDate)
        {
            if (account.SellerApiContext == null)
                return null;

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

            GetOrdersCall getOrdersApiCall = new GetOrdersCall(account.SellerApiContext);
            DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] { DetailLevelCodeType.ReturnSummary };
            getOrdersApiCall.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels);

            getOrdersApiCall.GetOrders(timeFilter, TradingRoleCodeType.Seller, OrderStatusCodeType.All);

            StringCollection orderIds = new StringCollection();
            foreach (OrderType order in getOrdersApiCall.OrderList)
            {
                orderIds.Add(order.OrderID);
            }

            return orderIds;
        }
Ejemplo n.º 21
0
        // Upload tracking number to ebay.
        //  CompleteSale
        //  https://developer.ebay.com/DevZone/XML/docs/Reference/ebay/CompleteSale.html
        public static bool UploadTrackingNumber(AccountType account, string itemId, string ebayTransId, 
            string shippingCarrier, string shipmentTrackingNumber)
        {
            CompleteSaleCall completeSaleApiCall = new CompleteSaleCall(account.SellerApiContext);
            completeSaleApiCall.Shipment = new eBay.Service.Core.Soap.ShipmentType();

            ShipmentTrackingDetailsType shippingDetailsType = new ShipmentTrackingDetailsType();
            shippingDetailsType.ShippingCarrierUsed = shippingCarrier;
            shippingDetailsType.ShipmentTrackingNumber = shipmentTrackingNumber;
            completeSaleApiCall.Shipment.ShipmentTrackingDetails = new eBay.Service.Core.Soap.ShipmentTrackingDetailsTypeCollection();
            completeSaleApiCall.Shipment.ShipmentTrackingDetails.Add(shippingDetailsType);

            completeSaleApiCall.ItemID = itemId;
            completeSaleApiCall.TransactionID = ebayTransId;

            bool result = false;
            try
            {
                completeSaleApiCall.Execute();
                result = true;
            }
            catch (System.Exception ex)
            {
                Logger.WriteSystemLog(string.Format("ERROR: UploadTrackingNumber failed with error msg={0}", ex.Message));
            }

            return result;
        }
Ejemplo n.º 22
0
        public static List<EbayMessageType> GetAllMessageByIds(AccountType account, StringCollection msgIds)
        {
            List<EbayMessageType> messageList = new List<EbayMessageType>();

            if (msgIds.Count > 10)
            {
                Logger.WriteSystemLog("[GetAllMessageByIds]: can only get at most 10 messages once.");
                return messageList;
            }

            GetMyMessagesCall getMyMessageApiCall = new GetMyMessagesCall(account.SellerApiContext);
            getMyMessageApiCall.MessageIDList = msgIds;
            DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] { DetailLevelCodeType.ReturnMessages };
            getMyMessageApiCall.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels);
            getMyMessageApiCall.GetMyMessages();
            MyMessagesMessageTypeCollection messages = getMyMessageApiCall.MessageList;

            foreach (MyMessagesMessageType msg in messages)
            {
                // See if this message has already existed.
                String msgId = msg.MessageID;

                EbayMessageType tmpEbayMsg = EbayMessageDAL.GetOneMessage(msgId);
                if (tmpEbayMsg != null && tmpEbayMsg.EbayMessageId != "")
                {
                    Logger.WriteSystemLog(string.Format("[GetAllMessageByIds]: message with id={0} has already existed, skip and continue.", msgId));
                    continue;
                }

                EbayMessageType ebayMsg = new EbayMessageType();
                ebayMsg.EbayMessageId = msg.MessageID;
                ebayMsg.SellerName = account.ebayAccount;
                ebayMsg.MessageType = msg.MessageType.ToString();
                ebayMsg.QuestionType = msg.QuestionType.ToString();
                ebayMsg.IsRead = msg.Read;
                ebayMsg.IsReplied = msg.Replied;
                ebayMsg.IsResponseEnabled = msg.ResponseDetails != null ? msg.ResponseDetails.ResponseEnabled : false;
                ebayMsg.ResponseURL = msg.ResponseDetails != null ? msg.ResponseDetails.ResponseURL : "";
                ebayMsg.UserResponseDate = msg.ResponseDetails != null ? msg.ResponseDetails.UserResponseDate : DateTime.MinValue;
                ebayMsg.ReceiveDate = msg.ReceiveDate;
                //ebayMsg.RecipientUserId = msg.RecipientUserID;
                ebayMsg.RecipientUserId = msg.SendToName;
                ebayMsg.Sender = msg.Sender;
                ebayMsg.Subject = msg.Subject;
                ebayMsg.IsHighPriority = msg.HighPriority;
                // The message body. Plain text.
                ebayMsg.Content = msg.Content;
                // This field contains message content, and can contain a threaded message.
                // Max length: 2 megabytes in size.
                ebayMsg.Text = msg.Text;
                ebayMsg.ExternalMessageId = msg.ExternalMessageID;
                ebayMsg.FolderId = msg.Folder != null ? msg.Folder.FolderID : -1;
                ebayMsg.ItemID = msg.ItemID;
                ebayMsg.ItemTitle = msg.ItemTitle;
                ebayMsg.ItemEndTime = msg.ItemEndTime;
                ebayMsg.ListingStatus = msg.ListingStatus.ToString();

                messageList.Add(ebayMsg);
            }

            return messageList;
        }
Ejemplo n.º 23
0
        public static bool AddOneAccount(AccountType account)
        {
            AccountType existedAccount = GetAccountByEbayUsername(account.ebayAccount);
            if (existedAccount != null)
                return false;

            XmlNode accountsNode = XmlDoc.SelectSingleNode("/Settings/Accounts");
            XmlElement xe = XmlDoc.CreateElement("Account");
            accountsNode.AppendChild(xe);

            // ebayAccount
            {
                XmlElement xeEbayAccount = XmlDoc.CreateElement("ebayAccount");
                xeEbayAccount.InnerText = account.ebayAccount;
                xe.AppendChild(xeEbayAccount);
            }
            // ebayToken
            {
                XmlElement xeEbayToken = XmlDoc.CreateElement("ebayToken");
                xeEbayToken.InnerText = account.ebayToken;
                xe.AppendChild(xeEbayToken);
            }
            // paypalAccount
            {
                XmlElement xePPAccount = XmlDoc.CreateElement("paypalAccount");
                xePPAccount.InnerText = account.paypalAccount;
                xe.AppendChild(xePPAccount);
            }
            // paypalUsername
            {
                XmlElement xePPUsername = XmlDoc.CreateElement("paypalUsername");
                xePPUsername.InnerText = account.paypalUsername;
                xe.AppendChild(xePPUsername);
            }
            // paypalPassword
            {
                XmlElement xePPPassword = XmlDoc.CreateElement("paypalPassword");
                xePPPassword.InnerText = account.paypalPassword;
                xe.AppendChild(xePPPassword);
            }
            // paypalSignature
            {
                XmlElement xePPSignature = XmlDoc.CreateElement("paypalSignature");
                xePPSignature.InnerText = account.paypalSignature;
                xe.AppendChild(xePPSignature);
            }

            XmlDoc.Save(EbayConstants.SystemSettingsXmlPath);
            ReloadAllAccounts();
            return true;
        }
Ejemplo n.º 24
0
        //
        // AddMemberMessageRTQ
        // http://developer.ebay.com/DevZone/XML/docs/Reference/eBay/AddMemberMessageRTQ.html
        public static bool ReplyBuyerMessage(AccountType account, String itemId, 
            String externalMessageId, String buyerId, String body)
        {
            if (account == null || account.SellerApiContext == null)
                return false;

            if (itemId == null)
                return false;

            if (body == null || body.Trim().Length == 0)
                return false;

            AddMemberMessageRTQCall apiCall = new AddMemberMessageRTQCall(account.SellerApiContext);
            apiCall.ItemID = itemId;
            apiCall.MemberMessage = new eBay.Service.Core.Soap.MemberMessageType();
            apiCall.MemberMessage.Body = body;
            apiCall.MemberMessage.DisplayToPublic = false;
            apiCall.MemberMessage.EmailCopyToSender = true;
            apiCall.MemberMessage.ParentMessageID = externalMessageId;

            StringCollection recipientIds = new StringCollection();
            recipientIds.Add(buyerId);
            apiCall.MemberMessage.RecipientID = recipientIds;
            apiCall.MemberMessage.Subject = "";

            bool result = false;
            try
            {
                apiCall.AddMemberMessageRTQ(apiCall.ItemID, apiCall.MemberMessage);
                result = true;
            }
            catch (System.Exception ex)
            {
                Logger.WriteSystemUserLog(string.Format("Error when sending message to buyer, msg={0}", ex.Message));
            }

            return result;
        }
Ejemplo n.º 25
0
        //
        // GetMyeBaySelling
        //  Use this call to return information from the All Selling section of the authenticated user's My eBay account.
        //      http://developer.ebay.com/DevZone/XML/docs/Reference/eBay/GetMyeBaySelling.html
        //
        public static List<EbayActiveListingType> GetMyActiveListing(AccountType account)
        {
            if (account.SellerApiContext == null)
            {
                Logger.WriteSystemLog("Invalid API context in GetMyActiveListing.");
                return null;
            }

            GetMyeBaySellingCall getMyeBaySellingApiCall = new GetMyeBaySellingCall(account.SellerApiContext);
            DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] { DetailLevelCodeType.ReturnAll };
            getMyeBaySellingApiCall.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels);

            getMyeBaySellingApiCall.SellingSummary = new eBay.Service.Core.Soap.ItemListCustomizationType();
            getMyeBaySellingApiCall.SellingSummary.Include = true;

            getMyeBaySellingApiCall.ActiveList = new eBay.Service.Core.Soap.ItemListCustomizationType();
            getMyeBaySellingApiCall.ActiveList.Include = true;
            getMyeBaySellingApiCall.ActiveList.IncludeNotes = true;
            //getMyeBaySellingApiCall.ActiveList.ListingType = ListingTypeCodeType.FixedPriceItem;
            getMyeBaySellingApiCall.ActiveList.Pagination = new PaginationType();
            getMyeBaySellingApiCall.ActiveList.Pagination.EntriesPerPage = 25; // max 200 default 25
            getMyeBaySellingApiCall.ActiveList.Pagination.PageNumber = 1;

            //getMyeBaySellingApiCall.BidList = new ItemListCustomizationType();
            //getMyeBaySellingApiCall.BidList.Include = true;
            //getMyeBaySellingApiCall.BidList.Pagination = new PaginationType();
            //getMyeBaySellingApiCall.BidList.Pagination.EntriesPerPage = 25;
            //getMyeBaySellingApiCall.BidList.Pagination.PageNumber = 1;

            getMyeBaySellingApiCall.GetMyeBaySelling();

            AmountType amountLimitRemaining = getMyeBaySellingApiCall.Summary.AmountLimitRemaining;
            long quantityLimitRemaining = getMyeBaySellingApiCall.Summary.QuantityLimitRemaining;

            PaginatedItemArrayType paginatedItemArray = getMyeBaySellingApiCall.ActiveListReturn;

            if (paginatedItemArray == null || paginatedItemArray.ItemArray == null)
                return null;

            List<EbayActiveListingType> activeListings = new List<EbayActiveListingType>();
            foreach (ItemType item in paginatedItemArray.ItemArray)
            {
                EbayActiveListingType activeListing = new EbayActiveListingType();
                activeListing.ListId = 0;   // to be set
                activeListing.SellerName = account.ebayAccount;
                activeListing.ItemID = StringUtil.GetSafeString(item.ItemID);
                activeListing.Title = StringUtil.GetSafeString(item.Title);
                if (item.ListingTypeSpecified)
                {
                    if (ListingTypeCodeType.FixedPriceItem == item.ListingType)
                        activeListing.ListingType = "FixedPriceItem";
                    else if (ListingTypeCodeType.Auction == item.ListingType ||
                            ListingTypeCodeType.Chinese == item.ListingType)
                        activeListing.ListingType = "Auction";
                    else
                        activeListing.ListingType = "Unknown";
                }
                else
                {
                    activeListing.ListingType = "Unknown";
                }
                if (item.PictureDetails != null)
                    activeListing.GalleryURL = StringUtil.GetSafeString(item.PictureDetails.GalleryURL);
                else
                    activeListing.GalleryURL = "";

                if (item.BiddingDetails != null)
                {
                    activeListing.QuantityBid = StringUtil.GetSafeInt(item.BiddingDetails.QuantityBid);
                    if (item.BiddingDetails.MaxBid != null)
                        activeListing.MaxBid = StringUtil.GetSafeDouble(item.BiddingDetails.MaxBid.Value);
                    else
                        activeListing.MaxBid = 0.0;
                }
                else
                {
                    activeListing.QuantityBid = 0;
                    activeListing.MaxBid = 0.0;
                }

                if (item.StartPrice!=null)
                {
                    activeListing.StartPrice = StringUtil.GetSafeDouble(item.StartPrice.Value);
                }
                else
                {
                    activeListing.StartPrice = 0.0;
                }

                if (item.BuyItNowPrice != null)
                {
                    activeListing.BuyItNowPrice = StringUtil.GetSafeDouble(item.BuyItNowPrice.Value);
                    activeListing.CurrencyID = StringUtil.GetSafeString(item.BuyItNowPrice.currencyID);
                }
                else
                {
                    activeListing.BuyItNowPrice = 0.0;
                    activeListing.CurrencyID = "";
                }

                if (item.ListingDetails != null)
                {
                    activeListing.StartTime = StringUtil.GetSafeDateTime(item.ListingDetails.StartTime);
                    activeListing.EndTime = StringUtil.GetSafeDateTime(item.ListingDetails.EndTime);
                    activeListing.ViewItemURL = StringUtil.GetSafeString(item.ListingDetails.ViewItemURL);

                }

                activeListing.ListDuration = StringUtil.GetSafeInt(StringUtil.GetSafeListDurationDays(item.ListingDuration));
                activeListing.PrivateListing = StringUtil.GetSafeBool(item.PrivateListing);
                activeListing.Quantity = StringUtil.GetSafeInt(item.Quantity);
                activeListing.QuantityAvailable = StringUtil.GetSafeInt(item.QuantityAvailable);
                if (item.SellingStatus != null)
                {
                    if (item.SellingStatus.ListingStatus == ListingStatusCodeType.Active)
                        activeListing.SellingStatus = "Active";
                    else if (item.SellingStatus.ListingStatus == ListingStatusCodeType.Completed)
                        activeListing.SellingStatus = "Completed";
                    else if (item.SellingStatus.ListingStatus == ListingStatusCodeType.Ended)
                        activeListing.SellingStatus = "Ended";
                    else
                        activeListing.SellingStatus = "Unknown";

                    if (item.SellingStatus.BidCountSpecified)
                        activeListing.BidCount = item.SellingStatus.BidCount;
                    else
                        activeListing.BidCount = 0;

                    if (item.SellingStatus.BidderCountSpecified)
                        activeListing.BidderCount = (int)item.SellingStatus.BidderCount;
                    else
                        activeListing.BidderCount = 0;

                    if (item.SellingStatus.CurrentPrice != null)
                        activeListing.CurrentPrice = item.SellingStatus.CurrentPrice.Value;
                    else
                        activeListing.CurrentPrice = 0.0;
                }
                else
                {
                    activeListing.SellingStatus = "Unknown";
                }
                activeListing.SKU = StringUtil.GetSafeString(item.SKU);
                activeListing.TimeLeft = StringUtil.GetSafeString(item.TimeLeft);
                activeListing.WatchCount = StringUtil.GetSafeInt(item.WatchCount);

                activeListings.Add(activeListing);

            }

            Logger.WriteSystemLog(string.Format("Successfully called GetMyActiveListing, returns {0} entries", activeListings.Count));
            return activeListings;
        }
Ejemplo n.º 26
0
        public static bool GetBuyerFeedbackLeft(AccountType account, String buyerId, String orderId)
        {
            //bool sellerLeftFeedback = false;
            //bool buyerLeftFeedback = false;

            GetFeedbackCall getFeedbackApiCall = new GetFeedbackCall(account.SellerApiContext);
            DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] { DetailLevelCodeType.ReturnAll };
            getFeedbackApiCall.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels);
            getFeedbackApiCall.OrderLineItemID = orderId;

            try
            {
                FeedbackDetailTypeCollection feedbacks = getFeedbackApiCall.GetFeedback();
                foreach (FeedbackDetailType feedback in feedbacks)
                {
                    //if (feedback.CommentingUser == account.ebayAccount)
                    //    sellerLeftFeedback = true;

                    if (feedback.CommentingUser == buyerId)
                    {
                        return true;
                    }
                }
            }
            catch (System.Exception ex)
            {
                Logger.WriteSystemLog(String.Format("GetFeedback failed with error msg={0}", ex.Message));
                Logger.WriteSystemLog(String.Format("Transaction with BuyerId={0} maybe happened more than 90 days.", buyerId));
                return true;
            }

            return false;
        }