Ejemplo n.º 1
0
        private void Init()
        {
            this.dataMng = DBMngDataMng.getInstance();

            //DB 탭
            this.DbIPTB.Text       = this.dbIp;
            this.DbSidTB.Text      = this.dbSid;
            this.DbIdTB.Text       = this.dbId;
            this.DbPwTB.Text       = this.dbPw;
            this.Oracle8CB.Checked = this.db8i;

            //TCP 탭
            this.TcpIpTB.Text   = this.tcpIp;
            this.TcpPortTB.Text = this.tcpPort;

            if (this.tcpState)
            {
                this.TcpCloseBtn.Enabled   = true;
                this.TcpConBtn.Enabled     = false;
                this.Tcp1StateLB.ForeColor = Color.Blue;
                this.Tcp1StateLB.Text      = string.Format("Result : {0}", "Connect");
            }
            else
            {
                this.TcpConBtn.Enabled     = true;
                this.TcpCloseBtn.Enabled   = false;
                this.Tcp1StateLB.ForeColor = Color.Red;
                this.Tcp1StateLB.Text      = string.Format("Result  :  {0}", "Fail");
            }

            //UDP 탭
            this.UdpIpTB.Text   = this.udpIp;
            this.UdpPortTB.Text = this.udpPort;

            this.SaveBtn.Enabled = false;
            this.dbFLAG          = false;
            this.tcpFLAG         = false;
            this.udpFLAG         = false;
            this.logFLAG         = false;
        }
Ejemplo n.º 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");
            }
        }