Exemplo n.º 1
0
        public static BIEvent CreateBiEvent(IDnaDataReader reader, ITheGuideSystem theGuideSys, IRiskModSystem riskModSys)
        {
            EventTypes et = (EventTypes)reader.GetInt32("EventType");
            
            BIEvent be = null;

            switch (et)
            {
                case EventTypes.ET_POSTNEEDSRISKASSESSMENT: be = new BIPostNeedsRiskAssessmentEvent(theGuideSys, riskModSys); break;
                case EventTypes.ET_POSTTOFORUM:             be = new BIPostToForumEvent(riskModSys); break;
                case EventTypes.ET_MODERATIONDECISION_POST: be = new BIPostModerationDecisionEvent(riskModSys); break;

                default: throw new InvalidOperationException("Event Type " + et.ToString() + " not supported");
            }

            be.SetProperties(reader);

            return be;
        }   
Exemplo n.º 2
0
        public bool RecordPostToForumEvent(BIPostToForumEvent ev, out bool? risky)
        {
            risky = null;

            // When disabled, don't record this event
            if (Disabled)
                return false;

            DateTime startTime = DateTime.Now;

            using (IDnaDataReader reader = RiskModDataReaderCreator.CreateDnaDataReader("predict"))
            {
                reader.AddParameter("EntryId", ev.ThreadEntryId);
                reader.AddParameter("isArticle", 0);
                reader.AddParameter("ModClassId", ev.ModClassId);
                reader.AddParameter("SiteID", ev.SiteId);
                reader.AddParameter("ForumId", ev.ForumId);
                reader.AddParameter("ThreadID", ev.ThreadId);
                reader.AddParameter("UserID", ev.UserId);
                reader.AddParameter("NextSibling", ev.NextSibling);
                reader.AddParameter("Parent", ev.Parent);
                reader.AddParameter("PrevSibling", ev.PrevSibling);
                reader.AddParameter("FirstChild", ev.FirstChild);
                reader.AddParameter("DatePosted", ev.DatePosted);
                reader.AddParameter("text", ev.Text);
                reader.AddIntOutputParameter("moderation");
                reader.Execute();

                int? moderationResult = reader.GetNullableIntOutputParameter("moderation");

                BIEventProcessor.BIEventLogger.Log(TraceEventType.Verbose, "RecordPostToForumEvent() end", startTime, "ThreadEntryId", ev.ThreadEntryId, "ModerationResult", moderationResult);

                if (moderationResult.HasValue)
                    risky = moderationResult > 0;
                else
                    risky = null;
            }

            return true;
        }
Exemplo n.º 3
0
        public void RiskModSystem_When_Disabled_Check_RecordPostToForumEvent_Returns_False()
        {
            // Create with "Disabled" is true
            var rm = new RiskModSystem(null, true);

            var postEvent = new BIPostToForumEvent(null);
            bool? risky;
            bool recPost = rm.RecordPostToForumEvent(postEvent, out risky);
            Assert.IsFalse(recPost);
        }