当前位置: 首页>>代码示例>>C#>>正文


C# Sdk.ApiContext类代码示例

本文整理汇总了C#中eBay.Service.Core.Sdk.ApiContext的典型用法代码示例。如果您正苦于以下问题:C# ApiContext类的具体用法?C# ApiContext怎么用?C# ApiContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ApiContext类属于eBay.Service.Core.Sdk命名空间,在下文中一共展示了ApiContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetApiContext

        /// <summary>
        /// Populate eBay SDK ApiContext object with data from application configuration file
        /// </summary>
        /// <returns>ApiContext object</returns>
        static ApiContext GetApiContext()
        {
            //apiContext is a singleton,
            //to avoid duplicate configuration reading
            if (apiContext != null)
            {
                return apiContext;
            }
            else
            {
                apiContext = new ApiContext();

                //set Api Server Url
                apiContext.SoapApiServerUrl = 
                    ConfigurationManager.AppSettings["Environment.ApiServerUrl"];
                //set Api Token to access eBay Api Server
                ApiCredential apiCredential = new ApiCredential();
                apiCredential.eBayToken = 
                    ConfigurationManager.AppSettings["UserAccount.ApiToken"];
                apiContext.ApiCredential = apiCredential;
                //set eBay Site target to US
                apiContext.Site = SiteCodeType.US;

                //set Api logging
                apiContext.ApiLogManager = new ApiLogManager();
                apiContext.ApiLogManager.ApiLoggerList.Add(
                    new FileLogger("listing_log.txt", true, true, true)
                    );
                apiContext.ApiLogManager.EnableLogging = true;


                return apiContext;
            }
        }
开发者ID:jaskirat-danits,项目名称:oswebshop,代码行数:38,代码来源:Program.cs

示例2: Page_Init

        protected void Page_Init()
        {
            //get eBayToken and ServerAddress from Web.config
            string tradingServerAddress = System.Configuration.ConfigurationManager.AppSettings["TradingServerAddress"];
            string eBayToken = System.Configuration.ConfigurationManager.AppSettings["EBayToken"];

            apiContext = new ApiContext();

            //set Api Server Url
            apiContext.SoapApiServerUrl = tradingServerAddress;

            //set Api Token to access eBay Api Server
            ApiCredential apiCredential = new ApiCredential();
            apiCredential.eBayToken = eBayToken;
            apiContext.ApiCredential = apiCredential;

            //set eBay Site target to US
            apiContext.Site = SiteCodeType.US;

            //set Api logging
            apiContext.ApiLogManager = new ApiLogManager();
            apiContext.ApiLogManager.ApiLoggerList.Add(
                new FileLogger("trading_log.txt", true, true, true)
                );
            apiContext.ApiLogManager.EnableLogging = true;
        }
开发者ID:jackpetraitis,项目名称:besthashfordacash,代码行数:26,代码来源:AddToWatchList.aspx.cs

示例3: GetGenericApiContext

        public static ApiContext GetGenericApiContext(string site)
        {
            ApiContext apiContext = new ApiContext();
            apiContext.Version = System.Configuration.ConfigurationManager.AppSettings.Get(VERSION);
            apiContext.Timeout = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings.Get(TIME_OUT));
            apiContext.SoapApiServerUrl = System.Configuration.ConfigurationManager.AppSettings.Get(API_SERVER_URL);
            apiContext.EPSServerUrl = System.Configuration.ConfigurationManager.AppSettings.Get(EPS_SERVER_URL);
            apiContext.SignInUrl = System.Configuration.ConfigurationManager.AppSettings.Get(SIGNIN_URL);

            ApiAccount apiAccount = new ApiAccount();
            apiAccount.Developer = System.Configuration.ConfigurationManager.AppSettings["Environment.DevId"];
            apiAccount.Application = System.Configuration.ConfigurationManager.AppSettings["Environment.AppId"];
            apiAccount.Certificate = System.Configuration.ConfigurationManager.AppSettings["Environment.CertId"];

            ApiCredential apiCredential = new ApiCredential();
            apiCredential.ApiAccount = apiAccount;

            apiContext.ApiCredential = apiCredential;

            apiContext.EnableMetrics = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings.Get(ENABLE_METRICS));

            if (!string.IsNullOrEmpty(site))
            {
                apiContext.Site = (SiteCodeType)Enum.Parse(typeof(SiteCodeType), site, true);
            }

            apiContext.RuleName = System.Configuration.ConfigurationManager.AppSettings["RuName"];// EBayPriceChanges.Config.RuName;
            apiContext.RuName = System.Configuration.ConfigurationManager.AppSettings["RuName"];// EBayPriceChanges.Config.RuName;
            return apiContext;
        }
