Beispiel #1
0
        public async Task <IHttpActionResult> CreateAppConfiguration([FromBody] AppConfigurationInfo info, CancellationToken token)
        {
            CustomTrace.TraceInformation("[CreateAppConfiguration] AppId={0}", info.AppId);

            var appConfiguration = await this.Database.AppConfigurations.GetSingleAsync(info.AppId, token);

            if (appConfiguration == null)
            {
                appConfiguration = new AppConfigurationEntity
                {
                    Id            = info.AppId,
                    Configuration = info.Configuration,
                };

                await this.Database.AppConfigurations.InsertAsync(appConfiguration, token);
            }
            else
            {
                await this.Database.AppConfigurations.UpsertAsync(appConfiguration, token);
            }

            var response = new AppConfigurationResponse
            {
                AppId         = info.AppId,
                Configuration = info.Configuration
            };

            return(this.CreateSuccessResult(response));
        }
Beispiel #2
0
        public AppServerApiController(UCenterDatabaseContext database)
            : base(database)
        {
            this.appConfigurationCacheProvider = new CacheProvider <AppConfigurationResponse>(
                TimeSpan.FromMinutes(5),
                async(key, token) =>
            {
                var appConfiguration = await this.Database.AppConfigurations.GetSingleAsync(key, token);

                var response = new AppConfigurationResponse
                {
                    AppId         = key,
                    Configuration = appConfiguration == null ? string.Empty : appConfiguration.Configuration
                };

                return(response);
            });
            this.appCacheProvider = new CacheProvider <AppResponse>(
                TimeSpan.FromMinutes(5),
                async(key, token) =>
            {
                var app      = await this.Database.Apps.GetSingleAsync(key, token);
                var response = new AppResponse
                {
                    AppId     = key,
                    AppSecret = app == null ? string.Empty : app.AppSecret
                };

                return(response);
            });
        }
Beispiel #3
0
        //-------------------------------------------------------------------------
        //void _onUCenterGetIpAddress(UCenterResponseStatus status, IPInfoResponse response, UCenterError error)
        //{
        //    EbLog.Note("ClientSampleApp._onUCenterGetIpAddress() UCenterResult=" + status);

        //    if (error != null)
        //    {
        //        EbLog.Note("ErrorCode=" + error.ErrorCode);
        //        EbLog.Note("ErrorMessage=" + error.Message);
        //    }
        //    else if (status == UCenterResponseStatus.Success)
        //    {
        //        EbLog.Note("Code=" + response.Code);
        //        EbLog.Note("Area=" + response.Content.Area);
        //        EbLog.Note("City=" + response.Content.City);
        //        EbLog.Note("Country=" + response.Content.Country);
        //        EbLog.Note("Region=" + response.Content.Region);
        //        EbLog.Note("IP=" + response.Content.IP);
        //    }
        //}

        //-------------------------------------------------------------------------
        void _onUCenterGetAppConfig(UCenterResponseStatus status, AppConfigurationResponse response, UCenterError error)
        {
            EbLog.Note("ClientSampleApp._onUCenterGetAppConfig() UCenterResult=" + status);

            if (error != null)
            {
                EbLog.Note("ErrorCode=" + error.ErrorCode);
                EbLog.Note("ErrorMessage=" + error.Message);
            }
            else if (status == UCenterResponseStatus.Success)
            {
                EbLog.Note("AppId=" + response.AppId);
                EbLog.Note("Configuration=" + response.Configuration);
            }
        }
Beispiel #4
0
        public async Task <IHttpActionResult> GetAppConfiguration([FromUri] string appId, CancellationToken token)
        {
            CustomTrace.TraceInformation($"AppClient.GetAppConfiguration AppId={appId}");

            var app = await this.Database.Apps.GetSingleAsync(appId, token);

            if (app == null)
            {
                throw new UCenterException(UCenterErrorCode.AppNotExit);
            }

            var appConfiguration = await this.Database.AppConfigurations.GetSingleAsync(appId, token);

            var response = new AppConfigurationResponse
            {
                AppId         = app.Id,
                Configuration = appConfiguration == null ? string.Empty : appConfiguration.Configuration
            };

            return(this.CreateSuccessResult(response));
        }
        public async Task <IActionResult> GetAppConfiguration(string appId, CancellationToken token)
        {
            AppConfigurationResponse response = null;// await this.appConfigurationCacheProvider.Get(appId, token);

            return(this.CreateSuccessResult(response));
        }