/// <summary> /// 使用指定的<see cref="SCSimpleObject"/>和引用对象ID初始化<see cref="SCWrappedSchemaOwnership"/>。 /// </summary> /// <param name="schemaObject"></param> /// <param name="refId"></param> public SCWrappedSchemaOwnership(SCSimpleObject schemaObject, string refId) { if (schemaObject == null) throw new ArgumentNullException("org"); this.schemaObject = schemaObject; this.refId = refId; }
protected void AddExistMembers(object sender, EventArgs e) { try { Util.EnsureOperationSafe(); var errorAdapter = new ListErrorAdapter(this.notice.Errors); SCOrganization parent = (SCOrganization)DbUtil.GetEffectiveObject(this.ParentOrganization); this.ParentOrganization = parent.ToSimpleObject(); var users = DbUtil.LoadAndCheckObjects("人员", errorAdapter, this.GetPostedKeys()); foreach (SCUser user in users) { try { SCObjectOperations.InstanceWithPermissions.AddUserToOrganization(user, parent); } catch (Exception ex) { this.notice.AddErrorInfo(string.Format("无法添加人员 {0} :{1}", user.DisplayName, ex.Message)); WebUtility.ShowClientError(ex); } } this.InnerRefreshList(); } catch (Exception ex) { WebUtility.ShowClientError(ex); this.notice.AddErrorInfo(ex); } }
protected void Page_Load(object sender, EventArgs e) { string appID = GetAppIDFromRequestOrRedirect(); this.ctlUpload.Tag = appID; Util.InitSecurityContext(this.notice); this.Page.Response.CacheControl = "no-cache"; if (Page.IsPostBack == false) { this.AppObject = SchemaObjectAdapter.Instance.Load(appID).ToSimpleObject(); if (this.AppObject == null && this.AppObject.Status != SchemaObjectStatus.Normal) { throw new ObjectNotFoundException("指定的应用不存在或已删除"); } this.DeluxeSearch.UserCustomSearchConditions = DbUtil.LoadSearchCondition(ThisPageSearchResourceKey, "Default"); this.CurrentAdvancedSearchCondition = new PageAdvancedSearchCondition(); this.gridMain.PageSize = ProfileUtil.PageSize; } this.binding1.Data = this.AppObject; this.searchBinding.Data = this.CurrentAdvancedSearchCondition; }
private static SCSimpleObject MapDataRowToSimpleObject(DataRow row) { SCSimpleObject data = new SCSimpleObject(); ORMapping.DataRowToObject(row, data); if (data.DisplayName.IsNullOrEmpty()) { data.DisplayName = data.Name; } return(data); }
/// <summary> /// 根据<see cref="SCSimpleObject"/>获取有效的对象 /// </summary> /// <param name="obj"></param> /// <param name="message">对象不存在时异常消息的字符串,为 <see langword="null"/>时使用自动的字符串</param> /// <returns>不会是空</returns> /// <exception cref="ArgumentNullException">obj参数为<see langword="null"/></exception> /// <exception cref="ObjectNotFoundException">对象不存在或已被删除</exception> internal static SCBase GetEffectiveObject(SCSimpleObject obj, string message) { if (obj == null) { throw new ArgumentNullException("obj"); } SCBase result = (SCBase)PC.Adapters.SchemaObjectAdapter.Instance.Load(obj.ID); if (result == null || result.SchemaType != obj.SchemaType || result.Status != SchemaObjectStatus.Normal) { throw new ObjectNotFoundException(message ?? string.Format("对象 {0}({1}) 已经删除或不存在", obj.DisplayName, obj.ID)); } return(result); }
protected void Page_Load(object sender, EventArgs e) { string id = Request.QueryString["role"]; Util.InitSecurityContext(this.notice); this.Page.Response.CacheControl = "no-cache"; if (Page.IsPostBack == false) { this.RoleObject = DbUtil.GetEffectiveObject<SCRole>(id).ToSimpleObject(); this.gridMain.PageSize = ProfileUtil.PageSize; } this.binding1.Data = this.RoleObject; }
protected void Page_Load(object sender, EventArgs e) { string id = Request.QueryString["role"]; Util.InitSecurityContext(this.notice); this.Page.Response.CacheControl = "no-cache"; if (Page.IsPostBack == false) { this.RoleObject = DbUtil.GetEffectiveObject <SCRole>(id).ToSimpleObject(); this.gridMain.PageSize = ProfileUtil.PageSize; } this.binding1.Data = this.RoleObject; }
/// <summary> /// 提供 /// </summary> /// <param name="schemaObj">一个<see cref="MCS.Library.SOA.DataObjects.SCSimpleObject"/>,或一个<see cref="System.Data.DataRowView"/></param> /// <returns></returns> public static string CssSpritesFor(object schemaObj, IconSizeType size) { SCSimpleObject obj = schemaObj as SCSimpleObject; System.Data.DataRowView view = schemaObj as System.Data.DataRowView; string css = string.Empty; string schemaType = null; int status = 0; if (obj != null) { schemaType = obj.SchemaType; status = obj.Status == SchemaObjectStatus.Normal ? 0 : 1; } else if (view != null) { schemaType = (string)view["SchemaType"]; status = 0; } if (schemaType != null) { switch (size) { case IconSizeType.Size16: css = "pc-icon16"; break; case IconSizeType.Size32: css = "pc-icon32"; break; default: break; } if (status != 0) { css += " pc-status-deleted"; } css += " " + schemaType; } return(css); }
public void LoadSimpleObjectTest() { SCOrganization root = SCOrganization.GetRoot(); SCOrganization newOrg = SCObjectGenerator.PrepareOrganizationObject(); SCObjectOperations.Instance.AddOrganization(newOrg, root); root.ClearRelativeData(); SCSimpleObjectCollection simpleChildren = root.CurrentChildren.ToSimpleObjects(); SCSimpleObject simpleObj = simpleChildren.Find(obj => obj.ID == newOrg.ID); Console.WriteLine(simpleObj.DisplayName); Assert.IsNotNull(simpleObj); Assert.AreEqual(simpleObj.Name, simpleObj.DisplayName); }
/// <summary> /// 获取组织和父组织ID /// </summary> /// <param name="timePoint">时间点 或 <see cref="DateTime.MinValue"/>表示取当前时间</param> /// <param name="orgIds">组织的ID</param> /// <returns></returns> public IEnumerable <SCWrappedSchemaOwnership> GetDirectParents(DateTime timePoint, params string[] orgIds) { string sql = @"SELECT O.*,R.ParentID AS QCHID FROM SC.SchemaOrganizationSnapshot O INNER JOIN SC.SchemaRelationObjectsSnapshot R ON O.ID = R.ObjectID WHERE "; InSqlClauseBuilder inBuilder = new InSqlClauseBuilder("R.ObjectID"); inBuilder.AppendItem(orgIds); WhereSqlClauseBuilder whereBuilder = new WhereSqlClauseBuilder(); var timeCondition = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder(timePoint, "O."); var timeCondition2 = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder(timePoint, "R."); whereBuilder.AppendItem("O.Status", (int)SchemaObjectStatus.Normal); whereBuilder.AppendItem("R.Status", (int)SchemaObjectStatus.Normal); whereBuilder.AppendItem("R.ParentSchemaType", "Organizations"); ConnectiveSqlClauseCollection connectiveBuilder = new ConnectiveSqlClauseCollection(inBuilder, whereBuilder, timeCondition, timeCondition2); sql += connectiveBuilder.ToSqlString(TSqlBuilder.Instance) + " ORDER BY R.ParentID ASC"; var ds = DbHelper.RunSqlReturnDS(sql, this.GetConnectionName()); SCSimpleObject lastObj = null; foreach (System.Data.DataRow row in ds.Tables[0].Rows) { SCSimpleObject obj; if (lastObj != null && lastObj.ID == (string)row["ID"]) { obj = lastObj; } else { obj = new SCSimpleObject(); MCS.Library.Data.Mapping.ORMapping.DataRowToObject(row, obj); lastObj = obj; } yield return(new SCWrappedSchemaOwnership(obj, (string)row["QCHID"])); } }
private bool InitState() { string ouID = WebUtility.GetRequestQueryString("ou", string.Empty); bool result = true; try { SchemaObjectBase parent = DbUtil.GetEffectiveObject(ouID, null); this.ParentOrganization = parent.ToSimpleObject(); this.hfOuParentId.Value = parent.ID == SCOrganization.RootOrganizationID ? string.Empty : DbUtil.GetParentOURelation(parent.ID).ParentID; } catch (ObjectNotFoundException) { result = false; } return(result); }
protected void Page_Load(object sender, EventArgs e) { string userId = Request.QueryString["id"]; Util.InitSecurityContext(this.notice); this.Page.Response.CacheControl = "no-cache"; if (Page.IsPostBack == false) { this.UserObject = DbUtil.GetEffectiveObject <SCUser>(userId).ToSimpleObject(); this.DeluxeSearch.UserCustomSearchConditions = DbUtil.LoadSearchCondition(ThisPageSearchResourceKey, "Default"); this.CurrentAdvancedSearchCondition = new PageAdvancedSearchCondition(); this.gridMain.PageSize = ProfileUtil.PageSize; } this.binding1.Data = this.UserObject; this.searchBinding.Data = this.CurrentAdvancedSearchCondition; }
protected void Page_Load(object sender, EventArgs e) { string userId = Request.QueryString["id"]; Util.InitSecurityContext(this.notice); this.Page.Response.CacheControl = "no-cache"; if (Page.IsPostBack == false) { this.UserObject = DbUtil.GetEffectiveObject<SCUser>(userId).ToSimpleObject(); this.DeluxeSearch.UserCustomSearchConditions = DbUtil.LoadSearchCondition(ThisPageSearchResourceKey, "Default"); this.CurrentAdvancedSearchCondition = new PageAdvancedSearchCondition(); this.gridMain.PageSize = ProfileUtil.PageSize; } this.binding1.Data = this.UserObject; this.searchBinding.Data = this.CurrentAdvancedSearchCondition; }
protected void Page_Load(object sender, EventArgs e) { string appId = Request.QueryString["app"]; Util.InitSecurityContext(this.notice); this.Page.Response.CacheControl = "no-cache"; if (Page.IsPostBack == false) { this.AppObject = SchemaObjectAdapter.Instance.Load(appId).ToSimpleObject(); this.DeluxeSearch.UserCustomSearchConditions = DbUtil.LoadSearchCondition(ThisPageSearchResourceKey, "Default"); this.CurrentAdvancedSearchCondition = new PageAdvancedSearchCondition(); this.gridMain.PageSize = ProfileUtil.PageSize; } this.binding1.Data = this.AppObject; this.searchBinding.Data = this.CurrentAdvancedSearchCondition; this.ctlUpload.Tag = appId; }
private static void PrepareTreeNodeRecursively(SCSimpleObject parentOrg, DeluxeTreeNode parentTreeNode, Dictionary <string, SCSimpleObject> parentsList, DateTime timePoint, string selectedNodeHint) { SCObjectAndRelationCollection relations = SCSnapshotAdapter.Instance.QueryObjectAndRelationByParentIDs(PC.SchemaInfo.FilterByCategory("Organizations").ToSchemaNames(), new string[] { parentOrg.ID }, false, true, false, timePoint); BindObjectsToTreeNodes(relations, parentTreeNode.Nodes); foreach (DeluxeTreeNode childNode in parentTreeNode.Nodes) { SCSimpleObject obj = null; if (childNode.Value == selectedNodeHint) { childNode.Checked = childNode.Selected = true; } if (parentsList.TryGetValue(childNode.Value, out obj)) { childNode.ChildNodesLoadingType = ChildNodesLoadingTypeDefine.Normal; childNode.Expanded = true; PrepareTreeNodeRecursively(obj, childNode, parentsList, timePoint, selectedNodeHint); } } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); string unitID = Request.QueryString["unitId"]; if (string.IsNullOrEmpty(unitID)) { throw new HttpException("没有提供unitId查询参数"); } if (Page.IsPostBack == false) { this.DeluxeSearch.UserCustomSearchConditions = DbUtil.LoadSearchCondition(ThisPageSearchResourceKey, "Default"); this.CurrentAdvancedSearchCondition = new PageAdvancedSearchCondition(); var unit = DbUtil.GetEffectiveObject <AU.AdminUnit>(unitID); this.AdminUnitObject = unit.ToSimpleObject(); var schema = unit.GetUnitSchema(); this.AUSchemaObject = schema.ToSimpleObject(); var scope = unit.GetNormalScopes().GetScope(this.Request.QueryString["schemaType"]); if (scope == null) { throw new HttpException("schemaType参数指定的管理范围不存在或已删除"); } this.CurrentScope = scope.ToSimpleObject(); this.Scopes = schema.Scopes.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); } this.searchBinding.Data = this.CurrentAdvancedSearchCondition; this.calcProgress.Tag = this.CurrentScope.ID; this.calcProgressAll.Tag = this.Request.QueryString["schemaType"]; }
private static SCSimpleObject MapDataRowToSimpleObject(DataRow row) { SCSimpleObject data = new SCSimpleObject(); ORMapping.DataRowToObject(row, data); if (data.DisplayName.IsNullOrEmpty()) data.DisplayName = data.Name; return data; }
private bool InitState() { string ouID = WebUtility.GetRequestQueryString("ou", string.Empty); bool result = true; try { SchemaObjectBase parent = DbUtil.GetEffectiveObject(ouID, null); this.ParentOrganization = parent.ToSimpleObject(); this.hfOuParentId.Value = parent.ID == SCOrganization.RootOrganizationID ? string.Empty : DbUtil.GetParentOURelation(parent.ID).ParentID; } catch (ObjectNotFoundException) { result = false; } return result; }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); string unitID = Request.QueryString["unitId"]; if (string.IsNullOrEmpty(unitID)) throw new HttpException("没有提供unitId查询参数"); if (Page.IsPostBack == false) { this.DeluxeSearch.UserCustomSearchConditions = DbUtil.LoadSearchCondition(ThisPageSearchResourceKey, "Default"); this.CurrentAdvancedSearchCondition = new PageAdvancedSearchCondition(); var unit = DbUtil.GetEffectiveObject<AU.AdminUnit>(unitID); this.AdminUnitObject = unit.ToSimpleObject(); var schema = unit.GetUnitSchema(); this.AUSchemaObject = schema.ToSimpleObject(); var scope = unit.GetNormalScopes().GetScope(this.Request.QueryString["schemaType"]); if (scope == null) throw new HttpException("schemaType参数指定的管理范围不存在或已删除"); this.CurrentScope = scope.ToSimpleObject(); this.Scopes = schema.Scopes.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); } this.searchBinding.Data = this.CurrentAdvancedSearchCondition; this.calcProgress.Tag = this.CurrentScope.ID; this.calcProgressAll.Tag = this.Request.QueryString["schemaType"]; }
/// <summary> /// 获取组织和父组织ID /// </summary> /// <param name="timePoint">时间点 或 <see cref="DateTime.MinValue"/>表示取当前时间</param> /// <param name="orgIds">组织的ID</param> /// <returns></returns> public IEnumerable<SCWrappedSchemaOwnership> GetDirectParents(DateTime timePoint, params string[] orgIds) { string sql = @"SELECT O.*,R.ParentID AS QCHID FROM SC.SchemaOrganizationSnapshot O INNER JOIN SC.SchemaRelationObjectsSnapshot R ON O.ID = R.ObjectID WHERE "; InSqlClauseBuilder inBuilder = new InSqlClauseBuilder("R.ObjectID"); inBuilder.AppendItem(orgIds); WhereSqlClauseBuilder whereBuilder = new WhereSqlClauseBuilder(); var timeCondition = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder(timePoint, "O."); var timeCondition2 = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder(timePoint, "R."); whereBuilder.AppendItem("O.Status", (int)SchemaObjectStatus.Normal); whereBuilder.AppendItem("R.Status", (int)SchemaObjectStatus.Normal); whereBuilder.AppendItem("R.ParentSchemaType", "Organizations"); ConnectiveSqlClauseCollection connectiveBuilder = new ConnectiveSqlClauseCollection(inBuilder, whereBuilder, timeCondition, timeCondition2); sql += connectiveBuilder.ToSqlString(TSqlBuilder.Instance) + " ORDER BY R.ParentID ASC"; var ds = DbHelper.RunSqlReturnDS(sql, this.GetConnectionName()); SCSimpleObject lastObj = null; foreach (System.Data.DataRow row in ds.Tables[0].Rows) { SCSimpleObject obj; if (lastObj != null && lastObj.ID == (string)row["ID"]) { obj = lastObj; } else { obj = new SCSimpleObject(); MCS.Library.Data.Mapping.ORMapping.DataRowToObject(row, obj); lastObj = obj; } yield return new SCWrappedSchemaOwnership(obj, (string)row["QCHID"]); } }
private static void PrepareTreeNodeRecursively(SCSimpleObject parentOrg, DeluxeTreeNode parentTreeNode, Dictionary<string, SCSimpleObject> parentsList, DateTime timePoint, string selectedNodeHint) { SCObjectAndRelationCollection relations = SCSnapshotAdapter.Instance.QueryObjectAndRelationByParentIDs(PC.SchemaInfo.FilterByCategory("Organizations").ToSchemaNames(), new string[] { parentOrg.ID }, false, true, false, timePoint); BindObjectsToTreeNodes(relations, parentTreeNode.Nodes); foreach (DeluxeTreeNode childNode in parentTreeNode.Nodes) { SCSimpleObject obj = null; if (childNode.Value == selectedNodeHint) childNode.Checked = childNode.Selected = true; if (parentsList.TryGetValue(childNode.Value, out obj)) { childNode.ChildNodesLoadingType = ChildNodesLoadingTypeDefine.Normal; childNode.Expanded = true; PrepareTreeNodeRecursively(obj, childNode, parentsList, timePoint, selectedNodeHint); } } }
internal static SCBase GetEffectiveObject(SCSimpleObject obj) { return(DbUtil.GetEffectiveObject(obj, null)); }