示例#1
0
文件: Kernel.cs 项目: jsakamoto/bjd5
        //�T�[�o�ċN���ŁA�ēx���s����鏉����
        public void ListInitialize()
        {
            //Logger���g�p�ł��Ȃ��Ԃ̃��O�́A������ɕۑ����āA���Logger�ɑ���
            var tmpLogger = new TmpLogger();

            //************************************************************
            // �j��
            //************************************************************
            if (ListOption != null){
                ListOption.Dispose();
                ListOption = null;
            }
            //Java fix
            if (ListTool != null){
                ListTool.Dispose();
                ListTool = null;
            }
            if (ListServer != null){
                ListServer.Dispose();
                ListServer = null;
            }
            if (MailBox != null){
                MailBox = null;
            }
            if (LogFile != null){
                LogFile.Dispose();
                LogFile = null;
            }

            //************************************************************
            // ������
            //************************************************************
            //ListPlugin �́BListOption��ListServer�����������Ԃ�����������
            //isTest=true�̏ꍇ�A�p�X��""�ɂ��āA�v���O�C��0�‚ŏ�������������

            //ListPlugin listPlugin = new ListPlugin((isTest) ? "" : string.Format("%s\\plugins", getProgDir()));
            var listPlugin = new ListPlugin(ProgDir());
            foreach (var o in listPlugin){
                //�����[�g�N���C�A���g�̏ꍇ�A���̃��O�́A��₱�����̂ŕ\�����Ȃ�
                if (RunMode == RunMode.Normal){
                    tmpLogger.Set(LogKind.Detail, null, 9000008, string.Format("{0}Server", o.Name));
                }
            }

            //ListOption�Ŋe�I�v�V���������������O�ɁAisJp�����͏��������Ă����K�v������̂�
            //�ŏ���OptionBasic��lang������ǂݏo��
            //Ver5.8.6 Java fix
            //_isJp = OptionIni.GetInstance().IsJp();
            _isJp = IniDb.IsJp();

            ListOption = new ListOption(this, listPlugin);

            //Ver5.9.1
            //���߂Ă�����ʉ߂���Ƃ��A�ߋ��̃o�[�W������Option��ǂݍ��ނ�
            //���I�v�V�����̓I�u�W�F�N�g�̒���OneOption�ɂ̂ݕێ������
            //���̏�ԂŁA�����̃I�v�V�����w���OK����ƁA���̃I�v�V�����ȊO��
            //Option.ini�ɕۑ�����Ȃ����ߔj������Ă��܂�
            //���̖��ɑΏ����邽�߁A�����ň�x�AOption.ini��ۑ����邱�Ƃɂ���
            if (!_isTest){
                ListOption.Save(IniDb);
            }

            //OptionBasic
            var confBasic = new Conf(ListOption.Get("Basic"));
            EditBrowse = (bool) confBasic.Get("editBrowse");

            //OptionLog
            var confOption = new Conf(ListOption.Get("Log"));
            LogView.SetFont((Font) confOption.Get("font"));

            if (RunMode == RunMode.Normal || RunMode == RunMode.Service){
                //LogFile�̏�����
                var saveDirectory = (String) confOption.Get("saveDirectory");
                saveDirectory = ReplaceOptionEnv(saveDirectory);
                var normalLogKind = (int) confOption.Get("normalLogKind");
                var secureLogKind = (int) confOption.Get("secureLogKind");
                var saveDays = (int) confOption.Get("saveDays");
                //Ver6.0.7
                var useLogFile = (bool)confOption.Get("useLogFile");
                var useLogClear = (bool) confOption.Get("useLogClear");
                if (!useLogClear){
                    saveDays = 0; //���O�̎����폜�������ȏꍇ�AsaveDays��0��Z�b�g����
                }
                if (saveDirectory == ""){
                    tmpLogger.Set(LogKind.Error, null, 9000045, "It is not appointed");
                } else{
                    tmpLogger.Set(LogKind.Detail, null, 9000032, saveDirectory);
                    try{
                        LogFile = new LogFile(saveDirectory, normalLogKind, secureLogKind, saveDays,useLogFile);
                    } catch (IOException e){
                        LogFile = null;
                        tmpLogger.Set(LogKind.Error, null, 9000031, e.Message);
                    }
                }

                //Ver5.8.7 Java fix
                //mailBox������
                foreach (var o in ListOption) {
                    //SmtpServer�Ⴕ���́APop3Server���g�p�����ꍇ�̂݃��[���{�b�N�X�����������
                    if (o.NameTag == "Smtp" || o.NameTag == "Pop3") {
                        if (o.UseServer) {
                            var conf = new Conf(ListOption.Get("MailBox"));
                            var dir = ReplaceOptionEnv((String) conf.Get("dir"));
                            var datUser = (Dat) conf.Get("user");
                            var logger = CreateLogger("MailBox", (bool)conf.Get("useDetailsLog"), null);
                            MailBox = new MailBox(logger,datUser, dir);
                            break;
                        }
                    }
                }

            }
            _logger = CreateLogger("kernel", true, null);
            tmpLogger.Release(_logger);

            //Ver5.8.7 Java fix �����[�g�N���C�A���g�̏ꍇ����[���{�b�N�X��쐬���Ă��܂��o�O��C��
            //            //mailBox������
            //            foreach (var o in ListOption){
            //                //SmtpServer�Ⴕ���́APop3Server���g�p�����ꍇ�̂݃��[���{�b�N�X�����������
            //                if (o.NameTag == "Smtp" || o.NameTag == "Pop3"){
            //                    if (o.UseServer){
            //                        var conf = new Conf(ListOption.Get("MailBox"));
            //                        MailBox = new MailBox(this, conf);
            //                        break;
            //                    }
            //                }
            //            }

            ListServer = new ListServer(this, listPlugin);

            ListTool = new ListTool();
            ListTool.Initialize(this);

            View.SetColumnText(); //Log�r���[�̃J�����e�L�X�g�̏�����
            Menu.Initialize(IsJp()); //���j���[�\�z�i����e�[�u���̏������j

            WebApi = new WebApi();
        }
