public static void GetEmailByAPI(AccountType account, DateTime beginDate, DateTime endDate, ISession NSession)
        {
            ApiContext context = AppSettingHelper.GetGenericApiContext("US");
            context.ApiCredential.eBayToken = account.ApiToken;
            GetMemberMessagesCall apicall = new GetMemberMessagesCall(context);
            apicall.DetailLevelList.Add(DetailLevelCodeType.ReturnAll);
            TimeFilter fltr = new TimeFilter();
            fltr.TimeFrom = beginDate;
            fltr.TimeTo = endDate;
            MemberMessageExchangeTypeCollection messages;
            int i = 1;
            do
            {
                apicall.Pagination = new eBay.Service.Core.Soap.PaginationType();
                apicall.Pagination.PageNumber = i;
                apicall.Pagination.EntriesPerPage = 100;
                messages = apicall.GetMemberMessages(fltr, MessageTypeCodeType.All, MessageStatusTypeCodeType.Unanswered);

                for (int k = 0; k < messages.Count; k++)
                {
                    MemberMessageExchangeType mmet = messages[k];
                    EbayMessageType email = new EbayMessageType();

                    email.Body = mmet.Question.Body;
                    email.CreationDate = mmet.CreationDate;
                    email.MessageId = mmet.Question.MessageID;
                    email.MessageStatus = "未回复";
                    email.MessageType = MessageType(mmet.Question.MessageType.ToString());
                    email.SenderEmail = mmet.Question.SenderEmail;
                    email.SenderID = mmet.Question.SenderID;
                    email.Subject = mmet.Question.Subject;
                    if (mmet.Item != null)
                    {
                        email.ItemId = mmet.Item.ItemID;
                        email.Title = mmet.Item.Title;
                       
                    }
                    email.Shop = mmet.Question.RecipientID[0];
                    email.CreateOn = DateTime.Now;
                    email.ReplayOn = Convert.ToDateTime("2000-01-01");
                    if (HasExist(email.MessageId, NSession))
                    {

                    }
                    else
                    {
                        NSession.Save(email);
                        NSession.Flush();
                    }

                }
                i++;
            } while (messages != null && messages.Count == 100);
        }
 public void GetMemberMessages()
 {
     GetMemberMessagesCall api = new GetMemberMessagesCall(this.apiContext);
     api.DetailLevelList = new DetailLevelCodeTypeCollection();
     api.DetailLevelList.Add(DetailLevelCodeType.ReturnMessages);
     api.DisplayToPublic = false;
     api.MailMessageType = MessageTypeCodeType.AskSellerQuestion;
     api.MessageStatus = MessageStatusTypeCodeType.Unanswered;
     // Time filter
     System.DateTime calTo = System.DateTime.Now;
     System.DateTime calFrom = calTo.AddHours(-1);
     api.StartCreationTime = calFrom;
     api.EndCreationTime = calTo;
     // Make API call.
     api.Execute();
     TestData.MemberMessages = api.ApiResponse.MemberMessage;
 }
