public ActionResult Create(WorkVM model) { HttpCookie cookieReq = Request.Cookies["Localhost cookie"]; int ids; if (null != cookieReq) { ids = Convert.ToInt32(cookieReq["ids"]); } else { FormsAuthentication.SignOut(); return(RedirectToActionPermanent("Index", "Works")); } model.UserId = ids; model.DateOfPublication = DateTime.Now; if (ModelState.IsValid) { WorkBL newWork = AutoMapperBL <WorkVM, WorkBL> .Map(model); workBL.Create(newWork); return(RedirectToActionPermanent("Index", "Works")); } return(View()); }
private void ApplyChanges(object obj) { if (IsEditing) { Minutes = Hours * 60 + MinutesShort; _hours = Minutes / 60; _minutesShort = Minutes % 60; Work.WorkTypeID = SelectedWorkTypeIndex; UpdateWorkTimeRanges(); WorkVM.UpdateWork(); IsEditing = false; MainWindow.IsEnable = true; var sortWorkRanges = WorkTimeRanges.OrderBy(r => r.EndTime).ToList(); int lastRngIndex = sortWorkRanges.Count - 1; if (lastRngIndex >= 0) { LastRangeTime = sortWorkRanges[lastRngIndex].EndTime; } _generate_path(); RaisePropertyChanged("MinutesShort"); RaisePropertyChanged("Hours"); RaisePropertyChanged("TimeLast"); RaisePropertyChanged("LastRangeTime"); } }
public ActionResult Update(WorkVM user) { WorkBL newUser = AutoMapperBL <WorkVM, WorkBL> .Map(user); workBL.Update(newUser); return(RedirectToActionPermanent("Index", "Works")); }
public ActionResult Update(int id) { ViewBag.GenreList = new SelectList(genreBL.GetGenres().ToList(), "Id", "Name"); WorkVM work = AutoMapperBL <WorkBL, WorkVM> .Map(workBL.GetWork, id); return(View(work)); }
public ActionResult Details(int id) { WorkVM work = AutoMapperBL <WorkBL, WorkVM> .Map(workBL.GetWork, id); work.Name = ""; work.UserId = 1; return(View(work)); }
private void CancelChanges(object obj) { if (WorkVM.IsEdititig) { WorkVM.CancelWork(); IsEditing = false; MainWindow.IsEnable = true; } }
private async void workList_ItemClick(object sender, ItemClickEventArgs e) { workDetailControl.Visibility = Visibility.Visible; detailColumn.Width = new GridLength(1, GridUnitType.Star); WorkVM workVM = e.ClickedItem as WorkVM; await VM.ChangeWorkDetail(workVM); workContent.NavigateToString(workVM.Content); }
public HttpResponseMessage UpdateWorkCompleteData(WorkVM workVM) { var response = inwardOutwardService.UpdateWorkCompleteData(workVM); if (response.IsSuccess) { return(Request.CreateResponse(HttpStatusCode.OK, response, "application/json")); } else { return(Request.CreateResponse(HttpStatusCode.BadRequest, response, "application/json")); } }
private void Delete(object obj) { var dialogResult = System.Windows.MessageBox.Show("Вы уверены, что хотите удалить работу?", "Подтверждение", MessageBoxButton.YesNo, MessageBoxImage.Question); if (dialogResult == MessageBoxResult.No) { return; } WorkVM.DeleteWork(); UnRegister(); IsEditing = false; CancelChanges(obj); }
public ActionResult Edit(WorkVM vm) { if (!ModelState.IsValid) { return(PartialView(vm)); } else { vm.DoEdit(); if (!ModelState.IsValid) { vm.DoReInit(); return(PartialView(vm)); } else { return(FFResult().CloseDialog().RefreshGridRow(vm.Entity.ID)); } } }
public ActionResult Create(WorkVM vm) { if (!ModelState.IsValid) { return(PartialView(vm)); } else { vm.DoAdd(); if (!ModelState.IsValid) { vm.DoReInit(); return(PartialView(vm)); } else { return(FFResult().CloseDialog().RefreshGrid()); } } }
public ActionResult Details(WorkVM user) { HttpCookie cookieReq = Request.Cookies["Localhost cookie"]; int ids = 0; if (cookieReq != null) { ids = Convert.ToInt32(cookieReq["ids"]); } WorkBL newUser = AutoMapperBL <WorkVM, WorkBL> .Map(user); CommentBL newComment = new CommentBL(); newComment.Comment = newUser.Title; newComment.WorkId = newUser.Id; newComment.UserId = ids; return(RedirectToActionPermanent("Index", "Works")); }
public void FileAnalysis() { RepetitivePlanVM model = new RepetitivePlanVM(); if (System.Web.HttpContext.Current.Session["session_filetext"] != null) { var fileText = System.Web.HttpContext.Current.Session["session_filetext"].ToString(); //日期 MatchCollection dateMatch = Regex.Matches(fileText, FileAnalysisReg.dateReg); try { if (dateMatch.Count > 1) { model.StartDate = DateTime.Parse(dateMatch[0].Value.Replace("年", "-").Replace("月", "-").Replace("日", "")); model.EndDate = DateTime.Parse(dateMatch[1].Value.Replace("年", "-").Replace("月", "-").Replace("日", "")); } else if (dateMatch.Count == 1) { var arr = dateMatch[0].Value.Split('至'); model.StartDate = DateTime.Parse(arr[0].Replace("年", "-").Replace("月", "-").Replace("日", "")); model.EndDate = DateTime.Parse(arr[1].Replace("年", "-").Replace("月", "-").Replace("日", "")); } } catch { } //公司名称 if (Regex.IsMatch(fileText, FileAnalysisReg.companyReg)) { try { model.CompanyName = Regex.Match(fileText, FileAnalysisReg.companyReg).Value + "公司"; } catch { } } ////地区 //if (Regex.IsMatch(fileText, FileAnalysisReg.areaReg)) //{ // model.FlightArea = Regex.Match(fileText, FileAnalysisReg.areaReg).Value; //} //任务性质 if (Regex.IsMatch(fileText, FileAnalysisReg.taskReg)) { try { var list = fbll.GetList(); model.FlightType = list.Find(m => m.Description.Contains(Regex.Match(fileText, FileAnalysisReg.taskReg).Value)).TaskCode; } catch { } } //机型 if (Regex.IsMatch(fileText, FileAnalysisReg.airplaneTypeReg)) { model.AircraftType = Regex.Match(fileText, FileAnalysisReg.airplaneTypeReg).Value; } #region 临时起降点 if (Regex.IsMatch(fileText, FileAnalysisReg.airportReg)) { model.AirportText = Regex.Match(fileText, FileAnalysisReg.airportReg).Value; if (Regex.IsMatch(model.AirportText, FileAnalysisReg.airportReg1)) { MatchCollection airportMatches = Regex.Matches(model.AirportText, FileAnalysisReg.airportReg1); foreach (Match airport in airportMatches) { string airportName = "", code4 = "", lngAndLat = ""; if (Regex.IsMatch(airport.Value, FileAnalysisReg.airportName)) { airportName = Regex.Match(airport.Value, FileAnalysisReg.airportName).Value; } if (Regex.IsMatch(airport.Value, FileAnalysisReg.code4)) { code4 = Regex.Match(airport.Value, FileAnalysisReg.code4).Value; } if (Regex.IsMatch(airport.Value, FileAnalysisReg.lngAndLat)) { lngAndLat = Regex.Match(airport.Value, FileAnalysisReg.lngAndLat).Value; } model.airportList.Add(new AirportVM() { Name = airportName, Code4 = code4, LatLong = lngAndLat }); } } } #endregion #region 航线分析 if (Regex.IsMatch(fileText, @"(?<=(\uff08\u4e00\uff09\u822a\u7ebf))[.\s\S]*?(?=(\uff08\u4e8c\uff09\u4f5c\u4e1a\u533a))")) { model.AirlineText = Regex.Match(fileText, @"(?<=(\uff08\u4e00\uff09\u822a\u7ebf))[.\s\S]*?(?=(\uff08\u4e8c\uff09\u4f5c\u4e1a\u533a))").Value; } MatchCollection areaMatch = Regex.Matches(model.AirlineText, @"(?<=[1-9\uff1a][\.\u3001\r])[^\uff1b^\u3002^\;]+"); if (areaMatch.Count > 0) { var i = 0; foreach (Match area in areaMatch) { if (i == 0) { i++; continue; } try { var areaval = area.Value.Split('-'); AirlineVM airvm = new AirlineVM(); foreach (var item in areaval) { string airlineName = "", lngAndLat = ""; if (Regex.IsMatch(item, "^[\u4e00-\u9fa5_a-zA-Z0-9]+")) { airlineName = Regex.Match(item, "^[\u4e00-\u9fa5_a-zA-Z0-9]+").Value; } if (Regex.IsMatch(item, FileAnalysisReg.lngAndLat)) { lngAndLat = Regex.Match(item, FileAnalysisReg.lngAndLat).Value; } airvm.pointList.Add(new PointVM() { Name = airlineName, LatLong = lngAndLat }); } if (airvm.pointList.Count > model.airLineMaxCol) { model.airLineMaxCol = airvm.pointList.Count; } //高度 if (Regex.IsMatch(area.Value, @"(?<=(\u9ad8\u5ea6))[.\s\S]*?(?=(\u7c73))")) { airvm.FlyHeight = Regex.Match(area.Value, @"(?<=(\u9ad8\u5ea6))[.\s\S]*?(?=(\u7c73))").Value; } model.airlineList.Add(airvm); } catch (Exception ex) { } } } #endregion #region 作业区 if (Regex.IsMatch(fileText, @"(?<=(\uff08\u4e8c\uff09\u4f5c\u4e1a\u533a))[.\s\S]*?(?=(\u4e94\u3001\u5b89\u5168\u8d23\u4efb))")) { model.WorkText = Regex.Match(fileText, @"(?<=(\uff08\u4e8c\uff09\u4f5c\u4e1a\u533a))[.\s\S]*?(?=(\u4e94\u3001\u5b89\u5168\u8d23\u4efb))").Value.Trim(); } MatchCollection areaMatch1 = Regex.Matches(model.WorkText, @"(?<=[1-9\uff1a][\.\u3001\r])[^\uff1b^\u3002^\;]+"); if (areaMatch1.Count > 0) { var i = 0; foreach (Match area in areaMatch1) { if (i < 1) { i++; continue; } #region 作业区(圆) try { if (area.Value.Contains("为圆心半径") && Regex.IsMatch(area.Value, @"(?<=(\u4e3a\u5706\u5fc3\u534a\u5f84))[.\s\S]*?(?=(\u516c\u91cc\u8303\u56f4\u5185))")) { var areaval = area.Value.Split('-'); WorkVM workvm = new WorkVM(); foreach (var item in areaval) { string workName = "", lngAndLat = ""; if (Regex.IsMatch(item, "^[\u4e00-\u9fa5_a-zA-Z0-9]+")) { workName = Regex.Match(item, "^[\u4e00-\u9fa5_a-zA-Z0-9]+").Value.Replace("以", ""); } if (Regex.IsMatch(item, FileAnalysisReg.lngAndLat)) { lngAndLat = Regex.Match(item, FileAnalysisReg.lngAndLat).Value; } workvm.pointList.Add(new PointVM() { Name = workName, LatLong = lngAndLat }); } //半径 if (Regex.IsMatch(area.Value, @"(?<=(\u4e3a\u5706\u5fc3\u534a\u5f84))[.\s\S]*?(?=(\u516c\u91cc\u8303\u56f4\u5185))")) { workvm.Raidus = Regex.Match(area.Value, @"(?<=(\u4e3a\u5706\u5fc3\u534a\u5f84))[.\s\S]*?(?=(\u516c\u91cc\u8303\u56f4\u5185))").Value; } //高度 if (Regex.IsMatch(area.Value, @"(?<=(\u9ad8\u5ea6))[.\s\S]*?(?=(\u7c73))")) { workvm.FlyHeight = Regex.Match(area.Value, @"(?<=(\u9ad8\u5ea6))[.\s\S]*?(?=(\u7c73))").Value; } model.cworkList.Add(workvm); } } catch { } #endregion #region 作业区(点) try { if (area.Value.Contains("连线范围")) { var areaval = area.Value.Split('-'); WorkVM workvm = new WorkVM(); foreach (var item in areaval) { string workName = "", lngAndLat = ""; if (Regex.IsMatch(item, "^[\u4e00-\u9fa5_a-zA-Z0-9]+")) { workName = Regex.Match(item, "^[\u4e00-\u9fa5_a-zA-Z0-9]+").Value; } if (Regex.IsMatch(item, FileAnalysisReg.lngAndLat)) { lngAndLat = Regex.Match(item, FileAnalysisReg.lngAndLat).Value; } workvm.pointList.Add(new PointVM() { Name = workName, LatLong = lngAndLat }); } if (workvm.pointList.Count > model.pworkMaxCol) { model.pworkMaxCol = workvm.pointList.Count; } //高度 if (Regex.IsMatch(area.Value, @"(?<=(\u9ad8\u5ea6))[.\s\S]*?(?=(\u7c73))")) { workvm.FlyHeight = Regex.Match(area.Value, @"(?<=(\u9ad8\u5ea6))[.\s\S]*?(?=(\u7c73))").Value; } model.pworkList.Add(workvm); } } catch { } #endregion #region 作业区(线) try { if (area.Value.Contains("航线左右") && Regex.IsMatch(area.Value, @"(?<=(\u822a\u7ebf\u5de6\u53f3))[.\s\S]*?(?=(\u516c\u91cc\u8303\u56f4\u5185))")) { var areaval = area.Value.Split('-'); WorkVM workvm = new WorkVM(); foreach (var item in areaval) { string airportName = "", lngAndLat = ""; if (Regex.IsMatch(item, "^[\u4e00-\u9fa5_a-zA-Z0-9]+")) { airportName = Regex.Match(item, "^[\u4e00-\u9fa5_a-zA-Z0-9]+").Value; } if (Regex.IsMatch(item, FileAnalysisReg.lngAndLat)) { lngAndLat = Regex.Match(item, FileAnalysisReg.lngAndLat).Value; } workvm.pointList.Add(new PointVM() { Name = airportName, LatLong = lngAndLat }); } if (workvm.pointList.Count > model.hworkMaxCol) { model.hworkMaxCol = workvm.pointList.Count; } //距离(航线左右--公里范围) if (Regex.IsMatch(area.Value, @"(?<=(\u9ad8\u5ea6))[.\s\S]*?(?=(\u7c73))")) { workvm.Raidus = Regex.Match(area.Value, @"(?<=(\u822a\u7ebf\u5de6\u53f3))[.\s\S]*?(?=(\u516c\u91cc\u8303\u56f4))").Value; } //高度 if (Regex.IsMatch(area.Value, @"(?<=(\u9ad8\u5ea6))[.\s\S]*?(?=(\u7c73))")) { workvm.FlyHeight = Regex.Match(area.Value, @"(?<=(\u9ad8\u5ea6))[.\s\S]*?(?=(\u7c73))").Value; } model.hworkList.Add(workvm); } } catch { } #endregion } ; } #endregion } Response.Clear(); Response.Write(JsonConvert.SerializeObject(model)); Response.ContentType = "application/json"; Response.End(); }
/// <summary> /// 临时计划 /// </summary> private void GetData1() { var planid = Request.Form["id"]; FlightPlanVM model = new FlightPlanVM(); var data = bll.Get(Guid.Parse(planid)); if (data != null) { model.FillObject(data); var filemasterList = bll.GetFileFlightPlanMasterList(u => u.FlightPlanID.Equals(planid)).Select(u => u.MasterID); var masterList = rpbll.GetFileMasterList(u => filemasterList.Contains(u.ID)); var airlinelist = masterList.Where(u => u.WorkType.Equals("airline")); if (airlinelist != null && airlinelist.Any()) { foreach (var item in airlinelist) { var airlinevm = new AirlineVM(); airlinevm.FlyHeight = item.FlyHeight; var detailList = rpbll.GetFileDetailList(o => o.MasterID == item.ID); airlinevm.pointList.AddRange(detailList.Select(u => new PointVM() { Name = u.PointName, LatLong = (!string.IsNullOrEmpty(u.Latitude) && !string.IsNullOrEmpty(u.Longitude)) ? string.Concat("N", SpecialFunctions.ConvertDigitalToDegrees(u.Latitude), "E", SpecialFunctions.ConvertDigitalToDegrees(u.Longitude)) : "" })); if (airlinevm.pointList.Count > model.airLineMaxCol) { model.airLineMaxCol = airlinevm.pointList.Count; } model.airlineList.Add(airlinevm); model.airlineworkList.Add(item.ID); } ; } var worklist = masterList.Where(u => u.WorkType.Equals("circle") || u.WorkType.Equals("airlinelr") || u.WorkType.Equals("area")); if (worklist != null && worklist.Any()) { foreach (var item in worklist) { var workvm = new WorkVM(); workvm.FlyHeight = item.FlyHeight; workvm.Raidus = (item.RaidusMile ?? 0).ToString(); var detailList = rpbll.GetFileDetailList(o => o.MasterID == item.ID); workvm.pointList.AddRange(detailList.Select(u => new PointVM() { Name = u.PointName, LatLong = (!string.IsNullOrEmpty(u.Latitude) && !string.IsNullOrEmpty(u.Longitude)) ? string.Concat("N", SpecialFunctions.ConvertDigitalToDegrees(u.Latitude), "E", SpecialFunctions.ConvertDigitalToDegrees(u.Longitude)) : "" })); switch (item.WorkType.ToLower()) { case "circle": model.cworkList.Add(workvm); model.airlineworkList.Add(item.ID); break; case "airlinelr": if (workvm.pointList.Count > model.hworkMaxCol) { model.hworkMaxCol = workvm.pointList.Count; } model.hworkList.Add(workvm); model.airlineworkList.Add(item.ID); break; case "area": if (workvm.pointList.Count > model.pworkMaxCol) { model.pworkMaxCol = workvm.pointList.Count; } model.pworkList.Add(workvm); model.airlineworkList.Add(item.ID); break; default: break; } } ; } } Response.Write(JsonConvert.SerializeObject(model)); Response.ContentType = "application/json"; Response.End(); }
public ActionResult GetComments(WorkVM work) { HttpCookie cookieReqs = Request.Cookies["Localhost cookie"]; int idsWork = work.Id; int idsUser = 0; if (cookieReqs != null) { idsUser = Convert.ToInt32(cookieReqs["ids"]); } else { FormsAuthentication.SignOut(); } if (work.UserId != 0) { RatingBL userRatingForWork = ratingBL.GetRatings().Where(x => x.UserId == idsUser && x.WorkId == idsWork).FirstOrDefault(); RatingBL newRating = new RatingBL { Rank = work.UserId, UserId = idsUser, WorkId = idsWork }; if (userRatingForWork != null) { RatingBL old = ratingBL.GetRating(userRatingForWork.Id); ratingBL.DeleteRating(old.Id); ratingBL.Create(newRating); } else { ratingBL.Create(newRating); } } if (work.Name != null) { CommentBL newComment = new CommentBL(); newComment.Comment = work.Name; newComment.UserId = idsUser; newComment.WorkId = idsWork; CommentBL test = commentBL.GetComments().Where(x => x.UserId == idsUser && x.WorkId == idsWork).FirstOrDefault(); if (null != commentBL.GetComments().Where(x => x.UserId == idsUser && x.WorkId == idsWork).FirstOrDefault()) { CommentBL old = commentBL.GetComment(test.Id); commentBL.DeleteComment(old.Id); commentBL.Create(newComment); } else { commentBL.Create(newComment); } } var commentList = commentBL.GetComments().Join(workBL.GetWorks(), c => c.WorkId, w => w.Id, (c, w) => new { Id = c.Id, Comment = c.Comment, UserId = c.UserId, WorkId = c.WorkId }).Join(userBL.GetUsers(), c => c.UserId, u => u.Id, (c, u) => new UserWithCommentVM { Id = c.Id, UserName = u.Login, Comment = c.Comment, WorkId = c.WorkId, IsDelete = u.IsDelete }).ToList(); foreach (var item in commentList) { if (item.IsDelete == true) { item.UserName = "******"; } } ViewBag.CommentsList = commentList.Where(c => c.WorkId == idsWork).ToList(); List <RatingBL> lst = ratingBL.GetRatings().Where(x => x.WorkId == idsWork).Join(userBL.GetUsers(), c => c.UserId, u => u.Id, (c, u) => new RatingBL { Id = c.Id, Rank = c.Rank, UserId = c.UserId, WorkId = c.WorkId, IsDeleteCheck = u.IsDelete }).Where(x => x.IsDeleteCheck == false).ToList(); if (lst.Count != 0) { int sum = 0; int rating = 0; foreach (var item in lst) { sum += item.Rank; } rating = sum / lst.Count; ViewBag.Ratings = rating; } else { ViewBag.Ratings = 0; } return(View("_CommentsTable")); }