123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- 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
- {
-
-
-
-
-
- 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()
- {
- }
-
-
-
-
- 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;
- }
-
-
-
- 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,
- "SYSDBA",
- "masterkey",
- DB_PATH,
- "KSC_5601",
- "0");
- 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();
- }
- }
- }
- }
- }
|