Ejemplo n.º 1
0
        public Controller(string filename)  //テキストファイルから
        {
            if (File.Exists(filename) == true)
            {
                List <string> filedata = openTextfile(filename);
                (ConfigController conf, bool mig) = setConfig(filedata);

                if (conf == null)
                {
                    logOutput.writeLog("設定ファイルが記述されていません。");
                    this.conf = new ConfigController();
                }
                else
                {
                    this.conf = conf;
                }

                init();

                if (mig == true)
                {
                    migration();
                }
            }
            else
            {
                logOutput.writeLog("ファイルが存在しません。");

                conf = new ConfigController();
                init();
            }

            setNextGetTime();
            loop = startLoop();
        }
Ejemplo n.º 2
0
        public ConfigController()    //ファイル名から作成
        {
            if (ConfigController.existConfigFile() == true)
            {
                logOutput.writeLog("設定ファイルが見つかりました。");
                object obj;

                saveClass sClass = new saveClass();
                bool      result = XmlFileIO.xmlLoad(sClass.GetType(), filename, out obj);

                if (obj is saveClass)
                {
                    sClass = obj as saveClass;

                    this.username = sClass.username;
                    this.password = sClass.password;
                    this.db_name  = sClass.db_name;
                    this.address  = sClass.address;

                    if (sClass.db == POSTGRE)
                    {
                        chpDB = new PostgreSQL_Chp(this.address, this.db_name, this.username, this.password);
                        eveDB = new PostgreSQL_Emg(this.address, this.db_name, this.username, this.password);
                    }
                    else
                    {
                        chpDB = new PostgreSQL_Chp(this.address, this.db_name, this.username, this.password);
                        eveDB = new PostgreSQL_Emg(this.address, this.db_name, this.username, this.password);
                    }
                }
            }
            else
            {
                logOutput.writeLog("設定ファイルが見つかりません。初期設定をします。");

                Console.Write("Address:");
                this.address = Console.ReadLine();
                Console.Write("Database:");
                this.db_name = Console.ReadLine();
                Console.Write("username:"******"password:");
                this.password = Console.ReadLine();

                //とりあえずPostgreSQL
                chpDB = new PostgreSQL_Chp(this.address, this.db_name, this.username, this.password);
                eveDB = new PostgreSQL_Emg(this.address, this.db_name, this.username, this.password);

                saveFile();
            }
        }
Ejemplo n.º 3
0
        private (ConfigController cc, bool migration) setConfig(List <string> textfile)
        {
            string server   = "";
            string database = "";
            string user     = "";
            string password = "";
            bool   mig      = false;


            foreach (string s in textfile)
            {
                string[] sepalate = s.Split('=');

                switch (sepalate[0])
                {
                case "server":
                    server = sepalate[1];
                    break;

                case "database":
                    database = sepalate[1];
                    break;

                case "user":
                    user = sepalate[1];
                    break;

                case "password":
                    password = sepalate[1];
                    break;

                case "init":
                    if (sepalate[1] == "true" || sepalate[1] == "1" || sepalate[1] == "yes")
                    {
                        mig = true;
                    }
                    break;
                }
            }

            if (server != "" && database != "" && user != "" && password != "")
            {
                ConfigController output = new ConfigController(user, password, server, database, ConfigController.POSTGRE);
                return(output, mig);
            }
            else
            {
                return(null, mig);
            }
        }
Ejemplo n.º 4
0
        public Controller(ConfigController conf)
        {
            this.conf = conf;

            /*
             * http = new HttpClient();
             * emgGet = new AkiEmgGetter(http);
             * chpGet = new AkiChpGetter(http);
             *
             * emgWriter = new EmgDatabase_Writer(conf.eveDB);
             * chpWriter = new ChpDatabase_Writer(conf.chpDB);
             */
            init();
            setNextGetTime();
            loop = startLoop();
        }
Ejemplo n.º 5
0
        public Controller() //設定ファイルから(設定ファイルがない場合は作られる。)
        {
            conf = new ConfigController();

            /*
             * http = new HttpClient();
             * emgGet = new AkiEmgGetter(http);
             * chpGet = new AkiChpGetter(http);
             *
             * emgWriter = new EmgDatabase_Writer(conf.eveDB);
             * chpWriter = new ChpDatabase_Writer(conf.chpDB);
             */

            init();

            setNextGetTime();
            loop = startLoop();
        }