public void PerformGenerationJob(CGDataEntities.CGWebEntities webEntities) { log.Info("Starting ServiceGenerationJob..."); AddServices(webEntities); AddServiceRoleRelationships(webEntities); log.Info("ServiceGenerationJob Complete..."); }
public void PerformGenerationJob(CGDataEntities.CGWebEntities webEntities) { log.Info("Starting data purge..."); List<ForumReply> replysToRemove = webEntities.ForumReplies.ToList(); webEntities.ForumReplies.RemoveRange(replysToRemove); webEntities.SaveChanges(); List<ForumThread> threadsToRemove = webEntities.ForumThreads.ToList(); webEntities.ForumThreads.RemoveRange(threadsToRemove); webEntities.SaveChanges(); List<ForumTopic> topicsToRemove = webEntities.ForumTopics.ToList(); webEntities.ForumTopics.RemoveRange(topicsToRemove); webEntities.SaveChanges(); List<Forum> forumsToRemove = webEntities.Forums.ToList(); webEntities.Forums.RemoveRange(forumsToRemove); webEntities.SaveChanges(); List<Announcement> announcementsToRemove = webEntities.Announcements.ToList(); webEntities.Announcements.RemoveRange(announcementsToRemove); webEntities.SaveChanges(); foreach (UserProfile profile in webEntities.UserProfiles) { List<webpages_Roles> roles = profile.webpages_Roles.ToList(); foreach (webpages_Roles role in roles) profile.webpages_Roles.Remove(role); } webEntities.SaveChanges(); List<Service_Roles> serviceRoleToRemove = webEntities.Service_Roles.ToList(); webEntities.Service_Roles.RemoveRange(serviceRoleToRemove); webEntities.SaveChanges(); List<UserProfile> profilesToRemove = webEntities.UserProfiles.ToList(); webEntities.UserProfiles.RemoveRange(profilesToRemove); List<webpages_OAuthMembership> oAuthToRemove = webEntities.webpages_OAuthMembership.ToList(); webEntities.webpages_OAuthMembership.RemoveRange(oAuthToRemove); List<webpages_Membership> membershipToRemove = webEntities.webpages_Membership.ToList(); webEntities.webpages_Membership.RemoveRange(membershipToRemove); List<webpages_Roles> rolesToRemove = webEntities.webpages_Roles.ToList(); webEntities.webpages_Roles.RemoveRange(rolesToRemove); List<Service> servicesToRemove = webEntities.Services.ToList(); webEntities.Services.RemoveRange(servicesToRemove); webEntities.SaveChanges(); log.Info("Current user data purged! Hope you didn't need that :O"); }
private void AddServices(CGDataEntities.CGWebEntities webEntities) { foreach (KeyValuePair<string, Guid> service in _servicesDict) webEntities.Services.Add(new CGDataEntities.Service() { ServiceId = service.Value, ServiceName = service.Key }); webEntities.SaveChanges(); log.Info("Added services to system."); }
public UserProfile(CGDataEntities.UserProfile profileEntity) { this.AvatarFileName = profileEntity.AvatarFileName; this.BanExpireDate = profileEntity.BanExpireDate; this.Email = profileEntity.Email; this.ListInDirectory = profileEntity.ListInDirectory; this.PhoneNumber = profileEntity.PhoneNumber; this.Signature = profileEntity.Signature; this.SteamHandle = profileEntity.SteamHandle; this.Timezone = profileEntity.Timezone; this.UserId = profileEntity.UserId; this.UserName = profileEntity.UserName; }
private void AddServiceRoleRelationships(CGDataEntities.CGWebEntities webEntities) { foreach (KeyValuePair<string, Guid> service in _servicesDict) { Service currentService = webEntities.Services.Where(S => S.ServiceId.Equals(service.Value)).Single(); foreach (KeyValuePair<string, string> relationship in _serviceRoleRelationships) { webpages_Roles currentRole = webEntities.webpages_Roles.Where(R => R.RoleName.Equals(relationship.Value)).Single(); currentService.Service_Roles.Add(new Service_Roles() { RoleId = currentRole.RoleId, ServiceId = currentService.ServiceId, ServiceRoleId = Guid.NewGuid() }); } } webEntities.SaveChanges(); log.Info("Added services role relationships to system."); }
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..."); }
private void CreateNewRoles(CGDataEntities.CGWebEntities webEntities) { //wont work without HttpContext :( //SimpleRoleProvider provider = new SimpleRoleProvider(); //foreach (KeyValuePair<int, string> roleKV in _roles) // provider.CreateRole(roleKV.Value); foreach (KeyValuePair<int, string> roleKV in _roles) webEntities.webpages_Roles.Add(new webpages_Roles() { RoleName = roleKV.Value }); webEntities.SaveChanges(); log.Info("Added roles to system."); }
private void AsignUserRoles(CGDataEntities.CGWebEntities webEntities) { SimpleRoleProvider provider = new SimpleRoleProvider(); List<int> roleKeyList = _usersInRoles.Select(T => T.Value).Distinct().ToList(); foreach (int roleKey in roleKeyList) { string roleName = _roles[roleKey]; int[] usersInRoleIndexes = _usersInRoles.Where(kv => kv.Value.Equals(roleKey)).Select(kv => kv.Key).ToArray(); string[] userNames = new string[usersInRoleIndexes.Count()]; for (int i = 0; i < usersInRoleIndexes.Count(); i++) { userNames[i] = _userProfileList[usersInRoleIndexes[i]].Username; } //wont work without HttpContext :( //provider.AddUsersToRoles(userNames, roleNames); webpages_Roles currentRole = webEntities.webpages_Roles.Where(R => R.RoleName.Equals(roleName)).Single(); foreach (UserProfile profile in webEntities.UserProfiles.Where(UP => userNames.Contains(UP.UserName))) profile.webpages_Roles.Add(currentRole); webEntities.SaveChanges(); } log.Info("Added Roles to system."); }
public void PerformGenerationJob(CGDataEntities.CGWebEntities webEntities) { log.Info("Starting UserSchemaGenerationJob..."); CreateNewRoles(webEntities); CreateNewUsers(); AsignUserRoles(webEntities); log.Info("UserSchemaGenerationJob Complete!"); }
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."); } }