示例#1
0
        public int Update()
        {
            if (this.id < 1)
            {
                return(-1);
            }
            if (this.device_id < 1)
            {
                return(-1);
            }
            DBConn    dBConn    = null;
            DbCommand dbCommand = null;

            try
            {
                dBConn = DBConnPool.getConnection();
                if (dBConn.con != null)
                {
                    dbCommand             = DBConn.GetCommandObject(dBConn.con);
                    dbCommand.CommandType = CommandType.Text;
                    string commandText = "update line_info set max_voltage=?,min_voltage=?,max_power=?,min_power=?,max_current=?,min_current=?  where id=" + this.id;
                    dbCommand.CommandText = commandText;
                    dbCommand.Parameters.Add(DBTools.GetParameter("@max_voltage", this.max_voltage, dbCommand));
                    dbCommand.Parameters.Add(DBTools.GetParameter("@min_voltage", this.min_voltage, dbCommand));
                    dbCommand.Parameters.Add(DBTools.GetParameter("@max_power", this.max_power, dbCommand));
                    dbCommand.Parameters.Add(DBTools.GetParameter("@min_power", this.min_power, dbCommand));
                    dbCommand.Parameters.Add(DBTools.GetParameter("@max_current", this.max_current, dbCommand));
                    dbCommand.Parameters.Add(DBTools.GetParameter("@min_current", this.min_current, dbCommand));
                    int result = dbCommand.ExecuteNonQuery();
                    dbCommand.Parameters.Clear();
                    DBCacheStatus.Device = true;
                    DBCacheStatus.DBSyncEventSet(true, new string[]
                    {
                        "DBSyncEventName_Service_Device"
                    });
                    return(result);
                }
            }
            catch (Exception ex)
            {
                DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace);
            }
            finally
            {
                try
                {
                    dbCommand.Dispose();
                }
                catch
                {
                }
                if (dBConn != null)
                {
                    dBConn.close();
                }
            }
            return(-1);
        }
示例#2
0
        public static long DeleteLogByRecords(int records)
        {
            long      result      = 0L;
            string    commandText = "select min(log.id) from (select top " + records + " id from logrecords order by id desc ) as log";
            string    arg         = "delete from logrecords where id < ";
            DBConn    dBConn      = null;
            DbCommand dbCommand   = new OleDbCommand();

            try
            {
                dBConn = DBConnPool.getLogConnection();
                if (dBConn.con != null)
                {
                    dbCommand             = DBConn.GetCommandObject(dBConn.con);
                    dbCommand.CommandType = CommandType.Text;
                    if (DBUrl.SERVERMODE)
                    {
                        commandText = "select min(logg.id) from (select id from logrecords order by id desc LIMIT " + records + " OFFSET 0 ) as logg";
                    }
                    dbCommand.CommandText = commandText;
                    object obj = dbCommand.ExecuteScalar();
                    if (obj != null && obj != DBNull.Value)
                    {
                        int num = 0;
                        try
                        {
                            num = Convert.ToInt32(obj);
                        }
                        catch
                        {
                        }
                        dbCommand.CommandText = arg + num;
                        result = (long)dbCommand.ExecuteNonQuery();
                    }
                    dbCommand.Dispose();
                }
            }
            catch (Exception ex)
            {
                DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace);
            }
            finally
            {
                try
                {
                    dbCommand.Dispose();
                }
                catch
                {
                }
                if (dBConn != null)
                {
                    dBConn.close();
                }
            }
            return(result);
        }
示例#3
0
        public int UpdateLineThreshold(DBConn conn)
        {
            if (this.id < 1)
            {
                return(-1);
            }
            if (this.device_id < 1)
            {
                return(-1);
            }
            DbCommand dbCommand = null;

            try
            {
                if (conn.con != null)
                {
                    dbCommand             = DBConn.GetCommandObject(conn.con);
                    dbCommand.Connection  = conn.con;
                    dbCommand.CommandType = CommandType.Text;
                    string text = "update line_info set ";
                    text = text + "max_voltage=" + CultureTransfer.ToString(this.max_voltage);
                    text = text + ",min_voltage=" + CultureTransfer.ToString(this.min_voltage);
                    text = text + ",max_power=" + CultureTransfer.ToString(this.max_power);
                    text = text + ",min_power=" + CultureTransfer.ToString(this.min_power);
                    text = text + ",max_current=" + CultureTransfer.ToString(this.max_current);
                    text = text + ",min_current=" + CultureTransfer.ToString(this.min_current);
                    text = text + "  where id= " + this.id;
                    dbCommand.CommandText = text;
                    int result = dbCommand.ExecuteNonQuery();
                    dbCommand.Parameters.Clear();
                    dbCommand.Dispose();
                    return(result);
                }
            }
            catch (Exception ex)
            {
                try
                {
                    dbCommand.Dispose();
                }
                catch
                {
                }
                DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace);
            }
            finally
            {
                try
                {
                    dbCommand.Dispose();
                }
                catch
                {
                }
            }
            return(-1);
        }
示例#4
0
        public static bool SetEventInfo(DataTable eventlist)
        {
            bool      result    = false;
            DBConn    dBConn    = null;
            DbCommand dbCommand = new OleDbCommand();

            try
            {
                dBConn = DBConnPool.getConnection();
                if (dBConn.con != null)
                {
                    dbCommand = DBConn.GetCommandObject(dBConn.con);
                    foreach (DataRow dataRow in eventlist.Rows)
                    {
                        dbCommand.CommandType = CommandType.Text;
                        dbCommand.CommandText = string.Concat(new object[]
                        {
                            "update event_info set logflag = ",
                            Convert.ToInt16(dataRow["logflag"]),
                            ", mailflag = ",
                            Convert.ToInt16(dataRow["mailflag"]),
                            " where eventid = '",
                            Convert.ToString(dataRow["eventid"]),
                            "' "
                        });
                        dbCommand.ExecuteNonQuery();
                    }
                    dbCommand.Dispose();
                    DBCacheStatus.Event = true;
                    DBCacheStatus.DBSyncEventSet(true, new string[]
                    {
                        "DBSyncEventName_Service_Event"
                    });
                    return(true);
                }
            }
            catch (Exception ex)
            {
                DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace);
            }
            finally
            {
                try
                {
                    dbCommand.Dispose();
                }
                catch
                {
                }
                if (dBConn != null)
                {
                    dBConn.close();
                }
            }
            return(result);
        }
