Example #1
0
        //�e�X�g�p�R���X�g���N�^(MailBox�̂ݏ�����)
        public Kernel(String option)
        {
            _isTest = true;
            DefaultInitialize(null, null, null, null);

            if (option.IndexOf("MailBox") != -1)
            {
                var op      = ListOption.Get("MailBox");
                var conf    = new Conf(op);
                var dir     = ReplaceOptionEnv((String)conf.Get("dir"));
                var datUser = (Dat)conf.Get("user");
                MailBox = new MailBox(null, datUser, dir);
            }
        }
Example #2
0
        //Conf�̐���
        //���O��ListOption���������������K�v������
        public Conf CreateConf(String nameTag)
        {
            if (ListOption == null)
            {
                Util.RuntimeException("createConf() ListOption==null");
                return(null);
            }
            var oneOption = ListOption.Get(nameTag);

            if (oneOption != null)
            {
                return(new Conf(oneOption));
            }
            return(null);
        }
Example #3
0
        //���j���[�I����̏���
        public void MenuOnClick(String cmd)
        {
            if (cmd.IndexOf("Option_") == 0)
            {
                if (RunMode == RunMode.Remote)
                {
                    //Java fix RunMOde==Remote�̏ꍇ�̃��j���[����
                    RemoteClient.MenuOnClick(cmd);
                }
                else
                {
                    var oneOption = ListOption.Get(cmd.Substring(7));
                    if (oneOption != null)
                    {
                        var dlg = new OptionDlg(this, oneOption);
                        if (DialogResult.OK == dlg.ShowDialog())
                        {
                            //Ver5.8.6 Java fix
                            //oneOption.Save(OptionIni.GetInstance());
                            oneOption.Save(IniDb);
                            MenuOnClick("StartStop_Reload");
                        }
                    }
                }
            }
            else if (cmd.IndexOf("Tool_") == 0)
            {
                if (RunMode == RunMode.Remote)
                {
                    //Java fix RunMOde==Remote�̏ꍇ�̃��j���[����
                    RemoteClient.MenuOnClick(cmd);
                }
                else
                {
                    var nameTag = cmd.Substring(5);
                    var oneTool = ListTool.Get(nameTag);
                    if (oneTool == null)
                    {
                        return;
                    }

                    //BJD.EXE�ȊO�̏ꍇ�A�T�[�o�I�u�W�F�N�g�ւ̃|�C���^���K�v�ɂȂ�
                    OneServer oneServer = null;
                    if (nameTag != "BJD")
                    {
                        oneServer = ListServer.Get(nameTag);
                        if (oneServer == null)
                        {
                            return;
                        }
                    }

                    ToolDlg dlg = oneTool.CreateDlg(oneServer);
                    dlg.ShowDialog();
                }
            }
            else if (cmd.IndexOf("StartStop_") == 0)
            {
                if (RunMode == RunMode.Remote)
                {
                    //Java fix RunMOde==Remote�̏ꍇ�̃��j���[����
                    RemoteClient.MenuOnClick(cmd);
                }
                else
                {
                    switch (cmd)
                    {
                    case "StartStop_Start":
                        Start();
                        break;

                    case "StartStop_Stop":
                        Stop();
                        break;

                    case "StartStop_Restart":
                        Stop();
                        Thread.Sleep(300);
                        Start();
                        break;

                    case "StartStop_Reload":
                        Stop();
                        ListInitialize();
                        Start();
                        break;

                    case "StartStop_Service":
                        SetupService();     //�T�[�r�X�̐ݒ�
                        break;

                    default:
                        Util.RuntimeException(string.Format("cmd={0}", cmd));
                        break;
                    }
                    View.SetColor();  //�E�C���h�̃J���[������
                    Menu.SetEnable(); //��Ԃɉ������L���E����
                }
            }
            else
            {
                switch (cmd)
                {
                case "File_LogClear":
                    LogView.Clear();
                    break;

                case "File_LogCopy":
                    LogView.SetClipboard();
                    break;

                case "File_Trace":
                    TraceDlg.Open();
                    break;

                case "File_Exit":
                    View.MainForm.Close();
                    break;

                case "Help_Version":
                    var dlg = new VersionDlg(this);
                    dlg.ShowDialog();
                    break;

                case "Help_Homepage":
                    Process.Start(Define.WebHome());
                    break;

                case "Help_Document":
                    Process.Start(Define.WebDocument());
                    break;

                case "Help_Support":
                    Process.Start(Define.WebSupport());
                    break;
                }
            }
        }
Example #4
0
        //�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();
        }
