/// <summary> /// 将字符串转化为DiyProcess对象 /// </summary> public static DiyProcess ConvertToObject_DiyProcessDal(string strProcess) { DiyProcess process = new DiyProcess(); List <DiyStep> diyStepList = new List <DiyStep>(); string[] diySteps = strProcess.Split(';'); foreach (string diyStep in diySteps) { string[] steps = diyStep.Split('|'); if (steps.Length > 4) { DiyStep step = new DiyStep(Convert.ToInt32(steps[0]), steps[1], new OperatorType(Convert.ToInt32(steps[2]), OperatorType.FindOperatorTypeByID(Convert.ToInt32(steps[2]))), Convert.ToInt32(steps[3])); string[] mailAccounts = steps[4].Split(','); foreach (string mailAccount in mailAccounts) { if (!string.IsNullOrEmpty(mailAccount)) { step.MailAccount.Add(new Account(Convert.ToInt32(mailAccount), "", "")); } } diyStepList.Add(step); } } process.DiySteps = diyStepList; return(process); }
/// <summary> /// 将DiyProcess对象转化为字符串 /// </summary> public static string ConvertToString(DiyProcess diyProcess) { string process = ""; StringBuilder processtext = new StringBuilder(); if (diyProcess != null && diyProcess.DiySteps != null && diyProcess.DiySteps.Count > 0) { foreach (DiyStep step in diyProcess.DiySteps) { processtext.Append(step.DiyStepID); processtext.Append("|"); processtext.Append(step.Status); processtext.Append("|"); processtext.Append(step.OperatorType.Id); processtext.Append("|"); processtext.Append(step.OperatorID); processtext.Append("|"); foreach (Account account in step.MailAccount) { processtext.Append(account.Id); processtext.Append(","); } processtext.Append("|"); foreach (ProcessType role in step.MailRole) { processtext.Append(role.Id); processtext.Append(","); } processtext.Append(";"); } } if (processtext.Length > 0) { process = processtext.ToString().Substring(0, processtext.Length - 1); } return(process); }