开发者ID:jmyd,项目名称:oms,代码行数:30,代码来源:AppSettingHelper.cs

示例4: GetGenericApiContext

		/// <summary>
		/// 
		/// </summary>
		/// <returns> API Context without user crendials
		/// </returns>
		private static ApiContext GetGenericApiContext()
		{
			ApiContext apiContext = new ApiContext();

            apiContext.Version = System.Configuration.ConfigurationManager.AppSettings.Get(VERSION);
            apiContext.Timeout = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings.Get(TIME_OUT));
            apiContext.SoapApiServerUrl = System.Configuration.ConfigurationManager.AppSettings.Get(API_SERVER_URL);
            apiContext.EPSServerUrl = System.Configuration.ConfigurationManager.AppSettings.Get(EPS_SERVER_URL);
            apiContext.SignInUrl = System.Configuration.ConfigurationManager.AppSettings.Get(SIGNIN_URL);	

			ApiAccount apiAccount = new ApiAccount();
            apiAccount.Developer = System.Configuration.ConfigurationManager.AppSettings.Get(DEV_ID);
            apiAccount.Application = System.Configuration.ConfigurationManager.AppSettings.Get(APP_ID);
            apiAccount.Certificate = System.Configuration.ConfigurationManager.AppSettings.Get(CERT_ID);

			ApiCredential apiCredential = new ApiCredential();
			apiCredential.ApiAccount = apiAccount;

			apiContext.ApiCredential = apiCredential;

            apiContext.EnableMetrics = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings.Get(ENABLE_METRICS));

            string site = System.Configuration.ConfigurationManager.AppSettings.Get(EBAY_USER_SITE_ID);
			if (site != null) 
			{
				apiContext.Site = (SiteCodeType)Enum.Parse(typeof(SiteCodeType), site, false);
			}

            apiContext.RuleName = System.Configuration.ConfigurationManager.AppSettings.Get(RULE_NAME);

			return apiContext;
		}
开发者ID:jaskirat-danits,项目名称:oswebshop,代码行数:37,代码来源:AppSettingHelper.cs

示例5: GetLeafCategory

		/// <summary>
		///return leaf category objects of specific number
		/// </summary>
		/// <param name="number">how many leaf categories you wanna get.</param>
		/// <param name="category"></param>
		/// <param name="apiContext"></param>
		/// <param name="message"></param>
		/// <returns></returns>
		public static bool GetLeafCategory(int number,out CategoryTypeCollection categories,ApiContext apiContext,out string message)
		{
			CategoryTypeCollection categoryTypeCollection;
			categories=new CategoryTypeCollection();
			if(number<=0)
			{
				number=1;
			}

			if(getAllCategories(apiContext,out categoryTypeCollection,out message))
			{
				foreach(CategoryType category in categoryTypeCollection)
				{
					if(category.LeafCategory==true)
					{
						categories.Add(category);

						if(categories.Count==number)
						{
							break;
						}
					}
				}

				return true;
			}

			return false;
		}
开发者ID:jaskirat-danits,项目名称:oswebshop,代码行数:37,代码来源:CategoryHelper.cs

示例6: APIAccount_Load

        private void APIAccount_Load(object sender, EventArgs e)
        {
            if (apiContext == null)
            {
                apiContext = AppSettingHelper.GetApiContext();
                apiContext.ApiLogManager = new ApiLogManager();
                LoggingProperties logProps = AppSettingHelper.GetLoggingProperties();
                apiContext.ApiLogManager.ApiLoggerList.Add(new FileLogger(logProps.LogFileName, true, true, true));
                apiContext.ApiLogManager.EnableLogging = true;
                apiContext.Site = SiteCodeType.US;
            }
            string[] sites = Enum.GetNames(typeof(SiteCodeType));
            foreach (string site in sites)
            {
                if (site != "CustomCode")
                {
                    CboSite.Items.Add(site);
                }
            }
            string[] langs = Enum.GetNames(typeof(ErrorLanguageCodeType));
            foreach (string lang in langs)
            {
                if (lang != "CustomCode")
                {
                    CboLanguage.Items.Add(lang);
                }
            }
            CboSite.SelectedIndex = 0;

            SetBindings();
        }
