示例#1
0
        /// <summary>
        /// 获取告警类型数据
        /// </summary>
        /// <param name="whereStr"></param>
        /// <returns></returns>
        public DataTable GetAlarmList(QueryAlarmNew alarmNew, string groupId)
        {
            try
            {
                int intPazeSize = alarmNew.PageSize;
                int intNext = intPazeSize * (alarmNew.PageIndex - 1);

                string whereStr = "";
                string orderStr = "ORDER BY id desc";
                whereStr += " and ALARMTIME between '" + alarmNew.StartTime.ToString("yyyy-MM-dd 00:00:00") + "' and '" + alarmNew.EndTime.ToString("yyyy-MM-dd 23:59:59") + "'";
                if (alarmNew.AlarmLevel != "")
                {
                    whereStr += " and ALARMLEVEL = " + alarmNew.AlarmLevel;
                }
                if (alarmNew.AlarmStatus != "")
                {
                    whereStr += " and STATUS = " + alarmNew.AlarmStatus;
                }
                if (alarmNew.AlarmType != "")
                {
                    whereStr += " and alarmtype = " + alarmNew.AlarmType;
                }
                IList<string> lstAreaId = GetAlarmListAreaId(alarmNew.ObjectId, alarmNew.ObjType);
                IList<string> lstDeviceId = GetAlarmListDeviceId(alarmNew.ObjectId, alarmNew.ObjType);
                whereStr += " and (";
                if (lstAreaId.Count > 0)
                {
                    string strAreaId = string.Join(",", lstAreaId.ToArray());
                    whereStr += " ALARMOBJID in (" + strAreaId + ") and alarmObjType=32  ";
                }
                else
                {
                    whereStr += "1=2";
                }
                whereStr += " or ";
                if (lstDeviceId.Count > 0)
                {
                    string strDeviceId = string.Join(",", lstDeviceId.ToArray());
                    whereStr += " ALARMOBJID in (" + strDeviceId + ") and alarmObjType=31 ";
                }
                else
                {
                    whereStr += "1=2";
                }
                whereStr += ")";

                var cmd = new DataCommand("GetAlarmList", new SqlCustomDbCommand());
                cmd.ReplaceParameterValue("#PageSize#", intPazeSize.ToString());
                cmd.ReplaceParameterValue("#Next#", intNext.ToString());
                cmd.ReplaceParameterValue("#whereStr#", whereStr);
                cmd.ReplaceParameterValue("#orderStr#", orderStr);
                return cmd.ExecuteDataSet().Tables[0];
            }
            catch (Exception ex)
            {
                return null;
            }
        }
示例#2
0
        /// <summary>
        /// 获取告警类型
        /// </summary>
        /// <param name="whereStr"></param>
        /// <returns></returns>
        public int GetAlarmIndexCount(QueryAlarmNew alarmNew)
        {
            int intPazeSize = alarmNew.PageSize;
            int intNext = intPazeSize * (alarmNew.PageIndex - 1);
            DataTable dtAlarmType = new DataTable();
            string strSql = @" SELECT count(id) from AlarmAreaDevice where 1=1";
            string whereStr = "";
            whereStr += " and ALARMTIME between '" + alarmNew.StartTime.ToString("yyyy-MM-dd 00:00:00") + "' and '" + alarmNew.EndTime.ToString("yyyy-MM-dd 23:59:59") + "'";
            if (alarmNew.AlarmStatus != "")
            {
                whereStr += " and STATUS = " + alarmNew.AlarmStatus;
            }

            if (!whereStr.Equals(string.Empty))
            {
                strSql = strSql + whereStr;
            }

            // Object obj = SqlHelper.GetSingle(strSql);
            var cmd = new DataCommand("GetBaseDataItem", new SqlCustomDbCommand());
            cmd.ReplaceParameterValue("#SQLSTR#", strSql);
            return int.Parse(cmd.ExecuteScalar().ToString());
        }
示例#3
0
 public ResultAlarmNewList GetAlarmList(QueryAlarmNew ParamAlarm, string groupId)
 {
     return new NTS.WEB.BLL.Alarm().GetAlarmList(ParamAlarm, groupId);
 }
