public async Task <IActionResult> InsertFast([FromServices] DataStorageService db) { var entry = CreateEntry(); await db.Insert(entry); return(NoContent()); }
public void ChangeSettings(object sender, EventArgs args) { bool CurrentConnectionStatus = SignalRService.IsConnected; if (CurrentConnectionStatus) { SignalRService.CloseConnection(); } ConnectionSettings = ConnectionSettingsChanged; UserInfo = UserInfoChanged; IsActivated = IsActivatedChange; SignalRService.Settings = ConnectionSettings; SignalRService.UserInfo = UserInfo; if (CurrentConnectionStatus && IsActivated) { SignalRService.StartConnection(); } ConnectionService.Settings = ConnectionSettings; DataStorageService.StoreData(UserInfo, "UserInfo.json", this); DataStorageService.StoreData(ConnectionSettings, "ConnectionSettings.json", this); DataStorageService.StoreData(IsActivated, "IsActivated.json", this); Reciver.OnReceive(this, new Intent()); }
public bool DeleteRoleGroup(int id) { var script = string.Format("DELETE FROM [RoleGroup] WHERE Id = {0}", id); _dbConnector.ExecuteCommand(new SqlCommand(script)); DataStorageService.DeleteRoleGroupRole(id); return(true); }
public RoleGroupModel UpdateRoleGroup(RoleGroupModel model) { var script = string.Format("UPDATE [RoleGroup] SET RoleGroupName='{0}',Description = '{1}' WHERE Id ={2}", model.RoleGroupName, model.Description, model.Id); _dbConnector.ExecuteCommand(new SqlCommand(script)); DataStorageService.UpdateRoleGroupRole(model); return(model); }
public RoleGroupModel AddRoleGroup(RoleGroupModel model) { var script = string.Format("INSERT INTO [RoleGroup](RoleGroupName,Description) VALUES('{0}','{1}');SELECT @@IDENTITY;", model.RoleGroupName, model.Description); model.Id = _dbConnector.GetIntegerValue(new SqlCommand(script)); DataStorageService.AddRoleGroupRole(model); return(model); }
public bool UsageValidate(CategoryModel model) { var categoryUsed = DataStorageService.GetAllNews().Any(n => n.Category.Id.Equals(model.Id)); if (!categoryUsed) { categoryUsed = DataStorageService.GetAllProducts().Any(n => n.Category.Id.Equals(model.Id)); } return(!categoryUsed); }
public UserModel UpdateUser(UserModel model) { var script = string.Format("UPDATE [User] SET UserName='******',Password = '******' WHERE Id ={2}", model.UserName, model.Password, model.Id); _dbConnector.ExecuteCommand(new SqlCommand(script)); DataStorageService.UpdateUserRole(model); DataStorageService.UpdateUserRoleGroup(model); return(model); }
public UserModel AddUser(UserModel model) { var script = string.Format("INSERT INTO [User](UserName,Password) VALUES('{0}','{1}');SELECT @@IDENTITY;", model.UserName, model.Password); model.Id = _dbConnector.GetIntegerValue(new SqlCommand(script)); DataStorageService.AddUserRole(model); DataStorageService.AddUserRoleGroup(model); return(model); }
public UserModel GetUserByAuthenticate(string authentication) { var script = string.Format("SELECT [User].* FROM [User] INNER JOIN [UserAuthentication] ON [User].Id = [UserAuthentication].UserId WHERE [UserAuthentication].Authentication = '{0}'", authentication); var ds = _dbConnector.ExecuteCommandsDataSet(new SqlCommand(script)); var models = PopulateUser(ds); var model = models.Count == 1 ? models.First() : null; DataStorageService.AddUserRole(model); DataStorageService.AddUserRoleGroup(model); return(model); }
public VirtualHostList() : base() { InitializeComponent(); dataStorageService = new DataStorageService(); var filePath = dataStorageService.Read <string>(AppConst.filePathConfig).Replace("\"", ""); if (!string.IsNullOrEmpty(filePath)) { context = new VirtualHostContext(filePath); context.Read(); setItems(); } //var a = new GetDirectoryForm().ShowDialog(); //setup(); //creating new column }
public override StartCommandResult OnStartCommand(Intent intent, [GeneratedEnum] StartCommandFlags flags, int startId) { UserInfo = DataStorageService.LoadData <UserInfo>("UserInfo.json", this); if (UserInfo == null) { UserInfo = new UserInfo(); DataStorageService.StoreData(UserInfo, "UserInfo.json", this); } ConnectionSettings = DataStorageService.LoadData <ConnectionSettings>("ConnectionSettings.json", this); if (ConnectionSettings == null) { ConnectionSettings = new ConnectionSettings(); DataStorageService.StoreData(ConnectionSettings, "ConnectionSettings.json", this); } IsActivated = DataStorageService.LoadData <bool>("IsActivated.json", this); if (IsActivated == default(bool)) { IsActivated = false; DataStorageService.StoreData(IsActivated, "IsActivated.json", this); } SignalRService = new SignalRService(ConnectionSettings, UserInfo); ConnectionService = new ConnectionService(ConnectionSettings); UserInfoChanged = UserInfo; ConnectionSettingsChanged = ConnectionSettings; IsActivatedChange = IsActivated; Reciver = new NetworkStatusListener(); Reciver.CheckNetwork = ConnectionService.CheckNetwork; Reciver.RegisterOnNetwork = SignalRService.StartConnection; RegisterReceiver(Reciver, new IntentFilter(ConnectivityManager.ConnectivityAction)); return(StartCommandResult.Sticky); }
public static string VirualHostTemplateRead(this DataStorageService dataStorage, string fileName) { var result = dataStorage.Read <string>(fileName); if (string.IsNullOrEmpty(result)) { result = @"<VirtualHost *:80> ServerName localhost ServerAlias localhost ErrorLog ""logs/dummy-host.example.com-error.log"" CustomLog ""logs/dummy-host.example.com-access.log"" common DocumentRoot ""${INSTALL_DIR}/www"" < Directory ""${INSTALL_DIR}/www/"" > Options + Indexes + Includes + FollowSymLinks + MultiViews AllowOverride All Require local </ Directory > </ VirtualHost> "; } return(result); }
private IList <NewsModel> PopulateNews(DataSet ds) { var models = new List <NewsModel>(); if (ds != null) { foreach (DataRow rowItem in ds.Tables[0].Rows) { var model = new NewsModel(); model.Content = rowItem["Content"].ToString(); model.Id = int.Parse(rowItem["Id"].ToString()); model.Title = rowItem["Title"].ToString(); model.Category = DataStorageService.FindCategoryById(int.Parse(rowItem["CategoryId"].ToString())); model.DateCreated = DateTime.Parse(rowItem["DateCreated"].ToString()); model.DateUpdated = DateTime.Parse(rowItem["DateUpdated"].ToString()); models.Add(model); } } return(models); }
private IList <RoleGroupModel> PopulateRoleGroup(DataSet ds) { var models = new List <RoleGroupModel>(); if (ds != null) { foreach (DataRow rowItem in ds.Tables[0].Rows) { var model = new RoleGroupModel(); model.RoleGroupName = rowItem["RoleGroupName"].ToString(); model.Id = int.Parse(rowItem["Id"].ToString()); model.Description = rowItem["Description"].ToString(); model.DateCreated = DateTime.Parse(rowItem["DateCreated"].ToString()); model.DateUpdated = DateTime.Parse(rowItem["DateUpdated"].ToString()); model = DataStorageService.GetRoleGroupRole(model); models.Add(model); } } return(models); }
private IList <UserModel> PopulateUser(DataSet ds) { var models = new List <UserModel>(); if (ds != null) { foreach (DataRow rowItem in ds.Tables[0].Rows) { var model = new UserModel(); model.UserName = rowItem["UserName"].ToString(); model.Id = int.Parse(rowItem["Id"].ToString()); model.Password = rowItem["Password"].ToString(); model.DateCreated = DateTime.Parse(rowItem["DateCreated"].ToString()); model.DateUpdated = DateTime.Parse(rowItem["DateUpdated"].ToString()); model = DataStorageService.GetUserRoles(model); model = DataStorageService.GetUserRoleGroups(model); models.Add(model); } } return(models); }
public SettingForm() { InitializeComponent(); dataStorageService = new DataStorageService(); #region Init config column hostDataGridViewColumns = dataStorageService.Read <VirtualHostDataGridViewColumns>(AppConst.VirtualHostColumns); if (hostDataGridViewColumns == null) { hostDataGridViewColumns = new VirtualHostDataGridViewColumns() { Author = true, CreateAt = true, Description = true, Directory = true, ErrorLogs = true, Status = true, UpdateAt = true, Url = true, }; } var list = hostDataGridViewColumns.GetType() .GetProperties() .Select(x => new { Name = x.Name, Value = (bool)x.GetValue(hostDataGridViewColumns) }) .ToList(); list.ForEach(x => { checkedListBox1.Items.Add(x.Name); checkedListBox1.SetItemChecked(checkedListBox1.Items.Count - 1, x.Value); }); #endregion #region Init virtual host template virtualHostTemplateTxt.Text = dataStorageService.VirualHostTemplateRead(AppConst.VirtualHostTemplate); #endregion }
public override IEnumerable <RoleModel> GetAll() { return(DataStorageService.GetAllRoles()); }
public override bool Delete(int key) { return(DataStorageService.DeleteRole(key)); }
public override RoleModel Update(RoleModel model) { return(DataStorageService.UpdateRole(model)); }
public override RoleModel Create(RoleModel model) { return(DataStorageService.AddRole(model)); }
public override RoleModel GetByKey(int key) { return(DataStorageService.FindRoleById(key)); }
public override IEnumerable <ProductModel> GetAll() { return(DataStorageService.GetAllProducts()); }
public override CategoryModel Create(CategoryModel model) { return(DataStorageService.AddCategory(model)); }
public override bool Delete(int key) { return(DataStorageService.DeleteCategory(key)); }
public override CategoryModel GetByKey(int key) { return(DataStorageService.FindCategoryById(key)); }
public override ProductModel GetByKey(int key) { return(DataStorageService.FindProductById(key)); }
public override CategoryModel Update(CategoryModel model) { return(DataStorageService.UpdateCategory(model)); }
public override ProductModel Create(ProductModel model) { return(DataStorageService.AddProduct(model)); }
public override IEnumerable <CategoryModel> GetAll() { return(DataStorageService.GetAllCategories()); }
public override ProductModel Update(ProductModel model) { return(DataStorageService.UpdateProduct(model)); }