public string Do(string doWhat, string para1, bool isLogin) { // 如果admin账户登陆时有错误发生,则返回错误信息 var result = LetAdminLogin("CH", isLogin); if (string.IsNullOrEmpty(result) == false) { return(result); } switch (doWhat) { case "GenerFlowTemplete": Flow temp = new BP.WF.Flow(para1); return(null); case "NewFrmSort": BP.Sys.FrmSort frmSort = null; try { frmSort = new FrmSort(); frmSort.No = "01"; frmSort.Name = para1; frmSort.No = frmSort.GenerNewNo; frmSort.Insert(); return(null); } catch (Exception ex) { return("Do Method NewFlowSort Branch has a error , para:\t" + para1 + ex.Message); } case "NewFlowSort": BP.WF.FlowSort fs = null; try { fs = new FlowSort(); fs.Name = para1; fs.No = fs.GenerNewNo; fs.Insert(); return(fs.No); } catch (Exception ex) { BP.DA.Log.DefaultLogWriteLineError("Do Method NewFlowSort Branch has a error , para:\t" + para1 + ex.Message); return(null); } case "EditFlowSort": try { var para = para1.Split(','); fs = new FlowSort(para[0]); fs.Name = para[1]; fs.Save(); return(fs.No); } catch (Exception ex) { BP.DA.Log.DefaultLogWriteLineError("Do Method EditFlowSort Branch has a error , para:\t" + para1 + ex.Message); return(null); } case "NewFlow": Flow fl = new Flow(); try { string[] ps = para1.Split(','); if (ps.Length != 5) { throw new Exception("@创建流程参数错误"); } string fk_floSort = ps[0]; string flowName = ps[1]; DataStoreModel dataSaveModel = (DataStoreModel)int.Parse(ps[2]); string pTable = ps[3]; string flowCode = ps[4]; fl.DoNewFlow(fk_floSort, flowName, dataSaveModel, pTable, flowCode); return(fl.No + ";" + fl.Name); } catch (Exception ex) { BP.DA.Log.DefaultLogWriteLineError("Do Method NewFlow Branch has a error , para:\t" + para1 + ex.Message); return(ex.Message); } case "DelFlow": BP.WF.Flow fl1 = new BP.WF.Flow(para1); try { fl1.DoDelete(); return(null); } catch (Exception ex) { BP.DA.Log.DefaultLogWriteLineError("Do Method DelFlow Branch has a error , para:\t" + para1 + ex.Message); return(ex.Message); } case "DelLable": BP.WF.LabNote ln = new BP.WF.LabNote(para1); try { ln.Delete(); } catch (Exception ex) { BP.DA.Log.DefaultLogWriteLineError("Do Method DelLable Branch has a error , para:\t" + para1 + ex.Message); } return(null); case "DelFlowSort": try { FlowSort delfs = new FlowSort(para1); delfs.Delete(); } catch (Exception ex) { BP.DA.Log.DefaultLogWriteLineError("Do Method DelFlowSort Branch has a error , para:\t" + para1 + ex.Message); } return(null); case "NewNode": try { BP.WF.Flow fl11 = new BP.WF.Flow(para1); BP.WF.Node node = new BP.WF.Node(); node.FK_Flow = ""; node.X = 0; node.Y = 0; node.Insert(); } catch (Exception ex) { BP.DA.Log.DefaultLogWriteLineError("Do Method NewNode Branch has a error , para:\t" + para1 + ex.Message); } return(null); case "DelNode": try { if (!string.IsNullOrEmpty(para1)) { BP.WF.Node delNode = new BP.WF.Node(int.Parse(para1)); delNode.Delete(); } } catch (Exception ex) { BP.DA.Log.DefaultLogWriteLineError("Do Method DelNode Branch has a error , para:\t" + para1 + ex.Message); } return(null); case "NewLab": BP.WF.LabNote lab = new BP.WF.LabNote();; try { lab.FK_Flow = para1; lab.MyPK = BP.DA.DBAccess.GenerOID().ToString(); lab.Insert(); } catch (Exception ex) { BP.DA.Log.DefaultLogWriteLineError("Do Method NewLab Branch has a error , para:\t" + para1 + ex.Message); } return(lab.MyPK); case "DelLab": try { BP.WF.LabNote dellab = new BP.WF.LabNote(); dellab.MyPK = para1; dellab.Delete(); } catch (Exception ex) { BP.DA.Log.DefaultLogWriteLineError("Do Method DelLab Branch has a error , para:\t" + para1 + ex.Message); } return(null); case "GetSettings": return(SystemConfig.AppSettings[para1]); case "GetFlows": string sqls = "SELECT NO,NAME FROM WF_FlowSort"; sqls += "@SELECT No,Name,FK_FlowSort FROM WF_Flow"; return(RunSQLReturnTableS(sqls)); case "SaveFlowFrm": Entity en = null; try { AtPara ap = new AtPara(para1); string enName = ap.GetValStrByKey("EnName"); string pk = ap.GetValStrByKey("PKVal"); en = ClassFactory.GetEn(enName); en.ResetDefaultVal(); if (en == null) { throw new Exception("无效的类名:" + enName); } if (string.IsNullOrEmpty(pk) == false) { en.PKVal = pk; en.RetrieveFromDBSources(); } foreach (string key in ap.HisHT.Keys) { if (key == "PKVal") { continue; } en.SetValByKey(key, ap.HisHT[key].ToString().Replace('^', '@')); } en.Save(); return(en.PKVal as string); } catch (Exception ex) { if (en != null) { en.CheckPhysicsTable(); } return("Error:" + ex.Message); } case "ReleaseToFTP": // 暂时注释,下次更新ftp功能时会得新编译 。 //var args = para1.Split(','); //var binaryData = Convert.FromBase64String(args[1]); //var imageFilePath = Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath) + "/Temp/" + args[0] + ".jpg"; //if (File.Exists(imageFilePath)) //{ // File.Delete(imageFilePath); //} //System.IO.Directory.CreateDirectory( // Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath) + "/Temp"); //var stream = new System.IO.FileStream(imageFilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite); //stream.Write(binaryData, 0, binaryData.Length); //stream.Close(); //var xmlFilePath = FlowTemplete_Gener(args[0], true); //string remoteDr = "/" + ConfigurationSettings.AppSettings["UserIdentifier"];; //var ftp = new FtpConnection(); //try //{ // string ftpIP = ConfigurationSettings.AppSettings["FTPServerIP"]; // string email = ConfigurationSettings.AppSettings["FTPUserEmail"]; // Session session = new Session(); // session.Server = ftpIP; // session.Connect("anonymous", "*****@*****.**"); // ftp.Connect(ftpIP, "anonymous", email); // remoteDr = remoteDr; // if(!ftp.DirectoryExist(remoteDr)) // { // ftp.CreateDirectory(remoteDr); // } // ftp.SetCurrentDirectory(remoteDr); // ftp.PutFile(imageFilePath, remoteDr); // return string.Empty;//上传成功 //} //catch (Exception err) //{ // return err.Message;//上传失败 //} //finally //{ // ftp.Close(); //} return(string.Empty); default: throw null; } }
/// <summary> /// 保存流程, 用 ~ 隔开。 /// </summary> /// <param name="flowNo">流程编号</param> /// <param name="nodes">节点信息,格式为:@NodeID=xxxx@X=xxx@Y=xxx@Name=xxxx@RunModel=1</param> /// <param name="dirs">方向信息,格式为: @Node=xxxx@ToNode=xxx@X=xxx@Y=xxx@Name=xxxx </param> /// <param name="labes">标签信息,格式为:@MyPK=xxxxx@Label=xxx@X=xxx@Y=xxxx</param> public static string SaveFlow(string fk_flow, string nodes, string dirs, string labes) { try { #region 处理方向. string sql = "DELETE FROM WF_Direction WHERE FK_Flow='" + fk_flow + "'"; DBAccess.RunSQL(sql); string[] mydirs = dirs.Split('~'); foreach (string dir in mydirs) { if (string.IsNullOrEmpty(dir)) { continue; } AtPara ap = new AtPara(dir); string dots = ap.GetValStrByKey("Dots").Replace('#', '@'); if (string.IsNullOrEmpty(dots) == true) { dots = ""; } Direction enDir = new Direction(); enDir.Node = ap.GetValIntByKey(DirectionAttr.Node); enDir.ToNode = ap.GetValIntByKey(DirectionAttr.ToNode); enDir.IsCanBack = ap.GetValBoolenByKey(DirectionAttr.IsCanBack); enDir.DirType = ap.GetValIntByKey(DirectionAttr.DirType); enDir.FK_Flow = fk_flow; enDir.Dots = dots; try { enDir.Insert(); } catch { // enDir.Update(); } } #endregion 处理方向. #region 保存节点 string[] nds = nodes.Split('~'); foreach (string nd in nds) { if (string.IsNullOrEmpty(nd)) { continue; } AtPara ap = new AtPara(nd); sql = "UPDATE WF_Node SET X=" + ap.GetValStrByKey("X") + ",Y=" + ap.GetValStrByKey("Y") + ", Name='" + ap.GetValStrByKey("Name") + "' WHERE NodeID=" + ap.GetValIntByKey("NodeID"); DBAccess.RunSQL(sql); } Flow.UpdateVer(fk_flow); #endregion 保存节点 #region 处理标签。 sql = "DELETE FROM WF_LabNote WHERE FK_Flow='" + fk_flow + "'"; DBAccess.RunSQL(sql); string[] mylabs = labes.Split('~'); foreach (string lab in mylabs) { if (string.IsNullOrEmpty(lab)) { continue; } AtPara ap = new AtPara(lab); LabNote ln = new LabNote(); ln.MyPK = BP.DA.DBAccess.GenerGUID(); // ap.GetValStrByKey("MyPK"); ln.FK_Flow = fk_flow; ln.Name = ap.GetValStrByKey("Label"); ln.X = ap.GetValIntByKey("X"); ln.Y = ap.GetValIntByKey("Y"); ln.Insert(); } #endregion 处理标签。 // 备份文件 //f1.WriteToXml(); } catch (Exception ex) { return(ex.Message); } return(null); }