Exemplo n.º 1
0
        /// <summary>
        /// Parsed and persist the submission list response to the database
        /// </summary>
        /// <param name="response">The submission list response to parsed and to save</param>
        /// <param name="isUpdate">Flag if it is to update or add the response to database</param>
        private void parsedAndPersistSubmissionListResponse(GetFeedSubmissionListResponse response, ref bool isUpdate)
        {
            if (!response.IsSetGetFeedSubmissionListResult())
            {
                return;
            }

            var submissionInfo = response.GetFeedSubmissionListResult.FeedSubmissionInfo.First();

            var requestReport = new MarketplaceRequestReport
            {
                RequestId        = response.ResponseMetadata.RequestId,
                ReportRequestId  = submissionInfo.FeedSubmissionId,
                FeedType         = submissionInfo.FeedType,
                ProcessingStatus = submissionInfo.FeedProcessingStatus,
                StartDate        = submissionInfo.StartedProcessingDate,
                EndDate          = submissionInfo.CompletedProcessingDate,
                SubmittedDate    = submissionInfo.SubmittedDate,
                SubmittedBy      = _submittedBy
            };

            if (isUpdate)
            {
                _logger.UpdateRequestReport(requestReport);
            }
            else
            {
                _logger.AddRequestReport(requestReport);
                isUpdate = true;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// returns a list of feed submission identifiers and their associated metadata
        ///
        /// </summary>
        /// <param name="service">Instance of MarketplaceWebService service</param>
        /// <param name="request">GetFeedSubmissionListRequest request</param>
        public static async Task InvokeGetFeedSubmissionList(MarketplaceWebService service, GetFeedSubmissionListRequest request)
        {
            try
            {
                GetFeedSubmissionListResponse response = await service.GetFeedSubmissionList(request);


                Console.WriteLine("Service Response");
                Console.WriteLine("=============================================================================");
                Console.WriteLine();

                Console.WriteLine("        GetFeedSubmissionListResponse");
                if (response.IsSetGetFeedSubmissionListResult())
                {
                    Console.WriteLine("            GetFeedSubmissionListResult");
                    GetFeedSubmissionListResult getFeedSubmissionListResult = response.GetFeedSubmissionListResult;
                    if (getFeedSubmissionListResult.IsSetNextToken())
                    {
                        Console.WriteLine("                NextToken");
                        Console.WriteLine("                    {0}", getFeedSubmissionListResult.NextToken);
                    }
                    if (getFeedSubmissionListResult.IsSetHasNext())
                    {
                        Console.WriteLine("                HasNext");
                        Console.WriteLine("                    {0}", getFeedSubmissionListResult.HasNext);
                    }
                    List <FeedSubmissionInfo> feedSubmissionInfoList = getFeedSubmissionListResult.FeedSubmissionInfo;
                    foreach (FeedSubmissionInfo feedSubmissionInfo in feedSubmissionInfoList)
                    {
                        Console.WriteLine("                FeedSubmissionInfo");
                        if (feedSubmissionInfo.IsSetFeedSubmissionId())
                        {
                            Console.WriteLine("                    FeedSubmissionId");
                            Console.WriteLine("                        {0}", feedSubmissionInfo.FeedSubmissionId);
                        }
                        if (feedSubmissionInfo.IsSetFeedType())
                        {
                            Console.WriteLine("                    FeedType");
                            Console.WriteLine("                        {0}", feedSubmissionInfo.FeedType);
                        }
                        if (feedSubmissionInfo.IsSetSubmittedDate())
                        {
                            Console.WriteLine("                    SubmittedDate");
                            Console.WriteLine("                        {0}", feedSubmissionInfo.SubmittedDate);
                        }
                        if (feedSubmissionInfo.IsSetFeedProcessingStatus())
                        {
                            Console.WriteLine("                    FeedProcessingStatus");
                            Console.WriteLine("                        {0}", feedSubmissionInfo.FeedProcessingStatus);
                        }
                        if (feedSubmissionInfo.IsSetStartedProcessingDate())
                        {
                            Console.WriteLine("                    StartedProcessingDate");
                            Console.WriteLine("                        {0}", feedSubmissionInfo.StartedProcessingDate);
                        }
                        if (feedSubmissionInfo.IsSetCompletedProcessingDate())
                        {
                            Console.WriteLine("                    CompletedProcessingDate");
                            Console.WriteLine("                        {0}", feedSubmissionInfo.CompletedProcessingDate);
                        }
                    }
                }
                if (response.IsSetResponseMetadata())
                {
                    Console.WriteLine("            ResponseMetadata");
                    ResponseMetadata responseMetadata = response.ResponseMetadata;
                    if (responseMetadata.IsSetRequestId())
                    {
                        Console.WriteLine("                RequestId");
                        Console.WriteLine("                    {0}", responseMetadata.RequestId);
                    }
                }

                Console.WriteLine("            ResponseHeaderMetadata");
                Console.WriteLine("                RequestId");
                Console.WriteLine("                    " + response.ResponseHeaderMetadata.RequestId);
                Console.WriteLine("                ResponseContext");
                Console.WriteLine("                    " + response.ResponseHeaderMetadata.ResponseContext);
                Console.WriteLine("                Timestamp");
                Console.WriteLine("                    " + response.ResponseHeaderMetadata.Timestamp);
            }
            catch (MarketplaceWebServiceException ex)
            {
                Console.WriteLine("Caught Exception: " + ex.Message);
                Console.WriteLine("Response Status Code: " + ex.StatusCode);
                Console.WriteLine("Error Code: " + ex.ErrorCode);
                Console.WriteLine("Error Type: " + ex.ErrorType);
                Console.WriteLine("Request ID: " + ex.RequestId);
                Console.WriteLine("XML: " + ex.XML);
                Console.WriteLine("ResponseHeaderMetadata: " + ex.ResponseHeaderMetadata);
            }
        }
Exemplo n.º 3
0
        private FeedSubmissionInfo[] _GetFeedSubmissionList(string[] FeedSubmissionIdList, EFeedType[] FeedTypeList, EFeedProcessingStatus[] FeedProcessingStatusList, DateTime SubmittedFromDate, DateTime SubmittedToDate)
        {
            string                       NextToken   = string.Empty;
            AmazonCredential             Credentials = this.GetCredential();
            MarketplaceWebServiceClient  Client      = this.GetClient(Credentials);
            GetFeedSubmissionListRequest Request     = new GetFeedSubmissionListRequest()
            {
                Merchant = Credentials.MerchantID,
                MaxCount = 100
            };

            if (FeedSubmissionIdList != null)
            {
                Request.FeedSubmissionIdList = new IdList()
                {
                    Id = FeedSubmissionIdList.ToList()
                }
            }
            ;
            else if (FeedTypeList != null)
            {
                Request.FeedTypeList = new TypeList()
                {
                    Type = FeedTypeList.Select(Item => EnumStringHandler.GetEnumString <EFeedType>(Item)).ToList()
                }
            }
            ;
            else if (FeedProcessingStatusList != null)
            {
                Request.FeedProcessingStatusList = new StatusList()
                {
                    Status = FeedProcessingStatusList.Select(Item => EnumStringHandler.GetEnumString <EFeedProcessingStatus>(Item)).ToList()
                }
            }
            ;
            else if (SubmittedFromDate != default(DateTime) && SubmittedToDate != default(DateTime))
            {
                Request.SubmittedFromDate = SubmittedFromDate;
                Request.SubmittedToDate   = SubmittedToDate;
            }

            List <FeedSubmissionInfo> Info = new List <FeedSubmissionInfo>();
            Task GetFeedSubmissionListTask = new Task(() =>
            {
                while (true)
                {
                    switch (NextToken == string.Empty)
                    {
                    case true:
                        this.Throttle(ERequestType.GetFeedSubmissionList);
                        GetFeedSubmissionListResponse Response = Client.GetFeedSubmissionList(Request);
                        if (Response.IsSetGetFeedSubmissionListResult())
                        {
                            GetFeedSubmissionListResult Result = Response.GetFeedSubmissionListResult;
                            if (Result.IsSetFeedSubmissionInfo())
                            {
                                foreach (var FeedInfo in Result.FeedSubmissionInfo)
                                {
                                    Info.Add(FeedInfo);
                                }
                            }

                            if (Result.HasNext)
                            {
                                NextToken = Result.NextToken;
                            }
                            else
                            {
                                goto EndOfLoop;
                            }
                        }
                        break;

                    case false:
                        this.Throttle(ERequestType.GetFeedSubmissionListByNextToken);
                        GetFeedSubmissionListByNextTokenRequest RequestNextToken = new GetFeedSubmissionListByNextTokenRequest()
                        {
                            Merchant  = Credentials.MerchantID,
                            NextToken = NextToken,
                        };
                        GetFeedSubmissionListByNextTokenResponse ResponseNextToken = Client.GetFeedSubmissionListByNextToken(RequestNextToken);
                        if (ResponseNextToken.IsSetGetFeedSubmissionListByNextTokenResult())
                        {
                            GetFeedSubmissionListByNextTokenResult ResultNextToken = ResponseNextToken.GetFeedSubmissionListByNextTokenResult;
                            if (ResultNextToken.IsSetFeedSubmissionInfo())
                            {
                                foreach (var FeedInfo in ResultNextToken.FeedSubmissionInfo)
                                {
                                    Info.Add(FeedInfo);
                                }
                            }

                            if (ResultNextToken.HasNext)
                            {
                                NextToken = ResultNextToken.NextToken;
                            }
                            else
                            {
                                goto EndOfLoop;
                            }
                        }
                        break;
                    }
                }
                EndOfLoop:
                Console.Write("");
            });

            GetFeedSubmissionListTask.Start();
            GetFeedSubmissionListTask.Wait((int)Math.Ceiling(TimeSpan.FromMinutes(Definitions.Timeout_Minutes).Add(TimeSpan.FromHours(Definitions.Timeout_Hours)).TotalMilliseconds));
            return(Info.ToArray());
        }