using System; using System.Collections.Generic; using System.Text; using FirebirdSql.Data.FirebirdClient; using System.Data; using System.Collections; using System.IO; using System.Data.Common; using System.Diagnostics; namespace FPER { // ¼ö½Å¹ÝÀÇ °æ¿ì ¿ÜºÎ DB ¿¡ °¢°¢ Á¢¼ÓÇØ¾ßµÈ´Ù. // DAC ·Î ½ÃÀÛÇÏ´Â Á¢µÎ»ç·Î ±¸ÇöµÈ ³ª¸ÓÁö Ŭ·¡½ºÆÄÀϵéÀº // MDIParent ±â¹Ý¿¡¼­ µ¿ÀÛÀ» Çϱ⠶§¹®¿¡ ¼ö½Å±â ¾ÆÀ̵𰡠Çʼö ¿´Áö¸¸ // DacFireDesk ¿¡¼­´Â ¿ÀÁ÷ ¼ö½Å±â ¾ÆÀ̵𸦠±â¹ÝÀ¸·Î µ¿ÀÛÇÏ°Ô ¸¸µé¾îÁø´Ù // ¿©±â¿¡¼­´Â ¼ö½Å±â ¾ÆÀ̵𰡠0À¸·Î µé¾î¿À´Â °æ¿ì°¡ °ÅÀÇ ¾ø´Ù°í °¡Á¤ÇÑ´Ù public class _DacFireDesk { // µ¥ÀÌŸº£À̽º ¾ÆÀÌÇÇ string DB_IP = null; // µ¥ÀÌŸº£À̽º ÆÄÀϰæ·Î string DB_PATH = null; // ¼ö½Å±â¾ÆÀ̵ð public string ReceiverID = null; // µ¥ÀÌŸº£À̽º ¼¼¼Ç public FbConnection connection = null; public static int iOpenCount = 0; public static int iAccessCount = 0; public _DacFireDesk(string ID) { // ¼ö½Å±â ¾ÆÀ̵ð ReceiverID = ID; _FireDesk_Receiver FireDesk_Receiver = (_FireDesk_Receiver)_Data.Hash_Receiver[ReceiverID]; DB_IP = FireDesk_Receiver.DATABASE_NAME_IP; DB_PATH = FireDesk_Receiver.DATABASE_NAME_PATH; } ~_DacFireDesk() { } // // Read (Select) // //ÀÔÃâ·Â ȸ·Î ŸÀÔÁ¶È¸ public DataTable TB_DEVICE_TYPE_From_SelectAll() { DataTable dt = null; try { String SQL = ""; SQL += "SELECT SYMBOL_TYPE,DEVICE_TYPE,DEVICE_TYPE_NAME,USE_FLAG,SEQ_NO "; SQL += "FROM TB_DEVICE_TYPE "; SQL += "WHERE SYMBOL_TYPE = 'O'"; DataSet dao = Select(SQL); dt = dao.Tables[0]; } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } return dt; } // // Write (ExecuteNonQuery) // public void Receiver_Clear() { try { String SQL = "DELETE FROM TB_RECEIVER "; ExecuteNonQuery(SQL); } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } // // µ¥ÀÌŸº£À̽º // // Á¢¼Ó½ÃÀÛ public bool Connect() { bool ret = false; try { // »ç¿ëÀÚ¿Í ¾ÏÈ£´Â °íÁ¤½ÃŲ´Ù String strConnection = string.Format("Server={0};User={1};Password={2};Database={3};Charset={4};ServerType={5}", DB_IP, // IP ex)192.168.63.22 "SYSDBA", // »ç¿ëÀÚ "masterkey", // ¾ÏÈ£ DB_PATH, // Àý´ëÀ§Ä¡.. ex) C:\TEST\TEST.FDB "KSC_5601", // KSC_5601 °°Àº ¹®ÀÚ¼ÂÀ» ÁöÁ¤ "0"); // 0À̸é Classic/Super Server, 1À̸é Embedded Server¸¦ ÁöÁ¤ÇϽŴÙÀ½... connection = new FbConnection(strConnection); connection.Open(); iOpenCount++; iAccessCount++; if (iAccessCount > 100000) { iAccessCount = 0; } ret = (this.connection.State == ConnectionState.Open); } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } return ret; } // Á¢¼ÓÁ¾·á public void DisConnect() { try { if (connection != null) connection.Close(); iOpenCount--; } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } // Äõ¸®¿äû-ÀÀ´ä public DataSet Select(String sqlSyntax) { DataSet data = null; if (this.Connect()) { try { FbCommand command = new FbCommand(sqlSyntax, connection); command.CommandType = CommandType.Text; command.CommandTimeout = 2147483647; data = new DataSet(); FbDataAdapter adapter = new FbDataAdapter(command); adapter.Fill(data); adapter.Dispose(); command.Dispose(); } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); throw ex; } finally { this.DisConnect(); } } return data; } // Äõ¸®¸í·É public void ExecuteNonQuery(String sqlSyntax) { if (this.Connect()) { FbTransaction transaction = connection.BeginTransaction(); try { FbCommand command = new FbCommand(sqlSyntax, connection, transaction); command.CommandType = CommandType.Text; command.CommandTimeout = 2147483647; command.ExecuteNonQuery(); transaction.Commit(); command.Dispose(); } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); transaction.Rollback(); throw ex; } finally { this.DisConnect(); } } } } }