Beispiel #1
0
        public static IEnumerable <UserGroupUser> Map(IRepository <eSuiteDbContext> repository, SqlDataReader dr)
        {
            var ret = new List <UserGroupUser>();

            var userId = LookUpUser(repository, Convert.ToString(dr["U_Login_Id"]));

            var uguESmat = new UserGroupUser();

            uguESmat.UserId = userId;
            uguESmat.ApplicationUserGroupId = LookUpApplicationUserGroup(repository, "eSmat", Convert.ToString(dr["UT_User_Type"]));
            if (uguESmat.UserId != default(int) && uguESmat.ApplicationUserGroupId != default(int))
            {
                ret.Add(uguESmat);
            }

            var uguESuite = new UserGroupUser();

            uguESuite.UserId = userId;
            uguESuite.ApplicationUserGroupId = LookUpApplicationUserGroup(repository, "eSuite", "User");
            if (uguESuite.UserId != default(int) && uguESuite.ApplicationUserGroupId != default(int))
            {
                ret.Add(uguESuite);
            }

            var uguEAction = new UserGroupUser();

            uguEAction.UserId = userId;
            uguEAction.ApplicationUserGroupId = LookUpApplicationUserGroup(repository, "eAction", Convert.ToString(dr["UT_User_Type"]).Replace("SMAT Leader", "Action Leader"));
            if (uguEAction.UserId != default(int) && uguEAction.ApplicationUserGroupId != default(int))
            {
                ret.Add(uguEAction);
            }

            return(ret);
        }
