/// <summary> /// 저장 버튼 클릭 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SaveBtn_Click(object sender, EventArgs e) { if (this.SaveValidation()) { AdengUtil.INIWriteValueString(this.setting, this.portNum, this.ComPortCB.Text, IniFilePath); AdengUtil.INIWriteValueString(this.setting, this.baudRate, this.BaudRateCB.Text, IniFilePath); AdengUtil.INIWriteValueString(this.setting, this.dataBits, this.DataBitsCB.Text, IniFilePath); AdengUtil.INIWriteValueString(this.setting, this.stopBit, this.StopBitCB.Text, IniFilePath); AdengUtil.INIWriteValueString(this.setting, this.udpIp, this.UdpIpTB.Text, IniFilePath); AdengUtil.INIWriteValueString(this.setting, this.udpPort, this.UdpPortTB.Text, IniFilePath); AdengUtil.INIWriteValueString(this.setting, this.tcpIp, this.TcpIpTB.Text, IniFilePath); AdengUtil.INIWriteValueString(this.setting, this.tcpPort, this.TcpPortTB.Text, IniFilePath); AdengUtil.INIWriteValueString(this.setting, this.tcpSvrIp, this.TcpSvrIpTB.Text, IniFilePath); AdengUtil.INIWriteValueString(this.setting, this.tcpSvrPort, this.TcpSvrPortTB.Text, IniFilePath); string tmpStr = (this.ParityCB.Text == "홀수") ? "2" : (this.ParityCB.Text == "짝수") ? "1" : "0"; AdengUtil.INIWriteValueString(this.setting, this.parity, tmpStr, IniFilePath); this.SaveBtn.Enabled = false; } else { MessageBox.Show("정보를 확인하세요.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// 환경 설정창에서 발생하는 TCP 셋팅 값 변경 이벤트 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void optionForm_OnTcpSettingEvt(object sender, TcpSettingEventArgs e) { AdengUtil.INIWriteValueString(this.setting, this.TCPIP, e.Ip, this.IniFilePath); AdengUtil.INIWriteValueString(this.setting, this.TCPPort, e.Port, this.IniFilePath); this.localTcpIp = e.Ip; this.localTcpPort = int.Parse(e.Port); //바뀐 설정값으로 재연결 this.clientSoc.Disconnect(); this.clientSoc.ConnectTo(this.localTcpIp, this.localTcpPort); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (AdengUtil.CheckAppOverlap("MewsDBManager")) { MessageBox.Show("The program is already running.", "EDWS DB Manager", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Dispose(true); } this.init(); }
/// <summary> /// 환경 설정창에서 발생하는 Log 셋팅 값 변경 이벤트 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void optionForm_OnLogSettingEvt(object sender, LogSettingEventArgs e) { if (e.State) { AdengUtil.INIWriteValueString(this.setting, this.LogFlag, "T", this.IniFilePath); this.logState = true; } else { AdengUtil.INIWriteValueString(this.setting, this.LogFlag, "F", this.IniFilePath); this.logState = false; } }
public void setBtnColor(byte _kind) { mode = _kind; this.btnMic.BackColor = Color.Black; this.btnRec.BackColor = Color.Black; if (AdengUtil.INIReadValueString(this.setting, "siren1", this.IniFilePath) != string.Empty) { msgTime[0] = AdengUtil.INIReadValueString(this.setting, "siren1", this.IniFilePath); } if (AdengUtil.INIReadValueString(this.setting, "siren2", this.IniFilePath) != string.Empty) { msgTime[1] = AdengUtil.INIReadValueString(this.setting, "siren2", this.IniFilePath); } }
/// <summary> /// 환경 설정창에서 발생하는 DB 셋팅 값 변경 이벤트 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void optionForm_OnDbSettingDataEvt(object sender, DbSettingDataEvtArgs e) { AdengUtil.INIWriteValueString(this.setting, this.DBIP, e.DbIp, this.IniFilePath); AdengUtil.INIWriteValueString(this.setting, this.DBSID, e.DbSid, this.IniFilePath); AdengUtil.INIWriteValueString(this.setting, this.DBID, e.DbId, this.IniFilePath); AdengUtil.INIWriteValueString(this.setting, this.DBPW, e.DbPw, this.IniFilePath); if (e.Oracle8) { AdengUtil.INIWriteValueString(this.setting, this.Oracle8i, "T", this.IniFilePath); } else { AdengUtil.INIWriteValueString(this.setting, this.Oracle8i, "F", this.IniFilePath); } }
/// <summary> /// 데이터 초기화 /// </summary> private void init() { this.ComPortCB.Text = AdengUtil.INIReadValueString(this.setting, this.portNum, this.IniFilePath); this.BaudRateCB.Text = AdengUtil.INIReadValueString(this.setting, this.baudRate, this.IniFilePath); this.DataBitsCB.Text = AdengUtil.INIReadValueString(this.setting, this.dataBits, this.IniFilePath); string p = AdengUtil.INIReadValueString(this.setting, this.parity, this.IniFilePath); this.StopBitCB.Text = AdengUtil.INIReadValueString(this.setting, this.stopBit, this.IniFilePath); this.UdpIpTB.Text = AdengUtil.INIReadValueString(this.setting, this.udpIp, this.IniFilePath); this.UdpPortTB.Text = AdengUtil.INIReadValueString(this.setting, this.udpPort, this.IniFilePath); this.TcpIpTB.Text = AdengUtil.INIReadValueString(this.setting, this.tcpIp, this.IniFilePath); this.TcpPortTB.Text = AdengUtil.INIReadValueString(this.setting, this.tcpPort, this.IniFilePath); this.TcpSvrIpTB.Text = AdengUtil.INIReadValueString(this.setting, this.tcpSvrIp, this.IniFilePath); this.TcpSvrPortTB.Text = AdengUtil.INIReadValueString(this.setting, this.tcpSvrPort, this.IniFilePath); //parity = 0이면 Parity.None //parity = 1이면 Parity.Even //parity = 2이면 Parity.Odd this.ParityCB.Text = (p == "2") ? "홀수" : (p == "1") ? "짝수" : "없음"; }
/// <summary> /// 환경 설정창에서 발생하는 TCP 통신 제어 이벤트 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void optionForm_OnTcpSocketEvt(object sender, TcpSocketEventArgs e) { if (e.State) //통신연결 { AdengUtil.INIWriteValueString(this.setting, this.TCPIP, e.Ip, this.IniFilePath); AdengUtil.INIWriteValueString(this.setting, this.TCPPort, e.Port, this.IniFilePath); this.localTcpIp = e.Ip; this.localTcpPort = int.Parse(e.Port); this.clientSoc.ConnectTo(this.localTcpIp, this.localTcpPort); } else //연결해제 { this.clientSoc.Disconnect(); this.tcpState = false; this.SetLogListBox(string.Format("TCP {0} / {1} Connect Close!", this.localTcpIp, this.localTcpPort)); this.SetToolLBImage(this.ToolStripStatusLabel3, MewsDBManager.Properties.Resources.IconListRed); this.SetOptionTcpBtn(false); } }
/// <summary> /// 옵션 클릭 이벤트 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void optionOToolStripMenuItem_Click(object sender, EventArgs e) { using (this.optionForm = new DBMngOption()) { this.optionForm.OnDbSettingDataEvt += new EventHandler <DbSettingDataEvtArgs>(optionForm_OnDbSettingDataEvt); this.optionForm.OnTcpSocketEvt += new EventHandler <TcpSocketEventArgs>(optionForm_OnTcpSocketEvt); this.optionForm.OnTcpSettingEvt += new EventHandler <TcpSettingEventArgs>(optionForm_OnTcpSettingEvt); this.optionForm.OnLogSettingEvt += new EventHandler <LogSettingEventArgs>(optionForm_OnLogSettingEvt); this.optionForm.OnUdpSettingEvt += new EventHandler <TcpSettingEventArgs>(optionForm_OnUdpSettingEvt); //DB this.optionForm.DbIp = AdengUtil.INIReadValueString(this.setting, this.DBIP, this.IniFilePath); this.optionForm.DbSid = AdengUtil.INIReadValueString(this.setting, this.DBSID, this.IniFilePath); this.optionForm.DbId = AdengUtil.INIReadValueString(this.setting, this.DBID, this.IniFilePath); this.optionForm.DbPw = AdengUtil.INIReadValueString(this.setting, this.DBPW, this.IniFilePath); this.optionForm.Db8i = (AdengUtil.INIReadValueString(this.setting, this.Oracle8i, this.IniFilePath) == "T" ? true : false); //TCP this.optionForm.TcpIp = AdengUtil.INIReadValueString(this.setting, this.TCPIP, this.IniFilePath); this.optionForm.TcpPort = AdengUtil.INIReadValueString(this.setting, this.TCPPort, this.IniFilePath); this.optionForm.TcpState = this.tcpState; //UDP this.optionForm.UdpIp = AdengUtil.INIReadValueString(this.setting, this.UDPIP, this.IniFilePath); this.optionForm.UdpPort = AdengUtil.INIReadValueString(this.setting, this.UDPPort, this.IniFilePath); //LOG this.optionForm.LogCheckBox = (AdengUtil.INIReadValueString(this.setting, this.LogFlag, this.IniFilePath) == "T" ? true : false); //ShowDialog this.optionForm.ShowDialog(); this.optionForm.OnDbSettingDataEvt -= new EventHandler <DbSettingDataEvtArgs>(optionForm_OnDbSettingDataEvt); this.optionForm.OnTcpSocketEvt -= new EventHandler <TcpSocketEventArgs>(optionForm_OnTcpSocketEvt); this.optionForm.OnTcpSettingEvt -= new EventHandler <TcpSettingEventArgs>(optionForm_OnTcpSettingEvt); this.optionForm.OnLogSettingEvt -= new EventHandler <LogSettingEventArgs>(optionForm_OnLogSettingEvt); this.optionForm.OnUdpSettingEvt -= new EventHandler <TcpSettingEventArgs>(optionForm_OnUdpSettingEvt); } }
public OrderSelLiveSiren() { InitializeComponent(); label2.Text = LangPack.GetSelSiren(); btnMic.Text = LangPack.GetSiren1(); btnRec.Text = LangPack.GetSiren2(); try { if (AdengUtil.INIReadValueString(this.setting, "siren1", this.IniFilePath) != string.Empty) { msgTime[0] = AdengUtil.INIReadValueString(this.setting, "siren1", this.IniFilePath); } if (AdengUtil.INIReadValueString(this.setting, "siren2", this.IniFilePath) != string.Empty) { msgTime[1] = AdengUtil.INIReadValueString(this.setting, "siren2", this.IniFilePath); } if (!(System.IO.File.Exists(Util.file_Siren + "siren_1.wav"))) { this.LameMp3ToWav(Util.file_Siren + "siren_1.mp3", Util.file_Siren + "siren_1.wav"); } if (!(System.IO.File.Exists(Util.file_Siren + "siren_2.wav"))) { this.LameMp3ToWav(Util.file_Siren + "siren_2.mp3", Util.file_Siren + "siren_2.wav"); } } catch (Exception ex) { AdengUtil.INIWriteValueString(this.setting, "siren1", msgTime[0], IniFilePath); AdengUtil.INIWriteValueString(this.setting, "siren2", msgTime[1], IniFilePath); } }
/// <summary> /// 재접속을 위한 메소드 /// </summary> /// <returns></returns> private bool TryConnect() { try { string ip = AdengUtil.INIReadValueString(this.setting, this.DBIP, this.IniFilePath); string sid = AdengUtil.INIReadValueString(this.setting, this.DBSID, this.IniFilePath); string id = AdengUtil.INIReadValueString(this.setting, this.DBID, this.IniFilePath); string psw = AdengUtil.INIReadValueString(this.setting, this.DBPW, this.IniFilePath); bool support8 = (AdengUtil.INIReadValueString(this.setting, this.Oracle8i, this.IniFilePath) == "T") ? true : false; if (this.dataMng.OracleConnect(ip, sid, id, psw, support8) == false) { throw new Exception(string.Format("{0}, {1}, {2}, {3}, {4}", ip, sid, id, psw, support8)); } return(true); } catch (Exception ex) { Debug.WriteLine("TryConnect - " + ex.Message); } return(false); }
/// <summary> /// [LocalSetting] 섹션의 키 값 쓰기 /// </summary> /// <param name="keyName">키 이름</param> /// <param name="keyValue">키 값</param> /// <returns></returns> private void WriteKeyValue(string sectionName, string keyName, string keyValue) { AdengUtil.INIWriteValueString(sectionName, keyName, keyValue, INI_PATH); }
/// <summary> /// 키 값 읽기 /// </summary> /// <param name="keyName"></param> /// <returns>키 설정 값</returns> private string ReadKeyValue(string sectionName, string keyName) { return(AdengUtil.INIReadValueString(sectionName, keyName, INI_PATH)); }
/// <summary> /// 환경 설정창에서 발생하는 UDP 셋팅 값 변경 이벤트 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void optionForm_OnUdpSettingEvt(object sender, TcpSettingEventArgs e) { AdengUtil.INIWriteValueString(this.setting, this.UDPIP, e.Ip, this.IniFilePath); AdengUtil.INIWriteValueString(this.setting, this.UDPPort, e.Port, this.IniFilePath); MessageBox.Show("UDP setting changed. Please program restart!", "EDWS DB Manager", MessageBoxButtons.OK, MessageBoxIcon.Warning); }
/// <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"); } }