开发者ID:andyzhang0216,项目名称:EBayTool,代码行数:31,代码来源:APIAccount.cs

示例7: GetApiContext

        //get parameters from config file and create
        //ApiContext object
        static ApiContext GetApiContext()
        {
            ApiContext cxt = new ApiContext();

            // set api server address
            cxt.SoapApiServerUrl = ConfigurationManager.AppSettings[KEY_API_URL];


            // set token
            ApiCredential ac = new ApiCredential();
            string token = ConfigurationManager.AppSettings[KEY_APITOKEN];
            ac.eBayToken = token;
            cxt.ApiCredential = ac;

            // initialize log.
            ApiLogManager logManager = null;
            string logPath = ConfigurationManager.AppSettings[KEY_LOGFILE];
            if (logPath.Length > 0)
            {
                logManager = new ApiLogManager();

                logManager.EnableLogging = true;

                logManager.ApiLoggerList = new ApiLoggerCollection();
                ApiLogger log = new FileLogger(logPath, true, true, true);
                logManager.ApiLoggerList.Add(log);
            }
            cxt.ApiLogManager = logManager;

            return cxt;
        }
开发者ID:jaskirat-danits,项目名称:oswebshop,代码行数:33,代码来源:AttributesTester.cs

示例8: DetailsDownloader

 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="context"></param>
 public DetailsDownloader(ApiContext context)
 {
     this.context = context;
     //must initialize some super class fields
     this.filePrefix = "EBayDetails";
     this.fileSuffix = "eds";
     this.objType = typeof(GeteBayDetailsResponseType);
 }
开发者ID:fudder,项目名称:cs493,代码行数:12,代码来源:DetailsDownloader.cs

示例9: CategoryFacade

        //constructor
        public CategoryFacade(string catId, ApiContext apiContext,SiteFacade siteFacade)
        {
            this.catId = catId;
            this.apiContext = apiContext;
            this.siteFacade = siteFacade;

            this.SyncCategoryMetaData();
        }
开发者ID:jaskirat-danits,项目名称:oswebshop,代码行数:9,代码来源:CategoryFacade.cs

示例10: CategoriesDownloader

		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="context"></param>
		public CategoriesDownloader(ApiContext context)
		{
			this.context=context;
			//must initialize some super class fields
			this.filePrefix = "AllCategories";
			this.fileSuffix = "cats";
			this.objType = typeof(GetCategoriesResponseType);
		}
开发者ID:jaskirat-danits,项目名称:oswebshop,代码行数:12,代码来源:CategoriesDownloader.cs

示例11: GetShippingServices

		//get eBay Details
		public static GeteBayDetailsResponseType GetShippingServices(ApiContext apiContext)
		{
				GeteBayDetailsCall api = new GeteBayDetailsCall(apiContext);
				DetailNameCodeTypeCollection names=new DetailNameCodeTypeCollection();
				names.Add(DetailNameCodeType.ShippingLocationDetails);
				names.Add(DetailNameCodeType.ShippingServiceDetails);
				api.GeteBayDetails(null);
				return api.ApiResponse;
		}
开发者ID:jaskirat-danits,项目名称:oswebshop,代码行数:10,代码来源:CategoryFeatureManager.cs

示例12: CategoryFacade

        //constructor
        public CategoryFacade(string catId, ApiContext apiContext, AttributesMaster attrMaster, SiteFacade siteFacade)
        {
            this.catId = catId;
            this.apiContext = apiContext;
            this.attrMaster = attrMaster;
            this.siteFacade = siteFacade;

            this.SyncCategoryMetaData();
        }
开发者ID:fudder,项目名称:cs493,代码行数:10,代码来源:CategoryFacade.cs

