本文整理汇总了C#中IDnaDataReaderCreator类的典型用法代码示例。如果您正苦于以下问题:C# IDnaDataReaderCreator类的具体用法?C# IDnaDataReaderCreator怎么用?C# IDnaDataReaderCreator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IDnaDataReaderCreator类属于命名空间,在下文中一共展示了IDnaDataReaderCreator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateTermForModClassId
/// <summary>
/// Calls the db and updates the term and action for a given modclassid
/// </summary>
/// <param name="readerCreator"></param>
/// <param name="modClassId"></param>
/// <param name="historyId"></param>
public bool UpdateTermForModClassId(IDnaDataReaderCreator readerCreator, int modClassId, int historyId)
{
if (string.IsNullOrEmpty(Value))
{//if empty then throw exception
throw new Exception("Term value cannot be empty.");
}
if (historyId == 0)
{//if empty then throw exception
throw new Exception("HistoryId cannot be 0.");
}
if (modClassId == 0)
{//if empty then throw exception
throw new Exception("ModClassId cannot be 0.");
}
bool termUpdated = true;
using (IDnaDataReader reader = readerCreator.CreateDnaDataReader("addtermsfilterterm"))
{
reader.AddParameter("term", Value);
reader.AddParameter("actionId", (byte)Action);
reader.AddParameter("modClassId", modClassId);
reader.AddParameter("historyId", historyId);
reader.Execute();
if (reader.HasRows && reader.Read())
{
termUpdated = reader.GetBoolean("termupdated");
}
}
return termUpdated;
}
示例2: CreateFromDatabase
static public ReviewForum CreateFromDatabase(IDnaDataReaderCreator readerCreator, int id, bool isReviewForumID)
{
ReviewForum forum = new ReviewForum()
{
Id = id
};
using (IDnaDataReader reader = readerCreator.CreateDnaDataReader("fetchreviewforumdetails"))
{
if (isReviewForumID)
{
reader.AddParameter("reviewforumid", id);
}
else
{
reader.AddParameter("h2g2id", id);
}
reader.Execute();
// Check to see if we found anything
if (reader.HasRows && reader.Read())
{
forum.Id = reader.GetInt32NullAsZero("ReviewForumID");
forum.ForumName = reader.GetStringNullAsEmpty("forumname");
forum.UrlFriendlyName = reader.GetStringNullAsEmpty("urlfriendlyname");
forum.H2g2Id = reader.GetInt32NullAsZero("h2g2id");
forum.SiteId = reader.GetInt32NullAsZero("siteid");
forum.IncubateTime = reader.GetInt32NullAsZero("IncubateTime");
forum.Recommendable= reader.GetByteNullAsZero("recommend");
}
}
return forum;
}
示例3: GetRelatedMembers
static public ArticleInfoRelatedMembers GetRelatedMembers(int h2g2Id, IDnaDataReaderCreator readerCreator)
{
ArticleInfoRelatedMembers members = new ArticleInfoRelatedMembers();
members.RelatedArticles = RelatedArticle.GetRelatedArticles(h2g2Id, readerCreator);
members.RelatedClubs = RelatedClubs.GetRelatedClubs(h2g2Id, readerCreator);
return members;
}
示例4: CreateSubmittable
static public ArticleInfoSubmittable CreateSubmittable(IDnaDataReaderCreator readerCreator, int h2g2Id, bool isSubmittable)
{
ArticleInfoSubmittable submittable = new ArticleInfoSubmittable();
using (IDnaDataReader reader = readerCreator.CreateDnaDataReader("fetchreviewforummemberdetails"))
{
reader.AddParameter("h2g2id", h2g2Id);
reader.Execute();
if (reader.HasRows && reader.Read())
{
submittable.Forum = new SubmittableForum(){Id=reader.GetInt32("ForumID")};
submittable.Thread = new SubmittableThread() { Id = reader.GetInt32("ThreadID") };
submittable.Post = new SubmittablePost() { Id = reader.GetInt32("PostID") };
submittable.Type = "IN";
submittable.ReviewForum = ReviewForum.CreateFromDatabase(readerCreator, reader.GetInt32("ReviewForumID"), true);
}
else if (isSubmittable)
{
submittable.Type = "YES";
}
else
{
submittable.Type = "NO";
}
}
return submittable;
}
示例5: LoadSmileys
/// <summary>
/// Load list of smileys which need to be replaced by Smiley XML.
/// Generate XML replacements.
/// Generate RegEx to match smiley shortcode.
/// </summary>
/// <returns></returns>
public static void LoadSmileys(IDnaDataReaderCreator creator)
{
Replacements.Clear();
TagReplacements.Clear();
IsInitialised = false;
String regex = String.Empty;
using (IDnaDataReader dataReader = creator.CreateDnaDataReader("getsmileylist"))
{
dataReader.Execute();
while (dataReader.Read())
{
String name = dataReader.GetStringNullAsEmpty("name");
String shorthand = dataReader.GetStringNullAsEmpty("tag");
String replace = "<SMILEY TYPE='***' H2G2='Smiley#***'/>";
shorthand = StringUtils.EscapeAllXml(shorthand);
if (shorthand.IndexOf("<") == 0)
{
TagReplacements.Add(shorthand, replace.Replace("***", name));
}
else
{
Replacements.Add(shorthand, replace.Replace("***", name));
}
}
}
IsInitialised = true;
}
示例6: CallingUser
/// <summary>
/// Debug constructor
/// </summary>
/// <param name="signInSystem">The sign in system to use</param>
/// <param name="dnaDataReaderCreator">A DnaDataReaderCreator object for creating the procedure this class needs.
/// If NULL, it uses the connection stringsfrom the configuration manager</param>
/// <param name="dnaDiagnostics">A DnaDiagnostics object for logging purposes</param>
/// <param name="caching">The caching object that the class can use for caching</param>
/// <param name="debugUserID">A userid for debugging/testing purposes</param>
/// <param name="siteList">A SiteList object for getting siteoption values</param>
public CallingUser(SignInSystem signInSystem, IDnaDataReaderCreator dnaDataReaderCreator, IDnaDiagnostics dnaDiagnostics, ICacheManager caching, string debugUserID, ISiteList siteList)
: base(dnaDataReaderCreator, dnaDiagnostics, caching)
{
_signInSystem = signInSystem;
_debugUserID = debugUserID;
_siteList = siteList;
}
示例7: 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;
}
示例8: CreateListForArticle
static public ArticleInfoPageAuthor CreateListForArticle(int h2g2Id, int editorId, IDnaDataReaderCreator readerCreator)
{
ArticleInfoPageAuthor author = new ArticleInfoPageAuthor();
// Create the datareader to get the authors
using (IDnaDataReader reader = readerCreator.CreateDnaDataReader("getauthorsfromh2g2id"))
{
reader.AddParameter("h2g2ID", h2g2Id);
reader.Execute();
// Now go through all the results in turn
int lastUserID = 0;
while (reader.Read())
{
// Get the current researcher
int researcherID = reader.GetInt32("UserID");
if (researcherID != lastUserID)
{
// Check to see if we've just got the editors results
User researcher = User.CreateUserFromReader(reader);
author.Researchers.Add(researcher);
if (researcherID == editorId)
{
author.Editor = new UserElement() { user = researcher };
}
lastUserID = researcherID;
}
}
}
return author;
}
示例9: RegisterComplaint
/// <summary>
/// Registers complaint against post
/// </summary>
/// <param name="creator"></param>
/// <param name="userId"></param>
/// <param name="complaintText"></param>
/// <param name="email"></param>
/// <param name="postId"></param>
/// <param name="verificationUid"></param>
/// <param name="modId"></param>
public static void RegisterComplaint(IDnaDataReaderCreator creator, int userId, String complaintText,
String email, int postId, string ipAddress, Guid bbcUid, out Guid verificationUid, out int modId)
{
verificationUid = Guid.Empty;
modId = 0;
using (IDnaDataReader dataReader = creator.CreateDnaDataReader("registerpostingcomplaint"))
{
dataReader.AddParameter("complainantid", userId);
dataReader.AddParameter("correspondenceemail", email);
dataReader.AddParameter("postid", postId);
dataReader.AddParameter("complainttext", complaintText);
dataReader.AddParameter("ipaddress", ipAddress);
dataReader.AddParameter("bbcuid", bbcUid);
//HashValue
Guid hash = DnaHasher.GenerateHash(Convert.ToString(userId) + ":" + email + ":" + Convert.ToString(postId) + ":" + complaintText);
dataReader.AddParameter("hash", hash);
dataReader.Execute();
// Send Email
if (dataReader.Read())
{
if (dataReader.DoesFieldExist("modId"))
{
modId = dataReader.GetInt32NullAsZero("modId");
}
if (dataReader.DoesFieldExist("verificationUid"))
{
verificationUid = dataReader.GetGuid("verificationUid");
}
}
}
}
示例10: HasGroupAlertOnItem
/// <summary>
/// Checks if an item has a group alert
/// </summary>
/// <param name="reader"></param>
/// <param name="groupId"></param>
/// <param name="userId"></param>
/// <param name="siteId"></param>
/// <param name="itemType"></param>
/// <param name="itemId"></param>
static public void HasGroupAlertOnItem(IDnaDataReaderCreator readerCreator, ref int groupId, int userId, int siteId, EventItemTypes itemType, int itemId)
{
groupId =0;
IDnaDataReader reader = null;
switch (itemType)
{
case EventItemTypes.IT_FORUM: reader = readerCreator.CreateDnaDataReader("getforumgroupalertid"); reader.AddParameter("itemid", itemId); break;
case EventItemTypes.IT_H2G2: reader = readerCreator.CreateDnaDataReader("getarticlegroupalertid"); reader.AddParameter("itemid", itemId); break;
case EventItemTypes.IT_NODE: reader = readerCreator.CreateDnaDataReader("getnodegroupalertid"); reader.AddParameter("nodeid", itemId); break;
case EventItemTypes.IT_THREAD: reader = readerCreator.CreateDnaDataReader("getthreadgroupalertid"); reader.AddParameter("threadid", itemId); break;
case EventItemTypes.IT_CLUB: reader = readerCreator.CreateDnaDataReader("getclubgroupalertid"); reader.AddParameter("itemid", itemId); break;
default: throw new NotImplementedException();
}
using (reader)
{
reader.AddParameter("userid", userId);
reader.AddParameter("siteid", siteId);
reader.Execute();
if (reader.Read())
{
groupId = reader.GetInt32NullAsZero("GroupID");
}
}
}
示例11: CreateMockedDataBaseObjects
/// <summary>
/// Creates a mocked datareader and loads it with row data ready to replay
/// </summary>
/// <param name="mocks">The mock repository object that all the tests are running with</param>
/// <param name="procedureName">The name of the procedure you want to call</param>
/// <param name="creator">The new DataReaderCreator object</param>
/// <param name="reader">The new DataReader object</param>
/// <param name="testRowData">A list of test row data to load the reader with</param>
static public void CreateMockedDataBaseObjects(MockRepository mocks, string procedureName, out IDnaDataReaderCreator creator, out IDnaDataReader reader, List<TestDatabaseRow> testRowData)
{
reader = CreateMockedIDnaDataReader(mocks, testRowData);
creator = mocks.DynamicMock<IDnaDataReaderCreator>();
creator.Stub(x => x.CreateDnaDataReader(procedureName)).Return(reader);
mocks.ReplayAll();
}
示例12: CreateForumTermAdmin
/// <summary>
/// Creates the forum specific term admin object
/// </summary>
/// <param name="readerCreator"></param>
/// <param name="cacheManager"></param>
/// <param name="forumId"></param>
/// <returns></returns>
public static TermsFilterAdmin CreateForumTermAdmin(IDnaDataReaderCreator readerCreator, ICacheManager cacheManager,
int forumId)
{
var termAdmin = new TermsFilterAdmin(forumId, true);
termAdmin.TermsList = TermsList.GetTermsListByForumId(readerCreator, cacheManager, forumId, true);
return termAdmin;
}
示例13: GetChildArticles
public static List<ArticleSummary> GetChildArticles(IDnaDataReaderCreator readerCreator, int nodeID, int siteID)
{
List<ArticleSummary> childArticles = new List<ArticleSummary>();
using (IDnaDataReader reader = readerCreator.CreateDnaDataReader("getarticlesinhierarchynode"))
{
reader.AddParameter("nodeID", nodeID);
reader.AddParameter("currentsiteid", siteID);
reader.Execute();
if (reader.HasRows)
{
while (reader.Read())
{
ArticleSummary childArticle = new ArticleSummary();
childArticle.H2G2ID = reader.GetInt32NullAsZero("h2g2id");
childArticle.Name = reader.GetStringNullAsEmpty("subject");
childArticle.StrippedName = StringUtils.StrippedName(reader.GetStringNullAsEmpty("subject"));
childArticle.Type = Article.GetArticleTypeFromInt(reader.GetInt32NullAsZero("Type"));
childArticle.Editor = new UserElement() { user = User.CreateUserFromReader(reader, "editor")} ;
childArticle.DateCreated = new DateElement(reader.GetDateTime("datecreated"));
childArticle.LastUpdated = new DateElement(reader.GetDateTime("lastupdated")); ;
//childArticle.SortOrder = null;
childArticle.Status = ArticleStatus.GetStatus(reader.GetInt32NullAsZero("status"));
childArticles.Add(childArticle);
}
}
}
return childArticles;
}
示例14: 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;
}
示例15: Context
public Context(IDnaDiagnostics dnaDiagnostics, IDnaDataReaderCreator dataReaderCreator, ICacheManager cacheManager, ISiteList siteList)
{
DnaDiagnostics = dnaDiagnostics;
DnaDataReaderCreator = dataReaderCreator;
CacheManager = cacheManager;
SiteList = siteList;
}