int GetPool(GmConnection conn, int tableId)
        {
            int recordId;

            conn.DbConnection.Open();
            IDbTransaction tr    = conn.DbConnection.BeginTransaction(IsolationLevel.Serializable);
            string         query = string.Format("select RecordId from [{0}] where TableId=@TableId", tableName);
            GmCommand      cmd   = conn.CreateCommand(query);

            cmd.AddInt("TableId", tableId);
            cmd.DbCommand.Transaction = tr;
            try
            {
                object obj = cmd.ExecuteScalar();
                if (obj is int)
                {
                    recordId        = (int)obj;
                    cmd.CommandText = string.Format("update [{0}] set RecordId=@RecordId where TableId=@TableId", tableName);
                }
                else
                {
                    recordId        = minRecordId;
                    cmd.CommandText = string.Format("insert into [{0}] values (@TableId, @RecordId)", tableName);
                }
                cmd.AddInt("RecordId", recordId + poolSize);
                cmd.ExecuteNonQuery();
                tr.Commit();
            }
            catch (Exception ex)
            {
                tr.Rollback();
                throw ex;
            }
            return(recordId);
        }
Пример #2
0
        public DbDataAdapter CreateDataAdapter(GmCommand cmd)
        {
            DbDataAdapter da = CreateDataAdapter();

            (da as IDbDataAdapter).SelectCommand = cmd.DbCommand;
            return(da);
        }
Пример #3
0
        public GmCommand CreateCommand(string cmdText)
        {
            GmCommand cmd = null;

/*			if(CommandCache.enabled)
 *                      {
 *                              cmd=CommandCache.Get(cmdText);
 *                              if(cmd!=null)
 *                              {
 *                                      cmd.Connection=this;
 *                                      return cmd;
 *                              }
 *                      }*/
            cmd = new GmCommand(this, cmdText);
//			if(CommandCache.enabled) CommandCache.Save(cmdText,cmd);
            return(cmd);
        }
Пример #4
0
 public void Write(LogType logType, string subType, string msg)
 {
     if (connFactory != null)
     {
         using (GmConnection conn = connFactory.CreateConnection())
         {
             GmCommand cmd = conn.CreateCommand("insert into Log values (@Time,@TerminalId,@UserId,@LogType,@SubType,@Message)");
             cmd.AddDateTime("Time", DateTime.Now);
             cmd.AddInt("TerminalId", App.TerminalId);
             IDbDataParameter par = cmd.AddInt("UserId", App.UserId);
             if (App.UserId == 0)
             {
                 par.Value = DBNull.Value;
             }
             cmd.AddInt("LogType", (int)logType);
             cmd.AddString("SubType", subType, FieldLength.subType);
             cmd.AddString("Message", msg, FieldLength.message);
             cmd.ExecuteNonQuery();
         }
     }
 }
Пример #5
0
        public DbDataAdapter CreateDataAdapter(string cmdText)
        {
            GmCommand cmd = CreateCommand(cmdText);

            return(CreateDataAdapter(cmd));
        }