コード例 #1
0
        //Save workspace Owner
        public void SaveWorkspaceOwner(WorkSpaceOwnerDTO workspaceOwnerDTO)
        {
            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <WorkSpaceOwnerDTO, WorkSpaceOwnerMaster>();
            });
            IMapper mapper = config.CreateMapper();

            var workspaceOwner = mapper.Map <WorkSpaceOwnerDTO, WorkSpaceOwnerMaster>(workspaceOwnerDTO);

            using (var context = new BIPortalEntities())
            {
                var workspaceOwnerExists = context.WorkSpaceOwnerMasters.FirstOrDefault(c => c.WorkspaceID == workspaceOwner.WorkspaceID);
                if (workspaceOwnerExists != null)
                {
                    workspaceOwnerExists.OwnerID      = workspaceOwner.OwnerID;
                    workspaceOwnerExists.ModifiedDate = workspaceOwner.ModifiedDate;
                    workspaceOwnerExists.ModifiedBy   = workspaceOwner.ModifiedBy;
                }
                else
                {
                    var workspaceOwnerMaster = new WorkSpaceOwnerMaster
                    {
                        WorkspaceID = workspaceOwner.WorkspaceID,
                        OwnerID     = workspaceOwner.OwnerID,
                        CreatedDate = workspaceOwner.CreatedDate,
                        CreatedBy   = workspaceOwner.CreatedBy,
                        Active      = workspaceOwner.Active
                    };
                    context.WorkSpaceOwnerMasters.Add(workspaceOwnerMaster);
                }

                context.SaveChanges();
            }
        }
コード例 #2
0
        public void RejectRequest(List <WorkFlowMasterDTO> workFlowMasterDTO, string powerBIUserName, string powerBIPWD, string smtpHost, int smtpPort)
        {
            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <WorkFlowMasterDTO, WorkFlowMaster>();
                cfg.CreateMap <WorkFlowDetailsDTO, WorkFlowDetail>();
            });
            IMapper mapper = config.CreateMapper();

            var workFlowMasterDetails = mapper.Map <List <WorkFlowMasterDTO>, List <WorkFlowMaster> >(workFlowMasterDTO);

            using (var context = new BIPortalEntities())
            {
                foreach (var f in workFlowMasterDTO)
                {
                    var workflowMasterEntity = context.WorkFlowMasters.FirstOrDefault(x => x.RequestID == f.RequestID);
                    if (workflowMasterEntity != null)
                    {
                        workflowMasterEntity.Status        = f.Status;
                        workflowMasterEntity.ProcessedDate = f.ProcessedDate;

                        context.WorkFlowMasters.AddOrUpdate(workflowMasterEntity);
                        context.SaveChanges();

                        //send email
                        var       subject   = "Your request is rejected.";
                        var       body      = "Your request for access to workspace " + workflowMasterEntity.WorkspaceName + " has been rejected.";
                        EmailData emailData = new EmailData();
                        emailData.SendEmail(powerBIUserName, powerBIPWD, smtpHost, smtpPort, workflowMasterEntity.RequestFor, subject, body);
                    }
                    foreach (var e in f.WorkFlowDetails)
                    {
                        var workflowDetailEntity = context.WorkFlowDetails.FirstOrDefault(x => x.RequestID == e.RequestID && x.ReportID == e.ReportID);
                        if (workflowDetailEntity != null)
                        {
                            workflowDetailEntity.Status        = e.Status;
                            workflowDetailEntity.ProcessedDate = e.ProcessedDate;

                            context.WorkFlowDetails.AddOrUpdate(workflowDetailEntity);
                            context.SaveChanges();
                        }
                    }
                }
            }
        }
