/// <summary> /// Accesses DB and creates Routes List. /// Routes created by users. /// </summary> /// <param name="userID">The user of the routes to get</param> /// <param name="siteID">Site of the routes</param> /// <param name="skip">number of routes to skip</param> /// <param name="show">number to show</param> /// <param name="showPrivate">Indicates whether private routes should be included.</param> /// <returns>Whether created ok</returns> public bool CreateRoutesList(int userID, int siteID, int skip, int show, bool showPrivate) { // check object is not already initialised if (userID <= 0 || show <= 0) { return false; } XmlElement list = AddElementTag(RootElement, "ROUTES-LIST"); AddAttribute(list, "SKIP", skip); AddAttribute(list, "SHOW", show); using (IDnaDataReader dataReader = InputContext.CreateDnaDataReader("getmoreroutes")) { dataReader.AddParameter("userid", userID); dataReader.AddParameter("siteid", InputContext.CurrentSite.SiteID); // Get +1 so we know if there are more left dataReader.AddParameter("skip", skip); dataReader.AddParameter("show", show + 1); dataReader.Execute(); if (dataReader.HasRows) { //1st Result set gets user details. if (dataReader.Read()) { User user = new User(InputContext); user.AddUserXMLBlock(dataReader, userID, list); dataReader.NextResult(); } //Paged List of Routes. int count = 0; if (dataReader.HasRows) { while (dataReader.Read() && count < show) { Route route = new Route(InputContext); //Delegate creation of XML to Route class. route.CreateRouteXML(dataReader, false); AddInside(list, route); ++count; } } // Add More Attribute Indicating there are more rows. if (dataReader.Read() && count > 0) { AddAttribute(list, "MORE", 1); } } } return true; }
/// <summary> /// Functions generates the User Subscription List /// </summary> /// <param name="userID">The user of the subscriptions to get</param> /// <param name="siteID">Site of the posts</param> /// <param name="skip">number of posts to skip</param> /// <param name="show">number to show</param> /// <returns>Whether created ok</returns> public bool CreateUserSubscriptionsList(int userID, int siteID, int skip, int show) { // check object is not already initialised if (userID <= 0 || show <= 0) { return false; } int count = show; XmlElement UserSubscriptionsList = AddElementTag(RootElement, "USERSUBSCRIPTION-LIST"); AddAttribute(UserSubscriptionsList, "SKIP", skip); AddAttribute(UserSubscriptionsList, "SHOW", show); using (IDnaDataReader dataReader = GetUsersSubscriptionList(userID, siteID, skip, show + 1)) // Get +1 so we know if there are more left { // Check to see if we found anything Owner of the list record first // then their list in the following recordset string userName = String.Empty; if (dataReader.HasRows && dataReader.Read()) { User subscriber = new User(InputContext); subscriber.AddPrefixedUserXMLBlock(dataReader, userID, "Subscriber", UserSubscriptionsList); _userAcceptsSubscriptions = dataReader.GetBoolean("SubscriberAcceptSubscriptions"); dataReader.NextResult(); if (dataReader.HasRows && dataReader.Read()) { XmlElement users = CreateElement("USERS"); do { User subscribedTo = new User(InputContext); int subscribedToID = dataReader.GetInt32NullAsZero("subscribedToID"); subscribedTo.AddUserXMLBlock(dataReader, subscribedToID, users); count--; } while (count > 0 && dataReader.Read()); // dataReader.Read won't get called if count == 0 UserSubscriptionsList.AppendChild(users); // See if there's an extra row waiting if (count == 0 && dataReader.Read()) { AddAttribute(UserSubscriptionsList, "MORE", 1); } } } } return true; }
/// <summary> /// Accesses DB and creates Links List. /// Links created by users. /// </summary> /// <param name="userID">The user of the links to get</param> /// <param name="siteID">Site of the links</param> /// <param name="skip">number of links to skip</param> /// <param name="show">number to show</param> /// <param name="showPrivate">Indicates whether private links should be included.</param> /// <returns>Whether created ok</returns> public bool CreateLinksList(int userID, int siteID, int skip, int show, bool showPrivate) { // check object is not already initialised if (userID <= 0 || show <= 0) { return false; } XmlElement list = AddElementTag(RootElement, "LINKS-LIST"); AddAttribute(list, "SKIP", skip); AddAttribute(list, "SHOW", show); using (IDnaDataReader dataReader = InputContext.CreateDnaDataReader("getmorelinks")) { dataReader.AddParameter("userid", userID); dataReader.AddParameter("linkgroup", String.Empty); dataReader.AddParameter("showprivate", showPrivate); dataReader.AddParameter("siteid", InputContext.CurrentSite.SiteID); // Get +1 so we know if there are more left dataReader.AddParameter("skip", skip); dataReader.AddParameter("show", show + 1); dataReader.Execute(); if (dataReader.HasRows) { //1st Result set gets user details. if (dataReader.Read()) { User user = new User(InputContext); user.AddUserXMLBlock(dataReader, userID, list); dataReader.NextResult(); } //Paged List of Links / Clippings / Bookmarks . int count = 0; Link link = new Link(InputContext); while (dataReader.Read() && count < show) { //Delegate creation of XML to Link class. link.CreateLinkXML(dataReader, list, true, false); ++count; } // Add More Attribute Indicating there are more rows. if (dataReader.Read() && count > 0) { AddAttribute(list, "MORE", 1); } } } return true; }
/// <summary> /// Generate the Watched User List for a particular user /// </summary> /// <param name="userID">User ID</param> public void Initialise(int userID) { RootElement.RemoveAll(); XmlElement watchedUserList = AddElementTag(RootElement, "WATCHED-USER-LIST"); AddAttribute(watchedUserList, "USERID", userID); using (IDnaDataReader dataReader = InputContext.CreateDnaDataReader("fetchwatchedjournals")) { dataReader.AddParameter("userID", userID); dataReader.Execute(); if (dataReader.HasRows) { while (dataReader.Read()) { int watchedUserID = dataReader.GetInt32NullAsZero("UserID"); User tempUser = new User(InputContext); tempUser.AddUserXMLBlock(dataReader, watchedUserID, watchedUserList); } } } }
/// <summary> /// Functions generates the User Subscription List /// </summary> /// <param name="userID">The user requesting their subscriptions</param> /// <param name="siteID">The site the user is getting their subscriptions from</param> /// <param name="skip">number of articles to skip</param> /// <param name="show">number of articles to show</param> /// <returns>Success</returns> public bool CreateArticleSubscriptionsList(int userID, int siteID, int skip, int show) { RootElement.RemoveAll(); XmlElement articleSubscriptionsList = AddElementTag(RootElement, "ARTICLESUBSCRIPTIONLIST"); AddAttribute(articleSubscriptionsList, "SKIP", skip); AddAttribute(articleSubscriptionsList, "SHOW", show); XmlNode articles = AddElementTag(articleSubscriptionsList, "ARTICLES"); int total = 0; int count = 0; using (IDnaDataReader dataReader = GetArticleSubscriptionList(userID, siteID, skip + 1, show)) // Add 1 to skip because row number starts at 1. { 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); } } 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); AddXmlTextTag(article, "SUBJECT", dataReader.GetStringNullAsEmpty("SUBJECT")); AddTextTag(article, "TYPE", dataReader.GetInt32NullAsZero("type")); AddTextTag(article, "STATUS", dataReader.GetInt32NullAsZero("status")); int editorID = dataReader.GetInt32NullAsZero("editor"); XmlNode editor = CreateElementNode("EDITOR"); User user = new User(InputContext); user.AddUserXMLBlock(dataReader, editorID, editor); article.AppendChild(editor); //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)); } AddDateXml(dataReader, article, "DateCreated", "DATECREATED"); AddDateXml(dataReader, article, "LastUpdated", "LASTUPDATED"); AddTextTag(article, "NUMBEROFPOSTS", dataReader.GetInt32NullAsZero("ForumPostCount")); if (dataReader.DoesFieldExist("ZeitgeistScore")) { AddElement(article, "ZEITGEIST", "<SCORE>" + dataReader.GetDoubleNullAsZero("ZeitgeistScore") + "</SCORE>"); } if (!dataReader.IsDBNull("StartDate")) { AddDateXml(dataReader, article, "StartDate", "DATERANGESTART"); DateTime articlesDateRangeEnd = dataReader.GetDateTime("EndDate"); if (InputContext.GetSiteOptionValueBool(dataReader.GetInt32NullAsZero("SiteID"), "GuideEntries", "InclusiveDateRange")) { // take a minute from the end date as stored in the database so to match user's expectations. // I.e. If SiteOption InclusiveDateRange is true user will have submitted a date range like 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 but for display purposes expect the // end date to be 02/09/1980. 02/09/1980 23:59 is therefore returned. TimeSpan minute = new TimeSpan(0, 1, 0); AddDateXml(articlesDateRangeEnd.Subtract(minute), article, "DATERANGEEND"); } else { AddDateXml(articlesDateRangeEnd, article, "DATERANGEEND"); } AddTextTag(article, "TIMEINTERVAL", dataReader.GetInt32NullAsZero("TimeInterval")); } if (dataReader.DoesFieldExist("Latitude") && !dataReader.IsDBNull("Latitude")) { AddTextTag(article, "LATITUDE", dataReader.GetDoubleNullAsZero("Latitude").ToString()); } if (dataReader.DoesFieldExist("Longitude") && !dataReader.IsDBNull("Longitude")) { AddTextTag(article, "LONGITUDE", dataReader.GetDoubleNullAsZero("Longitude").ToString()); } if (dataReader.DoesFieldExist("Distance") && !dataReader.IsDBNull("Distance")) { AddTextTag(article, "DISTANCE", dataReader.GetDoubleNullAsZero("Distance").ToString()); } //*********************************************************************** // 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()); } } articleSubscriptionsList.AppendChild(articles); } AddAttribute(articleSubscriptionsList, "COUNT", count); AddAttribute(articleSubscriptionsList, "TOTAL", total); return true; }
/// <summary> /// Adds the MediaAsset XML data to the XML document /// </summary> /// <param name="dataReader">Record set containing the data</param> /// <param name="parent">parent to add the xml to</param> /// <param name="mediaAssetID">Media asset id in question</param> private void AddMediaAssetXml(IDnaDataReader dataReader, XmlNode parent, int mediaAssetID) { // TODO: move this method into a MedaiAsset class - it's duplicated in ArticleSearch.cs. string FTPPath = String.Empty; XmlNode mediaAsset = CreateElementNode("MEDIAASSET"); AddAttribute(mediaAsset, "MEDIAASSETID", mediaAssetID); AddAttribute(mediaAsset, "CONTENTTYPE", dataReader.GetInt32NullAsZero("ContentType")); GenerateFTPDirectoryString(mediaAssetID, ref FTPPath); AddTextTag(mediaAsset, "FTPPATH", FTPPath); AddTextTag(mediaAsset, "CAPTION", dataReader.GetStringNullAsEmpty("Caption")); int ownerID = dataReader.GetInt32NullAsZero("OwnerID"); XmlNode owner = CreateElementNode("OWNER"); User user = new User(InputContext); user.AddUserXMLBlock(dataReader, ownerID, owner); mediaAsset.AppendChild(owner); AddTextTag(mediaAsset, "MIMETYPE", dataReader.GetStringNullAsEmpty("Mimetype")); //Extra extendedable element stuff removed for time being XmlDocument extraelementinfo = new XmlDocument(); extraelementinfo.LoadXml("<EXTRAELEMENTXML>" + dataReader.GetStringNullAsEmpty("EXTRAELEMENTXML") + "</EXTRAELEMENTXML>"); mediaAsset.AppendChild(ImportNode(extraelementinfo.FirstChild)); AddTextTag(mediaAsset, "HIDDEN", dataReader.GetInt32NullAsZero("Hidden")); string externalLinkID = String.Empty; string externalLinkType = String.Empty; string externalLinkURL = dataReader.GetStringNullAsEmpty("ExternalLinkURL"); GetIDFromLink(externalLinkURL, ref externalLinkID, ref externalLinkType); AddTextTag(mediaAsset, "EXTERNALLINKTYPE", externalLinkType); AddTextTag(mediaAsset, "EXTERNALLINKURL", externalLinkURL); AddTextTag(mediaAsset, "EXTERNALLINKID", externalLinkID); parent.AppendChild(mediaAsset); }
/// <summary> /// Makes the XML for a Media Asset from the datareader and attache it to the parent element /// </summary> /// <param name="dataReader"></param> /// <param name="parent"></param> /// <returns></returns> public XmlNode MakeXml(IDnaDataReader dataReader, XmlElement parent) { _mediaAssetID = dataReader.GetInt32NullAsZero("mediaassetid"); if (_mediaAssetID == 0) { return null; } int ownerID = dataReader.GetInt32NullAsZero("ownerid"); int hidden = dataReader.GetInt32NullAsZero("hidden"); int contentType = dataReader.GetInt32NullAsZero("contentType"); int siteID = dataReader.GetInt32NullAsZero("siteID"); string caption = dataReader.GetStringNullAsEmpty("caption"); string filename = dataReader.GetStringNullAsEmpty("filename"); string mediaassetdescription = dataReader.GetStringNullAsEmpty("description"); string mimeType = dataReader.GetStringNullAsEmpty("mimetype"); string externalLinkURL = dataReader.GetStringNullAsEmpty("externallinkurl"); XmlElement assetXML = AddElementTag(parent, "MEDIAASSET"); AddAttribute(assetXML, "MEDIAASSETID", _mediaAssetID); AddTextElement(assetXML, "FTPPATH", GenerateFTPDirectoryString()); AddIntElement(assetXML, "SITEID", siteID); AddTextElement(assetXML, "CAPTION", caption); AddTextElement(assetXML, "FILENAME", filename); AddTextElement(assetXML, "MIMETYPE", mimeType); AddIntElement(assetXML, "CONTENTTYPE", contentType); //TODO : Need to add the keyphrases for the media asset here //Extra extendedable element stuff removed for time being XmlDocument extraelementinfo = new XmlDocument(); extraelementinfo.LoadXml("<EXTRAELEMENTXML>" + dataReader.GetStringNullAsEmpty("EXTRAELEMENTXML") + "</EXTRAELEMENTXML>"); assetXML.AppendChild(ImportNode(extraelementinfo.FirstChild)); XmlNode owner = AddElementTag(assetXML,"OWNER"); User user = new User(InputContext); user.AddUserXMLBlock(dataReader, ownerID, owner); assetXML.AppendChild(owner); AddTextElement(assetXML, "MEDIAASSETDESCRIPTION", mediaassetdescription); AddDateXml(dataReader, assetXML, "MADateCreated", "DATECREATED"); AddDateXml(dataReader, assetXML, "MALastUpdated", "LASTUPDATED"); AddIntElement(assetXML, "HIDDEN", hidden); string externalLinkID = String.Empty; string externalLinkType = String.Empty; string flickrFarmPath = String.Empty; string flickrServer = String.Empty; string flickrID = String.Empty; string flickrSecret = String.Empty; string flickrSize = String.Empty; GetIDFromLink(externalLinkURL, ref externalLinkID, ref externalLinkType, ref flickrFarmPath, ref flickrServer, ref flickrID, ref flickrSecret, ref flickrSize); AddTextElement(assetXML, "EXTERNALLINKURL", externalLinkURL); AddTextElement(assetXML, "EXTERNALLINKID", externalLinkID); AddTextElement(assetXML, "EXTERNALLINKTYPE", externalLinkType); if (externalLinkType == "Flickr") { XmlElement flickr = AddElementTag(assetXML, "FLICKR"); AddTextElement(flickr, "FARMPATH", flickrFarmPath); AddTextElement(flickr, "SERVER", flickrServer); AddTextElement(flickr, "ID", flickrID); AddTextElement(flickr, "SECRET", flickrSecret); AddTextElement(flickr, "SIZE", flickrSize); assetXML.AppendChild(flickr); } AddPollXml(dataReader, assetXML); return assetXML; }
private void GenerateUsersArticleAssetsXML(IDnaDataReader dataReader, MediaAssetParameters mediaAssetParams) { int count = 0; int total = 0; bool more = false; XmlElement articleAsset = AddElementTag(_builderRoot, "ARTICLEMEDIAASSETINFO"); AddAttribute(articleAsset, "CONTENTTYPE", mediaAssetParams.ContentType); AddAttribute(articleAsset, "SORTBY", mediaAssetParams.SortBy); AddAttribute(articleAsset, "SKIPTO", mediaAssetParams.Skip); AddAttribute(articleAsset, "SHOW", mediaAssetParams.Show); AddTextElement(articleAsset, "ACTION", "showusersarticleswithassets"); if (dataReader.HasRows) { if (dataReader.Read()) { User user = new User(InputContext); user.AddUserXMLBlock(dataReader, mediaAssetParams.UserID, articleAsset); count = dataReader.GetInt32NullAsZero("COUNT"); total = dataReader.GetInt32NullAsZero("TOTAL"); if (total > mediaAssetParams.Skip + mediaAssetParams.Show) { more = true; } do { XmlElement article = AddElementTag(articleAsset, "ARTICLE"); AddAttribute(article, "H2G2ID", dataReader.GetInt32NullAsZero("H2G2ID")); AddTextElement(article, "SUBJECT", dataReader.GetStringNullAsEmpty("SUBJECT")); XmlDocument extrainfo = new XmlDocument(); extrainfo.LoadXml(dataReader.GetStringNullAsEmpty("EXTRAINFO")); article.AppendChild(ImportNode(extrainfo.FirstChild)); AddDateXml(dataReader, article, "DateCreated", "DATECREATED"); AddDateXml(dataReader, article, "LastUpdated", "LASTUPDATED"); MakeXml(dataReader, article); } while (dataReader.Read()); } } AddAttribute(articleAsset, "COUNT", count); AddAttribute(articleAsset, "TOTAL", total); AddAttribute(articleAsset, "MORE", more); }
private void GenerateUsersMediaAssetsXML(IDnaDataReader dataReader, MediaAssetParameters mediaAssetParams) { int count = 0; int total = 0; bool more = false; XmlElement usersMediaAssets = AddElementTag(_builderRoot, "MEDIAASSETINFO"); AddAttribute(usersMediaAssets, "CONTENTTYPE", mediaAssetParams.ContentType); AddAttribute(usersMediaAssets, "SORTBY", mediaAssetParams.SortBy); AddAttribute(usersMediaAssets, "SKIPTO", mediaAssetParams.Skip); AddAttribute(usersMediaAssets, "SHOW", mediaAssetParams.Show); AddTextElement(usersMediaAssets, "ACTION", "showusersassets"); if (dataReader.HasRows) { if (dataReader.Read()) { User user = new User(InputContext); user.AddUserXMLBlock(dataReader, mediaAssetParams.UserID, usersMediaAssets); count = dataReader.GetInt32NullAsZero("COUNT"); total = dataReader.GetInt32NullAsZero("TOTAL"); if (total > mediaAssetParams.Skip + mediaAssetParams.Show) { more = true; } do { MakeXml(dataReader, usersMediaAssets); } while (dataReader.Read()); } } AddAttribute(usersMediaAssets, "COUNT", count); AddAttribute(usersMediaAssets, "TOTAL", total); AddAttribute(usersMediaAssets, "MORE", more); }
/// <summary> /// Functions generates the Recent Comments List /// </summary> /// <param name="userID">The user of the comments to get</param> /// <param name="siteID">Site of the comments</param> /// <param name="skip">Number of comments to skip</param> /// <param name="show">Number of comments to show</param> /// <returns>Whether created ok</returns> public bool CreateRecentCommentsList(int userID, int siteID, int skip, int show) { // check object is not already initialised if (userID <= 0 || show <= 0) { return false; } bool showPrivate = false; if (InputContext.ViewingUser.UserID != 0 && InputContext.ViewingUser.UserLoggedIn && (userID == InputContext.ViewingUser.UserID || InputContext.ViewingUser.IsEditor)) { showPrivate = true; } int count = show; XmlElement commentsList = AddElementTag(RootElement, "COMMENTS-LIST"); AddAttribute(commentsList, "SKIP", skip); AddAttribute(commentsList, "SHOW", show); using (IDnaDataReader dataReader = GetUsersMostRecentComments(userID, siteID, skip, show+1, showPrivate)) // Get +1 so we know if there are more left { // Check to see if we found anything string userName = String.Empty; if (dataReader.HasRows && dataReader.Read()) { User user = new User(InputContext); user.AddUserXMLBlock(dataReader, userID, commentsList); XmlElement comments = CreateElement("COMMENTS"); do { // Setup the Comment Tag and Attributes XmlElement comment = CreateElement("COMMENT"); AddIntElement(comment, "SiteID", dataReader.GetInt32NullAsZero("SiteID")); // Add the Subject string subject = dataReader.GetStringNullAsEmpty("Subject"); AddXmlTextTag(comment, "SUBJECT", subject); AddDateXml(dataReader, comment, "DatePosted", "DatePosted"); // Get the forumid and title AddIntElement(comment, "POSTID", dataReader.GetInt32NullAsZero("EntryID")); AddIntElement(comment, "ForumID", dataReader.GetInt32NullAsZero("ForumID")); AddXmlTextTag(comment, "ForumTitle", dataReader.GetStringNullAsEmpty("ForumTitle")); AddIntElement(comment, "ForumPostCount", dataReader.GetInt32NullAsZero("ForumPostCount")); AddIntElement(comment, "ForumPostLimit", InputContext.GetSiteOptionValueInt("Forum", "PostLimit")); AddTextTag(comment, "URL", dataReader.GetStringNullAsEmpty("URL")); AddIntElement(comment, "PostIndex", dataReader.GetInt32NullAsZero("PostIndex")); // Add the text, checking to see what style it is int postStyle = dataReader.GetTinyIntAsInt("PostStyle"); string bodyText = dataReader.GetStringNullAsEmpty("Text"); if (postStyle != 1) { bodyText = StringUtils.ConvertPlainText(bodyText); } else { //TODO Do we need Rich Post stuff for the post style?? string temp = "<RICHPOST>" + bodyText.Replace("\r\n", "<BR />").Replace("\n", "<BR />") + "</RICHPOST>"; //Regex regex = new Regex(@"(<[^<>]+)<BR \/>"); //while (regex.Match(temp).Success) //{ // temp = regex.Replace(temp, @"$1 "); //} //bodyText = temp; bodyText = HtmlUtils.TryParseToValidHtml(temp); } AddElement(comment, "Text", bodyText); AddDateXml(dataReader, comment, "ForumCloseDate", "ForumCloseDate"); // Finally close the COMMENT tag comments.AppendChild(comment); count--; } while (count > 0 && dataReader.Read()); // dataReader.Read won't get called if count == 0 commentsList.AppendChild(comments); // See if there's an extra row waiting if (count == 0 && dataReader.Read()) { AddAttribute(commentsList, "MORE", 1); } } } //AddAttribute(commentsList, "COUNT", count); return true; }
/// <summary> /// Generates XML for Blocked User Subscriptions. /// Allows the author to stop blocked users from tracking their content. /// </summary> /// <param name="userID">The ID of the user to get the list of blocked users for</param> /// <param name="skip">Number of blocked users to skip</param> /// <param name="show">Number of blocked users to show</param> private void GenerateBlockedUserSubscriptionsXml(int userID, int skip, int show) { XmlElement bannedUserSubscriptions = AddElementTag(RootElement, "BLOCKEDUSERSUBSCRIPTIONS"); AddAttribute(bannedUserSubscriptions, "USERID", userID); bool userAcceptsSubscriptions = false; if (_actionResult != null) { bannedUserSubscriptions.AppendChild(_actionResult); } XmlElement bannedList = AddElementTag(bannedUserSubscriptions, "BLOCKEDUSERSUBSCRIPTIONS-LIST"); AddAttribute(bannedList, "SKIP", skip); AddAttribute(bannedList, "SHOW", show); bannedUserSubscriptions.AppendChild(bannedList); XmlElement users = CreateElement("USERS"); using (IDnaDataReader dataReader = InputContext.CreateDnaDataReader("getblockedusersubscriptions")) { dataReader.AddParameter("userid", userID); dataReader.AddParameter("siteid", InputContext.CurrentSite.SiteID); dataReader.AddParameter("skip", skip); dataReader.AddParameter("show", show + 1); dataReader.Execute(); if (dataReader.HasRows && dataReader.Read()) { User blocker = new User(InputContext); blocker.AddPrefixedUserXMLBlock(dataReader, userID, "Blocker", bannedList); userAcceptsSubscriptions = dataReader.GetBoolean("BlockerAcceptSubscriptions"); AddAttribute(bannedUserSubscriptions, "ACCEPTSUBSCRIPTIONS", Convert.ToInt32(userAcceptsSubscriptions)); //Get the list from the second recordset dataReader.NextResult(); if (dataReader.HasRows) { User user = new User(InputContext); int count = show; while (((count--) > 0) && dataReader.Read()) { //Delegate generation of standardised User XML to User class. int blockedUserId = dataReader.GetInt32NullAsZero("userid"); user.AddUserXMLBlock(dataReader, blockedUserId, users); } if (count <= 0 && dataReader.Read()) { AddAttribute(bannedList, "MORE", 1); } } } } bannedList.AppendChild(users); }
/// <summary> /// Gets all the users who have voted on a given vote with a given response. /// </summary> /// <param name="voteID">The ID of the vote you want to get the users for.</param> /// <param name="response">The Response to match for.</param> /// <returns>true if ok, false if not</returns> public bool GetAllUsersWithResponse(int voteID, int response) { XmlElement visibleUsers = CreateElement("VisibleUsers"); // Get all the current users who have already voted with the same result string storedProcedureName = @"getallvotinguserswithresponse"; using (IDnaDataReader dataReader = InputContext.CreateDnaDataReader(storedProcedureName)) { // Add the VoteID and Response dataReader.AddParameter("ivoteid", voteID) .AddParameter("iresponse", response) .AddParameter("isiteid", InputContext.CurrentSite.SiteID); dataReader.Execute(); if (dataReader.HasRows) { if (dataReader.Read()) { // Setup some local variables int hiddenUsersCount = 0; int visibleUsersCount = 0; // Go through the results adding the data to the XML do { // Get the user ID int userID = dataReader.GetInt32NullAsZero("UserID"); if (userID == 0) { // We've got a anonymous user! These are always hidden! hiddenUsersCount++; } else { // Check to see if the user wanted to be hidden if (dataReader.GetInt32NullAsZero("Visible") > 0) { User user = new User(InputContext); user.AddUserXMLBlock(dataReader, userID, visibleUsers); visibleUsersCount++; } else { // Hidden user, just increment the count hiddenUsersCount++; } } // Get the next entry }while(dataReader.Read()); // Add the hidden users // Initialise the XML Builder XmlElement votingUsers = CreateElement("VotingUsers"); votingUsers.SetAttribute("Response", response.ToString()); visibleUsers.SetAttribute("Count", visibleUsersCount.ToString()); votingUsers.AppendChild(visibleUsers); XmlElement hiddenUsers = CreateElement("HiddenUsers"); hiddenUsers.SetAttribute("Count", hiddenUsersCount.ToString()); votingUsers.AppendChild(hiddenUsers); visibleUsers.AppendChild(votingUsers); } } else { throw new DnaException("Vote - FailedGettingUsersForVote - Failed to get the users alreay voted"); } } return true; }
///<summary> /// Checks to see if this sub editor has any allocations that they have /// not yet been notified about, and if so builds the email to send /// in order to notify them. /// </summary> /// <param name="subID">user id of the sub to create the notification for</param> /// <param name="toSend">returned whether or not an email to send was created</param> /// <param name="emailAddress">the subs email address</param> /// <param name="emailSubject">the subject line for the email</param> /// <param name="emailText">the text of the email</param> public void CreateNotificationEmail(int subID, ref bool toSend, ref string emailAddress, ref string emailSubject, ref string emailText) { string subName = String.Empty; string authorName = String.Empty; string subject = String.Empty; int authorID = 0; int h2g2ID = 0; string batchDetails = String.Empty; toSend = false; RootElement.RemoveAll(); XmlElement email = AddElementTag(RootElement, "EMAIL"); AddAttribute(email, "TYPE", "SUB-NOTIFICATION"); // call the SP to fetch all the allocations that the sub has not yet been notified of // this also updates these allocations status and the subs last notified date using (IDnaDataReader dataReader = InputContext.CreateDnaDataReader("FetchAndUpdateSubsUnnotifiedAllocations")) { dataReader.AddParameter("SubID", subID); dataReader.AddParameter("currentsiteid", InputContext.CurrentSite.SiteID); dataReader.Execute(); // Check to see if we found anything if (dataReader.HasRows && dataReader.Read()) { // set the email address and subject toSend = true; emailAddress = dataReader.GetStringNullAsEmpty("SubEmail"); subName = dataReader.GetStringNullAsEmpty("SubName"); AddTextTag(email, "EMAIL-ADDRESS", emailAddress); //Add the user info with groups User user = new User(InputContext); user.AddUserXMLBlock(dataReader, subID, email); // build up a string containing the details of the subs allocated batch do { authorName = dataReader.GetStringNullAsEmpty("AuthorName"); authorID = dataReader.GetInt32NullAsZero("AuthorID"); subject = dataReader.GetStringNullAsEmpty("Subject"); h2g2ID = dataReader.GetInt32NullAsZero("h2g2ID"); batchDetails += "A" + h2g2ID + " '" + subject + "' by " + authorName + " (U" + authorID + ")\r\n"; } while (dataReader.Read()); emailSubject = String.Empty; emailText = String.Empty; // fetch the template for the email using (IDnaDataReader dataReader2 = InputContext.CreateDnaDataReader("fetchemailtext")) { dataReader2.AddParameter("SiteID", InputContext.CurrentSite.SiteID); dataReader2.AddParameter("emailname", "SubAllocationsEmail"); dataReader2.Execute(); if (dataReader2.HasRows && dataReader2.Read()) { emailSubject = dataReader2.GetStringNullAsEmpty("Subject"); emailText = dataReader2.GetStringNullAsEmpty("text"); // do any appropriate substitutions emailSubject = emailSubject.Replace("++**sub_name**++", subName); emailText = emailText.Replace("++**sub_name**++", subName); emailText = emailText.Replace("++**batch_details**++", batchDetails); } } AddTextTag(email, "SUBJECT", emailSubject); AddTextTag(email, "TEXT", emailText); } } }
/// <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> /// Gets all the Category lists for a given user. /// </summary> /// <param name="userID">The Id of the user you want to get the list for.</param> /// <param name="siteID">the id of the site you want to get the lists for</param> /// <param name="showUserInfo"> If this is true, the information on the owner of the list is also included in the XML.</param> public void GetUserCategoryLists(int userID, int siteID, bool showUserInfo) { RootElement.RemoveAll(); // Make sure we've been given a valid user if (userID == 0) { throw new DnaException("GetUserCategoryLists - No User ID Given"); } XmlElement userCategoryLists = AddElementTag(RootElement, "USERCATEGORYLISTS"); AddIntElement(userCategoryLists, "CATEGORYLISTSOWNERID", userID); // Now call the procedure to get the lists using (IDnaDataReader reader = InputContext.CreateDnaDataReader("getcategorylistsforuser")) { reader.AddParameter("UserID", userID); reader.AddParameter("SiteID", siteID); reader.Execute(); // If we found the info, set the number of seconds if (reader.HasRows && reader.Read()) { do { XmlElement list = AddElementTag(userCategoryLists, "LIST"); string GUID = reader.GetGuidAsStringOrEmpty("CategoryListID"); // Remove the dashes from the GUID as this will be used to form the URL later. GUID = GUID.Replace("-", ""); AddTextTag(list, "GUID", GUID); AddTextTag(list, "DESCRIPTION", reader.GetStringNullAsEmpty("Description")); User owner = new User(InputContext); int ownerID = reader.GetInt32NullAsZero("UserID"); XmlElement ownerTag = AddElementTag(list, "OWNER"); owner.AddUserXMLBlock(reader, ownerID, ownerTag); if (reader.DoesFieldExist("CreatedDate") && !reader.IsDBNull("CreatedDate")) { AddDateXml(reader, list, "CreatedDate", "CREATEDDATE"); } if (reader.DoesFieldExist("LastUpdated") && !reader.IsDBNull("LastUpdated")) { AddDateXml(reader, list, "LastUpdated", "LASTUPDATED"); } // Get the nodes that belong to this list list.AppendChild(GetCategoryListsNodes(GUID)); } while (reader.Read()); } } }
/// <summary> /// Adds user to blocked user subscriptions or removes them. /// </summary> /// <param name="action">Action to perform on the list</param> /// <param name="authorid">Author of the page thats doing the blocking</param> /// <param name="blockUnblockUserId">The user to block/unblock</param> private void TryUpdateBlockedSubscriptions(string action, int authorid, int blockUnblockUserId) { if (action == "blockusersubscription") { if (authorid != blockUnblockUserId) { using (IDnaDataReader dataReader = InputContext.CreateDnaDataReader("blockusersubscription")) { dataReader.AddParameter("authorid", authorid); dataReader.AddParameter("userid", blockUnblockUserId); dataReader.Execute(); _actionResult = CreateElement("ACTIONRESULT"); AddAttribute(_actionResult, "ACTION", "blockuser"); while (dataReader.Read()) { //Delegate generation of standardised User XML to User class. int blockedUserID = dataReader.GetInt32NullAsZero("userid"); User user = new User(InputContext); user.AddUserXMLBlock(dataReader, blockedUserID, _actionResult); } } } else { //Don't allow them to block themselves , just add error. AddErrorXml("invalidcredentials", "You cannot block your own blocked subscriptions.", RootElement); } } else if (action == "unblockusersubscription") { if (authorid != blockUnblockUserId) { using (IDnaDataReader dataReader = InputContext.CreateDnaDataReader("unblockusersubscription")) { dataReader.AddParameter("authorid", authorid); dataReader.AddParameter("userid", blockUnblockUserId); dataReader.Execute(); _actionResult = CreateElement("ACTIONRESULT"); AddAttribute(_actionResult, "ACTION", "unblockuser"); while (dataReader.Read()) { //Delegate generation of standardised User XML to User class. int unblockedUserID = dataReader.GetInt32NullAsZero("userid"); User user = new User(InputContext); user.AddUserXMLBlock(dataReader, unblockedUserID, _actionResult); } } } else { //Don't allow them to unblock themselves , just add error. AddErrorXml("invalidcredentials", "You cannot unblock your own blocked subscriptions.", RootElement); } } else if (action == "blocksubscriptions") { InputContext.ViewingUser.BeginUpdateDetails(); InputContext.ViewingUser.SetAcceptSubscriptions(false); InputContext.ViewingUser.UpdateDetails(); _actionResult = CreateElement("ACTIONRESULT"); AddAttribute(_actionResult, "ACTION", "blocksubscriptions"); } else if (action == "acceptsubscriptions") { InputContext.ViewingUser.BeginUpdateDetails(); InputContext.ViewingUser.SetAcceptSubscriptions(true); InputContext.ViewingUser.UpdateDetails(); _actionResult = CreateElement("ACTIONRESULT"); AddAttribute(_actionResult, "ACTION", "unblocksubscriptions"); } }
/// <summary> /// Deallocates the specified entries from whichever sub editor they /// happen to be allocated to currently, so long as they have not /// already been returned. /// </summary> /// <param name="deallocatorID">user doing the deallocation</param> /// <param name="entryIDs">array of entry IDs to be deallocated</param> /// <param name="totalDeallocated">total number of entries in the array</param> /// <returns></returns> public bool SubmitDeallocation(int deallocatorID, int[] entryIDs, ref int totalDeallocated) { //if no entries then return false if (entryIDs == null || entryIDs.Length == 0) return false; //prepare XML Doc using (IDnaDataReader dataReader = InputContext.CreateDnaDataReader("deallocateentriesfromsubs")) { dataReader.AddParameter("deallocatorid", deallocatorID); for (int i = 0; i < entryIDs.Length; i++) { dataReader.AddParameter(String.Format("id{0}", i), entryIDs[i]); } dataReader.AddParameter("currentsiteid", InputContext.CurrentSite.SiteID); dataReader.Execute(); //if nothing returned then fail //setup allocation elements and counters XmlNode successfulAllocations = AddElementTag(RootElement, "SUCCESSFUL-DEALLOCATIONS"); XmlNode failedAllocations = AddElementTag(RootElement, "FAILED-DEALLOCATIONS"); int totalFailed = 0; int totalSuccess = 0; if (dataReader.HasRows) { // check the stauts of the entries returned to see if any couldn't be deallocated // because they had already been returned while (dataReader.Read()) { // stauts should now be 1 = 'Accepted' or something went wrong if (dataReader.GetInt32NullAsZero("Status") == 1) {//success so increment totalSuccess++; } else {//add error xml totalFailed++; XmlElement failedAllocation = CreateElement("DEALLOCATION"); AddElement(failedAllocation, "H2G2-ID", dataReader.GetInt32NullAsZero("h2g2ID").ToString()); AddElement(failedAllocation, "SUBJECT", dataReader.GetAmpersandEscapedStringNullAsEmpty("sSubject")); //get full user object User user = new User(InputContext); user.AddUserXMLBlock(dataReader, dataReader.GetInt32NullAsZero("userID"), failedAllocation); AddElement(failedAllocation, "STATUS", dataReader.GetInt32NullAsZero("Status").ToString()); if (!dataReader.IsDBNull("DateAllocated")) { XmlElement dateAllocated = CreateElement("DATE-RETURNED"); dateAllocated.AppendChild(DnaDateTime.GetDateTimeAsElement(RootElement.OwnerDocument, dataReader.GetDateTime("DateReturned"))); failedAllocation.AppendChild(dateAllocated); } } dataReader.NextResult(); } } else {//all deallocated so none returned totalSuccess = entryIDs.Length; } AddAttribute(successfulAllocations, "TOTAL", totalSuccess); AddAttribute(failedAllocations, "TOTAL", totalFailed); totalDeallocated = totalSuccess; return true; } }