コード例 #1
0
        public List <Organization> GetOrgName(string orgId)
        {
            List <Organization> orgs = new List <Organization>();

            try
            {
                var dbOrgs = JSSESecurityManager.GetOrgName(orgId);
                foreach (var dbOrg in dbOrgs)
                {
                    if (!orgs.Any(o => o.Org_Id == dbOrg.org_cd))
                    {
                        Organization org = new Organization();
                        org.Org_Id      = dbOrg.org_cd;
                        org.Org_Name    = dbOrg.org_level_name;
                        org.Departments = null;
                        orgs.Add(org);
                    }
                }
            }
            catch
            {
                throw;
            }
            return(orgs.Distinct().ToList());
        }
コード例 #2
0
        /* Get Group Users of selected */
        public Entities.UserGroup GetUserSecurity(string userName)
        {
            if (!userName.ToLower().StartsWith("coned"))
            {
                userName = "******" + userName;
            }
            Entities.UserGroup userGroup = new Entities.UserGroup();
            try
            {
                var dbUserGroup = JSSESecurityManager.GetUserSecurity(userName);
                if (dbUserGroup != null)
                {
                    userGroup.User = new Entities.UserInfo();
                    userGroup.User.SecurityUserID = dbUserGroup.SecurityUser_ID;
                    userGroup.User.User_ID        = dbUserGroup.User_ID;
                    int empId = 0;
                    Int32.TryParse(dbUserGroup.EmptNo, out empId);
                    userGroup.User.Emp_Id        = empId;
                    userGroup.User.FirstName     = dbUserGroup.FirstName;
                    userGroup.User.LastName      = dbUserGroup.LastName;
                    userGroup.User.FullName      = dbUserGroup.LastName + " , " + dbUserGroup.FirstName;
                    userGroup.User.Email         = dbUserGroup.Email;
                    userGroup.User.User_ID       = dbUserGroup.User_ID;
                    userGroup.User.Org_Id        = dbUserGroup.Org_ID;
                    userGroup.User.MajorGroup_Id = dbUserGroup.MajorGroup_ID;
                    userGroup.User.Dept_Id       = dbUserGroup.Dept_Id;
                    userGroup.User.Section_Id    = dbUserGroup.SectionId;

                    List <Entities.Group> groups = new List <Entities.Group>();
                    foreach (var ugp in dbUserGroup.T_JSSE_Security_UserGroup)
                    {
                        Entities.Group group = new Entities.Group();
                        group.Group_ID  = ugp.T_JSSE_Security_Group.SecurityGroup_ID;
                        group.GroupName = ugp.T_JSSE_Security_Group.GroupName;
                        group.GroupType = new Entities.GroupType()
                        {
                            Level_Id = ugp.T_JSSE_Security_Group.GroupLevel
                        };
                        group.MajorGroup_Id = ugp.T_JSSE_Security_Group.MajorGroup_Id;
                        group.Org_Id        = ugp.T_JSSE_Security_Group.Org_Id;
                        List <Entities.Permission> perms = new List <Entities.Permission>();
                        foreach (var dbPerm in ugp.T_JSSE_Security_Group.T_JSSE_Security_GroupPermission)
                        {
                            Entities.Permission perm = new Entities.Permission();
                            perm.Permission_ID  = dbPerm.T_JSSE_Security_Permission.SecurityPermission_ID;
                            perm.PermissionName = dbPerm.T_JSSE_Security_Permission.PermissionName;
                            perms.Add(perm);
                        }
                        group.Permissions = perms.ToArray();
                        groups.Add(group);
                    }
                    userGroup.Groups = groups.ToArray();
                }
            }
            catch
            {
                throw;
            }
            return(userGroup);
        }
コード例 #3
0
        public List <Organization> GetUserOrgsByPermission(string userId, int groupType, int permissionID)
        {
            List <Organization> orgs = new List <Organization>();

            try
            {
                var dbOrgs = JSSESecurityManager.GetUserOrgsByPermission(userId, groupType, permissionID);
                foreach (var dbOrg in dbOrgs)
                {
                    if (!orgs.Any(o => o.Org_Id == dbOrg.org_cd))
                    {
                        Organization org = new Organization();
                        org.Org_Id          = dbOrg.org_cd;
                        org.Org_Name        = dbOrg.org_level_name;
                        org.MajorGroup_Id   = dbOrg.vp_cd;
                        org.MajorGroup_Name = dbOrg.vp_level_name;
                        org.Departments     = null;
                        orgs.Add(org);
                    }
                }
            }
            catch
            {
                throw;
            }
            return(orgs.Distinct().ToList());
        }