コード例 #3
0
ファイル: RolesData.cs プロジェクト: dsemantics/BIPortal
        //Update access rights
        public void UpdateRoleAndRights(List <RoleRightsMappingDTO> roleRights)
        {
            var config = new MapperConfiguration(cfg =>
            {
                //cfg.CreateMap<RolesDTO, RoleMaster>();
                cfg.CreateMap <RoleRightsMappingDTO, RoleRightsMapping>();
            });
            IMapper mapper = config.CreateMapper();

            var roleAndRights = mapper.Map <List <RoleRightsMappingDTO>, List <RoleRightsMapping> >(roleRights);

            var roleID = roleAndRights[0].RoleID;

            using (var context = new BIPortalEntities())
            {
                var roleRightsMappingExists = context.RoleRightsMappings.Where(c => c.RoleID == roleID);

                if (roleRightsMappingExists != null)
                {
                    context.RoleRightsMappings.RemoveRange(roleRightsMappingExists);
                    context.SaveChanges();
                }

                foreach (var d in roleAndRights)
                {
                    var rolerightsmapping = new RoleRightsMapping
                    {
                        RoleID        = d.RoleID,
                        WorkspaceID   = d.WorkspaceID,
                        WorkspaceName = d.WorkspaceName,
                        ReportID      = d.ReportID,
                        ReportName    = d.ReportName,
                        CreatedDate   = d.CreatedDate,
                        CreatedBy     = d.CreatedBy,
                        ModifiedDate  = d.ModifiedDate,
                        ModifiedBy    = d.ModifiedBy,
                        Active        = d.Active
                    };
                    context.RoleRightsMappings.Add(rolerightsmapping);
                }
                context.SaveChanges();
            }
        }
コード例 #4
0
        public void ApproveRequest(List <WorkFlowMasterDTO> workFlowMasterDTO)
        {
            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <WorkFlowMasterDTO, WorkFlowMaster>();
                cfg.CreateMap <WorkFlowDetailsDTO, WorkFlowDetail>();
            });
            IMapper mapper = config.CreateMapper();

            var workFlowMasterDetails = mapper.Map <List <WorkFlowMasterDTO>, List <WorkFlowMaster> >(workFlowMasterDTO);

            using (var context = new BIPortalEntities())
            {
                foreach (var f in workFlowMasterDTO)
                {
                    var workflowMasterEntity = context.WorkFlowMasters.FirstOrDefault(x => x.RequestID == f.RequestID);
                    if (workflowMasterEntity != null)
                    {
                        workflowMasterEntity.Status        = f.Status;
                        workflowMasterEntity.ProcessedDate = f.ProcessedDate;

                        context.WorkFlowMasters.AddOrUpdate(workflowMasterEntity);
                        context.SaveChanges();
                    }
                    foreach (var e in f.WorkFlowDetails)
                    {
                        var workflowDetailEntity = context.WorkFlowDetails.FirstOrDefault(x => x.RequestID == e.RequestID && x.ReportID == e.ReportID);
                        if (workflowDetailEntity != null)
                        {
                            workflowDetailEntity.Status        = e.Status;
                            workflowDetailEntity.ProcessedDate = e.ProcessedDate;

                            context.WorkFlowDetails.AddOrUpdate(workflowDetailEntity);
                            context.SaveChanges();
                        }
                    }
                }
            }
        }
コード例 #5
0
        public void AddNewRequest(List <WorkFlowMasterDTO> workFlowMasterDTO)
        {
            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <WorkFlowMasterDTO, WorkFlowMaster>();
                cfg.CreateMap <WorkFlowDetailsDTO, WorkFlowDetail>();
            });
            IMapper mapper = config.CreateMapper();

            var workFlowMasterDetails = mapper.Map <List <WorkFlowMasterDTO>, List <WorkFlowMaster> >(workFlowMasterDTO);

            using (var context = new BIPortalEntities())
            {
                context.WorkFlowMasters.AddRange(workFlowMasterDetails);
                context.SaveChanges();
            }
        }
