public async void TelegramMsgSend(string mType, string msg) { try { DataTable dt = db.ChatID_Get(mType); #if (!DEBUG) await _client.Connect(); //_client.Connect(); if (!_client.isAuth()) { SetMessage(true, "메시지 전송 실패-인증필요.", false); return; } #endif foreach (DataRow dr in dt.Rows) { #if (!DEBUG) await _client.SendMessageToChat(enChatsInfoType.id, Fnc.obj2String(dr["ChatID"]), msg); //_client.SendMessageToChat(enChatsInfoType.id, Fnc.obj2String(dr["ChatID"]), msg); cTelLg.WLog("[Mtype]{0}[ChatID{1}:{2}]{3}", mType, dr["chatid"], dr["desc"], msg); #else cTelLg.WLog("미전송[Mtype]{0}[ChatID{1}:{2}]{3}", mType, dr["chatid"], dr["desc"], msg); #endif } } catch (Exception ex) { ProcException(ex, "TelegramMsgSend"); } }
private void evtClientConnected(Socket soc) { IPEndPoint ip = (IPEndPoint)soc.RemoteEndPoint; string str = string.Format("{0}:{1} 접속 확인", ip.Address.ToString(), ip.Port); clsLog.WLog(str); //if (evtClientConected != null) evtClientConected(str); }
private void thTest(object obj) { if (isTestWork) { return; } try { isTestWork = true; if (log == null) { string fld = ".\\TestLog"; if (!Function.system.clsFile.FolderExists(fld)) { Function.system.clsFile.FolderCreate(fld); } log = new Function.Util.Log(fld, "TestLog", 30, true); } //address, interval, from, to string[] param = (string[])obj; lngTestTimes++; if (lngTestTimes == 1) { decTestValue = decimal.Parse(param[2]); decTestMaxValue = decimal.Parse(param[3]); log.WLog("PlcTest를 시작합니다.[IP]{0} [Port]{1} [PlcType]{2} [ValueFrom]{3} [ValueTo]{4}", Comm.IPAddress, Comm.Port, Comm.enPLCType, decTestValue, decTestMaxValue); } else if ((lngTestTimes % 100) == 0) { log.WLog("PlcTest {0}번째 진행중 [현재값]{1}", lngTestTimes, decTestValue); } Comm.WriteOrder(param[0], int.Parse(decTestValue.ToString())); Function.form.control.Invoke_Control_Text(lblTestMsg, string.Format("[{0}] Value:{1}", DateTime.Now.ToString("HH:mm:ss"), decTestValue)); decTestValue++; } catch (Exception ex) { log.WLog_Exception("thTest", ex); Function.form.control.Invoke_Control_Text(lblTestMsg, ex.Message); } finally { isTestWork = false; } }
private DataSet excute_Query(string Query, string strTable, bool writelog = false) { try { this.DB_isOpen(); if (Query.Trim() == "") { throw new Exception("쿼리에 문제가 있습니다.(길이 0)"); } this.Dbcmd.Connection = this.Dbconn; Dbcmd.CommandType = CommandType.Text; Dbcmd.CommandText = Query; if (_log != null & writelog) { _log.WLog("[SQLDB 쿼리 실행]{0}", Query); } DataSet ds = new DataSet(); SqlDataAdapter da = new SqlDataAdapter(Dbcmd); if (strTable != null && strTable != string.Empty) { da.Fill(ds, strTable); } else { da.Fill(ds); } da.Dispose(); return(ds); } catch (SqlException ex) { throw new Exception( string.Format("excute_Query Err(SQL) : {0} / 쿼리 : {1}", ex.Message, Query), ex); } catch (Exception ex) { throw new Exception( string.Format("excute_Query Err(일반) : {0} / 쿼리 : {1}", ex.Message, Query), ex); } finally { if (!isTaransaction) { DB_Close(); } } }
/// <summary> /// 백업파일을 삭제 한다. 30일 이내는 삭제 하지 않고, 30일이 지난경우 말일자만 남겨 놓는다. 1년 지나면 전부 삭제. /// </summary> private void DelProc() { try { //하루에 한번 //if (DateTime.Now.ToShortDateString() == _dtLastDelWork.ToShortDateString()) return; DirectoryInfo di = new DirectoryInfo(_backupFolder); DateTime tt; foreach (FileInfo fi in di.GetFiles()) { string[] bkNm = Function.system.clsFile.FileSplit_NameExtention(fi.Name); string[] fn = bkNm[0].Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries); try { DateTime dn = Fnc.String2Date(fn[fn.Length - 1], Fnc.enDateType.Date); //30일 지난것만 if (dn > DateTime.Now.AddDays(-30)) { continue; } if (dn > DateTime.Now.AddYears(-1)) { //해당월 마지막 날짜를 구한다. tt = new DateTime(dn.Year, dn.Month, 1).AddMonths(1).AddDays(-1); if (dn.Day == tt.Day) { continue; } } fi.Delete(); _log.WLog("[백업File]{0} 삭제 하였습니다.", fi.Name); } catch { } } _dtLastDelWork = DateTime.Now; } catch (Exception ex) { if (_log != null) { _log.WLog_Exception("DelProc", ex); } } }
private void frmBasic_Load(object sender, EventArgs e) { frmBaseForm_MdiChildActivate(this, null); //Nofyicon init if (Notifyicon_Visible && CloseToMinimize) { NotifyContextMenu = new ContextMenu(); MenuItem m = NotifyContextMenu.MenuItems.Add("Á¾·á..."); m.Click += M_Click; Notifyicon.ContextMenu = NotifyContextMenu; } stBar.DoubleClick += new EventHandler(stBar_DoubleClick); tmrDtNow = new System.Threading.Timer(new System.Threading.TimerCallback(Timer_1sec), null, 0, 1000); //Çػ󵵺° âÀ§Ä¡ °íÁ¤ if (LocationFix) { tmrScr.Interval = 1000; tmrScr.Tick += TmrScr_Tick; tmrScr.Enabled = true; tmrScr.Start(); } if (clsLog != null) { clsLog.WLog(pgmName + "À»(¸¦) ½ÃÀÛ ÇÕ´Ï´Ù."); } }
/// <summary> /// 로그 기록을 합니다. /// </summary> /// <param name="strModule"></param> /// <param name="strMsg"></param> internal void LogWrite(string strModule, string strMsg) { try { if (log == null) { return; } string strMessage = string.Format("[{1}] {2}", strModule, strMsg); log.WLog(strMessage); } catch { } }
/// <summary> /// 접점 컨트롤시 응답 /// </summary> /// <param name="Port"></param> /// <param name="DeviceType"></param> /// <param name="sts"></param> void parser_OnExternDeviceControlAck(short Port, short DeviceType, Status sts) { if (Port == 0 && DeviceType == 0x3 && sts == Status.No_Error) { //output port 컨트롤에 대한 응답 clsLog.WLog("Dio Output Port 처리 응답 받음"); boolAckDio = true; } else if (Port == 4) { //input port 상태에 변화(on)에 대한 이벤트 bool Port1, Port2, Port3, Port4; Port1 = Port2 = Port3 = Port4 = false; if ((DeviceType & 0x1) == 0x1) { Port1 = true; } if ((DeviceType & 0x2) == 0x2) { Port2 = true; } if ((DeviceType & 0x4) == 0x4) { Port3 = true; } if ((DeviceType & 0x8) == 0x8) { Port4 = true; } clsLog.WLog(string.Format("Dio Input Port 상태변경 : [Port1]{0} [Port2]{1} [Port3]{2} [Port4]{3}", Port1, Port2, Port3, Port4)); if (evtDioInPortAck != null) { evtDioInPortAck(Port1, Port2, Port3, Port4); } } }
protected override void Form_Init() { try { base.Form_Init(); Text = $"TorqueTool [{vari.StationID}] v.{Application.ProductVersion}"; Title_Label = $"TorqueTool [{vari.StationID}]"; //운영모드 확인 if (vari.OpMode == vari.enOpMode.Monitoring) { //모니터링 if (!tabControl1.TabPages.Contains(tabMonitoring)) { tabControl1.TabPages.Insert(0, tabMonitoring); } } else { //조화 Only tabControl1.TabPages.Remove(tabMonitoring); } //이미지 if (System.IO.File.Exists(vari.TorqueImagePath)) { try { pnlImage.BackgroundImage = new Bitmap(vari.TorqueImagePath); } catch (Exception ex) { pnlImage.BackgroundImage = null; ProcException(ex, "Image 로드 실패", true); } } else { pnlImage.BackgroundImage = null; } //db if if (vari.bIF_Chk) { lblIF_Status.Text = ""; ifLog.WLog("FormInit I/F 활성 화 중.."); } else { lblIF_Status.Text = "중지 중..."; ifLog.WLog("FormInit I/F 중지 상태"); } try { //plc 연결 정보 초기화 if (opc != null) { opc.Dispose(); } Application.DoEvents(); #if (TestPLC) opc = new PLCComm.PLCComm(PLCComm.enPlcType.TEST, "127.0.0.1", 6001, "", "PLC_LOG"); //new PLCModule.clsPLCModule(PLCModule.enPlcType.TEST, "", 0, "", "PLC_LOG"); Text += " - PLC Test Mode"; #else //opc = new PLCModule.clsPLCModule(PLCModule.enPlcType.AB, vari.plc.RSLINX_ID, vari.plc.RSLINX_ID, "Torque", "Torque", 1000, "Torque_PLC"); opc = new PLCComm.PLCComm(PLCComm.enPlcType.AB, "", vari.plc.RSLINX_ID, "Torque", "Torque", 1000, "Torque_PLC"); #endif opc.OnChConnectionStatus += Opc_OnChConnectionStatus; PLCComm.delChAddressValue dChAddress = new PLCComm.delChAddressValue(OnChAddress); opc.Open(); opc.AddAddress(vari.plc.Add_Trigger, PLCComm.enPLCValueType.INT); opc.AddAddress(vari.plc.Add_Ack, PLCComm.enPLCValueType.INT); opc.AddAddress(vari.plc.Add_Confirm, PLCComm.enPLCValueType.INT); opc.AddAddress(vari.plc.Add_Info, PLCComm.enPLCValueType.STRING); opc.AddAddress(vari.plc.Add_Data, PLCComm.enPLCValueType.HEX); opc.ChangeEvtAddress_Add(vari.plc.Add_Trigger, dChAddress); } catch (Exception ex) { ProcException(ex, "PLC 연결 초기화 실패", true); } try { //db상태 체크 타이머 if (tmrDB_Chk == null) { tmrDB_Chk = new System.Threading.Timer(new TimerCallback(Sql_Connection_Chk), null, 0, 10000); } else { Sql_Connection_Chk(null); } // if (tmrIF_Chk == null) { tmrIF_Chk = new System.Threading.Timer(new TimerCallback(IF_Db), null, 0, iIF_Span * 1000); } else { IF_Db(null); } //코드 테이블의 info 정보 변경 dba.dev_Station_set(vari.StationID); //코드 정보 로드 vari.DB_CodeDetail_Load(); Last_Work_Get(); } catch (Exception ex) { ProcException(ex, "DB 연결 초기화 실패", true); } //plc 체크 쓰래드 if (tmrWork == null) { tmrWork = new System.Threading.Timer(new TimerCallback(Work_Plc), null, 5000, 10000); } //조회 조건 초기화 Search_Conditon_Reset(); } catch (Exception ex) { ProcException(ex, "Form_Init"); } }