コード例 #1
0
        /// <summary>
        /// get checked data from childnodes and update to db
        /// </summary>
        /// <param name="roleCode"></param>
        /// <param name="treeNodes"></param>
        /// <param name="roleAuthorityVo"></param>
        private void UpdateChildNode(String roleCode, TreeNodeCollection treeNodes, RoleAuthorityControlVo roleAuthorityVo)
        {
            string authorityCode;

            foreach (TreeNode child in treeNodes)
            {
                authorityCode = child.Tag.ToString();

                int roleAuthorityCount =
                    roleAuthorityVo.RoleAuthorityControlListVo.Count(
                        t => t.RoleCode == roleCode && t.AuthorityControlCode == authorityCode);

                if (child.Checked)
                {
                    if (roleAuthorityCount == 0)
                    {
                        AddRoleAuthority(roleCode, authorityCode);
                    }
                }
                else
                {
                    if (roleAuthorityCount == 1)
                    {
                        DeleteRoleAuthority(roleCode, authorityCode);
                    }
                }

                UpdateChildNode(roleCode, child.Nodes, roleAuthorityVo);
            }
        }
コード例 #2
0
        /// <summary>
        /// Updates role authority
        /// </summary>
        private void UpdateRoleAuthority()
        {
            TreeNodeCollection nodes = RoleAuthorityDetails_tv.Nodes;

            try
            {
                RoleAuthorityControlVo roleAuthorityCheckVo =
                    (RoleAuthorityControlVo)base.InvokeCbm(new GetRoleAuthorityControlMasterMntCbm(), new RoleAuthorityControlVo(), false);


                foreach (TreeNode tn in nodes)
                {
                    //if (IsAdminUser())
                    //{
                    //    if (!tn.Tag.Equals(ADMIN))
                    //    {
                    //        UpdateChildNode(tn.Tag.ToString(), tn.Nodes, roleAuthorityCheckVo);
                    //    }
                    //}
                    //else
                    //{
                    UpdateChildNode(tn.Tag.ToString(), tn.Nodes, roleAuthorityCheckVo);
                    //}
                }

                messageData = new MessageData("mmci00002", Properties.Resources.mmci00002, null);
                logger.Info(messageData);
                popUpMessage.Information(messageData, Text);
            }
            catch (Framework.ApplicationException exception)
            {
                popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                logger.Error(exception.GetMessageData());
            }
        }
コード例 #3
0
        public override ValueObject Execute(TransactionContext trxContext, ValueObject arg)
        {
            RoleAuthorityControlVo inVo = (RoleAuthorityControlVo)arg;

            StringBuilder sqlQuery = new StringBuilder();

            sqlQuery.Append("Delete from m_role_authority_control");
            sqlQuery.Append(" Where	");
            sqlQuery.Append(" authority_control_cd = :authcd ");
            sqlQuery.Append(" and ");
            sqlQuery.Append(" role_cd = :rolecd ;");

            //create command
            DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString());

            //create parameter
            DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList();

            sqlParameter.AddParameterString("authcd", inVo.AuthorityControlCode);
            sqlParameter.AddParameterString("rolecd", inVo.RoleCode);

            RoleAuthorityControlVo outVo = new RoleAuthorityControlVo
            {
                AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter)
            };

            return(outVo);
        }
コード例 #4
0
        public override ValueObject Execute(TransactionContext trxContext, ValueObject arg)
        {
            RoleAuthorityControlVo inVo = (RoleAuthorityControlVo)arg;

            StringBuilder sqlQuery = new StringBuilder();

            sqlQuery.Append("Select rac.role_cd,rac.authority_control_cd ");
            sqlQuery.Append("from m_role_authority_control rac ");
            sqlQuery.Append(" inner join m_mes_role ro  on rac.role_cd = ro.role_cd ");
            sqlQuery.Append(" inner join m_authority_control ac  on rac.authority_control_cd = ac.authority_control_cd ");
            sqlQuery.Append(" where 1 = 1 ");

            if (inVo.RoleCode != null)
            {
                sqlQuery.Append(" and rac.role_cd = :rolecd ");
            }

            if (inVo.AuthorityControlCode != null)
            {
                sqlQuery.Append(" and rac.authority_control_cd = :authcd ");
            }

            //create command
            DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString());

            //create parameter
            DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList();

            if (inVo.RoleCode != null)
            {
                sqlParameter.AddParameterString("rolecd", inVo.RoleCode);
            }

            if (inVo.AuthorityControlCode != null)
            {
                sqlParameter.AddParameterString("authcd", inVo.AuthorityControlCode);
            }

            //execute SQL
            IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter);

            RoleAuthorityControlVo outVo = new RoleAuthorityControlVo();

            while (dataReader.Read())
            {
                RoleAuthorityControlVo currOutVo = new RoleAuthorityControlVo
                {
                    RoleCode             = dataReader["role_cd"].ToString(),
                    AuthorityControlCode = dataReader["authority_control_cd"].ToString()
                };
                outVo.RoleAuthorityControlListVo.Add(currOutVo);
            }

            dataReader.Close();

            return(outVo);
        }