示例#2
0
文件: Kernel.cs 项目: schifflee/bjd5
        //�T�[�o�ċN���ŁA�ēx���s����鏉����
        public void ListInitialize()
        {
            //Logger���g�p�ł��Ȃ��Ԃ̃��O�́A������ɕۑ����āA���Logger�ɑ���
            var tmpLogger = new TmpLogger();

            //************************************************************
            // �j��
            //************************************************************
            if (ListOption != null)
            {
                ListOption.Dispose();
                ListOption = null;
            }
            //Java fix
            if (ListTool != null)
            {
                ListTool.Dispose();
                ListTool = null;
            }
            if (ListServer != null)
            {
                ListServer.Dispose();
                ListServer = null;
            }
            if (MailBox != null)
            {
                MailBox = null;
            }
            if (LogFile != null)
            {
                LogFile.Dispose();
                LogFile = null;
            }

            //************************************************************
            // ������
            //************************************************************
            //ListPlugin �́BListOption��ListServer�����������Ԃ�����������
            //isTest=true�̏ꍇ�A�p�X��""�ɂ��āA�v���O�C��0�‚ŏ�������������

            //ListPlugin listPlugin = new ListPlugin((isTest) ? "" : string.Format("%s\\plugins", getProgDir()));
            var listPlugin = new ListPlugin(ProgDir());

            foreach (var o in listPlugin)
            {
                //�����[�g�N���C�A���g�̏ꍇ�A���̃��O�́A��₱�����̂ŕ\�����Ȃ�
                if (RunMode == RunMode.Normal)
                {
                    tmpLogger.Set(LogKind.Detail, null, 9000008, string.Format("{0}Server", o.Name));
                }
            }

            //ListOption�Ŋe�I�v�V���������������O�ɁAisJp�����͏��������Ă����K�v������̂�
            //�ŏ���OptionBasic��lang������ǂݏo��
            //Ver5.8.6 Java fix
            //_isJp = OptionIni.GetInstance().IsJp();
            _isJp = IniDb.IsJp();

            ListOption = new ListOption(this, listPlugin);

            //Ver5.9.1
            //���߂Ă�����ʉ߂���Ƃ��A�ߋ��̃o�[�W������Option��ǂݍ��ނ�
            //���I�v�V�����̓I�u�W�F�N�g�̒���OneOption�ɂ̂ݕێ������
            //���̏�ԂŁA�����̃I�v�V�����w���OK����ƁA���̃I�v�V�����ȊO��
            //Option.ini�ɕۑ�����Ȃ����ߔj������Ă��܂�
            //���̖��ɑΏ����邽�߁A�����ň�x�AOption.ini��ۑ����邱�Ƃɂ���
            if (!_isTest)
            {
                ListOption.Save(IniDb);
            }


            //OptionBasic
            var confBasic = new Conf(ListOption.Get("Basic"));

            EditBrowse = (bool)confBasic.Get("editBrowse");

            //OptionLog
            var confOption = new Conf(ListOption.Get("Log"));

            LogView.SetFont((Font)confOption.Get("font"));

            if (RunMode == RunMode.Normal || RunMode == RunMode.Service)
            {
                //LogFile�̏�����
                var saveDirectory = (String)confOption.Get("saveDirectory");
                saveDirectory = ReplaceOptionEnv(saveDirectory);
                var normalLogKind = (int)confOption.Get("normalLogKind");
                var secureLogKind = (int)confOption.Get("secureLogKind");
                var saveDays      = (int)confOption.Get("saveDays");
                //Ver6.0.7
                var useLogFile  = (bool)confOption.Get("useLogFile");
                var useLogClear = (bool)confOption.Get("useLogClear");
                if (!useLogClear)
                {
                    saveDays = 0; //���O�̎����폜�������ȏꍇ�AsaveDays��0��Z�b�g����
                }
                if (saveDirectory == "")
                {
                    tmpLogger.Set(LogKind.Error, null, 9000045, "It is not appointed");
                }
                else
                {
                    tmpLogger.Set(LogKind.Detail, null, 9000032, saveDirectory);
                    try{
                        LogFile = new LogFile(saveDirectory, normalLogKind, secureLogKind, saveDays, useLogFile);
                    } catch (IOException e) {
                        LogFile = null;
                        tmpLogger.Set(LogKind.Error, null, 9000031, e.Message);
                    }
                }

                //Ver5.8.7 Java fix
                //mailBox������
                foreach (var o in ListOption)
                {
                    //SmtpServer�Ⴕ���́APop3Server���g�p�����ꍇ�̂݃��[���{�b�N�X�����������
                    if (o.NameTag == "Smtp" || o.NameTag == "Pop3")
                    {
                        if (o.UseServer)
                        {
                            var conf    = new Conf(ListOption.Get("MailBox"));
                            var dir     = ReplaceOptionEnv((String)conf.Get("dir"));
                            var datUser = (Dat)conf.Get("user");
                            var logger  = CreateLogger("MailBox", (bool)conf.Get("useDetailsLog"), null);
                            MailBox = new MailBox(logger, datUser, dir);
                            break;
                        }
                    }
                }
            }
            _logger = CreateLogger("kernel", true, null);
            tmpLogger.Release(_logger);


            //Ver5.8.7 Java fix �����[�g�N���C�A���g�̏ꍇ����[���{�b�N�X��쐬���Ă��܂��o�O��C��
//            //mailBox������
//            foreach (var o in ListOption){
//                //SmtpServer�Ⴕ���́APop3Server���g�p�����ꍇ�̂݃��[���{�b�N�X�����������
//                if (o.NameTag == "Smtp" || o.NameTag == "Pop3"){
//                    if (o.UseServer){
//                        var conf = new Conf(ListOption.Get("MailBox"));
//                        MailBox = new MailBox(this, conf);
//                        break;
//                    }
//                }
//            }

            ListServer = new ListServer(this, listPlugin);

            ListTool = new ListTool();
            ListTool.Initialize(this);

            View.SetColumnText();    //Log�r���[�̃J�����e�L�X�g�̏�����
            Menu.Initialize(IsJp()); //���j���[�\�z�i����e�[�u���̏������j

            WebApi = new WebApi();
        }
