public void Settings_CRUD() { var proxy = new ProxyService <SystemService>(new SystemService(new ServiceContext())); //arrange var dto = testUtil.SettingsDto(); //Create var rpInsert = proxy.RunAsync(x => x.InsertSettings(dto)); rpInsert.Wait(); Assert.True(rpInsert.Result.Data > 0); //Read long identity = rpInsert.Result.Data; var rpGet = proxy.RunAsync(x => x.GetSettings(identity)); rpGet.Wait(); Assert.True(rpInsert.Result.Data == rpGet.Result.Data.Id); //Update var tmpDto = rpGet.Result.Data; tmpDto.Key = "Name updated!"; var rpUpdate = proxy.RunAsync(x => x.UpdateSettings(tmpDto)); rpUpdate.Wait(); var rpUpdateGet = proxy.RunAsync(x => x.GetSettings(identity)); rpUpdateGet.Wait(); Assert.Equal(rpUpdateGet.Result.Data.Key, tmpDto.Key); //Delete var rpDelete = proxy.RunAsync(x => x.DeleteSettings(identity)); rpDelete.Wait(); var rpDeleteGet = proxy.RunAsync(x => x.GetSettings(identity)); rpDeleteGet.Wait(); Assert.True(rpDeleteGet.Result.Data == null); //List var queryDto = new SettingsDto { }; var pagingDto = new PagingDto { pageSize = 3, pageNumber = 1 }; var rpList = proxy.RunAsync(x => x.ListSettings(queryDto, pagingDto));//List rpList.Wait(); Assert.True(rpList?.Result.Data != null && rpList.Result.Data.Any()); //assert //cleaup var rpHardDelete = proxy.RunAsync(x => x.DeleteHardSettings(identity)); }
public void Device_CRUD() { var proxy = new ProxyService <DeviceService>(new DeviceService(new ServiceContext())); //arrange var dto = testUtil.DeviceDto(); //Create var rpInsert = proxy.RunAsync(x => x.InsertDevice(dto)); rpInsert.Wait(); Assert.True(rpInsert.Result.Data > 0); //Read long identity = rpInsert.Result.Data; var rpGet = proxy.RunAsync(x => x.GetDevice(identity)); rpGet.Wait(); Assert.True(rpInsert.Result.Data == rpGet.Result.Data.Id); //Update var tmpDto = rpGet.Result.Data; tmpDto.DeviceCode = "Name updated!"; var rpUpdate = proxy.RunAsync(x => x.UpdateDevice(tmpDto)); rpUpdate.Wait(); var rpUpdateGet = proxy.RunAsync(x => x.GetDevice(identity)); rpUpdateGet.Wait(); Assert.Equal(rpUpdateGet.Result.Data.DeviceCode, tmpDto.DeviceCode); //Delete var rpDelete = proxy.RunAsync(x => x.DeleteDevice(identity)); rpDelete.Wait(); var rpDeleteGet = proxy.RunAsync(x => x.GetDevice(identity)); rpDeleteGet.Wait(); Assert.True(rpDeleteGet.Result.Data == null); //List var queryDto = new DeviceDto { LastAccessDate = null }; var pagingDto = new PagingDto { pageSize = 3, pageNumber = 1 }; var rpList = proxy.RunAsync(x => x.ListDevice(queryDto, pagingDto));//List rpList.Wait(); Assert.True(rpList?.Result.Data != null && rpList.Result.Data.Any()); //assert //cleaup var rpHardDelete = proxy.RunAsync(x => x.DeleteHardDevice(identity)); }
public void DicoverNetwork_CRUD() { var proxy = new ProxyService <NetworkService>(new NetworkService(new ServiceContext())); var rp = proxy.RunAsync(x => x.DiscoverNetwork()); rp.Wait(); Assert.True(rp.Result.Data != null); }
static void Main(string[] args) { // 1- Simple call example // Application.Current.Build(); // var proxy1 = new ProxyService<TestService>(new TestService(new ServiceContext())); // var result1 = proxy1.Run(x => x.TestMethod1("test")); // System.Console.WriteLine(result1); // 2- Complex call example // var app = Application.Current; // // add services // app.AddService<LanguageService>("tr-TR"); // // use middwares // app.appBuilder.UseCache(); // Application.Current.Build(); // var proxy2 = new ProxyService<TestService>(new TestService(new ServiceContext())); // var result2 = proxy2.RunAsync(x => x.TestMethod2("test")); // System.Console.WriteLine(result2.Result.Data); // 3- More Complex call example var app2 = Application.Current; // add services app2.AddService <LanguageService>("tr-TR"); // use middwares app2.appBuilder.UseDatabaseContext(options => { options.DbProviderName = "System.Data.SQLite"; options.ReadConnectionString = "Data Source=D:/ws/Example/.config/Core.Service/CoreService.db;"; options.WriteConnectionString = "Data Source=D:/ws/Example/.config/Core.Service/CoreService.db;"; }); Application.Current.Build(); var proxy3 = new ProxyService <TestService>(new TestService(new ServiceContext())); UserDto userDto = new UserDto { Name = "Testd3452345", LastName = "Testd123452345", Age = 56, BirthDate = DateTime.Now }; var result3 = proxy3.RunAsync(x => x.InsertUser(userDto)); result3.Wait(); Console.WriteLine(result3.Result.Data); }
private async void goButton_Click(object sender, EventArgs e) { try { var text = decklistTextBox.Text; Cards = ProxyService.ParseImport(text); messageLabel.Text = "Running"; loadingBox.Visible = true; await ProxyService.RunAsync(Cards, SavePath); loadingBox.Visible = false; messageLabel.Text = "Finished"; messageLabel.ForeColor = Color.Green; } catch (Exception ex) { messageLabel.Text = $"Error"; messageLabel.ForeColor = Color.Red; loadingBox.Visible = false; MessageBox.Show($"Error: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Cards = null; } }
public void LoadDefautlData() { Console.ForegroundColor = ConsoleColor.Green; //load appsettings #region Setting log4net.ILog log = log4net.LogManager.GetLogger(typeof(LogMiddleware)); if (log.IsDebugEnabled) { log.Debug("Loading settings..."); } try { IEnumerable <SettingsDto> settingsDtoList = null; var proxy = new ProxyService <SystemService>(new SystemService(new ServiceContext())); Task <ServiceResponse <IEnumerable <SettingsDto> > > tSettings = proxy.RunAsync((x) => x.ListSettingsInternal()); tSettings.Wait(); settingsDtoList = tSettings.Result.Data; if (settingsDtoList == null) { throw new Exception("Settings not loaded!, check your database configurations!"); } foreach (SettingsDto _settings in settingsDtoList) { if (_settings?.Key != null && _settings.Val != null && !ConfigManager.Current.Configurations.ContainsKey(_settings.Key)) { ConfigManager.Current.Configurations[_settings.Key] = _settings.Val; } } if (log.IsDebugEnabled) { log.Debug($"Settings loaded. Count:{ConfigManager.Current.Configurations.Count}"); } } catch (Exception ex) { log.Error("Settings not loaded! service cannot started!, check your database connections.", ex); throw ex; } #endregion //load cache manager #region Language Cache try { var proxy = new ProxyService <SystemService>(new SystemService(new ServiceContext())); IEnumerable <LanguageDto> langDtoList = null; Task <ServiceResponse <IEnumerable <LanguageDto> > > tLang = proxy.RunAsync((x) => x.ListAllLanguage()); tLang.Wait(); langDtoList = tLang.Result.Data; var langService = Application.Current.GetService <LanguageService>(); foreach (LanguageDto lang in langDtoList) { object _value = lang.Val; if (!langService.Cache(lang.LanguageCode.ToUpper()).TryGetValue(lang.Key, out _value)) { langService.Cache(lang.LanguageCode.ToUpper())[lang.Key] = lang.Val; } } if (log.IsDebugEnabled) { log.Debug("Language cache loaded.."); } } catch (Exception ex) { log.Error("Settings not loaded! service cannot started!, check your database connections.", ex); throw ex; } #endregion Console.ResetColor(); }