示例#1
0
        public void Delete(string groupName, int siteId)
        {
            var contentGroupParms = new IDataParameter[]
            {
                GetParameter(ParmGroupName, DataType.VarChar, 255, groupName),
                GetParameter(ParmSiteId, DataType.Integer, siteId)
            };

            ExecuteNonQuery(SqlDelete, contentGroupParms);

            ContentGroupManager.ClearCache();
        }
示例#2
0
        public void Update(ContentGroupInfo contentGroup)
        {
            var updateParms = new IDataParameter[]
            {
                GetParameter(ParmDescription, DataType.Text, contentGroup.Description),
                GetParameter(ParmGroupName, DataType.VarChar, 255, contentGroup.GroupName),
                GetParameter(ParmSiteId, DataType.Integer, contentGroup.SiteId)
            };

            ExecuteNonQuery(SqlUpdate, updateParms);

            ContentGroupManager.ClearCache();
        }
示例#3
0
        //     public ContentGroupInfo GetContentGroupInfo(string groupName, int siteId)
        //     {
        //         ContentGroupInfo contentGroup = null;

        //         string sqlString =
        //             $"SELECT GroupName, SiteId, Taxis, Description FROM siteserver_ContentGroup WHERE GroupName = @GroupName AND SiteId = {siteId}";

        //         var selectParms = new IDataParameter[]
        //{
        //	GetParameter(ParmGroupName, DataType.VarChar, 255, groupName)
        //};

        //         using (var rdr = ExecuteReader(sqlString, selectParms))
        //         {
        //             if (rdr.Read())
        //             {
        //                 var i = 0;
        //                 contentGroup = new ContentGroupInfo(GetString(rdr, i++), GetInt(rdr, i++), GetInt(rdr, i++), GetString(rdr, i));
        //             }
        //             rdr.Close();
        //         }

        //         return contentGroup;
        //     }

        private void SetTaxis(int siteId, string groupName, int taxis)
        {
            var sqlString =
                $"UPDATE {TableName} SET Taxis = {taxis} WHERE (GroupName = @GroupName AND SiteId = {siteId})";
            var updateParms = new IDataParameter[]
            {
                GetParameter(ParmGroupName, DataType.VarChar, 255, groupName)
            };

            ExecuteNonQuery(sqlString, updateParms);

            ContentGroupManager.ClearCache();
        }
示例#4
0
        public void Insert(ContentGroupInfo contentGroup)
        {
            var maxTaxis = GetMaxTaxis(contentGroup.SiteId);

            contentGroup.Taxis = maxTaxis + 1;

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

            ExecuteNonQuery(SqlInsert, insertParms);

            ContentGroupManager.ClearCache();
        }
示例#5
0
        public void UpdateTaxisToDown(int siteId, string groupName)
        {
            //Get Lower Taxis and ID
            //string sqlString =
            //    $"SELECT TOP 1 GroupName, Taxis FROM siteserver_ContentGroup WHERE (Taxis < (SELECT Taxis FROM siteserver_ContentGroup WHERE GroupName = @GroupName AND SiteId = {siteId}) AND SiteId = {siteId}) ORDER BY Taxis DESC";
            var sqlString = SqlUtils.ToTopSqlString("siteserver_ContentGroup", "GroupName, Taxis",
                                                    $"WHERE (Taxis < (SELECT Taxis FROM siteserver_ContentGroup WHERE GroupName = @GroupName AND SiteId = {siteId}) AND SiteId = {siteId})",
                                                    "ORDER BY Taxis DESC", 1);

            var selectParms = new IDataParameter[]
            {
                GetParameter(ParmGroupName, DataType.VarChar, 255, groupName)
            };
            var lowerGroupName = string.Empty;
            var lowerTaxis     = 0;

            using (var rdr = ExecuteReader(sqlString, selectParms))
            {
                if (rdr.Read())
                {
                    lowerGroupName = GetString(rdr, 0);
                    lowerTaxis     = GetInt(rdr, 1);
                }
                rdr.Close();
            }

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

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

            ContentGroupManager.ClearCache();
        }