コード例 #1
0
        public Dictionary<int, GroupSwitchGroup> GetAllGroupSwitchGroups(ref string errMessage)
        {
            Database db = DatabaseFactory.CreateDatabase();
            errMessage = "";
            var list = new Dictionary<int, GroupSwitchGroup>();
            try
            {
                GroupSwitchGroup groupSwitchGroup;
                DataSet ds = GroupSwitchGroupDataAccess.GetAllGroupSwitchGroupInfo(db);
                DataSet groupSwitchDetail;
                GroupSwitchDetailInfo groupSwitchDetailInfo;
                CameraMonitorPairInfo cameraMonitorPairInfo;
                //对于每一个群组切换的组
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    groupSwitchGroup = new GroupSwitchGroup(ds.Tables[0].Rows[i]);
                    groupSwitchDetail = GroupSwitchDetailDataAccess.GetGroupSwitchDetailByGroupSwitchId(db, groupSwitchGroup.Id);
                    groupSwitchGroup.ListGroupSwitchDetailInfo = new Dictionary<int, GroupSwitchDetailInfo>();
                    //对于一个组中的所有与同步群组有联系的记录
                    foreach (DataRow drgsdi in groupSwitchDetail.Tables[0].Rows)
                    {
                        groupSwitchDetailInfo = new GroupSwitchDetailInfo(drgsdi);
                        //根据同步群组获取同步群组与摄像机、监视器的配对信息
                        DataSet dsCamMonPair = CameraMonitorPairDataAccess.GetCameraMonitorPairBySynGroupId(db,
                                            groupSwitchDetailInfo.SynGroupId);
                        groupSwitchDetailInfo.ListCameraMonitorPair = new Dictionary<int, CameraMonitorPairInfo>();
                        foreach (DataRow drCmP in dsCamMonPair.Tables[0].Rows)
                        {
                            cameraMonitorPairInfo = new CameraMonitorPairInfo(drCmP);
                            groupSwitchDetailInfo.ListCameraMonitorPair.Add(cameraMonitorPairInfo.CameraMonitorPairId, cameraMonitorPairInfo);
                        }

                        groupSwitchGroup.ListGroupSwitchDetailInfo.Add(groupSwitchDetailInfo.Id, groupSwitchDetailInfo);
                    }

                    list.Add(groupSwitchGroup.Id, groupSwitchGroup);
                }
                return list;

            }
            catch (Exception ex)
            {
                errMessage = ex.Message + ex.StackTrace;
                Logger.Error("Error Message:" + ex.Message + " Trace:" + ex.StackTrace);
                return null;
            }
        }
コード例 #2
0
        public static int Insert(Database db, GroupSwitchGroup oGroupInfo)
        {
            StringBuilder sbField = new StringBuilder();
            StringBuilder sbValue = new StringBuilder();
            sbField.Append("INSERT INTO GroupSwitchGroup(");
            sbValue.Append("values(");
            sbField.Append("Name");
            sbValue.AppendFormat("'{0}'", oGroupInfo.Name);
            sbField.Append(",Description)");
            sbValue.AppendFormat(",'{0}')", oGroupInfo.Description);
            string cmdText = sbField.ToString() + " " + sbValue.ToString() + "";
            try
            {
                return db.ExecuteNonQuery(CommandType.Text, cmdText);

            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
コード例 #3
0
        public static int Update(Database db, GroupSwitchGroup oGroupInfo)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("update GroupSwitchGroup set");
            sb.AppendFormat(" Name='{0}'", oGroupInfo.Name);
            sb.AppendFormat(",Description='{0}'", oGroupInfo.Description);
            sb.AppendFormat(" where ID={0})", oGroupInfo.Id);
            string cmdText = sb.ToString();
            try
            {
                return db.ExecuteNonQuery(CommandType.Text, cmdText);

            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
コード例 #4
0
        public int Update(ref string errMessage, GroupSwitchGroup groupSwitchGroup)
        {
            Database db = DatabaseFactory.CreateDatabase();
            errMessage = "";
            try
            {
                return GroupSwitchGroupDataAccess.Update(db, groupSwitchGroup);

            }
            catch (Exception ex)
            {
                errMessage = ex.Message + ex.StackTrace;
                Logger.Error("Error Message:" + ex.Message + " Trace:" + ex.StackTrace);
                return -1;
            }
        }
コード例 #5
0
        public GroupSwitchGroup GetGroupSwitchGroupById(ref string errMessage, int groupSwitchGroupId)
        {
            Database db = DatabaseFactory.CreateDatabase();
            errMessage = "";
            try
            {
                DataSet ds = GroupSwitchGroupDataAccess.GetGroupSwitchGroupById(db, groupSwitchGroupId);
                if (ds.Tables[0].Rows.Count == 0)
                {
                    return null;
                }
                var groupSwitchGroup = new GroupSwitchGroup(ds.Tables[0].Rows[0]) {ListGroupSwitchDetailInfo = new Dictionary<int, GroupSwitchDetailInfo>()};

                var groupSwitchDetail = GroupSwitchDetailDataAccess.GetGroupSwitchDetailByGroupSwitchId(db, groupSwitchGroup.Id);
                groupSwitchGroup.ListGroupSwitchDetailInfo = new Dictionary<int, GroupSwitchDetailInfo>();
                //对于一个组中的所有与同步群组有联系的记录
                foreach (DataRow drgsdi in groupSwitchDetail.Tables[0].Rows)
                {
                    var groupSwitchDetailInfo = new GroupSwitchDetailInfo(drgsdi);
                    //根据同步群组获取同步群组与摄像机、监视器的配对信息
                    DataSet dsCamMonPair = CameraMonitorPairDataAccess.GetCameraMonitorPairBySynGroupId(db,
                                        groupSwitchDetailInfo.SynGroupId);
                    groupSwitchDetailInfo.ListCameraMonitorPair = new Dictionary<int, CameraMonitorPairInfo>();
                    foreach (DataRow drCmP in dsCamMonPair.Tables[0].Rows)
                    {
                        var cameraMonitorPairInfo = new CameraMonitorPairInfo(drCmP);
                        groupSwitchDetailInfo.ListCameraMonitorPair.Add(cameraMonitorPairInfo.CameraMonitorPairId, cameraMonitorPairInfo);
                    }

                    groupSwitchGroup.ListGroupSwitchDetailInfo.Add(groupSwitchDetailInfo.Id, groupSwitchDetailInfo);
                }
                return groupSwitchGroup;

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