public void BuildAccessTree(AccessPermissionTree tree)
 {
     this.Dispatcher.BeginInvoke((Action<AccessPermissionTree>)delegate(AccessPermissionTree result)
     {
         this.AccessTree.ItemsSource = result.CategoryNodes;
     }, tree);
 }
예제 #2
0
 public void UpdateRolePermission(int roleId, int editType, string roleName, AccessPermissionTree accessTree, DataPermissionTree dataTree, Action<bool> EndUpdatePermission)
 {
     this._ServiceProxy.BeginUpdateRolePermission(roleId, editType, roleName, accessTree, dataTree, delegate(IAsyncResult ar)
     {
         bool isSuccess = this._ServiceProxy.EndUpdateRolePermission(ar);
         EndUpdatePermission(isSuccess);
     }, null);
 }
예제 #3
0
        public static void UpdateRolePermission(int roleId,int editType, string roleName, AccessPermissionTree accessTree, DataPermissionTree dataTree)
        {
            string xmlAccessTree = string.Empty;
            string xmlDataTree = string.Empty;
            if (editType == 1)
            {
                StringBuilder accessStr = new StringBuilder();
                accessStr.Append("<AccessTree>");
                foreach (CategoryNode cate in accessTree.CategoryNodes)
                {
                    foreach (ModuleNode module in cate.ModuleNodes)
                    {
                        foreach (OperationNode operation in module.OperationNodes)
                        {
                            accessStr.AppendFormat("<Access Id=\"{0}\"/>", operation.Id);
                        }
                    }
                }
                accessStr.Append("</AccessTree>");
                xmlAccessTree = accessStr.ToString();

                StringBuilder dataStr = new StringBuilder();
                dataStr.Append("<DataTree>");
                foreach (DataPermission data in dataTree.DataPermissions)
                {
                    foreach (ExChangeSystem sys in data.ExChangeSystems)
                    {
                        foreach (Target target in sys.Targets)
                        {
                            dataStr.AppendFormat("<Data Id=\"{0}\"/>", target.TargetId);
                        }
                    }
                }
                dataStr.Append("</DataTree>");
                xmlDataTree = dataStr.ToString();
            }
            using (SqlConnection sqlConnection = DataAccess.GetSqlConnection())
            {
                SqlCommand command = sqlConnection.CreateCommand();
                command.CommandText = "dbo.UpdateRolePermission";
                command.CommandType = System.Data.CommandType.StoredProcedure;
                command.Parameters.Add(new SqlParameter("@roleId", roleId));
                if (editType ==0)
                {
                    command.Parameters.Add(new SqlParameter("@roleName", roleName));
                }
                if (editType == 1)
                {
                    command.Parameters.Add(new SqlParameter("@xmlAccessTree", xmlAccessTree));
                    command.Parameters.Add(new SqlParameter("@xmlDataTree", xmlDataTree));
                }
                command.ExecuteNonQuery();
            }
        }
예제 #4
0
 public bool UpdateRolePermission(int roleId,int editType, string roleName, AccessPermissionTree accessTree, DataPermissionTree dataTree)
 {
     UserDataAccess.UpdateRolePermission(roleId,editType,roleName,accessTree,dataTree);
     return true;
 }
예제 #5
0
 public static AccessPermissionTree GetAccessPermissionTree(int roleId)
 {
     AccessPermissionTree tree = new AccessPermissionTree();
     using (SqlConnection sqlConnection = DataAccess.GetSqlConnection())
     {
         SqlCommand command = sqlConnection.CreateCommand();
         command.CommandText = "dbo.InitAccessPermissionTree";
         command.CommandType = System.Data.CommandType.StoredProcedure;
         command.Parameters.Add(new SqlParameter("@roleId", roleId));
         SqlDataReader reader = command.ExecuteReader();
         while (reader.Read())
         {
             CategoryNode node = new CategoryNode();
             node.Id = (int)reader.GetValue(0);
             node.CategoryDescription = reader.GetValue(1).ToString();
             tree.CategoryNodes.Add(node);
         }
         reader.NextResult();
         while (reader.Read())
         {
             ModuleNode node = new ModuleNode();
             node.Id = (int)reader.GetValue(0);
             node.ModuleDescription = reader.GetValue(2).ToString();
             tree.CategoryNodes.Find(c => c.Id == (int)reader.GetValue(1)).ModuleNodes.Add(node);
         }
         reader.NextResult();
         while (reader.Read())
         {
             OperationNode node = new OperationNode();
             node.Id = (Guid)reader.GetValue(2);
             node.OperationDescription = reader.GetValue(3).ToString();
             tree.CategoryNodes.Find(c => c.Id == (int)reader.GetValue(0)).ModuleNodes.Find(m => m.Id == (int)reader.GetValue(1)).OperationNodes.Add(node);
         }
     }
     return tree;
 }