所属类别:.NET
文章作者:佚名
特别推荐:免费发布信息 承包关键词~~抢爆了!HOT!
注意类前面的[xmlinclude]那部分using System;using System.Collections ;using System.IO ;using System.Xml.Serialization;using System.Diagnostics ;namespace Bigeagle.Model.Base{/// /// 枚举,表示组织结构节点类型/// public enum ObjectType{Enterprise = 0 ,Outter ,Unit ,Department ,Position ,Duty ,Data}/// /// 组织结构类/// Author:Bigeagle@163.net/// Date:2001/12/26/// History: 2001/12/26 finished/// 2001/12/28,添加流程数组/// ///组织结构类[XmlInclude(typeof(Enterprise)), XmlInclude(typeof(Outter)), XmlInclude(typeof(Data)) , XmlInclude(typeof(Department)), XmlInclude(typeof(Duty)) , XmlInclude(typeof(Position)), XmlInclude(typeof(Unit)) , XmlInclude(typeof(ModelEvent)), XmlInclude(typeof(Flow))]public class Organize{/// /// 名称/// private string m_strName ;/// /// 子节点数组/// private ArrayList m_arrChilds ;/// /// 流程数组/// private ArrayList m_arrFlows ;/// /// 存取名称的属性/// public string Name{get{return this.m_strName ;}set{this.m_strName = value ;}}/// /// 存取子节点的属性/// public ArrayList Childs{get{return this.m_arrChilds ;}set{this.m_arrChilds = value ;}}/// /// 存取流程数组的属性/// public ArrayList Flows{get{return this.m_arrFlows ;}set{this.m_arrFlows = value ;}}/// /// 构造函数/// public Organize(){//// TODO: Add constructor logic here//this.m_strName = "" ;this.m_arrChilds = new ArrayList() ;}//end method/// /// 添加节点/// /// 父节点的id/// 要添加的节点/// 新插入节点的idpublic string AddChild(string a_strFatherID , object a_objChild){OrganizeChild objFather = (OrganizeChild)this.GetChild(a_strFatherID) ;OrganizeChild objChild = (OrganizeChild)a_objChild ;//if(objFather == null)//{//if(objChild.Type != ObjectType.Enterprise && objChild.Type != ObjectType.Outter)//{//throw(new Exception("组织结构下只能插入企业和外部活动者!")) ;//}//}//else if(objFather.Type == ObjectType.Outter && objChild.Type != ObjectType.Data)//{//throw(new Exception("外部活动者下只能插入数据对象!")) ;//}//else if(objFather.Type == ObjectType.Enterprise//&& objChild.Type != ObjectType.Unit objChild.Type != ObjectType.Data)//{//throw(new Exception("企业下只能插入单位对象!")) ;//}////else if(objChild.Type != ObjectType.Data && (int)objChild.Type - (int)objFather.Type > 1)//{//throw(new Exception("要加入的节点类型错误!")) ;//}//计算idstring strID = "" ;if(a_strFatherID == "0"){strID = (this.GetChildCount(a_strFatherID) + 1).ToString() ;}else{strID = a_strFatherID + "." + (this.GetChildCount(a_strFatherID) + 1).ToString() ;}((OrganizeChild)a_objChild).ID = strID ;this.m_arrChilds.Add(a_objChild) ;return strID ;}//end method/// /// 根据id返回一个child/// /// 节点id/// 如果未找到则返回nullpublic object GetChild(string a_strID){//for(int i = 0 ; i < this.m_arrChilds.Count ; i ++)//{//OrganizeChild oc = (OrganizeChild)this.m_arrChilds[i] ;//if(oc.ID == a_strID)//{//return this.m_arrChilds[i] ;//}//}foreach(OrganizeChild o in this.m_arrChilds){if(o.ID.Equals(a_strID)){return o ;}}return null ;}//end method/// /// 取得指定节点的字节点数/// /// 节点id/// public int GetChildCount(string a_strID){int intCount = 0 ;for(int i = 0 ; i < this.m_arrChilds.Count ; i ++){OrganizeChild oc = (OrganizeChild)this.m_arrChilds[i] ;if(oc.ID.Length > a_strID.Length && oc.ID.Substring(0 , a_strID.Length) == a_strID){intCount ++ ;}}//end forreturn intCount ;}//end method/// /// 根据id取得父节点/// /// 节点id/// 如果没有父节点则返回nullpublic object GetParent(string a_strID){string[] str = a_strID.Split('.') ;if(str.Length == 1){return null ;}foreach(OrganizeChild o in this.m_arrChilds){string id = a_strID.Substring(0 , a_strID.Length - str[str.Length - 1].Length -1) ;if(o.ID == id){return o ;}}return null ;}//end method/// /// 根据id取得子节点数组/// /// 节点id/// 是否包含全部子节点/// 子节点数组/// 如果a_bAll为true返回所有子节点,否则只返回下一层的子节点public ArrayList GetChilds(string a_strID , bool a_bAll){ArrayList result = new ArrayList() ;foreach(OrganizeChild oc in this.Childs){if(a_bAll){if(oc.ID.Length > a_strID.Length&& oc.ID.Substring(0 , a_strID.Length) == a_strID){result.Add(oc) ;}}else{if(oc.ID.Length > a_strID.Length&& oc.ID.Substring(0 , a_strID.Length) == a_strID&& oc.ID.Split('.').Length - a_strID.Split('.').Length == 1){result.Add(oc) ;}}}return result ;}//end method/// /// 添加一个新事件/// /// 要添加的事件idpublic void AddEvent(ModelEvent a_objEvent){//取得事件所属的节点OrganizeChild parent = (OrganizeChild)this.GetParent(a_objEvent.BeginModelID) ;#if DEBUGDebug.Assert(parent != null , "事件所属节点不能为空!") ;Debug.Assert(parent == this.GetParent(a_objEvent.EndModelID), "事件开始对象和结束对象的父节点应该相同!") ;#endif//DEBUG//生成idstring strId = parent.ID + "_" ;if(parent.ModelEvents.Count == 0){strId = strId + "1" ;}else{strId = strId + (int.Parse(((ModelEvent)parent.ModelEvents[parent.ModelEvents.Count - 1]).ID.Split('_')[1]) + 1).ToString() ;}a_objEvent.ID = strId ;parent.ModelEvents.Add(a_objEvent) ;}//end methodpublic void AddFlow(Flow a_objFlow){//生成idint intID = 0 ;if(this.m_arrFlows.Count == 0){intID = 1 ;}else{intID = ((Flow)this.m_arrFlows[this.m_arrFlows.Count - 1]).ID + 1 ;}a_objFlow.ID = intID ;this.m_arrFlows.Add(a_objFlow) ;}//end method}//end class}//end class 关闭本页
相关信息· filemanage功能中用到的lib.js
· 系统测试设计的层次
· Windows系统爆三大最新严重漏洞
· 一个有效展示True Type字体的例子
67462
84641
