Beispiel #1
0
        //
        // GET: /Forum/

        public ActionResult Index()
        {
            ForumIndexModel indexModel = new ForumIndexModel()
            {
                Forums = new Dictionary <string, Guid>()
            };

            using (CGWebEntities entities = new CGWebEntities())
            {
                if (Request.IsAuthenticated)
                {
                    foreach (Forum forum in entities.Forums)
                    {
                        indexModel.Forums.Add(forum.ForumTitle, forum.ForumId);
                    }
                }
                else
                {
                    foreach (Forum forum in entities.Forums.Where(F => F.IsPublic))
                    {
                        indexModel.Forums.Add(forum.ForumTitle, forum.ForumId);
                    }
                }
            }
            return(View(indexModel));
        }
Beispiel #2
0
        public ActionResult ViewThread(ForumThreadRequestModel requestModel)
        {
            ViewThreadModel viewThreadModel = new ViewThreadModel()
            {
                Replies = new List <ForumReplyModel>()
            };

            using (CGWebEntities entities = new CGWebEntities())
            {
                ForumThread currentThread = entities.ForumThreads.Where(FT => FT.ThreadId.Equals(requestModel.ThreadId)).Single();

                viewThreadModel.ParentTopic = currentThread.ParentForumTopic.ConvertToForumTopicModel();

                if (!currentThread.ParentForumTopic.IsPublic && !Request.IsAuthenticated)
                {
                    return(RedirectToAction("Login", "Account"));
                }

                int currentPagingLimit = Convert.ToInt32(ConfigurationManager.AppSettings["ForumReplyPagingLimit"]);
                viewThreadModel.CurrentPage = requestModel.CurrentPage;
                viewThreadModel.MaxPages    = (int)Math.Ceiling((double)currentThread.ForumReplies.Count / (double)currentPagingLimit);

                viewThreadModel.CurrentThread = currentThread.ConvertToForumThreadModel(true);

                foreach (ForumReply reply in currentThread.ForumReplies.OrderBy(FR => FR.CreatedOn).Skip(requestModel.CurrentPage * currentPagingLimit).Take(currentPagingLimit))
                {
                    viewThreadModel.Replies.Add(reply.ConvertToThreadReplyModel(true));
                }
            }

            return(View(viewThreadModel));
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            log.Info("Checking developer lacking caffinee...");
            Console.WriteLine("This will clear and factory reset the database.");
            Console.WriteLine("!!!Any change you have made manually will disapear!!!");
            Console.WriteLine("You sure? (y to DELETE ALL THE THINGS!)");

            if (Console.ReadKey().Key == ConsoleKey.Y)
            {
                log.Info("Caffinee levels confirmed. Starting CgWebDataGenerator...");

                Stopwatch generationTimer = new Stopwatch();
                generationTimer.Start();

                log.Info("Calling WebSecurity.InitializeDatabaseConnection()...");
                WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "UserId", "UserName", autoCreateTables: false);

                log.Info("Opening database context.");
                using (CGWebEntities entities = new CGWebEntities())
                {
                    log.Info("Stepping generation actions...");
                    for (int i = 0; i < _generationActions.Count(); i++)
                    {
                        log.Info(String.Format("Trying initalization for type {0}", _generationActions[i].GetType()));
                        try
                        {
                            _generationActions[i].InitalizeGenerationJob();
                        }
                        catch (Exception ex)
                        {
                            log.Error(String.Format("There was a problem initalizing type {0}", _generationActions[i].GetType()), ex);
                            HangForUserAndExit(1);
                        }

                        log.Info(String.Format("Trying generationAction for type {0}", _generationActions[i].GetType()));
                        try
                        {
                            _generationActions[i].PerformGenerationJob(entities);
                        }
                        catch (Exception ex)
                        {
                            log.Error(String.Format("There was a problem in generationAction for type {0}", _generationActions[i].GetType()), ex);
                            HangForUserAndExit(1);
                        }
                    }
                    log.Info("All generation modules performed without error.");
                }
                log.Info("Disposed of database context");
                generationTimer.Stop();

                log.Info(String.Format("CgWebDataGenerator has ended. Generation took: {0}", generationTimer.Elapsed.ToString()));

                HangForUserAndExit(0);
            }
            else
            {
                Console.WriteLine("I'll get you next time Gadget...");
                Environment.Exit(0);
            }
        }