Exemple #3
0
        private void BtnGetMemberMessages_Click(object sender, System.EventArgs e)
        {
            try
            {
                LstMessages.Items.Clear();

                GetMemberMessagesCall apicall = new GetMemberMessagesCall(Context);				apicall.DisplayToPublic = ChkPublic.Checked;
                MemberMessageExchangeTypeCollection messages;
                if (TxtItemId.Text != String.Empty)
                {
                    messages = apicall.GetMemberMessages(TxtItemId.Text, (MessageTypeCodeType) Enum.Parse(typeof(MessageTypeCodeType), CboType.SelectedItem.ToString()), (MessageStatusTypeCodeType) Enum.Parse(typeof(MessageStatusTypeCodeType), CboStatus.SelectedItem.ToString()));
                }
                else
                {
                    TimeFilter fltr = new TimeFilter();
                    if (ChkStartFrom.Checked)
                    {
                        fltr.TimeFrom = DatePickStartFrom.Value;
                    }
                    if (ChkStartTo.Checked)
                    {
                        fltr.TimeTo = DatePickStartTo.Value;
                    }
                    messages = apicall.GetMemberMessages(fltr, (MessageTypeCodeType) Enum.Parse(typeof(MessageTypeCodeType), CboType.SelectedItem.ToString()), (MessageStatusTypeCodeType) Enum.Parse(typeof(MessageStatusTypeCodeType), CboStatus.SelectedItem.ToString()));
                }

                foreach (MemberMessageExchangeType msg in messages)
                {
                    string[] listparams = new string[6];
                    if (msg.Item != null)
                        listparams[0] = msg.Item.ItemID;
                    else
                        listparams[0] = "";
                    listparams[1] = msg.Question.MessageID;
                    listparams[2] = msg.MessageStatus.ToString();
                    listparams[3] = msg.Question.QuestionType.ToString();
                    listparams[4] = msg.Question.SenderID;
                    listparams[5] = msg.Question.Body;

                    ListViewItem vi = new ListViewItem(listparams);
                    LstMessages.Items.Add(vi);

                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #4
0
        public void GetEmailByAPI(SaleAccountType account, DateTime beginDate, DateTime endDate)
        {
            ApiContext context = AppSettingHelper.GetGenericApiContext("US");
            context.ApiCredential.eBayToken = account.ApiToken;
            GetMemberMessagesCall apicall = new GetMemberMessagesCall(context);
            apicall.DetailLevelList.Add(DetailLevelCodeType.ReturnAll);
            TimeFilter fltr = new TimeFilter();
            fltr.TimeFrom = beginDate;
            fltr.TimeTo = endDate;
            MemberMessageExchangeTypeCollection messages;

            int i = 1;
            do
            {
                apicall.Pagination = new eBay.Service.Core.Soap.PaginationType();
                apicall.Pagination.PageNumber = i;
                apicall.Pagination.EntriesPerPage = 100;
                messages = apicall.GetMemberMessages(fltr, MessageTypeCodeType.All, MessageStatusTypeCodeType.Unanswered);

                for (int k = 0; k < messages.Count; k++)
                {
                    MemberMessageExchangeType mmet = messages[k];
                    EmailType email = OMS.Core.DoMain.EmailType.find("MessageID=:t1").set("t1", mmet.Question.MessageID).first();

                    if (email == null)
                    {
                        email = new Core.DoMain.EmailType();
                    }
                    else
                    {
                        continue;
                    }

                    email.Body = mmet.Question.Body;
                    email.CreateOn = mmet.CreationDate;
                    email.MessageID = mmet.Question.MessageID;
                    email.MessageStatus = mmet.MessageStatus.ToString();
                    email.MessageType = mmet.Question.MessageType.ToString();
                    email.SaleAccount = mmet.Question.RecipientID[0];
                    email.BuyerEmail = mmet.Question.SenderEmail;
                    email.BuyerAccount = mmet.Question.SenderID;
                    email.Subject = mmet.Question.Subject;

                    if (mmet.Item != null)
                    {
                        email.ItemPriceCurrency = mmet.Item.SellingStatus.CurrentPrice.currencyID.ToString();
                        email.ItemPrice = mmet.Item.SellingStatus.CurrentPrice.Value;
                        email.ItemID = mmet.Item.ItemID;
                        email.ItemTitle = mmet.Item.Title;
                        email.ItemURL = mmet.Item.ListingDetails.ViewItemURL;
                    }
                    else
                    {
                        email.ItemTitle = "";
                        email.ItemID = "";
                    }

                    int sortNumber = 0;
                    if (HasOrderByTime(email.SaleAccount, email.BuyerAccount, 24))//判断24小时前后是否有订单
                    {
                        sortNumber = 50;
                    }
                    else if (OrderGoodsHasColor(email.ItemTitle))//判断涉及产品是否有颜色
                    {
                        sortNumber = 40;
                    }
                    else
                    {

                    }

                    email.LastReplier = GetLastReplier(email.SaleAccount, email.BuyerAccount);//获取上次回复人
                    email.SortNumber = sortNumber;

                    email.insert();
                }
                i++;
            } while (messages != null && messages.Count == 100);
        }