コード例 #5
0
        /// <summary>
        /// Deletes role authority
        /// </summary>
        /// <param name="roleCode"></param>
        /// <param name="authorityCode"></param>
        private void DeleteRoleAuthority(string roleCode, string authorityCode)
        {
            RoleAuthorityControlVo roleAuthorityInVo = new RoleAuthorityControlVo
            {
                RoleCode             = roleCode,
                AuthorityControlCode = authorityCode
            };

            try
            {
                RoleAuthorityControlVo roleAuthorityOutVo =
                    (RoleAuthorityControlVo)base.InvokeCbm(new DeleteRoleAuthorityControlMasterMntCbm(), roleAuthorityInVo, false);
            }
            catch (Framework.ApplicationException exception)
            {
                popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                logger.Error(exception.GetMessageData());
            }
        }
コード例 #6
0
        public override ValueObject Execute(TransactionContext trxContext, ValueObject arg)
        {
            RoleAuthorityControlVo inVo = (RoleAuthorityControlVo)arg;

            StringBuilder sqlQuery = new StringBuilder();

            sqlQuery.Append("Insert into m_role_authority_control");
            sqlQuery.Append(" ( ");
            sqlQuery.Append(" role_cd, ");
            sqlQuery.Append(" authority_control_cd, ");
            sqlQuery.Append(" registration_user_cd, ");
            sqlQuery.Append(" registration_date_time, ");
            sqlQuery.Append(" factory_cd ");
            sqlQuery.Append(" ) ");
            sqlQuery.Append("VALUES	");
            sqlQuery.Append(" ( ");
            sqlQuery.Append(" :rolecd ,");
            sqlQuery.Append(" :authcd ,");
            sqlQuery.Append(" :registrationusercode ,");
            sqlQuery.Append(" now() ,");
            sqlQuery.Append(" :factorycode ");
            sqlQuery.Append(" ); ");

            //create command
            DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString());

            //create parameter
            DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList();

            sqlParameter.AddParameterString("rolecd", inVo.RoleCode);
            sqlParameter.AddParameterString("authcd", inVo.AuthorityControlCode);
            sqlParameter.AddParameterString("registrationusercode", inVo.RegistrationUserCode);
            //sqlParameter.AddParameterDateTime("registrationdatetime", inVo.RegistrationDateTime);
            sqlParameter.AddParameterString("factorycode", inVo.FactoryCode);

            RoleAuthorityControlVo outVo = new RoleAuthorityControlVo
            {
                AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter)
            };

            return(outVo);
        }
コード例 #7
0
        /// <summary>
        /// Adds new role authority
        /// </summary>
        /// <param name="roleCode"></param>
        /// <param name="authCode"></param>
        private void AddRoleAuthority(string roleCode, string authCode)
        {
            RoleAuthorityControlVo roleAuthorityInVo = new RoleAuthorityControlVo
            {
                RoleCode             = roleCode,
                AuthorityControlCode = authCode,
                //RegistrationDateTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"),
                RegistrationUserCode = UserData.GetUserData().UserCode,
                FactoryCode          = UserData.GetUserData().FactoryCode
            };

            try
            {
                RoleAuthorityControlVo roleAuthorityOutVo =
                    (RoleAuthorityControlVo)base.InvokeCbm(new AddRoleAuthorityControlMasterMntCbm(), roleAuthorityInVo, false);
            }
            catch (Framework.ApplicationException exception)
            {
                popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                logger.Error(exception.GetMessageData());
            }
        }
コード例 #8
0
        /// <summary>
        /// bind child treenodes
        /// </summary>
        /// <param name="authority"></param>
        /// <param name="roleAuthority"></param>
        /// <param name="parentControlCode"></param>
        /// <param name="roleCode"></param>
        /// <param name="childNode"></param>
        private void PopulateChildNode(List <AuthorityControlVo> authority, RoleAuthorityControlVo roleAuthority,
                                       string parentControlCode, string roleCode, TreeNode childNode)
        {
            List <AuthorityControlVo> parentAuthorityVo = authority.Where(
                t => t.ParentControlCode == parentControlCode).ToList();

            TreeNode mainChildNode = childNode;

            foreach (AuthorityControlVo auth in parentAuthorityVo)
            {
                TreeNode childTreeNode = new TreeNode();

                childTreeNode.Text = auth.AuthorityControlCode + ": " + auth.AuthorityControlName;
                childTreeNode.Tag  = auth.AuthorityControlCode;

                List <RoleAuthorityControlVo> roleAuthorityList =
                    roleAuthority.RoleAuthorityControlListVo.Where(t => t.RoleCode == roleCode)
                    .ToList();

                foreach (RoleAuthorityControlVo roleAuth in roleAuthorityList)
                {
                    if (roleAuth.AuthorityControlCode == childTreeNode.Tag.ToString())
                    {
                        childTreeNode.Checked = true;
                    }
                }
                mainChildNode.Nodes.Add(childTreeNode);
                List <AuthorityControlVo> childAuthorityVo = authority.Where(
                    t => t.ParentControlCode == auth.AuthorityControlCode
                    ).ToList();

                if (childAuthorityVo.Count > 0)
                {
                    PopulateChildNode(authority, roleAuthority, auth.AuthorityControlCode, roleCode, childTreeNode);
                }
            }
        }
