public async Task <IActionResult> InsertFast([FromServices] DataStorageService db)
        {
            var entry = CreateEntry();
            await db.Insert(entry);

            return(NoContent());
        }
Example #2
0
        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());
        }
Example #3
0
        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);
        }
Example #4
0
        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);
        }
Example #5
0
        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);
        }
Example #6
0
        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);
        }
Example #7
0
        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);
        }
Example #8
0
        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);
        }
Example #9
0
        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);
        }
Example #10
0
        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
        }
Example #11
0
        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);
        }
Example #12
0
        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);
        }
Example #13
0
        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);
        }
Example #14
0
        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);
        }
Example #15
0
        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);
        }
Example #16
0
        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
        }
Example #17
0
 public override IEnumerable <RoleModel> GetAll()
 {
     return(DataStorageService.GetAllRoles());
 }
Example #18
0
 public override bool Delete(int key)
 {
     return(DataStorageService.DeleteRole(key));
 }
Example #19
0
 public override RoleModel Update(RoleModel model)
 {
     return(DataStorageService.UpdateRole(model));
 }
Example #20
0
 public override RoleModel Create(RoleModel model)
 {
     return(DataStorageService.AddRole(model));
 }
Example #21
0
 public override RoleModel GetByKey(int key)
 {
     return(DataStorageService.FindRoleById(key));
 }
Example #22
0
 public override IEnumerable <ProductModel> GetAll()
 {
     return(DataStorageService.GetAllProducts());
 }
Example #23
0
 public override CategoryModel Create(CategoryModel model)
 {
     return(DataStorageService.AddCategory(model));
 }
Example #24
0
 public override bool Delete(int key)
 {
     return(DataStorageService.DeleteCategory(key));
 }
Example #25
0
 public override CategoryModel GetByKey(int key)
 {
     return(DataStorageService.FindCategoryById(key));
 }
Example #26
0
 public override ProductModel GetByKey(int key)
 {
     return(DataStorageService.FindProductById(key));
 }
Example #27
0
 public override CategoryModel Update(CategoryModel model)
 {
     return(DataStorageService.UpdateCategory(model));
 }
Example #28
0
 public override ProductModel Create(ProductModel model)
 {
     return(DataStorageService.AddProduct(model));
 }
Example #29
0
 public override IEnumerable <CategoryModel> GetAll()
 {
     return(DataStorageService.GetAllCategories());
 }
Example #30
0
 public override ProductModel Update(ProductModel model)
 {
     return(DataStorageService.UpdateProduct(model));
 }