internal static AURole FindMatchRole(IEnumerable <AURole> auRoles, AUSchemaRole schemaRole) { AURole result = null; foreach (var item in auRoles) { if (item.SchemaRoleID == schemaRole.ID) { result = item; break; } } return(result); }
protected void postControl_DoPostedData(object sender, MCS.Web.WebControls.PostProgressDoPostedDataEventArgs e) { string unitID = e.ClientExtraPostedData; var unit = DbUtil.GetEffectiveObject <AU.AdminUnit>(unitID); var status = new UploadProgressStatus(); StringBuilder output = new StringBuilder(); try { status.MinStep = 1; status.MaxStep = e.Steps.Count + 1; status.CurrentStep = 1; AU.AUSchemaRole currentRole = null; foreach (Dictionary <string, object> item in e.Steps) { currentRole = DoAction(unit, status, output, currentRole, item); status.Response(); status.CurrentStep++; } } catch (Exception ex) { status.StatusText = ex.Message; output.AppendLine(ex.ToString()); status.Response(); } finally { output.AppendLine("结束"); e.Result.CloseWindow = false; e.Result.ProcessLog = output.ToString(); } }
private static AU.AUSchemaRole DoAction(AU.AdminUnit unit, UploadProgressStatus status, StringBuilder output, AU.AUSchemaRole currentRole, Dictionary <string, object> item) { string roleID, schemaRoleID, userID; int type; try { roleID = (string)item["RoleID"]; schemaRoleID = (string)item["SchemaRoleID"]; userID = (string)item["UserID"]; type = (int)item["Type"]; if (currentRole == null || currentRole.ID != roleID) { currentRole = DbUtil.GetEffectiveObject <AU.AUSchemaRole>(schemaRoleID); } status.StatusText = string.Format("正在向角色{0}{1}用户{2}", roleID, type == 0 ? "添加" : "删除", userID); output.AppendLine(status.StatusText); if (type == 0) { AU.Operations.Facade.InstanceWithPermissions.AddUserToRole(new PC.SCUser() { ID = userID }, unit, currentRole); } else { AU.Operations.Facade.InstanceWithPermissions.RemoveUserFromRole(new PC.SCUser() { ID = userID, CodeName = "abc", Name = "abc" }, unit, currentRole); } } catch (Exception ex) { status.StatusText = ex.Message; output.AppendLine(ex.ToString()); } return(currentRole); }
internal static AURole FindMatchRole(SchemaObjectCollection auRoles, AUSchemaRole schemaRole) { return((AURole)auRoles.Find(m => ((AURole)m).SchemaRoleID == schemaRole.ID)); }