Example #1
0
        public Dictionary <int, GroupInfo> GetAllGroupInfos(ref string errMessage)
        {
            Database db = DatabaseFactory.CreateDatabase();

            errMessage = "";
            Dictionary <int, GroupInfo> list = new Dictionary <int, GroupInfo>();

            try
            {
                GroupInfo  oGroupInfo;
                DeviceInfo oDevice;
                DataSet    ds = GroupDataAccess.GetAllGroupInfo(db);
                DataSet    dsDevice;
                DataSet    dsCamera;
                CameraInfo oCamera;
                DataSet    dsAlarm;
                AlarmInfo  oAlarm;
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    oGroupInfo            = new GroupInfo(ds.Tables[0].Rows[i]);
                    dsDevice              = DeviceDataAccess.GetDeviceInfoByGroupId(db, oGroupInfo.GroupID);
                    oGroupInfo.ListDevice = new Dictionary <int, DeviceInfo>();
                    foreach (DataRow dr in dsDevice.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);
                    }
                    list.Add(oGroupInfo.GroupID, oGroupInfo);
                }
                return(list);
            }
            catch (Exception ex)
            {
                errMessage = ex.Message + ex.StackTrace;
                logger.Error("Error Message:" + ex.Message + " Trace:" + ex.StackTrace);
                return(null);
            }
        }
Example #2
0
        public DeviceInfo GetDeviceInfoByDeviceName(ref string errMessage, string deviceName)
        {
            Database db = DatabaseFactory.CreateDatabase();

            errMessage = "";
            try
            {
                DataSet ds = DeviceDataAccess.GetDeviceInfoByDeviceName(db, deviceName);
                if (ds.Tables[0].Rows.Count == 0)
                {
                    return(null);
                }
                DataSet    dsCamera;
                CameraInfo oCamera;

                DeviceInfo oDeviceInfo = new DeviceInfo(ds.Tables[0].Rows[0]);
                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>();
                DataSet   dsAlarm;
                AlarmInfo oAlarm;
                dsAlarm = AlarmDataAccess.GetAlarmInfoByDeviceId(db, oDeviceInfo.DeviceId);
                foreach (DataRow drAlarm in dsAlarm.Tables[0].Rows)
                {
                    oAlarm = new AlarmInfo(drAlarm);
                    oDeviceInfo.ListAlarm.Add(oAlarm.AlarmId, oAlarm);
                }


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