コード例 #4
0
 /* Get User Info of a user by alias */
 public Entities.UserInfo GetUserInfo(string userName)
 {
     Entities.UserInfo userInfo = new Entities.UserInfo();
     try
     {
         var dbUserGroup = JSSESecurityManager.GetUserInfo(userName);
         if (dbUserGroup != null)
         {
             userInfo.CompanyId     = dbUserGroup.Company_Cd;
             userInfo.Emp_Id        = dbUserGroup.Emp_No;
             userInfo.User_ID       = dbUserGroup.PRIMARY_WINDOWS_NT_ACCOUNT;
             userInfo.FirstName     = dbUserGroup.FIRST_NAME;
             userInfo.LastName      = dbUserGroup.LAST_NAME;
             userInfo.FullName      = dbUserGroup.LAST_NAME + " " + dbUserGroup.FIRST_NAME;
             userInfo.Email         = dbUserGroup.EMAIL_ADDRESS_COMPANY;
             userInfo.MajorGroup_Id = dbUserGroup.VP_CD.ToString();
             userInfo.Org_Id        = dbUserGroup.ORG_CD.ToString();
             userInfo.Dept_Id       = dbUserGroup.DEPT_CD.ToString();
             userInfo.Section_Id    = dbUserGroup.SECT_CD.ToString();
         }
     }
     catch
     {
         throw;
     }
     return(userInfo);
 }
コード例 #5
0
        /* Deactivate Security Request to add User to group */
        public int DeActivateUserRequest(Entities.UserRequest request)
        {
            int result = 0;

            result = JSSESecurityManager.DeActiveUserRequest(request.Request_ID);
            return(result);
        }
コード例 #6
0
        /* Add Security Request to add User to group */
        public int AddUserRequest(Entities.UserRequest request)
        {
            int result = 0;
            T_JSSE_Security_Request dbJSSE = new T_JSSE_Security_Request();

            dbJSSE.Requested_By = request.Requested_By;
            dbJSSE.Description  = request.Description;
            dbJSSE.CreatedBy    = request.Requested_By;
            dbJSSE.CreatedDate  = DateTime.Now;
            dbJSSE.Active       = true;
            result = JSSESecurityManager.AddUserRequest(dbJSSE, request.Org_Id);
            return(result);
        }
コード例 #7
0
        public int AddUserToGroupByRequest(Entities.UserRequest request)
        {
            Entities.UserGroup group = new Entities.UserGroup();
            group.User  = request.User;
            group.Group = request.Group;
            //Add User to Group from Request
            try
            {
                JSSESecurityManager.AddUser(group);
            }
            catch (Exception ex)
            {
                //Check Data base Error to see if User Already member of Group, Then Remove Request
                if (ex.Message.IndexOf(JSSEConstants.USER_ALREADY_IN_GROUP) > 0)
                {
                    RemoveUserRequest(request);
                }
                throw ex;
            };
            RemoveUserRequest(request);
            var ccUsers = string.Empty;
            //Get Groups By Level Id (1 for admin 2 for Owner and 3 for user of JSSE)
            var ownerGroups = GetGroupsByLevel(2, request.Group.Org_Id, 0);

            //If Owner Group Exists, then Get Users Owner List in to Variable for Email
            if (ownerGroups.Count > 0)
            {
                int groupId    = ownerGroups.FirstOrDefault().Group_ID;
                var ccUserList = GetGroupUsers(groupId).Select(x => x.User.Email);
                ccUsers = string.Join(",", ccUserList.ToArray());
            }
            else
            {
                string userName = request.User.User_ID;
                ccUsers = GetUserInfo(userName).Email;
            }
            //Send Email notification to User and CC Owner
            string        subject = string.Format(JSSEConstants.ACCESS_GRANT_TEXT, request.Group.GroupName);// "Access has been GRANTED to " + request.Group.GroupName + " Group.";
            StringBuilder sbBody  = new StringBuilder();

            sbBody.AppendLine(subject);
            sbBody.Append("<br/>");
            sbBody.AppendLine(@"<b>Request Sent by: </b>");
            sbBody.Append(request.User.FullName);
            sbBody.Append("<br/>");
            sbBody.AppendLine(@"<b>Granted Access to: </b>");
            sbBody.Append(request.Group.GroupName + " Group");
            SendEmailNotification(sbBody.ToString(), request.User.Email, ccUsers, subject);
            return(1);
        }
