Beispiel #1
0
        /// <summary>
        /// Does the correct call to the database to get the most recent articles
        /// </summary>
        /// <param name="userID">The user id to look for</param>
        /// <param name="siteID">SiteID of the articles list to get</param>
        /// <param name="skip">The number of articles to skip</param>
        /// <param name="show">The number of articles to show</param>
        /// <param name="whichType">Type of Articles to show</param>
        /// <param name="guideType">Type of Guide Article to show</param>
        /// <returns>Dataset</returns>
        IDnaDataReader GetUsersMostRecentEntries(int userID, int siteID, int skip, int show, ArticleListType whichType, int guideType)
        {
            IDnaDataReader dataReader;
            string storedProcedure = String.Empty;

	        // Check to see which procedures to call
	        // This depends on the whichType and guideType parameters
	        if (guideType > 0)
	        {
		        // We've been given a GuideType to filter on, call the relavent procedure depending on the status type
		        if (whichType == ArticleListType.ARTICLELISTTYPE_APPROVED)
		        {
                    storedProcedure = "getuserrecentapprovedentrieswithguidetype";
		        }
		        else if (whichType == ArticleListType.ARTICLELISTTYPE_NORMAL)
		        {
			        storedProcedure = "getuserrecententrieswithguidetype";
		        }
                else if (whichType == ArticleListType.ARTICLELISTTYPE_NORMALANDAPPROVED)
		        {
			        storedProcedure = "getuserrecentandapprovedentrieswithguidetype";
		        }
		        else
		        {
			        storedProcedure = "getusercancelledentrieswithguidetype";
		        }

                dataReader = InputContext.CreateDnaDataReader(storedProcedure);
                
                // Now add the guide type as a parameter
		        dataReader.AddParameter("guidetype", guideType);
	        }
	        else
	        {
		        // Just call the relavent procedure depending on the status type
		        if (whichType == ArticleListType.ARTICLELISTTYPE_APPROVED)
		        {
			        storedProcedure = "getuserrecentapprovedentries";
		        }
		        else if (whichType == ArticleListType.ARTICLELISTTYPE_NORMAL)
		        {
			        storedProcedure = "getuserrecententries";
		        }
                else if (whichType == ArticleListType.ARTICLELISTTYPE_NORMALANDAPPROVED)
		        {
			        storedProcedure = "getuserrecentandapprovedentries";
		        }
		        else
		        {
			        storedProcedure = "getusercancelledentries";
		        }

                dataReader = InputContext.CreateDnaDataReader(storedProcedure);
            }


            dataReader.AddParameter("userid", userID);
            dataReader.AddParameter("siteid", siteID);
            dataReader.AddParameter("currentsiteid", InputContext.CurrentSite.SiteID);
            //dataReader.AddParameter("firstindex", skip);
            //dataReader.AddParameter("lastindex", skip + show - 1);

            dataReader.Execute();

            return dataReader;
        }
 public ActionResult SearchByPage(string keyWord, long classifyId, ArticleListType listType, int pageIndex = 2)
 {
     return(PartialView(listType == ArticleListType.Image ? "_ImageList" : "_TextList", ArticleRepository.GetPagedList((keyWord ?? "").Trim(), classifyId, pageIndex, PageSize)));
 }
Beispiel #3
0
        /// <summary>
        /// Functions generates an Article List of the given type
        /// </summary>
        /// <param name="userID">The user of the Articles to get</param>
        /// <param name="siteID">Site of the Articles</param>
        /// <param name="skip">Number of Articles to skip</param>
        /// <param name="show">Number of Articles to show</param>
        /// <param name="whichType">Type of Articles to show</param>
        /// <param name="guideType">Type of Guide Article to show</param>
        /// <returns>Whether created ok</returns>
        private bool CreateArticleList(int userID, int siteID, int skip, int show, ArticleListType whichType, int guideType)
        {
            // check object is not already initialised
            if (userID <= 0 || show <= 0)
            {
                return false;
            }

            // Get the cache article list date
            DateTime expiryDate = CacheGetArticleListDate(userID, siteID);

            // Check to see if the article list is cached
            _cachedFileName = "AL" + userID.ToString() + "-" + Convert.ToString(skip + show - 1) + "-" + skip.ToString() + "-" + whichType.ToString() + "-" + siteID.ToString();
            // If we have a guidetype then add this as well. Leave it out when 0 will reuse older existing cached files.
            if (guideType > 0)
            {
                _cachedFileName += "-" + guideType.ToString();
            }
            _cachedFileName += ".xml";

            string cachedArticleList = "";
            if (InputContext.FileCacheGetItem("articlelist", _cachedFileName, ref expiryDate, ref cachedArticleList) && cachedArticleList.Length > 0)
            {
                // Create the journal from the cache
                CreateAndInsertCachedXML(cachedArticleList, "ARTICLE-LIST", true);

                // Finally update the relative dates and return
                UpdateRelativeDates();
                return true;
            }
            
            int count = show;

            XmlElement articleList = AddElementTag(RootElement, "ARTICLE-LIST");
            AddAttribute(articleList, "COUNT", show);
            AddAttribute(articleList, "SKIPTO", skip);

            // now set the list type attribute
            switch (whichType)
            {
                case ArticleListType.ARTICLELISTTYPE_APPROVED :
                {
                    AddAttribute(articleList, "TYPE", "USER-RECENT-APPROVED");
                    break;
                }
                case ArticleListType.ARTICLELISTTYPE_NORMAL : 
                {
                    AddAttribute(articleList, "TYPE", "USER-RECENT-ENTRIES"); 
                    break;
                }
                case ArticleListType.ARTICLELISTTYPE_CANCELLED : 
                {
                    AddAttribute(articleList, "TYPE", "USER-RECENT-CANCELLED"); 
                    break;
                }
                case ArticleListType.ARTICLELISTTYPE_NORMALANDAPPROVED : 
                {
                    AddAttribute(articleList, "TYPE", "USER-RECENT-NORMALANDAPPROVED"); 
                    break;
                }
                default: 
                {
                    AddAttribute(articleList, "TYPE", "USER-RECENT-ENTRIES"); 
                    break;
                }
            }

            using (IDnaDataReader dataReader = GetUsersMostRecentEntries(userID, siteID, skip, show, whichType, guideType))	// Get +1 so we know if there are more left
            {
                // Check to see if we found anything
                if (dataReader.HasRows && dataReader.Read())
                {
                    count = CreateList(articleList, dataReader, skip, show);
                }
            }
            //AddAttribute(commentsList, "COUNT", count);

            return true;
        }