예제 #1
0
 private MarketplaceWebService.MarketplaceWebService Configurations(string intergrationType, string accessKey, string secretKey)
 {
     MarketplaceWebService.MarketplaceWebServiceConfig config = new MarketplaceWebService.MarketplaceWebServiceConfig();
     config.ServiceURL = SOHelper.GetIntegrationType(intergrationType.Trim(), SOConstants.serviceUrl);
     MarketplaceWebService.MarketplaceWebService serviceConfig = new MarketplaceWebService.MarketplaceWebServiceClient(accessKey, secretKey, SOConstants.appName, SOConstants.version, config);
     return(serviceConfig);
 }
        internal static void TestSellerAccount(SOAmazonSetup setupview)
        {
            bool marketplaceIdExist = false;

            try
            {
                if (setupview != null)
                {
                    MarketplaceWebServiceSellersConfig msconfig = new MarketplaceWebServiceSellersConfig();
                    msconfig.ServiceURL = SOHelper.GetIntegrationType(setupview.IntegrationType.Trim(), SOConstants.serviceUrl);
                    MarketplaceWebServiceSellers.MarketplaceWebServiceSellers client = new MarketplaceWebServiceSellersClient(SOConstants.appName, SOConstants.version, setupview.AccessKey, setupview.SecretKey, msconfig);
                    SOServiceCalls sample = new SOServiceCalls(client);
                    ListMarketplaceParticipationsResponse response = null;
                    response = sample.InvokeListMarketplaceParticipations(setupview.SellerId, setupview.AuthToken);
                    if (response != null)
                    {
                        string integrationType = SOHelper.GetIntegrationType(setupview.IntegrationType.Trim(), SOConstants.domainName);
                        foreach (Marketplace marketplace in response.ListMarketplaceParticipationsResult.ListMarketplaces.Marketplace)
                        {
                            if (!string.IsNullOrEmpty(marketplace.Name) && !string.IsNullOrEmpty(integrationType) && marketplace.Name.ToLower() == integrationType.ToLower() &&
                                !string.IsNullOrEmpty(setupview.MarketplaceId) && !string.IsNullOrEmpty(marketplace.MarketplaceId) && setupview.MarketplaceId.ToLower() == marketplace.MarketplaceId.ToLower())
                            {
                                marketplaceIdExist = true;
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(SOMessages.connectionFailed + Convert.ToString(ex.Message));
            }
            if (marketplaceIdExist)  // we need this condition check because  if we  try to raise PXOperationCompletedException inside try catch block ,
                                     //the catch block  gets executed and displays a success message with error icon.

            {
                throw new PXOperationCompletedException(SOMessages.connectionSuccess);
            }
            else
            {
                throw new PXOperationCompletedWithErrorException(SOMessages.connectionFailed + SOMessages.errorMsg);
            }
        }