private EmailDetailsToProcess CreateProcessorForEmail(IDnaDataReader reader) { EmailDetailsToProcess emailToProcess = new EmailDetailsToProcess(); emailToProcess.ID = reader.GetInt32("ID"); emailToProcess.Subject = reader.GetString("Subject"); emailToProcess.Body = reader.GetString("Body"); emailToProcess.FromAddress = reader.GetString("FromEmailAddress"); emailToProcess.ToAddress = reader.GetString("ToEmailAddress"); if (reader.Exists("CCAddress")) { emailToProcess.CCAddress = reader.GetString("CCAddress"); } return emailToProcess; }
/// <summary> /// Creates the commentforumdata from a given reader /// </summary> /// <param name="reader">The database reaser</param> /// <returns>A Filled comment forum object</returns> private CommentForum CommentForumCreateFromReader(IDnaDataReader reader) { var closingDate = reader.GetDateTime("forumclosedate"); //if (closingDate == null) //{ // closingDate = DateTime.MaxValue; //} var site = SiteList.GetSite(reader.GetStringNullAsEmpty("sitename")); var commentForum = new CommentForum(); commentForum.Title = reader.GetStringNullAsEmpty("Title"); commentForum.Id = reader.GetStringNullAsEmpty("UID"); commentForum.CanRead = reader.GetByteNullAsZero("canRead") == 1; commentForum.CanWrite = reader.GetByteNullAsZero("canWrite") == 1; commentForum.ParentUri = reader.GetStringNullAsEmpty("Url"); commentForum.SiteName = reader.GetStringNullAsEmpty("sitename"); commentForum.CloseDate = closingDate; commentForum.LastUpdate = reader.GetDateTime("LastUpdated"); if (reader.GetDateTime("lastposted") > commentForum.LastUpdate) { //use last posted as it is newer commentForum.LastUpdate = reader.GetDateTime("lastposted"); } commentForum.Updated = new DateTimeHelper(commentForum.LastUpdate); commentForum.Created = new DateTimeHelper(reader.GetDateTime("DateCreated")); commentForum.commentSummary = new CommentsSummary { Total = reader.GetInt32NullAsZero("ForumPostCount"), EditorPicksTotal = reader.GetInt32NullAsZero("editorpickcount") }; commentForum.ForumID = reader.GetInt32NullAsZero("forumid"); commentForum.isClosed = !commentForum.CanWrite || site.IsEmergencyClosed || site.IsSiteScheduledClosed(DateTime.Now) || (DateTime.Now > closingDate); //MaxCharacterCount = siteList.GetSiteOptionValueInt(site.SiteID, "CommentForum", "'MaxCommentCharacterLength") var replacements = new Dictionary<string, string>(); replacements.Add("commentforumid", reader.GetStringNullAsEmpty("uid")); replacements.Add("sitename", site.SiteName); if (reader.Exists("IsContactForm") && !reader.IsDBNull("IsContactForm")) { commentForum.isContactForm = true; commentForum.Uri = UriDiscoverability.GetUriWithReplacments(BasePath, UriDiscoverability.UriType.ContactFormById, replacements); commentForum.commentSummary.Uri = UriDiscoverability.GetUriWithReplacments(BasePath, UriDiscoverability.UriType.ContactFormById, replacements); } else { commentForum.Uri = UriDiscoverability.GetUriWithReplacments(BasePath, UriDiscoverability.UriType.CommentForumById, replacements); commentForum.commentSummary.Uri = UriDiscoverability.GetUriWithReplacments(BasePath, UriDiscoverability.UriType.CommentsByCommentForumId, replacements); } //get moderation status commentForum.ModerationServiceGroup = ModerationStatus.ForumStatus.Unknown; if (!reader.IsDBNull("moderationstatus")) { //if it is set for the specific forum commentForum.ModerationServiceGroup = (ModerationStatus.ForumStatus) (reader.GetTinyIntAsInt("moderationstatus")); } if (commentForum.ModerationServiceGroup == ModerationStatus.ForumStatus.Unknown) { //else fall back to site moderation status switch (site.ModerationStatus) { case ModerationStatus.SiteStatus.UnMod: commentForum.ModerationServiceGroup = ModerationStatus.ForumStatus.Reactive; break; case ModerationStatus.SiteStatus.PreMod: commentForum.ModerationServiceGroup = ModerationStatus.ForumStatus.PreMod; break; case ModerationStatus.SiteStatus.PostMod: commentForum.ModerationServiceGroup = ModerationStatus.ForumStatus.PostMod; break; default: commentForum.ModerationServiceGroup = ModerationStatus.ForumStatus.Reactive; break; } } commentForum.NotSignedInUserId = reader.GetInt32NullAsZero("NotSignedInUserId"); commentForum.allowNotSignedInCommenting = commentForum.NotSignedInUserId != 0; return commentForum; }
/// <summary> /// Creates and adds the returned User Xml block to a given parent post node from the passed user parameters with a prefix /// ie the field name of OwnerUserName, OwnerFirstNames /// </summary> /// <param name="dataReader">Data reader object</param> /// <param name="userID">The users id</param> /// <param name="prefix">The prefix of the field names for a different user in the same result set</param> /// <param name="parent">The parent Node to add the user xml to</param> /// <returns>XmlNode Containing user XML from the stored procedure</returns> public void AddPrefixedUserXMLBlock(IDnaDataReader dataReader, int userID, string prefix, XmlNode parent) { string userName = ""; if (dataReader.Exists(prefix + "UserName")) { userName = dataReader.GetStringNullAsEmpty(prefix + "UserName"); } else if (dataReader.Exists(prefix + "Name")) { userName = dataReader.GetStringNullAsEmpty(prefix + "Name"); } if (userName == String.Empty) { userName = "******" + userID.ToString(); } string identityUserId = ""; if (dataReader.Exists(prefix + "identityUserId")) { identityUserId = dataReader.GetStringNullAsEmpty(prefix + "identityUserId"); } string emailAddress = ""; if (dataReader.Exists(prefix + "Email")) { emailAddress = dataReader.GetStringNullAsEmpty(prefix + "Email"); } double zeigeistScore = 0.0; if (dataReader.DoesFieldExist(prefix + "ZeitgeistScore")) { zeigeistScore = dataReader.GetDoubleNullAsZero(prefix + "ZeitgeistScore"); } string siteSuffix = ""; if (dataReader.Exists(prefix + "SiteSuffix")) { siteSuffix = dataReader.GetStringNullAsEmpty(prefix + "SiteSuffix"); } string area = ""; if (dataReader.Exists(prefix + "Area")) { area = dataReader.GetStringNullAsEmpty(prefix + "Area"); } string title = ""; if (dataReader.Exists(prefix + "Title")) { title = dataReader.GetStringNullAsEmpty(prefix + "Title"); } int subQuota = 0; if (dataReader.Exists(prefix + "SubQuota")) { subQuota = dataReader.GetInt32NullAsZero(prefix + "SubQuota"); } int allocations = 0; if (dataReader.Exists(prefix + "Allocations")) { allocations = dataReader.GetInt32NullAsZero(prefix + "Allocations"); } int journal = 0; if (dataReader.Exists(prefix + "Journal")) { journal = dataReader.GetInt32NullAsZero(prefix + "Journal"); } bool isActive = false; if (dataReader.Exists(prefix + "Active") && !dataReader.IsDBNull(prefix + "Active")) { isActive = dataReader.GetBoolean(prefix + "Active"); } DateTime dateLastNotified = DateTime.MinValue; if (dataReader.Exists(prefix + "DateLastNotified") && dataReader.GetValue(prefix + "DateLastNotified") != DBNull.Value) { dateLastNotified = dataReader.GetDateTime(prefix + "DateLastNotified"); } DateTime dateJoined = DateTime.MinValue; if (dataReader.Exists(prefix + "DateJoined") && dataReader.GetValue(prefix + "DateJoined") != DBNull.Value) { dateJoined = dataReader.GetDateTime(prefix + "DateJoined"); } int forumPostedTo = -1; if (dataReader.Exists(prefix + "ForumPostedTo")) { forumPostedTo = dataReader.GetInt32NullAsZero(prefix + "ForumPostedTo"); } int masthead = -1; if (dataReader.Exists(prefix + "Masthead")) { masthead = dataReader.GetInt32NullAsZero(prefix + "Masthead"); } int sinbin = -1; if (dataReader.Exists(prefix + "SinBin")) { sinbin = dataReader.GetInt32NullAsZero(prefix + "SinBin"); } int forumID = -1; if (dataReader.Exists(prefix + "ForumID")) { forumID = dataReader.GetInt32NullAsZero(prefix + "ForumID"); } XmlNode userXML = GenerateUserXml(userID, userName, emailAddress, dataReader.GetStringNullAsEmpty(prefix + "FirstNames"), dataReader.GetStringNullAsEmpty(prefix + "LastName"), dataReader.GetInt32NullAsZero(prefix + "Status"), dataReader.GetInt32NullAsZero(prefix + "TaxonomyNode"), isActive, zeigeistScore, siteSuffix, area, title, journal, dateLastNotified, subQuota, allocations, dateJoined, forumID, forumPostedTo, masthead, sinbin, identityUserId); if (userXML != null) { XmlNode importxml = parent.OwnerDocument.ImportNode(userXML, true); parent.AppendChild(importxml); } }
/// <summary> /// Creates user object from given reader and user id /// </summary> /// <param name="reader"></param> /// <param name="userID"></param> /// <returns></returns> static public User CreateUserFromReader(IDnaDataReader reader, string prefix) { //IUser user = new User(_dnaDataReaderCreator, _dnaDiagnostics, _cacheManager); IUser user = new User(); if (reader.Exists(prefix + "userID")) { user.UserId = reader.GetInt32NullAsZero(prefix + "userID"); } else if (reader.Exists(prefix + "ID")) { user.UserId = reader.GetInt32NullAsZero(prefix + "ID"); } if (reader.Exists(prefix + "IdentityUserID")) { user.IdentityUserId = reader.GetStringNullAsEmpty(prefix + "IdentityUserId"); } if (reader.Exists(prefix + "IdentityUserName")) { user.IdentityUserName = reader.GetStringNullAsEmpty(prefix + "IdentityUserName"); } else if (reader.Exists(prefix + "LoginName")) { user.IdentityUserName = reader.GetStringNullAsEmpty(prefix + "LoginName"); } /* if (reader.Exists(prefix + "FirstNames")) { user.FirstNames = reader.GetStringNullAsEmpty(prefix + "FirstNames") ?? ""; } if(reader.Exists(prefix + "LastName")) { user.LastName = reader.GetStringNullAsEmpty(prefix + "LastName") ?? ""; } */ if(reader.Exists(prefix + "Status")) { user.Status= reader.GetInt32NullAsZero(prefix + "Status"); } if(reader.Exists(prefix + "TaxonomyNode")) { user.TaxonomyNode= reader.GetInt32NullAsZero(prefix + "TaxonomyNode"); } if (reader.Exists(prefix + "UserName")) { user.UserName = reader.GetStringNullAsEmpty(prefix + "UserName") ?? ""; } else if (reader.Exists(prefix + "Name")) { user.UserName = reader.GetStringNullAsEmpty(prefix + "Name") ?? ""; } if (user.UserName == String.Empty) { user.UserName = "******" + user.UserId.ToString(); } /* NO NO not emails * if (reader.Exists(prefix + "Email")) { user.Email = reader.GetStringNullAsEmpty(prefix + "Email") ?? ""; } */ if (reader.Exists(prefix + "SiteSuffix")) { user.SiteSuffix = reader.GetStringNullAsEmpty(prefix + "SiteSuffix") ?? ""; } if (reader.Exists(prefix + "Area")) { user.Area = reader.GetStringNullAsEmpty(prefix + "Area") ?? ""; } if (reader.Exists(prefix + "Title")) { user.Title = reader.GetStringNullAsEmpty(prefix + "Title") ?? ""; } if (reader.Exists(prefix + "SubQuota")) { user.SubQuota = reader.GetInt32NullAsZero(prefix + "SubQuota"); } if (reader.Exists(prefix + "Allocations")) { user.Allocations = reader.GetInt32NullAsZero(prefix + "Allocations"); } if (reader.Exists(prefix + "Journal")) { user.Journal = reader.GetInt32NullAsZero(prefix + "Journal"); } if (reader.Exists(prefix + "Active") && !reader.IsDBNull(prefix + "Active")) { user.Active = reader.GetBoolean(prefix + "Active"); } if (reader.Exists(prefix + "DateLastNotified") && reader.GetValue(prefix + "DateLastNotified") != DBNull.Value) { user.DateLastNotified = new DateElement(reader.GetDateTime(prefix + "DateLastNotified")); } if (reader.Exists(prefix + "DateJoined") && reader.GetValue(prefix + "DateJoined") != DBNull.Value) { user.DateJoined = new DateElement(reader.GetDateTime(prefix + "DateJoined")); } if (reader.Exists(prefix + "ForumPostedTo")) { user.ForumPostedTo = reader.GetInt32NullAsZero(prefix + "ForumPostedTo"); } if (reader.Exists(prefix + "Masthead")) { user.MastHead = reader.GetInt32NullAsZero(prefix + "Masthead"); } if (reader.Exists(prefix + "SinBin")) { user.SinBin = reader.GetInt32NullAsZero(prefix + "SinBin"); } if (reader.Exists(prefix + "ForumID")) { user.ForumId = reader.GetInt32NullAsZero(prefix + "ForumID"); } var siteId = 0; if (reader.Exists("SiteID")) { siteId = reader.GetInt32NullAsZero("SiteID"); } if (siteId != 0 && user.UserId != 0) { var userGroups = (UserGroups)SignalHelper.GetObject(typeof(UserGroups)); var groupList = userGroups.GetUsersGroupsForSite(user.UserId, siteId); foreach (var group in groupList) { user.Groups.Add(new Group(){Name = group.Name.ToUpper()}); } } else { } return (User)user; }
/// <summary> /// This method creates the crumbtrail for a given item /// </summary> /// <param name="reader">The DnaDataReader that contains the crumbtrail result set.</param> private void GetCrumbtrailForItem(IDnaDataReader reader) { XmlNode crumbtrailsNode = AddElementTag(RootElement, "CRUMBTRAILS"); bool startOfTrail = true; XmlNode crumbtrailNode = null; while (reader.Read()) { // Check to see if we're at the top level int treeLevel = reader.GetInt32("TreeLevel"); if (treeLevel == 0) { startOfTrail = true; } // Check to see if we're starting a new trail if (startOfTrail) { crumbtrailNode = AddElementTag(crumbtrailsNode, "CRUMBTRAIL"); startOfTrail = false; } XmlNode ancestorNode = AddElementTag(crumbtrailNode, "ANCESTOR"); AddIntElement(ancestorNode, "NODEID", reader.GetInt32("NodeID")); AddTextElement((XmlElement)ancestorNode, "NAME", reader.GetString("DisplayName")); AddIntElement(ancestorNode, "TREELEVEL", treeLevel); AddIntElement(ancestorNode, "NODETYPE", reader.GetInt32("Type")); if (reader.Exists("RedirectNodeID") && !reader.IsDBNull("RedirectNodeID")) { XmlNode redirectNode = AddTextElement((XmlElement)ancestorNode, "REDIRECTNODE", reader.GetString("RedirectNodeName")); AddAttribute(redirectNode,"ID", reader.GetInt32("RedirectNodeID")); } } }
/// <summary> /// With the returned data set generate the XML for the Article Search page /// </summary> /// <param name="dataReader">The returned search resultset</param> /// <param name="asp">The Article Search Params</param> private void GenerateArticleSearchXml(IDnaDataReader dataReader, ArticleSearchParams asp) { RootElement.RemoveAll(); XmlNode articleSearch = AddElementTag(RootElement, "ARTICLESEARCH"); AddAttribute(articleSearch, "CONTENTTYPE", asp.ContentType); AddAttribute(articleSearch, "SORTBY", asp.SortBy); AddAttribute(articleSearch, "SKIPTO", asp.Skip); AddAttribute(articleSearch, "SHOW", asp.Show); AddAttribute(articleSearch, "DATESEARCHTYPE", asp.DateSearchType); AddAttribute(articleSearch, "TIMEINTERVAL", asp.TimeInterval); AddAttribute(articleSearch, "ARTICLESTATUS", asp.ArticleStatus); AddAttribute(articleSearch, "ARTICLETYPE", asp.ArticleType); AddAttribute(articleSearch, "LATITUDE", asp.Latitude); AddAttribute(articleSearch, "LONGITUDE", asp.Longitude); AddAttribute(articleSearch, "RANGE", asp.Range); AddAttribute(articleSearch, "POSTCODE", asp.PostCode); AddAttribute(articleSearch, "PLACENAME", asp.Placename); AddAttribute(articleSearch, "LOCATIONSEARCHTYPE", asp.LocationSearchType); //Add the new descending order attribute if (asp.DescendingOrder) { AddAttribute(articleSearch, "DESCENDINGORDER", 1); } else { AddAttribute(articleSearch, "DESCENDINGORDER", 0); } //Add the requested searchphraselist GeneratePhraseXml(asp.SearchPhraseList, (XmlElement)articleSearch); //Add Date Search Params if we are doing a date search if (asp.DateSearchType != 0) { AddDateXml(asp.StartDate, articleSearch, "DATERANGESTART"); // Take a day from the end date as used in the database for UI purposes. // E.g. User submits a date range of 01/09/1980 to 02/09/1980. They mean for this to represent 2 days i.e. 01/09/1980 00:00 - 03/09/1980 00:00. // This gets used in the database but for display purposes we subtract a day from the database end date to return the // original dates submitted by the user inorder to match their expectations. AddDateXml(asp.EndDate.AddDays(-1), articleSearch, "DATERANGEEND"); } AddTextTag(articleSearch, "FREETEXTSEARCH", asp.FreeTextSearchCondition); XmlNode articles = AddElementTag(articleSearch, "ARTICLES"); int total = 0; int count = 0; //Generate Hot-List from Search Results. PopularPhrases popularPhrases = null; if (InputContext.GetSiteOptionValueBool("articlesearch", "generatepopularphrases")) { popularPhrases = new PopularPhrases(); } if (dataReader.HasRows) { // process first results set: the Article Key phrase results set Dictionary<int, ArrayList> articleKeyPhrases = new Dictionary<int, ArrayList>(); ArrayList phraselist = new ArrayList(); int h2g2ID = 0; if (dataReader.Read()) { int previousH2G2ID = 0; do { h2g2ID = dataReader.GetInt32NullAsZero("H2G2ID"); if (h2g2ID != previousH2G2ID) { //New now have a new article so clean up the last one if (previousH2G2ID != 0) { articleKeyPhrases.Add(previousH2G2ID, phraselist); phraselist = new ArrayList(); } } //set the previous h2g2id to this one previousH2G2ID = h2g2ID; //Create fill an new Phrase object Phrase nameSpacedPhrase = new Phrase(); String nameSpace = String.Empty; String phraseName = dataReader.GetStringNullAsEmpty("phrase"); if (phraseName != String.Empty) { if (dataReader.Exists("namespace")) { nameSpace = dataReader.GetStringNullAsEmpty("namespace"); } nameSpacedPhrase.NameSpace = nameSpace; nameSpacedPhrase.PhraseName = phraseName; //add it to the list phraselist.Add(nameSpacedPhrase); //Record Popular Phrases. if (popularPhrases != null) { popularPhrases.AddPhrase(phraseName, nameSpace); } } } while (dataReader.Read()); } articleKeyPhrases.Add(h2g2ID, phraselist); dataReader.NextResult(); if (dataReader.Read()) { total = dataReader.GetInt32NullAsZero("TOTAL"); //The stored procedure returns one row for each article. The article's keyphrases have been stored in articleKeyPhrases. XmlNode article = CreateElementNode("ARTICLE"); do { count++; h2g2ID = dataReader.GetInt32NullAsZero("H2G2ID"); //Start filling new article xml AddAttribute(article, "H2G2ID", h2g2ID); int editorID = dataReader.GetInt32NullAsZero("editor"); XmlNode editor = CreateElementNode("EDITOR"); User user = new User(InputContext); user.AddUserXMLBlock(dataReader, editorID, editor); article.AppendChild(editor); AddTextTag(article, "STATUS", dataReader.GetInt32NullAsZero("status")); AddXmlTextTag(article, "SUBJECT", dataReader.GetStringNullAsEmpty("SUBJECT")); AddTextTag(article, "TYPE", dataReader.GetInt32NullAsZero("type")); AddDateXml(dataReader, article, "DateCreated", "DATECREATED"); AddDateXml(dataReader, article, "LastUpdated", "LASTUPDATED"); //Add Extra Info XML where it exists. string extraInfo = dataReader.GetAmpersandEscapedStringNullAsEmpty("EXTRAINFO"); if (extraInfo != string.Empty) { XmlDocument extraInfoXml = new XmlDocument(); extraInfoXml.LoadXml(extraInfo); article.AppendChild(ImportNode(extraInfoXml.FirstChild)); } AddTextTag(article, "NUMBEROFPOSTS", dataReader.GetInt32NullAsZero("ForumPostCount")); AddDateXml(dataReader, article, "LASTPOSTED", "FORUMLASTPOSTED"); if (!dataReader.IsDBNull("StartDate")) { AddDateXml(dataReader, article, "StartDate", "DATERANGESTART"); // Take a day from the end date as stored in the database for UI purposes. // E.g. User submits a date range of 01/09/1980 to 02/09/1980. They mean for this to represent 2 days i.e. 01/09/1980 00:00 - 03/09/1980 00:00. // This gets stored in the database but for display purposes we subtract a day from the database end date to return the // original dates submitted by the user inorder to match their expectations. AddDateXml(dataReader.GetDateTime("EndDate").AddDays(-1), article, "DATERANGEEND"); AddTextTag(article, "TIMEINTERVAL", dataReader.GetInt32NullAsZero("TimeInterval")); } if (dataReader.DoesFieldExist("BookmarkCount")) { AddTextTag(article, "BOOKMARKCOUNT", dataReader.GetInt32NullAsZero("BookmarkCount")); } if (dataReader.DoesFieldExist("ZeitgeistScore")) { AddElement(article, "ZEITGEIST", "<SCORE>" + dataReader.GetDoubleNullAsZero("ZeitgeistScore") + "</SCORE>"); } #region LocationXML //*********************************************************************** // Location Info //*********************************************************************** if (dataReader.DoesFieldExist("Latitude") && !dataReader.IsDBNull("Latitude")) { AddTextTag(article, "LATITUDE", dataReader.GetDoubleNullAsZero("Latitude").ToString()); AddTextTag(article, "LONGITUDE", dataReader.GetDoubleNullAsZero("Longitude").ToString()); if (dataReader.DoesFieldExist("Distance")) { if (dataReader.GetDoubleNullAsZero("Distance") < 0.0001) { AddTextTag(article, "DISTANCE", "0"); } else { AddTextTag(article, "DISTANCE", dataReader.GetDoubleNullAsZero("Distance").ToString()); } } AddTextTag(article, "LOCATIONTITLE", dataReader.GetString("LocationTitle")); AddTextTag(article, "LOCATIONDESCRIPTION", dataReader.GetString("LocationDescription")); AddTextTag(article, "LOCATIONZOOMLEVEL", dataReader.GetInt32NullAsZero("LocationZoomLevel").ToString()); AddTextTag(article, "LOCATIONUSERID", dataReader.GetInt32NullAsZero("LocationUserID").ToString()); AddDateXml(dataReader.GetDateTime("LocationDateCreated"), article, "LOCATIONDATECREATED"); } //*********************************************************************** #endregion //*********************************************************************** // Media Asset Info //*********************************************************************** int mediaAssetID = dataReader.GetInt32NullAsZero("MediaAssetID"); if (mediaAssetID != 0) { AddMediaAssetXml(dataReader, article, mediaAssetID); } //*********************************************************************** AddPollXml(dataReader, article); if (articleKeyPhrases.ContainsKey(h2g2ID)) { GeneratePhraseXml(articleKeyPhrases[h2g2ID], (XmlElement)article); } XmlNode previousarticle = article.CloneNode(true); articles.AppendChild(previousarticle); article.RemoveAll(); } while (dataReader.Read()); } } articleSearch.AppendChild(articles); AddAttribute(articleSearch, "COUNT", count); AddAttribute(articleSearch, "TOTAL", total); if (popularPhrases != null) { //Include popularPhrase statistics. XmlElement popularPhrasesXml = popularPhrases.GenerateXml(); articleSearch.AppendChild(ImportNode(popularPhrasesXml)); } FileCache.PutItem(AppContext.TheAppContext.Config.CachePath, "articlesearch", _cacheName, articleSearch.OuterXml); //articleSearch.OwnerDocument.Save(@"c:\TEMP\Articlesearch.xml"); }
/// <summary> /// This method creates the crumbtrail for a given item /// </summary> /// <param name="reader">The DnaDataReader that contains the crumbtrail result set.</param> static public CrumbTrails GetCrumbtrailForItem(IDnaDataReader reader) { CrumbTrails crumbTrialList = new CrumbTrails(); bool startOfTrail = true; CrumbTrail crumbTrail = null; while (reader.Read()) { // Check to see if we're at the top level int treeLevel = reader.GetInt32("TreeLevel"); if (treeLevel == 0) { startOfTrail = true; } // Check to see if we're starting a new trail if (startOfTrail) { if (crumbTrail != null) {//add the previous to the list crumbTrialList.CrumbTrail.Add(crumbTrail); } //start new crumbTrail = new CrumbTrail(); startOfTrail = false; } CrumbTrailAncestor ancestor = new CrumbTrailAncestor(); ancestor.Name = reader.GetString("DisplayName"); ancestor.NodeId = reader.GetInt32("NodeID"); ancestor.TreeLevel = treeLevel; ancestor.NodeType = reader.GetInt32("Type"); if (reader.Exists("RedirectNodeID") && !reader.IsDBNull("RedirectNodeID")) { ancestor.RedirectNode = new CrumbTrialAncestorRedirect(); ancestor.RedirectNode.id = reader.GetInt32("RedirectNodeID"); ancestor.RedirectNode.value = reader.GetString("RedirectNodeName"); } crumbTrail.Ancestor.Add(ancestor); } if (crumbTrail != null) {//add the previous to the list crumbTrialList.CrumbTrail.Add(crumbTrail); } return crumbTrialList; }
/// <summary> /// Method for reading user data from user procedure calls /// </summary> /// <param name="reader">The StoredProcedure reader that contains the data</param> private void ReadUserDetails(IDnaDataReader reader) { UserID = reader.GetInt32("userid"); UserName = reader.GetString("username"); IdentityUserID = reader.GetStringNullAsEmpty("IdentityUserID"); IdentityUserName = reader.GetStringNullAsEmpty("IdentityUserName"); _status = reader.GetInt32("status"); _prefStatus = reader.GetInt32("PrefStatus"); if (_status == 1)//normal global status { if (reader.GetInt32("PrefStatus") == 4)//banned { _status = 0; } } //NO NO emails Email = reader.GetString("email"); SiteSuffix = reader.GetStringNullAsEmpty("SiteSuffix"); LastSynchronisedDate = reader.GetDateTime("LastUpdatedDate"); if (reader.Exists("AcceptSubscriptions")) { AcceptSubscriptions = reader.GetBoolean("AcceptSubscriptions"); } if (reader.Exists("SinBin")) { IsAutoSinBin = reader.GetInt32NullAsZero("SinBin"); } //PrimarySiteId = reader.GetInt32NullAsZero("PrimarySiteId"); }