コード例 #8
0
        public List <Entities.Group> GetSecurityGroups(int?levelID)
        {
            List <Entities.Group> groups = new List <Entities.Group>();

            try
            {
                var dbGroups = JSSESecurityManager.GetSecurityGroups(levelID);
                foreach (var dbGrp in dbGroups)
                {
                    Entities.Group grp = new Entities.Group();
                    grp.Group_ID  = dbGrp.SecurityGroup_ID;
                    grp.GroupName = dbGrp.GroupName;
                    grp.GroupDesc = dbGrp.GroupDesc;
                    grp.GroupType = new Entities.GroupType()
                    {
                        Level_Id = dbGrp.Level_ID, Level_Name = dbGrp.LevelName
                    };
                    grp.MajorGroup_Id = dbGrp.MajorGroup_Id;
                    grp.Org_Id        = dbGrp.Org_Id;
                    grp.ModifiedDate  = dbGrp.ModifiedDate;
                    if (dbGrp.PermIDList != null)
                    {
                        List <Entities.Permission> perms = new List <Entities.Permission>();
                        string[] permIDList   = dbGrp.PermIDList.Split(',');
                        string[] permNameList = dbGrp.PermList.Split(',');
                        for (int dbPerm = 0; dbPerm < permIDList.Length; dbPerm++)
                        {
                            Entities.Permission perm = new Entities.Permission();
                            perm.Permission_ID  = Int32.Parse(permIDList[dbPerm]);
                            perm.PermissionName = permNameList[dbPerm];
                            perms.Add(perm);
                        }
                        grp.Permissions = perms.ToArray();
                    }
                    groups.Add(grp);
                }
            }
            catch
            {
                throw;
            }
            return(groups);
        }
コード例 #9
0
        public List <Entities.Group> GetGroupsByLevel(int levelId, string orgId, int permissionID)
        {
            List <Entities.Group> groups = new List <Entities.Group>();

            try
            {
                var dbGroups = JSSESecurityManager.GetGroupsByLevel(levelId, orgId, permissionID);
                foreach (var dbGrp in dbGroups)
                {
                    Entities.Group grp = new Entities.Group();
                    grp.Group_ID  = dbGrp.SecurityGroup_ID;
                    grp.GroupName = dbGrp.GroupName;
                    grp.GroupDesc = dbGrp.GroupDesc;
                    grp.GroupType = new Entities.GroupType()
                    {
                        Level_Id = dbGrp.GroupLevel
                    };
                    grp.MajorGroup_Id = dbGrp.MajorGroup_Id;
                    grp.Org_Id        = dbGrp.Org_Id;
                    grp.ModifiedDate  = dbGrp.ModifiedDate;
                    if (dbGrp.T_JSSE_Security_GroupPermission != null)
                    {
                        List <Entities.Permission> perms = new List <Entities.Permission>();
                        foreach (var dbPerm in dbGrp.T_JSSE_Security_GroupPermission)
                        {
                            Entities.Permission perm = new Entities.Permission();
                            perm.Permission_ID  = dbPerm.T_JSSE_Security_Permission.SecurityPermission_ID;
                            perm.PermissionName = dbPerm.T_JSSE_Security_Permission.PermissionName;
                            perms.Add(perm);
                        }
                        grp.Permissions = perms.ToArray();
                    }
                    groups.Add(grp);
                }
            }
            catch
            {
                throw;
            }
            return(groups);
        }
