Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="database"></param>
        private async Task <bool> InitAsync(string database)
        {
            if (System.IO.Path.IsPathRooted(database))
            {
                this.mDatabaseName = System.IO.Path.GetFileNameWithoutExtension(database);
                this.DatabasePath  = System.IO.Path.GetDirectoryName(database);
            }
            else
            {
                this.mDatabaseName = database;
            }
            InitPath();

            if (CheckDatabaseExist(mDatabaseName))
            {
                LoadDatabase();

                mHisFileManager = new DataFileManager(mDatabaseName);
                mHisFileManager.TagCountOneFile = mHisDatabase.Setting.TagCountOneFile;

                var task = mHisFileManager.Int();
                realEnginer = new RealEnginer(mRealDatabase);
                realEnginer.Init();

                hisEnginer = new HisEnginer(mHisDatabase, realEnginer);
                hisEnginer.MergeMemoryTime = mHisDatabase.Setting.DataBlockDuration * 60;
                hisEnginer.LogManager      = new LogManager()
                {
                    Database = mDatabaseName
                };
                hisEnginer.Init();

                compressEnginer = new CompressEnginer(hisEnginer.MegerMemorySize);
                compressEnginer.TagCountOneFile = mHisDatabase.Setting.TagCountOneFile;

                seriseEnginer = new SeriseEnginer()
                {
                    DatabaseName = database
                };
                seriseEnginer.FileDuration    = mHisDatabase.Setting.FileDataDuration;
                seriseEnginer.BlockDuration   = mHisDatabase.Setting.DataBlockDuration;
                seriseEnginer.TagCountOneFile = mHisDatabase.Setting.TagCountOneFile;
                seriseEnginer.DataSeriser     = mHisDatabase.Setting.DataSeriser;

                querySerivce = new QuerySerivce(this.mDatabaseName);

                RegistorInterface();

                DriverManager.Manager.Init(realEnginer);

                await task;

                return(true);
            }
            else
            {
                LoggerService.Service.Erro("Runner", string.Format(DBRuntime.Res.Get("databasenotexist"), mDatabaseName));
                return(false);
            }
        }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="database"></param>
        private async Task <bool> InitAsync(string database)
        {
            if (System.IO.Path.IsPathRooted(database))
            {
                this.mDatabaseName = System.IO.Path.GetFileNameWithoutExtension(database);
                //this.DatabasePath = System.IO.Path.GetDirectoryName(database);
            }
            else
            {
                this.mDatabaseName = database;
            }
            InitPath();

            if (CheckDatabaseExist(mDatabaseName))
            {
                LoadDatabase();

                mHisFileManager = new DataFileManager(mDatabaseName);
                mHisFileManager.TagCountOneFile    = mHisDatabase.Setting.TagCountOneFile;
                mHisFileManager.PrimaryHisDataPath = mHisDatabase.Setting.HisDataPathPrimary;
                mHisFileManager.BackHisDataPath    = mHisDatabase.Setting.HisDataPathBack;


                var task = mHisFileManager.Int();
                realEnginer = new RealEnginer(mRealDatabase);
                realEnginer.Init();
                ServiceLocator.Locator.Registor <IRealData>(realEnginer);
                ServiceLocator.Locator.Registor <IRealDataNotify>(realEnginer);
                ServiceLocator.Locator.Registor <IRealDataNotifyForProducter>(realEnginer);
                ServiceLocator.Locator.Registor <IRealTagConsumer>(realEnginer);
                ServiceLocator.Locator.Registor <IRealTagProduct>(realEnginer);

                ServiceLocator.Locator.Registor("DatabaseLocation", PathHelper.helper.GetDatabasePath(mDatabase.Name));

                hisEnginer = new HisEnginer3(mHisDatabase, realEnginer);
                hisEnginer.MergeMemoryTime = mHisDatabase.Setting.DataBlockDuration * 60;
                hisEnginer.LogManager      = new LogManager3()
                {
                    Database = mDatabaseName, Parent = hisEnginer
                };
                hisEnginer.Init();
                ServiceLocator.Locator.Registor <IHisEngine3>(hisEnginer);
                ServiceLocator.Locator.Registor <ITagHisValueProduct>(hisEnginer);

                //初始化从内存中查询数据的服务
                HisDataMemoryQueryService3.Service.HisEnginer = hisEnginer;
                ServiceLocator.Locator.Registor <IHisQueryFromMemory>(HisDataMemoryQueryService3.Service);


                compressEnginer = new CompressEnginer3();
                compressEnginer.TagCountOneFile = mHisDatabase.Setting.TagCountOneFile;
                compressEnginer.Init();
                ServiceLocator.Locator.Registor <IDataCompress3>(compressEnginer);

                seriseEnginer = new SeriseEnginer4()
                {
                    DatabaseName = database
                };
                seriseEnginer.FileDuration                  = mHisDatabase.Setting.FileDataDuration;
                seriseEnginer.BlockDuration                 = mHisDatabase.Setting.DataBlockDuration;
                seriseEnginer.TagCountOneFile               = mHisDatabase.Setting.TagCountOneFile;
                seriseEnginer.DataSeriser                   = mHisDatabase.Setting.DataSeriser;
                SeriseEnginer4.HisDataPathPrimary           = mHisDatabase.Setting.HisDataPathPrimary;
                SeriseEnginer4.HisDataPathBack              = mHisDatabase.Setting.HisDataPathBack;
                SeriseEnginer4.HisDataKeepTimeInPrimaryPath = mHisDatabase.Setting.HisDataKeepTimeInPrimaryPath;
                SeriseEnginer4.KeepNoZipFileDays            = mHisDatabase.Setting.KeepNoZipFileDays;
                seriseEnginer.Init();
                ServiceLocator.Locator.Registor <IDataSerialize3>(seriseEnginer);


                HisQueryManager.Instance.Registor(mDatabaseName, mHisFileManager);
                querySerivce = new QuerySerivce(this.mDatabaseName);

                mSecurityRunner = new SecurityRunner()
                {
                    Document = mDatabase.Security
                };

                RegistorInterface();

                DriverManager.Manager.Init(realEnginer, hisEnginer);

                HisQueryManager.Instance.StartMonitor();

                await task;

                return(true);
            }
            else
            {
                LoggerService.Service.Erro("Runner", string.Format(DBRuntime.Res.Get("databasenotexist"), mDatabaseName));
                return(false);
            }
        }