Beispiel #1
0
 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;
 }
        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 = "******";
                }

                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;
        }
        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;
        }
Beispiel #4
0
        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;
        }