using sbcLabSystem.Data.Domain.Account; using sbcLabSystem.Data.Domain.Backstage; using System; using System.Collections.Generic; using System.Linq; using System.Text; using sbcLabSystem.Service.QC; namespace sbcLabSystem.Service { public class StringOperation { //拆分字符 public char[] split(string s) { return s.ToCharArray(); } //截取子串(Substring) public string Intercept(string s, int x) { return s.Substring(x); } //是否在字符串中 public bool Contains(string s, string x) { return s.Contains(x); } // public string Replace(string s, string x, string x2) { return s.Replace(x, x2); } public string StringContents(UserRequestInfo info, QCDistributionRegisterInfo regInfo, string s) { if (regInfo != null) { QCDistribution qcDistInfo = PalGain.Core.PalGainEngine.Instance.Resolve().GetQcDistributions() .FirstOrDefault(p => p.Id == regInfo.QCDistributionId); s = s.Replace("[挂号信]", regInfo.LetterNo); s = s.Replace("[质评号]", qcDistInfo.DistNo); s = s.Replace("[质评类别]", regInfo.ProjectId.ToString()); s = s.Replace("[快递单号]", regInfo.EMSNo); s = s.Replace("[质评开始日期]", qcDistInfo.IssuedDate.GetValueOrDefault().ToString("yyyy-MM-dd")); s = s.Replace("[质评结束日期]", qcDistInfo.CloseDate.GetValueOrDefault().ToString("yyyy-MM-dd")); } string stringCont = s; if (info != null) { if (Contains(stringCont, "[实验室编码]")) { stringCont = Replace(stringCont, "[实验室编码]", info.LabCode); } if (Contains(stringCont, "[实验室登录名]")) { stringCont = Replace(stringCont, "[实验室登录名]", info.LabLoginName); } if (Contains(stringCont, "[实验室密码]")) { stringCont = Replace(stringCont, "[实验室密码]", info.LabPassword); } if (Contains(stringCont, "[单位名称]")) { stringCont = Replace(stringCont, "[单位名称]", info.CompanyName); } if (Contains(stringCont, "[实验室名称]")) { stringCont = Replace(stringCont, "[实验室名称]", info.LabName); } if (Contains(stringCont, "[地址]")) { stringCont = Replace(stringCont, "[地址]", info.Address); } if (Contains(stringCont, "[省市]")) { stringCont = Replace(stringCont, "[省市]", info.Province); } if (Contains(stringCont, "[邮政编码]")) { stringCont = Replace(stringCont, "[邮政编码]", info.PostCode); } if (Contains(stringCont, "[操作人名称]")) { stringCont = Replace(stringCont, "[操作人名称]", info.ManagerName); } if (Contains(stringCont, "[操作人固话]")) { stringCont = Replace(stringCont, "[操作人固话]", info.ManagerPhone); } if (Contains(stringCont, "[操作人传真]")) { stringCont = Replace(stringCont, "[操作人传真]", info.ManagerFax); } if (Contains(stringCont, "[操作人手机]")) { stringCont = Replace(stringCont, "[操作人手机]", info.ManagerMobile); } if (Contains(stringCont, "[操作人邮箱]")) { stringCont = Replace(stringCont, "[操作人邮箱]", info.ManagerEmail); } if (Contains(stringCont, "[负责人名称]")) { stringCont = Replace(stringCont, "[负责人名称]", info.OperatorName); } if (Contains(stringCont, "[负责人固话]")) { stringCont = Replace(stringCont, "[负责人固话]", info.OperatorPhone); } if (Contains(stringCont, "[负责人传真]")) { stringCont = Replace(stringCont, "[负责人传真]", info.OperatorFax); } if (Contains(stringCont, "[负责人手机]")) { stringCont = Replace(stringCont, "[负责人手机]", info.OperatorMobile); } if (Contains(stringCont, "[负责人邮箱]")) { stringCont = Replace(stringCont, "[负责人邮箱]", info.OperatorEmail); } if (Contains(stringCont, "[质项类别]")) { stringCont = Replace(stringCont, "[质项类别]", info.ProjectId.ToString()); } if (Contains(stringCont, "[管理员名称]")) { stringCont = Replace(stringCont, "[管理员名称]", "admin"); } } //if (Contains(stringCont, "[管理员密码]")) //{ // stringCont = Replace(stringCont, "[管理员密码]", info.CompanyName); //} return stringCont; } } }