using System; using System.Collections; using System.Data; using BP.DA; using BP.En; using BP.Sys; using BP.Port; using System.Security.Cryptography; using System.Text; using BP.WF.XML; using BP.WF.Template; namespace BP.WF { /// /// 系统约定字段列表 /// public class WorkSysFieldAttr { /// /// 发送人员字段 /// 用在节点发送时确定下一个节点接受人员, 类似与发送邮件来选择接受人. /// 并且在下一个节点属性的 访问规则中选择【按表单SysSendEmps字段计算】有效。 /// public const string SysSendEmps = "SysSendEmps"; /// /// 抄送人员字段 /// 当前的工作需要抄送时, 就需要在当前节点表单中,增加此字段。 /// 并且在节点属性的抄送规则中选择【按表单SysCCEmps字段计算】有效。 /// 如果有多个操作人员,字段的接受值用逗号分开。比如: zhangsan,lisi,wangwu /// public const string SysCCEmps = "SysCCEmps"; /// /// 流程应完成日期 /// 说明:在开始节点表单中增加此字段,用来标记此流程应当完成的日期. /// 用户在发送后就会把此值记录在WF_GenerWorkFlow 的 SDTOfFlow 中. /// 此字段显示在待办,发起,在途,删除,挂起列表里. /// public const string SysSDTOfFlow = "SysSDTOfFlow"; /// /// 节点应完成时间 /// 说明:在开始节点表单中增加此字段,用来标记此节点的下一个节点应该完成的日期. /// public const string SysSDTOfNode = "SysSDTOfNode"; /// /// PWorkID 调用 /// public const string PWorkID = "PWorkID"; /// /// FromNode /// public const string FromNode = "FromNode"; /// /// 是否需要已读回执 /// public const string SysIsReadReceipts = "SysIsReadReceipts"; #region 与质量考核相关的字段 /// /// 编号 /// public const string EvalEmpNo = "EvalEmpNo"; /// /// 名称 /// public const string EvalEmpName = "EvalEmpName"; /// /// 分值 /// public const string EvalCent = "EvalCent"; /// /// 内容 /// public const string EvalNote = "EvalNote"; #endregion 与质量考核相关的字段 } /// /// 工作属性 /// public class WorkAttr { #region 基本属性 /// /// 工作ID /// public const string OID = "OID"; /// /// 记录人 /// public const string Rec = "Rec"; /// /// 记录人Text /// public const string RecText = "RecText"; /// /// Emps /// public const string Emps = "Emps"; /// /// 流程ID /// public const string FID = "FID"; /// /// MD5 /// public const string MD5 = "MD5"; #endregion } /// /// WorkBase 的摘要说明。 /// 工作 /// abstract public class Work : Entity { /// /// 检查MD5值是否通过 /// /// true/false public bool IsPassCheckMD5() { string md51 = this.GetValStringByKey(WorkAttr.MD5); string md52 = Glo.GenerMD5(this); if (md51 != md52) return false; return true; } #region 基本属性(必须的属性) /// /// 主键 /// public override string PK { get { return "OID"; } } /// /// classID /// public override string ClassID { get { return "ND"+this.HisNode.NodeID; } } /// /// 流程ID /// public virtual Int64 FID { get { if (this.HisNode.IsSubThread == false) return 0; return this.GetValInt64ByKey(WorkAttr.FID); } set { if (this.HisNode.IsSubThread == false) this.SetValByKey(WorkAttr.FID, 0); else this.SetValByKey(WorkAttr.FID, value); } } /// /// workid,如果是空的就返回 0 . /// public virtual Int64 OID { get { return this.GetValInt64ByKey(WorkAttr.OID); } set { this.SetValByKey(WorkAttr.OID, value); } } /// /// 人员emps /// public string Emps { get { return this.GetValStringByKey(WorkAttr.Emps); } set { this.SetValByKey(WorkAttr.Emps, value); } } public int RetrieveFID() { QueryObject qo = new QueryObject(this); qo.AddWhereIn(WorkAttr.OID, "(" + this.FID + "," + this.OID + ")"); int i = qo.DoQuery(); if (i == 0) { if (BP.Difference.SystemConfig.IsDebug == false) { this.CheckPhysicsTable(); throw new Exception("@节点[" + this.EnDesc + "]数据丢失:WorkID=" + this.OID + " FID=" + this.FID + " sql=" + qo.SQL); } } return i; } /// /// 记录人 /// public string Rec { get { string str = this.GetValStringByKey(WorkAttr.Rec); if (str == "") this.SetValByKey(WorkAttr.Rec, BP.Web.WebUser.No); return this.GetValStringByKey(WorkAttr.Rec); } set { this.SetValByKey(WorkAttr.Rec, value); } } public int FrmVer { get { return this.GetParaInt("FrmVer"); } } private Node _HisNode = null; /// /// 工作的节点. /// public Node HisNode { get { if (this._HisNode == null) { this._HisNode = new Node(this.NodeID); } return _HisNode; } set { _HisNode = value; } } /// /// 从表. /// public MapDtls HisMapDtls { get { return this.HisNode.MapData.MapDtls; } } /// /// 附件. /// public FrmAttachments HisFrmAttachments { get { return this.HisNode.MapData.FrmAttachments; } } #endregion #region 构造函数 /// /// 工作 /// protected Work() { } /// /// 工作 /// /// WFOID protected Work(Int64 oid) { this.SetValByKey(EntityOIDAttr.OID, oid); this.Retrieve(); } #endregion #region 重写基类的方法。 /// /// 按照指定的OID Insert. /// public void InsertAsOID(Int64 oid) { this.SetValByKey("OID", oid); this.RunSQL(SqlBuilder.Insert(this)); } /// /// 按照指定的OID 保存 /// /// public void SaveAsOID(Int64 oid) { this.SetValByKey("OID", oid); if (this.IsExits==false) this.InsertAsOID(oid); this.Update(); } /// /// 保存实体信息 /// public new int Save() { if (this.OID <= 10) throw new Exception("@没有给WorkID赋值,不能保存."); if (this.Update() == 0) { this.InsertAsOID(this.OID); return 0; } return 1; } public override void Copy(DataRow dr) { foreach (Attr attr in this.EnMap.Attrs) { if ( attr.Key == WorkAttr.Rec || attr.Key == WorkAttr.FID || attr.Key == WorkAttr.OID || attr.Key == "No" || attr.Key == "Name") continue; try { this.SetValByKey(attr.Key, dr[attr.Key]); } catch { } } } public override void Copy(Entity fromEn) { if (fromEn == null) return; Attrs attrs = fromEn.EnMap.Attrs; foreach (Attr attr in attrs) { if ( attr.Key == WorkAttr.Rec || attr.Key == WorkAttr.FID || attr.Key == WorkAttr.OID || attr.Key == WorkAttr.Emps || attr.Key == "No" || attr.Key == "Name") continue; this.SetValByKey(attr.Key, fromEn.GetValByKey(attr.Key)); } } #endregion #region 公共方法 /// /// 直接的保存 /// public new void DirectSave() { this.beforeUpdateInsertAction(); if (this.DirectUpdate() == 0) this.DirectInsert(); } public string NodeFrmID = ""; protected int _nodeID = 0; public int NodeID { get { if (_nodeID == 0) throw new Exception("您没有给_Node给值。"); return this._nodeID; } set { if (this._nodeID != value) { this._nodeID = value; this._enMap = null; } this._nodeID = value; } } /// /// 已经路过的节点 /// public string HisPassedFrmIDs = ""; #endregion } /// /// 工作 集合 /// abstract public class Works : EntitiesOID { #region 构造方法 /// /// 信息采集基类 /// public Works() { } #endregion } }