using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using PMS.BusinessModels.SysManager; using PMS.Interface; using PMS.Interface.SysManager; using PMS.Interface.Product; using PMS.BusinessModels.Product; using PMS.EntityModels.Product; using PMS.Interface.BaseCode; using System.IO; namespace PMS.WebUI.Controllers { public class ProductController : BaseController { IProductModule ProductModule = InterfaceFactory.CreateBusinessInstance(); IBaseCode BaseCode_obj = InterfaceFactory.CreateBusinessInstance(); // GET: Product #region 产品管理 public ActionResult ProductInfoManage() { return View(); } /// /// 版本计划 /// /// public ActionResult ProductVersionManagePlan() { return View(); } public ActionResult ProductProblemWindow() { ViewBag.PersonProperty = GetCurrentUser().PersonProperty; return View(); } /// /// 获取产品线datagrid /// /// /// /// [HttpGet] public ActionResult ProductInfoDataGrid(string Search, string States) { var json = ProductModule.GetProductInfoDataGrid(Search, States); return Content(json, "application/json"); } /// /// 获取产品线combobox(valueField:ID,textField:名称) /// /// public ActionResult ProductInfoCombobox() { var json = ProductModule.ProductInfoCombobox(); return Content(json, "application/json"); } /// /// 获取产品功能树 /// /// /// /// /// [HttpGet] public ActionResult productFunctionTree(string Search, string States, string ProductId) { var json = ProductModule.GetProductFunctionTree(ProductId,Search, States); return Content(json, "application/json"); } /// /// 通过ID获取产品信息 /// /// /// public ActionResult GetProductInfo(string id) { var dt = ProductModule.GetProductInfo(id); return this.ResponseJson(System.Net.HttpStatusCode.OK, "读取成功", dt); } /// /// 产品信息编辑 /// /// /// public ActionResult ProductInfoEdit(string id) { ViewBag.id = id; return View(); } /// /// 删除产品线 /// /// /// public ActionResult PostDelProduct(string id) { //调用业务接口进行删除 var r = ProductModule.DelProduct(id); if (r) {//删除成功 return this.ResponseJson(System.Net.HttpStatusCode.OK, "删除成功"); } else {//删除失败 return this.ResponseJson(System.Net.HttpStatusCode.InternalServerError, "删除失败"); } } /// /// 编辑产品线 /// /// /// [HttpPost] public ActionResult PostSaveProduct(FormProductModel model) { //调用业务接口进行保存 var r = ProductModule.SaveProductInfo(model); if (r) {//保存成功 return this.ResponseJson(System.Net.HttpStatusCode.OK, "保存成功"); } else {//保存失败 return this.ResponseJson(System.Net.HttpStatusCode.InternalServerError, "保存失败"); } } /// /// 产品功能编辑 /// /// /// public ActionResult ProductFunEdit(string id,string ProID,string ParentId) { ViewBag.id = id; ViewBag.ProID = ProID; ViewBag.ParentId = ParentId; return View(); } /// /// 获取产品功能树 /// /// public ActionResult GetProdutFunTree(string ProID) { var json = ProductModule.GetProdutFunTree(ProID); return Content(json, "application/json"); } /// /// 通过ID获取产品功能 /// /// /// public ActionResult GetProductFunInfo(string id) { var dt = ProductModule.GetProductFunInfo(id); return this.ResponseJson(System.Net.HttpStatusCode.OK, "读取成功", dt); } /// /// 产品功能编辑 /// [HttpPost] public ActionResult PostSaveProductFun(FormProductFunModel Model) { // 调用业务接口进行保存 var r = ProductModule.PostSaveProductFun(Model); if (r) {//保存成功 return this.ResponseJson(System.Net.HttpStatusCode.OK, "保存成功"); } else {//保存失败 return this.ResponseJson(System.Net.HttpStatusCode.InternalServerError, "保存失败"); } } /// /// 产品功能删除 /// /// /// public ActionResult PostDelProductFun(string id) { //调用业务接口进行删除 var r = ProductModule.DelProductFun(id); if (r) {//删除成功 return this.ResponseJson(System.Net.HttpStatusCode.OK, "删除成功"); } else {//删除失败 return this.ResponseJson(System.Net.HttpStatusCode.InternalServerError, "删除失败"); } } #endregion #region 产品版本 public ActionResult ProductVersionManage() { ViewBag.PersonProperty = GetCurrentUser().PersonProperty; return View(); } /// /// 获取产品版本树 /// /// 产品ID /// 状态 /// public ActionResult productVersionInfoTreeGrid(string ProductID, string States) { var json = ProductModule.productVersionInfoTreeGrid(ProductID, States); return Content(json, "application/json"); } public ActionResult ProductVerInfoEdit(string id,string ProID) { ViewBag.id = id; ViewBag.ProID = ProID; return View(); } /// /// 获取产品版本树 /// /// 产品ID /// public ActionResult GetProdutVersionTree(string ProID) { var json = ProductModule.GetProdutVersionTree(ProID); return Content(json, "application/json"); } /// /// 获取产品版本信息 /// /// 产品版本ID /// public ActionResult GetProductVerInfo(string id) { var dt = ProductModule.GetProductVerInfo(id); return this.ResponseJson(System.Net.HttpStatusCode.OK, "读取成功", dt); } public ActionResult PostSaveProductVersion(FormProductVerModel FormModel) { var emodel = FormModel.ToDBModel(); // 调用业务接口进行保存 var r = ProductModule.PostSaveProductVersion(emodel); if (r) {//保存成功 return this.ResponseJson(System.Net.HttpStatusCode.OK, "保存成功"); } else {//保存失败 return this.ResponseJson(System.Net.HttpStatusCode.InternalServerError, "保存失败"); } } public ActionResult PostDelProductVer(string id) { //调用业务接口进行删除 var r = ProductModule.PostDelProductVer(id); if (r) {//删除成功 return this.ResponseJson(System.Net.HttpStatusCode.OK, "删除成功"); } else {//删除失败 return this.ResponseJson(System.Net.HttpStatusCode.InternalServerError, "删除失败"); } } /// /// 获取产品版本附件datagrid /// /// 版本ID /// public ActionResult ProductVerAnnexDataGrid (string ProductVerID) { var json = ProductModule.ProductVerAnnexDataGrid(ProductVerID); return Content(json, "application/json"); } public ActionResult ProductVerFlieUpload(string id) { ViewBag.id = id; return View(); } /// /// 根据分类ID获取基础编码 /// /// /// public ActionResult GetCodeCombobox(string ClassificationID) { var json = BaseCode_obj.GetCodeComboboxs(ClassificationID); return Content(json, "application/json"); } //获取所有的产品目录列表 public ActionResult GetAllProducts() { var json = ProductModule.GetAllProducts(); return Content(json, "application/json"); } /// /// 上传产品版本附件 /// /// /// /// public ActionResult UplodProductVersionFile(string VersionId,string Type) { var files = this.Request.Files; var rs = false; var Model = new ProductVersionFileModel(); Model.Name = GetCurrentUser().Name; Model.VersionID = VersionId; Model.Type = Type; if (files.Count > 0) { for (int i = 0; i < files.Count; i++) { using (BinaryReader br = new BinaryReader(files[i].InputStream)) { byte[] byteData = br.ReadBytes((int)files[i].InputStream.Length); var uploadFile = files[i]; var fileName = uploadFile.FileName; string _tp = System.IO.Path.GetExtension(fileName); //上传 var UplodResult = UploadFile(byteData, fileName, _tp); ///是否上传成功 if (UplodResult.code == 100) { ///保存到问题附件表 Model.FileId = UplodResult.data; var t= ProductModule.AddVersionFile(Model); if (t) rs = true; } } } } if (rs) { return Content(new PmsJsonResoult(System.Net.HttpStatusCode.OK, "成功", null).ToString(), "application/json"); } else { return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, "失败", null).ToString(), "application/json"); } } /// /// 删除产品版本附件 /// /// /// public ActionResult DeleteProductVersionFile(string id) { var rs = ProductModule.DeleteProductVersionFile(id); if (rs) { return Content(new PmsJsonResoult(System.Net.HttpStatusCode.OK, "成功", null).ToString(), "application/json"); } else { return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, "失败", null).ToString(), "application/json"); } } #endregion } }