public void CheckOnChangedAction() { var changed = new List<string>(); var changing = new List<string>(); var notifyViewModel = new NotifyViewModel(changed, changing); const string PropertyName = "Property"; var dependent = new Dictionary<string, string[]>(); Action<string, string[]> addToDependent = dependent.Add; var property = new ViewModelProperty<int>(notifyViewModel, addToDependent, PropertyName); var viewModelProperty = (IViewModelProperty<int>)property; var values = new List<int>(); viewModelProperty.OnChanged(values.Add); const int Value = 10; property.SetValue(Value, false).Should().Be.True(); property.Changed(() => Value); changing.Should().Have.SameSequenceAs(PropertyName); changed.Should().Have.SameSequenceAs(PropertyName); values.Should().Have.SameSequenceAs(Value); }
public NotificationView(Context context, IWindowManager windowManager, NotifyViewModel viewModel) : base(context) { _windowManager = windowManager; _viewModel = viewModel; Initialize(); }
public ActionResult Notify(string Zip) { NotifyViewModel model = new NotifyViewModel(); model.Zip = Zip; return(View(model)); }
public void CheckOnChangedAction() { var changed = new List <string>(); var changing = new List <string>(); var notifyViewModel = new NotifyViewModel(changed, changing); const string PropertyName = "Property"; var dependent = new Dictionary <string, string[]>(); Action <string, string[]> addToDependent = dependent.Add; var property = new ViewModelProperty <int>(notifyViewModel, addToDependent, PropertyName); var viewModelProperty = (IViewModelProperty <int>)property; var values = new List <int>(); viewModelProperty.OnChanged(values.Add); const int Value = 10; property.SetValue(Value, false).Should().BeTrue(); property.Changed(() => Value); changing.Should().BeEquivalentTo(PropertyName); changed.Should().BeSameAs(new[] { PropertyName }); values.Should().BeSameAs(new[] { Value }); }
public async void Notify(NotifyViewModel viewModel) { var compactViewId = 0; await CoreApplication.CreateNewView().Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { var applicationView = ApplicationView.GetForCurrentView(); compactViewId = applicationView.Id; var appTitleBar = applicationView.TitleBar; appTitleBar.ButtonBackgroundColor = Colors.White; appTitleBar.ButtonForegroundColor = Colors.White; appTitleBar.ButtonHoverBackgroundColor = Colors.White; appTitleBar.ButtonHoverForegroundColor = Colors.White; appTitleBar.ButtonInactiveBackgroundColor = Colors.White; appTitleBar.ButtonInactiveForegroundColor = Colors.White; appTitleBar.ButtonPressedBackgroundColor = Colors.White; appTitleBar.ButtonPressedForegroundColor = Colors.White; var notifyPage = new NotifyPage(viewModel); Window.Current.Content = notifyPage; //Window.Current.SetTitleBar(notifyPage); Window.Current.Activate(); CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true; }); bool viewShown = await ApplicationViewSwitcher.TryShowAsViewModeAsync(compactViewId, ApplicationViewMode.CompactOverlay); }
public void TestSetRestDesc() { var notifyModel = new NotifyViewModel(null, null); notifyModel.SetRestDesc(); Assert.AreEqual("Please Take A Rest, Times Remain: 10s", notifyModel.RestDesc); }
// GET: Services/Edit/5 public ActionResult Notify(int?id) { if (id == null) { return(View("NotFound")); } Service service = db.Services.Find(id); if (service == null) { return(View("NotFound")); } if (!Authorize(service.FuneralHome)) { return(View("NotFound")); } NotifyViewModel notify = new NotifyViewModel(); notify.Id = service.Id; notify.IsSecured = service.IsSecured; notify.ContactEmail = service.ContactEmail; notify.FirstName = service.FirstName; notify.LastName = service.LastName; return(View(notify)); }
public NotifyPageViewModel(NotifyViewModel vm) { Text = vm.Text; Action = new Command(() => { Window.Current.Close(); vm.Action(); }); }
public NotificationPage() { InitializeComponent(); BindingContext = notifyViewModel = new NotifyViewModel(this); //android icon kaldırma if (Device.RuntimePlatform == Device.Android) { DependencyService.Get <IRemoveIcon>().removeIcon(false, "Bildirimler"); } }
public MainViewModel() { notifyViewModel = new NotifyViewModel(); currentCurrencyEnum = CurrencyEnum.dollars; dataManagement = new DataManagement(currentCurrencyEnum); currenciesPreviewViewModel = new CurrenciesPreviewViewModel(dataManagement); GoToPreviewsCommand = new RelayCommand(GoToPreviews, CanExecuteGoToPreviews); GoToNotifyCommand = new RelayCommand(GoToNotify, CanExecuteGoToNotify); currentContentViewModel = currenciesPreviewViewModel; currenciesPreviewViewModel.ShowMoreAboutCurrency += new CurrenciesPreviewViewModel.SeeMoreAboutCurrencyDelegate(ChangeViewToCurrencyInfo); }
public ActionResult Notify(NotifyViewModel notify) { if (ModelState.IsValid) { Service service = db.Services.Find(notify.Id); if (notify.IsSecured == true) { string userName = service.FirstName + service.LastName + service.Id.ToString(); userName = userName.Replace(" ", ""); var currentUser = UserManager.FindByName(userName); //Delete user if already exists if (currentUser != null) { service.ViewingUserId = null; service.ViewingUser = null; db.Entry(service).State = EntityState.Modified; db.SaveChanges(); UserManager.Delete(currentUser); } ApplicationUser viewingUser = new ApplicationUser(); var rndNum = new Random(DateTime.Now.Second); var rawPW = System.Web.Security.Membership.GeneratePassword(8, 0); rawPW = Regex.Replace(rawPW, @"[^a-zA-Z0-9]", m => rndNum.Next(0, 10).ToString()); viewingUser.UserName = userName; viewingUser.Name = notify.ContactName; UserManager.Create(viewingUser, rawPW); UserManager.AddToRole(viewingUser.Id, "Viewing"); service.ViewingUserId = viewingUser.Id; if (service.Video != null) { //Email.sendFamilyNotificationSecure(service, notify, userName, rawPW); } } else { Email.sendFamilyNotification(service, notify); } service.ContactEmail = notify.ContactEmail; service.IsSecured = notify.IsSecured; db.Entry(service).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(notify)); }
public static void sendFamilyNotification(Service service, NotifyViewModel notification) { try { string serviceUrl = HttpUtility.UrlEncode(notification.ServiceUrl); string message = HttpUtility.UrlEncode(notification.Message); string templatepath = ConfigurationManager.AppSettings["portalPath"] + "/Email/NotifyFamily/" + service.Id + "?message=" + message + "&link=" + serviceUrl; HtmlDocument page = new HtmlWeb().Load(templatepath); string sgUsername = ConfigurationManager.AppSettings["sendGridUsername"]; string sgPassword = ConfigurationManager.AppSettings["sendGridPassword"]; var myMessage = new SendGridMessage(); myMessage.AddTo(notification.ContactEmail); myMessage.From = new MailAddress(notification.FromEmail); string subject = "Service now available"; if (service.FuneralHome != null) { subject = "New Message From " + service.FuneralHome.Name; } myMessage.Subject = subject; string html = page.DocumentNode.OuterHtml; myMessage.Html = html; /* SEND THE MESSAGE * ===================================================*/ var credentials = new NetworkCredential(sgUsername, sgPassword); // Create a Web transport for sending email. var transportWeb = new Web(credentials); // Send the email. SendAsync(myMessage); } catch (Exception e) { string LogFilePath = ConfigurationManager.AppSettings["logFilePath"]; var sr = new StreamWriter(LogFilePath + "familyNotification" + DateTime.Now.ToString() + ".log"); sr.WriteLine("start"); sr.WriteLine("not sent"); sr.WriteLine(e.StackTrace); sr.WriteLine(e.Message); sr.WriteLine(e.InnerException); sr.Close(); } }
public ActionResult Notification() { _viewModel = new NotifyViewModel(); ViewBag.listRequest = _friendService.GetRelationship(User.Identity.GetUserId()).Count; CreateLayoutView("Thông báo"); List <Notification> listNotification = _notificationService.getAllNotification(User.Identity.GetUserId()); foreach (Notification notification in listNotification) { NotificationViewModel notificationViewModel = new NotificationViewModel(); ApplicationUser userT = new ApplicationUser(); userT = _service.GetUserById(notification.Id_User); FieldHelper.CopyNotNullValue(notificationViewModel, userT); FieldHelper.CopyNotNullValue(notificationViewModel, notification); NotifyViewModel.ListNotification.Add(notificationViewModel); } NotifyViewModel.ListNotification.OrderBy(x => x.CreatedDate); ViewBag.listNotification = listNotification.Count - 1; return(PartialView("_Notification", NotifyViewModel)); }
public PartialViewResult NotificationSectionAccount(string username) { NotifyViewModel notify = new NotifyViewModel(); if (username != null) { List <Notification> listNotification = _notificationService.getAllNotification(_service.GetUserByUserName(username).Id); foreach (Notification notification in listNotification) { NotificationViewModel notificationViewModel = new NotificationViewModel(); ApplicationUser userT = new ApplicationUser(); userT = _service.GetUserById(notification.Id_User); FieldHelper.CopyNotNullValue(notificationViewModel, userT); FieldHelper.CopyNotNullValue(notificationViewModel, notification); notify.ListNotification.Add(notificationViewModel); } notify.ListNotification.OrderBy(x => x.CreatedDate); } return(PartialView("_Notify", notify)); }
public async Task <IActionResult> create([FromBody] OrderCreateRequest request) { var orderId = await _orderService.Create(request); if (orderId == 0) { return(BadRequest("Đặt hàng thất bại!")); } var notify = new NotifyViewModel() { notify = $"Có khách vừa mới đặt hàng!", link = "/admin/order-manage/order-not-confirm", //senderId = request.userId.HasValue ? request.userId.Value ? null, receiverId = adminId, isViewed = false, status = enums.NotifyStatus.order, }; await _hubContext.Clients.All.SendAsync("ReceiveNotify", notify); return(Ok("Đặt hàng thành công! Admin sẽ thông báo đến bạn thông qua số điện thoại hoặc gmail! Trân trọng!")); }
public ActionResult Notify(NotifyViewModel model) { ParkNotify request = new ParkNotify { Name = model.Name, Zip = model.Zip, Email = model.Email }; bool success = _serviceFacade.SaveParkNotify(request); ViewBag.success = success; if (!success) { return(View(model)); } else { return(View()); } }
/*public async Task UserOnlineList() * { * var userIdOnlineList = _connections.GetOnlineUsers(); * var userOnlineList = await _chatService.GetUserOnlines(userIdOnlineList); * await Clients.Client(Context.ConnectionId).SendAsync("UserOnlineList", userOnlineList); * }*/ // // public async Task SendMessage(ChatCreateRequest _message) { var messageId = await _chatService.CreateMessage(_message); var message = await _chatService.GetMessageById(messageId); //Receive Message List <string> ReceiverConnectionids = _connections.GetConnections(message.receiverId).ToList <string>(); if (ReceiverConnectionids.Count() > 0) { //Save-Receive-Message try { var notify = new NotifyViewModel() { notify = $"Bạn đã nhận tin nhắn từ {message.sender.displayname}", link = null, senderId = message.senderId, receiverId = message.receiverId, isViewed = false, status = enums.NotifyStatus.chat, }; List <string> connects = _connections.GetConnections(message.receiverId).ToList <string>(); await Clients.All.SendAsync("ReceiveNotify", notify); // ReceiverConnectionids.Add(_message.connectionId); await Clients.Clients(ReceiverConnectionids).SendAsync("ReceiveMessage", message); } catch (Exception) { } } else { await Clients.Client(_message.connectionId).SendAsync("ReceiveMessage", message); } }
public void Notify(NotifyViewModel viewModel) { var windowManager = Application.Context.GetSystemService(Context.WindowService).JavaCast <IWindowManager>(); var theView = new NotificationView(Application.Context, windowManager, viewModel); var param = new WindowManagerLayoutParams( 800, 300, //ViewGroup.LayoutParams.WrapContent, //ViewGroup.LayoutParams.WrapContent, WindowManagerTypes.SystemAlert, WindowManagerFlags.Fullscreen | WindowManagerFlags.WatchOutsideTouch | WindowManagerFlags.AllowLockWhileScreenOn | WindowManagerFlags.NotFocusable, Android.Graphics.Format.Translucent); param.Gravity = GravityFlags.Top | GravityFlags.Right ; windowManager.AddView(theView, param); }
/// <summary> /// 设备控制平台回调 /// </summary> /// <param name="notifyModel"></param> /// <returns></returns> public object SetDeviceNotify(NotifyViewModel notifyModel) { var ret = SingleInstance <DeviceService> .Instance.SetDeviceCallBack(notifyModel); return(OK(ret)); }
public NotifyPage(NotifyViewModel vm) { this.InitializeComponent(); DataContext = new NotifyPageViewModel(vm); //Tapped += (s, e) => vm.Action.Execute(null); }
/// <summary> /// 设备控制回调处理 /// </summary> /// <param name="notifyModel"></param> /// <returns></returns> public BaseRetViewModel SetDeviceCallBack(NotifyViewModel notifyModel) { var ret = new BaseRetViewModel(); return(ret); }
public BaseViewModel() { this.Notify = new NotifyViewModel(); }
private string SendEmail(NotifyViewModel nvm) { string email = ""; string message = ""; string rply = ""; string revieweremail = ""; string approveremail = "*****@*****.**"; //string approveremail = "*****@*****.**"; string recipient = ""; try { switch (nvm.DocumentStatus) { case "For Review": if (nvm.CompanyId == 1) //slpgc { ////gbarroyo revieweremail = "*****@*****.**"; //revieweremail = "*****@*****.**"; } else { ////eccueto revieweremail = "*****@*****.**"; //revieweremail = "*****@*****.**"; } message = "There's a form For Review for area " + nvm.Area + " with Reference No: " + nvm.ReferenceNo; break; case "For Approval": message = "There's a form For Approval for area " + nvm.Area + " with Reference No: " + nvm.ReferenceNo; break; default: break; } string msg = "Hi, <br /><br />" + message + " <br /><br />"; var body = msg; MailMessage mail = new MailMessage(); mail.From = new MailAddress("*****@*****.**", "Safety Equipment Monitoring System"); if (nvm.DocumentStatus == "For Review") { mail.To.Add(new MailAddress(revieweremail)); //mail.To.Add(new MailAddress("*****@*****.**")); recipient = revieweremail; } else { mail.To.Add(new MailAddress(approveremail)); recipient = approveremail; } mail.Bcc.Add(new MailAddress("*****@*****.**")); mail.Bcc.Add(new MailAddress("*****@*****.**")); mail.Subject = "Safety Equipment Monitoring System" + " - " + nvm.DocumentStatus.ToUpper(); mail.Body = string.Format(body + " Click on this link to view details. http://192.168.30.182/SEM/"); mail.IsBodyHtml = true; using (var smtp = new SmtpClient()) //mail server { try { smtp.Host = "mail.cpcaccess.com"; smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "System@1"); smtp.Port = 587; smtp.EnableSsl = false; smtp.Send(mail); rply = "success"; } catch (Exception e) { WriteLog(e.Message); rply = e.Message; } } } catch (Exception e) { WriteLog(e.Message); rply = e.Message.ToString(); } Log log = new Log(); log.Action = "Send Email"; log.Descriptions = "Send EMAIL by Header Referenceno : " + nvm.ReferenceNo + ", Recipient : " + recipient; log.Status = rply; //log.UserId = User.Identity.GetUserName(); _context.Logs.Add(log); _context.SaveChanges(); return(rply); }
public string SendNotification(string docstatus, string equipmenttype, int id) { int compid = 0; var notify = new NotifyViewModel(); var _area = _context.Areas; switch (equipmenttype) { case "fe": var _fe = _context.FireExtinguisherHeaders.Where(a => a.Id == id).FirstOrDefault(); var areafe = _area.Find(_fe.AreaId); notify.Area = areafe.Name; notify.CompanyId = areafe.CompanyId; notify.DocumentStatus = docstatus; notify.Equipment = "Fire Extinguisher"; notify.ReferenceNo = _fe.ReferenceNo; break; case "el": var _el = _context.EmergencyLightHeaders.Where(a => a.Id == id).FirstOrDefault(); var areael = _area.Find(_el.AreaId); notify.Area = areael.Name; notify.CompanyId = areael.CompanyId; notify.DocumentStatus = docstatus; notify.Equipment = "Emergency Light"; notify.ReferenceNo = _el.ReferenceNo; break; case "it": var _it = _context.InergenTankHeaders.Where(a => a.Id == id).FirstOrDefault(); var areait = _area.Find(_it.AreaId); notify.Area = areait.Name; notify.CompanyId = areait.CompanyId; notify.DocumentStatus = docstatus; notify.Equipment = "Inergen Tank"; notify.ReferenceNo = _it.ReferenceNo; break; case "fh": var _fh = _context.FireHydrantHeaders.Where(a => a.Id == id).FirstOrDefault(); var areafh = _area.Find(_fh.AreaId); notify.Area = areafh.Name; notify.CompanyId = areafh.CompanyId; notify.DocumentStatus = docstatus; notify.Equipment = "Fire Hydrant"; notify.ReferenceNo = _fh.ReferenceNo; break; case "bc": var _bc = _context.BicycleEntryHeaders.Include(a => a.Bicycles.Departments).Where(a => a.Id == id).FirstOrDefault(); notify.CompanyId = _bc.Bicycles.Departments.CompanyId; notify.Equipment = "Bicycle"; notify.ReferenceNo = _bc.ReferenceNo; break; } ; string status = ""; string message = ""; if (docstatus != "Approved") { message = SendEmail(notify); } if (message != "success") { status = "fail"; } else { status = "success"; } return(message); }
public WindowsNotifier() { this.vm = new NotifyViewModel(); }
public ActionResult Notify(NotifyViewModel model, string submitButton, string id, long?Role) { if (User.IsInRole(AppSettings.Roles.APPROVEDUSER) || User.IsInRole(AppSettings.Roles.AUDITORS)) { return(new HttpNotFoundResult()); } if (model.Role == null) { return(View(model)); // redisplay the view if error } long role = (long)model.Role; if (Role != null) { role = (long)Role; } model.notifyList = (List <Notification>)Session["notifyListDB"]; model.Role = (long)Session["roleResult"]; model.Roles = (List <SelectListItem>)Session["RolesList"]; long result; if (!long.TryParse(id, out result)) { return(View(model)); } FM_Datastore_Entities_EF db_manager = new FM_Datastore_Entities_EF(); // get notification Notification oldNotify = db_manager.Notifications.FirstOrDefault(m => m.Id == result); switch (submitButton) { case "Resend Notification": //send email to new user Mail.send( oldNotify.Email, "Access Approved", "here is the link to sign up this link will only be available for so long - " + "https://" + HttpContext.Request.Url.Authority + Url.Action("Register", "Account") + "?rqst=" + UrlEncryption.Encrypt( DateTime.UtcNow, oldNotify.Email, oldNotify.AddressId, oldNotify.DivisionId, role)); ViewBagHelper.setMessage(ViewBag, ViewBagHelper.MessageType.SuccessMsgBox, "New user request resent to \"" + oldNotify.Email + "\""); return(NotifyView()); case "Accept": if (oldNotify.notifyType.Equals(AppSettings.Notify.newUser)) { //send email to new user Mail.send( oldNotify.Email, "Access Approved", "here is the link to sign up this link will only be available for so long - " + "https://" + HttpContext.Request.Url.Authority + Url.Action("Register", "Account") + "?rqst=" + UrlEncryption.Encrypt( DateTime.UtcNow, oldNotify.Email, oldNotify.AddressId, oldNotify.DivisionId, role)); oldNotify.notifyType = AppSettings.Notify.pendingUser; oldNotify.Role = db_manager.Roles.FirstOrDefault(m => m.Id == role).Name; db_manager.Entry(oldNotify); db_manager.SaveChanges(); db_manager.Dispose(); } return(NotifyView()); case "Deny": // send denial email to user Mail.send(oldNotify.Email, "Denied Access", "Appologies user you have been denied access by administration to the application."); model.notifyList.Remove(model.notifyList.First(m => m.Id == result)); // remove from current model db_manager.Notifications.Remove(oldNotify); break; default: break; } db_manager.SaveChanges(); db_manager.Dispose(); return(View(model)); }