本文整理汇总了C#中User.AddUserXMLBlock方法的典型用法代码示例。如果您正苦于以下问题:C# User.AddUserXMLBlock方法的具体用法?C# User.AddUserXMLBlock怎么用?C# User.AddUserXMLBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类User
的用法示例。
在下文中一共展示了User.AddUserXMLBlock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateRoutesList
/// <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;
}
示例2: CreateUserSubscriptionsList
/// <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;
}
示例3: CreateLinksList
/// <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;
}
示例4: Initialise
/// <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);
}
}
}
}
示例5: CreateArticleSubscriptionsList
/// <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.
//.........这里部分代码省略.........
示例6: AddMediaAssetXml
/// <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);
}
示例7: MakeXml
/// <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;
}
示例8: GenerateUsersArticleAssetsXML
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);
}
示例9: GenerateUsersMediaAssetsXML
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);
}
示例10: CreateRecentCommentsList
/// <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);
//.........这里部分代码省略.........
示例11: GenerateBlockedUserSubscriptionsXml
/// <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);
}
示例12: GetAllUsersWithResponse
/// <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;
}
示例13: CreateNotificationEmail
///<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);
}
}
}
示例14: GenerateArticleSearchXml
//.........这里部分代码省略.........
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"));
示例15: GetUserCategoryLists
/// <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());
}
}
}