using System; using System.Collections.Generic; using System.Text; using System.Windows.Forms; using System.Text.RegularExpressions; using System.Collections; using System.Diagnostics; using System.Data; using System.IO; using Microsoft.Win32; namespace FPER { public class Util { /**************************************************************** * String --> Int, °ø¹éÀ̳ª NULL Àΰæ¿ì. ±âº»°ªÀ¸·Î ¸®ÅÏÇÑ´Ù. ****************************************************************/ public static int StrToInt(object txt, int val) { int ret_val = val; try { if (txt == null) return val; if (txt.ToString().Trim() == "") return val; ret_val = int.Parse(txt.ToString()); } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } finally { } return ret_val; } /**************************************************************** * °ø¹éÀ̳ª NULL Àΰæ¿ì. ±âº»°ªÀ¸·Î ¸®ÅÏÇÑ´Ù. ****************************************************************/ public static string NullToStr(object txt) { string ret_val = ""; try { if (txt == null) return ret_val; if (txt.ToString().Trim() == "") return ret_val; ret_val = txt.ToString().Trim(); } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } finally { } return ret_val; } /******************************************* * control ¼ýÀÚÇü ÀԷ°ª °Ë»ç. *******************************************/ public static Boolean ChkOnlyLiteralTextBox(TextBox txt, String txtboxName) { try { String input_value = txt.Text; if (!onlyLiteral(input_value)) { txt.Text = ""; txt.Focus(); throw new Exception(String.Format("[{0}] ÀÔ·ÂÇü½ÄÀÌ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù. ¼ýÀÚ¸¦ ÀÔ·ÂÇÏ¿© Áֽʽÿä.", txtboxName)); } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } return true; } /******************************************* * TextBox Çʼö ÀÔ·Â °Ë»ç. *******************************************/ public static Boolean ChkTxtBox(TextBox txt, String txtboxName) { try { if (txt.Text.Trim() == "") { txt.Focus(); throw new Exception(String.Format("[{0}] ÀԷ°ªÀº ÇʼöÀÔ´Ï´Ù.", txtboxName)); } return true; } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); throw ex; } } /******************************************* * MaskedTextBox Çʼö ÀÔ·Â °Ë»ç. *******************************************/ public static Boolean ChkTxtBox(MaskedTextBox txt, String txtboxName) { try { if (txt.Text.Trim() == "") { txt.Focus(); throw new Exception(String.Format("[{0}] ÀԷ°ªÀº ÇʼöÀÔ´Ï´Ù.", txtboxName)); } return true; } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); throw ex; } } /******************************************* * ComboBox Çʼö ÀÔ·Â °Ë»ç. *******************************************/ public static Boolean ChkComboBox(ComboBox cbo, String cboName) { try { if (cbo.SelectedValue == null) { throw new Exception(String.Format("[{0}] °ªÀ» ¼±ÅÃÇÏ¿© Áֽʽÿä.", cboName)); } return true; } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); throw ex; } } /************************************************************************************** * GroupBox ÄÁÆ®·Ñ »óÅ º¯°æÇϱâ * ¼öÁ¤,ÀԷ¸ðµå * ÀԷºҰ¡¸ðµå **************************************************************************************/ public static void GroupUIChange(Control gb, UIMode mode) { try { /** È­¸é ÀÔ·Â,¼öÁ¤ ¸ðµå **/ if (mode == UIMode.input) { foreach (Control currentControl in gb.Controls) { if (currentControl is TextBox) { TextBox txt = (TextBox)currentControl; //txt.Enabled = true; txt.ReadOnly = false; } else if (currentControl is MaskedTextBox) { MaskedTextBox msktxt = (MaskedTextBox)currentControl; //msktxt.Enabled = true; msktxt.ReadOnly = false; } else if (currentControl is ComboBox) { ComboBox cbo = (ComboBox)currentControl; cbo.Enabled = true; } else if (currentControl is CheckBox) { CheckBox chk = (CheckBox)currentControl; chk.Enabled = true; } else if (currentControl is Button) { Button btn = (Button)currentControl; btn.Visible = true; } else if (currentControl is TabControl) { TabControl tc = (TabControl)currentControl; GroupUIChange(tc, mode); } else if (currentControl is TabPage) { TabPage pg = (TabPage)currentControl; GroupUIChange(pg, mode); } } } /** È­¸é ÀÔ·Â,¼öÁ¤ ¸ðµå ¿©±â±îÁö**/ /** È­¸é VIEW ¸ðµå **/ else { foreach (Control currentControl in gb.Controls) { if (currentControl is TextBox) { TextBox txt = (TextBox)currentControl; //txt.Enabled = false; txt.ReadOnly = true; } else if (currentControl is MaskedTextBox) { MaskedTextBox msktxt = (MaskedTextBox)currentControl; //msktxt.Enabled = false; msktxt.ReadOnly = true; } else if (currentControl is ComboBox) { ComboBox cbo = (ComboBox)currentControl; cbo.Enabled = false; cbo.ForeColor = System.Drawing.Color.Black; } else if (currentControl is CheckBox) { CheckBox btn = (CheckBox)currentControl; btn.Enabled = false; btn.ForeColor = System.Drawing.Color.Black; } else if (currentControl is Button) { Button btn = (Button)currentControl; btn.Visible = false; } else if (currentControl is TabControl) { TabControl tc = (TabControl)currentControl; GroupUIChange(tc, mode); } else if (currentControl is TabPage) { TabPage pg = (TabPage)currentControl; GroupUIChange(pg, mode); } } } /** È­¸é VIEW ¸ðµå ¿©±â±îÁö **/ } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } /************************************************************************************** * GroupBox ÄÁÆ®·Ñ »óÅ º¯°æÇϱâ * ¼öÁ¤,ÀԷ¸ðµå * ÀԷºҰ¡¸ðµå **************************************************************************************/ public static void GroupControlChange(Control gb, UIMode mode) { try { /** È­¸é ÀÔ·Â,¼öÁ¤ ¸ðµå **/ if (mode == UIMode.input) { foreach (Control currentControl in gb.Controls) { if (currentControl is TextBox) { TextBox txt = (TextBox)currentControl; //txt.Enabled = true; txt.ReadOnly = false; } else if (currentControl is MaskedTextBox) { MaskedTextBox msktxt = (MaskedTextBox)currentControl; //msktxt.Enabled = true; msktxt.ReadOnly = false; } else if (currentControl is ComboBox) { ComboBox cbo = (ComboBox)currentControl; cbo.Enabled = true; } else if (currentControl is CheckBox) { CheckBox chk = (CheckBox)currentControl; chk.Enabled = true; } else if (currentControl is Button) { Button btn = (Button)currentControl; btn.Enabled = true; } else if (currentControl is TabControl) { TabControl tc = (TabControl)currentControl; GroupControlChange(tc, mode); } else if (currentControl is TabPage) { TabPage pg = (TabPage)currentControl; GroupControlChange(pg, mode); } } } /** È­¸é ÀÔ·Â,¼öÁ¤ ¸ðµå ¿©±â±îÁö**/ /** È­¸é VIEW ¸ðµå **/ else { foreach (Control currentControl in gb.Controls) { if (currentControl is TextBox) { TextBox txt = (TextBox)currentControl; //txt.Enabled = false; txt.ReadOnly = true; } else if (currentControl is MaskedTextBox) { MaskedTextBox msktxt = (MaskedTextBox)currentControl; //msktxt.Enabled = false; msktxt.ReadOnly = true; } else if (currentControl is ComboBox) { ComboBox cbo = (ComboBox)currentControl; cbo.Enabled = false; cbo.ForeColor = System.Drawing.Color.Black; } else if (currentControl is CheckBox) { CheckBox btn = (CheckBox)currentControl; btn.Enabled = false; btn.ForeColor = System.Drawing.Color.Black; } else if (currentControl is Button) { Button btn = (Button)currentControl; btn.Enabled = false; } else if (currentControl is TabControl) { TabControl tc = (TabControl)currentControl; GroupControlChange(tc, mode); } else if (currentControl is TabPage) { TabPage pg = (TabPage)currentControl; GroupControlChange(pg, mode); } } } /** È­¸é VIEW ¸ðµå ¿©±â±îÁö **/ } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } /******************************************* * ¿ìÆí¹øÈ£Á¶ÇÕ °Ë»ç. *******************************************/ public static Boolean chkZipCode(String intxt) { String ZipRegex = "[0-9]{3}-[0-9]{3}"; if (Regex.IsMatch(intxt, ZipRegex)) { return true; } else { return false; } } /******************************************* * ¼ýÀÚÁ¶ÇÕ °Ë»ç. *******************************************/ public static Boolean onlyLiteral(String intxt) { String patttern = "^[0-9]+$"; //Á¤¼ö:0-9¼ýÀÚ ½Ç¼ö:^[+-]?\d+(\.\d+)?$ ¶Ç´Â ^[+-]?\d*\.?\d*$ if (Regex.IsMatch(intxt, patttern)) { return true; } else { return false; } } /******************************************* * ¼ýÀÚ¿µ¹®Á¶ÇÕ °Ë»ç. *******************************************/ public static Boolean onlyLiteralnAlpa(String intxt) { String patttern = "\\w+"; //[a-zA-Z0-9_] ¿µ¹®¼ýÀÚ_ if (Regex.IsMatch(intxt, patttern)) { return true; } else { return false; } } /******************************************* * »ç¿ëÇÔ/»ç¿ë¾ÈÇÔ ArrayList »ý¼º *******************************************/ public static ArrayList useFlagArray() { ArrayList ary = new ArrayList(); ary.Add(new cboitem("Y", "»ç¿ëÇÔ")); ary.Add(new cboitem("N", "»ç¿ë¾ÈÇÔ")); return ary; } /******************************************* * ComInfo ÀÀ´ä ¿¡·¯Ã¼Å© *******************************************/ public static bool ComInfoErrProcess(CmdInfo cmd, bool connected) { bool CompleteOK = true; try { if (cmd != null) { if (cmd.ErrResponse) { if (connected) { RCVData_NACK nack = (RCVData_NACK)cmd.ErrResponseData; } CompleteOK = false; } else if (cmd.ResponseData == null) { CompleteOK = false; } } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); CompleteOK = false; } return CompleteOK; } // cyim 2015.7.23 NACK ó¸® ºÎºÐ ¿À·ù // NACK Áï, ÀÀ´äÀ» ÇÏÁö ¾Ê´Â °æ¿ì¿¡ ÇÑÇØ¼­ 󸮸¦ ÇØ¾ßµÇ´Âµ¥µµ ºÒ±¸Çϰí, ´Ù¸¥ ¸í·É¿¡ ´ëÇÑ ÀÀ´äÀÌ µé¾î¿À¸é // ¹«Á¶°Ç ¿¹¿Ü󸮸¦ ÇØ¹ö¸®´Â °ÍÀÌ ¹®Á¦°¡ µÈ´Ù. Á¦´ë·Î ó¸®ÇÏ·Á¸é NACK ¿Ü ¾î¶² ¸í·ÉÀÌ ¿Ô´ÂÁö ÆÄ¶ó¹ÌÅÍ·Î Àü´ÞÇÏ¿© ¿À¹ö·Îµù ó¸®Çؾߵȴ٠public static bool ComInfoErrProcess(CmdInfo cmd, bool connected, string CmdType) { bool CompleteOK = true; try { if (cmd != null) { if (cmd.ErrResponseData.GetType().Name == CmdType) { ;// CmdType ÀÌ Á¦´ë·Î ¸Â¾Ò´Ù¸é ÀÌ´Â ¿À·ù°¡ ¾Æ´Ï´Ù } else if (cmd.ErrResponse) { if (connected) { RCVData_NACK nack = (RCVData_NACK)cmd.ErrResponseData; } CompleteOK = false; } else if (cmd.ResponseData == null) { CompleteOK = false; } } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); CompleteOK = false; } return CompleteOK; } /******************************************* * COMPORT ArrayList »ý¼º *******************************************/ public static ArrayList ArrayComport() { ////·¹Áö½ºÆ®¸®¿¡¼­ ¼ö½Å±âIDÁ¤º¸ Àоî¿À±â -- >º¯°æ µ¥¸ó°ú µ¿ÀÏÇÑ PC°¡ ¾Æ´Ò¼ö ÀÖÀ¸¹Ç·Î.. //RegistryKey rk = Registry.LocalMachine.OpenSubKey("HARDWARE\\DEVICEMAP\\SERIALCOMM", false); //if (rk != null) //{ // String[] keys = rk.GetValueNames(); // for (int i = 0; i < keys.Length; i++) // { // String value = rk.GetValue(keys[i]).ToString(); // int no = int.Parse(value.Replace("COM", "")); // if (no > 9) // comport.Add(new cboitem(value, value)); // else // comport.Add(new cboitem(value, value)); // } //} ArrayList comport = new ArrayList(); // cyim 2013.7.10 µðÀÚÀΰ³¼±ÀÛ¾÷ : ¼ö½Å±â¼³Á¤ - Åë½Å¼³Á¤ COM1~COM8 ·Î ¹üÀ§¸¦ Ãà¼Ò : 20 -> 8 for (int i = 1; i <= 8; i++) { String value = "COM" + i.ToString(); comport.Add(new cboitem(value, value)); } return comport; } /******************************************* * ¼Óµµ ArrayList »ý¼º *******************************************/ public static ArrayList ArraySpeed() { ArrayList speed = new ArrayList(); //speed.Add(new cboitem("110","110")); //speed.Add(new cboitem("300","300")); //speed.Add(new cboitem("600","600")); //speed.Add(new cboitem("1200","1200")); speed.Add(new cboitem("2400", "2400")); speed.Add(new cboitem("4800", "4800")); speed.Add(new cboitem("9600", "9600")); speed.Add(new cboitem("14400", "14400")); speed.Add(new cboitem("19200", "19200")); speed.Add(new cboitem("28800", "28800")); speed.Add(new cboitem("38400", "38400")); speed.Add(new cboitem("57600", "57600")); speed.Add(new cboitem("115200", "115200")); //±âº» //speed.Add(new cboitem("128000", "128000")); //speed.Add(new cboitem("256000", "256000")); return speed; } /******************************************* * DATABIT ArrayList »ý¼º *******************************************/ public static ArrayList ArrayDatabit() { ArrayList databit = new ArrayList(); //databit.Add(new cboitem("4", "4")); //databit.Add(new cboitem("5", "5")); //databit.Add(new cboitem("6", "6")); databit.Add(new cboitem("7", "7")); //±âº» databit.Add(new cboitem("8", "8")); return databit; } /******************************************* * PARITY ArrayList »ý¼º *******************************************/ public static ArrayList ArrayParity() { ArrayList parity = new ArrayList(); parity.Add(new cboitem("E", "E ¦¼ö")); //parity.Add(new cboitem("M", "M Ç¥½Ã")); parity.Add(new cboitem("N", "N ¾øÀ½")); //±âº» parity.Add(new cboitem("O", "O Ȧ¼ö")); //parity.Add(new cboitem("S", "S °ø°£")); return parity; } /******************************************* * STOPBIT ArrayList »ý¼º *******************************************/ public static ArrayList ArrayStopbit() { ArrayList stopbit = new ArrayList(); stopbit.Add(new cboitem("1", "1")); //±âº» //stopbit.Add(new cboitem("2", "1.5")); stopbit.Add(new cboitem("2", "2")); return stopbit; } /******************************************* * Baud Rate ArrayList »ý¼º *******************************************/ public static ArrayList baudRateArray() { ArrayList ary = new ArrayList(); ary.Add(new cboitem("0", "2400")); ary.Add(new cboitem("1", "4800")); ary.Add(new cboitem("2", "9600")); ary.Add(new cboitem("3", "19200")); ary.Add(new cboitem("4", "38400")); ary.Add(new cboitem("5", "57600")); ary.Add(new cboitem("6", "76800")); ary.Add(new cboitem("7", "115200")); return ary; } /******************************************* * Baud Code --> Baud Rate ¸®ÅÏ *******************************************/ public static String baudCodeToRate(String code) { String baud = null; switch (code) { case "0": baud = "2400"; break; case "1": baud = "4800"; break; case "2": baud = "9600"; break; case "3": baud = "19200"; break; case "4": baud = "38400"; break; case "5": baud = "57600"; break; case "6": baud = "76800"; break; case "7": baud = "115200"; break; } return baud; } /******************************************* * Baud Code --> Baud Rate ¸®ÅÏ *******************************************/ public static String baudRateToCode(String rate) { String code = null; switch (rate) { case "2400": code = "0"; break; case "4800": code = "1"; break; case "9600": code = "2"; break; case "19200": code = "3"; break; case "38400": code = "4"; break; case "57600": code = "5"; break; case "76800": code = "6"; break; case "115200": code = "7"; break; } return code; } /******************************************* * ÄÞº¸¹Ú½º¿¡ ArrayList ¼ÂÆÃ *******************************************/ public static void ComboSetting(ComboBox co, ArrayList ary, String defaultvalue) { try { if (ary == null) { co.DataSource = null; return; } if (co == null) return; //co.Items.Clear(); co.DataSource = ary; co.DisplayMember = "text"; co.ValueMember = "value"; if (defaultvalue != null) co.SelectedValue = defaultvalue; //if (defaultvalue == null) // co.SelectedIndex = -1; //else // co.SelectedValue = defaultvalue; } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); //Debug.WriteLine(ex.Message); } } /******************************************* * ÄÁÆ®·Ñ À̸§À¸·Î °Ë»ö *******************************************/ public static Control FineControl(Control parent, String ContronlName) { //Control con = null; //foreach (Control currentControl in parent.Controls) //{ // String cName = currentControl.Name; //btnRepeater1 // if (cName.Equals(ContronlName)) // { // con = currentControl; // } //} Control con = null; if (parent == null) return null; Control[] controls = parent.Controls.Find(ContronlName, true); if (controls.Length > 0) { con = controls[0]; } return con; } /******************************************* * chars -> StringÀ¸·Î º¯È¯ *******************************************/ public static String CharToStr(char[] chars) { String s = ""; foreach (Char c in chars) { s += string.Format("{0}", c); } return s; } /******************************************* * bytes -> StringÀ¸·Î º¯È¯ *******************************************/ public static String ByteToStr(byte[] bytes, int start_idx, int length_idx) { ASCIIEncoding ascii = new ASCIIEncoding(); //ȸ·Î I/OŸÀÔ int charCount = ascii.GetCharCount(bytes, start_idx, length_idx); Char[] iochar = new Char[charCount]; int charsDecodedCount = ascii.GetChars(bytes, start_idx, length_idx, iochar, 0); return CharToStr(iochar); } /******************************************* * byte -> hex ½ºÆ®¸µÀ¸·Î º¯È¯ *******************************************/ public static String ToHex(byte[] bin_data) { string result = ""; foreach (byte ch in bin_data) { result += string.Format("{0:x2} ", ch); // 2ÀÚ¸®ÀÇ 16Áø¼ö·Î Ãâ·Â, [Âü°í] ¸µÅ© Àо °Í } return result; } /******************************************* * ½ºÆ®¸µÀ» byte ¹è¿­·Î º¯È¯ *******************************************/ public static byte[] ToBytes(String arg) { string arg2 = NullToStr(arg); System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); return encoding.GetBytes(arg2); } /******************************************* * byte + byte ¹è¿­·Î º¯È¯ *******************************************/ public static byte[] ByteArrayCopyAdd(byte[] srcByte, byte[] addByte, int addLen) { int totalLen = srcByte.Length + addLen; byte[] totalByte = new byte[totalLen]; try { Array.Copy(srcByte, 0, totalByte, 0, srcByte.Length); Array.Copy(addByte, 0, totalByte, srcByte.Length, addLen); } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); throw ex; //Debug.WriteLine(ex.Message); } return totalByte; } /******************************************* * Y,N String --> Bool·Î º¯È¯ *******************************************/ public static bool StringToBool(String flg) { return flg == "Y" ? true : false; } /******************************************* * 2010-1-1 ÀÌÈÄ ÇöÀç±îÁö °£°Ý *******************************************/ public static double milisec() { DateTime stdDate = new DateTime(2010, 1, 1, 0, 0, 0); TimeSpan ts = DateTime.Now - stdDate; double intRtn = ts.TotalMilliseconds; return intRtn; } /******************************************* * ÇÏÀ§,»óÀ§ ¼ýÀÚ·Î float º¼Æ®¸®ÅÏ *******************************************/ public static float ToValtage(int vol_dn, int vol_up) { float voltage24 = 0; //24V (»óÀ§*256 + ÇÏÀ§) / 100 voltage24 = (vol_up * 256) + vol_dn; voltage24 = voltage24 / 100; return voltage24; } /******************************************* * TextBox ÀÔ·ÂÀ» ´ë¹®ÀÚ·Î º¯°æÇØÁÜ *******************************************/ public static void ToUpper(TextBox obj) { try { int caretPosition; caretPosition = obj.SelectionStart; obj.Text = obj.Text.ToUpper(); obj.Select(caretPosition, 0); } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } public static void LogWrite(string logstr) { try { //Util.UDebugMessage("LogWrite " + logstr, 0, 0); } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } // try // { // // string fileName = string.Format("FTER_{0:yyyyMMdd}.txt", DateTime.Now); // string dirPath = string.Format("{0}\\Logs",Application.StartupPath); // // if (!System.IO.Directory.Exists(dirPath)) System.IO.Directory.CreateDirectory(dirPath); // // string fullFileName = string.Format("{0}\\{1}", dirPath, fileName); // // FileStream fs = new FileStream(fullFileName, FileMode.Append, FileAccess.Write, FileShare.Read); // StreamWriter sw = new StreamWriter(fs); // sw.WriteLine(string.Format("{0:yyyy-MM-dd HH:mm:ss} : {1}", DateTime.Now, logstr)); //³»¿ë¾²°í // sw.Flush(); // sw.Close(); // // } // catch (Exception ex) // { // Util.UErrorMessage(ex,0,0); // //Debug.WriteLine(ex.StackTrace); // } } public static void LogBineryWrite(byte[] logstr, int offset) { try { string fileName = string.Format("FTER_PACKET_{0:yyyyMMdd}.dat", DateTime.Now); string dirPath = string.Format("{0}\\Logs", Application.StartupPath); if (!System.IO.Directory.Exists(dirPath)) System.IO.Directory.CreateDirectory(dirPath); byte[] ReadBuffer = new byte[offset]; Array.Copy(logstr, ReadBuffer, offset); string fullFileName = string.Format("{0}\\{1}", dirPath, fileName); FileStream fs = new FileStream(fullFileName, FileMode.Append, FileAccess.Write); BinaryWriter bw = new BinaryWriter(fs); bw.Write(ReadBuffer); bw.Close(); fs.Close(); } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); // Debug.WriteLine(ex.StackTrace); } } //ȸ·Î Ç¥Çö ¸Þ¼¼Áö public static string device_message(string inout_type, int receiver_id, int comm_id, int board_id, int loop_no, int repeater_id, int device_id) { string message = ""; try { switch (inout_type) { case "I": case "O": { DacUIProcess dacUIProcess = new DacUIProcess(receiver_id); // cyim 2015.7.30 µ¥ÀÌŸº£À̽º Á¢¼Ó ·çƾ º¯°æ MskDeviceIDString device_str = new MskDeviceIDString(comm_id, board_id, loop_no, repeater_id, device_id, inout_type); string device_name = ""; string position_name = ""; string device_type_name = ""; DataTable dt = dacUIProcess.Device_Select(receiver_id, comm_id, board_id, loop_no, repeater_id, device_id, inout_type); if (dt.Rows.Count > 0) { DataRow dr = dt.Rows[0]; device_name = Util.NullToStr(dr["DEVICE_NAME"]); position_name = Util.NullToStr(dr["POSITION_NAME"]); device_type_name = Util.NullToStr(dr["DEVICE_TYPE_NAME"]); } string inoutName = inout_type.Equals(code_InOutType.Output) ? "Ãâ·Â" : "ÀÔ·Â"; if (comm_id == 1 || comm_id == 3) { //message = string.Format("[{0}]-[{1}]-[{2}]-[{3}]" // , device_str.MskId, device_name, position_name, device_type_name); //message = string.Format("{3}\r\n{2} {1}\r\n[{0}]" // , device_str.MskId, device_name, position_name, device_type_name); message = string.Format("{0} {1} [{2}]", position_name, device_name, device_str.MskId); } else if (comm_id == 4) { message = string.Format("ŰÆÐµå[{0}]", device_name); } break; } case "D": { if (comm_id == 1) message = string.Format("Åë½Åº¸µå[{0}] LOOP¹øÈ£[{1}] Áß°è±â¹øÈ£[{2}] ȸ·Î¹øÈ£[{3}]" , board_id, loop_no, repeater_id, device_id); else if (comm_id == 3) message = string.Format("I/Oº¸µå[{0}] ȸ·Î¹øÈ£[{1}]", board_id, device_id); else if (comm_id == 4) message = string.Format("ŰÆÐµå¹øÈ£[{0}] ", device_id); break; } case "R": { if (comm_id == 1) message = string.Format("Åë½Åº¸µå[{0}] LOOP¹øÈ£[{1}] Áß°è±â¹øÈ£[{2}]" , board_id, loop_no, repeater_id); break; } case "L": { if (comm_id == 1) message = string.Format("Åë½Åº¸µå[{0}] LOOP¹øÈ£[{1}] ", board_id, loop_no); else if (comm_id == 2) message = string.Format("BACKLOOP Åë½Åº¸µå[{0}] LOOP¹øÈ£[{1}] ", board_id, loop_no); else if (comm_id == 3) message = "IOº¸µå"; else if (comm_id == 4) message = "ŰÆÐµå"; break; } case "B": { if (comm_id == 1) message = string.Format("Åë½Åº¸µå[{0}] ", board_id); else if (comm_id == 3) message = string.Format("I/Oº¸µå[{0}] ", board_id); else if (comm_id == 4) message = string.Format("ŰÆÐµå[{0}] ", board_id); break; } case "C": case "A": { if (comm_id == 1) message = "Front"; else if (comm_id == 2) message = "Back"; else if (comm_id == 3) message = "I/Oº¸µå"; else if (comm_id == 4) message = "ŰÆÐµå"; else message = "¼ö½Å±â"; break; } } } catch (Exception ex) { message = "";//2010.11.11,k.s.d, db access bug fix. Util.UErrorMessage(ex, 0, 0); } return message; } // cyim 2015.7.29 ¼ö½Å¹Ý ·çƾÀ» À§ÇØ ·¹Áö½ºÆ®¸®°ª ÀÌ¿ëÀº ÃÖ¼ÒÈ­ : ÇÁ·Î±×·¥ ½ÃÀ۽ÿ¡ ÀÌ¹Ì ÀоîµéÀÓ //public static string FirebirdPath() //{ // String filePath = ""; // try // { // //·¹Áö½ºÆ®¸®¿¡¼­ DBÁ¢¼ÓÁ¤º¸ Àоî¿À±â // RegistryKey rk = Registry.LocalMachine.OpenSubKey("SOFTWARE\\I_FPER_COMM_DAEMON", false); // if (rk != null) // { // String DATABASE_NAME = rk.GetValue("DATABASE_NAME").ToString(); // int pos = DATABASE_NAME.IndexOf(":"); // if (pos != -1) // { // filePath = DATABASE_NAME.Substring(pos + 1); // } // } // } // catch (Exception ex) // { // Util.UErrorMessage(ex, 0, 0); // } // return filePath; //} public static DateTime getBackUpLastDateTime() { DateTime backup_dt = DateTime.Parse("1999-01-01"); try { //·¹Áö½ºÆ®¸®¿¡¼­ DBÁ¢¼ÓÁ¤º¸ Àоî¿À±â RegistryKey rk = Registry.LocalMachine.OpenSubKey("SOFTWARE\\I_FPER_COMM_DAEMON", false); if (rk != null) { String backup_dt_str = rk.GetValue("BACKUP_DATETIME").ToString(); if (backup_dt_str.Length == 19) { backup_dt = DateTime.Parse(backup_dt_str); } } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } return backup_dt; } public static void setBackUpLastDateTime(DateTime backup_dt) { try { //·¹Áö½ºÆ®¸®¿¡¼­ DBÁ¢¼ÓÁ¤º¸ Àоî¿À±â RegistryKey rk = Registry.LocalMachine.CreateSubKey("SOFTWARE").CreateSubKey("I_FPER_COMM_DAEMON"); if (rk != null) { rk.SetValue("BACKUP_DATETIME", string.Format("{0:yyyy-MM-dd HH:mm:ss}", backup_dt)); } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } //2010.11.08, k.s.d , Debug message Function //static int prt_dbg_level = -1;// dbg message level public static void UDebugMessage(string msg, int dbg_category, int dbg_level) {// dbg message //if(dbg_level <= prt_dbg_level) { // Debug.WriteLine("[FPER]: "+msg); //} ; } public static void UDebugMessage(string msg, int dbg_category, int dbg_level, StackTrace st) {// error message //if(dbg_level <= prt_dbg_level) { // Debug.WriteLine(string.Format("[FPER][{0}]: {1} //+ {2} -//",dbg_category,msg,st.ToString())); //} ; } public static void UErrorMessage(Exception ex, int dbg_category, int dbg_level) { // error message with stack //if(dbg_level <= prt_dbg_level) { // Debug.WriteLine(string.Format("[FPER]:[ERR]: {0}, //+ {1} -// ", ex.Message, ex.StackTrace)); //} ; } } }