Example #5
0
        //�N�����ɁA�R���X�g���N�^����Ăяo����鏉����
        private void DefaultInitialize(MainForm mainForm, ListView listViewLog, MenuStrip menuStrip, NotifyIcon notifyIcon)
        {
            RunMode       = RunMode.Normal;
            RemoteConnect = null;//�����[�g����Őڑ�����Ă��鎞���������������

            //logger�����������܂ł̃��O��ꎞ�I�ɕۊǂ���
            //ArrayList<LogTemporary> tmpLogger = new ArrayList<>();

            //�v���Z�X�N�����ɏ����������
            View = new View(this, mainForm, listViewLog, notifyIcon);
            //logView = new LogView(listViewLog);
            LogView  = new LogView(this, listViewLog);
            Menu     = new Menu(this, menuStrip); //�����ł́A�I�u�W�F�N�g�̐����̂݁Amenu.Initialize()�́AlistInitialize()�̒��ŌĂяo�����
            DnsCache = new DnsCache();
            Wait     = new Wait();

            Ver = new Ver(); //�o�[�W�����Ǘ�

            //Java fix
            //RunMode�̏�����
            if (mainForm == null)
            {
                RunMode = RunMode.Service; //�T�[�r�X�N��
            }
            else
            {
                if (Environment.GetCommandLineArgs().Length > 1)
                {
                    RunMode = RunMode.Remote; //�����[�g�N���C�A���g
                }
                else
                {
                    //�T�[�r�X�o�^�̏�Ԃ�擾����
                    var setupService = new SetupService(this);
                    if (setupService.IsRegist)
                    {
                        RunMode = RunMode.NormalRegist; //�T�[�r�X�o�^�������
                    }
                }
            }

            //Ver5.8.6 Java fix
            //OptionIni.Create(this); //�C���X�^���X�̏�����

            IniDb = new IniDb(ProgDir(), (RunMode == RunMode.Remote) ? "$remote" : "Option");

            MailBox = null;

            ListInitialize(); //�T�[�o�ċN���ŁA�ēx���s����鏉����


            if (_isTest)
            {
                return;
            }

            //�E�C���h�T�C�Y�̕���
            var path = string.Format("{0}\\BJD.ini", ProgDir());

            try{
                //�E�C���h�E�̊O�ς�ۑ��E����(View���O�ɏ���������)
                WindowSize = new WindowSize(new Conf(ListOption.Get("Basic")), path);
                View.Read(WindowSize);
            } catch (IOException) {
                WindowSize = null;
                // �w�肳�ꂽWindow���ۑ��t�@�C��(BJD.ini)��IO�G���[���������Ă���
                _logger.Set(LogKind.Error, null, 9000022, path);
            }

            //TraceDlg = new TraceDlg(this, (mainForm != null) ? mainForm.getFrame() : null); //�g���[�X�\��
            TraceDlg = new TraceDlg(this); //�g���[�X�\��

            switch (RunMode)
            {
            case RunMode.Normal:
                MenuOnClick("StartStop_Start");     //���j���[�I��C�x���g
                break;

            case RunMode.Remote:
                RemoteClient = new RemoteClient(this);
                RemoteClient.Start();
                break;

            //Java fix Ver5.8.3
            case RunMode.NormalRegist:
            case RunMode.Service:
                break;

            default:
                Util.RuntimeException("Kernel.defaultInitialize() not implement (RunMode)");
                break;
            }

            //Java fix Ver5.8.3
            View.SetColor();//�E�C���h�F�̏�����
        }
Example #6
0
        //�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();
        }