示例#5
0
        public int UpdatePortThreshold(DBConn conn)
        {
            if (this.id < 1)
            {
                return(-1);
            }
            if (this.device_id < 1)
            {
                return(-1);
            }
            DbCommand dbCommand = new OleDbCommand();

            try
            {
                if (conn.con != null)
                {
                    dbCommand             = DBConn.GetCommandObject(conn.con);
                    dbCommand.CommandType = CommandType.Text;
                    string text = "update port_info set port_nm=?,port_confirmation=?,port_ondelay_time=?,port_offdelay_time=?,max_voltage=?,min_voltage=?,max_power_diss=?,min_power_diss=?,max_power=?,min_power=?,max_current=?,min_current=?,shutdown_method=?,mac=? where id=" + this.id;
                    text = "update port_info set ";
                    text = text + "port_nm='" + this.port_nm + "'";
                    text = text + ",port_confirmation=" + CultureTransfer.ToString(this.port_confirmation);
                    text = text + ",port_ondelay_time=" + CultureTransfer.ToString(this.port_ondelay_time);
                    text = text + ",port_offdelay_time=" + CultureTransfer.ToString(this.port_offdelay_time);
                    text = text + ",max_voltage=" + CultureTransfer.ToString(this.max_voltage);
                    text = text + ",min_voltage=" + CultureTransfer.ToString(this.min_voltage);
                    text = text + ",max_power_diss=" + CultureTransfer.ToString(this.max_power_diss);
                    text = text + ",min_power_diss=" + CultureTransfer.ToString(this.min_power_diss);
                    text = text + ",max_power=" + CultureTransfer.ToString(this.max_power);
                    text = text + ",min_power=" + CultureTransfer.ToString(this.min_power);
                    text = text + ",max_current=" + CultureTransfer.ToString(this.max_current);
                    text = text + ",min_current=" + CultureTransfer.ToString(this.min_current);
                    text = text + ",shutdown_method=" + CultureTransfer.ToString(this.shutdown_method);
                    text = text + ",mac='" + this.port_mac + "'";
                    text = text + "  where id= " + this.id;
                    dbCommand.CommandText = text;
                    int result = dbCommand.ExecuteNonQuery();
                    dbCommand.Parameters.Clear();
                    dbCommand.Dispose();
                    return(result);
                }
            }
            catch (Exception ex)
            {
                DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace);
                try
                {
                    dbCommand.Dispose();
                }
                catch
                {
                }
            }
            return(-1);
        }
示例#6
0
        public static int InsertBillReport(string str_title, string str_writer, DateTime dt_time, string str_path)
        {
            int       result    = -1;
            DBConn    dBConn    = null;
            DbCommand dbCommand = null;

            try
            {
                dBConn = DBConnPool.getConnection();
                if (dBConn.con != null)
                {
                    dbCommand = DBConn.GetCommandObject(dBConn.con);
                    if (DBUrl.SERVERMODE)
                    {
                        string commandText = "insert into reportbill(Title,Writer,ReportTime,ReportPath) values(?Title,?Writer,?ReportTime,?ReportPath)";
                        dbCommand.CommandText = commandText;
                        dbCommand.Parameters.Add(DBTools.GetParameter("?Title", str_title, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?Writer", str_writer, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?ReportTime", dt_time.ToString("yyyy-MM-dd HH:mm:ss"), dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?ReportPath", str_path, dbCommand));
                    }
                    else
                    {
                        string commandText = "insert into reportbill(Title,Writer,ReportTime,ReportPath) values(?,?,?,?)";
                        dbCommand.CommandText = commandText;
                        dbCommand.Parameters.Add(DBTools.GetParameter("@Title", str_title, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@Writer", str_writer, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@ReportTime", dt_time.ToString("yyyy-MM-dd HH:mm:ss"), dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@ReportPath", str_path, dbCommand));
                    }
                    result = dbCommand.ExecuteNonQuery();
                    return(result);
                }
            }
            catch (Exception ex)
            {
                DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace);
            }
            finally
            {
                if (dbCommand != null)
                {
                    dbCommand.Dispose();
                }
                if (dBConn.con != null)
                {
                    dBConn.Close();
                }
            }
            return(result);
        }
示例#7
0
        public static int UpdateGroupStatus(int i_selectflag, string str_groups)
        {
            int       result    = -1;
            DBConn    dBConn    = null;
            DbCommand dbCommand = null;

            try
            {
                dBConn = DBConnPool.getConnection();
                if (dBConn.con != null)
                {
                    dbCommand             = DBConn.GetCommandObject(dBConn.con);
                    dbCommand.CommandType = CommandType.Text;
                    string commandText = string.Concat(new object[]
                    {
                        "update data_group set isselect = ",
                        i_selectflag,
                        " where id in (",
                        str_groups,
                        " )"
                    });
                    dbCommand.CommandText = commandText;
                    result = dbCommand.ExecuteNonQuery();
                    DBCacheStatus.Group = true;
                    DBCacheStatus.DBSyncEventSet(true, new string[]
                    {
                        "DBSyncEventName_Service_Group"
                    });
                }
            }
            catch (Exception ex)
            {
                DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace);
            }
            finally
            {
                try
                {
                    dbCommand.Dispose();
                }
                catch
                {
                }
                if (dBConn != null)
                {
                    dBConn.close();
                }
            }
            return(result);
        }
示例#8
0
        public static long DeleteLogByDay(int iDays)
        {
            long     result   = 0L;
            DateTime dateTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")).AddDays((double)(-(double)(iDays - 1)));

            new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, 0, 0, 0);
            string    commandText = "delete from logrecords where ticks < #" + DateTime.Now.AddHours((double)(-24 * iDays)).ToString("yyyy-MM-dd HH:mm:ss") + "#";
            DBConn    dBConn      = null;
            DbCommand dbCommand   = new OleDbCommand();

            try
            {
                dBConn = DBConnPool.getLogConnection();
                if (dBConn.con != null)
                {
                    dbCommand             = DBConn.GetCommandObject(dBConn.con);
                    dbCommand.CommandType = CommandType.Text;
                    dbCommand.CommandText = commandText;
                    if (DBUrl.SERVERMODE)
                    {
                        dbCommand.CommandText = dbCommand.CommandText.Replace("#", "'");
                    }
                    result = (long)dbCommand.ExecuteNonQuery();
                }
                dbCommand.Dispose();
            }
            catch (Exception ex)
            {
                DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace);
            }
            finally
            {
                try
                {
                    dbCommand.Dispose();
                }
                catch
                {
                }
                if (dBConn != null)
                {
                    dBConn.close();
                }
            }
            return(result);
        }
