/// <summary> /// 项目转化接口 /// </summary> /// <param name="xm_id">项目ID</param> /// <param name="xm_name">项目名称</param> /// <param name="xm_type">项目类型(参考枚举)</param> /// <param name="xm_summary">项目描述</param> /// <returns></returns> public static bool TransformatFromXM(int xm_id, string xm_name, int xm_type, string xm_summary) { using(GGZBTQPT_PRO.Models.GGZBTQPTDBContext db = new GGZBTQPT_PRO.Models.GGZBTQPTDBContext()) { try { T_XM_Case t_xm_case = new T_XM_Case(); t_xm_case.GenerateFromID = xm_id; t_xm_case.Type = xm_type; t_xm_case.GenerateType = (int)GenerateTypes.FromSystem; t_xm_case.Name = xm_name; t_xm_case.Summary = xm_summary; t_xm_case.Analysis = "无"; t_xm_case.CreatedAt = DateTime.Now; t_xm_case.UpdatedAt = DateTime.Now; db.T_XM_Case.Add(t_xm_case); db.SaveChanges(); return true; } catch { return false; } } }
public ActionResult Create(T_XM_Case t_xm_case) { if (Request.IsAjaxRequest()) { if (ModelState.IsValid) { t_xm_case.CreatedAt = DateTime.Now; t_xm_case.UpdatedAt = DateTime.Now; t_xm_case.GenerateType = (int)GenerateTypes.FromUser; t_xm_case.IsPublished = false; t_xm_case.GenerateFromID = CurrentUser().ID; t_xm_case.IsValid = true; if(Session["CaseFile"] != null && Session["CaseFile"].ToString() != "") { Stream stream = (Stream)Session["CaseFile"]; //存入文件 if (stream.Length > 0) { t_xm_case.File = new byte[stream.Length]; stream.Read(t_xm_case.File, 0, t_xm_case.File.Length); } } db.T_XM_Case.Add(t_xm_case); int result = db.SaveChanges(); if (result > 0) { return ReturnJson(true, "操作成功", "", "", true, ""); } else { return ReturnJson(false, "操作失败", "", "", false, ""); } } } return Json(new { }); }
public JsonResult Edit(T_XM_Case t_xm_case, int generate_type) { if (Request.IsAjaxRequest()) { if (ModelState.IsValid) { t_xm_case.UpdatedAt = DateTime.Now; t_xm_case.IsValid = true; t_xm_case.GenerateType = generate_type; BusinessService.TransformatFromXM(1,"xx",1,"xxx"); if (Session["CaseFile"] != null && Session["CaseFile"].ToString() != "") { Stream stream = (Stream)Session["CaseFile"]; //存入文件 if (stream.Length > 0) { t_xm_case.File = new byte[stream.Length]; stream.Read(t_xm_case.File, 0, t_xm_case.File.Length); } } db.Entry(t_xm_case).State = EntityState.Modified; int result = db.SaveChanges(); if (result >= 0) return ReturnJson(true, "操作成功", "", "", true, ""); else return ReturnJson(false, "操作失败", "", "", false, ""); } } return Json(""); }