/// <summary> /// 系统公告 /// </summary> /// <returns>弹出“系统公告”窗口</returns> public ActionResult Notice() { // 1.获取服务器端公告标识 string noticeFolder = Server.MapPath("~/Content/Notice"); string serverNoticeFile = Directory.GetFiles(noticeFolder, "Notice_*.txt", SearchOption.TopDirectoryOnly).OrderBy(f => System.IO.File.GetCreationTime(f)).FirstOrDefault(); if (string.IsNullOrEmpty(serverNoticeFile)) { // 不显示公告 return(null); } // 2.获取客户端公告标识 string clientNoticeFile = Request.Cookies[SysContext.ConstKeys.Cookie_Notice] != null ? Request.Cookies[SysContext.ConstKeys.Cookie_Notice].Value : string.Empty; if (serverNoticeFile == clientNoticeFile) { return(null); } // 3.显示公告 NoticeViewModel model = new NoticeViewModel(); model.NoticeTime = System.IO.File.GetCreationTime(serverNoticeFile); model.NoticeContent = System.IO.File.ReadAllText(serverNoticeFile); // 4.更新客户端公告标识 HttpCookie noticeCookie = new HttpCookie(SysContext.ConstKeys.Cookie_Notice, serverNoticeFile); noticeCookie.HttpOnly = true; noticeCookie.Expires = DateTime.Now.AddDays(3); // 公告保留时间 Response.Cookies.Add(noticeCookie); return(PartialView(model)); }
public void EditNotice(NoticeViewModel notice) { var dbNotice = _buotDb.Notice.FirstOrDefault(n => n.Id == notice.Id); if (!dbNotice.Title.Equals(notice.Title)) { dbNotice.Title = notice.Title; } if (!dbNotice.ImageUrl.Equals(notice.ImageUrl)) { dbNotice.ImageUrl = notice.ImageUrl; } if (!dbNotice.Description.Equals(notice.Description)) { dbNotice.Description = notice.Description; } if (!dbNotice.Content.Equals(notice.Content)) { dbNotice.Content = notice.Content; } _buotDb.SaveChanges(); }
public async Task <IActionResult> Notice(int?page, int?searchtype, string query) { if (!page.HasValue) { page = 1; } else if (page.Value == 0) { page = 1; } NoticeViewModel searchModel = new NoticeViewModel(); searchModel.PageNumber = page.Value; if (!string.IsNullOrWhiteSpace(query)) { searchModel.NoticeSearchCriteria.SearchType = (SearchType)searchtype.Value; searchModel.NoticeSearchCriteria.SearchString = query; } searchModel = await _noticeViewModel.SearchNotices(searchModel); return(View(searchModel)); }
public ActionResult GetContractNotice(Guid contractGuid, string searchValue, int pageSize, int skip, int take, string sortField, string dir) { try { var contractNotices = _contractNoticeService.GetContractNoticeByContractId(contractGuid, searchValue, pageSize, skip, take, sortField, dir); List <NoticeViewModel> list = new List <NoticeViewModel>(); foreach (var data in contractNotices) { NoticeViewModel notice = new NoticeViewModel(); notice.Attachment = HttpUtility.HtmlDecode(data.Attachment); notice.IssuedDate = data.IssuedDate?.ToString("MM/dd/yyyy"); notice.LastUpdatedDate = data.LastUpdatedDate.ToString("MM/dd/yyyy"); notice.NoticeDescription = data.NoticeDescription; notice.UpdatedBy = data.UpdatedBy; notice.ResourceGuid = data.ResourceGuid; notice.ContractNoticeGuid = data.ContractNoticeGuid; notice.NoticeType = data.NoticeType; notice.Resolution = data.Resolution; list.Add(notice); } return(Ok(new { result = list, count = _contractNoticeService.GetNoticeCount(contractGuid) })); } catch (Exception ex) { ModelState.Clear(); ModelState.AddModelError("", ex.Message); return(BadRequestFormatter.BadRequest(this, ex)); } }
public JsonResult AddClassNotice(NoticeViewModel newNotice) { var reJson = new JsonReMsg(); //判断是否具有权限 if (GuserInfo.UserType != 1) { reJson.Status = "ERR"; reJson.Msg = "没有发布公告权限"; } else { var addresult = _classInfoService.AddClassNotice(GuserInfo.CurrentClass.Id, Mapper.Map <NoticeInput>(newNotice)); if (addresult.Status) { reJson.Status = "OK"; reJson.Data = Mapper.Map <List <NoticeViewModel> >(_classInfoService.GetAllNotices(GuserInfo.CurrentClass.Id)); } else { //删除失败 reJson.Status = "ERR"; reJson.Msg = addresult.Msg; reJson.Data = addresult.Data; } } return(Json(reJson, JsonRequestBehavior.AllowGet)); }
public async Task <IActionResult> Edit(Guid id, NoticeViewModel viewModel) { if (ModelState.IsValid) { try { Notice notice = viewModel.Notice; notice.Category = _categoryAdminManager.FindById(viewModel.CategoryId).Result; notice.Creator = _userAdminManager.FindById(viewModel.CreatorId); await _noticesAdminManager.Update(notice); } catch (DbUpdateConcurrencyException) { if (!_noticesAdminManager.NoticeExists(viewModel.Notice.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } NoticeViewModel viewModelClear = new NoticeViewModel { Notice = new Notice(), Categories = _categoryAdminManager.findAll(), Users = _userAdminManager.FindAll() }; return(View(viewModelClear)); }
public ActionResult Visualize(long noticeId, Guid userId) { var noticeRepository = new NoticeRepository(_context); var notSeenNotices = noticeRepository.ListNotSeenNotices(userId); var userNotice = new UserNotice { VisualizationDateTime = DateTime.Now, NoticeId = noticeId, UserId = userId }; _context.GetList <UserNotice>().Add(userNotice); _context.Save(); var dateTimeHumanizerStrategy = new DefaultDateTimeHumanizeStrategy(); var nextNotice = noticeRepository.ListNotSeenNotices(userId).Except(notSeenNotices).FirstOrDefault(); if (nextNotice != null) { return(Json(NoticeViewModel.FromEntity(nextNotice, dateTimeHumanizerStrategy))); } return(new EmptyResult()); }
public async Task <ActionResult> Edit(NoticeViewModel vm) { using (NoticeManager nm = new NoticeManager()) { var postedBy = await nm.PostedBy(vm.Id); var current = await User.Identity.GetApplicationUserAsync(); var notice = await nm.GetAsync(vm.Id); if (notice.Status == NoticeStatus.Approved) { return(Json(JsonViewModel.Error)); } if ((postedBy.Id == current.Id && notice.IsPendingApproval) || await User.Identity.IsModeratorAsync()) { notice.NoticeId = vm.Id; notice.HighPriority = vm.isHighPriority; notice.NoticeBoardId = vm.NoticeBoardId; notice.Title = vm.Title; notice.Description = vm.Description; notice.Status = NoticeStatus.PendingApproval; var res = await nm.UpdateAsync(notice); //if (res > 0) ; // return Json(JsonViewModel.Success); } } // return Json(JsonViewModel.Error); return(RedirectToAction("Index", "MyPosts")); }
public async void InitDefaultView() { //初始化工具栏,通知窗口 await Task.Run(() => { _PopBoxView = new PopBoxViewModel(); _NoticeView = new NoticeViewModel(); //加载窗体模块 _ModuleManager = new ModuleManager(); //await _ModuleManager.LoadModules(); //设置系统默认首页 }); var page = OpenPageCollection.FirstOrDefault(t => t.HeaderName.Equals("系统首页")); if (page == null) { //演示Demo加载默认首页,较消耗性能。 实际开发务移除患者更新开发部件。 HomePage about = new HomePage(); OpenPageCollection.Add(new PageInfo() { HeaderName = "系统首页", Body = about }); CurrentPage = OpenPageCollection[OpenPageCollection.Count - 1]; } }
public async Task <IActionResult> Index(int page = 1) { double totalCount = await _context.Categories.CountAsync(); int pageCount = (int)Math.Ceiling(totalCount / 5); if (page < 1) { page = 1; } else if (page > pageCount) { page = pageCount; } ViewBag.PageCount = pageCount; ViewBag.SelectedPage = page; NoticeViewModel noticeVM = new NoticeViewModel { Notices = await _context.Notices.Skip((page - 1) * 5).Take(5).ToListAsync() }; return(View(noticeVM)); }
public async Task <IActionResult> Edit(Guid id, NoticeViewModel viewModel) { if (ModelState.IsValid) { try { IdentityUser user = await _userManager.GetUserAsync(HttpContext.User).ConfigureAwait(false); Notice notice = viewModel.Notice; notice.Category = _categoryManager.FindById(viewModel.CategoryId); await _noticesManager.Update(notice, user); } catch (DbUpdateConcurrencyException) { if (!_noticesManager.NoticeExists(viewModel.Notice.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index", "Home")); } NoticeViewModel viewModelClear = new NoticeViewModel { Notice = new Notice(), Categories = _categoryManager.FindAll().Result, Users = _siteUserManager.findAll() }; return(View(viewModelClear)); }
public IHttpActionResult GetMemberNotice(int memberId) { try { bool isSent = false; bool isOpen = false; List <NoticeViewModel> noticeListVM = new List <NoticeViewModel>(); IEnumerable <MemberNotice> notice = new List <MemberNotice>(); notice = _memberNotice.GetAllMemeberNotice(memberId, isSent, isOpen); if (notice != null) { foreach (MemberNotice note in notice) { NoticeViewModel noticeVM = new NoticeViewModel(); noticeVM.Content = note.Notice.Content; noticeVM.NoticeCode = note.Notice.NoticeCode; noticeVM.ID = note.Notice.ID; noticeVM.Type = note.Notice.Type; noticeListVM.Add(noticeVM); } } var messageData = new { code = Constant.SuccessMessageCode, message = Constant.MessageSuccess }; var returnObject = new { notice = noticeListVM, messageCode = messageData }; return(Ok(returnObject)); } catch (Exception ex) { string errorLogId = _eventLog.WriteLogs(User.Identity.Name, ex, MethodBase.GetCurrentMethod().Name); var messageData = new { code = Constant.ErrorMessageCode, message = String.Format(Constant.MessageTaskmateError, errorLogId) }; var returnObject = new { messageCode = messageData }; return(Ok(returnObject)); } }
/// <summary> /// 系统公告 /// </summary> /// <returns>弹出“系统公告”窗口</returns> public ActionResult Notice() { // 1.获取服务器端公告标识 string noticeFolder = Server.MapPath("~/Content/Notice"); string serverNoticeFile = Directory.GetFiles(noticeFolder, "Notice_*.txt", SearchOption.TopDirectoryOnly).OrderBy(f => System.IO.File.GetCreationTime(f)).FirstOrDefault(); if (string.IsNullOrEmpty(serverNoticeFile)) { // 不显示公告 return null; } // 2.获取客户端公告标识 string clientNoticeFile = Request.Cookies[SysContext.ConstKeys.Cookie_Notice] != null ? Request.Cookies[SysContext.ConstKeys.Cookie_Notice].Value : string.Empty; if (serverNoticeFile == clientNoticeFile) { return null; } // 3.显示公告 NoticeViewModel model = new NoticeViewModel(); model.NoticeTime = System.IO.File.GetCreationTime(serverNoticeFile); model.NoticeContent = System.IO.File.ReadAllText(serverNoticeFile); // 4.更新客户端公告标识 HttpCookie noticeCookie = new HttpCookie(SysContext.ConstKeys.Cookie_Notice, serverNoticeFile); noticeCookie.HttpOnly = true; noticeCookie.Expires = DateTime.Now.AddDays(3); // 公告保留时间 Response.Cookies.Add(noticeCookie); return PartialView(model); }
public NoticeDetailPage(int Id) { InitializeComponent(); BindingContext = new NoticeViewModel { SelectedId = Id }; ((NoticeViewModel)BindingContext).GetNoticeComand.Execute(null); }
public ActionResult NoticePanel() { var repo = new NoticeRepository(_context); var notices = repo.ListNotSeenNotices(_loggedUser.Id); var dateTimeHumanizerStrategy = new DefaultDateTimeHumanizeStrategy(); return(PartialView("_NoticePanel", NoticeViewModel.FromEntityList(notices, dateTimeHumanizerStrategy))); }
public ActionResult Preview(NoticeViewModel model) { if (ModelState.IsValid) { return(View(model)); } return(View()); }
public ActionResult Create([FromForm] NoticeViewModel model) { if (!ModelState.IsValid) { return(View(model)); } try { //notice var n = new Notice() { NoticeId = Guid.NewGuid(), CheckStatus = true, //默认审核通过 NoticeContent = model.Content, NoticeTitle = model.Title, NoticeCustomPath = model.CustomPath, NoticePublisher = UserName, NoticePublishTime = DateTime.UtcNow, UpdateBy = UserName, UpdateTime = DateTime.UtcNow }; // if (!string.IsNullOrEmpty(n.NoticeCustomPath)) { if (n.NoticeCustomPath.EndsWith(".html")) { n.NoticeCustomPath = n.NoticeCustomPath.Substring(0, n.NoticeCustomPath.Length - 5); // trim end ".html" } } else { n.NoticeCustomPath = DateTime.UtcNow.ToString("yyyyMMddHHmmss"); } var existStatus = _bLLNotice.Exist(nx => nx.NoticeCustomPath.ToLower().Equals(n.NoticeCustomPath.ToLower())); if (existStatus) { n.NoticeCustomPath = DateTime.UtcNow.ToString("yyyyMMddHHmmss"); } n.NoticePath = $"{n.NoticeCustomPath}.html"; var c = _bLLNotice.Insert(n); if (c == 1) { OperLogHelper.AddOperLog($"{UserName}添加新公告,{n.NoticeTitle},ID:{n.NoticeId:N}", OperLogModule.Notice, UserName); return(RedirectToAction("Index")); } else { return(View(model)); } } catch (Exception ex) { Logger.Error(ex); throw; } }
public async Task <NoticeModel> GetTroubleView() { var model = new NoticeViewModel(); model.Text = await LoadConfigFile(_options.Authentication.TroubleFile) ?? "Under construction."; return(model); }
/// <summary> /// 系统通知页 /// </summary> /// <param name="model"></param> /// <returns></returns> public ActionResult Notice(NoticeViewModel model) { var queryRst = MiddleTier.NoticeManager.Query(new NoticeQuery { PageIndex = model.PageIndex, PageSize = model.PageSize, Title = model.Text }); model.Notices = queryRst; return(View(model)); }
public IActionResult Index() { int id = int.Parse(User.FindFirst(x => x.Type == System.Security.Claims.ClaimTypes.NameIdentifier).Value); var model = new NoticeViewModel { Notices = _noticeService.GetAllInclude(id) }; return View(model); }
public IActionResult Edit(int id) { var model = new NoticeViewModel { Notice = _noticeService.GetById(id) }; return(View(model)); }
public ActionResult Post(int id) { NoticeViewModel vm = new NoticeViewModel { NoticeBoardId = id }; return(View(vm)); }
public ActionResult Create(NoticeViewModel model) { if (!ModelState.IsValid) { return(View()); } try { //notice var n = new Notice() { NoticeId = Guid.NewGuid(), CheckStatus = true, //默认审核通过 NoticeContent = model.Content, NoticeTitle = model.Title, NoticeCustomPath = model.CustomPath, NoticePublisher = Username, NoticePublishTime = DateTime.Now, UpdateBy = Username, UpdateTime = DateTime.Now }; // if (!string.IsNullOrEmpty(n.NoticeCustomPath)) { if (n.NoticeCustomPath.EndsWith(".html")) { n.NoticePath = n.NoticeCustomPath; } else { n.NoticePath = n.NoticeCustomPath + ".html"; } } else { n.NoticePath = DateTime.Now.ToString("yyyyMMddHHmmss") + ".html"; } var c = BusinessHelper.NoticeHelper.Add(n); if (c == 1) { OperLogHelper.AddOperLog($"{Username}添加新公告,{n.NoticeTitle},ID:{n.NoticeId:N}", OperLogModule.Notice, Username); return(RedirectToAction("Index")); } else { return(View()); } } catch (Exception ex) { Logger.Error(ex); throw; } }
//Inspector public void AddNotice(string message, string url, string linkText) { var notice = new NoticeViewModel { NoticeText = message, NoticeHyperlinkUrl = url, NoticeHyperlinkText = linkText }; _inspectorWindow.Dispatcher.BeginInvoke((System.Windows.Forms.MethodInvoker) delegate { Notices.Add(notice); }); }
public async Task <NoticeModel> GetNoticeView(string returnUrl, string next = "Login") { var model = new NoticeViewModel { ReturnUrl = returnUrl, Next = next }; model.Text = await LoadConfigFile(_options.Authentication.NoticeFile) ?? "This site uses cookies to manage authentication."; return(model); }
public async Task <ActionResult> Post(NoticeViewModel vm) { if (ModelState.IsValid) { NoticeManager nm = new NoticeManager(); await nm.AddAsync(NoticeMappings.From(vm), await this.User.Identity.GetApplicationUserAsync()); return(RedirectToAction("View", new { id = vm.NoticeBoardId })); } return(View(vm)); }
public async Task <IActionResult> Notice(NoticeViewModel model) { if (model.NoticeSearchCriteria != null && !string.IsNullOrWhiteSpace(model.NoticeSearchCriteria.SearchString)) { model.PageNumber = 1; return(RedirectToAction("Notice", new { page = 1, searchtype = (int)model.NoticeSearchCriteria.SearchType, query = model.NoticeSearchCriteria.SearchString })); } else { model.Notices.CurrentPage = 1; return(RedirectToAction("Notice", new { page = 1, searchtype = SearchType.Title, query = "" })); } }
public async Task <ActionResult> Off([FromBody] NoticeViewModel model) { var notice = await _noticesService.GetByIdAsync(model.Id); if (notice == null) { return(NotFound()); } notice.Order = -1; await _noticesService.UpdateAsync(notice); return(Ok()); }
public NoticePage() { try { InitializeComponent(); this.Title = "Notice Board"; _NoticeViewModel = new NoticeViewModel(); BindingContext = _NoticeViewModel; } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public static Notice MapEntity(this NoticeViewModel model, IMapper mapper, string currentUserId) { var entity = mapper.Map <NoticeViewModel, Notice>(model); if (model.Id == 0) { entity.SetCreated(currentUserId); } else { entity.SetUpdated(currentUserId); } return(entity); }
public ActionResult ListNoticeHistory(DateTime?startDate, DateTime?endDate, NoticeType noticeType = NoticeType.All, int page = 1) { var range = new DateRange { StartDate = startDate, EndDate = endDate }; var historyService = new HistoryService(_context, new DefaultDateTimeHumanizeStrategy()); return(Json( NoticeViewModel.FromEntityList(historyService.SearchNotices(range, page, _loggedUser.Id, noticeType)), JsonRequestBehavior.AllowGet)); }