I'm just beginning to work on a new project using the latest release of Xafari Framework. I have a question about how to best implement numerators in one of by hierarchical business objects. The following is the code as it currently exists. I would like to add a property that adds a numerator based on the position of the row in the list view. I would like for this to work like the Hierarchy Full Name property in this code, which automatically changes during a drag and drop of the list view's rows. Instead of using the Process name, I want the new property's column to display a value based on it's position in the hierarchy like the following example. 001 001.001 001.001.001 001.001.002 001.001.003 001.002 001.002.001 001.002.002 001.002.003 using DevExpress.ExpressApp; using DevExpress.ExpressApp.DC; using DevExpress.ExpressApp.Model; using DevExpress.ExpressApp.Utils; using DevExpress.ExpressApp.Xpo; using DevExpress.Persistent.Base; using DevExpress.Persistent.Base.General; using DevExpress.Persistent.Validation; using DevExpress.Xpo; using System; using System.Collections; using System.Drawing; using System.Linq; using Xafari; using Xafari.Base; using Xafari.BC; using Xafari.BC.HierarchicalData; using Xafari.BC.Numerators; namespace XAF9.Module.BusinessObjects.XAF9 { [DefaultClassOptions]
public partial class BusinessProcess : XPObject, IHierarchyNode, ITreeNodeImageProvider, INameSupport, IIndexNumberSupport { public BusinessProcess(Session session) : base(session) { } public override void AfterConstruction() { base.AfterConstruction(); } public int IndexNumber { get { return GetPropertyValue("IndexNumber"); } set { SetPropertyValue("IndexNumber", value); } } private string _name; [ImmediatePostData]
[HierarchyNodeNameProperty()]
public String Name { get { return _name; } set { SetPropertyValue("Name", ref _name, value); } } #region BusinessProcess private BusinessProcess _process; [Association("Process - SubProcess")]
[ParentProperty("Hierarchy")]
public BusinessProcess ParentProcess { get { return _process; } set { SetPropertyValue("ParentProcess", ref _process, value); } } [Association("Process - SubProcess")]
[ChildrenProperty("Hierarchy", DeletingMode = DeletingMode.Cascade)]
public XPCollection SubProcess { get { return GetCollection("SubProcess"); } } private string _hierarchyFullName; [FieldSize(1000)]
[ModelDefault("RowCount", "0")]
[ModelDefault("AllowEdit", "false")]
[HierarchyFullNameProperty("Hierarchy")]
public string HierarchyFullName { get { return _hierarchyFullName; } set { SetPropertyValue("HierarchyFullName", ref _hierarchyFullName, value); } } #endregion [RuleFromBoolProperty("IsValidProcess", DefaultContexts.Save, "Cannot select yourself as parent.")]
[NonPersistent]
[MemberDesignTimeVisibility(false)]
public bool IsValidProcess { get { return this.ParentProcess != this; } } protected override void OnDeleting() { base.OnDeleting(); var objectSpace = XPObjectSpace.FindObjectSpaceByObject(this); if (objectSpace != null) this.GetType().Xafari().BC().HierarchyNodeTypeInfo.DeleteObject(objectSpace, this); } protected override void OnChanged(string propertyName, object oldValue, object newValue) { base.OnChanged(propertyName, oldValue, newValue); if (propertyName == "ParentProcess" || propertyName == "Name") UpdateFullNameValue(); } public void UpdateFullNameValue(string separator = " : ") { var typeInfo = XafTypesInfo.Instance.FindTypeInfo(this.GetType()); if (typeInfo == null) return; foreach (var hierarchyName in typeInfo.Type.Xafari().BC().HierarchyNodeTypeInfo.Hierarchies.Select(a => a.HierarchyName)) this.GetType().Xafari().BC().HierarchyInfo(hierarchyName).UpdateFullName(this); } Image ITreeNodeImageProvider.GetImage(out string imageName) { imageName = "BO_User"; return ImageLoader.Instance.GetImageInfo(imageName).Image; } private bool CheckCircularReference(string hierarchyName = HierarchyManager.DefaultHierarchyName) { return this.GetType().Xafari().BC().HierarchyInfo(hierarchyName).CheckCircularReference(this); } #region Implementation of IHierarchyNode public string GetHierarchyNodeName(string hierarchyName = null) { return this.GetType().Xafari().BC().HierarchyInfo(hierarchyName).GetNodeName(this); } public string GetHierarchyNodeFullName(string hierarchyName = null) { return this.GetType().Xafari().BC().HierarchyInfo(hierarchyName).GetNodeFullName(this); } public void SetHierarchyNodeFullName(string value, string hierarchyName = null) { this.GetType().Xafari().BC().HierarchyInfo(hierarchyName).SetNodeFullName(this, value); } public string GetHierarchyNodeFullPath(string hierarchyName = null) { throw new NotImplementedException(); } public void SetHierarchyNodeFullPath(string value, string hierarchyName = null) { throw new NotImplementedException(); } public IHierarchyNode GetHierarchyParent(string hierarchyName = null) { return this.GetType().Xafari().BC().HierarchyInfo(hierarchyName).GetParent(this); } public void SetHierarchyParent(IHierarchyNode parent, string hierarchyName = null) { this.GetType().Xafari().BC().HierarchyInfo(hierarchyName).SetParent(this, parent); } public IList GetHierarchyChildren(string hierarchyName = null) { return this.GetType().Xafari().BC().HierarchyInfo(hierarchyName).GetChildren(this); } #endregion } } |