コード例 #1
0
        protected override void ExecuteInternal()
        {
            this.Message = null;

            GetMyMessagesCall apiCall = new GetMyMessagesCall(this.ApiContext);

            apiCall.ApiRequest.DetailLevel = new DetailLevelCodeTypeCollection();
            apiCall.ApiRequest.DetailLevel.Add(DetailLevelCodeType.ReturnMessages);
            apiCall.ApiRequest.ExternalMessageIDs = new StringCollection();
            apiCall.ApiRequest.ExternalMessageIDs.Add(this.MessageId);

            apiCall.Execute();


            if (apiCall.HasWarning)
            {
                string message = apiCall.ApiException.Message;
            }
            if (apiCall.HasError)
            {
                string message = apiCall.ApiException.Message;
            }

            if (apiCall.ApiResponse != null &&
                apiCall.ApiResponse.Messages != null &&
                apiCall.ApiResponse.Messages.Count > 0)
            {
                this.Message = apiCall.ApiResponse.Messages[0];
            }
        }
コード例 #2
0
        }  // GetAllMessageByIds

        // Get all messages between buyers and sellers.
        public static bool GetAllMessages(AccountType account, DateTime startTime, DateTime endTime)
        {
            GetMyMessagesCall getMyMessageApiCall = new GetMyMessagesCall(account.SellerApiContext);

            getMyMessageApiCall.StartTime = startTime;
            getMyMessageApiCall.EndTime   = endTime;

            DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] { DetailLevelCodeType.ReturnHeaders };
            getMyMessageApiCall.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels);
            getMyMessageApiCall.GetMyMessages();
            MyMessagesMessageTypeCollection messages = getMyMessageApiCall.MessageList;

            foreach (MyMessagesMessageType msg in messages)
            {
                string            msgId = msg.MessageID;
                GetMyMessagesCall getMyMessageApiCall2 = new GetMyMessagesCall(account.SellerApiContext);

                StringCollection msgIds = new StringCollection();
                msgIds.Add(msgId);
                getMyMessageApiCall2.MessageIDList = msgIds;
                detailLevels = new DetailLevelCodeType[] { DetailLevelCodeType.ReturnMessages };
                getMyMessageApiCall2.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels);
                getMyMessageApiCall2.GetMyMessages();

                MyMessagesMessageType msg2 = getMyMessageApiCall2.MessageList[0];

                EbayMessageType ebayMsg = new EbayMessageType();
                ebayMsg.EbayMessageId     = msgId;
                ebayMsg.SellerName        = account.ebayAccount;
                ebayMsg.MessageType       = msg2.MessageType.ToString();
                ebayMsg.QuestionType      = msg2.QuestionType.ToString();
                ebayMsg.IsRead            = msg2.Read;
                ebayMsg.IsReplied         = msg2.Replied;
                ebayMsg.IsResponseEnabled = msg2.ResponseDetails != null ? msg2.ResponseDetails.ResponseEnabled : false;
                ebayMsg.ResponseURL       = msg2.ResponseDetails != null ? msg2.ResponseDetails.ResponseURL : "";
                ebayMsg.UserResponseDate  = msg2.ResponseDetails != null ? msg2.ResponseDetails.UserResponseDate : DateTime.MinValue;
                ebayMsg.ReceiveDate       = msg2.ReceiveDate;
                ebayMsg.RecipientUserId   = msg2.RecipientUserID;
                ebayMsg.Sender            = msg2.Sender;
                ebayMsg.Subject           = msg2.Subject;
                ebayMsg.IsHighPriority    = msg2.HighPriority;
                ebayMsg.Content           = msg2.Content;
                ebayMsg.Text = msg2.Text;
                ebayMsg.ExternalMessageId = msg2.ExternalMessageID;
                ebayMsg.FolderId          = msg2.Folder != null ? msg2.Folder.FolderID : -1;
                ebayMsg.ItemID            = msg2.ItemID;
                ebayMsg.ItemTitle         = msg2.ItemTitle;
                ebayMsg.ItemEndTime       = msg2.ItemEndTime;
                ebayMsg.ListingStatus     = msg2.ListingStatus.ToString();

                EbayMessageDAL.InsertOneMessage(ebayMsg);
            }

            return(true);
        }  // GetAllMessages