/// <summary>
        /// Revises a Selling Manager sale record when you specify
        /// one of the following: an ItemID, a TransactionID, or an OrderID.
        /// This call is subject to change without notice; the
        /// deprecation process is inapplicable to this call.
        /// </summary>
        /// 
        /// <param name="ItemID">
        /// The item ID associated with the sale record.
        /// </param>
        ///
        /// <param name="TransactionID">
        /// The transaction ID associated with the sale record.
        /// </param>
        ///
        /// <param name="OrderID">
        /// The order ID associated with the sale record.
        /// If specified, then the following, if specified in the same call, are ignored:
        /// ItemID and TransactionID.
        /// </param>
        ///
        /// <param name="SellingManagerSoldOrder">
        /// Details of a Selling Manager order.
        /// Each order can have one or more transactions.
        /// </param>
        ///
        public void ReviseSellingManagerSaleRecord(string ItemID, string TransactionID, string OrderID, SellingManagerSoldOrderType SellingManagerSoldOrder)
        {
            this.ItemID = ItemID;
            this.TransactionID = TransactionID;
            this.OrderID = OrderID;
            this.SellingManagerSoldOrder = SellingManagerSoldOrder;

            Execute();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Enables sellers, who subscribe to Selling Manager Pro, to revise a Selling Manager sale record.
        /// </summary>
        ///
        /// <param name="ItemID">
        /// Unique identifier for an eBay item listing. A listing can have multiple
        /// order line items (transactions), but only one <b>ItemID</b>. An <b>ItemID</b> can be
        /// paired up with a corresponding <b>TransactionID</b> and used as an input filter
        /// for <b>ReviseSellingManagerSaleRecord</b>. The <b>ItemID</b>/<b>TransactionID</b> pair
        /// corresponds to a Selling Manager <b>SaleRecordID</b>, which can be retrieved
        /// with the <b>GetSellingManagerSaleRecord</b> call.
        ///
        /// Unless an <b>OrderLineItemID</b> is used to identify a single line item order,
        /// or the <b>OrderID</b> is used to identify a single or multiple line item
        /// (Combined Invoice) order, the <b>ItemID</b>/<b>TransactionID</b> pair must be
        /// specified. For a multiple line item (Combined Invoice) order, <b>OrderID</b>
        /// should be used. If <b>OrderID</b> or <b>OrderLineItemID</b> are specified, the
        /// <b>ItemID</b>/<b>TransactionID</b> pair is ignored if present in the same request.
        /// </param>
        ///
        /// <param name="TransactionID">
        /// Unique identifier for an eBay order line item (transaction). An order
        /// line item is created once there is a commitment from a buyer to purchase
        /// an item. Since an auction listing can only have one order line item
        /// during the duration of the listing, the <b>TransactionID</b> for
        /// auction listings is always 0. Along with its corresponding <b>ItemID</b>, a
        /// <b>TransactionID</b> is used and referenced during an order checkout flow and
        /// after checkout has been completed. The <b>ItemID</b>/<b>TransactionID</b> pair can be
        /// used as an input filter for <b>ReviseSellingManagerSaleRecord</b>. The
        /// <b>ItemID</b>/<b>TransactionID</b> pair corresponds to a Selling Manager <b>SaleRecordID</b>,
        /// which can be retrieved with the <b>GetSellingManagerSaleRecord</b> call.
        ///
        /// Unless an <b>OrderLineItemID</b> is used to identify a single line item order,
        /// or the <b>OrderID</b> is used to identify a single or multiple line item
        /// (Combined Invoice) order, the <b>ItemID</b>/<b>TransactionID</b> pair must be
        /// specified. For a multiple line item (Combined Invoice) order, <b>OrderID</b>
        /// must be used. If <b>OrderID</b> or <b>OrderLineItemID</b> are specified, the
        /// <b>ItemID</b>/<b>TransactionID</b> pair is ignored if present in the same request.
        /// </param>
        ///
        /// <param name="OrderID">
        /// A unique identifier that identifies a single line item or multiple line
        /// item (Combined Invoice) order.
        ///
        /// For a single line item order, the <b>OrderID</b> value is identical to the
        /// <b>OrderLineItemID</b> value that is generated upon creation of the order line
        /// item. For a Combined Invoice order, the <b>OrderID</b> value is created by eBay
        /// when the buyer or seller (sharing multiple, common order line items)
        /// combines multiple order line items into a Combined Invoice order through
        /// the eBay site. A Combined Invoice order can also be created by the
        /// seller through the <b>AddOrder</b> call. The <b>OrderID</b> can be used as an input
        /// filter for <b>ReviseSellingManagerSaleRecord</b>. The <b>OrderID</b>
        /// is linked to a Selling Manager <b>SaleRecordID</b>, and can be retrieved
        /// with the <b>GetSellingManagerSaleRecord</b> call.
        ///
        /// <b>OrderID</b> overrides an <b>OrderLineItemID</b> or <b>ItemID</b>/<b>TransactionID</b> pair if
        /// these fields are also specified in the same request.
        /// </param>
        ///
        /// <param name="SellingManagerSoldOrder">
        /// Container consisting of order costs, shipping details, order status, and
        /// other information. The changes made under this container will update the
        /// order in Selling Manager.
        /// </param>
        ///
        /// <param name="OrderLineItemID">
        /// <b>OrderLineItemID</b> is a unique identifier for an eBay order line item and
        /// is based upon the concatenation of <b>ItemID</b> and <b>TransactionID</b>, with a
        /// hyphen in between these two IDs. For a single line item order, the
        /// <b>OrderLineItemID</b> value can be passed into the <b>OrderID</b> field to revise the
        /// order in Selling Manager.
        ///
        /// Unless an <b>ItemID</b>/<b>TransactionID</b> pair is used to identify a single line
        /// item order, or the <b>OrderID</b> is used to identify a single or multiple line
        /// item (Combined Invoice) order, the <b>OrderLineItemID</b> must be specified.
        /// For a multiple line item (Combined Invoice) order, <b>OrderID</b> should be
        /// used. If <b>OrderLineItemID</b> is specified, the <b>ItemID</b>/<b>TransactionID</b> pair are
        /// ignored if present in the same request.
        /// </param>
        ///
        public void ReviseSellingManagerSaleRecord(string ItemID, string TransactionID, string OrderID, SellingManagerSoldOrderType SellingManagerSoldOrder, string OrderLineItemID)
        {
            this.ItemID                  = ItemID;
            this.TransactionID           = TransactionID;
            this.OrderID                 = OrderID;
            this.SellingManagerSoldOrder = SellingManagerSoldOrder;
            this.OrderLineItemID         = OrderLineItemID;

            Execute();
        }
Exemplo n.º 3
0
    private List<ParcelItem> GetEbayAccountTransactions(EbayServiceBL service, KeyValuePair<int, string> account, int UserCode)
    {
        int accountID = account.Key;
        DataModelEntities context = new DataModelEntities();
        List<PriceManagerDAL.ParcelItem> parcelItems = context.ParcelItems.Where(f => f.AccountID == accountID && f.User_Code == UserCode && f.Is_Active == true).ToList();

        string currentItemID = string.Empty, currentTransactionID = string.Empty, currentRecordNo = string.Empty;

        SellingManagerSoldOrderType[] results = service.GetPendingShipmentItems(account.Value);

        if(results == null)
            results = new SellingManagerSoldOrderType[0];

        // delete all database entries that does not exist in the API results.
        foreach (PriceManagerDAL.ParcelItem existingItem in parcelItems)
        {
            long transactionID = long.Parse(existingItem.TransactionID);
            SellingManagerSoldOrderType checkResult = results.FirstOrDefault(r => r.SellingManagerSoldTransaction.Count(c => c.ItemID == existingItem.ItemID && c.TransactionID == transactionID) > 0);
            if (checkResult == null)
            {
                context.ParcelItems.DeleteObject(existingItem);
            }
        }

        // delete entries which do not have correct shipping details
        foreach (PriceManagerDAL.ParcelItem existingItem in parcelItems.Where(p => string.IsNullOrEmpty(p.BuyerName) == true))
        {
            context.ParcelItems.DeleteObject(existingItem);
        }

        // now traverse through API results and save only those which are new
        List<ParcelItem> items = new List<ParcelItem>();
        if (results != null && results.Length > 0)
        {
            List<ChargeCode> chargeCodes = new DataModelEntities().ChargeCodes.Where(u => u.Is_Active == true && u.User_Code == UserCode).ToList();
            foreach (SellingManagerSoldOrderType result in results)
            {
                foreach (SellingManagerSoldTransactionType transaction in result.SellingManagerSoldTransaction)
                {
                    try
                    {

                        currentItemID = transaction.ItemID;
                        currentTransactionID = transaction.TransactionID.ToString();

                        // ignore if the item already exists in our database
                        if (context.ParcelItems.FirstOrDefault(f => f.AccountID == accountID && f.ItemID == currentItemID && f.TransactionID == currentTransactionID) != null)
                        {
                            continue;
                        }

                        ParcelItem item = new ParcelItem();
                        item.Type = "EBAY";

                        SellingManagerSoldOrderType itemDetails = service.GetSaleRecordDetails(transaction.ItemID, transaction.TransactionID.ToString(), account.Value);

                        currentRecordNo = itemDetails.SaleRecordID.ToString();

                        item.AccountID = account.Key.ToString();
                        item.ItemID = transaction.ItemID;
                        item.TransactionID = transaction.TransactionID.ToString();
                        item.ItemName = transaction.ItemTitle;
                        item.CustomLabel = transaction.CustomLabel;
                        item.CustomLabelText = transaction.SaleRecordID.ToString() + ":" + transaction.CustomLabel;
                        if (itemDetails.ShippingAddress != null)
                        {
                            if (StateHelper.States.Where(s => s.Key == itemDetails.ShippingAddress.StateOrProvince.ToLower()).Count() > 0)
                                item.State = StateHelper.States[itemDetails.ShippingAddress.StateOrProvince.ToLower()];
                            else
                                item.State = itemDetails.ShippingAddress.StateOrProvince.ToLower();
                            item.BuyerName = itemDetails.ShippingAddress.Name;
                            item.Street = itemDetails.ShippingAddress.Street;
                            item.Street2 = itemDetails.ShippingAddress.Street1;
                            item.Street3 = itemDetails.ShippingAddress.Street2;
                            item.City = itemDetails.ShippingAddress.CityName;
                            item.PostalCode = itemDetails.ShippingAddress.PostalCode.TrimStart('0'); ;
                            item.Country = itemDetails.ShippingAddress.Country.ToString();
                            item.Phone = itemDetails.ShippingAddress.Phone;
                        }
                        else
                        {

                        }
                        item.EmailAddress = itemDetails.BuyerEmail;
                        item.BuyerID = itemDetails.BuyerID;
                        item.Quantity = transaction.QuantitySold;
                        if (itemDetails.ActualShippingCost != null)
                            item.ShippingCost = itemDetails.ActualShippingCost.Value;
                        item.SaleRecordId = itemDetails.SaleRecordID.ToString();

                        bool IspostCodeOK = true;
                        if (itemDetails.ShippingDetails != null)
                        {
                            if (itemDetails.ShippingDetails.InsuranceFee == null)
                                item.HasInsurance = false;
                            else
                            {
                                item.HasInsurance = true;
                                item.Insurance = itemDetails.ShippingDetails.InsuranceFee.Value;
                            }
                            if (itemDetails.ShippingDetails != null && itemDetails.ShippingDetails.ShippingServiceOptions != null)
                                item.ShippingMethod = itemDetails.ShippingDetails.ShippingServiceOptions[0].ShippingService;
                            else
                                item.ShippingMethod = "N/A";

                            IspostCodeOK = Common.VerifyPostCode(itemDetails.ShippingAddress.PostalCode, itemDetails.ShippingAddress.CityName);
                            if (IspostCodeOK)
                                item.PostCodeImageURL = Constant.tickURL;
                            else
                                item.PostCodeImageURL = Constant.crossURL;
                        }

                        if (itemDetails.SellingManagerSoldTransaction != null)
                        {
                            item.Currency = itemDetails.SellingManagerSoldTransaction[0].ItemPrice.currencyID.ToString();
                            item.Price = itemDetails.SellingManagerSoldTransaction[0].ItemPrice.Value;
                        }

                        item.RecordNumber = itemDetails.SaleRecordID.ToString();

                        ChargeCode code = chargeCodes.FirstOrDefault(u => item.ShippingMethod.ToLower().Contains(u.Ebay_Code.ToLower()) == true);
                        if (code != null && code.Charge_Code_Name.ToLower() == "ignore")
                        {
                            continue; // ignore the item
                        }

                        GetMemberMessagesResponseType messages = service.GetTransactionMessages(item.ItemID, item.BuyerID, account.Value);
                        if (messages.MemberMessage != null)
                        {
                            List<ParcelMessage> ebayMessages = service.ConvertEbayMessages(messages);
                            item.Messages = Common.Serialize(ebayMessages);
                        }

                        items.Add(item);

                        currentItemID = string.Empty;
                        currentRecordNo = string.Empty;
                        currentTransactionID = string.Empty;
                    }
                    catch (Exception ex)
                    {
                        Logging.WriteLog(LogType.Critical, ex.ToString());
                    }
                }
            }
            context.SaveChanges();
            return items.OrderBy(i => i.BuyerID).ToList();
        }
        else
        {
            context.SaveChanges();
            return null;
        }
    }