示例#1
0
        /// <summary>
        ///     updator entry point
        /// </summary>
        /// <param name="version">version no</param>
        /// <param name="debug">0:debug, 1:Release</param>
        private static void Main(int version = 0, int debug = 0)
        {
            UpdatorDto updatorDto = null;

            using var svc = new ServiceExecutorManager <IUpdatorExistsService>(new UpdatorExistsService());
            svc.SetRequest(o => o.Request = version)
            .OnExecuted(o => {
                updatorDto = o.Result;
                return(true);
            });

            if (updatorDto.xIsNotNull())
            {
                using var updatorSvc = new ServiceExecutorManager <IUpdatorService>(new UpdatorService());
                updatorSvc.AddFilter(o => o.Result.xIsNotNull())
                .SetRequest(o => o.Request = updatorDto.FileList)
                .OnExecuted(o => {
                    if (o.Result)
                    {
                        Console.WriteLine("downloaded");
                    }
                    return(true);
                });
            }
        }
 public override bool PreExecute()
 {
     using var executor = new ServiceExecutorManager <IGetTodoItemSvc>(_getTodoItemSvc);
     return(executor.SetRequest(o => o.Request = Request)
            .OnExecuted(o => {
         _exists = o.Result;
         return true;
     }));
 }
 public override bool PreExecute()
 {
     using var executor = new ServiceExecutorManager <IGetAccountSvc>(_getAccountSvc);
     return(executor.SetRequest(o => o.Request = this.Request)
            .OnExecuted(o => {
         _exists = o.Result;
         return _exists.xIsNotNull();
     }));
 }
示例#4
0
        public async Task <bool> RemoveWeather(RequestDto <WeatherForecastRequestDto> request)
        {
            var result = false;

            using var executor = new ServiceExecutorManager <IDeleteWeatherForecastSvc>(_deleteWeatherForecastSvc);
            await executor.SetRequest(o => o.Request = request.Data)
            .OnExecutedAsync(async o => result = o.Result);

            return(result);
        }
示例#5
0
        public async Task <int> SaveWeather(RequestDto <WEATHER_FORECAST> request)
        {
            var result = 0;

            using var executor = new ServiceExecutorManager <ISaveWeatherForecastSvc>(_saveWeatherForecastSvc);
            await executor.SetRequest(o => o.Request = request.Data)
            .OnExecutedAsync(async o => {
                result = o.Result;
                return(true);
            });

            return(result);
        }
示例#6
0
        public async Task <IEnumerable <WEATHER_FORECAST> > GetWeathers()
        {
            IEnumerable <WEATHER_FORECAST> result = null;

            using var executor = new ServiceExecutorManager <IGetAllWeatherForecastSvc>(_getAllWeatherForecastSvc);
            await executor.SetRequest(o => o.Request = new WeatherForecastRequestDto())
            .OnExecutedAsync(async o => {
                result = o.Result;
                return(true);
            });

            return(result);
        }
示例#7
0
        public async Task <WEATHER_FORECAST> GetWeather(int idx = 1)
        {
            WEATHER_FORECAST result = null;

            using var executor = new ServiceExecutorManager <IGetWeatherForecastSvc>(_getWeatherForecastSvc);
            await executor.SetRequest(o => o.Request = new WeatherForecastRequestDto { ID = idx })
            .OnExecutedAsync(async o => {
                result = o.Result;
                return(true);
            });

            return(result);
        }
示例#8
0
        public override bool PreExecute()
        {
            var result = false;

            using var executor = new ServiceExecutorManager <IGetAccountByIdSvc>(_getAccountByIdSvc);
            executor.SetRequest(o => o.Request = Request)
            .OnExecuted(o => {
                result = o.Result.isNotNull();
                return(true);
            });

            return(result);
        }
示例#9
0
        public async Task UserMigrationTestAsync()
        {
            var result = false;

            using (var executor = new ServiceExecutorManager <IMigrationDatabaseService>(_initDatabaseService)) {
                await executor.SetRequest(o => o.Request = true)
                .OnExecutedAsync(async o => {
                    result = o.Result;
                    return(true);
                });
            }

            Assert.True(result);
        }
