技术开发 频道

WF的监控


class wfInfoData { public static SqlParameter[] Getwf_Info() { SqlParameter[] spwf_Info = SqlHelper.GetCachedParameters("WFInfodata"); if (spwf_Info == null) { spwf_Info = new SqlParameter[] { new SqlParameter("@WID", SqlDbType.Int,4), new SqlParameter("@WorkflowId", SqlDbType.UniqueIdentifier,16), new SqlParameter("@WorkflowName", SqlDbType.NVarChar,50), new SqlParameter("@ItemName", SqlDbType.NVarChar,50), new SqlParameter("@ListTitle", SqlDbType.NVarChar,50), new SqlParameter("@DisplayName", SqlDbType.NVarChar,50), new SqlParameter("@Created", SqlDbType.DateTime), new SqlParameter("@Investigator", SqlDbType.NVarChar,50), new SqlParameter("@InvCreated", SqlDbType.DateTime), new SqlParameter("@Status", SqlDbType.NVarChar,50) }; SqlHelper.CacheParameters("WFInfodata", spwf_Info); } return spwf_Info; } /**//// <summary> /// 增加一条数据 /// </summary> /// <param name="info"></param> public static void Addwf_Info(WFInfo info) { using(SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringProfile)) { SqlParameter[] spwf_Info = wfInfoData.Getwf_Info(); spwf_Info[0].Direction = ParameterDirection.Output; spwf_Info[1].Value = info.WorkflowId; spwf_Info[2].Value = info.WorkflowName; spwf_Info[3].Value = info.ItemName; spwf_Info[4].Value = info.ListTitle; spwf_Info[5].Value = info.DisplayName; spwf_Info[6].Value = info.Created; spwf_Info[7].Value = info.Investigator; spwf_Info[8].Value = info.InvCreated; spwf_Info[9].Value = info.Status; SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "ADDwfInfo", spwf_Info); } } } Modul public class WFInfo { public WFInfo() { } Model#region Model private int _wid; private Guid _workflowid; private string _workflowname; private string _itemname; private string _listtitle; private string _displayname; private DateTime _created; private string _investigator; private DateTime _invcreated; private string _status; /**//// <summary> /// /// </summary> public int WID { set { _wid = value; } get { return _wid; } } /**//// <summary> /// 工作流GUID /// </summary> public Guid WorkflowId { set { _workflowid = value; } get { return _workflowid; } } /**//// <summary> /// 工作流名称 /// </summary> public string WorkflowName { set { _workflowname = value; } get { return _workflowname; } } /**//// <summary> /// 表单名称 /// </summary> public string ItemName { set { _itemname = value; } get { return _itemname; } } /**//// <summary> /// 表单库名称 /// </summary> public string ListTitle { set { _listtitle = value; } get { return _listtitle; } } /**//// <summary> /// 申请者 /// </summary> public string DisplayName { set { _displayname = value; } get { return _displayname; } } /**//// <summary> /// 申请时间 /// </summary> public DateTime Created { set { _created = value; } get { return _created; } } /**//// <summary> /// 审批者 /// </summary> public string Investigator { set { _investigator = value; } get { return _investigator; } } /**//// <summary> /// 审批时间 /// </summary> public DateTime InvCreated { set { _invcreated = value; } get { return _invcreated; } } /**//// <summary> /// 工作流状态 /// </summary> public string Status { set { _status = value; } get { return _status; } } /**//// <summary> /// 增加记录 /// </summary> /// <param name="workflowId"></param> /// <param name="workflowName"></param> /// <param name="itemName"></param> /// <param name="listTitle"></param> /// <param name="displayName"></param> /// <param name="created"></param> /// <param name="investigator"></param> /// <param name="invCreated"></param> /// <param name="status"></param> public WFInfo(Guid workflowId, string workflowName, string itemName, string listTitle, string displayName, DateTime created, string investigator, DateTime invCreated, string status) { this.WorkflowId = workflowId; this.WorkflowName = workflowName; this.ItemName = itemName; this.ListTitle = listTitle; this.DisplayName = displayName; this.Created = created; this.Investigator = investigator; this.InvCreated = invCreated; this.Status = status; } public WFInfo(int wID ,Guid workflowId, string workflowName, string itemName, string listTitle, string displayName, DateTime created, string investigator, DateTime invCreated, string status) { this.WID = wID; this.WorkflowId = workflowId; this.WorkflowName = workflowName; this.ItemName = itemName; this.ListTitle = listTitle; this.DisplayName = displayName; this.Created = created; this.Investigator = investigator; this.InvCreated = invCreated; this.Status = status; } #endregion Model } //获取工作流状态 string statu = GetWorkflowStatu(); //记录工作流的基本信息 wfInfoData.Addwf_Info(new WFInfo(workflowProperties.WorkflowId, workflowProperties.Workflow.ParentAssociation.Name,wfItemName, this.listTitle, wfOriginator.DisplayName, applyDate, "",DateTime.Now, statu)); string GetWorkflowStatu() { //获取工作流状态 SPFieldWorkflowStatus statusField = workflowProperties.List.Fields.GetField(workflowProperties.Workflow.ParentAssociation.InternalName) as SPFieldWorkflowStatus; System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); doc.LoadXml(workflowProperties.Workflow.Xml); System.Xml.XmlNode node = doc.SelectSingleNode("Workflow/@Status1"); string statu = statusField.GetFieldValueAsText(node.InnerText); return statu; }
0
相关文章