Ejemplo n.º 1
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            try
            {
                // 재실행 방지 코드
                bool  executeProc;
                Mutex mutex = new Mutex(true, Application.ProductName, out executeProc);

                if (!executeProc)
                {
                    //MessageBox.Show("방송 DMB송출 시스템이 이미 실행중입니다.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //this.Dispose();
                    //Application.Exit();
                    //return;
                }

                DmbBizActivator.Active(DmbDefineActivatorCode.ForProv);
                TcpProfileMng.LoadNavProfileConfig();
                TcpProfileMng.LoadSpProfileConfig();
                this.SetServerState(); //서버상태 부분

                this.logMng = new LogManager();
                this.logMng.Dir_Mng();

                DmbProtocolCmdP protoP = DmbProtocolFactory.CreateDmbProtocol(DmbDefineCmd.CmdP) as DmbProtocolCmdP;
                protoP.IP       = DMBBIZ.DmbUtility.DmbUtilityMng.IDmbEtcUtility.GetIPv4();
                this.forNaviSoc = new DmbNetSessionClientMng();
                this.forNaviSoc.PollingDatas = DmbProtocolFactory.MakeFrame(protoP);

                foreach (TcpProfileData eachTcpProfileData in TcpProfileMng.LstNavTcpProfileData)
                {
                    DmbProfile profileForDmb = new DmbProfile();
                    profileForDmb.IpAddr = eachTcpProfileData.IpAddr;
                    profileForDmb.Port   = eachTcpProfileData.Port;
                    profileForDmb.Name   = "ForNav";

                    this.forNaviSoc.AddProfile(profileForDmb);
                }

                this.forNaviSoc.ConnectNetSessionClient += new DmbNetSessionConnectEventHandler(forNaviSoc_ConnectNetSessionClient);
                this.forNaviSoc.RecvNetSessionClient    += new DmbNetSessionRecvEventHandler(forNaviSoc_RecvNetSessionClient);
                this.forNaviSoc.CloseNetSessionClient   += new DmbNetSessionCloseEventHandler(forNaviSoc_CloseNetSessionClient);

                this.forSpSoc = new DmbNetSessionClientMng();
                this.forSpSoc.PollingDatas = DmbProtocolFactory.MakeFrame(protoP);

                foreach (TcpProfileData eachTcpProfileData in TcpProfileMng.LstSpTcpProfileData)
                {
                    DmbProfile profileForWeb = new DmbProfile();
                    profileForWeb.IpAddr = eachTcpProfileData.IpAddr;
                    profileForWeb.Port   = eachTcpProfileData.Port;
                    profileForWeb.Name   = "ForSp";

                    this.forSpSoc.AddProfile(profileForWeb);
                }

                this.forSpSoc.ConnectNetSessionClient += new DmbNetSessionConnectEventHandler(forSpSoc_ConnectNetSessionClient);
                this.forSpSoc.RecvNetSessionClient    += new DmbNetSessionRecvEventHandler(forSpSoc_RecvNetSessionClient);
                this.forSpSoc.CloseNetSessionClient   += new DmbNetSessionCloseEventHandler(forSpSoc_CloseNetSessionClient);

                this.forNaviSoc.StartSessionClientMng();
                this.forSpSoc.StartSessionClientMng();

                this.datamanager = DataManager.getInstance();
                this.Text       += " " + DMBBIZ.DmbUtility.DmbUtilityMng.IDmbEtcUtility.GetVersionInfo();
                //this.Text += this.mainVersionStr;
                mainviewform = new MainViewForm();
                secession    = new Secession();
                recvmng      = RecvMng.getInstance();
                serialMng    = SerialMng.getInstance();
                tcpcheck     = new TcpCheck();

                mainviewform.MdiParent      = this;
                mainviewform.Dock           = DockStyle.Fill;
                MainToolStripButton.Checked = true;
                mainviewform.Show();

                this.tcpcheck.ConnectionCheckEvt += new TcpCheck.ConnectionCheckHandle(tcpcheck_ConnectionCheckEvt);
                this.tcpconnect(); //tcp통신연결 부분
            }
            catch (Exception ex)
            {
                Console.WriteLine("MainForm_Load - " + ex.Message);
            }
        }