コード例 #1
0
ファイル: StoryBR.cs プロジェクト: Letractively/dotnetkicks
        public static string AddStory(int hostID, string title, string description, string url, short categoryID, User user, string ipAddress)
        {
            if (user.IsBanned)
                return GetStoryIdentifier(title); //to stop the spammers

            //TODO: improve the validation
            string storyIdentifier = GetStoryIdentifier(title);

            if (description.Length > 2500)
                description = description.Substring(0, 2500);

            url = url.Trim();
            if (url.Length > 980)
                throw new Exception("The url is too long");

            title = HttpUtility.HtmlEncode(title);
            description = HttpUtility.HtmlEncode(description);

            Story story = new Story();
            story.HostID = hostID;
            story.StoryIdentifier = storyIdentifier;
            story.Title = title;
            story.Description = description;
            story.Url = url;
            story.CategoryID = categoryID;
            story.UserID = user.UserID;
            story.KickCount = 0;
            story.SpamCount = 0;
            story.ViewCount = 0;
            story.CommentCount = 0;
            story.IsPublishedToHomepage = false;
            story.IsSpam = false;
            story.AdsenseID = user.AdsenseID;
            story.IPAddress = ipAddress;
            story.PublishedOn = DateTime.Now;
            story.UpdatedOn = DateTime.Now;
            story.Save();

            UserAction.RecordStorySubmission(hostID, user, story);

            UserCache.KickStory(story.StoryID, user.UserID, hostID, ipAddress);

            TagBR.AddUserStoryTags(CategoryCache.GetCategory(categoryID, hostID).TagIdentifier, user, story.StoryID, hostID);

            System.Diagnostics.Trace.WriteLine("AddStory: " + title);

            //now send a trackback ping
            Host host = HostCache.GetHost(hostID);
            string storyUrl = host.RootUrl + "/" + CategoryCache.GetCategory(categoryID, hostID).CategoryIdentifier + "/" + story.StoryIdentifier;
            TrackbackHelper.SendTrackbackPing_Begin(url, title, storyUrl, "You've been kicked (a good thing) - Trackback from " + host.SiteTitle, host.SiteTitle);

            return story.StoryIdentifier;
        }
コード例 #2
0
        public static void Destroy(int storyID, int userID, int hostID, int tagID)
        {
            //NOTE: GJ: there is most likely a much better way of doing this with subsonic
            Query            query            = new Query(StoryUserHostTag.Schema).WHERE(StoryUserHostTag.Columns.StoryID, storyID).AND(StoryUserHostTag.Columns.UserID, userID).AND(StoryUserHostTag.Columns.HostID, hostID).AND(StoryUserHostTag.Columns.TagID, tagID);
            StoryUserHostTag storyUserHostTag = new StoryUserHostTag();

            storyUserHostTag.LoadAndCloseReader(StoryUserHostTag.FetchByQuery(query));
            StoryUserHostTag.Destroy(storyUserHostTag.StoryUserHostTagID);

            //update the story for the next crawl to pickup the change
            Story story = Story.FetchByID(storyID);

            story.UpdatedOn = DateTime.Now;
            story.Save();
        }
コード例 #3
0
        public void Update(int StoryID, int HostID, string StoryIdentifier, string Title, string Description, string Url, short CategoryID, int UserID, int KickCount, int SpamCount, int ViewCount, int CommentCount, bool IsPublishedToHomepage, bool IsSpam, string AdsenseID, DateTime CreatedOn, DateTime PublishedOn, DateTime UpdatedOn, string IPAddress)
        {
            Story item = new Story();

            item.StoryID = StoryID;

            item.HostID = HostID;

            item.StoryIdentifier = StoryIdentifier;

            item.Title = Title;

            item.Description = Description;

            item.Url = Url;

            item.CategoryID = CategoryID;

            item.UserID = UserID;

            item.KickCount = KickCount;

            item.SpamCount = SpamCount;

            item.ViewCount = ViewCount;

            item.CommentCount = CommentCount;

            item.IsPublishedToHomepage = IsPublishedToHomepage;

            item.IsSpam = IsSpam;

            item.AdsenseID = AdsenseID;

            item.CreatedOn = CreatedOn;

            item.PublishedOn = PublishedOn;

            item.UpdatedOn = UpdatedOn;

            item.IPAddress = IPAddress;

            item.MarkOld();
            item.Save(UserName);
        }
コード例 #4
0
        public void Insert(int HostID,string StoryIdentifier,string Title,string Description,string Url,short CategoryID,int UserID,int KickCount,int SpamCount,int ViewCount,int CommentCount,bool IsPublishedToHomepage,bool IsSpam,string AdsenseID,DateTime CreatedOn,DateTime PublishedOn,DateTime UpdatedOn,string IPAddress)
        {
            Story item = new Story();

            item.HostID = HostID;

            item.StoryIdentifier = StoryIdentifier;

            item.Title = Title;

            item.Description = Description;

            item.Url = Url;

            item.CategoryID = CategoryID;

            item.UserID = UserID;

            item.KickCount = KickCount;

            item.SpamCount = SpamCount;

            item.ViewCount = ViewCount;

            item.CommentCount = CommentCount;

            item.IsPublishedToHomepage = IsPublishedToHomepage;

            item.IsSpam = IsSpam;

            item.AdsenseID = AdsenseID;

            item.CreatedOn = CreatedOn;

            item.PublishedOn = PublishedOn;

            item.UpdatedOn = UpdatedOn;

            item.IPAddress = IPAddress;

            item.Save(UserName);
        }