Beispiel #2
0
 //Thêm người dùng vào nhóm
 public bool InsertUserToGroup(string pUserName, string pIdGroup)
 {
     try
     {
         dc = new DbSpaDataContext();
         var query = from us in dc.UserGroupUsers
                     where us.USERNAME == pUserName && us.IDGROUPUSER.Equals(pIdGroup)
                     select us;
         if (query != null)
         {
             UserGroupUser us = new UserGroupUser();
             us.USERNAME    = pUserName;
             us.IDGROUPUSER = Convert.ToInt32(pIdGroup);
             us.STATUS      = 1;
             dc.UserGroupUsers.InsertOnSubmit(us);
             dc.SubmitChanges();
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch
     {
         return(false);
     }
 }
Beispiel #3
0
        public void AddUserToGroup(UserAccount user, UserGroup group)
        {
            var userGroupUser = new UserGroupUser
            {
                Group       = group,
                User        = user,
                Permissions = 0
            };

            group.Users.Add(userGroupUser);
            Commit();
        }
Beispiel #4
0
 //Xóa người dùng khỏi nhóm
 public bool DeleteUserOutGroup(string pUserName, string pIdGroup)
 {
     try
     {
         dc = new DbSpaDataContext();
         UserGroupUser user = dc.UserGroupUsers.Where(t => t.USERNAME == pUserName && t.IDGROUPUSER == Convert.ToInt32(pIdGroup)).FirstOrDefault();
         dc.UserGroupUsers.DeleteOnSubmit(user);
         dc.SubmitChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Beispiel #5
0
        public UserGroup CreateAndAddNewGroup(string name, UserAccount admin)
        {
            var userGroup = new UserGroup
            {
                Name = name
            };

            var userGroupUser = new UserGroupUser
            {
                Group       = userGroup,
                User        = admin,
                Permissions = 1
            };

            userGroup.Users.Add(userGroupUser);

            Add(userGroup);
            Commit();
            return(userGroup);
        }
        // Test version until A/D available
        public void AddUserToGroup(string groupName, UserModel user)
        {
            var group = db.FindUserGroup(groupName);

            if (group == null)
            {
                group = new UserGroup {
                    GroupName = groupName, Enabled = true
                };
                db.InsertOrUpdateUserGroup(group);
            }

            var groupUser = db.FindUserGroupUser(group.Id, user.Id);

            if (groupUser == null)
            {
                groupUser = new UserGroupUser {
                    UserGroup = group,
                    User      = db.FindUser(user.Id)
                };
                db.InsertOrUpdateUserGroupUser(groupUser);
            }
        }
Beispiel #7
0
        public static void AddTransaction(BizPortalSessionContext context, int functionId, int pageId, UserGroupUser uguTarget, User u, ref string message, ref int warningCount)
        {
            string functionName = "";
            string lange        = context.CurrentLanguage.Code;

            using (ITransaction tx = context.PersistenceSession.BeginTransaction())
            {
                try
                {
                    if (IsExisting(uguTarget.Group.GroupUsers, u, ref message))
                    {
                        warningCount++;
                    }
                    if (warningCount == 0)
                    {
                        MaintenanceWorkflow fw = GetFunctionMaintenanceWorkflow(context.User, functionId);
                        functionName = Messages.UserGroupUser.AddUserGroupUser.Format(lange, uguTarget.User.LoginName, uguTarget.Group.Title);
                        if (fw.MemberFunction == null)
                        {
                            warningCount++;
                            message = Messages.Genaral.IsNotMemberFunction.Format(context.CurrentLanguage.Code);
                        }
                        BizPortalFunction             function          = fw.MemberFunction.Function;
                        AddMemberGroupUserTransaction transactionMember = new AddMemberGroupUserTransaction(context, fw, DateTime.Now, context.Member, uguTarget);
                        transactionMember.Transit(context, fw, functionName, TransitionEventCode.SubmitEvent);
                        transactionMember.Persist(context);
                        tx.Commit();

                        message = String.Format("{0} <br/>", Messages.Genaral.TransactionSubmitedForPendingApproval.Format(lange, functionName));
                        context.Log(functionId, pageId, 0, ActionLog.BankAdminFunction.AddMemberGroupUser, functionName);
                    }
                }
                catch (Exception ex)
                {
                    tx.Rollback();
                    warningCount++;
                    context.Log((int)functionId, pageId, 0, ActionLog.BankAdminFunction.AddMemberGroupUser
                                , IBankException.LogMessageProgramError(ex, ExceptionMessages.AddTransactionUserGroupUserError_Role.Code + "-" + functionName + message));
                    message = ExceptionMessages.AddTransactionUserGroupUserError_Role.Message;
                }
            }
        }
Beispiel #8
0
        public static void AddTransactionClient(BizPortalSessionContext context, Member member, int functionId, UserGroupUser uguTarget, User u, ref string message, ref int warningCount)
        {
            string functionName = "";
            string lange        = context.CurrentLanguage.Code;

            using (ITransaction tx = context.PersistenceSession.BeginTransaction())
            {
                try
                {
                    if (uguTarget.IsNotFinalized)
                    {
                        warningCount++;
                        message = Messages.Genaral.TransactionApproved.Format(lange);
                    }
                    if (IsExisting(uguTarget.Group.GroupUsers, u, ref message))
                    {
                        warningCount++;
                    }
                    if (warningCount == 0)
                    {
                        MaintenanceWorkflow fw = GetFunctionMaintenanceWorkflow(context.User, functionId);
                        functionName = Messages.UserGroupUser.AddUserGroupUser.Format(lange, uguTarget.User.LoginName, uguTarget.Group.Title);
                        if (fw.MemberFunction == null)
                        {
                            warningCount++;
                            message = Messages.Genaral.IsNotMemberFunction.Format(context.CurrentLanguage.Code);
                        }
                        else
                        {
                            BizPortalFunction             function          = fw.MemberFunction.Function;
                            AddMemberGroupUserTransaction transactionMember = new AddMemberGroupUserTransaction(context, fw, DateTime.Now, member, uguTarget);
                            transactionMember.Transit(context, fw, functionName, TransitionEventCode.SubmitEvent);
                            transactionMember.Persist(context);
                            tx.Commit();

                            message = String.Format("- {0} {1} {2} <br/>",
                                                    functionName,
                                                    Messages.Genaral.Success.Format(lange),
                                                    Messages.Genaral.PendingApproval.Format(lange));
                            context.Log(functionId, 0, 0, ActionLog.BankAdminFunction.AddMemberGroupUser, functionName);
                        }
                    }
                }
                catch (Exception)
                {
                    tx.Rollback();
                    warningCount++;
                    context.Log((int)functionId, 0, 0, ActionLog.BankAdminFunction.AddMemberGroupUser, functionName + message);
                    //context.Log((int)functionId, 0, 0, Messages.UserGroupUser.AddUserGroupUser.Format(lange, "", ""),
                    //        functionName + message);
                }
            }
        }