Пример #1
0
        protected string GetTagLink(Tag tag)
        {
            #region arguments

            if (tag == null)
            {
                throw new ArgumentNullException("tag");
            }

            #endregion

            string tagLink = "";

            DynamicPage dPage = Page as DynamicPage;
            if (dPage != null)
            {

                RouteValueDictionary rvd = new RouteValueDictionary();
                rvd.Add(Constants.PageRouteIdentifier, 1);

                if (!string.IsNullOrEmpty(tag.Name))
                {
                    rvd.Add(Constants.SearchRouteIdentifier, tag.Name);
                }

                tagLink = Page.GetRouteUrl(dPage.RouteName, rvd);
            }

            return tagLink;
        }
Пример #2
0
        public IList<Tag> GetTags(Guid key, long resourceId)
        {
            #region argument checking

            if (key == Guid.Empty)
            {
                throw new ArgumentException("key");
            }

            #endregion

            List<Tag> tags = new List<Tag>();

            SqlCommand command = new SqlCommand();
            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = @"Proc_Ratna_Tags_Get";

            AddParameter(command, "@SiteId", SqlDbType.Int, Jardalu.Ratna.Core.WebContext.Current.Site.Id);
            AddParameter(command, "@Key", SqlDbType.UniqueIdentifier, key);
            AddParameter(command, "@ResourceId", SqlDbType.BigInt, resourceId);

            SqlParameter errorCodeParameter = AddOutputParameter(command, "@ErrorCode", SqlDbType.BigInt);

            using (SqlConnection sqlConnection = new SqlConnection(ConnectionInformation.Instance.ConnectionString))
            {
                using (command)
                {
                    command.Connection = sqlConnection;
                    command.Connection.Open();

                    SqlDataReader reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        Tag tagCreated = new Tag();
                        tagCreated.Name = reader["Tag"] as string;
                        tagCreated.Weight = (int)reader["Weight"];
                        tags.Add(tagCreated);
                    }

                    if (!reader.IsClosed)
                    {
                        reader.Close();
                    }
                }
            }

            //read the error code
            long errorCode = (long)errorCodeParameter.Value;
            if (errorCode != NoErrorCode)
            {
                ThrowError(errorCode);
            }

            return tags;
        }