示例#9
0
        public int Update()
        {
            if (this.id < 1)
            {
                return(-1);
            }
            if (this.device_id < 1)
            {
                return(-1);
            }
            DBConn    dBConn    = null;
            DbCommand dbCommand = null;

            try
            {
                dBConn = DBConnPool.getConnection();
                if (dBConn.con != null)
                {
                    dbCommand             = DBConn.GetCommandObject(dBConn.con);
                    dbCommand.CommandType = CommandType.Text;
                    if (DBUrl.SERVERMODE)
                    {
                        string commandText = "update bank_info set port_nums=?port_nums,bank_nm=?bank_nm,voltage=?voltage,max_voltage=?max_voltage,min_voltage=?min_voltage,max_power_diss=?max_power_diss,min_power_diss=?min_power_diss,max_power=?max_power,min_power=?min_power,max_current=?max_current,min_current=?min_current  where id=" + this.id;
                        dbCommand.CommandText = commandText;
                        dbCommand.Parameters.Add(DBTools.GetParameter("?port_nums", this.portlists, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?bank_nm", this.bank_nm, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?voltage", this.voltage, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?max_voltage", this.max_voltage, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?min_voltage", this.min_voltage, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?max_power_diss", this.max_power_diss, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?min_power_diss", this.min_power_diss, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?max_power", this.max_power, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?min_power", this.min_power, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?max_current", this.max_current, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?min_current", this.min_current, dbCommand));
                    }
                    else
                    {
                        if (this.bank_nm != null && this.bank_nm.Equals("\r\n"))
                        {
                            string commandText = "update bank_info set port_nums=?,voltage=?,max_voltage=?,min_voltage=?,max_power_diss=?,min_power_diss=?,max_power=?,min_power=?,max_current=?,min_current=?  where id=" + this.id;
                            dbCommand.CommandText = commandText;
                            dbCommand.Parameters.Add(DBTools.GetParameter("@port_nums", this.portlists, dbCommand));
                            dbCommand.Parameters.Add(DBTools.GetParameter("@voltage", this.voltage, dbCommand));
                            dbCommand.Parameters.Add(DBTools.GetParameter("@max_voltage", this.max_voltage, dbCommand));
                            dbCommand.Parameters.Add(DBTools.GetParameter("@min_voltage", this.min_voltage, dbCommand));
                            dbCommand.Parameters.Add(DBTools.GetParameter("@max_power_diss", this.max_power_diss, dbCommand));
                            dbCommand.Parameters.Add(DBTools.GetParameter("@min_power_diss", this.min_power_diss, dbCommand));
                            dbCommand.Parameters.Add(DBTools.GetParameter("@max_power", this.max_power, dbCommand));
                            dbCommand.Parameters.Add(DBTools.GetParameter("@min_power", this.min_power, dbCommand));
                            dbCommand.Parameters.Add(DBTools.GetParameter("@max_current", this.max_current, dbCommand));
                            dbCommand.Parameters.Add(DBTools.GetParameter("@min_current", this.min_current, dbCommand));
                        }
                        else
                        {
                            string commandText = "update bank_info set port_nums=?,bank_nm=?,voltage=?,max_voltage=?,min_voltage=?,max_power_diss=?,min_power_diss=?,max_power=?,min_power=?,max_current=?,min_current=?  where id=" + this.id;
                            dbCommand.CommandText = commandText;
                            dbCommand.Parameters.Add(DBTools.GetParameter("@port_nums", this.portlists, dbCommand));
                            dbCommand.Parameters.Add(DBTools.GetParameter("@bank_nm", this.bank_nm, dbCommand));
                            dbCommand.Parameters.Add(DBTools.GetParameter("@voltage", this.voltage, dbCommand));
                            dbCommand.Parameters.Add(DBTools.GetParameter("@max_voltage", this.max_voltage, dbCommand));
                            dbCommand.Parameters.Add(DBTools.GetParameter("@min_voltage", this.min_voltage, dbCommand));
                            dbCommand.Parameters.Add(DBTools.GetParameter("@max_power_diss", this.max_power_diss, dbCommand));
                            dbCommand.Parameters.Add(DBTools.GetParameter("@min_power_diss", this.min_power_diss, dbCommand));
                            dbCommand.Parameters.Add(DBTools.GetParameter("@max_power", this.max_power, dbCommand));
                            dbCommand.Parameters.Add(DBTools.GetParameter("@min_power", this.min_power, dbCommand));
                            dbCommand.Parameters.Add(DBTools.GetParameter("@max_current", this.max_current, dbCommand));
                            dbCommand.Parameters.Add(DBTools.GetParameter("@min_current", this.min_current, dbCommand));
                        }
                    }
                    int result = dbCommand.ExecuteNonQuery();
                    dbCommand.Parameters.Clear();
                    DBCacheStatus.Device = true;
                    DBCacheStatus.DBSyncEventSet(true, new string[]
                    {
                        "DBSyncEventName_Service_Device"
                    });
                    return(result);
                }
            }
            catch (Exception ex)
            {
                DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace);
            }
            finally
            {
                try
                {
                    dbCommand.Dispose();
                }
                catch
                {
                }
                if (dBConn != null)
                {
                    dBConn.close();
                }
            }
            return(-1);
        }
示例#10
0
        public static DataTable GetPrePage(int i_key, int i_range_type, DateTime dt_start, DateTime dt_end, int i_pagenum, int i_pagesize, int i_total)
        {
            DateTime   now        = DateTime.Now;
            DataTable  dataTable  = new DataTable();
            DataColumn dataColumn = new DataColumn("insert_time");

            dataColumn.DataType = Type.GetType("System.String");
            dataTable.Columns.Add(dataColumn);
            DataColumn dataColumn2 = new DataColumn("eventid");

            dataColumn2.DataType = Type.GetType("System.String");
            dataTable.Columns.Add(dataColumn2);
            DataColumn dataColumn3 = new DataColumn("parametervalue");

            dataColumn3.DataType = Type.GetType("System.String");
            dataTable.Columns.Add(dataColumn3);
            DataColumn dataColumn4 = new DataColumn("id");

            dataColumn4.DataType = Type.GetType("System.Int32");
            dataTable.Columns.Add(dataColumn4);
            DBConn    dBConn    = null;
            DbCommand dbCommand = new OleDbCommand();
            long      arg_BF_0  = dt_start.Ticks;
            long      arg_C7_0  = dt_end.Ticks;
            string    text      = "";

            switch (i_range_type)
            {
            case 0:
                text = string.Concat(new object[]
                {
                    " 2=2 id > ",
                    i_key,
                    " and ticks <= #",
                    dt_end.ToString("yyyy-MM-dd HH:mm:ss"),
                    "# "
                });
                break;

            case 1:
                text = string.Concat(new object[]
                {
                    " 2=2 id > ",
                    i_key,
                    " and ticks >= #",
                    dt_start.ToString("yyyy-MM-dd HH:mm:ss"),
                    "# and ticks <= #",
                    dt_end.ToString("yyyy-MM-dd HH:mm:ss"),
                    "# "
                });
                break;

            case 2:
                text = string.Concat(new object[]
                {
                    " 2=2 id > ",
                    i_key,
                    " and (ticks <= #",
                    dt_start.ToString("yyyy-MM-dd HH:mm:ss"),
                    "# or ticks >= #",
                    dt_end.ToString("yyyy-MM-dd HH:mm:ss"),
                    "# )"
                });
                break;
            }
            try
            {
                dBConn = DBConnPool.getLogConnection();
                if (dBConn.con != null)
                {
                    dbCommand             = DBConn.GetCommandObject(dBConn.con);
                    dbCommand.CommandType = CommandType.Text;
                    long      num        = 0L;
                    long      num2       = 0L;
                    DataTable dataTable2 = new DataTable();
                    string    commandText;
                    if (i_pagenum * i_pagesize > i_total)
                    {
                        int num3 = i_pagenum * i_pagesize - i_total;
                        commandText = string.Concat(new object[]
                        {
                            "select top ",
                            i_pagesize - num3,
                            " id  from (select top ",
                            i_pagesize - num3,
                            " id from logrecords where ",
                            text,
                            " order by id asc) order by id desc"
                        });
                    }
                    else
                    {
                        commandText = string.Concat(new object[]
                        {
                            "select id from ( select top ",
                            i_pagesize,
                            " id from logrecords where ",
                            text,
                            " order by id asc ) order by id desc"
                        });
                    }
                    dbCommand.CommandText = commandText;
                    if (DBUrl.SERVERMODE)
                    {
                        dbCommand.CommandText = dbCommand.CommandText.Replace("#", "'");
                    }
                    DbDataReader dbDataReader = dbCommand.ExecuteReader();
                    if (dbDataReader.HasRows)
                    {
                        dataTable2 = DBConn.ConvertOleDbReaderToDataTable(dbDataReader);
                    }
                    dbDataReader.Close();
                    DataRow[] array = dataTable2.Select("", "id DESC");
                    if (array.Length > 0)
                    {
                        num2 = Convert.ToInt64(array[0]["id"]);
                        num  = Convert.ToInt64(array[array.Length - 1]["id"]);
                    }
                    dbCommand.CommandText = string.Concat(new object[]
                    {
                        "select * from logrecords where id >= ",
                        num,
                        " and id <= ",
                        num2,
                        " order by id desc"
                    });
                    if (DBUrl.SERVERMODE)
                    {
                        dbCommand.CommandText = dbCommand.CommandText.Replace("#", "'");
                    }
                    DbDataReader dbDataReader2 = dbCommand.ExecuteReader();
                    while (dbDataReader2.Read())
                    {
                        string  value   = Convert.ToDateTime(dbDataReader2.GetValue(1)).ToString("yyyy-MM-dd HH:mm:ss");
                        string  @string = dbDataReader2.GetString(2);
                        string  string2 = dbDataReader2.GetString(3);
                        int     num4    = Convert.ToInt32(dbDataReader2.GetValue(0));
                        DataRow dataRow = dataTable.NewRow();
                        dataRow["insert_time"]    = value;
                        dataRow["eventid"]        = @string;
                        dataRow["parametervalue"] = string2;
                        dataRow["id"]             = num4;
                        dataTable.Rows.Add(dataRow);
                    }
                    dbDataReader2.Close();
                }
            }
            catch (Exception ex)
            {
                DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace);
            }
            finally
            {
                try
                {
                    dbCommand.Dispose();
                }
                catch
                {
                }
                if (dBConn != null)
                {
                    dBConn.close();
                }
            }
            Console.WriteLine("million sencods is : " + (DateTime.Now - now).TotalMilliseconds.ToString());
            return(dataTable);
        }
