本文整理汇总了C#中User.AddPrefixedUserXMLBlock方法的典型用法代码示例。如果您正苦于以下问题:C# User.AddPrefixedUserXMLBlock方法的具体用法?C# User.AddPrefixedUserXMLBlock怎么用?C# User.AddPrefixedUserXMLBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类User
的用法示例。
在下文中一共展示了User.AddPrefixedUserXMLBlock方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: TryCreateComingUpXML
/// <summary>
/// Functions generates the TryCreateComingUp XML
/// </summary>
/// <param name="skip">Number of posts to skip</param>
/// <param name="show">Number of posts to show</param>
public void TryCreateComingUpXML(int skip, int show)
{
//Clean any existing XML.
RootElement.RemoveAll();
int recordsCount = 0;
int total = 0;
int numberToTryandGet = show + 1;
XmlElement recommendations = AddElementTag(RootElement, "RECOMMENDATIONS");
AddAttribute(recommendations, "COUNT", show);
AddAttribute(recommendations, "SKIPTO", skip);
using (IDnaDataReader dataReader = InputContext.CreateDnaDataReader("getacceptedentries"))
{
dataReader.AddParameter("siteID", InputContext.CurrentSite.SiteID);
dataReader.Execute();
// Check to see if we found anything
if (dataReader.HasRows && dataReader.Read())
{
//Read/skip over the skip number of rows so that the row that the first row that in the do below is
//the one required
for (int i = 0; i < skip; i++)
{
dataReader.Read();
}
do
{
string subject = dataReader.GetStringNullAsEmpty("Subject");
int guideStatus = dataReader.GetInt32NullAsZero("GuideStatus");
int acceptedStatus = dataReader.GetByteNullAsZero("AcceptedStatus");
int originalEntryID = dataReader.GetInt32NullAsZero("OriginalEntryID");
int originalh2g2ID = dataReader.GetInt32NullAsZero("Originalh2g2ID");
int newEntryID = dataReader.GetInt32NullAsZero("EntryID");
int newh2g2ID = dataReader.GetInt32NullAsZero("h2g2ID");
int subEditorID = dataReader.GetInt32NullAsZero("SubEditorID");
int scoutID = dataReader.GetInt32NullAsZero("ScoutID");
DateTime dateAllocated = DateTime.MinValue;
DateTime dateReturned = DateTime.MinValue;
bool existsDateAllocated = !dataReader.IsDBNull("DateAllocated");
bool existsDateReturned = !dataReader.IsDBNull("DateReturned");
if (existsDateAllocated)
{
dateAllocated = dataReader.GetDateTime("DateAllocated");
}
if (existsDateReturned)
{
dateReturned = dataReader.GetDateTime("DateReturned");
}
XmlElement recommendation = AddElementTag(recommendations, "RECOMMENDATION");
AddTextTag(recommendation, "SUBJECT", subject);
AddIntElement(recommendation, "ACCEPTEDSTATUS", acceptedStatus);
AddIntElement(recommendation, "GUIDESTATUS", guideStatus);
XmlElement original = AddElementTag(recommendation, "ORIGINAL");
AddIntElement(original, "ENTRYID", originalEntryID);
AddIntElement(original, "H2G2ID", originalh2g2ID);
XmlElement edited = AddElementTag(recommendation, "EDITED");
AddIntElement(edited, "ENTRYID", newEntryID);
AddIntElement(edited, "H2G2ID", newh2g2ID);
User user = new User(InputContext);
user.AddPrefixedUserXMLBlock(dataReader, scoutID, "scout", recommendation);
user = new User(InputContext);
user.AddPrefixedUserXMLBlock(dataReader, subEditorID, "subeditor", recommendation);
if (existsDateAllocated)
{
AddDateXml(dateAllocated, recommendation, "DATEALLOCATED");
}
if (existsDateReturned)
{
AddDateXml(dateReturned, recommendation, "DATERETURNED");
}
total++;
recordsCount++;
} while (dataReader.Read());
}
}
AddAttribute(recommendations, "COUNT", recordsCount);
AddAttribute(recommendations, "TOTAL", total);
}
示例3: 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);
}
示例4: CreateList
/// <summary>
/// Helper method to create the list after a specific stored procedure
/// has been called to return an appropriate results set.
/// </summary>
/// <param name="articleList"></param>
/// <param name="dataReader"></param>
/// <param name="skip">Number of Articles to skip</param>
/// <param name="show">Number of Articles to show</param>
/// <returns></returns>
public int CreateList(XmlElement articleList, IDnaDataReader dataReader, int skip, int show)
{
int count = show;
bool records = true;
//Read/skip over the skip number of rows so that the row that the first row that in the do below is
//the one required
for (int i = 0; i < skip; i++)
{
records = dataReader.Read();
if (!records)
{
break;
}
}
if (records)
{
do
{
// Setup the article
XmlElement article = AddElementTag(articleList, "ARTICLE");
if (dataReader.DoesFieldExist("EntryID"))
{
AddIntElement(article, "ENTRY-ID", dataReader.GetInt32NullAsZero("EntryID"));
}
if (dataReader.DoesFieldExist("h2g2ID"))
{
AddAttribute(article, "H2G2ID", dataReader.GetInt32NullAsZero("h2g2ID"));
//TODO: remove the H2G2-ID from all schemas and skins...
AddIntElement(article, "H2G2-ID", dataReader.GetInt32NullAsZero("h2g2ID"));
}
if (dataReader.DoesFieldExist("SiteID"))
{
AddIntElement(article, "SITEID", dataReader.GetInt32NullAsZero("SiteID"));
}
if (dataReader.DoesFieldExist("RecommendationID"))
{
AddIntElement(article, "RECOMMENDATION-ID", dataReader.GetInt32NullAsZero("RecommendationID"));
}
if (dataReader.DoesFieldExist("NotificationSent"))
{
AddIntElement(article, "NOTIFIED", dataReader.GetBoolean("NotificationSent") ? 1 : 0);
}
User user = new User(InputContext);
if (dataReader.DoesFieldExist("Editor"))
{
// place all user details within a USER tag and structure them appropriately
// editor info
int editorID = dataReader.GetInt32NullAsZero("Editor");
XmlElement editorTag = AddElementTag(article, "EDITOR");
user.AddPrefixedUserXMLBlock(dataReader, editorID, "Editor", editorTag);
}
if (dataReader.DoesFieldExist("AuthorID"))
{
// author info
int authorID = dataReader.GetInt32NullAsZero("AuthorID");
XmlElement authorTag = AddElementTag(article, "AUTHOR");
user.AddPrefixedUserXMLBlock(dataReader, authorID, "Author", authorTag);
}
if (dataReader.DoesFieldExist("AcceptorID"))
{
// acceptor info (user that accepted a recommendation)
int acceptorID = dataReader.GetInt32NullAsZero("AcceptorID");
XmlElement acceptorTag = AddElementTag(article, "ACCEPTOR");
user.AddPrefixedUserXMLBlock(dataReader, acceptorID, "Acceptor", acceptorTag);
}
if (dataReader.DoesFieldExist("AllocatorID"))
{
// allocator info (user that allocated a recommendation to a sub)
int allocatorID = dataReader.GetInt32NullAsZero("AllocatorID");
XmlElement allocatorTag = AddElementTag(article, "ALLOCATOR");
user.AddPrefixedUserXMLBlock(dataReader, allocatorID, "Allocator", allocatorTag);
}
if (dataReader.DoesFieldExist("ScoutID"))
{
// scout info
int scoutID = dataReader.GetInt32NullAsZero("ScoutID");
XmlElement scoutTag = AddElementTag(article, "SCOUT");
user.AddPrefixedUserXMLBlock(dataReader, scoutID, "Scout", scoutTag);
}
if (dataReader.DoesFieldExist("SubEditorID"))
{
// sub editor info
//.........这里部分代码省略.........