示例#4
0
        /// <summary>
        /// 获取告警记录数据。
        /// </summary>
        /// <param name="alarmList"></param>
        /// <returns></returns>
        public ResultAlarmNewList GetAlarmList(QueryAlarmNew ParamAlarm, string groupId)
        {
            ResultAlarmNewList alarmList = new ResultAlarmNewList();

            ExecuteProcess process = new ExecuteProcess();
            process.ActionName = "";
            process.ActionTime = System.DateTime.Now;
            process.Success = true;
            process.ExceptionMsg = "";

            alarmList.ActionInfo = process;

            List<AlarmNewList> lstAlarm = new List<AlarmNewList>();

            DataTable dttype = new DataTable();
            int total = 0;
            if (ParamAlarm.AllAlarm == false)
            {
                dttype = _Alarm.GetAlarmList(ParamAlarm, groupId);
                total = _Alarm.GetAlarmListCount(ParamAlarm);
            }
            else
            {
                dttype = _Alarm.GetAlarmListIndex(ParamAlarm);
                total = _Alarm.GetAlarmIndexCount(ParamAlarm);
            }
            int pageCount = 0;
            if (total > 0)
            {
                pageCount = (total - 1) / ParamAlarm.PageSize + 1;
            }
            foreach (DataRow row in dttype.Rows)
            {
                AlarmNewList type = new AlarmNewList();
                type.Time = row["ALARMTIME"].ToString();
                type.Object = row["ALARMOBJNAME"].ToString();
                type.Position = ""; //row["LOCATION"].ToString();
                if (row["LOCATION"] != DBNull.Value)
                {
                    type.Position = row["LOCATION"].ToString();
                }
                type.Info = row["ALARMCONTENT"] == DBNull.Value ? "" : row["ALARMCONTENT"].ToString();
                type.AlarmItem = row["ALARMTYPENAME"] == DBNull.Value ? "" : row["ALARMTYPENAME"].ToString(); //告警类型名称
                type.Class = row["ALARMLEVEL"] == DBNull.Value ? "" : row["ALARMLEVEL"].ToString(); //告警等级
                type.AlarmStatus = "未知"; //告警类型
                if (row["STATUS"] != DBNull.Value)
                {
                    switch (row["STATUS"].ToString())
                    {
                        case "0":
                            type.AlarmStatus = "正在告警";
                            break;
                        case "1":
                            type.AlarmStatus = "已确认";
                            break;
                        case "2":
                            type.AlarmStatus = "已恢复";
                            break;
                        case "3":
                            type.AlarmStatus = "已处理";
                            break;
                        case "4":
                            type.AlarmStatus = "已取消";
                            break;
                        default:
                            type.AlarmStatus = "未知";
                            break;
                    }
                }
                lstAlarm.Add(type);
            }
            alarmList.data = lstAlarm;
            int[] intPageCount = new int[pageCount];
            for (int i = 0; i < pageCount; i++)
            {
                intPageCount[i] = i + 1;
            }
            alarmList.pages = intPageCount;
            alarmList.total = pageCount;
            alarmList.current = ParamAlarm.PageIndex;
            return alarmList;
        }
示例#5
0
        /// <summary>
        /// 获取告警类型数据
        /// </summary>
        /// <param name="whereStr"></param>
        /// <returns></returns>
        public DataTable GetAlarmListOld(QueryAlarmNew alarmNew)
        {
            int intPazeSize = alarmNew.PageSize;
            int intNext = intPazeSize * (alarmNew.PageIndex - 1);
            DataTable dtAlarmType = new DataTable();
            string strSql = @" SELECT distinct TOP " + intPazeSize + " id, ALARMOBJID,ALARMTYPE,ALARMTYPENAME,ALARMLEVEL,ALARMOBJNAME,ALARMCONTENT,STATUS,ALARMTIME,location " +
                 " from AlarmAreaDevice WHERE id not in " +
               "  ( SELECT TOP " + intNext + " id from AlarmAreaDevice ) and 1=1 ";
            string whereStr = "";
            string orderStr = "ORDER BY id desc";
            whereStr += " and ALARMTIME between '" + alarmNew.StartTime.ToString("yyyy-MM-dd 00:00:00") + "' and '" + alarmNew.EndTime.ToString("yyyy-MM-dd 23:59:59") + "'";
            if (alarmNew.AlarmLevel != "")
            {
                whereStr += " and ALARMLEVEL = " + alarmNew.AlarmLevel;
            }
            if (alarmNew.AlarmStatus != "")
            {
                whereStr += " and STATUS = " + alarmNew.AlarmStatus;
            }
            if (alarmNew.AlarmType != "")
            {
                whereStr += " and alarmtype = " + alarmNew.AlarmType;
            }
            IList<string> lstAreaId = GetAlarmListAreaId(alarmNew.ObjectId, alarmNew.ObjType);
            IList<string> lstDeviceId = GetAlarmListDeviceId(alarmNew.ObjectId, alarmNew.ObjType);
            whereStr += " and (";
            if (lstAreaId.Count > 0)
            {
                string strAreaId = string.Join(",", lstAreaId.ToArray());
                whereStr += " ALARMOBJID in (" + strAreaId + ") and alarmObjType=32  ";
            }
            else
            {
                whereStr += "1=2";
            }
            whereStr += " or ";
            if (lstDeviceId.Count > 0)
            {
                string strAreaId = string.Join(",", lstAreaId.ToArray());
                whereStr += " ALARMOBJID in (" + strAreaId + ") and alarmObjType=31 ";
            }
            else
            {
                whereStr += "1=2";
            }
            whereStr += ")";

            if (!whereStr.Equals(string.Empty))
            {
                strSql = strSql + whereStr;
            }
            if (!orderStr.Equals(string.Empty))
            {
                strSql = strSql + orderStr;
            }
            dtAlarmType = SqlHelper.Query(strSql).Tables[0];
            return dtAlarmType;
        }