示例#11
0
        public int Update()
        {
            if (this.id < 1)
            {
                return(-1);
            }
            if (this.device_id < 1)
            {
                return(-1);
            }
            DBConn    dBConn    = null;
            DbCommand dbCommand = new OleDbCommand();

            try
            {
                dBConn = DBConnPool.getConnection();
                if (dBConn.con != null)
                {
                    dbCommand             = DBConn.GetCommandObject(dBConn.con);
                    dbCommand.CommandType = CommandType.Text;
                    if (DBUrl.SERVERMODE)
                    {
                        string commandText = "update port_info set port_nm=?port_nm,port_confirmation=?port_confirmation,port_ondelay_time=?port_ondelay_time,port_offdelay_time=?port_offdelay_time,max_voltage=?max_voltage,min_voltage=?min_voltage,max_power_diss=?max_power_diss,min_power_diss=?min_power_diss,max_power=?max_power,min_power=?min_power,max_current=?max_current,min_current=?min_current,shutdown_method=?shutdown_method ,mac=?mac where id=" + this.id;
                        dbCommand.CommandText = commandText;
                        dbCommand.Parameters.Add(DBTools.GetParameter("?port_nm", this.port_nm, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?port_confirmation", this.port_confirmation, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?port_ondelay_time", this.port_ondelay_time, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?port_offdelay_time", this.port_offdelay_time, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?max_voltage", this.max_voltage, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?min_voltage", this.min_voltage, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?max_power_diss", this.max_power_diss, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?min_power_diss", this.min_power_diss, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?max_power", this.max_power, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?min_power", this.min_power, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?max_current", this.max_current, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?min_current", this.min_current, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?shutdown_method", this.shutdown_method, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?mac", this.port_mac, dbCommand));
                    }
                    else
                    {
                        string commandText = "update port_info set port_nm=?,port_confirmation=?,port_ondelay_time=?,port_offdelay_time=?,max_voltage=?,min_voltage=?,max_power_diss=?,min_power_diss=?,max_power=?,min_power=?,max_current=?,min_current=?,shutdown_method=? ,mac=? where id=" + this.id;
                        dbCommand.CommandText = commandText;
                        dbCommand.Parameters.Add(DBTools.GetParameter("@port_nm", this.port_nm, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@port_confirmation", this.port_confirmation, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@port_ondelay_time", this.port_ondelay_time, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@port_offdelay_time", this.port_offdelay_time, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@max_voltage", this.max_voltage, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@min_voltage", this.min_voltage, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@max_power_diss", this.max_power_diss, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@min_power_diss", this.min_power_diss, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@max_power", this.max_power, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@min_power", this.min_power, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@max_current", this.max_current, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@min_current", this.min_current, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@shutdown_method", this.shutdown_method, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@mac", this.port_mac, dbCommand));
                    }
                    int result = dbCommand.ExecuteNonQuery();
                    dbCommand.Parameters.Clear();
                    DBCacheStatus.Device = true;
                    DBCacheStatus.DBSyncEventSet(true, new string[]
                    {
                        "DBSyncEventName_Service_Device"
                    });
                    return(result);
                }
            }
            catch (Exception ex)
            {
                DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace);
            }
            finally
            {
                dbCommand.Dispose();
                if (dBConn != null)
                {
                    dBConn.close();
                }
            }
            return(-1);
        }
示例#12
0
        public int update()
        {
            int       num       = -1;
            DBConn    dBConn    = null;
            DbCommand dbCommand = new OleDbCommand();

            try
            {
                dBConn = DBConnPool.getConnection();
                string commandText  = "update sys_para set para_value = '" + this.maintenance + "' where para_name = 'LIMITTYPE' and para_type = 'int' ";
                string commandText2 = "update sys_para set para_value = '" + this.days + "' where para_name = 'DAYLIMIT' and para_type = 'int' ";
                string commandText3 = "update sys_para set para_value = '" + this.recordNum + "' where para_name = 'RECORDSLIMIT' and para_type = 'int' ";
                string commandText4 = "update sys_para set para_value = '" + this.pageSize + "' where para_name = 'PAGESIZE' and para_type = 'int' ";
                string commandText5 = "update sys_para set para_value = '" + this.saveRange + "' where para_name = 'SAVERANGE' and para_type = 'int' ";
                dbCommand             = DBConn.GetCommandObject(dBConn.con);
                dbCommand.CommandType = CommandType.Text;
                dbCommand.CommandText = commandText;
                num = dbCommand.ExecuteNonQuery();
                if (num < 1)
                {
                    int result = num;
                    return(result);
                }
                dbCommand.CommandText = commandText2;
                num = dbCommand.ExecuteNonQuery();
                if (num < 1)
                {
                    int result = num;
                    return(result);
                }
                dbCommand.CommandText = commandText3;
                num = dbCommand.ExecuteNonQuery();
                if (num < 1)
                {
                    int result = num;
                    return(result);
                }
                dbCommand.CommandText = commandText4;
                num = dbCommand.ExecuteNonQuery();
                if (num < 1)
                {
                    int result = num;
                    return(result);
                }
                dbCommand.CommandText = commandText5;
                num = dbCommand.ExecuteNonQuery();
                dbCommand.Dispose();
                DBCacheStatus.SystemParameter = true;
                DBCacheStatus.DBSyncEventSet(true, new string[]
                {
                    "DBSyncEventName_Service_SystemParameter"
                });
            }
            catch (Exception ex)
            {
                DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace);
            }
            finally
            {
                try
                {
                    dbCommand.Dispose();
                }
                catch
                {
                }
                if (dBConn != null)
                {
                    dBConn.close();
                }
            }
            return(num);
        }
示例#13
0
        public static int DeleteGroupByID(long l_id)
        {
            DBConn    dBConn    = null;
            DbCommand dbCommand = null;

            try
            {
                dBConn = DBConnPool.getConnection();
                if (dBConn.con != null)
                {
                    dbCommand             = DBConn.GetCommandObject(dBConn.con);
                    dbCommand.CommandType = CommandType.Text;
                    string commandText = "delete from group_detail where group_id = " + l_id;
                    dbCommand.CommandText = commandText;
                    int result = dbCommand.ExecuteNonQuery();
                    dbCommand.Parameters.Clear();
                    dbCommand.CommandText = "delete from groupcontroltask where groupid = " + l_id;
                    result = dbCommand.ExecuteNonQuery();
                    dbCommand.CommandText = "delete from taskschedule where groupid = " + l_id;
                    result = dbCommand.ExecuteNonQuery();
                    dbCommand.CommandText = "delete from data_group where id = " + l_id;
                    result = dbCommand.ExecuteNonQuery();
                    dbCommand.CommandText = "delete from ugp where gid =" + l_id;
                    dbCommand.ExecuteNonQuery();
                    DBCacheStatus.Group     = true;
                    DBCacheStatus.GroupTask = true;
                    DBCacheStatus.User      = true;
                    DBCacheStatus.DBSyncEventSet(true, new string[]
                    {
                        "DBSyncEventName_Service_Group"
                    });
                    DBCacheStatus.DBSyncEventSet(true, new string[]
                    {
                        "DBSyncEventName_Service_GroupTask"
                    });
                    DBCacheStatus.DBSyncEventSet(true, new string[]
                    {
                        "DBSyncEventName_Service_User"
                    });
                    return(result);
                }
            }
            catch (Exception ex)
            {
                DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace);
            }
            finally
            {
                try
                {
                    dbCommand.Dispose();
                }
                catch
                {
                }
                if (dBConn != null)
                {
                    dBConn.close();
                }
            }
            return(-1);
        }
示例#14
0
        public int UpdateSetting()
        {
            DBConn    dBConn    = null;
            DbCommand dbCommand = new OleDbCommand();

            try
            {
                dBConn = DBConnPool.getConnection();
                if (dBConn.con != null)
                {
                    dbCommand             = DBConn.GetCommandObject(dBConn.con);
                    dbCommand.CommandType = CommandType.Text;
                    if (DBUrl.SERVERMODE)
                    {
                        string commandText = "update smtpsetting set EnableSMTP=?EnableSMTP , ServerAddress=?ServerAddress , PortId=?PortId , EmailFrom=?EmailFrom , EmailTo=?EmailTo , SendEvent=?SendEvent , EnableAuth=?EnableAuth, Account=?Account, UserPwd=?UserPwd ";
                        dbCommand.CommandText = commandText;
                        dbCommand.Parameters.Add(DBTools.GetParameter("?EnableSMTP", this.smtp_enable, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?ServerAddress", this.smtp_server, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?PortId", this.smtp_port, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?EmailFrom", this.smtp_from, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?EmailTo", this.smtp_to, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?SendEvent", this.smtp_event, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?EnableAuth", this.smtp_auth, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?Account", this.smtp_account, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?UserPwd", this.smtp_pwd, dbCommand));
                    }
                    else
                    {
                        string commandText = "update smtpsetting set EnableSMTP=? , ServerAddress=? , PortId=? , EmailFrom=? , EmailTo=? , SendEvent=? , EnableAuth=?, Account=?, UserPwd=? ";
                        dbCommand.CommandText = commandText;
                        dbCommand.Parameters.Add(DBTools.GetParameter("@EnableSMTP", this.smtp_enable, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@ServerAddress", this.smtp_server, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@PortId", this.smtp_port, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@EmailFrom", this.smtp_from, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@EmailTo", this.smtp_to, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@SendEvent", this.smtp_event, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@EnableAuth", this.smtp_auth, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@Account", this.smtp_account, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@UserPwd", this.smtp_pwd, dbCommand));
                    }
                    int num = dbCommand.ExecuteNonQuery();
                    dbCommand.Parameters.Clear();
                    DBCacheStatus.Smtp = true;
                    DBCacheStatus.DBSyncEventSet(true, new string[]
                    {
                        "DBSyncEventName_Service_Smtp"
                    });
                    int result = num;
                    return(result);
                }
            }
            catch (Exception ex)
            {
                DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace);
                if (ex.Message.IndexOf(" duplicate values ") > 0)
                {
                    int result = -2;
                    return(result);
                }
            }
            finally
            {
                try
                {
                    dbCommand.Dispose();
                }
                catch
                {
                }
                if (dBConn != null)
                {
                    dBConn.close();
                }
            }
            return(-1);
        }
