工作流(js版本)
2008-12-04 16:29 key_sky 阅读(3686) 评论(0) 编辑 收藏 举报流程设计器部分源码下载地址:https://files.cnblogs.com/wendy_soft2008/WorkFlow(js).rar
这个js版本的流程设计器主要是将设计完毕的状态存入xml文件当中。而步骤,流向动作等存入数据库中,参与流程设计完毕后整个流程运行后的记录。比如现在运行到核查(check)这个步骤,首先是从check的上一步流入,然后数据库里记录时间,拥有check这个步骤权限的用户id,完成该check步骤后,从数据库里列出下一流向的id,然后选择转交给谁。这样处理的好处是不用考虑上一步,下一步,check是否通过等等。简单贴个数据库表设计:
在设计流程图当中,如果使用js来保存xml格式的流程图,页面通常会出现js不能创建对象等错误,主要是没有将设计流程图的站点设为可信任站点,不能下载未签名的activex控件。于是我想到在后台进行操作,来修改xml文件,并同时将数据库需要的属性存入数据库。
Code
protected void Button1_Click(object sender, EventArgs e)
{
string strsummary = Hidden1.Value.Trim();
string strtitle = Request.QueryString["id"];
string strname = Hidden2.Value.Trim();
string path = Server.MapPath("flows") + @"\" + strtitle.Trim() + ".xml";
FileInfo fi = new FileInfo(path);
if (!fi.Exists)
{
using (StreamWriter sw = fi.CreateText())
{
sw.WriteLine(@"<?xml version='1.0' encoding='UTF-8'?>");
sw.WriteLine("" + strsummary.Trim() + "");
}
}
else
{
StreamWriter fw = new StreamWriter(path);
fw.WriteLine(@"<?xml version='1.0' encoding='UTF-8'?>");
fw.WriteLine("" + strsummary.Trim() + "");
fw.Close();
}
string path2 = Server.MapPath("langs/main_zh.xml");
FileInfo fi2 = new FileInfo(path2);
if (fi2.Exists)
{
StreamWriter sw2 = new StreamWriter(path2);
sw2.WriteLine(@"<?xml version='1.0' encoding='utf-8'?><config><Properties>
<item id='treeText' property='innerHTML' text='流程导航视图' />
<item id='btnNewFlow' property='title' text='创建新流程' />
<item id='btnEditFlow' property='title' text='修改流程' /><item id='btnSaveFlow'
property='title' text='导出流程' />
</Properties><Selects><select id='flowList'>");
string DirPath = Server.MapPath("flows");
DirectoryInfo di = new DirectoryInfo(DirPath);
FileInfo[] dis = di.GetFiles();
if (dis.Length > 1)
{
for (int i = 0; i < dis.Length; i++)
{
if (dis[i].Name.ToString().Substring(dis[i].Name.LastIndexOf(".") + 1) == "xml")
{
StreamReader SR = new StreamReader(DirPath + "/" + dis[i].Name);
string s = SR.ReadToEnd();
string flowId = string.Empty;
string flowText = string.Empty;
if (s.Contains("flowId"))
{
s = s.Replace("flowId", "$");
flowId = s.Split(new char[] { '$' }, 2, StringSplitOptions.RemoveEmptyEntries)
.GetValue(1).ToString().Trim();
flowId = flowId.Split(new char[] { '"' }, 10, StringSplitOptions.RemoveEmptyEn
tries).GetValue(1).ToString().Trim();
}
if (s.Contains("flowText"))
{
s = s.Replace("flowText", "%");
flowText = s.Split(new char[] { '%' }, 2, StringSplitOptions.RemoveEmptyEntries)
.GetValue(1).ToString().Trim();
flowText = flowText.Split(new char[] { '"' }, 10, StringSplitOptions.RemoveEmpty
Entries).GetValue(1).ToString().Trim();
}
sw2.WriteLine(@"<option value='" + flowId + ".xml' text='" + flowText + "' />");
}
}
}
sw2.WriteLine(@"</select></Selects></config>");
sw2.Close();
}
Response.Write("<script language='javascript'>window.close();</script>");
}