示例#1
0
        /// <summary>
        /// NotifyIcon Context 메뉴 중 Exit 이벤트 (프로그램 강제 종료)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CMSToolStripMenuItem2_Click(object sender, EventArgs e)
        {
            this.clientSoc.UnInitTCPModClient(); //TCP 종료
            this.proc.Stop();                    //큐 스레드 종료
            this.procCountTD.Abort();            //큐 카운트 종료

            //종료 로그
            if (this.logState)
            {
                MTextLog.WriteTextLog(true, this.Text + " END");
            }

            foreach (Process proc in Process.GetProcesses())
            {
                if (proc.ProcessName.ToUpper().StartsWith("MEWSDBMANAGER"))
                {
                    proc.Kill();
                }
            }
        }
示例#2
0
        /// <summary>
        /// 초기화
        /// </summary>
        private void init()
        {
            //디렉토리가 있는지 체크..
            if (!Directory.Exists(this.IniFileDirectoryPath))
            {
                Directory.CreateDirectory(IniFileDirectoryPath);
            }

            //파일이 있는지 체크..없으면 파일 생성
            if (!File.Exists(IniFilePath))
            {
                AdengUtil.INIWriteValueString(this.setting, this.DBIP, "58.181.17.58", IniFilePath);
                AdengUtil.INIWriteValueString(this.setting, this.DBSID, "orcl", IniFilePath);
                AdengUtil.INIWriteValueString(this.setting, this.DBID, "mews33", IniFilePath);
                AdengUtil.INIWriteValueString(this.setting, this.DBPW, "mews", IniFilePath);
                AdengUtil.INIWriteValueString(this.setting, this.Oracle8i, "F", IniFilePath);
                AdengUtil.INIWriteValueString(this.setting, this.TCPIP, "127.0.0.1", IniFilePath);
                AdengUtil.INIWriteValueString(this.setting, this.TCPPort, "9009", IniFilePath);
                AdengUtil.INIWriteValueString(this.setting, this.LogFlag, "F", IniFilePath);
                AdengUtil.INIWriteValueString(this.setting, this.UDPIP, "127.0.0.1", IniFilePath);
                AdengUtil.INIWriteValueString(this.setting, this.UDPPort, "7001", IniFilePath);
            }

            //tcp client socket 생성
            this.clientSoc                  = TCPModClient.getTCPModClient();
            this.clientSoc.evConnected     += new TCPModClient.ConnectedHandler(clientSoc_evConnected);
            this.clientSoc.evConnectFailed += new TCPModClient.ConnectedFailedHandler(clientSoc_evConnectFailed);
            this.clientSoc.evDisconnected  += new TCPModClient.DisconnectedHandler(clientSoc_evDisconnected);
            this.clientSoc.evReceived      += new TCPModClient.ReceivedHandler(clientSoc_evReceived);
            this.clientSoc.evSendFailed    += new TCPModClient.SendFailedHandler(clientSoc_evSendFailed);
            this.clientSoc.evTimeout       += new TCPModClient.TimeOutHandler(clientSoc_evTimeout);

            //udp socket 생성
            try
            {
                this.udpSoc = new AdengUdpSocket(AdengUtil.INIReadValueString(this.setting, this.UDPIP, this.IniFilePath),
                                                 int.Parse(AdengUtil.INIReadValueString(this.setting, this.UDPPort, this.IniFilePath)));
                this.udpSoc.recvEvtHandler += new RecvEvtHandler(udpSoc_recvEvtHandler);
                this.SetLogListBox("UDP Success!");
            }
            catch (Exception ex)
            {
                this.SetLogListBox("UDP Fail!");
            }

            //data Manager 생성
            this.dataMng = DBMngDataMng.getInstance();
            this.dataMng.OnTermStateTCPSendEvt += new EventHandler <TermStateTCPSendEvtArgs>(dataMng_OnTermStateTCPSendEvt);

            //queue 생성
            this.insertQ = new Queue <PrtBase>();

            try
            {
                //로그 셋팅 값을 가져온다.
                this.logState = (AdengUtil.INIReadValueString(this.setting, this.LogFlag, IniFilePath) == "T" ? true : false);

                //TCP 연결
                this.localTcpIp   = AdengUtil.INIReadValueString(this.setting, this.TCPIP, this.IniFilePath);
                this.localTcpPort = int.Parse(AdengUtil.INIReadValueString(this.setting, this.TCPPort, this.IniFilePath));
                this.clientSoc.ConnectTo(this.localTcpIp, this.localTcpPort);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("MewsMain.init - " + ex.Message);
            }

            //폴링 데이터 처리
            PrtBase p9 = PrtMng.GetPrtObject(9);

            p9.MakeData();
            byte[] buff = PrtMng.MakeFrame(p9);
            this.clientSoc.BtPoll = buff;

            //기초데이터 로드 (단말)
            if (this.TryConnect())
            {
                if (this.dataMng.InitDataLoad())
                {
                    this.SetLogListBox("Init Data Load Success!");
                }
                else
                {
                    this.SetLogListBox("Init Data Load Fail (DB Read Fail!)");
                }
            }
            else
            {
                this.SetLogListBox("Init Data Load Fail (DB Connect Fail!)");
            }

            //처리한 큐 카운트를 라벨에 셋팅한다.
            this.procCountTD = new Thread(new ThreadStart(this.SetDataProcCnt));
            this.procCountTD.IsBackground = true;
            this.procCountTD.Start();

            //큐처리
            this.proc.runAsyncProcess += new InvokeValue(proc_runAsyncProcess);
            this.proc.Start();

            //프로그램 제목 최신 버전 표시
            this.Text += version1;

            //시작 로그
            if (this.logState)
            {
                MTextLog.WriteTextLog(true, this.Text + " START");
            }
        }