示例#6
0
        /// <summary>
        /// 获取告警类型数据
        /// </summary>
        /// <param name="whereStr"></param>
        /// <returns></returns>
        public DataTable GetAlarmListIndex(QueryAlarmNew alarmNew)
        {
            int intPazeSize = alarmNew.PageSize;
            int intNext = intPazeSize * (alarmNew.PageIndex - 1);
            DataTable dtAlarmType = new DataTable();
            //string strSql = @" SELECT distinct TOP " + intPazeSize + " id, ALARMOBJID,ALARMTYPE,ALARMTYPENAME,ALARMLEVEL,ALARMOBJNAME,ALARMCONTENT,STATUS,ALARMTIME,location " +
            //     " from AlarmAreaDevice WHERE id not in " +
            //   "  ( SELECT TOP " + intNext + " id from AlarmAreaDevice ) and 1=1 ";
            string whereStr = "";
            string orderStr = "ORDER BY id desc";
            whereStr += " and ALARMTIME between '" + alarmNew.StartTime.ToString("yyyy-MM-dd 00:00:00") + "' and '" + alarmNew.EndTime.ToString("yyyy-MM-dd 23:59:59") + "'";
            if (alarmNew.AlarmStatus != "")
            {
                whereStr += " and STATUS = " + alarmNew.AlarmStatus;
            }

            var cmd = new DataCommand("GetAlarmListIndex", new SqlCustomDbCommand());
            cmd.ReplaceParameterValue("#PageSize#", intPazeSize.ToString());
            cmd.ReplaceParameterValue("#Next#", intNext.ToString());
            cmd.ReplaceParameterValue("#whereStr#", whereStr);
            cmd.ReplaceParameterValue("#orderStr#", orderStr);
            return cmd.ExecuteDataSet().Tables[0];
        }
示例#7
0
        /// <summary>
        /// 获取告警类型
        /// </summary>
        /// <param name="whereStr"></param>
        /// <returns></returns>
        public int GetAlarmListCount(QueryAlarmNew alarmNew)
        {
            int intPazeSize = alarmNew.PageSize;
            int intNext = intPazeSize * (alarmNew.PageIndex - 1);
            DataTable dtAlarmType = new DataTable();

            string whereStr = "";
            whereStr += " and ALARMTIME between '" + alarmNew.StartTime.ToString("yyyy-MM-dd 00:00:00") + "' and '" + alarmNew.EndTime.ToString("yyyy-MM-dd 23:59:59") + "'";
            if (alarmNew.AlarmLevel != "")
            {
                whereStr += " and ALARMLEVEL = " + alarmNew.AlarmLevel;
            }
            if (alarmNew.AlarmStatus != "")
            {
                whereStr += " and STATUS = " + alarmNew.AlarmStatus;
            }
            if (alarmNew.AlarmType != "")
            {
                whereStr += " and alarmtype = " + alarmNew.AlarmType;
            }
            IList<string> lstAreaId = GetAlarmListAreaId(alarmNew.ObjectId, alarmNew.ObjType);
            IList<string> lstDeviceId = GetAlarmListDeviceId(alarmNew.ObjectId, alarmNew.ObjType);
            whereStr += " and (";
            if (lstAreaId.Count > 0)
            {
                string strAreaId = string.Join(",", lstAreaId.ToArray());
                whereStr += " ALARMOBJID in (" + strAreaId + ") ";
            }
            else
            {
                whereStr += "1=2";
            }
            whereStr += " or ";
            if (lstDeviceId.Count > 0)
            {
                string strDeviceId = string.Join(",", lstDeviceId.ToArray());
                whereStr += " ALARMOBJID in (" + strDeviceId + ") ";
            }
            else
            {
                whereStr += "1=2";
            }
            whereStr += ")";

            var cmd = new DataCommand("GetAlarmListCount", new SqlCustomDbCommand());
            cmd.ReplaceParameterValue("#whereStr#", whereStr);
            return int.Parse(cmd.ExecuteScalar().ToString());
        }