Esempio n. 1
0
        public void UploadEmailByAPI(SaleAccountType account)
        {
            ApiContext context = AppSettingHelper.GetGenericApiContext("US");
            context.ApiCredential.eBayToken = account.ApiToken;
            List<EmailRepliedType> result = EmailRepliedType.find("IsToEbay = 0 AND SaleAccount = '"+account.UserName+"'").list();

            AddMemberMessageRTQCall addMsgApicall = new AddMemberMessageRTQCall(context);
            ReviseMyMessagesCall revMsgApicall = new ReviseMyMessagesCall(context);

            foreach (EmailRepliedType er in result)
            {
                MemberMessageType mm = new MemberMessageType();
                mm.MessageID = er.MessageID;
                mm.Body = er.Body;
                mm.Subject = er.Subject;
                mm.SenderID = er.BuyerAccount;
                mm.SenderEmail = er.BuyerEmail;
                mm.ParentMessageID = er.MessageID;

                addMsgApicall.AddMemberMessageRTQ(er.ItemID, mm);
                revMsgApicall.ReviseMyMessages(true, false, new StringCollection(new string[] { mm.MessageID }));

                er.IsToEbay = true;
                er.ToEbayOn = DateTime.Now;
                er.RepliedSpaceHour = (er.ToEbayOn - er.ReceiveOn).TotalHours;
                er.update();
            }
        }
        public static void Upload(AccountType account, ISession NSession)
        {
            ApiContext context = AppSettingHelper.GetGenericApiContext("US");
            context.ApiCredential.eBayToken = account.ApiToken;
            AddMemberMessageRTQCall addMsgApicall = new AddMemberMessageRTQCall(context);
            ReviseMyMessagesCall revMsgApicall = new ReviseMyMessagesCall(context);
            IList<EbayMessageReType> list = NSession.CreateQuery("from EbayMessageReType where IsUpload<>'1'").List<EbayMessageReType>();
            if (list.Count != 0)
            {
                foreach (var item in list)
                {
                    MemberMessageType mm = new MemberMessageType();
                    mm.SenderID = item.SenderID;
                    mm.SenderEmail = item.SenderEmail;
                    mm.MessageID = item.EbayId;
                    mm.Body = item.BodyRe;
                    mm.ParentMessageID = item.EbayId;

                    addMsgApicall.AddMemberMessageRTQ(item.ItemId, mm);
                    revMsgApicall.ReviseMyMessages(true, false, new StringCollection(new string[] { mm.MessageID }));

                    item.IsUpload = 1;
                }
            }
        }