1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
 
 
using Common;
using Oracle.DataAccess.Client;
using System;
using System.Data;
using System.Data.Common;
 
namespace Dao
{
  public class GwAlarmDao : IDisposable
  {
    public DataTable GetTopAlarmLog(int count)
    {
      return OracleHelper.Execute(string.Format("select * from (SELECT * FROM GW_ALARM_LOG  ORDER BY ALARM_ID DESC) a where ROWNUM < {0}", (object) count), OracleHelper.Connection);
    }
 
    public DataTable GetTopAlarmLog(int count, out int recordCount, int pageIndex, int pageSize)
    {
      recordCount = 0;
      string str = string.Format(" from (SELECT * FROM GW_ALARM_LOG  ORDER BY ALARM_ID DESC) a where ROWNUM < {0}", (object) count);
      using (OracleDataReader reader = OracleHelper.ExecuteReader("SELECT count(*) as count" + str, OracleHelper.Connection))
      {
        while (((DbDataReader) reader).Read())
          recordCount = this.ReadCount(reader);
      }
      return OracleHelper.Execute(PubConstant.doOracleSql(pageIndex, pageSize, recordCount, "SELECT *" + str).ToString(), OracleHelper.Connection);
    }
 
    public DataTable GetUnrestoredAlarmLog()
    {
      return OracleHelper.Execute(string.Format("SELECT * FROM GW_ALARM_LOG WHERE RESTORE_FLAG=0  and rownum < 10 ORDER BY ALARM_ID DESC"), OracleHelper.Connection);
    }
 
    private int ReadCount(OracleDataReader reader)
    {
      int @int;
      try
      {
        @int = new OracleReaderWrapper(reader).GetInt("count", 0);
      }
      catch (Exception ex)
      {
        LogHelper.Error(ex);
        return 0;
      }
      return @int;
    }
 
    public void Dispose()
    {
    }
  }
}