Ejemplo n.º 1
0
        public int Update(ref string errMessage, AlarmInfo oAlarmInfo)
        {
            Database db = DatabaseFactory.CreateDatabase();
            errMessage = "";
            try
            {
                return AlarmDataAccess.Update(db, oAlarmInfo);

            }
            catch (Exception ex)
            {
                errMessage = ex.Message + ex.StackTrace;
                logger.Error("Error Message:" + ex.Message + " Trace:" + ex.StackTrace);
                return -1;
            }
        }
Ejemplo n.º 2
0
        public Dictionary<int, AlarmInfo> GetAllAlarmInfo(ref string errMessage)
        {
            Database db = DatabaseFactory.CreateDatabase();
            errMessage = "";
            Dictionary<int, AlarmInfo> list = new Dictionary<int, AlarmInfo>();
            try
            {

                DataSet ds = AlarmDataAccess.GetAllAlarmInfo(db);

                AlarmInfo alarmInfo;
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    alarmInfo = new AlarmInfo(ds.Tables[0].Rows[i]);
                    list.Add(alarmInfo.AlarmId, alarmInfo);

                }
                return list;

            }
            catch (Exception ex)
            {
                errMessage = ex.Message + ex.StackTrace;
                logger.Error("Error Message:" + ex.Message + " Trace:" + ex.StackTrace);
                return null;
            }
        }
Ejemplo n.º 3
0
        public static int Update(Database db, AlarmInfo oCameraInfo)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("update AlarmInfo set");
            sb.AppendFormat(" Name='{0}'", oCameraInfo.Name);
            sb.AppendFormat(",Description='{0}'", oCameraInfo.Description);
            sb.AppendFormat(",IsValid={0}", oCameraInfo.IsValid);
            sb.AppendFormat(",ChannelNo={0} ", oCameraInfo.ChannelNo);
            sb.AppendFormat(" where AlarmId={0})", oCameraInfo.AlarmId);
            string cmdText = sb.ToString();
            try
            {
                return db.ExecuteNonQuery(CommandType.Text, cmdText);

            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
Ejemplo n.º 4
0
        public static int Insert(Database db, AlarmInfo oCameraInfo)
        {
            StringBuilder sbField = new StringBuilder();
            StringBuilder sbValue = new StringBuilder();
            sbField.Append("INSERT INTO AlarmInfo(");
            sbValue.Append("values(");
            sbField.Append("DeviceId");
            sbValue.AppendFormat("{0}", oCameraInfo.DeviceId);
            sbField.Append(",Name");
            sbValue.AppendFormat(",'{0}'", oCameraInfo.Name);
            sbField.Append(",Description");
            sbValue.AppendFormat(",'{0}'", oCameraInfo.Description);
            sbField.Append(",IsValid");
            sbValue.AppendFormat(",{0}", oCameraInfo.IsValid);
            sbField.Append(",ChannelNo)");
            sbValue.AppendFormat(",{0})", oCameraInfo.ChannelNo);
            string cmdText = sbField + " " + sbValue ;
            try
            {
                return db.ExecuteNonQuery(CommandType.Text, cmdText);

            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
Ejemplo n.º 5
0
        public Dictionary<int, DeviceInfo> GetDeviceInfoByGroupId(ref string errMessage, int GroupId)
        {
            Database db = DatabaseFactory.CreateDatabase();
            errMessage = "";
            try
            {
                Dictionary<int, DeviceInfo> list = new Dictionary<int, DeviceInfo>();
                DataSet ds = DeviceDataAccess.GetDeviceInfoByGroupId(db, GroupId);
                if (ds.Tables[0].Rows.Count == 0)
                {
                    return null;
                }
                DataSet dsCamera;
                CameraInfo oCamera;
                DeviceInfo oDeviceInfo;
                DataSet dsAlarm;
                AlarmInfo oAlarm;
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    oDeviceInfo = new DeviceInfo(ds.Tables[0].Rows[i]);

                    oDeviceInfo.ListCamera = new Dictionary<int, CameraInfo>();

                    dsCamera = CameraDataAccess.GetCamInfoByDeviceId(db, oDeviceInfo.DeviceId);
                    foreach (DataRow drCam in dsCamera.Tables[0].Rows)
                    {
                        oCamera = new CameraInfo(drCam);
                        oDeviceInfo.ListCamera.Add(oCamera.CameraId, oCamera);
                    }

                    oDeviceInfo.ListAlarm = new Dictionary<int, AlarmInfo>();

                    dsAlarm = AlarmDataAccess.GetAlarmInfoByDeviceId(db, oDeviceInfo.DeviceId);
                    foreach (DataRow drAlarm in dsAlarm.Tables[0].Rows)
                    {
                        oAlarm = new AlarmInfo(drAlarm);
                        oDeviceInfo.ListAlarm.Add(oAlarm.AlarmId, oAlarm);
                    }

                    list.Add(oDeviceInfo.DeviceId, oDeviceInfo);

                }
                return list;

            }
            catch (Exception ex)
            {
                errMessage = ex.Message + ex.StackTrace;
                logger.Error("Error Message:" + ex.Message + " Trace:" + ex.StackTrace);
                return null;
            }
        }
Ejemplo n.º 6
0
        public GroupInfo GetGroupInfoByGroupName(ref string errMessage, string groupName)
        {
            Database db = DatabaseFactory.CreateDatabase();
            errMessage = "";
            try
            {
                DataSet ds = GroupDataAccess.GetGroupInfoByGroupName(db, groupName);
                if (ds.Tables[0].Rows.Count == 0)
                {
                    return null;
                }
                DataSet dsDevice;
                DataSet dsCamera;
                CameraInfo oCamera;
                DeviceInfo oDevice;
                DataSet dsAlarm;
                AlarmInfo oAlarm;

                GroupInfo oGroupInfo = new GroupInfo(ds.Tables[0].Rows[0]);
                dsDevice = DeviceDataAccess.GetDeviceInfoByGroupId(db, oGroupInfo.GroupID);
                oGroupInfo.ListDevice = new Dictionary<int, DeviceInfo>();
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    oDevice = new DeviceInfo(dr);
                    oDevice.ListCamera = new Dictionary<int, CameraInfo>();
                    dsCamera = CameraDataAccess.GetCamInfoByDeviceId(db, oDevice.DeviceId);
                    foreach (DataRow drCam in dsCamera.Tables[0].Rows)
                    {
                        oCamera = new CameraInfo(drCam);
                        oDevice.ListCamera.Add(oCamera.CameraId, oCamera);
                    }
                    oDevice.ListAlarm = new Dictionary<int, AlarmInfo>();
                    dsAlarm = AlarmDataAccess.GetAlarmInfoByDeviceId(db, oDevice.DeviceId);
                    foreach (DataRow drAlarm in dsAlarm.Tables[0].Rows)
                    {
                        oAlarm = new AlarmInfo(drAlarm);
                        oDevice.ListAlarm.Add(oAlarm.AlarmId, oAlarm);
                    }
                    oGroupInfo.ListDevice.Add(oDevice.DeviceId, oDevice);

                }

                return oGroupInfo;

            }
            catch (Exception ex)
            {
                errMessage = ex.Message + ex.StackTrace;
                logger.Error("Error Message:" + ex.Message + " Trace:" + ex.StackTrace);
                return null;
            }
        }