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 JsonResult Create(EbayMessageType obj)
 {
     try
     {
         NSession.SaveOrUpdate(obj);
         NSession.Flush();
     }
     catch (Exception ee)
     {
         return Json(new { ErrorMsg = "出错了", IsSuccess = false });
     }
     return Json(new { IsSuccess = "true" });
 }
 public string EbayMessageDown(EbayMessageType obj)
 {
     try
     {
         obj.CreateOn = DateTime.Now;
         obj.ReplayOn = Convert.ToDateTime("2000-01-01");
         if (HasExistByMessageId(obj.MessageId))
         {
             return "该条邮件已同步!";
         }
         else
         {
             NSession.Save(obj);
             NSession.Flush();
             return "同步一条邮件!";
         }
     }
     catch (Exception ex)
     {
         return "保存失败" + ex.Message;
     }
 }