示例#15
0
        public int Update()
        {
            if (this.id < 1)
            {
                return(-1);
            }
            if (this.device_id < 1)
            {
                return(-1);
            }
            DBConn    dBConn    = null;
            DbCommand dbCommand = new OleDbCommand();

            try
            {
                dBConn = DBConnPool.getConnection();
                if (dBConn.con != null)
                {
                    dbCommand             = DBConn.GetCommandObject(dBConn.con);
                    dbCommand.CommandType = CommandType.Text;
                    if (DBUrl.SERVERMODE)
                    {
                        string commandText = "update device_sensor_info set sensor_nm=?sensor_nm,max_humidity=?max_humidity,min_humidity=?min_humidity,max_temperature=?max_temperature,min_temperature=?min_temperature,max_press=?max_press,min_press=?min_press,sensor_type=?sensor_type,location_type=?location_type  where id=" + this.id;
                        dbCommand.CommandText = commandText;
                        dbCommand.Parameters.Add(DBTools.GetParameter("?sensor_nm", this.sensor_nm, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?max_humidity", this.max_humidity, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?min_humidity", this.min_humidity, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?max_temperature", this.max_temperature, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?min_temperature", this.min_temperature, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?max_press", this.max_press, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?min_press", this.min_press, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?sensor_type", this.sensor_type, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?location_type", this.sensor_locationtype, dbCommand));
                    }
                    else
                    {
                        string commandText = "update device_sensor_info set sensor_nm=?,max_humidity=?,min_humidity=?,max_temperature=?,min_temperature=?,max_press=?,min_press=?,sensor_type=?,location_type=?  where id=" + this.id;
                        dbCommand.CommandText = commandText;
                        dbCommand.Parameters.Add(DBTools.GetParameter("@sensor_nm", this.sensor_nm, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@max_humidity", this.max_humidity, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@min_humidity", this.min_humidity, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@max_temperature", this.max_temperature, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@min_temperature", this.min_temperature, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@max_press", this.max_press, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@min_press", this.min_press, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@sensor_type", this.sensor_type, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@location_type", this.sensor_locationtype, dbCommand));
                    }
                    int result = dbCommand.ExecuteNonQuery();
                    dbCommand.Parameters.Clear();
                    DBCacheStatus.Device = true;
                    DBCacheStatus.DBSyncEventSet(true, new string[]
                    {
                        "DBSyncEventName_Service_Device"
                    });
                    return(result);
                }
            }
            catch (Exception ex)
            {
                DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace);
            }
            finally
            {
                try
                {
                    dbCommand.Dispose();
                }
                catch
                {
                }
                if (dBConn != null)
                {
                    dBConn.close();
                }
            }
            return(-1);
        }