コード例 #10
0
        /* Get Group Requests of selected security group*/
        public List <Entities.UserRequest> GetGroupRequests(int groupId)
        {
            List <Entities.UserRequest> uReqs = new List <Entities.UserRequest>();

            try
            {
                var dbRequests = JSSESecurityManager.GetGroupRequests(groupId);
                foreach (var dbReq in dbRequests)
                {
                    Entities.UserRequest uReq = new Entities.UserRequest();
                    uReq.Group               = new Entities.Group();
                    uReq.User                = new Entities.UserInfo();
                    uReq.Request_ID          = dbReq.Request_ID;
                    uReq.User.SecurityUserID = dbReq.SecurityGroup_ID;
                    uReq.User.User_ID        = dbReq.PRIMARY_WINDOWS_NT_ACCOUNT;
                    uReq.User.Emp_Id         = dbReq.Emp_No;
                    uReq.User.CompanyId      = dbReq.Company_Cd;
                    uReq.User.FirstName      = dbReq.FirstName;
                    uReq.User.LastName       = dbReq.LastName;
                    uReq.User.FullName       = dbReq.LastName + " " + dbReq.FirstName;
                    uReq.User.Email          = dbReq.EMAIL_ADDRESS_COMPANY;
                    uReq.User.MajorGroup_Id  = dbReq.User_MajorGroup_Id.ToString();
                    uReq.User.Org_Id         = dbReq.User_Org_Id.ToString();
                    uReq.User.Dept_Id        = dbReq.User_Dept_Id.ToString();
                    uReq.User.Section_Id     = dbReq.Use_Sect_Id.ToString();
                    uReq.Description         = dbReq.Description;
                    uReq.Requested_By        = dbReq.CreatedBy;
                    uReq.CreatedDate         = dbReq.CreatedDate;
                    uReq.Group.Group_ID      = dbReq.SecurityGroup_ID;
                    uReq.Group.GroupName     = dbReq.GroupName;
                    uReq.Group.MajorGroup_Id = dbReq.MajorGroup_Id;
                    uReq.Group.Org_Id        = dbReq.Org_Id;
                    uReqs.Add(uReq);
                }
            }
            catch
            {
                throw;
            }
            return(uReqs);
        }
コード例 #11
0
        public List <Entities.UserGroup> GetGroupUsers(int groupId)
        {
            List <Entities.UserGroup> uGrps = new List <Entities.UserGroup>();

            try
            {
                var dbGroups = JSSESecurityManager.GetGroupUsers(groupId);
                foreach (var dbGrp in dbGroups)
                {
                    Entities.UserGroup uGrp = new Entities.UserGroup();
                    uGrp.Group = new Entities.Group();
                    uGrp.User  = new Entities.UserInfo();
                    uGrp.User.SecurityUserID = dbGrp.SecurityUser_ID;
                    uGrp.User.User_ID        = dbGrp.User_ID;
                    int empId = 0;
                    Int32.TryParse(dbGrp.EmptNo, out empId);
                    uGrp.User.Emp_Id     = empId;
                    uGrp.User.CompanyId  = dbGrp.CompanyCd;
                    uGrp.User.FirstName  = dbGrp.FirstName;
                    uGrp.User.LastName   = dbGrp.LastName;
                    uGrp.User.FullName   = dbGrp.LastName + " " + dbGrp.FirstName;
                    uGrp.User.Email      = dbGrp.Email;
                    uGrp.ModifiedDate    = dbGrp.ModifiedDate;
                    uGrp.Group.Group_ID  = dbGrp.SecurityGroup_ID;
                    uGrp.Group.GroupName = dbGrp.GroupName;
                    uGrp.Group.GroupType = new Entities.GroupType()
                    {
                        Level_Id = dbGrp.Level_ID, Level_Name = dbGrp.LevelName
                    };
                    uGrp.Group.MajorGroup_Id = dbGrp.MajorGroup_Id;
                    uGrp.Group.Org_Id        = dbGrp.Org_Id;
                    uGrps.Add(uGrp);
                }
            }
            catch
            {
                throw;
            }
            return(uGrps);
        }