Beispiel #4
0
        public ActionResult ViewTopic(ForumTopicRequestModel requestModel)
        {
            ViewTopicModel viewTopicModel = new ViewTopicModel()
            {
                Threads = new List <ForumThreadModel>()
            };

            using (CGWebEntities entities = new CGWebEntities())
            {
                ForumTopic currentTopic = entities.ForumTopics.Where(T => T.TopicId.Equals(requestModel.TopicId)).Single();
                viewTopicModel.CurrentTopic = currentTopic.ConvertToForumTopicModel();
                viewTopicModel.ParentForum  = currentTopic.Forum.ConvertToViewForumModel(false, false);

                if (!currentTopic.IsPublic && !Request.IsAuthenticated)
                {
                    return(RedirectToAction("Login", "Account"));
                }

                var currentTopicGroup = entities.ForumThreads.Where(FT => FT.ForumTopic.Equals(requestModel.TopicId));

                int currentTopicViewLimit = Convert.ToInt32(ConfigurationManager.AppSettings["ForumTopicPagingLimit"]);
                viewTopicModel.CurrentPage = requestModel.CurrentPage;
                viewTopicModel.MaxPages    = (int)Math.Ceiling((double)currentTopicGroup.Count() / (double)currentTopicViewLimit);

                foreach (ForumThread thread in currentTopicGroup.OrderByDescending(FT => FT.CreatedOn).OrderByDescending(FT => FT.IsSticky).Skip(currentTopicViewLimit * requestModel.CurrentPage).Take(currentTopicViewLimit))
                {
                    viewTopicModel.Threads.Add(thread.ConvertToForumThreadModel(false));
                }
            }

            return(View(viewTopicModel));
        }
        public ActionResult ManageUser(CincyGeeksWebsite.Models.Shared.UserProfile postedProfile)
        {
            using (CGWebEntities entities = new CGWebEntities())
            {
                UserProfile profile = entities.UserProfiles.Where(up => up.UserId.Equals(postedProfile.UserId)).Single();
                profile.AvatarFileName  = postedProfile.AvatarFileName;
                profile.BanExpireDate   = postedProfile.BanExpireDate;
                profile.Email           = postedProfile.Email;
                profile.ListInDirectory = postedProfile.ListInDirectory;
                profile.PhoneNumber     = postedProfile.PhoneNumber;
                profile.Signature       = postedProfile.Signature;
                profile.SteamHandle     = postedProfile.SteamHandle;
                profile.Timezone        = postedProfile.Timezone;
                profile.UserName        = postedProfile.UserName;

                try
                {
                    entities.SaveChanges();
                    ViewBag.SaveMessage = "Updated Okay.";
                }
                catch (Exception ex)
                {
                    ViewBag.SaveMessage = String.Format("There was a problem : {0}", ex.Message);
                }

                return(View(postedProfile));
            }
        }
Beispiel #6
0
        public ActionResult Index()
        {
            ViewBag.Title   = "Announcements";
            ViewBag.Message = "The information you need to game with you buddies.";

            IndexModel newIndexModel = new IndexModel();

            using (CGWebEntities cgweb = new CGWebEntities())
            {
                List <Announcement> announcements;



                if (Request.IsAuthenticated)
                {
                    UserProfile currentProfile = cgweb.UserProfiles.Where(UP => UP.UserName.Equals(User.Identity.Name)).Single();
                    List <int>  roleIds        = currentProfile.webpages_Roles.Select(WR => WR.RoleId).ToList();
                    announcements = cgweb.Announcements.Where(A => !A.RestrictToRole.HasValue || roleIds.Contains(A.RestrictToRole.Value)).ToList();
                }
                else
                {
                    announcements = cgweb.Announcements.Where(A => !A.RestrictToRole.HasValue).ToList();
                }
                newIndexModel.Announcements = new List <Models.Shared.AnnouncementPartialModel>();
                foreach (Announcement announce in announcements)
                {
                    newIndexModel.Announcements.Add(announce.BuildAnnouncementPartialModel());
                }
            }

            return(View(newIndexModel));
        }
Beispiel #7
0
        public ActionResult ViewForum(Guid forumId)
        {
            ViewForumModel viewForumModel = new ViewForumModel()
            {
            };

            using (CGWebEntities entities = new CGWebEntities())
            {
                Forum currentForum = entities.Forums.Where(F => F.ForumId.Equals(forumId)).Single();

                if (!currentForum.IsPublic && !Request.IsAuthenticated)
                {
                    return(RedirectToAction("Login", "Account"));
                }

                if (Request.IsAuthenticated)
                {
                    viewForumModel = currentForum.ConvertToViewForumModel(true, false);
                }
                else
                {
                    viewForumModel = currentForum.ConvertToViewForumModel(true, true);
                }
            }

            return(View(viewForumModel));
        }
        public ActionResult ManageUser(int userId)
        {
            using (CGWebEntities entities = new CGWebEntities())
            {
                UserProfile profile = entities.UserProfiles.Where(up => up.UserId.Equals(userId)).Single();

                return(View(new CincyGeeksWebsite.Models.Shared.UserProfile(profile)));
            }
        }
        public ActionResult UserDashboard()
        {
            List <CGDataEntities.UserProfile> viewRecords;

            using (CGWebEntities entities = new CGWebEntities())
            {
                viewRecords = entities.UserProfiles.ToList();
            }
            return(View(viewRecords));
        }
