// // GET: /DBConnection/ public ActionResult Index() { string query1 = string.Format("&appid={0}&tabid={1}", Request.QueryString["appid"], Request.QueryString["tabid"]); BizProcess.Platform.DBExtract bdbconn = new BizProcess.Platform.DBExtract(); if (!Request.Form["DeleteBut"].IsNullOrEmpty()) { string deleteID = Request.Form["checkbox_app"]; System.Text.StringBuilder delxml = new System.Text.StringBuilder(); foreach (string id in deleteID.Split(',')) { Guid gid; if (id.IsGuid(out gid)) { delxml.Append(bdbconn.Get(gid).Serialize()); bdbconn.Delete(gid); } } bdbconn.ClearCache(); BizProcess.Platform.Log.Add("删除了数据抽取", delxml.ToString(), BizProcess.Platform.Log.Types.流程相关); } var connList = bdbconn.GetAll(); ViewBag.Query1 = query1; return(View(connList)); }
public ActionResult Edit(FormCollection collection) { string editid = Request.QueryString["id"]; BizProcess.Platform.DBExtract bdbConn = new BizProcess.Platform.DBExtract(); BizProcess.Data.Model.DBExtract dbe = null; if (editid.IsGuid()) { dbe = bdbConn.Get(editid.ToGuid()); } bool isAdd = !editid.IsGuid(); string oldXML = string.Empty; if (dbe == null) { dbe = new BizProcess.Data.Model.DBExtract(); dbe.ID = Guid.NewGuid(); } else { oldXML = dbe.Serialize(); } if (collection != null) { string Name = Request.Form["Name"]; string Comment = Request.Form["Comment"]; string DBConnID = Request.Form["DBConnID"]; string ExtractType = Request.Form["ExtractType"]; string RunTime = Request.Form["RunTime"]; string OnlyIncrement = Request.Form["OnlyIncrement"]; string DesignJSON = ""; string db_table = Request.Form["db_table"]; string db_primarykey = Request.Form["db_primarykey"]; bool bSchemaChanged = false; if (dbe.DBConnID != DBConnID.ToGuid()) { bSchemaChanged = true; } dbe.Name = Name.Trim(); dbe.Comment = Comment; dbe.DBConnID = DBConnID.ToGuid(); System.Text.StringBuilder json = new System.Text.StringBuilder(); json.Append("{"); json.AppendFormat("\"table\":\"{0}\",", db_table.Trim()); json.AppendFormat("\"primarykey\":\"{0}\",", db_primarykey.Trim()); json.Append("\"fields\":["); String[] fields = Request.Form.GetValues("link_field[]"); foreach (String field in fields) { json.Append("{"); json.AppendFormat("\"field\":\"{0}\"", field.Trim()); if (fields.Last() != field) { json.Append("},"); } else { json.Append("}"); } } json.AppendFormat("]"); json.Append("}"); DesignJSON = json.ToString(); if (bSchemaChanged && (dbe.DesignJSON == null || !dbe.DesignJSON.Equals(DesignJSON))) { bSchemaChanged = true; } dbe.DesignJSON = DesignJSON; dbe.ExtractType = ExtractType == "Auto" ? true : false; dbe.RunTime = RunTime; dbe.OnlyIncrement = OnlyIncrement == "OnlyIncrement" ? true : false; if (isAdd) { bdbConn.Add(dbe); BizProcess.Platform.Log.Add("添加了数据抽取", dbe.Serialize(), BizProcess.Platform.Log.Types.流程相关); ViewBag.Script = "alert('添加成功!');new BPUI.Window().reloadOpener();new BPUI.Window().close();"; } else { bdbConn.Update(dbe, bSchemaChanged); BizProcess.Platform.Log.Add("修改了数据抽取", "", BizProcess.Platform.Log.Types.流程相关, oldXML, dbe.Serialize()); ViewBag.Script = "alert('修改成功!');new BPUI.Window().reloadOpener();new BPUI.Window().close();"; } bdbConn.ClearCache(); } return(View(dbe)); }