Esempio n. 1
0
        private static void OnChanged(object source, FileSystemEventArgs e)
        {
            //ignore other files in parentDirectory
            //this will break if files are not named correctly
            if (e.Name.Contains("passwd"))
            {
                //rebuild tables if changes occured
                dataSet = new DataSet();
                DataTableBuilders.UpdateUserTable(dataSet, passwdFilePath);
            }
            else if (e.Name.Contains("group"))
            {
                //rebuild tables if changes occured
                dataSet = new DataSet();
                DataTableBuilders.UpdateGroupTable(dataSet, groupFilePath);
            }
            JObject jObject = new JObject();

            jObject.Add("File", $"{e.FullPath} {e.ChangeType}");
            changeLog.Add(jObject);
        }
Esempio n. 2
0
        public Startup(IConfiguration configuration)
        {
            //get app settings and configurations
            Configuration          = configuration;
            Program.groupFilePath  = Configuration.GetSection("AppConfiguration")["groupFilePath"];
            Program.passwdFilePath = Configuration.GetSection("AppConfiguration")["passwdFilePath"];

            if (File.Exists(Program.groupFilePath) && File.Exists(Program.passwdFilePath))
            {
                Program.dataSet = new System.Data.DataSet();

                //init tables/watcher on startup
                DataTableBuilders.UpdateUserTable(Program.dataSet, Program.passwdFilePath);
                DataTableBuilders.UpdateGroupTable(Program.dataSet, Program.groupFilePath);

                Program.groupWatcher = Program.watchFile(Program.groupFilePath);
                Program.userWatcher  = Program.watchFile(Program.passwdFilePath);
            }
            else
            {
                Program.errorStatus = PasswdErrors.PasswdError.FileNotFound;
            }
        }