Beispiel #10
0
        public ActionResult ViewTopic(Guid topicId, string threadTitle, string threadContent, bool isSticky)
        {
            ViewTopicModel viewTopicModel = new ViewTopicModel()
            {
                Threads = new List <ForumThreadModel>()
            };

            using (CGWebEntities entities = new CGWebEntities())
            {
                UserProfile currentUserProfile = entities.UserProfiles.Where(P => P.UserName.Equals(User.Identity.Name)).Single();

                ForumThread newThread = new ForumThread()
                {
                    CreatedBy     = currentUserProfile.UserId,
                    CreatedOn     = DateTime.UtcNow,
                    ForumTopic    = topicId,
                    IsSticky      = isSticky,
                    ModifiedOn    = null,
                    ThreadContent = threadContent,
                    ThreadId      = Guid.NewGuid(),
                    ThreadTitle   = HtmlSanitizerUtility.SanitizeInputStringNoHTML(threadTitle)
                };

                entities.ForumThreads.Add(newThread);
                entities.SaveChanges();
                ModelState.Clear();

                ForumTopic currentTopic = entities.ForumTopics.Where(T => T.TopicId.Equals(topicId)).Single();
                viewTopicModel.CurrentTopic = currentTopic.ConvertToForumTopicModel();
                viewTopicModel.ParentForum  = currentTopic.Forum.ConvertToViewForumModel(false, false);

                if (!currentTopic.IsPublic && !Request.IsAuthenticated)
                {
                    return(RedirectToAction("Login", "Account"));
                }

                var currentTopicGroup = entities.ForumThreads.Where(FT => FT.ForumTopic.Equals(topicId));

                int currentTopicViewLimit = Convert.ToInt32(ConfigurationManager.AppSettings["ForumTopicPagingLimit"]);
                viewTopicModel.MaxPages    = (int)Math.Ceiling((double)currentTopicGroup.Count() / (double)currentTopicViewLimit);
                viewTopicModel.CurrentPage = viewTopicModel.MaxPages - 1;

                foreach (ForumThread thread in currentTopicGroup.OrderByDescending(FT => FT.CreatedOn).OrderByDescending(FT => FT.IsSticky).Skip(currentTopicViewLimit * viewTopicModel.CurrentPage).Take(currentTopicViewLimit))
                {
                    viewTopicModel.Threads.Add(thread.ConvertToForumThreadModel(false));
                }
            }

            return(View(viewTopicModel));
        }
Beispiel #11
0
        public ActionResult ViewThread(ForumReplyModel model)
        {
            ViewThreadModel viewThreadModel = new ViewThreadModel()
            {
                Replies = new List <ForumReplyModel>()
            };

            using (CGWebEntities entities = new CGWebEntities())
            {
                UserProfile currentUserProfile = entities.UserProfiles.Where(P => P.UserName.Equals(User.Identity.Name)).Single();

                ForumReply newReply = new ForumReply()
                {
                    CreatedBy      = currentUserProfile.UserId,
                    CreatedOn      = DateTime.UtcNow,
                    ModifiedOn     = null,
                    ParentThreadId = model.ThreadId,
                    ReplyContent   = model.ReplyContent,
                    ReplyId        = Guid.NewGuid()
                };

                entities.ForumReplies.Add(newReply);
                entities.SaveChanges();
                ModelState.Clear();

                ForumThread currentThread = entities.ForumThreads.Where(FT => FT.ThreadId.Equals(model.ThreadId)).Single();

                viewThreadModel.ParentTopic = currentThread.ParentForumTopic.ConvertToForumTopicModel();

                if (!currentThread.ParentForumTopic.IsPublic && !Request.IsAuthenticated)
                {
                    return(RedirectToAction("Login", "Account"));
                }

                int currentPagingLimit = Convert.ToInt32(ConfigurationManager.AppSettings["ForumReplyPagingLimit"]);
                viewThreadModel.MaxPages    = (int)Math.Ceiling((double)currentThread.ForumReplies.Count / (double)currentPagingLimit);
                viewThreadModel.CurrentPage = viewThreadModel.MaxPages - 1;

                viewThreadModel.CurrentThread = currentThread.ConvertToForumThreadModel(true);

                foreach (ForumReply reply in currentThread.ForumReplies.OrderBy(FR => FR.CreatedOn).Skip(viewThreadModel.CurrentPage * currentPagingLimit).Take(currentPagingLimit))
                {
                    viewThreadModel.Replies.Add(reply.ConvertToThreadReplyModel(true));
                }
            }

            return(View(viewThreadModel));
        }
        public ActionResult DeleteUser(int userId)
        {
            using (CGWebEntities entities = new CGWebEntities())
            {
                UserProfile           profile      = entities.UserProfiles.Where(up => up.UserId.Equals(userId)).Single();
                List <webpages_Roles> roleDropList = profile.webpages_Roles.ToList();

                foreach (webpages_Roles role in roleDropList)
                {
                    entities.webpages_Roles.Remove(role);
                }
                entities.SaveChanges();

                entities.UserProfiles.Remove(profile);
                entities.SaveChanges();
            }

            return(Redirect("~/Administration/UserDashboard"));
        }
