コード例 #1
0
        public void Delete(int siteId, string groupName)
        {
            var sqlString = $"DELETE FROM {TableName} WHERE GroupName = @GroupName AND SiteId = @SiteId";

            var groupParms = new IDataParameter[]
            {
                GetParameter(ParmGroupName, DataType.VarChar, 255, groupName),
                GetParameter(ParmSiteId, DataType.Integer, siteId)
            };

            ExecuteNonQuery(sqlString, groupParms);

            var channelIdList = ChannelManager.GetChannelIdList(ChannelManager.GetChannelInfo(siteId, siteId), EScopeType.All, groupName, string.Empty, string.Empty);

            foreach (var channelId in channelIdList)
            {
                var channelInfo   = ChannelManager.GetChannelInfo(siteId, channelId);
                var groupNameList = TranslateUtils.StringCollectionToStringList(channelInfo.GroupNameCollection);
                groupNameList.Remove(groupName);
                channelInfo.GroupNameCollection = TranslateUtils.ObjectCollectionToString(groupNameList);
                DataProvider.ChannelDao.Update(channelInfo);
            }

            ChannelGroupManager.ClearCache();
        }
コード例 #2
0
        public void Update(ChannelGroupInfo groupInfo)
        {
            var sqlString = $"UPDATE {TableName} SET Description = @Description WHERE GroupName = @GroupName AND SiteId = @SiteId";

            var updateParms = new IDataParameter[]
            {
                GetParameter(ParmDescription, DataType.Text, groupInfo.Description),
                GetParameter(ParmGroupName, DataType.VarChar, 255, groupInfo.GroupName),
                GetParameter(ParmSiteId, DataType.Integer, groupInfo.SiteId)
            };

            ExecuteNonQuery(sqlString, updateParms);

            ChannelGroupManager.ClearCache();
        }
コード例 #3
0
        public void Insert(ChannelGroupInfo groupInfo)
        {
            var maxTaxis = GetMaxTaxis(groupInfo.SiteId);

            groupInfo.Taxis = maxTaxis + 1;

            var sqlString = $"INSERT INTO {TableName} (GroupName, SiteId, Taxis, Description) VALUES (@GroupName, @SiteId, @Taxis, @Description)";

            var insertParms = new IDataParameter[]
            {
                GetParameter(ParmGroupName, DataType.VarChar, 255, groupInfo.GroupName),
                GetParameter(ParmSiteId, DataType.Integer, groupInfo.SiteId),
                GetParameter(ParmTaxis, DataType.Integer, groupInfo.Taxis),
                GetParameter(ParmDescription, DataType.Text, groupInfo.Description)
            };

            ExecuteNonQuery(sqlString, insertParms);

            ChannelGroupManager.ClearCache();
        }
コード例 #4
0
        public void UpdateTaxisToUp(int siteId, string groupName)
        {
            //Get Higher Taxis and ID
            //var sqlString = "SELECT TOP 1 GroupName, Taxis FROM siteserver_ChannelGroup WHERE (Taxis > (SELECT Taxis FROM siteserver_ChannelGroup WHERE GroupName = @GroupName AND SiteId = @SiteId) AND SiteId = @SiteId) ORDER BY Taxis";
            var sqlString = SqlUtils.ToTopSqlString("siteserver_ChannelGroup", "GroupName, Taxis",
                                                    "WHERE (Taxis > (SELECT Taxis FROM siteserver_ChannelGroup WHERE GroupName = @GroupName AND SiteId = @SiteId) AND SiteId = @SiteId)",
                                                    "ORDER BY Taxis", 1);

            var higherGroupName = string.Empty;
            var higherTaxis     = 0;

            var parms = new IDataParameter[]
            {
                GetParameter(ParmGroupName, DataType.VarChar, 255, groupName),
                GetParameter(ParmSiteId, DataType.Integer, siteId)
            };

            using (var rdr = ExecuteReader(sqlString, parms))
            {
                if (rdr.Read())
                {
                    higherGroupName = GetString(rdr, 0);
                    higherTaxis     = GetInt(rdr, 1);
                }
                rdr.Close();
            }

            if (!string.IsNullOrEmpty(higherGroupName))
            {
                //Get Taxis Of Selected ID
                var selectedTaxis = GetTaxis(siteId, groupName);

                //Set The Selected Class Taxis To Higher Level
                SetTaxis(siteId, groupName, higherTaxis);
                //Set The Higher Class Taxis To Lower Level
                SetTaxis(siteId, higherGroupName, selectedTaxis);
            }

            ChannelGroupManager.ClearCache();
        }