protected override void InitializeMockData() { firstProduct = new Product { Id = 1, Name = "Blade", Description = "x35 Blade F12" }; secondProduct = new Product { Id = 2, Name = "Blade F1", Description = "x35 Blade F10" }; firstDefect = new Defect { Id = 1, Name = "DI321", Description = "x35 Blade F12", Product = firstProduct }; secondDefect = new Defect { Id = 2, Name = "CO410", Description = "x35 Blade F10", Product = firstProduct }; products = new List <Product>() { firstProduct, secondProduct }; defects = new List <Defect>() { firstDefect, secondDefect }; defectUpdated = new Defect { Id = 2, Name = "CO410", Description = "x35 Blade F10", Product = firstProduct }; viewModel = new DefectViewModel() { Name = "DIM442", Description = "Dimension 442, 0 +-0.5", Product = 1 }; }
public async Task <ActionResult> Defect(string query = null) { var defects = await _unitOfWork.DefectRepository .GetWithProductAsync(); var vm = new DefectViewModel { Defects = defects.Select(d => _factory.Create(d)).ToList(), Products = await _unitOfWork.ProductRepository.GetAllAsync(), SearchCriteria = query }; if (!string.IsNullOrEmpty(query)) { vm.Defects = vm.Defects .Where(d => d.Name.ToLower().Contains(query.ToLower()) || d.Description.ToLower().Contains(query.ToLower()) || d.Product.ToLower().Contains(query.ToLower()) ) .ToList(); } return(View(vm)); }
public ActionResult Update(DefectViewModel dViewModel) { try { dViewModel.Defect.UpdatedOn = DateTime.Now; dViewModel.Defect.UpdatedBy = ((UserInfo)Session["User"]).UserId; DefectManager dMan = new DefectManager(); dMan.Update(dViewModel.Defect); dViewModel.Defect.Process_Id = 0; dViewModel.Friendly_Message.Add(MessageStore.Get("D012")); } catch (Exception ex) { dViewModel.Friendly_Message.Add(MessageStore.Get("SYS01")); Logger.Error("Defect Controller - Update" + ex.ToString()); } TempData["dViewModel"] = dViewModel; return(RedirectToAction("Search")); }
public Defect Create(DefectViewModel viewModel, User user) { return(new Defect(user) { Name = viewModel.Name, Description = viewModel.Description, Product = viewModel.Products.Single(p => p.Id == viewModel.Product) }); }
private async Task Create(DefectViewModel viewModel) { var user = await GetUserAsync(); var defect = _factory.Create(viewModel, user); _unitOfWork.DefectRepository.Add(defect); viewModel.Defects.Add(_factory.Create(defect)); }
public async Task <ActionResult> SaveModify(DefectViewModel model) { MethodReturnResult result = new MethodReturnResult(); try { using (DefectServiceClient client = new DefectServiceClient()) { Defect obj = new Defect() { Key = new DefectKey() { Year = model.Year, Month = model.Month, Day = model.Day, LocationName = model.LocationName, ShiftName = model.ShiftName, ReasonCodeCategoryName = model.ReasonCodeCategoryName, ReasonCodeName = model.ReasonCodeName }, Qty = model.Qty, Editor = User.Identity.Name, EditTime = DateTime.Now, CreateTime = model.CreateTime, Creator = model.Creator }; MethodReturnResult rst = await client.ModifyAsync(obj); if (rst.Code == 0) { rst.Message = string.Format(PPMResources.StringResource.Defect_Modify_Success, obj.Key); } else { //数据错误 result.Code = rst.Code; //错误代码 result.Message = rst.Message; //错误信息 result.Detail = rst.Message; //错误明细 return(Json(result)); } return(Json(rst)); } } catch (Exception e) { result.Code = 1002; result.Message = e.Message; result.Detail = e.ToString(); return(Json(result)); } }
public ActionResult Index(DefectViewModel dViewModel) { ViewBag.Title = "KPCL ERP :: Create, Update"; DefectManager dMan = new DefectManager(); dViewModel.Processes = dMan.Get_Processes(); return(View(dViewModel)); }
public ActionResult SaveNotify(DefectViewModel model) { if (!ModelState.IsValid) { return(View(model)); } return(RedirectToAction("Detail", "Defect", new { Id = Service.SaveNotify(model) }) .Success("Notified Defect " + model.Id + ((string.IsNullOrEmpty(model.AssignedTo)) ? "" : " to " + model.AssignedTo))); }
static void Main(string[] args) { var d = new Defect() { Category = "bug", Status = "open" }; var m = new DefectViewModel(); m.CopyPropertiesFrom(d); Console.WriteLine("{0}, {1}", m.Category, m.Status); }
public ActionResult Save(DefectViewModel model) { if (!ModelState.IsValid) { return(RedirectToAction("Create", new { id = model.Id, mailId = model.IMailItemUniqueId }) .Error("Erron in Save")); } return(RedirectToAction("Detail", "Defect", new { Id = Service.Save(model) }) .Success("Save Ok")); }
public ActionResult PostReleaseData(string param) { var context = new Defect_TrackerEntities1(); var sap = context.releases.ToList(); ViewBag.allreleasenames = sap; var res2 = context.releases.Where(x => x.Release_Name == param).Select(y => y.R_Id).Take(1).FirstOrDefault(); //var rel1 = context.TicketInfoes.Where(x => x.R_ID == res2).ToList(); //var rel1 = from ti in context.TicketInfoes // from te in context.Testexecutions // where (ti.T_Id == te.T_Id && ti.R_ID == res2) // select new DefectModel // { // T_Number = ti.T_Number, // T_Desc = ti.T_Desc, // T_State = ti.T_State, // T_Developer = ti.T_Developer, // Tester = ti.T_Tester, // Passed = te.passed ?? 0, // Testcases = te.Testcases ?? 0, // Fail = te.fail ?? 0, // OnHold = te.onhold ?? 0, // Defects = te.defects ?? 0 // }; var rel1 = from ti in context.TicketInfoes join te in context.Testexecutions on ti.T_Id equals te.T_Id into ps from te in ps.DefaultIfEmpty() where ti.R_ID == res2 select new DefectModel { T_Number = ti.T_Number, T_Desc = ti.T_Desc, T_State = ti.T_State, T_Developer = ti.T_Developer, Tester = ti.T_Tester, Passed = te.passed ?? 0, Testcases = te.Testcases ?? 0, Fail = te.fail ?? 0, OnHold = te.onhold ?? 0, Defects = te.defects ?? 0 }; ViewBag.ticketinformation = rel1.ToList(); DefectViewModel vm = new DefectViewModel(); vm.AllTicketDetails = rel1.ToList(); return(PartialView("PartialIndex2", vm)); }
public ActionResult ArchiveDefect(DefectViewModel model) { if (!ModelState.IsValid) { return(View(model)); } IMailItem itemRead = Mail.Get(ServiceFactory.Get <IItemFactory>().GetNew <IMailItem>(model.IMailItemUniqueId)); Mail.Complete(itemRead); return(RedirectToAction("Index", "Convert")); }
public JsonResult Get_Grid_By_Process_Id(DefectViewModel dViewModel) { DefectManager dMan = new DefectManager(); PaginationInfo Pager = new PaginationInfo(); Pager.IsPagingRequired = false; if (dViewModel.Filter.Process_Id > 0) { dViewModel.DefectGrid = dMan.Get_Grid_By_Process_Id(dViewModel.Filter.Process_Id); } return(Json(dViewModel, JsonRequestBehavior.AllowGet)); }
public ActionResult Get_Defect_By_Id(DefectViewModel dViewModel) { try { DefectManager dMan = new DefectManager(); dViewModel.Defect = dMan.Get_Defect_By_Id(dViewModel.EditMode.Defect_Id); dViewModel.Processes = dMan.Get_Processes(); } catch (Exception ex) { Logger.Error("Defect Controller - Get_Defect_By_Id " + ex.ToString()); } return(View("Index", dViewModel)); }
public JsonResult Get_Defects(DefectViewModel dViewModel) { DefectManager dMan = new DefectManager(); PaginationInfo pager = new PaginationInfo(); try { pager = dViewModel.Pager; if ((dViewModel.Filter.Defect_Id != 0) && (dViewModel.Filter.Process_Id > 0)) { dViewModel.DefectGrid = dMan.Get_Defect_By_Defect_Id_By_Process_Id(dViewModel.Filter.Process_Id, dViewModel.Filter.Defect_Id, ref pager); } else if (dViewModel.Filter.Process_Id > 0) { dViewModel.DefectGrid = dMan.Get_Defect_By_Process_Id(dViewModel.Filter.Process_Id, ref pager); } else if (dViewModel.Filter.Defect_Id != 0) { dViewModel.DefectGrid = dMan.Get_Defect_By_Name(dViewModel.Filter.Defect_Id, ref pager); } else { dViewModel.DefectGrid = dMan.Get_Defects(ref pager); } dViewModel.Pager = pager; dViewModel.Pager.PageHtmlString = PageHelper.NumericPager("javascript:PageMore({0})", dViewModel.Pager.TotalRecords, dViewModel.Pager.CurrentPage + 1, dViewModel.Pager.PageSize, 10, true); } catch (Exception ex) { dViewModel.Friendly_Message.Add(MessageStore.Get("SYS01")); Logger.Error("Defect Controller - Get_Defects " + ex.ToString()); } finally { pager = null; } return(Json(dViewModel, JsonRequestBehavior.AllowGet)); }
private void MainWindow_Loaded(object sender, RoutedEventArgs e) { // Message:获取测试数据 string url = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "测试数据.json"); string txt = System.IO.File.ReadAllText(url, Encoding.Default); var collecion = JsonConvert.DeserializeObject <List <TyeEncodeDeviceEntity> >(txt); IDefectSign defectViewModel = DefectViewModel.CreateInstance(); // Message:初始化树形控件(只需初始化一遍) defectViewModel.InitTyeEncodeDevice(collecion); List <TyeEncodeDeviceEntity> tyeEncodeDeviceEntitieChecks = new List <TyeEncodeDeviceEntity>(); defectViewModel.LoadTyeEncodeCheckDevice(collecion.Where(l => l.Code.Length == 2).ToList()); }
public async Task <ActionResult> SaveDefect(DefectViewModel viewModel) { var defects = await _unitOfWork.DefectRepository .GetWithProductAsync(); viewModel.Defects = defects.Select(d => _factory.Create(d)).ToList(); viewModel.Products = await _unitOfWork.ProductRepository.GetAllAsync(); try { if (viewModel.Id.HasValue) { var defect = await _unitOfWork.DefectRepository.FindByIdAsync(viewModel.Id); if (defect == null) { return(HttpNotFound()); } await Update(viewModel, defect); } else { await Create(viewModel); } await _unitOfWork.SaveChangesAsync(); } catch (Exception ex) { await LogExceptionAsync(ex); return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, ex.Message)); } if (!string.IsNullOrEmpty(viewModel.SearchCriteria)) { viewModel.Products = viewModel.Products .Where(p => p.Name.ToLower().Contains(viewModel.SearchCriteria.ToLower()) || p.Description.ToLower().Contains(viewModel.SearchCriteria.ToLower())) .ToList(); } return(View("Defect", viewModel)); }
public async Task <IActionResult> UpdateDefect([FromBody] DefectViewModel defectViewModel) { var defect = await _repo.GetDefectWithAssignedDefectByIdAsync(defectViewModel.Id); defect.Description = defectViewModel.Description; defect.RoomNumber = defectViewModel.RoomNumber; defect.AssignedDefect.Status = (Status)Enum.Parse(typeof(Status), defectViewModel.DefectStatus); var worker = await _userRepo.GetByIdAsync(defectViewModel.AssignedWorkerId); if (worker != null) { defect.AssignedDefect.AssignedWorker = worker; await _repo.UpdateAsync(defect); return(Ok()); } return(BadRequest()); }
public ActionResult Search(DefectViewModel dViewModel) { ViewBag.Title = "KPCL ERP :: Search"; DefectManager dMan = new DefectManager(); if (TempData["DefectTypeId"] != null) { dViewModel.Filter.Process_Id = Convert.ToInt32(TempData["ProcessId"]); } if (TempData["dViewModel"] != null) { dViewModel = (DefectViewModel)TempData["dViewModel"]; } dViewModel.Processes = dMan.Get_Processes(); return(View("Search", dViewModel)); }
private void MainWindow_Loaded(object sender, RoutedEventArgs e) { IDefectSign defectViewModel = new DefectViewModel(); defectViewModel.Load(this.GetEntity()); defectViewModel.ConfirmData += l => { Debug.WriteLine(l); }; window.Width = 1200; window.Height = 500; //window.WindowStyle = WindowStyle.None; // Do:取消 defectViewModel.CancelClick += () => { window.Hide(); }; // Do:q确定 defectViewModel.SumitClick += () => { window.Hide(); Debug.WriteLine(defectViewModel.ToString()); }; DefectControl defect = new DefectControl(); window.Content = defect; window.DataContext = defectViewModel; KeyGesture keyGesture = new KeyGesture(Key.W, ModifierKeys.Control); defect.KeyGestureForHistList = keyGesture; //window.ShowDialog(); }
public async Task <ActionResult> UpdateDefect(int id) { var defects = await _unitOfWork.DefectRepository .GetWithProductAsync(); var defect = defects.SingleOrDefault(d => d.Id == id); if (defect == null) { return(HttpNotFound()); } var vm = new DefectViewModel { Id = id, Name = defect.Name, Description = defect.Description, Product = defect.ProductId, Defects = defects.Select(d => _factory.Create(d)).ToList(), Products = await _unitOfWork.ProductRepository.GetAllAsync() }; return(View("Defect", vm)); }
/// <summary> 缺陷管理 </summary> private void Button_Click(object sender, RoutedEventArgs e) { Window window = new Window(); window.Width = 1000; window.Height = 600; //window.WindowStyle = WindowStyle.None; IDefectSign defectViewModel = DefectViewModel.CreateInstance(); // Message:刷新常用数据 List <DefectCommonUsed> defectCommonUseds = new List <DefectCommonUsed>(); for (int i = 0; i < 7; i++) { DefectCommonUsed defectCommonUsed = new DefectCommonUsed(); defectCommonUsed.Describletion = "统一跨距接头数量(n) -n>=2" + i.ToString(); defectCommonUsed.CountUse = i; defectCommonUsed.Code = "Code" + i; defectCommonUsed.ID = Guid.NewGuid().ToString(); defectCommonUseds.Add(defectCommonUsed); } defectViewModel.LoadDefectCommonUsed(defectCommonUseds); // Message:刷新预估缺陷 List <DefectCommonUsed> defectCommonUseds1 = new List <DefectCommonUsed>(); for (int i = 0; i < 3; i++) { DefectCommonUsed defectCommonUsed = new DefectCommonUsed(); defectCommonUsed.Code = "Code" + i; defectCommonUsed.Describletion = "统一跨距接头数量统一跨距接头数量(统一跨距接头数量((n) -n>=2" + i; defectCommonUsed.ID = Guid.NewGuid().ToString(); defectCommonUsed.CountUse = i; defectCommonUseds1.Add(defectCommonUsed); } defectViewModel.LoadEstimateDefectCommonUseds(defectCommonUseds1); // Message:刷新缺陷输入信息 defectViewModel.LoadPHM("B 01 15 000045 000261 000033"); // Do:取消 defectViewModel.CancelClick += () => { window.Hide(); }; // Do:q确定 defectViewModel.SumitClick += () => { window.Hide(); Debug.WriteLine(defectViewModel.ToString()); }; DefectControl defect = DefectViewModel.CreateInstance().GetControlInstance(); window.Content = defect; window.ShowDialog(); }
private async Task Update(DefectViewModel viewModel, Defect defect) { var user = await GetUserAsync(); defect.Update(user, viewModel.Name, viewModel.Description); }
/// <summary> /// 浏览信息 /// </summary> /// <param name="year">年</param> /// <param name="month">月</param> /// <param name="day">日</param> /// <param name="locationname">车间</param> /// <param name="shiftname">班别</param> /// <param name="reasoncodecategoryname">不良组</param> /// <param name="reasoncodename">不良原因</param> /// <returns></returns> public async Task <ActionResult> Detail(string year, string month, string day, string locationname, string shiftname, string reasoncodecategoryname, string reasoncodename) { MethodReturnResult <Defect> result = new MethodReturnResult <Defect>(); try { DefectViewModel viewModel = new DefectViewModel(); using (DefectServiceClient client = new DefectServiceClient()) { DefectKey key = new DefectKey() { Year = year, Month = month, Day = day, LocationName = locationname == null ? "" : locationname, ShiftName = shiftname, ReasonCodeCategoryName = reasoncodecategoryname, ReasonCodeName = reasoncodename }; //取得数据 result = await client.GetAsync(key); if (result.Code == 0) { viewModel = new DefectViewModel() { Year = result.Data.Key.Year, Month = result.Data.Key.Month, Day = result.Data.Key.Day, LocationName = result.Data.Key.LocationName, ShiftName = result.Data.Key.ShiftName, Qty = result.Data.Qty, CreateTime = result.Data.CreateTime, Creator = result.Data.Creator, Editor = result.Data.Editor, EditTime = result.Data.EditTime }; return(PartialView("_InfoPartial", viewModel)); } else { //数据错误 result.Code = result.Code; //错误代码 result.Message = result.Message; //错误信息 result.Detail = result.Message; //错误明细 return(Json(result)); } } } catch (Exception e) { result.Code = 1002; result.Message = e.Message; result.Detail = e.ToString(); return(Json(result)); } }