Beispiel #13
0
        public PartialViewResult Avatar(AvatarRenderModel renderModel)
        {
            AvatarPartialViewModel model;

            using (CGWebEntities entities = new CGWebEntities())
            {
                CGDataEntities.UserProfile currentProfile = entities.UserProfiles.Include("webpages_Roles").Where(UPE => UPE.UserId.Equals(renderModel.UserId)).Single();
                string fileName = String.IsNullOrEmpty(currentProfile.AvatarFileName) ? "DefaultAvatar.png" : currentProfile.AvatarFileName;
                model = new AvatarPartialViewModel()
                {
                    AltText      = "[CG] |" + currentProfile.UserName + "|",
                    Height       = 64,
                    Width        = 64,
                    ResourcePath = "~/Content/avatars/" + fileName,
                    StatsInfo    = currentProfile.BanExpireDate.HasValue ? "Banned" : "Active",
                    UserName     = currentProfile.UserName,
                    UserType     = currentProfile.webpages_Roles.Where(R => R.RoleId == currentProfile.webpages_Roles.Min(R2 => R2.RoleId)).Single().RoleName,
                    ImageOnly    = renderModel.PictureOnly
                };
                return(PartialView("_AvatarPartial", model));
            }
        }
Beispiel #14
0
        public ActionResult ViewForum(Guid forumId, string topicTitle, string topicDescription, bool isPublic)
        {
            using (CGWebEntities entities = new CGWebEntities())
            {
                UserProfile currentUserProfile = entities.UserProfiles.Where(P => P.UserName.Equals(User.Identity.Name)).Single();

                ForumTopic newTopic = new ForumTopic()
                {
                    CreatedBy        = currentUserProfile.UserId,
                    CreatedOn        = DateTime.UtcNow,
                    ForumId          = forumId,
                    IsPublic         = isPublic,
                    TopicDescription = topicDescription,
                    TopicId          = Guid.NewGuid(),
                    TopicTitle       = HtmlSanitizerUtility.SanitizeInputStringNoHTML(topicTitle)
                };
                entities.ForumTopics.Add(newTopic);
                entities.SaveChanges();
            }

            return(ViewForum(forumId));
        }
        public ActionResult ManageUserRoles(int userId)
        {
            using (CGWebEntities entities = new CGWebEntities())
            {
                UserProfile selectedProfile = entities.UserProfiles.Where(up => up.UserId.Equals(userId)).Single();

                RoleManagementModel returnValue = new RoleManagementModel();
                returnValue.UserId = selectedProfile.UserId;
                foreach (webpages_Roles role in selectedProfile.webpages_Roles)
                {
                    switch (role.RoleName)
                    {
                    case "Root":
                        returnValue.Root = true;
                        break;

                    case "Administrator":
                        returnValue.Administrator = true;
                        break;

                    case "Moderator":
                        returnValue.Moderator = true;
                        break;

                    case "User":
                        returnValue.User = true;
                        break;

                    case "Announcer":
                        returnValue.Announcer = true;
                        break;
                    }
                }

                return(View(returnValue));
            }
        }
        public void PerformGenerationJob(CGDataEntities.CGWebEntities webEntities)
        {
            log.Info("Starting AnnouncementGenerationJob...");
            using (CGWebEntities entities = new CGWebEntities())
            {
                foreach (AnnouncementStruct announce in _announcements)
                {
                    entities.Announcements.Add(new Announcement()
                    {
                        Content        = announce.Content,
                        CreatedBy      = announce.CreatedByUser,
                        CreatedDate    = announce.CreateDate,
                        IsPublic       = announce.IsPublic,
                        ModifiedBy     = announce.ModifiedByUser,
                        ModifiedDate   = announce.ModifiedDate,
                        RestrictToRole = announce.RestrictToRole,
                        Title          = announce.Title
                    });
                }

                entities.SaveChanges();
            }
            log.Info("AnnouncementGenerationJob Complete...");
        }