コード例 #6
0
ファイル: RolesData.cs プロジェクト: dsemantics/BIPortal
        //Save role and access rights
        public void SaveRoleAndRights(RolesDTO rolesDTO)
        {
            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <RolesDTO, RoleMaster>();
                cfg.CreateMap <RoleRightsMappingDTO, RoleRightsMapping>();
            });
            IMapper mapper = config.CreateMapper();

            var roleAndRights = mapper.Map <RolesDTO, RoleMaster>(rolesDTO);

            using (var context = new BIPortalEntities())
            {
                //var roleExists = context.RoleMasters.FirstOrDefault(c => c.RoleName.ToLower() == rolesDTO.RoleName.ToLower());
                if (context.RoleMasters.Any(o => o.RoleName.ToLower() == rolesDTO.RoleName.ToLower()))
                {
                    return;
                }
                var roleMaster = new RoleMaster
                {
                    RoleName    = roleAndRights.RoleName,
                    CreatedDate = roleAndRights.CreatedDate,
                    CreatedBy   = roleAndRights.CreatedBy,
                    Active      = roleAndRights.Active
                };

                foreach (var d in roleAndRights.RoleRightsMappings)
                {
                    var rolerightsmapping = new RoleRightsMapping
                    {
                        WorkspaceID   = d.WorkspaceID,
                        WorkspaceName = d.WorkspaceName,
                        ReportID      = d.ReportID,
                        ReportName    = d.ReportName,
                        CreatedDate   = d.CreatedDate,
                        CreatedBy     = d.CreatedBy,
                        Active        = d.Active
                    };
                    roleMaster.RoleRightsMappings.Add(rolerightsmapping);
                }

                context.RoleMasters.Add(roleMaster);

                context.SaveChanges();
            }
        }
