Esempio n. 1
0
        public static void Configure()
        {
            if (!_hasConfigure)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.ApplicationExit += (sender, e) =>
                {
                    //foreach (var dbChild in _dbChildContainer)
                    //{
                    //    if (dbChild.Value != null)
                    //    {
                    //        dbChild.Value.Dispose();
                    //    }
                    //}

                    //_dbChildContainer.Clear();
                    //_dbChildContainer = null;
                };

                // Config DB
                SQLiteManager.CreateDatabaseIfNotExists(_pathDB);
                using (var objDB = AppManager.GetConnection())
                {
                    var defValues = GetDefaultSetting();
                    objDB.SetDefaultValues(defValues);
                }
                using (var objDB = AppManager.GetConnection())
                {
                    ListBlock  = objDB.GetListBlock();
                    ListSensor = objDB.GetListSensor();
                }

                ListSensor.Select((sensor) => {
                    var pathDBSensor = PathFolderData + DBManagerChild.GetDBName(sensor.SensorId);
                    SQLiteManager.CreateDatabaseIfNotExists2(pathDBSensor);
                    GetDBChildConnection(DBManagerChild.GetDBName(sensor.SensorId));
                    return(sensor);
                }).ToList();

                //foreach (var sensor in ListSensor)
                //{
                //    var pathDBSensor = PathFolderData + DBManagerChild.GetDBName(sensor.SensorId);
                //    SQLiteManager.CreateDatabaseIfNotExists2(pathDBSensor);
                //    GetDBChildConnection(DBManagerChild.GetDBName(sensor.SensorId));
                //}

                // Config Log

                // Config Language
                LanguageHelper.LoadConfigDefaultLanguage();

                _hasConfigure = true;
            }
        }