提供3000多款全球软件/控件产品
针对软件研发的各个阶段提供专业培训与技术咨询
根据客户需求提供定制化的软件开发服务
全球知名设计软件,显著提升设计质量
打造以经营为中心,实现生产过程透明化管理
帮助企业合理产能分配,提高资源利用率
快速打造数字化生产线,实现全流程追溯
生产过程精准追溯,满足企业合规要求
以六西格玛为理论基础,实现产品质量全数字化管理
通过大屏电子看板,实现车间透明化管理
对设备进行全生命周期管理,提高设备综合利用率
实现设备数据的实时采集与监控
利用数字化技术提升油气勘探的效率和成功率
钻井计划优化、实时监控和风险评估
提供业务洞察与决策支持实现数据驱动决策
转帖|其它|编辑:郝浩|2011-05-09 16:47:54.000|阅读 988 次
概述:最近因为接手离职同事的公文审批(没有使用工作流)维护,感觉很麻烦,于是在我开发的工作流平台上重新写了相关的功能,扩展同事的功能,同时可以支持固定流和任意流功能。
# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>
最近因为接手离职同事的公文审批(没有使用工作流)维护,感觉很麻烦,于是在我开发的工作流平台上重新写了相关的功能,扩展同事的功能,同时可以支持固定流和任意流功能。
固定流就是由发起人定义审批的步骤,流程按照既定步骤执行。
任意流就是由发起人发起,选择下一步审批人审批,然后审批再选择下一步审批人。
当然公文审批支持的电子签名的功能也有,但是不作为本篇讨论内容,还有界面美观。
1.服务代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.ComponentModel;
namespace StateMachineService
{
[Serializable]
public class DocFlowEventArgs:ExternalDataEventArgs
{
public DocFlowEventArgs(string userID,Guid uninstand): base(uninstand)
{
this.uninstand = uninstand;
this.userID = userID;
}
private Guid uninstand = Guid.Empty;
public Guid Uninstand
{
get { return this.uninstand; }
set { this.uninstand = value; }
}
private string userID = string.Empty;
public string UserID
{
get { return this.userID; }
set { this.userID = value; }
}
}
[ExternalDataExchange]
public interface IDocFlowService
{
event EventHandler<DocFlowEventArgs> Next;
event EventHandler<DocFlowEventArgs> Jump;
event EventHandler<DocFlowEventArgs> Stop;
void SetFixNextApprover(int NextStpeID, string uninstand);
void SetFixEnableApprover(int CurrentStpeID, string uninstand);
void SetAutoNextApprover();
void SetAutoEnableApprover(string uninstand);
void ChangeStatus();
}
[Serializable]
public class DocFlowService:IDocFlowService
{
IDAL.IWFreeNode iwfreenode;
Guid T;
string UserID;
Dictionary<string, EventHandler<DocFlowEventArgs>> list =
new Dictionary<string, EventHandler<DocFlowEventArgs>>();
public void RaiseEventer(string eventName,Guid uninstand,string userID)
{
if(list[eventName]!=null)
{
try
{
EventHandler<DocFlowEventArgs> eventHandler=list[eventName];
DocFlowEventArgs args= new DocFlowEventArgs(userID ,uninstand);
args.WaitForIdle = true;
eventHandler.Invoke(null, args );
this.T = uninstand;
this.UserID = userID;
}
catch
{
}
}
}
IDocFlowService 成员#region IDocFlowService 成员
public event EventHandler <DocFlowEventArgs> Next
{
add
{
this.list.Add("Next", value);
}
remove
{
this.list.Remove("Next");
}
}
public event EventHandler <DocFlowEventArgs> Jump
{ add
{
this.list.Add("Jump", value);
}
remove
{
this.list.Remove("Jump");
}
}
public event EventHandler <DocFlowEventArgs> Stop
{
add
{
this.list.Add("Stop", value);
}
remove
{
this.list.Remove("Stop");
}
}
public void ChangeStatus()
{
throw new NotImplementedException();
}
#endregion
IDocFlowService 成员#region IDocFlowService 成员
public void SetFixNextApprover(int NextStpeID,string uninstand)
{
iwfreenode = DALFactory.WFreeNode.CreateInstance();
string script = "update WFreeNode set [ExceteState]=1
where Uninstand='"+uninstand+"' and StepID="+NextStpeID;
iwfreenode.Update(script);
//throw new NotImplementedException();
}
#endregion
IDocFlowService 成员#region IDocFlowService 成员
public void SetFixEnableApprover(int CurrentStpeID,string uninstand)
{
iwfreenode = DALFactory.WFreeNode.CreateInstance();
string script = "update WFreeNode set [ExceteState]=
2 where Uninstand='" +uninstand+ "' and userID=
'" + this.UserID + "' and StepID=" + CurrentStpeID;
iwfreenode.Update(script);
//throw new NotImplementedException();
}
#endregion
IDocFlowService 成员#region IDocFlowService 成员
public void SetAutoNextApprover()
{
//throw new NotImplementedException();
}
public void SetAutoEnableApprover(string uninstand)
{
iwfreenode = DALFactory.WFreeNode.CreateInstance();
string script = "update WFreeNode set [ExceteState]=2 where
Uninstand='" +uninstand + "' and userID='" + this.UserID + "'";
iwfreenode.Update(script);
}
#endregion
}
}
现在支持前进,抄送(平台功能)和终止,还不支持会退和跳批。
2.数据库结构
CREATE TABLE [dbo].[DocFlow](
[Uninstand] [uniqueidentifier] NOT NULL,
[UserID] [varchar](50) NOT NULL,
[Date] [datetime] NULL,
[Title] [varchar](400) NULL,
[Remark] [varchar](500) NULL,
[DocLevel] [varchar](50) NULL,
[FlowType] [varchar](10) NULL,
[Depart] [varchar](50) NULL
)
3.流程图
a.
b.
3.
4.
流程代码
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Linq;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
namespace StateMachineLibrary
{
public partial class DocFlow: StateMachineWorkflowActivity
{
public static DependencyProperty DocFlowTypeProperty = DependencyProperty.Register("DocFlowType", typeof(string), typeof(DocFlow));
public string DocFlowType
{
get { return (string)base.GetValue(DocFlow.DocFlowTypeProperty); }
set { base.SetValue(DocFlow.DocFlowTypeProperty, value); }
}
public static DependencyProperty StepIDListProperty =
DependencyProperty.Register("StepIDList", typeof
(System.Collections.Generic.List<int>), typeof(DocFlow));
public System.Collections.Generic.List<int> StepIDList
{
get { return (System.Collections.Generic.List<int>)
base.GetValue(DocFlow.StepIDListProperty); }
set { base.SetValue(DocFlow.StepIDListProperty, value); }
}
public static DependencyProperty UninstandProperty =
DependencyProperty.Register("Uninstand",typeof(string),typeof(DocFlow));
public string Uninstand
{
get { return (string)base.GetValue(DocFlow.UninstandProperty); }
set { base.SetValue(DocFlow.UninstandProperty, value); }
}
public static DependencyProperty CurrentIndexProperty =
DependencyProperty.Register("CurrentIndex", typeof(int), typeof(DocFlow));
public int CurrentIndex
{
get { return (int)base.GetValue(DocFlow.CurrentIndexProperty); }
set { base.SetValue(DocFlow.CurrentIndexProperty, value); }
}
private int MaxIndex = 0;
private int MinIndex = 0;
private void autoResearch(object sender, EventArgs e)
{
if(this.DocFlowType.Equals("fix",StringComparison.OrdinalIgnoreCase))
{
this.FindMinMax();
}
}
private void FindMinMax()
{
this.StepIDList.Sort(new Comparison<int>((x, y) => x.CompareTo(y)));
this.MinIndex = this.StepIDList[0];
this.MaxIndex = this.StepIDList[this.StepIDList.Count-1];
this.CurrentIndex = this.MinIndex;
}
private void FixCurrentRemove(object sender, EventArgs e)
{
if (this.DocFlowType.Equals("fix", StringComparison.OrdinalIgnoreCase))
{
this.StepIDList.Remove(this.CurrentIndex);
}
}
private void CheckDocType(object sender, ConditionalEventArgs e)
{
if (this.DocFlowType.Equals( "fix", StringComparison.OrdinalIgnoreCase))
{
e.Result = true;
}
else
{
e.Result = false;
}
}
private void CurrentIsOve(object sender, ConditionalEventArgs e)
{
if (this.StepIDList.FindAll(p => p == this.CurrentIndex).Count == 0)
{
e.Result = true;
}
else
{
e.Result = false;
}
}
private void CalCurrentStep(object sender, EventArgs e)
{
this.StepIDList.Sort(new Comparison<int>((x, y) => x.CompareTo(y)));
if(this.StepIDList.Count>0)
{
this.CurrentIndex = this.StepIDList[0];
}
}
private void FixIsFinal(object sender, ConditionalEventArgs e)
{
if (this.CurrentIndex == this.MaxIndex && this.StepIDList.FindAll(p =>
p == this.CurrentIndex).Count <= 1)
{
e.Result = true;
}
else
{
e.Result = false;
}
}
private void GetWorkflowID(object sender, EventArgs e)
{
this.Uninstand = this.WorkflowInstanceId.ToString();
}
}
}
主要是StepIDList用于记录固定工作流的步骤序号,DocFlow用于记录工作流类型 CurrentIndex 记录当前步骤号
其它的就是分析最小和最大号,找寻下部号,已经相关的流转控制。还有一些是访问后台数据库的服务。
用户操作界面
审批界面
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@pclwef.cn
文章转载自:博客园面对“数字中国”建设和中国制造2025战略实施的机遇期,中车信息公司紧跟时代的步伐,以“集约化、专业化、标准化、精益化、一体化、平台化”为工作目标,大力推进信息服务、工业软件等核心产品及业务的发展。在慧都3D解决方案的实施下,清软英泰建成了多模型来源的综合轻量化显示平台、实现文件不失真的百倍压缩比、针对模型中的大模型文件,在展示平台上进行流畅展示,提升工作效率,优化了使用体验。
本站的模型资源均免费下载,登录后即可下载。模型仅供学习交流,勿做商业用途。
本站的模型资源均免费下载,登录后即可下载。模型仅供学习交流,勿做商业用途。
本站的模型资源均免费下载,登录后即可下载。模型仅供学习交流,勿做商业用途。
服务电话
重庆/ 023-68661681
华东/ 13452821722
华南/ 18100878085
华北/ 17347785263
客户支持
技术支持咨询服务
服务热线:400-700-1020
邮箱:sales@pclwef.cn
关注我们
地址 : 重庆市九龙坡区火炬大道69号6幢