示例13: GetAdFormatCategory

        /// <summary>
        /// get some items which supports the ad format category, you can specify the number
        /// </summary>
        /// <param name="apiContext"></param>
        /// <param name="num"></param>
        /// <param name="categoryTypeCollection"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public static bool GetAdFormatCategory(ApiContext apiContext,int num,out CategoryTypeCollection categoryTypeCollection,out string message)
        {
            message=string.Empty;
            CategoryTypeCollection tmpCategories;
            categoryTypeCollection = null;
            num=(num<=0)?1:num;

            GetCategoryFeaturesCall api = new GetCategoryFeaturesCall(apiContext);
            setBasicInfo(ref api);
            //spcify category id
            if(!getAllCategories(apiContext,out tmpCategories, out message))
            {
                message=message+",203";
                return false;
            }

            FeatureIDCodeTypeCollection features=new FeatureIDCodeTypeCollection();
            FeatureIDCodeType type=FeatureIDCodeType.AdFormatEnabled;
            features.Add(type);

            string categoryID=string.Empty;

            foreach(CategoryType category in tmpCategories)
            {
                if(category.LeafCategory == true)
                {
                    categoryID=category.CategoryID;
                    try
                    {
                        //call
                        CategoryFeatureTypeCollection featureTypes = api.GetCategoryFeatures(categoryID,10,true,features,true);

                        if(featureTypes!=null&&featureTypes.Count>0)
                        {
                            if(featureTypes[0].AdFormatEnabled==AdFormatEnabledCodeType.Enabled)
                            {
                                categoryTypeCollection.Add(category);
                            }

                            if(categoryTypeCollection.Count>=num)
                            {
                                break;
                            }
                        }

                    }
                    catch(Exception e)
                    {
                        message=e.Message+",204";
                        return false;
                    }
                }
            }

            return true;
        }
开发者ID:fudder,项目名称:cs493,代码行数:64,代码来源:CategoryHelper.cs

示例14: SetServiceContext

        static void SetServiceContext()
        {
            eBayApiServiceUrl = Utility.GetApplicationSetting<string>(Constants.CONST_SETTINGS_EBAY_API_SERVER_URL, "");

            eBayApiToken = Utility.GetApplicationSetting<string>(Constants.CONST_SETTINGS_EBAY_API_TOKEN, "");

            _apiContext = new ApiContext();

            _apiContext.SoapApiServerUrl = eBayApiServiceUrl;

            ApiCredential apiCredential = new ApiCredential();

            apiCredential.eBayToken = eBayApiToken;

            _apiContext.ApiCredential = apiCredential;

            _apiContext.Site = SiteCodeType.UK;

            _apiContext.ApiLogManager = new ApiLogManager();

            CallRetry retry = new CallRetry();

            retry.DelayTime = 3000;

            retry.MaximumRetries = 5;

            retry.TriggerHttpStatusCodes.Add(500);
            retry.TriggerHttpStatusCodes.Add(502);

            _apiContext.CallRetry = retry;

            FileLogger loger = new FileLogger();

            string path = Utility.GetApplicationSetting<string>("LogFilePath", @"D:\");

            //string assemblyDir = Path.GetDirectoryName(path);

            string logFileDirectory = Path.Combine(path, @"LogFilePath");

            if (!Directory.Exists(logFileDirectory))
            {
                Directory.CreateDirectory(logFileDirectory);
            }

            string logFileName = string.Format(@"{0}\eBayLog_{1}.txt", logFileDirectory, DateTime.Now.Date.ToString("yyyyMMdd"));

            loger.FileName = logFileName;

            //loger.LogApiMessages = true;
            loger.LogExceptions = true;
            loger.LogInformations = false;

            _apiContext.ApiLogManager.ApiLoggerList.Add(loger);

            _apiContext.ApiLogManager.EnableLogging = true;
        }
开发者ID:verveinfotech,项目名称:Innoventory,代码行数:56,代码来源:eBayApiContextFactory.cs

示例15: GetCategoryFeaturesHelper

		/// <summary>
		/// 
		/// </summary>
        public GetCategoryFeaturesHelper(ApiContext ApiContext, string CategoryID, int LevelLimit, bool ViewAllNodes, FeatureIDCodeTypeCollection FeatureIDList, bool AllFeaturesForCategory) 
		{
			_apiContext = ApiContext;
			_site = _apiContext.Site;
			_categoryID = CategoryID;
			_levelLimit = LevelLimit;
			_viewAllNodes = ViewAllNodes;
			_featureIDs = FeatureIDList;
            _allFeaturesForCategory = AllFeaturesForCategory;
			loadCategoryFeatures(_site);
		}
开发者ID:jaskirat-danits,项目名称:oswebshop,代码行数:14,代码来源:GetCategoryFeaturesHelper.cs


注:本文中的eBay.Service.Core.Sdk.ApiContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。