本文整理汇总了C#中IDnaDataReader.GetStringNullAsEmpty方法的典型用法代码示例。如果您正苦于以下问题:C# IDnaDataReader.GetStringNullAsEmpty方法的具体用法?C# IDnaDataReader.GetStringNullAsEmpty怎么用?C# IDnaDataReader.GetStringNullAsEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDnaDataReader
的用法示例。
在下文中一共展示了IDnaDataReader.GetStringNullAsEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessAllowedURLListData
private void ProcessAllowedURLListData(IDnaDataReader dataReader)
{
int currentSiteID = 1;
int siteID = 1;
_allowedURLsList.Clear();
//For each row/site in the database add it's details
if (dataReader.Read())
{
siteID = dataReader.GetInt32NullAsZero("SiteID");
currentSiteID = siteID;
List<string> siteAllowedURLs = new List<string>();
string allowedURL = dataReader.GetStringNullAsEmpty("URL").ToLower();
siteAllowedURLs.Add(allowedURL);
while (dataReader.Read())
{
siteID = dataReader.GetInt32NullAsZero("SiteID");
if (siteID != currentSiteID)
{
_allowedURLsList.Add(currentSiteID, siteAllowedURLs);
siteAllowedURLs.Clear();
currentSiteID = siteID;
}
allowedURL = dataReader.GetStringNullAsEmpty("URL").ToLower();
siteAllowedURLs.Add(allowedURL);
}
_allowedURLsList.Add(currentSiteID, siteAllowedURLs);
}
}
示例2: CreateComplaintArticleEventActivity
static public SiteEvent CreateComplaintArticleEventActivity(IDnaDataReader dataReader, IDnaDataReaderCreator creator)
{
SiteEvent siteEvent = null;
try
{
siteEvent = new SiteEvent();
siteEvent.SiteId = dataReader.GetInt32NullAsZero("siteid");
siteEvent.Date = new Date(dataReader.GetDateTime("DateCreated"));
siteEvent.Type = SiteActivityType.ComplaintArticle;
var complainantUserName = dataReader.GetStringNullAsEmpty("complainantUserName");
if (String.IsNullOrEmpty(complainantUserName))
{
complainantUserName = "Anonymous";
}
siteEvent.ActivityData = XElement.Parse(
string.Format(DataFormat,
dataReader.GetInt32NullAsZero("complaintantID_userid"), complainantUserName,
dataReader.GetInt32NullAsZero("h2g2id"), dataReader.GetStringNullAsEmpty("subject"),
dataReader.GetStringNullAsEmpty("complainttext"))
);
siteEvent.UserId = 0;
siteEvent.SaveEvent(creator);
}
catch(Exception e)
{
siteEvent = null;
SiteEventsProcessor.SiteEventLogger.LogException(e);
}
return siteEvent;
}
示例3: CreateLinkFromReader
public static Link CreateLinkFromReader(IDnaDataReader reader)
{
Link link = new Link();
link.Type = reader.GetStringNullAsEmpty("destinationtype");
link.LinkId = reader.GetInt32NullAsZero("linkid");
link.TeamId = reader.GetInt32NullAsZero("teamid");
link.Relationship = reader.GetStringNullAsEmpty("relationship");
link.Private = reader.GetTinyIntAsInt("private");
link.Description = reader.GetStringNullAsEmpty("linkdescription");
link.DateLinked = new DateElement(reader.GetDateTime("DateLinked"));
link.Submitter = new UserElement() { user = BBC.Dna.Objects.User.CreateUserFromReader(reader, "submitter") };
//Create appropriate URL from link type.
int destinationId = reader.GetInt32NullAsZero("DestinationID");
switch (link.Type)
{
case "article":
{
link.DnaUid = "A" + destinationId.ToString();
break;
}
case "userpage":
{
link.DnaUid = "U" + destinationId.ToString();
break;
}
case "category":
{
link.DnaUid = "C" + destinationId.ToString();
break;
}
case "forum":
{
link.DnaUid = "F" + destinationId.ToString();
break;
}
case "thread":
{
link.DnaUid = "T" + destinationId.ToString();
break;
}
case "posting":
{
link.DnaUid = "TP" + destinationId.ToString();
break;
}
default: // "club" )
{
link.DnaUid = "G" + destinationId.ToString();
break;
}
}
return link;
}
示例4: CreateNewUserEventActivity
static public SiteEvent CreateNewUserEventActivity(IDnaDataReader dataReader, IDnaDataReaderCreator creator)
{
SiteEvent siteEvent = null;
try
{
siteEvent = new SiteEvent();
siteEvent.SiteId = dataReader.GetInt32NullAsZero("siteid");
siteEvent.Date = new Date(dataReader.GetDateTime("DateCreated"));
siteEvent.Type = SiteActivityType.NewUserToSite;
siteEvent.ActivityData = XElement.Parse(
string.Format(DataFormat,
dataReader.GetInt32NullAsZero("user_userid"), dataReader.GetStringNullAsEmpty("user_username"),
dataReader.GetInt32NullAsZero("siteid"))
);
siteEvent.UserId = dataReader.GetInt32NullAsZero("user_userid");
siteEvent.SaveEvent(creator);
}
catch(Exception e)
{
siteEvent = null;
SiteEventsProcessor.SiteEventLogger.LogException(e);
}
return siteEvent;
}
示例5: GetTopicFromReader
/// <summary>
/// Gets the topic elements from the current reader.
/// </summary>
/// <param name="reader"></param>
/// <returns></returns>
static public TopicElement GetTopicFromReader(IDnaDataReader reader)
{
var topicEdit = new TopicElement();
topicEdit.TopicId = reader.GetInt32NullAsZero("topicid");
topicEdit.H2G2Id = reader.GetInt32NullAsZero("h2g2ID");
topicEdit.SiteId = reader.GetInt32NullAsZero("SiteID");
topicEdit.TopicStatus = (TopicStatus)reader.GetInt32NullAsZero("TopicStatus");
topicEdit.Title = reader.GetStringNullAsEmpty("TITLE");
topicEdit.ForumId = reader.GetInt32NullAsZero("ForumID");
topicEdit.Description = reader.GetStringNullAsEmpty("description");
topicEdit.Position = reader.GetInt32NullAsZero("position");
topicEdit.TopicLinkId = reader.GetInt32NullAsZero("topiclinkid");
topicEdit.Createdby = new TopicCreatedDate
{
CreatedDate = new DateElement(reader.GetDateTime("createddate")),
Username = reader.GetStringNullAsEmpty("CreatedByUserName"),
Userid = reader.GetInt32NullAsZero("CreatedByUserID")
};
topicEdit.Updatedby = new TopicLastUpdated()
{
LastUpdated = new DateElement(reader.GetDateTime("LastUpdated")),
Username = reader.GetStringNullAsEmpty("UpdatedByUserName"),
Userid = reader.GetInt32NullAsZero("UpdatedByUserID")
};
topicEdit.Style = reader.GetInt32NullAsZero("style");
topicEdit.ForumPostCount = reader.GetInt32NullAsZero("forumpostcount");
topicEdit.FrontPageElement.Elementid = reader.GetInt32NullAsZero("FP_ElementID");
topicEdit.FrontPageElement.Position = reader.GetInt32NullAsZero("FP_Position");
topicEdit.FrontPageElement.Title = reader.GetStringNullAsEmpty("FP_Title");
topicEdit.FrontPageElement.TemplateElement = reader.GetInt32NullAsZero("FP_Template");
topicEdit.FrontPageElement.Text = reader.GetStringNullAsEmpty("FP_Text");
topicEdit.FrontPageElement.ImageName = reader.GetStringNullAsEmpty("FP_ImageName");
topicEdit.FrontPageElement.ImageAltText = reader.GetStringNullAsEmpty("FP_ImageAltText");
topicEdit.FrontPageElement.ForumPostCount = reader.GetInt32NullAsZero("forumpostcount");
topicEdit.FrontPageElement.TopicId = reader.GetInt32NullAsZero("topicid");
topicEdit.Fastmod = reader.GetInt32NullAsZero("fastmod");
topicEdit.Editkey = reader.GetGuid("editkey");
topicEdit.FrontPageElement.Editkey = reader.GetGuid("FP_EditKey");
return topicEdit;
}
示例6: CreatePostThreadInfoFromReader
public static PostThreadInfo CreatePostThreadInfoFromReader(IDnaDataReader reader)
{
PostThreadInfo postThreadInfo = new PostThreadInfo();
postThreadInfo.ForumId = reader.GetInt32NullAsZero("ForumId");
postThreadInfo.ThreadId = reader.GetInt32NullAsZero("ThreadId");
string type = reader.GetStringNullAsEmpty("Type");
if (type == "")
{
postThreadInfo.Type = 0;
}
else if (type == "Notice")
{
postThreadInfo.Type = 1;
}
else if (type == "Event")
{
postThreadInfo.Type = 2;
}
else
{
postThreadInfo.Type = 3;
}
if (reader.DoesFieldExist("FirstPostId"))
{
postThreadInfo.FirstPostId = reader.GetInt32NullAsZero("FirstPostId");
}
if (reader["DateFirstPosted"] != DBNull.Value)
{
postThreadInfo.DateFirstPosted = new DateElement(reader.GetDateTime("DateFirstPosted"));
}
if (reader["LastReply"] != DBNull.Value)
{
postThreadInfo.ReplyDate = new DateElement(reader.GetDateTime("LastReply"));
}
postThreadInfo.Subject = reader.GetStringNullAsEmpty("FirstSubject");
postThreadInfo.ForumTitle = reader.GetStringNullAsEmpty("ForumTitle");
if (reader.DoesFieldExist("JournalUserID"))
{
postThreadInfo.Journal = new UserElement() { user = BBC.Dna.Objects.User.CreateUserFromReader(reader, "Journal") };
}
return postThreadInfo;
}
示例7: CreateArticleModerationDecisionActivity
static public SiteEvent CreateArticleModerationDecisionActivity(IDnaDataReader dataReader, IDnaDataReaderCreator creator)
{
SiteEvent siteEventArticleModerationDecision = null;
try
{
siteEventArticleModerationDecision = new SiteEvent();
siteEventArticleModerationDecision.SiteId = dataReader.GetInt32NullAsZero("siteid");
siteEventArticleModerationDecision.Date = new Date(dataReader.GetDateTime("DateCreated"));
var statusId = dataReader.GetInt32NullAsZero("statusid");
switch ((ModerationDecisionStatus)statusId)
{
case ModerationDecisionStatus.Fail:
siteEventArticleModerationDecision.Type = SiteActivityType.ModerateArticleFailed;
siteEventArticleModerationDecision.ActivityData = XElement.Parse(
string.Format(DataFormatFailed, dataReader.GetInt32NullAsZero("h2g2id"),
dataReader.GetInt32NullAsZero("author_userid"), dataReader.GetStringNullAsEmpty("author_username"),
dataReader.GetInt32NullAsZero("mod_userid"), dataReader.GetStringNullAsEmpty("mod_username"),
dataReader.GetStringNullAsEmpty("ModReason")
));
break;
case ModerationDecisionStatus.Referred:
siteEventArticleModerationDecision.Type = SiteActivityType.ModerateArticleReferred;
siteEventArticleModerationDecision.ActivityData = XElement.Parse(
string.Format(DataFormatReferred, dataReader.GetInt32NullAsZero("h2g2id"),
dataReader.GetInt32NullAsZero("author_userid"), dataReader.GetStringNullAsEmpty("author_username"),
dataReader.GetInt32NullAsZero("mod_userid"), dataReader.GetStringNullAsEmpty("mod_username"),
dataReader.GetStringNullAsEmpty("Notes"))
);
break;
default:
siteEventArticleModerationDecision = null;
break;
}
siteEventArticleModerationDecision.UserId = 0;
siteEventArticleModerationDecision.SaveEvent(creator);
}
catch(Exception e)
{
siteEventArticleModerationDecision = null;
SiteEventsProcessor.SiteEventLogger.LogException(e);
}
return siteEventArticleModerationDecision;
}
示例8: GenerateMemberListXml
/// <summary>
///
/// </summary>
/// <param name="dataReader"></param>
/// <param name="userSearchType"></param>
/// <param name="searchText"></param>
/// <param name="checkAllSites"></param>
/// <param name="twitterAPIException"></param>
public void GenerateMemberListXml(
IDnaDataReader dataReader,
int userSearchType,
string searchText,
bool checkAllSites,
string twitterAPIException)
{
int count = 0;
XmlNode memberList = AddElementTag(RootElement, "MEMBERLIST");
AddAttribute(memberList, "USERSEARCHTYPE", userSearchType.ToString());
AddAttribute(memberList, "SEARCHTEXT", searchText);
AddAttribute(memberList, "CHECKALLSITES", checkAllSites.ToString());
if (dataReader.HasRows)
{
if (dataReader.Read())
{
XmlNode userAccounts = AddElementTag(memberList, "USERACCOUNTS");
//int previousUserID = 0;
XmlNode userAccount = null;
do
{
int userID = dataReader.GetInt32NullAsZero("USERID");
/*if (userID != previousUserID)
{
if (userAccount != null)
{
userAccounts.AppendChild(userAccount);
}
userAccount = CreateElementNode("USERACCOUNT");
previousUserID = userID;
}*/
userAccount = CreateElementNode("USERACCOUNT");
//Start filling new user xml
AddAttribute(userAccount, "USERID", userID);
AddTextTag(userAccount, "SITEID", dataReader.GetInt32NullAsZero("SITEID"));
AddTextTag(userAccount, "USERNAME", dataReader.GetStringNullAsEmpty("USERNAME"));
AddTextTag(userAccount, "LOGINNAME", dataReader.GetStringNullAsEmpty("LOGINNAME"));
AddTextTag(userAccount, "EMAIL", dataReader.GetStringNullAsEmpty("EMAIL"));
AddTextTag(userAccount, "PREFSTATUS", dataReader.GetInt32NullAsZero("PREFSTATUS"));
AddTextTag(userAccount, "PREFSTATUSDURATION", dataReader.GetInt32NullAsZero("PREFSTATUSDURATION"));
AddTextTag(userAccount, "USERSTATUSDESCRIPTION", ((ModerationStatus.UserStatus)dataReader.GetInt32NullAsZero("PREFSTATUS")).ToString());
if (!dataReader.IsDBNull("DATEJOINED"))
{
AddDateXml(dataReader.GetDateTime("DATEJOINED"), userAccount, "DATEJOINED");
}
if (!dataReader.IsDBNull("PREFSTATUSCHANGEDDATE"))
{
DateTime prefStatusChangedDate = dataReader.GetDateTime("PREFSTATUSCHANGEDDATE");
AddDateXml(prefStatusChangedDate, userAccount, "PREFSTATUSCHANGEDDATE");
}
else
{
AddTextTag(userAccount, "PREFSTATUSCHANGEDDATE", "");
}
AddTextTag(userAccount, "SHORTNAME", dataReader.GetStringNullAsEmpty("SHORTNAME"));
AddTextTag(userAccount, "URLNAME", dataReader.GetStringNullAsEmpty("URLNAME"));
if (dataReader.DoesFieldExist("IPADDRESS") && dataReader.GetStringNullAsEmpty("IPADDRESS") != String.Empty)
{
AddTextTag(userAccount, "IPADDRESS", dataReader.GetStringNullAsEmpty("IPADDRESS"));
}
if (dataReader.DoesFieldExist("BBCUID") && dataReader.GetGuidAsStringOrEmpty("BBCUID") != String.Empty)
{
AddTextTag(userAccount, "BBCUID", dataReader.GetGuidAsStringOrEmpty("BBCUID"));
}
if (userSearchType == 6)
{
AddTextTag(userAccount, "TWITTERUSERID", dataReader.GetStringNullAsEmpty("TwitterUserID"));
}
else
{
AddIntElement(userAccount, "SSOUSERID", dataReader.GetInt32NullAsZero("SSOUserID"));
}
AddTextTag(userAccount, "IDENTITYUSERID", dataReader.GetStringNullAsEmpty("IdentityUserID"));
AddIntElement(userAccount, "ACTIVE", dataReader.GetInt32NullAsZero("STATUS") != 0 ? 1:0);
userAccounts.AppendChild(userAccount);
count++;
} while (dataReader.Read());
memberList.AppendChild(userAccounts);
}
}
//.........这里部分代码省略.........
示例9: 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);
}
示例10: CreateUserFromReader
/// <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 = "Member " + 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"))
//.........这里部分代码省略.........
示例11: AddMessageXML
private void AddMessageXML(IDnaDataReader dataReader, XmlElement parent)
{
XmlElement message = AddElementTag(parent, "MESSAGE");
AddAttribute(message, "MSGID", dataReader.GetInt32NullAsZero("MsgID"));
AddAttribute(message, "SITEID", dataReader.GetInt32NullAsZero("SiteID"));
AddTextTag(message, "BODY", dataReader.GetStringNullAsEmpty("MESSAGEBODY"));
AddDateXml(dataReader, message, "DatePosted", "DATEPOSTED");
}
示例12: CreateFormXml
private void CreateFormXml(IDnaDataReader dataReader, string comments, bool acceptButton, bool rejectButton, bool cancelButton, bool fetchButton, bool byRecommendationID)
{
RootElement.RemoveAll();
_processRecommendationForm = AddElementTag(RootElement, "PROCESS-RECOMMENDATION-FORM");
int recommendationID = dataReader.GetInt32NullAsZero("recommendationID");
int h2g2ID = dataReader.GetInt32NullAsZero("h2g2ID");
int entryID = dataReader.GetInt32NullAsZero("entryID");
string entrySubject = dataReader.GetStringNullAsEmpty("Subject");
int editorID = dataReader.GetInt32NullAsZero("EditorID");
string editorName = dataReader.GetStringNullAsEmpty("EditorName");
User editor = new User(InputContext);
int scoutID = dataReader.GetInt32NullAsZero("ScoutID");
string scoutName = dataReader.GetStringNullAsEmpty("ScoutName");
User scout = new User(InputContext);
DateTime dateRecommended = dataReader.GetDateTime("DateRecommended");
string retrievedComments = dataReader.GetStringNullAsEmpty("Comments");
AddIntElement(_processRecommendationForm, "RECOMMENDATION-ID", recommendationID);
AddIntElement(_processRecommendationForm, "H2G2-ID", h2g2ID);
AddTextTag(_processRecommendationForm, "SUBJECT", entrySubject);
AddTextTag(_processRecommendationForm, "COMMENTS", retrievedComments);
XmlElement editorElement = AddElementTag(_processRecommendationForm, "EDITOR");
editor.AddPrefixedUserXMLBlock(dataReader, editorID, "editor", editorElement);
XmlElement scoutElement = AddElementTag(_processRecommendationForm, "SCOUT");
scout.AddPrefixedUserXMLBlock(dataReader, scoutID, "scout", scoutElement);
AddDateXml(dateRecommended, _processRecommendationForm, "DATE-RECOMMENDED");
// if we know what the decision is going to be then create an appropriate
// default email to send
string scoutEmailSubject = String.Empty;
string scoutEmailText = String.Empty;
string authorEmailSubject = String.Empty;
string authorEmailText = String.Empty;
if (acceptButton && !rejectButton)
{
CreateScoutAcceptanceEmail(scoutName, entrySubject, h2g2ID, dateRecommended, ref scoutEmailSubject, ref scoutEmailText);
if (byRecommendationID)
{
CreateAuthorAcceptanceEmail(editorName, entrySubject, h2g2ID, dateRecommended, ref authorEmailSubject, ref authorEmailText);
}
}
else if (rejectButton && !acceptButton)
{
CreateScoutRejectionEmail(scoutName, entrySubject, h2g2ID, dateRecommended, ref scoutEmailSubject, ref scoutEmailText);
}
if (byRecommendationID)
{
XmlElement scoutEmail = AddElementTag(_processRecommendationForm, "SCOUT-EMAIL");
AddTextTag(scoutEmail, "SUBJECT", scoutEmailSubject);
AddTextTag(scoutEmail, "TEXT", scoutEmailText);
XmlElement authorEmail = AddElementTag(_processRecommendationForm, "AUTHOR-EMAIL");
AddTextTag(authorEmail, "SUBJECT", authorEmailSubject);
AddTextTag(authorEmail, "TEXT", authorEmailText);
}
else
{
AddTextTag(_processRecommendationForm, "EMAIL-SUBJECT", scoutEmailSubject);
AddTextTag(_processRecommendationForm, "EMAIL-TEXT", scoutEmailText);
}
XmlElement functions = AddElementTag(_processRecommendationForm, "FUNCTIONS");
if (acceptButton)
{
AddElementTag(functions, "ACCEPT");
}
if (rejectButton)
{
AddElementTag(functions, "REJECT");
}
if (cancelButton)
{
AddElementTag(functions, "CANCEL");
}
if (fetchButton)
{
AddElementTag(functions, "FETCH");
}
}
示例13: CreateUserModatedEventActivity
static public SiteEvent CreateUserModatedEventActivity(IDnaDataReader dataReader, IDnaDataReaderCreator creator)
{
SiteEvent siteEvent = null;
try
{
siteEvent = new SiteEvent();
siteEvent.SiteId = dataReader.GetInt32NullAsZero("siteid");
siteEvent.Date = new Date(dataReader.GetDateTime("DateCreated"));
var duration = "";
var moderationStatus = "";
switch ((ModerationStatus.UserStatus)dataReader.GetInt32NullAsZero("status"))
{
case ModerationStatus.UserStatus.Postmoderated:
siteEvent.Type = SiteActivityType.UserModeratedPostMod;
moderationStatus = "postmoderated";
break;
case ModerationStatus.UserStatus.Premoderated:
siteEvent.Type = SiteActivityType.UserModeratedPremod;
moderationStatus = "premoderated";
break;
case ModerationStatus.UserStatus.Restricted:
siteEvent.Type = SiteActivityType.UserModeratedBanned;
moderationStatus = "banned";
break;
case ModerationStatus.UserStatus.Deactivated:
siteEvent.Type = SiteActivityType.UserModeratedDeactivated;
moderationStatus = "deactivated";
break;
case ModerationStatus.UserStatus.Standard:
siteEvent.Type = SiteActivityType.UserModeratedStandard;
moderationStatus = "returned to normal";
break;
case ModerationStatus.UserStatus.Trusted:
siteEvent.Type = SiteActivityType.UserModeratedTrusted;
moderationStatus = "trusted";
break;
default:
throw new Exception("Unknown moderation status: " + ((ModerationStatus.UserStatus)dataReader.GetInt32NullAsZero("status")).ToString());
}
switch(dataReader.GetInt32NullAsZero("prefduration"))
{
case 1440: duration = " for 1 day";break;
case 10080: duration = " for 1 week";break;
case 20160: duration = " for 2 weeks";break;
case 40320: duration = " for 1 month";break;
default:
if (dataReader.GetInt32NullAsZero("prefduration") > 0)
{
duration = " for " + dataReader.GetInt32NullAsZero("prefduration").ToString() + " hours";
}
break;
}
siteEvent.ActivityData = XElement.Parse(
string.Format(DataFormat,
dataReader.GetInt32NullAsZero("user_userid"), dataReader.GetStringNullAsEmpty("user_username"),
dataReader.GetInt32NullAsZero("status"), moderationStatus, dataReader.GetInt32NullAsZero("siteid"),
dataReader.GetInt32NullAsZero("mod_userid"), dataReader.GetStringNullAsEmpty("mod_username"),
duration, dataReader.GetStringNullAsEmpty("modreason"))
);
siteEvent.UserId = dataReader.GetInt32NullAsZero("user_userid");
if (siteEvent != null)
{
siteEvent.SaveEvent(creator);
}
}
catch(Exception e)
{
siteEvent = null;
SiteEventsProcessor.SiteEventLogger.LogException(e);
}
return siteEvent;
}
示例14: CommentCreateFromReader
/// <summary>
/// Creates a commentinfo object
/// </summary>
/// <param name="reader">A reader with all information</param>
/// <param name="site">site information</param>
/// <returns>Comment info object</returns>
private CommentInfo CommentCreateFromReader(IDnaDataReader reader, ISite site)
{
var commentInfo = new CommentInfo
{
Created =
new DateTimeHelper(DateTime.Parse(reader.GetDateTime("Created").ToString())),
User = UserReadById(reader, site),
ID = reader.GetInt32NullAsZero("id")
};
commentInfo.hidden = (CommentStatus.Hidden) reader.GetInt32NullAsZero("hidden");
if (reader.IsDBNull("poststyle"))
{
commentInfo.PostStyle = PostStyle.Style.richtext;
}
else
{
commentInfo.PostStyle = (PostStyle.Style) reader.GetTinyIntAsInt("poststyle");
}
commentInfo.IsEditorPick = reader.GetBoolean("IsEditorPick");
commentInfo.Index = reader.GetInt32NullAsZero("PostIndex");
//get complainant
var replacement = new Dictionary<string, string>();
replacement.Add("sitename", site.SiteName);
replacement.Add("postid", commentInfo.ID.ToString());
commentInfo.ComplaintUri = UriDiscoverability.GetUriWithReplacments(BasePath,
SiteList.GetSiteOptionValueString(site.SiteID, "General", "ComplaintUrl"),
replacement);
replacement = new Dictionary<string, string>();
replacement.Add("commentforumid", reader.GetString("forumuid"));
replacement.Add("sitename", site.SiteName);
commentInfo.ForumUri = UriDiscoverability.GetUriWithReplacments(BasePath,
UriDiscoverability.UriType.CommentForumById,
replacement);
replacement = new Dictionary<string, string>();
replacement.Add("parentUri", reader.GetString("parentUri"));
replacement.Add("postid", commentInfo.ID.ToString());
commentInfo.Uri = UriDiscoverability.GetUriWithReplacments(BasePath, UriDiscoverability.UriType.Comment,
replacement);
if(reader.DoesFieldExist("nerovalue"))
{
commentInfo.NeroRatingValue = reader.GetInt32NullAsZero("nerovalue");
}
if (reader.DoesFieldExist("neropositivevalue"))
{
commentInfo.NeroPositiveRatingValue = reader.GetInt32NullAsZero("neropositivevalue");
}
if (reader.DoesFieldExist("neronegativevalue"))
{
commentInfo.NeroNegativeRatingValue = reader.GetInt32NullAsZero("neronegativevalue");
}
if (reader.DoesFieldExist("tweetid"))
{
commentInfo.TweetId = reader.GetLongNullAsZero("tweetid");
}
commentInfo.text = CommentInfo.FormatComment(reader.GetStringNullAsEmpty("text"), commentInfo.PostStyle, commentInfo.hidden, commentInfo.User.Editor);
if (reader.DoesFieldExist("twitterscreenname"))
{
commentInfo.TwitterScreenName = reader.GetStringNullAsEmpty("twitterscreenname");
}
if (reader.DoesFieldExist("retweetid"))
{
commentInfo.RetweetId = reader.GetLongNullAsZero("retweetid");
}
if (reader.DoesFieldExist("retweetedby"))
{
commentInfo.RetweetedBy = reader.GetStringNullAsEmpty("retweetedby");
}
if (reader.DoesFieldExist("DmID"))
{
if (reader.IsDBNull("DmID") == false)
{
commentInfo.DistressMessage = IncludeDistressMessage(reader, site);
}
}
return commentInfo;
}
示例15: AddPrefixedUserXMLBlock
/// <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 = "Member " + 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"))
//.........这里部分代码省略.........