Beispiel #17
0
        public void PerformGenerationJob(CGDataEntities.CGWebEntities webEntities)
        {
            log.Info("Starting FourmGenerationJob...");
            using (CGWebEntities entities = new CGWebEntities())
            {
                foreach (ForumStruct forum in _forums)
                {
                    entities.Forums.Add(new Forum()
                    {
                        ForumId    = forum.ForumId,
                        ForumTitle = forum.ForumTitle,
                        IsPublic   = forum.IsPublic
                    });
                }
                entities.SaveChanges();
                log.Info("Wrote Forums data.");

                foreach (ForumTopicStruct topic in _forumTopics)
                {
                    entities.ForumTopics.Add(new ForumTopic()
                    {
                        CreatedBy        = topic.CreatedBy,
                        CreatedOn        = topic.CreatedOn,
                        TopicDescription = topic.Description,
                        ForumId          = topic.ForumId,
                        IsPublic         = topic.IsPublic,
                        TopicTitle       = topic.Title,
                        TopicId          = topic.TopicId
                    });
                }
                entities.SaveChanges();
                log.Info("Wrote Forums Topic data.");

                foreach (ForumThreadStruct thread in _forumThreads)
                {
                    entities.ForumThreads.Add(new ForumThread()
                    {
                        CreatedBy     = thread.CreatedBy,
                        CreatedOn     = thread.CreatedOn,
                        IsSticky      = thread.IsSticky,
                        ModifiedOn    = thread.ModifiedOn,
                        ThreadContent = thread.ThreadContent,
                        ThreadId      = thread.ThreadId,
                        ThreadTitle   = thread.ThreadTitle,
                        ForumTopic    = thread.TopicId
                    });
                }
                entities.SaveChanges();
                log.Info("Wrote Forums Theads data.");

                foreach (ForumReplyStruct reply in _forumReplys)
                {
                    entities.ForumReplies.Add(new ForumReply()
                    {
                        ReplyContent   = reply.Content,
                        CreatedBy      = reply.CreatedBy,
                        CreatedOn      = reply.CreatedOn,
                        ModifiedOn     = reply.ModifiedOn,
                        ParentThreadId = reply.ParentThreadId,
                        ReplyId        = reply.ReplyId
                    });
                }
                entities.SaveChanges();
                log.Info("Wrote Forums Reply data.");
            }
        }
        public ActionResult ManageUserRoles(RoleManagementModel model)
        {
            using (CGWebEntities entities = new CGWebEntities())
            {
                UserProfile selectedProfile = entities.UserProfiles.Where(up => up.UserId.Equals(model.UserId)).Single();

                if (model.Root)
                {
                    if (!selectedProfile.webpages_Roles.Any(r => r.RoleName.Equals("Root")))
                    {
                        selectedProfile.webpages_Roles.Add(entities.webpages_Roles.Where(r => r.RoleName.Equals("Root")).Single());
                    }
                }
                else
                {
                    webpages_Roles roleTest = selectedProfile.webpages_Roles.Where(r => r.RoleName.Equals("Root")).SingleOrDefault();
                    if (roleTest != null)
                    {
                        selectedProfile.webpages_Roles.Remove(roleTest);
                    }
                }

                if (model.Administrator)
                {
                    if (!selectedProfile.webpages_Roles.Any(r => r.RoleName.Equals("Administrator")))
                    {
                        selectedProfile.webpages_Roles.Add(entities.webpages_Roles.Where(r => r.RoleName.Equals("Administrator")).Single());
                    }
                }
                else
                {
                    webpages_Roles roleTest = selectedProfile.webpages_Roles.Where(r => r.RoleName.Equals("Administrator")).SingleOrDefault();
                    if (roleTest != null)
                    {
                        selectedProfile.webpages_Roles.Remove(roleTest);
                    }
                }

                if (model.Moderator)
                {
                    if (!selectedProfile.webpages_Roles.Any(r => r.RoleName.Equals("Moderator")))
                    {
                        selectedProfile.webpages_Roles.Add(entities.webpages_Roles.Where(r => r.RoleName.Equals("Moderator")).Single());
                    }
                }
                else
                {
                    webpages_Roles roleTest = selectedProfile.webpages_Roles.Where(r => r.RoleName.Equals("Moderator")).SingleOrDefault();
                    if (roleTest != null)
                    {
                        selectedProfile.webpages_Roles.Remove(roleTest);
                    }
                }

                if (model.User)
                {
                    if (!selectedProfile.webpages_Roles.Any(r => r.RoleName.Equals("User")))
                    {
                        selectedProfile.webpages_Roles.Add(entities.webpages_Roles.Where(r => r.RoleName.Equals("User")).Single());
                    }
                }
                else
                {
                    webpages_Roles roleTest = selectedProfile.webpages_Roles.Where(r => r.RoleName.Equals("User")).SingleOrDefault();
                    if (roleTest != null)
                    {
                        selectedProfile.webpages_Roles.Remove(roleTest);
                    }
                }

                if (model.Announcer)
                {
                    if (!selectedProfile.webpages_Roles.Any(r => r.RoleName.Equals("Announcer")))
                    {
                        selectedProfile.webpages_Roles.Add(entities.webpages_Roles.Where(r => r.RoleName.Equals("Announcer")).Single());
                    }
                }
                else
                {
                    webpages_Roles roleTest = selectedProfile.webpages_Roles.Where(r => r.RoleName.Equals("Announcer")).SingleOrDefault();
                    if (roleTest != null)
                    {
                        selectedProfile.webpages_Roles.Remove(roleTest);
                    }
                }

                try
                {
                    entities.SaveChanges();
                    ViewBag.SaveMessage = "Save Completed";
                }
                catch (Exception ex)
                {
                    ViewBag.SaveMessage = String.Format("There was a problem saving : {0}", ex.Message);
                }

                return(View("ManageUserRoles", model));
            }
        }