示例#16
0
        public int UpdateZone()
        {
            DBConn    dBConn    = null;
            DbCommand dbCommand = new OleDbCommand();

            try
            {
                dBConn = DBConnPool.getConnection();
                if (dBConn.con != null)
                {
                    dbCommand             = DBConn.GetCommandObject(dBConn.con);
                    dbCommand.CommandType = CommandType.Text;
                    if (DBUrl.SERVERMODE)
                    {
                        string commandText = "update zone_info set zone_nm=?zone_nm , racks=?racks , sx=?sx ,sy=?sy, ex=?ex ,ey=?ey, color=?color , reserve=?reserve where id= " + this.z_id;
                        dbCommand.CommandText = commandText;
                        dbCommand.Parameters.Add(DBTools.GetParameter("?zone_nm", this.z_name, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?racks", this.z_racklist, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?sx", this.z_s_x, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?sy", this.z_s_y, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?ex", this.z_e_x, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?ey", this.z_e_y, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?color", this.z_color, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?reserve", this.z_reserve, dbCommand));
                    }
                    else
                    {
                        string commandText = "update zone_info set zone_nm=? , racks=? , sx=? ,sy=?, ex=? ,ey=?, color=? , reserve=? where id= " + this.z_id;
                        dbCommand.CommandText = commandText;
                        dbCommand.Parameters.Add(DBTools.GetParameter("@zone_nm", this.z_name, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@racks", this.z_racklist, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@sx", this.z_s_x, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@sy", this.z_s_y, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@ex", this.z_e_x, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@ey", this.z_e_y, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@color", this.z_color, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@reserve", this.z_reserve, dbCommand));
                    }
                    int num = dbCommand.ExecuteNonQuery();
                    dbCommand.Parameters.Clear();
                    DBCacheStatus.ZONE = true;
                    DBCacheStatus.DBSyncEventSet(true, new string[]
                    {
                        "DBSyncEventName_Service_ZONE"
                    });
                    int result = num;
                    return(result);
                }
            }
            catch (Exception ex)
            {
                DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace);
                if (ex.Message.IndexOf(" duplicate values ") > 0)
                {
                    int result = -2;
                    return(result);
                }
            }
            finally
            {
                try
                {
                    dbCommand.Dispose();
                }
                catch
                {
                }
                if (dBConn != null)
                {
                    dBConn.close();
                }
            }
            return(-1);
        }
示例#17
0
        public static DataTable GetSearchResult(int i_range_type, DateTime dt_start, DateTime dt_end, int i_pagenum, int i_pagesize, int i_total)
        {
            DateTime   now        = DateTime.Now;
            DataTable  dataTable  = new DataTable();
            DataColumn dataColumn = new DataColumn("insert_time");

            dataColumn.DataType = Type.GetType("System.String");
            dataTable.Columns.Add(dataColumn);
            DataColumn dataColumn2 = new DataColumn("eventid");

            dataColumn2.DataType = Type.GetType("System.String");
            dataTable.Columns.Add(dataColumn2);
            DataColumn dataColumn3 = new DataColumn("parametervalue");

            dataColumn3.DataType = Type.GetType("System.String");
            dataTable.Columns.Add(dataColumn3);
            DBConn    dBConn    = null;
            DbCommand dbCommand = new OleDbCommand();
            long      arg_95_0  = dt_start.Ticks;
            long      arg_9D_0  = dt_end.Ticks;
            string    text      = "";

            switch (i_range_type)
            {
            case 0:
                text = " 2=2 ";
                break;

            case 1:
                text = string.Concat(new string[]
                {
                    " 2=2 and ticks >= #",
                    dt_start.ToString("yyyy-MM-dd HH:mm:ss"),
                    "# and ticks <= #",
                    dt_end.ToString("yyyy-MM-dd HH:mm:ss"),
                    "# "
                });
                break;

            case 2:
                text = string.Concat(new string[]
                {
                    " 2=2 and (ticks <= #",
                    dt_start.ToString("yyyy-MM-dd HH:mm:ss"),
                    "# or ticks >= #",
                    dt_end.ToString("yyyy-MM-dd HH:mm:ss"),
                    "# )"
                });
                break;
            }
            try
            {
                dBConn = DBConnPool.getLogConnection();
                if (dBConn.con != null)
                {
                    dbCommand             = DBConn.GetCommandObject(dBConn.con);
                    dbCommand.CommandType = CommandType.Text;
                    if (i_pagenum == 0 && i_pagesize == 0)
                    {
                        dbCommand.CommandText = "select ticks,eventid,logpara from logrecords where " + text + " order by id desc";
                        if (DBUrl.SERVERMODE)
                        {
                            dbCommand.CommandText = dbCommand.CommandText.Replace("#", "'");
                        }
                        DbDataReader dbDataReader = dbCommand.ExecuteReader();
                        while (dbDataReader.Read())
                        {
                            string  value   = Convert.ToDateTime(dbDataReader.GetValue(0)).ToString("yyyy-MM-dd HH:mm:ss");
                            string  @string = dbDataReader.GetString(1);
                            string  string2 = dbDataReader.GetString(2);
                            DataRow dataRow = dataTable.NewRow();
                            dataRow["insert_time"]    = value;
                            dataRow["eventid"]        = @string;
                            dataRow["parametervalue"] = string2;
                            dataTable.Rows.Add(dataRow);
                        }
                        dbDataReader.Close();
                    }
                    else
                    {
                        if (LogInfo.m_type == i_range_type && DateTime.Compare(LogInfo.mdt_start, dt_start) == 0 && DateTime.Compare(LogInfo.mdt_end, dt_end) == 0)
                        {
                            long num;
                            long num2;
                            if (i_pagenum * i_pagesize > i_total)
                            {
                                num  = Convert.ToInt64(LogInfo.ht_cache[(i_pagenum - 1) * i_pagesize + 1]);
                                num2 = Convert.ToInt64(LogInfo.ht_cache[i_total]);
                            }
                            else
                            {
                                num  = Convert.ToInt64(LogInfo.ht_cache[(i_pagenum - 1) * i_pagesize + 1]);
                                num2 = Convert.ToInt64(LogInfo.ht_cache[i_pagenum * i_pagesize]);
                            }
                            dbCommand.CommandText = string.Concat(new object[]
                            {
                                "select * from logrecords where id >= ",
                                num2,
                                " and id <= ",
                                num,
                                " order by id desc"
                            });
                            if (DBUrl.SERVERMODE)
                            {
                                dbCommand.CommandText = dbCommand.CommandText.Replace("#", "'");
                            }
                            DbDataReader dbDataReader2 = dbCommand.ExecuteReader();
                            while (dbDataReader2.Read())
                            {
                                string  value2   = Convert.ToDateTime(dbDataReader2.GetValue(1)).ToString("yyyy-MM-dd HH:mm:ss");
                                string  string3  = dbDataReader2.GetString(2);
                                string  string4  = dbDataReader2.GetString(3);
                                DataRow dataRow2 = dataTable.NewRow();
                                dataRow2["insert_time"]    = value2;
                                dataRow2["eventid"]        = string3;
                                dataRow2["parametervalue"] = string4;
                                dataTable.Rows.Add(dataRow2);
                            }
                            dbDataReader2.Close();
                        }
                        else
                        {
                            LogInfo.m_type        = i_range_type;
                            LogInfo.mdt_start     = dt_start;
                            LogInfo.mdt_end       = dt_end;
                            LogInfo.ht_cache      = new Hashtable();
                            dbCommand.CommandText = "select id from logrecords where " + text + " order by id desc";
                            if (DBUrl.SERVERMODE)
                            {
                                dbCommand.CommandText = dbCommand.CommandText.Replace("#", "'");
                            }
                            DbDataReader dbDataReader3 = dbCommand.ExecuteReader();
                            int          num3          = 1;
                            while (dbDataReader3.Read())
                            {
                                LogInfo.ht_cache.Add(num3, dbDataReader3.GetValue(0));
                                num3++;
                            }
                            dbDataReader3.Close();
                            new DataTable();
                            long num5;
                            long num6;
                            if (i_pagenum * i_pagesize > i_total)
                            {
                                int num4 = i_pagenum * i_pagesize - i_total;
                                string.Concat(new object[]
                                {
                                    "select top ",
                                    i_pagesize - num4,
                                    " id  from (select top ",
                                    i_pagesize - num4,
                                    " id from logrecords where ",
                                    text,
                                    " order by id asc) order by id desc"
                                });
                                num5 = Convert.ToInt64(LogInfo.ht_cache[(i_pagenum - 1) * i_pagesize + 1]);
                                num6 = Convert.ToInt64(LogInfo.ht_cache[i_total]);
                            }
                            else
                            {
                                num5 = Convert.ToInt64(LogInfo.ht_cache[(i_pagenum - 1) * i_pagesize + 1]);
                                num6 = Convert.ToInt64(LogInfo.ht_cache[i_pagenum * i_pagesize]);
                                if (i_pagenum * i_pagesize > i_total / 2)
                                {
                                    string.Concat(new object[]
                                    {
                                        "select top ",
                                        i_pagesize,
                                        " id  from (select top ",
                                        i_total - i_pagenum * i_pagesize + i_pagesize,
                                        " id from logrecords where ",
                                        text,
                                        " order by id asc) order by id desc"
                                    });
                                }
                                else
                                {
                                    string.Concat(new object[]
                                    {
                                        "select id from (select top ",
                                        i_pagesize,
                                        " id  from (select top ",
                                        i_pagenum * i_pagesize,
                                        " id from logrecords where ",
                                        text,
                                        " order by id desc) order by id asc) order by id desc"
                                    });
                                }
                            }
                            dbCommand.CommandText = string.Concat(new object[]
                            {
                                "select * from logrecords where id >= ",
                                num6,
                                " and id <= ",
                                num5,
                                " order by id desc"
                            });
                            if (DBUrl.SERVERMODE)
                            {
                                dbCommand.CommandText = dbCommand.CommandText.Replace("#", "'");
                            }
                            DbDataReader dbDataReader4 = dbCommand.ExecuteReader();
                            while (dbDataReader4.Read())
                            {
                                string  value3   = Convert.ToDateTime(dbDataReader4.GetValue(1)).ToString("yyyy-MM-dd HH:mm:ss");
                                string  string5  = dbDataReader4.GetString(2);
                                string  string6  = dbDataReader4.GetString(3);
                                DataRow dataRow3 = dataTable.NewRow();
                                dataRow3["insert_time"]    = value3;
                                dataRow3["eventid"]        = string5;
                                dataRow3["parametervalue"] = string6;
                                dataTable.Rows.Add(dataRow3);
                            }
                            dbDataReader4.Close();
                        }
                    }
                    dbCommand.Dispose();
                }
            }
            catch (Exception ex)
            {
                DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace);
            }
            finally
            {
                try
                {
                    dbCommand.Dispose();
                }
                catch
                {
                }
                if (dBConn != null)
                {
                    dBConn.close();
                }
            }
            Console.WriteLine("million sencods is : " + (DateTime.Now - now).TotalMilliseconds.ToString());
            return(dataTable);
        }
示例#18
0
        public static int CreateZoneInfo(string str_name, string str_racklist, int i_sx, int i_sy, int i_ex, int i_ey, string str_color)
        {
            DBConn    dBConn    = null;
            DbCommand dbCommand = new OleDbCommand();

            try
            {
                dBConn = DBConnPool.getConnection();
                if (dBConn.con != null)
                {
                    dbCommand             = DBConn.GetCommandObject(dBConn.con);
                    dbCommand.CommandType = CommandType.Text;
                    if (DBUrl.SERVERMODE)
                    {
                        string commandText = "insert into zone_info ( zone_nm,racks,sx,sy,ex,ey,color,reserve ) values(?zone_nm,?racks,?sx,?sy,?ex,?ey,?color,?reserve)";
                        dbCommand.CommandText = commandText;
                        dbCommand.Parameters.Clear();
                        dbCommand.Parameters.Add(DBTools.GetParameter("?zone_nm", str_name, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?racks", str_racklist, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?sx", i_sx, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?sy", i_sy, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?ex", i_ex, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?ey", i_ey, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?color", str_color, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?reserve", Convert.ToInt32("0"), dbCommand));
                    }
                    else
                    {
                        string commandText = "insert into zone_info ( zone_nm,racks,sx,sy,ex,ey,color,reserve ) values(?,?,?,?,?,?,?,?)";
                        dbCommand.CommandText = commandText;
                        dbCommand.Parameters.Clear();
                        dbCommand.Parameters.Add(DBTools.GetParameter("@zone_nm", str_name, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@racks", str_racklist, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@sx", i_sx, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@sy", i_sy, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@ex", i_ex, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@ey", i_ey, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@color", str_color, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@reserve", Convert.ToInt32("0"), dbCommand));
                    }
                    int num = dbCommand.ExecuteNonQuery();
                    dbCommand.Parameters.Clear();
                    DBCacheStatus.ZONE = true;
                    DBCacheStatus.DBSyncEventSet(true, new string[]
                    {
                        "DBSyncEventName_Service_ZONE"
                    });
                    int result = num;
                    return(result);
                }
            }
            catch (Exception ex)
            {
                DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace);
                if (ex.Message.IndexOf(" duplicate values ") > 0)
                {
                    int result = -2;
                    return(result);
                }
            }
            finally
            {
                try
                {
                    dbCommand.Dispose();
                }
                catch
                {
                }
                if (dBConn != null)
                {
                    dBConn.close();
                }
            }
            return(-1);
        }
示例#19
0
        public static int GetRowCount(int i_range_type, DateTime dt_start, DateTime dt_end)
        {
            DBConn    dBConn    = null;
            DbCommand dbCommand = new OleDbCommand();
            long      arg_0F_0  = dt_start.Ticks;
            long      arg_17_0  = dt_end.Ticks;

            try
            {
                dBConn = DBConnPool.getLogConnection();
                if (dBConn.con != null)
                {
                    dbCommand             = DBConn.GetCommandObject(dBConn.con);
                    dbCommand.CommandType = CommandType.Text;
                    switch (i_range_type)
                    {
                    case 0:
                        dbCommand.CommandText = "select count(id) from logrecords";
                        break;

                    case 1:
                        dbCommand.CommandText = string.Concat(new string[]
                        {
                            "select count(id) from logrecords where ticks >= #",
                            dt_start.ToString("yyyy-MM-dd HH:mm:ss"),
                            "# and ticks <= #",
                            dt_end.ToString("yyyy-MM-dd HH:mm:ss"),
                            "# "
                        });
                        break;

                    case 2:
                        dbCommand.CommandText = string.Concat(new string[]
                        {
                            "select count(id) from logrecords where ticks <= #",
                            dt_start.ToString("yyyy-MM-dd HH:mm:ss"),
                            "# or ticks >= #",
                            dt_end.ToString("yyyy-MM-dd HH:mm:ss"),
                            "# "
                        });
                        break;
                    }
                    if (DBUrl.SERVERMODE)
                    {
                        dbCommand.CommandText = dbCommand.CommandText.Replace("#", "'");
                    }
                    object obj = dbCommand.ExecuteScalar();
                    dbCommand.Dispose();
                    int result;
                    if (obj == null || obj is DBNull || Convert.ToInt32(obj) < 1)
                    {
                        result = -1;
                        return(result);
                    }
                    result = Convert.ToInt32(obj);
                    return(result);
                }
            }
            catch (Exception ex)
            {
                DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace);
            }
            finally
            {
                try
                {
                    dbCommand.Dispose();
                }
                catch
                {
                }
                if (dBConn != null)
                {
                    dBConn.close();
                }
            }
            return(-1);
        }
示例#20
0
        public static int DeleteByName(string str_zonename)
        {
            DBConn    dBConn    = null;
            DbCommand dbCommand = new OleDbCommand();

            try
            {
                dBConn = DBConnPool.getConnection();
                if (dBConn.con != null)
                {
                    string commandText = "select * from zone_info z inner join group_detail g on z.id = g.dest_id where z.zone_nm = '" + str_zonename + "' and g.grouptype = 'zone'";
                    dbCommand             = DBConn.GetCommandObject(dBConn.con);
                    dbCommand.CommandType = CommandType.Text;
                    dbCommand.CommandText = commandText;
                    DbDataAdapter dataAdapter = DBConn.GetDataAdapter(dBConn.con);
                    dataAdapter.SelectCommand = dbCommand;
                    DataTable dataTable = new DataTable();
                    dataAdapter.Fill(dataTable);
                    if (dataTable.Rows.Count > 0)
                    {
                        string commandText2 = string.Concat(new object[]
                        {
                            "delete from group_detail where grouptype = 'zone' and group_id = ",
                            dataTable.Rows[0]["group_id"],
                            " and dest_id =",
                            dataTable.Rows[0]["dest_id"]
                        });
                        dbCommand.CommandText = commandText2;
                        dbCommand.ExecuteNonQuery();
                    }
                    string commandText3 = "delete from zone_info where zone_nm = '" + str_zonename + "'";
                    dbCommand.CommandText = commandText3;
                    int result = dbCommand.ExecuteNonQuery();
                    dbCommand.Parameters.Clear();
                    DBCacheStatus.ZONE = true;
                    DBCacheStatus.DBSyncEventSet(true, new string[]
                    {
                        "DBSyncEventName_Service_ZONE"
                    });
                    return(result);
                }
            }
            catch (Exception ex)
            {
                DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace);
            }
            finally
            {
                try
                {
                    dbCommand.Dispose();
                }
                catch
                {
                }
                if (dBConn != null)
                {
                    dBConn.close();
                }
            }
            return(-1);
        }
示例#21
0
        public int UpdateSensorThreshold(DBConn conn)
        {
            if (this.id < 1)
            {
                return(-1);
            }
            if (this.device_id < 1)
            {
                return(-1);
            }
            DbCommand dbCommand = new OleDbCommand();

            try
            {
                if (conn.con != null)
                {
                    dbCommand             = DBConn.GetCommandObject(conn.con);
                    dbCommand.CommandType = CommandType.Text;
                    string text = "update device_sensor_info set max_humidity=?,min_humidity=?,max_temperature=?,min_temperature=?,max_press=?,min_press=?  where id=" + this.id;
                    text = "update device_sensor_info set ";
                    text = text + "max_humidity=" + CultureTransfer.ToString(this.max_humidity);
                    text = text + ",min_humidity=" + CultureTransfer.ToString(this.min_humidity);
                    text = text + ",max_temperature=" + CultureTransfer.ToString(this.max_temperature);
                    text = text + ",min_temperature=" + CultureTransfer.ToString(this.min_temperature);
                    text = text + ",max_press=" + CultureTransfer.ToString(this.max_press);
                    text = text + ",min_press=" + CultureTransfer.ToString(this.min_press);
                    text = text + "  where id= " + this.id;
                    dbCommand.CommandText = text;
                    int result = dbCommand.ExecuteNonQuery();
                    dbCommand.Parameters.Clear();
                    try
                    {
                        dbCommand.Dispose();
                    }
                    catch
                    {
                    }
                    return(result);
                }
            }
            catch (Exception ex)
            {
                DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace);
                try
                {
                    dbCommand.Dispose();
                }
                catch
                {
                }
            }
            finally
            {
                try
                {
                    dbCommand.Dispose();
                }
                catch
                {
                }
            }
            return(-1);
        }