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 #2
0
        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);
        }
Exemple #3
0
        public EbayServiceResponse <IEnumerable <MemberMessage> > GetMemberMessage(string token, DateTime from, DateTime to, MessageTypeCodeType messageTypeCodeType,
                                                                                   MessageStatusTypeCodeType messageStatusTypeCode)
        {
            var apiContext = CreateApiContext(apiServerUrl, ruName, appId, devId, certId, token);
            var response   = new EbayServiceResponse <IEnumerable <MemberMessage> >();

            try
            {
                var apiCall    = new GetMemberMessagesCall(apiContext);
                var timeFilter = new TimeFilter(from, to);
                var messages   = apiCall.GetMemberMessages(timeFilter, messageTypeCodeType, messageStatusTypeCode);
                var result     = new List <MemberMessage>();
                foreach (MemberMessageExchangeType message in messages)
                {
                    var memberMessage = new MemberMessage
                    {
                        ParentMessageId  = message.Question.ParentMessageID,
                        MessageId        = message.Question.MessageID,
                        MessageStatus    = message.MessageStatus.ToString(),
                        ItemId           = message.Item != null ? message.Item.ItemID : string.Empty,
                        QuestionType     = message.Question.QuestionType.ToString(),
                        SenderId         = message.Question.SenderID,
                        SenderEmail      = message.Question.SenderEmail,
                        RecipientId      = message.Question.RecipientID[0],
                        Body             = message.Question.Body,
                        CreatedDate      = message.CreationDate,
                        LastModifiedDate = message.LastModifiedDate
                    };
                    result.Add(memberMessage);
                }
                response.Result = result;
            }
            catch (Exception ex)
            {
                response.Error = ex.Message;
            }
            return(response);
        }
Exemple #4
0
        public IHttpActionResult GetSellerItems()
        {
            //[Step 1] Initialize eBay ApiContext object
            apiContext = GetApiContext();

            GetSellerListCall call = new GetSellerListCall(apiContext);

            call.DetailLevelList.Add(DetailLevelCodeType.ReturnAll);
            call.Pagination = new PaginationType()
            {
                EntriesPerPage = 200
            };
            call.EndTimeFrom = DateTime.UtcNow.AddDays(-1);
            call.EndTimeTo   = DateTime.UtcNow.AddDays(30);

            call.IncludeWatchCount = true;

            ItemTypeCollection items = call.GetSellerList();

            foreach (ItemType item in items)
            {
                try
                {
                    List <ZohoLead> leads = new List <ZohoLead>();

                    GetMemberMessagesCall messages = new GetMemberMessagesCall(apiContext);
                    messages.GetMemberMessages(item.ItemID, MessageTypeCodeType.AskSellerQuestion, MessageStatusTypeCodeType.Unanswered);

                    foreach (MemberMessageExchangeType message in messages.MemberMessageList)
                    {
                        leads = GetMemberMessageLead(leads, item, message);
                    }

                    if (item.BestOfferEnabled)
                    {
                        GetBestOffersCall boCall = new GetBestOffersCall(apiContext);
                        boCall.GetBestOffers(item.ItemID, null, BestOfferStatusCodeType.All, new PaginationType()
                        {
                            EntriesPerPage = 200
                        });
                        foreach (BestOfferType offer in boCall.BestOfferList)
                        {
                            leads = GetBestOfferLead(leads, item, offer);
                        }
                    }

                    GetAllBiddersCall bidderCall = new GetAllBiddersCall(apiContext);
                    var bidders = bidderCall.GetAllBidders(item.ItemID, GetAllBiddersModeCodeType.ViewAll);
                    foreach (OfferType bidder in bidders)
                    {
                        leads = GetBidderLead(leads, item, bidder);
                    }

                    if (leads.Count > 0)
                    {
                        leads = GetLeadInformation(leads);
                        InsertZohoLeads(leads);
                    }
                }
                catch (Exception ex)
                {
                    Trace.TraceError(ex.Message);
                }
            }

            return(Ok());
        }