Example #7
0
        //メニュー選択時の処理
        public void MenuOnClick(String cmd)
        {
            if (cmd.IndexOf("Option_") == 0)
            {
                if (RunMode == RunMode.Remote)
                {
                    //Java fix RunMOde==Remoteの場合のメニュー処理
                    RemoteClient.MenuOnClick(cmd);
                }
                else
                {
                    var oneOption = ListOption.Get(cmd.Substring(7));
                    if (oneOption != null)
                    {
                        var dlg = new OptionDlg(this, oneOption);
                        if (DialogResult.OK == dlg.ShowDialog())
                        {
                            //Ver5.8.6 Java fix
                            //oneOption.Save(OptionIni.GetInstance());
                            oneOption.Save(IniDb);
                            MenuOnClick("StartStop_Reload");
                        }
                    }
                }
            }
            else if (cmd.IndexOf("Tool_") == 0)
            {
                if (RunMode == RunMode.Remote)
                {
                    //Java fix RunMOde==Remoteの場合のメニュー処理
                    RemoteClient.MenuOnClick(cmd);
                }
                else
                {
                    var nameTag = cmd.Substring(5);
                    var oneTool = ListTool.Get(nameTag);
                    if (oneTool == null)
                    {
                        return;
                    }

                    //BJD.EXE以外の場合、サーバオブジェクトへのポインタが必要になる
                    OneServer oneServer = null;
                    if (nameTag != "BJD")
                    {
                        oneServer = ListServer.Get(nameTag);
                        if (oneServer == null)
                        {
                            return;
                        }
                    }

                    ToolDlg dlg = oneTool.CreateDlg(oneServer);
                    dlg.ShowDialog();
                }
            }
            else if (cmd.IndexOf("StartStop_") == 0)
            {
                if (RunMode == RunMode.Remote)
                {
                    //Java fix RunMOde==Remoteの場合のメニュー処理
                    RemoteClient.MenuOnClick(cmd);
                }
                else
                {
                    switch (cmd)
                    {
                    case "StartStop_Start":
                        Start();
                        break;

                    case "StartStop_Stop":
                        Stop();
                        break;

                    case "StartStop_Restart":
                        Stop();
                        Thread.Sleep(300);
                        Start();
                        break;

                    case "StartStop_Reload":
                        Stop();
                        ListInitialize();
                        Start();
                        break;

                    case "StartStop_Service":
                        SetupService();     //サービスの設定
                        break;

                    default:
                        Util.RuntimeException(string.Format("cmd={0}", cmd));
                        break;
                    }
                    View.SetColor();  //ウインドのカラー初期化
                    Menu.SetEnable(); //状態に応じた有効・無効
                }
            }
            else
            {
                switch (cmd)
                {
                case "File_LogClear":
                    LogView.Clear();
                    break;

                case "File_LogCopy":
                    LogView.SetClipboard();
                    break;

                case "File_Trace":
                    TraceDlg.Open();
                    break;

                case "File_Exit":
                    View.MainForm.Close();
                    break;

                case "Help_Version":
                    var dlg = new VersionDlg(this);
                    dlg.ShowDialog();
                    break;

                case "Help_Homepage":
                    Process.Start(Define.WebHome());
                    break;

                case "Help_Document":
                    Process.Start(Define.WebDocument());
                    break;

                case "Help_Support":
                    Process.Start(Define.WebSupport());
                    break;
                }
            }
        }
Example #8
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();
        }
Example #9
0
        //起動時に、コンストラクタから呼び出される初期化
        private void DefaultInitialize(MainForm mainForm, ListView listViewLog, MenuStrip menuStrip, NotifyIcon notifyIcon)
        {
            RunMode       = RunMode.Normal;
            RemoteConnect = null;//リモート制御で接続されている時だけ初期化される

            //loggerが生成されるまでのログを一時的に保管する
            //ArrayList<LogTemporary> tmpLogger = new ArrayList<>();

            //プロセス起動時に初期化される
            View = new View(this, mainForm, listViewLog, notifyIcon);
            //logView = new LogView(listViewLog);
            LogView  = new LogView(this, listViewLog);
            Menu     = new Menu(this, menuStrip); //ここでは、オブジェクトの生成のみ、menu.Initialize()は、listInitialize()の中で呼び出される
            DnsCache = new DnsCache();
            Wait     = new Wait();

            Ver = new Ver(); //バージョン管理

            //Java fix
            //RunModeの初期化
            if (mainForm == null)
            {
                RunMode = RunMode.Service; //サービス起動
            }
            else
            {
                if (Environment.GetCommandLineArgs().Length > 1)
                {
                    RunMode = RunMode.Remote; //リモートクライアント
                }
                else
                {
                    //サービス登録の状態を取得する
                    var setupService = new SetupService(this);
                    if (setupService.IsRegist)
                    {
                        RunMode = RunMode.NormalRegist; //サービス登録完了状態
                    }
                }
            }

            //Ver5.8.6 Java fix
            //OptionIni.Create(this); //インスタンスの初期化

            IniDb = new IniDb(ProgDir(), (RunMode == RunMode.Remote) ? "$remote" : "Option");

            MailBox = null;

            ListInitialize(); //サーバ再起動で、再度実行される初期化


            if (_isTest)
            {
                return;
            }

            //ウインドサイズの復元
            var path = string.Format("{0}\\BJD.ini", ProgDir());

            try
            {
                //ウインドウの外観を保存・復元(Viewより前に初期化する)
                WindowSize = new WindowSize(new Conf(ListOption.Get("Basic")), path);
                View.Read(WindowSize);
            }
            catch (IOException)
            {
                WindowSize = null;
                // 指定されたWindow情報保存ファイル(BJD.ini)にIOエラーが発生している
                _logger.Set(LogKind.Error, null, 9000022, path);
            }

            //TraceDlg = new TraceDlg(this, (mainForm != null) ? mainForm.getFrame() : null); //トレース表示
            TraceDlg = new TraceDlg(this); //トレース表示

            switch (RunMode)
            {
            case RunMode.Normal:
                MenuOnClick("StartStop_Start");     //メニュー選択イベント
                break;

            case RunMode.Remote:
                RemoteClient = new RemoteClient(this);
                RemoteClient.Start();
                break;

            //Java fix Ver5.8.3
            case RunMode.NormalRegist:
            case RunMode.Service:
                break;

            default:
                Util.RuntimeException("Kernel.defaultInitialize() not implement (RunMode)");
                break;
            }

            //Java fix Ver5.8.3
            View.SetColor();//ウインド色の初期化
        }