コード例 #12
0
        public List <UserInfo> SearchUsers(string firstName, string lastName)
        {
            List <UserInfo> userInfos = new List <UserInfo>();
            var             dbUsers   = JSSESecurityManager.SearchUsers(firstName, lastName);

            foreach (var dbUser in dbUsers)
            {
                UserInfo userInfo = new UserInfo();
                userInfo.CompanyId     = dbUser.Company_Cd;
                userInfo.Emp_Id        = dbUser.Emp_No;
                userInfo.FirstName     = dbUser.FIRST_NAME;
                userInfo.LastName      = dbUser.LAST_NAME;
                userInfo.FullName      = dbUser.LAST_NAME + " , " + dbUser.FIRST_NAME;
                userInfo.Email         = dbUser.EMAIL_ADDRESS_COMPANY;
                userInfo.User_ID       = dbUser.PRIMARY_WINDOWS_NT_ACCOUNT;
                userInfo.Org_Id        = dbUser.ORG_CD.ToString();
                userInfo.MajorGroup_Id = dbUser.VP_CD.ToString();
                userInfo.Dept_Id       = dbUser.DEPT_CD.ToString();
                userInfo.Section_Id    = dbUser.SECT_CD.ToString();
                userInfos.Add(userInfo);
            }
            return(userInfos.Distinct().ToList());
        }
コード例 #13
0
        public List <MajorGroup> GetUserMajorGroups(string userId, int groupType)
        {
            List <MajorGroup>   mgs   = new List <MajorGroup>();
            List <Organization> orgs  = null;
            List <Department>   depts = null;
            List <Section>      sects = null;

            try
            {
                var dbMGs = JSSESecurityManager.GetUserOrganizations(userId, groupType);
                foreach (var dbMG in dbMGs)
                {
                    if (!mgs.Any(o => o.MajorGroup_Id == dbMG.vp_cd))
                    {
                        MajorGroup mg = new MajorGroup();
                        mg.MajorGroup_Id   = dbMG.vp_cd;
                        mg.MajorGroup_Name = dbMG.vp_level_name;

                        var dbOrgs = dbMGs.Where(m => m.vp_cd == dbMG.vp_cd);
                        orgs = new List <Organization>();
                        foreach (var dbOrg in dbOrgs)
                        {
                            if (!orgs.Any(o => o.Org_Id == dbOrg.org_cd))
                            {
                                Organization org = new Organization();
                                org.Org_Id   = dbOrg.org_cd;
                                org.Org_Name = dbOrg.org_level_name;

                                var dbDepts = dbOrgs.Where(m => m.org_cd == dbOrg.org_cd);
                                depts = new List <Department>();
                                foreach (var dbDept in dbDepts)
                                {
                                    if (!depts.Any(o => o.Dept_Id == dbDept.dept_cd))
                                    {
                                        Department dept = new Department();
                                        dept.Dept_Id   = dbDept.dept_cd;
                                        dept.Dept_Name = dbDept.dept_level_name;

                                        var dbSects = dbDepts.Where(m => m.dept_cd == dbDept.dept_cd);
                                        sects = new List <Section>();
                                        foreach (var dbSect in dbSects)
                                        {
                                            if (!sects.Any(o => o.Section_Id == dbDept.sect_cd))
                                            {
                                                Section sect = new Section();
                                                sect.Section_Id   = dbSect.sect_cd;
                                                sect.Section_Name = dbSect.sect_level_name;
                                                sects.Add(sect);
                                            }
                                        }
                                        dept.Sections = sects.ToArray();
                                        depts.Add(dept);
                                    }
                                }
                                org.Departments = depts.ToArray();
                                orgs.Add(org);
                            }
                        }
                        mg.Organizations = orgs.ToArray();
                        mgs.Add(mg);
                    }
                }
            }
            catch
            {
                throw;
            }
            return(mgs.Distinct().ToList());
        }