コード例 #7
0
        public void UpdateUsersData(UsersDTO userDTO)
        {
            try
            {
                var config = new MapperConfiguration(cfg =>
                {
                    cfg.CreateMap <UsersDTO, UserMaster>();
                    cfg.CreateMap <UserRoleMappingDTO, UserRoleMapping>();
                    cfg.CreateMap <WorkFlowMasterDTO, WorkFlowMaster>();
                    cfg.CreateMap <WorkFlowDetailsDTO, WorkFlowDetail>();
                    cfg.CreateMap <UserAccessRightsDTO, UserAccessRight>();
                });
                IMapper mapper = config.CreateMapper();

                var updateUserDetails = mapper.Map <UsersDTO, UserMaster>(userDTO);

                var workFlowMasterDetails = mapper.Map <List <WorkFlowMasterDTO>, List <WorkFlowMaster> >(userDTO.WorkFlowMasterMappings);

                using (var context = new BIPortalEntities())
                {
                    var EditUserData = context.UserMasters.Where(x => x.UserID == updateUserDetails.UserID).FirstOrDefault();

                    if (EditUserData != null)
                    {
                        EditUserData.EmailID      = updateUserDetails.EmailID;
                        EditUserData.FirstName    = updateUserDetails.FirstName;
                        EditUserData.LastName     = updateUserDetails.LastName;
                        EditUserData.PermissionID = updateUserDetails.PermissionID;
                        EditUserData.Salutation   = updateUserDetails.Salutation;
                        EditUserData.CreatedDate  = DateTime.Now;
                        EditUserData.ModifiedBy   = updateUserDetails.ModifiedBy;
                        EditUserData.ModifiedDate = DateTime.Now;
                        EditUserData.Active       = updateUserDetails.Active;
                        EditUserData.BIObjectType = updateUserDetails.BIObjectType;
                        context.SaveChanges();
                    }


                    // remove existing UserRoleMapping for userid
                    var userRoleMappingRoleExists = context.UserRoleMappings.Where(x => x.UserID == updateUserDetails.UserID);
                    if (userRoleMappingRoleExists != null)
                    {
                        context.UserRoleMappings.RemoveRange(userRoleMappingRoleExists);
                        context.SaveChanges();
                    }

                    // Insert UserRoleMapping
                    foreach (var d in userDTO.SelectedRolesValues)
                    {
                        var userrolemapping = new UserRoleMapping
                        {
                            //RoleID = 1, //should come from UI
                            RoleID      = d,
                            CreatedDate = DateTime.Now,
                            //CreatedBy = "Selva",
                            CreatedBy = updateUserDetails.CreatedBy,
                            Active    = true
                        };
                        EditUserData.UserRoleMappings.Add(userrolemapping);
                    }
                    context.SaveChanges();

                    // remove existing UserAccessRights for userid
                    var userUserAccessRightsMappingUserExists = context.UserAccessRights.Where(x => x.UserID == updateUserDetails.UserID);
                    if (userUserAccessRightsMappingUserExists != null)
                    {
                        context.UserAccessRights.RemoveRange(userUserAccessRightsMappingUserExists);
                        context.SaveChanges();
                    }

                    //Insert UserAccessRights
                    foreach (var e in userDTO.UserAccessRightsMappings)
                    {
                        var userRightsAccessMapping = new UserAccessRight
                        {
                            UserID        = updateUserDetails.UserID,
                            WorkspaceID   = e.WorkspaceID,
                            WorkspaceName = e.WorkspaceName,
                            ReportID      = e.ReportID,
                            ReportName    = e.ReportName,
                            CreatedDate   = DateTime.Now,
                            CreatedBy     = e.CreatedBy,
                            ModifiedDate  = DateTime.Now,
                            ModifiedBy    = e.ModifiedBy,
                            Active        = e.Active
                        };
                        EditUserData.UserAccessRights.Add(userRightsAccessMapping);
                    }
                    context.SaveChanges();

                    // save only active users
                    if (userDTO.Active)
                    {
                        context.WorkFlowMasters.AddRange(workFlowMasterDetails);
                        context.SaveChanges();
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }
        }
コード例 #8
0
        public void SaveUsersData(UsersDTO userDTO)
        {
            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <UsersDTO, UserMaster>();
                cfg.CreateMap <UserRoleMappingDTO, UserRoleMapping>();
                cfg.CreateMap <WorkFlowMasterDTO, WorkFlowMaster>();
                cfg.CreateMap <WorkFlowDetailsDTO, WorkFlowDetail>();
                cfg.CreateMap <UserAccessRightsDTO, UserAccessRight>();
            });
            IMapper mapper = config.CreateMapper();

            var SaveUserDetails = mapper.Map <UsersDTO, UserMaster>(userDTO);

            var workFlowMasterDetails = mapper.Map <List <WorkFlowMasterDTO>, List <WorkFlowMaster> >(userDTO.WorkFlowMasterMappings);

            using (var context = new BIPortalEntities())
            {
                var saveUserMaster = new UserMaster
                {
                    Salutation   = SaveUserDetails.Salutation,
                    FirstName    = SaveUserDetails.FirstName,
                    LastName     = SaveUserDetails.LastName,
                    EmailID      = SaveUserDetails.EmailID,
                    PermissionID = SaveUserDetails.PermissionID,
                    CreatedDate  = DateTime.Now,
                    CreatedBy    = SaveUserDetails.CreatedBy,
                    ModifiedDate = DateTime.Now,
                    Active       = SaveUserDetails.Active,
                    BIObjectType = SaveUserDetails.BIObjectType
                };

                // Insert UserRoleMapping
                foreach (var d in userDTO.SelectedRolesValues)
                {
                    var userrolemapping = new UserRoleMapping
                    {
                        //RoleID = 1, //should come from UI
                        RoleID      = d,
                        CreatedDate = DateTime.Now,
                        CreatedBy   = SaveUserDetails.CreatedBy,
                        Active      = true
                    };
                    saveUserMaster.UserRoleMappings.Add(userrolemapping);
                }


                // Insert UserAcessRights
                foreach (var e in userDTO.UserAccessRightsMappings)
                {
                    var userRightsAccessMapping = new UserAccessRight
                    {
                        UserID        = SaveUserDetails.UserID,
                        WorkspaceID   = e.WorkspaceID,
                        WorkspaceName = e.WorkspaceName,
                        ReportID      = e.ReportID,
                        ReportName    = e.ReportName,
                        //CreatedDate = e.CreatedDate,
                        CreatedDate = DateTime.Now,
                        CreatedBy   = e.CreatedBy,
                        Active      = e.Active
                    };
                    saveUserMaster.UserAccessRights.Add(userRightsAccessMapping);
                }
                context.UserMasters.Add(saveUserMaster);
                context.SaveChanges();

                context.WorkFlowMasters.AddRange(workFlowMasterDetails);
                context.SaveChanges();
            }
        }