Beispiel #19
0
        public void InitalizeGenerationJob()
        {
            log.Info("Init FourmGenerationJob");

            Random rand = new Random((int)DateTime.UtcNow.Ticks);

            using (CGWebEntities entities = new CGWebEntities())
            {
                _currentUsers = entities.UserProfiles.ToList();
            }

            _forums = new List <ForumStruct> {
                new ForumStruct()
                {
                    ForumId    = Guid.NewGuid(),
                    ForumTitle = "Public Forum",
                    IsPublic   = true
                },
                new ForumStruct()
                {
                    ForumId    = Guid.NewGuid(),
                    ForumTitle = "Gaming",
                    IsPublic   = false
                },
                new ForumStruct()
                {
                    ForumId    = Guid.NewGuid(),
                    ForumTitle = "Meta",
                    IsPublic   = false
                },
                new ForumStruct()
                {
                    ForumId    = Guid.NewGuid(),
                    ForumTitle = "Website Support",
                    IsPublic   = true
                }
            };
            log.Info("Created Forum List:");
            foreach (ForumStruct forum in _forums)
            {
                log.Info(
                    String.Format("{0},{1},{2}",
                                  forum.ForumId,
                                  forum.ForumTitle,
                                  forum.IsPublic)
                    );
            }

            _forumTopics = new List <ForumTopicStruct>()
            {
                new ForumTopicStruct()
                {
                    CreatedBy   = _currentUsers[rand.Next(0, _currentUsers.Count - 1)].UserId,
                    CreatedOn   = DateTime.UtcNow,
                    Description = "Discussion for EvE Online goes here.",
                    ForumId     = _forums[1].ForumId,
                    IsPublic    = false,
                    Title       = "EvE Online",
                    TopicId     = Guid.NewGuid()
                },
                new ForumTopicStruct()
                {
                    CreatedBy   = _currentUsers[rand.Next(0, _currentUsers.Count - 1)].UserId,
                    CreatedOn   = DateTime.UtcNow,
                    Description = "Discussion for Counter Strike:Global Offensive goes here.",
                    ForumId     = _forums[1].ForumId,
                    IsPublic    = false,
                    Title       = "Counter Strike:Global Offensive",
                    TopicId     = Guid.NewGuid()
                },
                new ForumTopicStruct()
                {
                    CreatedBy   = _currentUsers[rand.Next(0, _currentUsers.Count - 1)].UserId,
                    CreatedOn   = DateTime.UtcNow,
                    Description = "Discussion for the public goes here.",
                    ForumId     = _forums[0].ForumId,
                    IsPublic    = true,
                    Title       = "Public Threads",
                    TopicId     = Guid.NewGuid()
                },
                new ForumTopicStruct()
                {
                    CreatedBy   = _currentUsers[rand.Next(0, _currentUsers.Count - 1)].UserId,
                    CreatedOn   = DateTime.UtcNow,
                    Description = "Discussion for the BOINC Team goes here.",
                    ForumId     = _forums[2].ForumId,
                    IsPublic    = false,
                    Title       = "BOINC Team",
                    TopicId     = Guid.NewGuid()
                },
                new ForumTopicStruct()
                {
                    CreatedBy   = _currentUsers[rand.Next(0, _currentUsers.Count - 1)].UserId,
                    CreatedOn   = DateTime.UtcNow,
                    Description = "Report website bugs here.",
                    ForumId     = _forums[3].ForumId,
                    IsPublic    = true,
                    Title       = "Bugs",
                    TopicId     = Guid.NewGuid()
                }
            };
            log.Info("Created Forum Topic List:");
            foreach (ForumTopicStruct topic in _forumTopics)
            {
                log.Info(
                    String.Format("{0},{1},{2},{3},{4},{5},{6}",
                                  topic.TopicId,
                                  topic.ForumId,
                                  topic.Title,
                                  topic.Description,
                                  topic.CreatedBy,
                                  topic.CreatedOn,
                                  topic.IsPublic)
                    );
            }

            _forumThreads = new List <ForumThreadStruct>()
            {
                new ForumThreadStruct()
                {
                    CreatedBy     = _currentUsers[rand.Next(0, _currentUsers.Count - 1)].UserId,
                    CreatedOn     = DateTime.UtcNow,
                    IsSticky      = false,
                    ModifiedOn    = null,
                    ThreadContent = "An Eve thread blah blah blah...",
                    ThreadId      = Guid.NewGuid(),
                    ThreadTitle   = "Eve Thread 01",
                    TopicId       = _forumTopics[0].TopicId
                },
                new ForumThreadStruct()
                {
                    CreatedBy     = _currentUsers[rand.Next(0, _currentUsers.Count - 1)].UserId,
                    CreatedOn     = DateTime.UtcNow,
                    IsSticky      = false,
                    ModifiedOn    = null,
                    ThreadContent = "An Eve thread blah blah blah...",
                    ThreadId      = Guid.NewGuid(),
                    ThreadTitle   = "Eve Thread 02",
                    TopicId       = _forumTopics[0].TopicId
                },
                new ForumThreadStruct()
                {
                    CreatedBy     = _currentUsers[rand.Next(0, _currentUsers.Count - 1)].UserId,
                    CreatedOn     = DateTime.UtcNow,
                    IsSticky      = false,
                    ModifiedOn    = null,
                    ThreadContent = "A Counter Strike:Global Offensive thread blah blah blah...",
                    ThreadId      = Guid.NewGuid(),
                    ThreadTitle   = "Counter Strike:Global Offensive 01",
                    TopicId       = _forumTopics[1].TopicId
                },
                new ForumThreadStruct()
                {
                    CreatedBy     = _currentUsers[rand.Next(0, _currentUsers.Count - 1)].UserId,
                    CreatedOn     = DateTime.UtcNow,
                    IsSticky      = false,
                    ModifiedOn    = null,
                    ThreadContent = "A Counter Strike:Global Offensive thread blah blah blah...",
                    ThreadId      = Guid.NewGuid(),
                    ThreadTitle   = "Counter Strike:Global Offensive 02",
                    TopicId       = _forumTopics[1].TopicId
                },
                new ForumThreadStruct()
                {
                    CreatedBy     = _currentUsers[rand.Next(0, _currentUsers.Count - 1)].UserId,
                    CreatedOn     = DateTime.UtcNow,
                    IsSticky      = false,
                    ModifiedOn    = null,
                    ThreadContent = "A public thread blah blah blah...",
                    ThreadId      = Guid.NewGuid(),
                    ThreadTitle   = "Public Thread",
                    TopicId       = _forumTopics[2].TopicId
                },
                new ForumThreadStruct()
                {
                    CreatedBy     = _currentUsers[rand.Next(0, _currentUsers.Count - 1)].UserId,
                    CreatedOn     = DateTime.UtcNow,
                    IsSticky      = false,
                    ModifiedOn    = null,
                    ThreadContent = "A BOINC thread blah blah blah...",
                    ThreadId      = Guid.NewGuid(),
                    ThreadTitle   = "BOINC Thread",
                    TopicId       = _forumTopics[3].TopicId
                },
                new ForumThreadStruct()
                {
                    CreatedBy     = _currentUsers[rand.Next(0, _currentUsers.Count - 1)].UserId,
                    CreatedOn     = DateTime.UtcNow,
                    IsSticky      = true,
                    ModifiedOn    = null,
                    ThreadContent = "A bug thread thread blah blah blah...",
                    ThreadId      = Guid.NewGuid(),
                    ThreadTitle   = "Bug Thread",
                    TopicId       = _forumTopics[4].TopicId
                },
                new ForumThreadStruct()
                {
                    CreatedBy     = _currentUsers[rand.Next(0, _currentUsers.Count - 1)].UserId,
                    CreatedOn     = DateTime.UtcNow.AddSeconds(1),
                    IsSticky      = true,
                    ModifiedOn    = null,
                    ThreadContent = "A bug thread thread blah blah blah...",
                    ThreadId      = Guid.NewGuid(),
                    ThreadTitle   = "Bug Thread 02",
                    TopicId       = _forumTopics[4].TopicId
                },
                new ForumThreadStruct()
                {
                    CreatedBy     = _currentUsers[rand.Next(0, _currentUsers.Count - 1)].UserId,
                    CreatedOn     = DateTime.UtcNow.AddSeconds(2),
                    IsSticky      = true,
                    ModifiedOn    = null,
                    ThreadContent = "A bug thread thread blah blah blah...",
                    ThreadId      = Guid.NewGuid(),
                    ThreadTitle   = "Bug Thread 03",
                    TopicId       = _forumTopics[4].TopicId
                }
            };
            log.Info("Created Forum Thread List:");
            foreach (ForumThreadStruct thread in _forumThreads)
            {
                log.Info(
                    String.Format("{0},{1},{2},{3},{4},{5},{6},{7}",
                                  thread.ThreadId,
                                  thread.TopicId,
                                  thread.ThreadTitle,
                                  thread.ThreadContent,
                                  thread.CreatedBy,
                                  thread.ModifiedOn,
                                  thread.CreatedOn,
                                  thread.IsSticky)
                    );
            }

            _forumReplys = new List <ForumReplyStruct>()
            {
                new ForumReplyStruct()
                {
                    Content        = "A reply, there is a bug dumbass",
                    CreatedBy      = _currentUsers[rand.Next(0, _currentUsers.Count - 1)].UserId,
                    CreatedOn      = DateTime.UtcNow,
                    ModifiedOn     = null,
                    ParentThreadId = _forumThreads[6].ThreadId,
                    ReplyId        = Guid.NewGuid()
                },
                new ForumReplyStruct()
                {
                    Content        = "Found another one",
                    CreatedBy      = _currentUsers[rand.Next(0, _currentUsers.Count - 1)].UserId,
                    CreatedOn      = DateTime.UtcNow,
                    ModifiedOn     = null,
                    ParentThreadId = _forumThreads[6].ThreadId,
                    ReplyId        = Guid.NewGuid()
                }
            };

            for (int i = 0; i < 80; i++)
            {
                _forumReplys.Add(new ForumReplyStruct()
                {
                    Content        = "A reply, there is a bug dumbass # " + i.ToString(),
                    CreatedBy      = _currentUsers[rand.Next(0, _currentUsers.Count - 1)].UserId,
                    CreatedOn      = DateTime.UtcNow.AddSeconds(i),
                    ModifiedOn     = null,
                    ParentThreadId = _forumThreads[6].ThreadId,
                    ReplyId        = Guid.NewGuid()
                });
            }

            log.Info("Created Forum Reply List:");
            foreach (ForumReplyStruct reply in _forumReplys)
            {
                log.Info(
                    String.Format("{0},{1},{2},{3},{4},{5}",
                                  reply.ReplyId,
                                  reply.ParentThreadId,
                                  reply.Content,
                                  reply.CreatedBy,
                                  reply.CreatedOn,
                                  reply.ModifiedOn)
                    );
            }
        }
        public void InitalizeGenerationJob()
        {
            log.Info("Init AnnouncementGenerationJob");
            using (CGWebEntities entities = new CGWebEntities())
            {
                _currentUsers = entities.UserProfiles.ToList();
                _currentRoles = entities.webpages_Roles.ToList();

                _announcements = new List <AnnouncementStruct>()
                {
                    new AnnouncementStruct()
                    {
                        Content        = "This is the content of announcement #1",
                        CreateDate     = DateTime.UtcNow,
                        CreatedByUser  = _currentUsers.First().UserId,
                        IsPublic       = true,
                        ModifiedByUser = null,
                        ModifiedDate   = null,
                        RestrictToRole = null,
                        Title          = "Announcement #1"
                    }
                };

                int         iterator  = 2;
                UserProfile createdBy = _currentUsers.Where(u => u.webpages_Roles.Any(r => r.RoleName.Equals("Announcer"))).First();

                foreach (webpages_Roles role in _currentRoles)
                {
                    _announcements.Add(new AnnouncementStruct()
                    {
                        Content        = String.Format("This is the content of announcement #{0}", iterator),
                        CreateDate     = DateTime.UtcNow,
                        CreatedByUser  = createdBy.UserId,
                        IsPublic       = false,
                        ModifiedByUser = null,
                        ModifiedDate   = null,
                        RestrictToRole = role.RoleId,
                        Title          = role.RoleName + " Announcement."
                    });

                    iterator++;
                }

                _announcements.Add(new AnnouncementStruct()
                {
                    Content        = "A modified announcement content!",
                    CreateDate     = DateTime.UtcNow.AddMinutes(-5),
                    CreatedByUser  = createdBy.UserId,
                    IsPublic       = true,
                    ModifiedByUser = createdBy.UserId,
                    ModifiedDate   = DateTime.UtcNow,
                    RestrictToRole = null,
                    Title          = "A modified announcement."
                });
            }

            log.Info("Created Announcement List:");
            foreach (AnnouncementStruct announce in _announcements)
            {
                log.Info(
                    String.Format("{0},{1},{2},{3},{4},{5},{6},{7}",
                                  announce.Title,
                                  announce.Content,
                                  announce.CreateDate,
                                  announce.CreatedByUser,
                                  announce.ModifiedDate,
                                  announce.ModifiedByUser,
                                  announce.IsPublic,
                                  announce.RestrictToRole)
                    );
            }
        }