コード例 #9
0
        /// <summary>
        /// Binds tree view with role
        /// </summary>
        /// <param name="userList"></param>
        private void PopulateTreeView(List <UserVo> userList)
        {
            RoleVo roleOutVo = new RoleVo();

            AuthorityControlVo authorityOutVo = new AuthorityControlVo();

            try
            {
                roleOutVo = (RoleVo)base.InvokeCbm(new GetRoleMasterMntCbm(), roleInVo, false);

                AuthorityControlVo authorityInVo = new AuthorityControlVo();

                authorityOutVo = (AuthorityControlVo)base.InvokeCbm(new GetAuthorityControlMasterMntCbm(), authorityInVo, false);
            }
            catch (Framework.ApplicationException exception)
            {
                popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                Logger.Error(exception.GetMessageData());
                return;
            }

            UserRoleDetails_tv.Nodes.Clear();

            TreeNode[] headerNode = new TreeNode[userList.Count];

            int i = 0;

            foreach (UserVo user in userList)
            {
                TreeNode child = new TreeNode
                {
                    Text = user.UserCode + ": " + user.UserName,
                    Tag  = user.UserCode
                };

                headerNode[i] = child;

                int childNodes = roleOutVo.RoleListVo.Count;

                TreeNode[] rootNodes = new TreeNode[childNodes];

                int node = 0;

                //UserRoleVo userRoleInVo = new UserRoleVo();

                UserRoleVo userRoleOutVo = new UserRoleVo();

                try
                {
                    userRoleOutVo = (UserRoleVo)base.InvokeCbm(new GetUserRoleMasterMntCbm(), new UserRoleVo(), false);
                }
                catch (Framework.ApplicationException exception)
                {
                    popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                    Logger.Error(exception.GetMessageData());
                    return;
                }

                foreach (RoleVo role in roleOutVo.RoleListVo)
                {
                    TreeNode rootChild = new TreeNode
                    {
                        Text = role.RoleCode + ": " + role.RoleName,
                        Tag  = role.RoleCode
                    };

                    List <UserRoleVo> userRoleList = userRoleOutVo.UserRoleListVo.Where(t => t.UserCode == child.Tag.ToString()).ToList();

                    foreach (UserRoleVo userRole in userRoleList)
                    {
                        if (userRole.RoleCode == rootChild.Tag.ToString())
                        {
                            rootChild.Checked = true;
                        }
                    }

                    rootNodes[node] = rootChild;

                    headerNode[i].Nodes.Add(rootNodes[node]);

                    RoleAuthorityControlVo roleAuthorityOutVo = new RoleAuthorityControlVo();

                    try
                    {
                        roleAuthorityOutVo = (RoleAuthorityControlVo)base.InvokeCbm(new GetRoleAuthorityControlMasterMntCbm(), new RoleAuthorityControlVo(), false);
                    }
                    catch (Framework.ApplicationException exception)
                    {
                        popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                        Logger.Error(exception.GetMessageData());
                        return;
                    }

                    List <RoleAuthorityControlVo> roleAuthorityList = roleAuthorityOutVo.RoleAuthorityControlListVo.Where(t => t.RoleCode == rootChild.Tag.ToString()).ToList();

                    int authorityNodes = roleAuthorityList.Count;

                    TreeNode[] authorityRootNodes = new TreeNode[authorityNodes];

                    int subnode = 0;

                    foreach (RoleAuthorityControlVo roleAuth in roleAuthorityList)
                    {
                        AuthorityControlVo authVo = authorityOutVo.AuthorityControlListVo.Where(t => t.AuthorityControlCode == roleAuth.AuthorityControlCode).ToList().First();

                        TreeNode authorityChild = new TreeNode
                        {
                            Text = authVo.AuthorityControlCode + ": " + authVo.AuthorityControlName,
                            Tag  = authVo.AuthorityControlCode
                        };

                        authorityRootNodes[subnode] = authorityChild;

                        rootNodes[node].Nodes.Add(authorityRootNodes[subnode]);

                        subnode += 1;
                    }

                    node += 1;
                }

                UserRoleDetails_tv.Nodes.Add(headerNode[i]);

                i += 1;
            }
        }