示例#3
0
        //サーバ再起動で、再度実行される初期化
        public void ListInitialize()
        {
            //Loggerが使用できない間のログは、こちらに保存して、後でLoggerに送る
            var tmpLogger = new TmpLogger();

            //************************************************************
            // 破棄
            //************************************************************
            if (ListOption != null)
            {
                ListOption.Dispose();
                ListOption = null;
            }
            //Java fix
            if (ListTool != null)
            {
                ListTool.Dispose();
                ListTool = null;
            }
            if (ListServer != null)
            {
                ListServer.Dispose();
                ListServer = null;
            }
            if (MailBox != null)
            {
                MailBox = null;
            }
            if (LogFile != null)
            {
                LogFile.Dispose();
                LogFile = null;
            }

            //************************************************************
            // 初期化
            //************************************************************
            //ListPlugin は。ListOptionとListServerを初期化する間だけ生存する
            //isTest=trueの場合、パスを""にして、プラグイン0個で初期化さあせる

            //ListPlugin listPlugin = new ListPlugin((isTest) ? "" : string.Format("%s\\plugins", getProgDir()));
            var listPlugin = new ListPlugin(ProgDir());

            foreach (var o in listPlugin)
            {
                //リモートクライアントの場合、このログは、ややこしいので表示しない
                if (RunMode == RunMode.Normal)
                {
                    tmpLogger.Set(LogKind.Detail, null, 9000008, string.Format("{0}Server", o.Name));
                }
            }

            //ListOptionで各オプションを初期化する前に、isJpだけは初期化しておく必要があるので
            //最初にOptionBasicのlangだけを読み出す
            //Ver5.8.6 Java fix
            //_isJp = OptionIni.GetInstance().IsJp();
            _isJp = IniDb.IsJp();

            ListOption = new ListOption(this, listPlugin);

            //Ver5.9.1
            //初めてここを通過するとき、過去のバージョンのOptionを読み込むと
            //旧オプションはオブジェクトの中のOneOptionにのみ保持される
            //この状態で、何かのオプション指定でOKすると、そのオプション以外が
            //Option.iniに保存されないため破棄されてしまう
            //この問題に対処するため、ここで一度、Option.iniを保存することにする
            if (!_isTest)
            {
                ListOption.Save(IniDb);
            }


            //OptionBasic
            var confBasic = new Conf(ListOption.Get("Basic"));

            EditBrowse = (bool)confBasic.Get("editBrowse");

            //OptionLog
            var confOption = new Conf(ListOption.Get("Log"));

            LogView.SetFont((Font)confOption.Get("font"));

            if (RunMode == RunMode.Normal || RunMode == RunMode.Service)
            {
                //LogFileの初期化
                var saveDirectory = (String)confOption.Get("saveDirectory");
                saveDirectory = ReplaceOptionEnv(saveDirectory);
                var normalLogKind = (int)confOption.Get("normalLogKind");
                var secureLogKind = (int)confOption.Get("secureLogKind");
                var saveDays      = (int)confOption.Get("saveDays");
                //Ver6.0.7
                var useLogFile  = (bool)confOption.Get("useLogFile");
                var useLogClear = (bool)confOption.Get("useLogClear");
                if (!useLogClear)
                {
                    saveDays = 0; //ログの自動削除が無効な場合、saveDaysに0をセットする
                }
                if (saveDirectory == "")
                {
                    tmpLogger.Set(LogKind.Error, null, 9000045, "It is not appointed");
                }
                else
                {
                    tmpLogger.Set(LogKind.Detail, null, 9000032, saveDirectory);
                    try
                    {
                        LogFile = new LogFile(saveDirectory, normalLogKind, secureLogKind, saveDays, useLogFile);
                    }
                    catch (IOException e)
                    {
                        LogFile = null;
                        tmpLogger.Set(LogKind.Error, null, 9000031, e.Message);
                    }
                }

                //Ver5.8.7 Java fix
                //mailBox初期化
                foreach (var o in ListOption)
                {
                    //SmtpServer若しくは、Pop3Serverが使用される場合のみメールボックスを初期化する
                    if (o.NameTag == "Smtp" || o.NameTag == "Pop3")
                    {
                        if (o.UseServer)
                        {
                            var conf    = new Conf(ListOption.Get("MailBox"));
                            var dir     = ReplaceOptionEnv((String)conf.Get("dir"));
                            var datUser = (Dat)conf.Get("user");
                            var logger  = CreateLogger("MailBox", (bool)conf.Get("useDetailsLog"), null);
                            MailBox = new MailBox(logger, datUser, dir);
                            break;
                        }
                    }
                }
            }
            _logger = CreateLogger("kernel", true, null);
            tmpLogger.Release(_logger);


            //Ver5.8.7 Java fix リモートクライアントの場合もメールボックスを作成してしまうバグを修正
            //            //mailBox初期化
            //            foreach (var o in ListOption){
            //                //SmtpServer若しくは、Pop3Serverが使用される場合のみメールボックスを初期化する
            //                if (o.NameTag == "Smtp" || o.NameTag == "Pop3"){
            //                    if (o.UseServer){
            //                        var conf = new Conf(ListOption.Get("MailBox"));
            //                        MailBox = new MailBox(this, conf);
            //                        break;
            //                    }
            //                }
            //            }

            ListServer = new ListServer(this, listPlugin);

            ListTool = new ListTool();
            ListTool.Initialize(this);

            View.SetColumnText();    //Logビューのカラムテキストの初期化
            Menu.Initialize(IsJp()); //メニュー構築(内部テーブルの初期化)

            WebApi = new WebApi();
        }