init lserp cs 5.0

This commit is contained in:
cyf
2026-07-10 15:25:05 +08:00
commit 90f3fda86a
3799 changed files with 976868 additions and 0 deletions
@@ -0,0 +1,44 @@
using System;
using System.Collections;
using System.Text;
namespace Zhaizj.Framework.Common.Security {
/// <summary>
/// ½ÇÉ«ºÏ²¢¹¤¾ß
/// </summary>
public class RoleMerger {
private IList results = new ArrayList();
private int iCount = 1;
public RoleMerger() {
}
public RoleMerger( IList roles ) {
this.Add( roles );
}
public RoleMerger Add( IList roles ) {
foreach (IRole obj in roles) {
RoleProxy rr = new RoleProxy();
rr.Id = iCount;
rr.Name = obj.Role.Name;
rr.Role = obj.Role;
results.Add( rr );
iCount++;
}
return this;
}
public IList GetResults() {
return results;
}
}
}
@@ -0,0 +1,104 @@
using System;
using System.Collections;
using System.Text;
using Zhaizj.Framework.ORM;
namespace Zhaizj.Framework.Common.Security {
/// <summary>
/// 权限序列化后工具,格式:Zhaizj.Framework.Security.Domain.SiteRole:2:1,2,8,16,17/
/// </summary>
public class SecurityString {
public static char roleSeperator = '/';
public static char itemSeperator = ':';
public static char actionIdSeperator = ',';
public Type RoleType { get; set; }
public String TypeFullName { get; set; }
public int RoleId { get; set; }
public int[] ActionIds { get; set; }
public SecurityString( String typeFullName, int roleId, IList actions ) {
Type roleType = Entity.GetType( typeFullName );
if (roleType == null || !rft.IsInterface( roleType, typeof( IRole ) )) return;
if (roleId < 0) return;
if (actions == null) return;
int[] aids = new int[actions.Count];
for (int i = 0; i < actions.Count; i++) {
aids[i] = ((ISecurityAction)actions[i]).Id;
}
this.RoleType = roleType;
this.TypeFullName = typeFullName;
this.RoleId = roleId;
this.ActionIds = aids;
}
public SecurityString( String strOne ) {
parse( strOne );
}
private void parse( String strOne ) {
if (strUtil.IsNullOrEmpty( strOne )) return;
strOne = strOne.TrimEnd( roleSeperator );
String[] arrItem = strOne.Split( itemSeperator );
if (arrItem.Length != 3) return;
String typeFullName = arrItem[0].Trim();
Type roleType = Entity.GetType( typeFullName );
if (roleType == null || !rft.IsInterface( roleType, typeof( IRole ) )) return;
int roleId = cvt.ToInt( arrItem[1].Trim() );
if (roleId < 0) return;
int[] Ids = cvt.ToIntArray( arrItem[2].Trim().Replace( '_', ',' ) );
foreach (int intOne in Ids) {
if (intOne <= 0) return;
}
this.RoleType = roleType;
this.TypeFullName = typeFullName;
this.RoleId = roleId;
this.ActionIds = Ids;
}
public override String ToString() {
if (strUtil.IsNullOrEmpty( this.TypeFullName )) return "";
if (this.RoleId < 0) return "";
if (this.ActionIds == null) return "";
return String.Format( "{0}:{1}:{2}", this.TypeFullName, this.RoleId, cvt.ToString( ActionIds ).Replace( ',', '_' ) );
}
public String GetKey() {
return GetRoleKey( this.TypeFullName, this.RoleId );
}
public static String GetRoleKey( String typeFullName, int roleId ) {
return String.Format( "{0}_{1}", typeFullName, roleId );
}
public Boolean IsError() {
return (this.RoleType == null);
}
public IList GetActions( IList actionAll ) {
IList results = new ArrayList();
foreach (ISecurityAction action in actionAll) {
foreach (int actionId in ActionIds) {
if (action.Id == actionId) {
results.Add( action );
continue;
}
}
}
return results;
}
}
}