You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

172 lines
7.1 KiB
C#

10 months ago
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using DSWeb.Models;
using DSWeb.EntityDA;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
namespace DSWeb.WorkFlow
{
public partial class StepEdit : System.Web.UI.Page
{
private string strWorkFlowID;//工作流GID
private string strHandle;
private string strUserID;
private string strShowName;
protected void Page_Load(object sender, EventArgs e)
{
if (Session["USERID"] != null)
{
strUserID = Session["USERID"].ToString();
}
if (Session["SHOWNAME"] != null)
{
strShowName = Session["SHOWNAME"].ToString();
}
if (Request.QueryString["handle"] != null)
{
strHandle = Request.QueryString["handle"].ToString().Trim().ToLower();
}
if (Request.QueryString["flowid"] != null)
{
strWorkFlowID = Request.QueryString["flowid"].ToString().Trim();
this.h_workflowid.Value = strWorkFlowID;
}
if (h_post.Value.Trim() != "")
{
if (h_post.Value.Trim().Equals("1"))
{
if (h_cache.Value.Trim() != "")
{
saveWorkFlowStep(h_cache.Value.Trim());
}
}
}
}
private void saveWorkFlowStep(string tempStepCache)
{
if (tempStepCache.IndexOf("[") >= 0 && tempStepCache.IndexOf("]") > 0)
{
string strStepList = tempStepCache.Substring(tempStepCache.IndexOf("[") + 1, tempStepCache.IndexOf("]") - tempStepCache.IndexOf("[") - 1);
IList<WorkFlowStepEntity> workFlowStepEntities = new List<WorkFlowStepEntity>();
string[] strFees = strStepList.Split(new string[] { "},{" }, System.StringSplitOptions.RemoveEmptyEntries);
if (strFees.Length > 0)
{
for (int i = 0; i < strFees.Length; i++)
{
strFees[i] = strFees[i].ToString().Replace("{", "");
strFees[i] = strFees[i].ToString().Replace("}", "");
string[] strCell = strFees[i].Split(new char[] { ',' });
if (strCell.Length > 0)
{
WorkFlowStepEntity workFlowStepEntity = new WorkFlowStepEntity();
for (int j = 0; j < strCell.Length; j++)
{
string[] strArg = strCell[j].Split(new char[] { ':' });
switch (strArg[0].Replace("\"", ""))
{
case "id":
workFlowStepEntity.GID = strArg[1].ToString().Replace("\"", "").Trim();
break;
case "no":
workFlowStepEntity.StepNO = int.Parse(strArg[1].ToString().Replace("\"", "").Trim());
break;
case "name":
workFlowStepEntity.Name = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
break;
case "desp":
workFlowStepEntity.Description = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
break;
case "must":
workFlowStepEntity.IsMust = strArg[1].ToString().Replace("\"", "").Trim().Equals("1") ? true : false;
break;
case "last":
workFlowStepEntity.IsLast = strArg[1].ToString().Replace("\"", "").Trim().Equals("1") ? true : false;
break;
case "parallel":
workFlowStepEntity.IsParallel = strArg[1].ToString().Replace("\"", "").Trim().Equals("1") ? true : false;
break;
case "dept":
workFlowStepEntity.IsDepartment = strArg[1].ToString().Replace("\"", "").Trim().Equals("1") ? true : false;
break;
case "remark":
workFlowStepEntity.Remark = strArg[1].ToString().Replace("\"", "").Trim();
break;
default:
break;
}
}
workFlowStepEntity.CreateUser = this.strUserID;
workFlowStepEntity.ModifiedUser = this.strUserID;
workFlowStepEntity.WorkFlowID = this.strWorkFlowID;
workFlowStepEntity.DefaultAuditor = "";
workFlowStepEntity.Auditor = "";
workFlowStepEntity.DepartmentID = "";
workFlowStepEntities.Add(workFlowStepEntity);
}
}
}
if (workFlowStepEntities.Count > 0)
{
WorkFlowStepDA workFlowStepDA = new WorkFlowStepDA();
workFlowStepDA.SaveWorkFlowStep(workFlowStepEntities);
}
}
}
public string UnicodeToGB(string text)
{
MatchCollection mc = Regex.Matches(text, "([\\w]+)|(\\\\u([\\w]{4}))");
if (mc != null && mc.Count > 0)
{
StringBuilder sb = new StringBuilder();
foreach (Match m2 in mc)
{
string v = m2.Value;
if (v.IndexOf("\\") >= 0)
{
string word = v.Substring(2);
byte[] codes = new byte[2];
int code = Convert.ToInt32(word.Substring(0, 2), 16);
int code2 = Convert.ToInt32(word.Substring(2), 16);
codes[0] = (byte)code2;
codes[1] = (byte)code;
sb.Append(Encoding.Unicode.GetString(codes));
}
else
{
sb.Append(v);
}
}
return sb.ToString();
}
else
{
return text;
}
}
}
}