コード例 #14
0
        public JSSEMain GetJSSE(int jsseId)
        {
            JSSEMain oJsse = new JSSEMain();

            try
            {
                var dbJsses = jsseRepo.GetJSSE(jsseId).ToList();
                foreach (var dbJSSE in dbJsses)
                {
                    oJsse.IsAnonymous = dbJSSE.IsAnonymous;
                    //Observers
                    List <UserInfo> oObservers     = new List <UserInfo>();
                    List <UserInfo> oSupervisors   = new List <UserInfo>();
                    var             selObservers   = string.Empty;
                    var             selSupervisors = string.Empty;
                    foreach (var dbObserver in dbJSSE.T_JSSE_Observer.Where(j => j.Active == true))
                    {
                        UserInfo observer = new UserInfo();
                        observer.Emp_Id        = Convert.ToInt64(dbObserver.Emp_ID);
                        observer.FirstName     = dbObserver.FirstName;
                        observer.LastName      = dbObserver.LastName;
                        observer.FullName      = dbObserver.LastName + " , " + dbObserver.FirstName;
                        observer.MajorGroup_Id = Convert.ToString(dbObserver.T_JSSE_Hierarchy.MajorGroup_Id);
                        observer.Org_Id        = Convert.ToString(dbObserver.T_JSSE_Hierarchy.Org_Id);
                        observer.Dept_Id       = Convert.ToString(dbObserver.T_JSSE_Hierarchy.Dept_Id);
                        observer.Section_Id    = Convert.ToString(dbObserver.T_JSSE_Hierarchy.Sect_Id);
                        observer.User_ID       = dbObserver.User_Id;
                        observer.UserRole      = dbObserver.UserRole;
                        if (dbObserver.UserRole != "Supervisor")
                        {
                            oObservers.Add(observer);
                            if (!string.IsNullOrEmpty(selObservers))
                            {
                                selObservers = selObservers + "; " + observer.FullName;
                            }
                            else
                            {
                                selObservers = observer.FullName;
                            }
                        }
                        else
                        {
                            oSupervisors.Add(observer);
                            if (!string.IsNullOrEmpty(selSupervisors))
                            {
                                selSupervisors = selSupervisors + "; " + observer.FullName;
                            }
                            else
                            {
                                selSupervisors = observer.FullName;
                            }
                        }
                    }
                    if (oObservers.Count > 0)
                    {
                        if (string.IsNullOrEmpty(oObservers[0].UserRole))
                        {
                            oJsse.IsSupervsrOBSRSame = -1;
                        }
                        else
                        {
                            oJsse.IsSupervsrOBSRSame = 1;
                        }
                        if (oObservers[0].User_ID.ToLower() == "anonymous")
                        {
                            oJsse.IsOBSRAnonymous = true;
                        }
                        else
                        {
                            oJsse.IsOBSRAnonymous = false;
                        }
                        if (oSupervisors.Count > 0)
                        {
                            if (oObservers[0].Emp_Id != oSupervisors[0].Emp_Id)
                            {
                                oJsse.IsSupervsrOBSRSame = 0;
                            }
                            else
                            {
                                oJsse.IsSupervsrOBSRSame = 1;
                            }
                        }
                    }

                    oJsse.Observers      = oObservers.ToArray();
                    oJsse.SelObservers   = selObservers;
                    oJsse.Supervisors    = oSupervisors.ToArray();
                    oJsse.SelSupervisors = selSupervisors;
                    //Observees
                    List <UserInfo> oObservees   = new List <UserInfo>();
                    var             selObservees = string.Empty;
                    foreach (var dbObservee in dbJSSE.T_JSSE_Observee.Where(j => j.Active == true))
                    {
                        UserInfo observee = new UserInfo();
                        observee.Emp_Id        = Convert.ToInt64(dbObservee.Emp_ID);
                        observee.FirstName     = dbObservee.FirstName;
                        observee.LastName      = dbObservee.LastName;
                        observee.FullName      = dbObservee.LastName + " , " + dbObservee.FirstName;
                        observee.MajorGroup_Id = Convert.ToString(dbObservee.T_JSSE_Hierarchy.MajorGroup_Id);
                        observee.Org_Id        = Convert.ToString(dbObservee.T_JSSE_Hierarchy.Org_Id);
                        observee.Dept_Id       = Convert.ToString(dbObservee.T_JSSE_Hierarchy.Dept_Id);
                        observee.Section_Id    = Convert.ToString(dbObservee.T_JSSE_Hierarchy.Sect_Id);
                        observee.User_ID       = dbObservee.User_Id;
                        //observee.UserTitle = "User Title";
                        oObservees.Add(observee);
                        if (!string.IsNullOrEmpty(selObservees))
                        {
                            selObservees = selObservees + "; " + observee.FullName;
                        }
                        else
                        {
                            selObservees = observee.FullName;
                        }
                    }
                    oJsse.Observees    = oObservees.ToArray();
                    oJsse.SelObservees = selObservees;

                    oJsse.JSSE_ID        = dbJSSE.JSSE_ID;
                    oJsse.Base64_JSSE_ID = dbJSSE.JSSE_ID.ToString();//Crypto.DecryptStringAES(Convert.ToString(dbJSSE.JSSE_ID), "JSSE");
                    oJsse.JobName        = dbJSSE.JobName;
                    oJsse.JobDescription = dbJSSE.JobDescription;
                    oJsse.JSSEDate       = dbJSSE.JSSEDate;
                    oJsse.JSSEStatus     = dbJSSE.Status;
                    oJsse.Location       = dbJSSE.Location;
                    var createdId = dbJSSE.CreatedBy != "Anonymous" && !dbJSSE.CreatedBy.StartsWith("CONED") ? "CONED\\" + dbJSSE.CreatedBy : dbJSSE.CreatedBy;
                    if (dbJSSE.CreatedBy != "Anonymous")
                    {
                        var createdUser = JSSESecurityManager.GetUserInfo(createdId);
                        if (createdUser != null)
                        {
                            oJsse.JSSECreator = createdUser.LAST_NAME + ", " + createdUser.FIRST_NAME;
                        }
                        else
                        {
                            oJsse.JSSECreator = dbJSSE.CreatedBy;
                        }
                    }
                    else
                    {
                        oJsse.JSSECreator = dbJSSE.CreatedBy;
                    }
                    oJsse.JSSEEnteredBy = dbJSSE.CreatedBy;
                    oJsse.Region_ID     = dbJSSE.T_JSSE_Master_Region.Region_ID;
                    oJsse.Location      = dbJSSE.Location;
                    oJsse.MajorGroup_Id = Convert.ToInt32(oJsse.Observees[0].MajorGroup_Id);
                    oJsse.Org_Id        = Convert.ToInt32(oJsse.Observees[0].Org_Id);
                    oJsse.Dept_Id       = !string.IsNullOrEmpty(oJsse.Observees[0].Dept_Id) ? Convert.ToInt32(oJsse.Observees[0].Dept_Id) : 0;
                    oJsse.Section_Id    = !string.IsNullOrEmpty(oJsse.Observees[0].Section_Id) ? Convert.ToInt32(oJsse.Observees[0].Section_Id) : 0;
                    oJsse.Hierarchy_ID  = dbJSSE.T_JSSE_Observee.FirstOrDefault(d => d.Active == true) != null?dbJSSE.T_JSSE_Observee.FirstOrDefault(d => d.Active == true).T_JSSE_Hierarchy.Hierarchy_ID : 0;

                    //oJsse.majorgroups = GetMajorGroups().ToArray();
                    //oJsse.organizations = GetOrganizations(oJsse.MajorGroup_Id.ToString()).ToArray();
                    //oJsse.departments = GetDepartments(oJsse.Org_Id.ToString()).ToArray();
                    //oJsse.sections = GetSections(oJsse.Dept_Id.ToString()).ToArray();
                    List <JSSECategory> oSelCats = new List <JSSECategory>();


                    //Build the selected cats
                    foreach (var dbSelCat in dbJSSE.T_JSSE_Category.Where(j => j.Active == true))
                    {
                        JSSECategory oSelCat = new JSSECategory();
                        oSelCat.Category_ID = dbSelCat.T_JSSE_Master_Category.Category_ID;
                        if (dbSelCat.T_JSSE_Master_Rating != null)
                        {
                            oSelCat.RatingID = Convert.ToString(dbSelCat.T_JSSE_Master_Rating.Rating_ID);
                        }
                        else
                        {
                            oSelCat.RatingID = "0";
                        }
                        oSelCat.Comments = dbSelCat.T_JSSE_Comment.SingleOrDefault().Comment;
                        oSelCat.JSSE_ID  = dbSelCat.T_JSSE_Main.JSSE_ID;
                        oSelCat.IsActive = Convert.ToBoolean(dbSelCat.Active);

                        //Build the selecrted behs
                        List <JSSEBehavior> oSelBehs = new List <JSSEBehavior>();
                        foreach (var dbSelBeh in dbSelCat.T_JSSE_Behavior.Where(j => j.Active == true))
                        {
                            JSSEBehavior oSelBeh = new JSSEBehavior();
                            oSelBeh.Behavior_ID     = dbSelBeh.T_JSSE_Master_Behavior.Behavior_ID;
                            oSelBeh.BehaviorType_ID = dbSelBeh.T_JSSE_Master_Behavior.T_JSSE_Master_BehaviorType.BehaviorType_ID;
                            oSelBeh.Category_ID     = dbSelBeh.T_JSSE_Category.JSSECategory_ID;
                            if (dbSelBeh.T_JSSE_Master_Rating != null)
                            {
                                oSelBeh.Rating_ID = dbSelBeh.T_JSSE_Master_Rating.Rating_ID;
                                oSelBeh.Rating    = dbSelBeh.T_JSSE_Master_Rating.Rating;
                            }
                            else
                            {
                                oSelBeh.Rating_ID = 2; // if rating is blank for old records then rating is effective
                            }
                            oSelBeh.Comments = dbSelBeh.Comment;
                            oSelBeh.IsActive = Convert.ToBoolean(dbSelBeh.Active);
                            oSelBehs.Add(oSelBeh);
                        }
                        oSelCat.EntBehaviors = oSelBehs.ToArray();
                        oSelCats.Add(oSelCat);
                    }

                    //Can be fine-tuned later
                    List <JSSECategory> oAllCats = null;
                    if (oSelCats.Count > 0)
                    {
                        oAllCats = GetAllMasterCategories(oJsse.Org_Id);
                    }
                    else
                    {
                        oAllCats = GetAllActiveMasterCategories(oJsse.Org_Id);
                    }

                    foreach (var oSelCat in oSelCats)
                    {
                        foreach (var oCat in oAllCats)
                        {
                            if (oCat.Category_ID == oSelCat.Category_ID)
                            {
                                oCat.RatingID = oSelCat.RatingID;
                                oCat.Comments = oSelCat.Comments;
                                oCat.JSSE_ID  = oSelCat.JSSE_ID;

                                foreach (var oBeh in oCat.EntBehaviors)
                                {
                                    foreach (var oSelBeh in oSelCat.EntBehaviors)
                                    {
                                        if (oBeh.Behavior_ID == oSelBeh.Behavior_ID)
                                        {
                                            oBeh.BehviorChecked = true;
                                            oBeh.Category_ID    = oSelBeh.Category_ID;
                                            oBeh.Rating_ID      = oSelBeh.Rating_ID;
                                            oBeh.Rating         = oSelBeh.Rating;
                                            oBeh.Comments       = oSelBeh.Comments;
                                        }
                                    }
                                }
                                foreach (var oBeh in oCat.OrgBehaviors)
                                {
                                    foreach (var oSelBeh in oSelCat.EntBehaviors)
                                    {
                                        if (oBeh.Behavior_ID == oSelBeh.Behavior_ID)
                                        {
                                            oBeh.BehviorChecked = true;
                                            oBeh.Category_ID    = oSelBeh.Category_ID;
                                            oBeh.Rating_ID      = oSelBeh.Rating_ID;
                                            oBeh.Rating         = oSelBeh.Rating;
                                            oBeh.Comments       = oSelBeh.Comments;
                                        }
                                    }
                                }
                            }
                            oCat.EntBehaviors = oCat.EntBehaviors.Where(eb => eb.IsActive == true || eb.Category_ID != null).ToArray();
                            oCat.OrgBehaviors = oCat.OrgBehaviors.Where(ob => ob.IsActive == true || ob.Category_ID != null).ToArray();
                        }
                    }
                    oJsse.Categories = oAllCats.Where(c => c.IsActive == true || c.JSSE_ID != null).ToArray();


                    //Get the attachments for the JSSE
                    List <JSSEAttachment> oAttachments = new List <JSSEAttachment>();
                    foreach (var dbAttachment in dbJSSE.T_JSSE_Attachments.Where(j => j.Active == true))
                    {
                        JSSEAttachment attachment = new JSSEAttachment();
                        attachment.Title             = dbAttachment.Title;
                        attachment.Description       = dbAttachment.Description;
                        attachment.FileName          = dbAttachment.FileName;
                        attachment.Base64ImageString = CreateBase64Image(dbAttachment.Image);
                        oAttachments.Add(attachment);
                    }
                    oJsse.Attachments = oAttachments.ToArray();
                }
            }
            catch (Exception ex) { throw ex; }
            return(oJsse);
        }