示例#10
0
        /// <summary>
        /// single execute
        /// </summary>
        /// <param name="serviceExecutor"></param>
        /// <param name="request"></param>
        /// <param name="func"></param>
        /// <typeparam name="TServiceExecutor"></typeparam>
        /// <typeparam name="TRequest"></typeparam>
        /// <typeparam name="TResult"></typeparam>
        /// <returns></returns>
        protected TResult CreateService <TServiceExecutor, TRequest, TResult>
            (TServiceExecutor serviceExecutor, TRequest request, Func <TServiceExecutor, bool> func = null)
            where TServiceExecutor : IServiceExecutor <TRequest, TResult>
        {
            var result = default(TResult);

            using var executor = new ServiceExecutorManager <TServiceExecutor>(serviceExecutor);
            executor.SetRequest(o => o.Request = request)
            .AddFilter(o => func.isNotNull() ? func(serviceExecutor) : true)
            .OnExecuted(o => {
                result = o.Result;
                return(true);
            });
            return(result);
        }
示例#11
0
        public void UserMigrationTest()
        {
            var result = false;

            using (var executor = new ServiceExecutorManager <IMigrationDatabaseService>(_initDatabaseService)) {
                executor.SetRequest(o => o.Request = true)
                .OnExecuted(o => {
                    result = o.Result;
                    return(true);
                });
            }

            Console.WriteLine(result);

            Assert.True(result);
        }
        /// <summary>
        /// 비동기 서비스 생성 메서드
        /// </summary>
        /// <param name="serviceExecutor"></param>
        /// <param name="request"></param>
        /// <param name="func"></param>
        /// <typeparam name="TServiceExecutor"></typeparam>
        /// <typeparam name="TRequest"></typeparam>
        /// <typeparam name="TResult"></typeparam>
        /// <returns></returns>
        protected async Task <TResult> CreateServiceAsync <TServiceExecutor, TRequest, TResult>
            (TServiceExecutor serviceExecutor, TRequest request, Func <TServiceExecutor, bool> func = null)
            where TServiceExecutor : IServiceExecutor <TRequest, TResult>
        {
            var result = default(TResult);

            using var executor = new ServiceExecutorManager <TServiceExecutor>(serviceExecutor);
            await executor.SetRequest(o => o.Request = request)
            .AddFilter(o => func.xIsNotNull() ? func(serviceExecutor) : true)
            .OnExecutedAsync(o => {
                result = o.Result;
                return(Task.FromResult(true));
            });

            return(result);
        }
示例#13
0
        public async Task <string> GetToken([FromBody] Account account)
        {
            var     jwtTokenService = new JwtTokenService();
            Account result          = null;

            using var executor = new ServiceExecutorManager <IGetAccountSvc>(_svc);
            await executor.SetRequest(o => o.Request = account)
            .AddFilter(o => o.Request.isNotNull())
            .OnExecutedAsync(async o => {
                result = o.Result;
                return(true);
            });

            var jwtToken = jwtTokenService.GenerateJwtToken(result.Id);

            return(jwtToken);
        }
        public override bool PreExecute()
        {
            using var executor = new ServiceExecutorManager <IGetWeatherForecastSvc>(_getWeatherForecastSvc);
            executor.SetRequest(o => o.Request = new WeatherForecastRequestDto {
                ID = Request.ID
            })
            .OnExecuted(o => {
                _exists = o.Result;
                return(true);
            });

            if (_exists.isNotNull())
            {
                return(true);
            }
            return(false);
        }
        public override bool PreExecute()
        {
            Account exists = null;

            using var executor = new ServiceExecutorManager <IGetAccountSvc>(_getAccountSvc);
            executor.SetRequest(o => o.Request = Request)
            .AddFilter(o => o.Request.xIsNotNull())
            .OnExecuted(o => {
                exists = o.Result;
                return(true);
            });

            if (exists.xIsNull())
            {
                return(false);
            }
            return(true);
        }
示例#16
0
        public override Task <WeatherForecastResponse> GetWeatherForecast(WeatherForecastRequest request,
                                                                          ServerCallContext context)
        {
            WEATHER_FORECAST result = null;

            using var executor = new ServiceExecutorManager <IGetWeatherForecastSvc>(new GetWeatherForecastSvc());
            executor.SetRequest(o => o.Request = new WeatherForecastRequestDto {
                ID = request.Id
            })
            .OnExecuted(o => {
                result = o.Result;
                return(true);
            });
            return(Task.FromResult(new WeatherForecastResponse {
                Id = result.ID,
                Date = result.DATE.ToString(),
                TemperatureC = result.TEMPERATURE_C.Value,
                TemperatureF = result.TEMPERATURE_F.Value,
                Summary = result.SUMMARY
            }));
        }