public async Task <IActionResult> PutAsset( [SwaggerParameter("The Asset Id", Required = true), FromODataUri, NotDefault] Guid id, [SwaggerParameter("The Asset", Required = true), Required] Delta <Asset> delta, CancellationToken cancellationToken) { IActionResult result; if (delta.GetInstance().Id != id) { ModelState.AddModelError(nameof(id), "Ids must match"); result = BadRequest(ModelState); } else if (_cache.TryGetValue(id, out _)) { var getRequest = new GetRequest <Asset>(nameof(MongoDB), new object[] { id }, _logger); var model = await _mediator.Send(getRequest, cancellationToken).ConfigureAwait(false); delta.Put(model); model.UpdatedBy = Guid.Parse(User.FindFirstValue(Sub)); model.UpdatedDate = UtcNow; var updateRequest = new UpdateRequest <Asset>(nameof(MongoDB), x => x.Id == id, model, _logger); await _mediator.Send(updateRequest, cancellationToken).ConfigureAwait(false); var notification = new UpdateNotification <Asset, Guid>(id, model); await _mediator.Publish(notification, cancellationToken).ConfigureAwait(false); result = NoContent(); } else { result = NotFound(); } return(result); }
/// <summary> /// Update the current context with the new Container. If you do a change on List make sure that /// you use UpdateNotification.ForceNotify so that it will trigger the change. /// </summary> /// <param name="data"></param> /// <param name="notifyChange"></param> /// <typeparam name="TContainer"></typeparam> public void UpdateWith <TContainer>(ref TContainer data, UpdateNotification notifyChange) { // nothing changed if (data.Equals(m_Target) && notifyChange != UpdateNotification.ForceNotify) { return; } bool changed = false; // go through each property var propertyBag = PropertyBag.GetPropertyBag <TContainer>(); foreach (var property in propertyBag.GetProperties(ref data)) { var name = property.Name; var value = property.GetValue(ref data); if (TrySetValue(name, value)) { changed = notifyChange != UpdateNotification.DoNotNotify; } } if (changed || notifyChange == UpdateNotification.ForceNotify) { stateChanged?.Invoke(); } }
public async Task <IActionResult> Put(int ID, UpdateNotification data) { data.Data.Attributes.Notification_id = ID; var result = await _mediatr.Send(data); return(Ok(result)); }
private void updateNotificationButton_Click(object sender, EventArgs e) { if (notificationId == null) { throw new Exception("No notificationId known"); } UpdateNotification notification = new UpdateNotification() { NotificationId = notificationId, Message = "New messgae € î ï è ç blâÿãh - " + DateTime.Now.ToString(), Data = "{\"dataId\" : 234}", MatchRange = 202, //Published = true, Timespans = new CreateNotificationV1.Timespan[] { new CreateNotificationV1.Timespan { Start = null, End = DateTime.UtcNow.AddDays(3) } } //Timespans = new CreateNotificationV1.Timespan[] { new CreateNotificationV1.Timespan { Start = DateTime.UtcNow, End = DateTime.UtcNow.AddDays(3) } } }; using (Connection conn = NewConnection()) { conn.UpdateNotification(notification); } AddLogLine(string.Format("Updated: {0}", notification.Data)); }
/// <inheritdoc /> public Task <Unit> Handle(UpdateRequest <T> request, CancellationToken cancellationToken, RequestHandlerDelegate <Unit> next) { if (request == default) { throw new ArgumentNullException(nameof(request)); } if (next == default) { throw new ArgumentNullException(nameof(next)); } if (!_options.UseScopedLogging) { return(Handle()); } using (request.Scope) { return(Handle()); } async Task <Unit> Handle() { var start = new UpdateNotification <T>(request.Expression, request.Model, request.Logger); await _mediator.Publish(start, cancellationToken).ConfigureAwait(false); var response = await next().ConfigureAwait(false); var finish = new UpdateNotification(request.Logger); await _mediator.Publish(finish, cancellationToken).ConfigureAwait(false); return(response); } }
public ActionResult DeleteConfirmed(int id) { UpdateNotification updatenotification = db.UpdateNotifications.Find(id); db.UpdateNotifications.Remove(updatenotification); db.SaveChanges(); return(RedirectToAction("Index")); }
public override void HandlePushNotification(string func, List <byte[]> args) { //try { if (Application.Current == null) { return; // not ready yet } if (func == "ActivityNotification") { Application.Current.Dispatcher.BeginInvoke(new Action(() => { ActivityNotification?.Invoke(this, new Priv10Engine.FwEventArgs() { guid = GetGuid(args[0]), entry = GetLogEntry(args[1]), progID = GetProgID(args[2]), services = GetStrList(args[3]), update = GetBool(args[4]) }); })); } else if (func == "ChangeNotification") { Application.Current.Dispatcher.BeginInvoke(new Action(() => { ChangeNotification?.Invoke(this, new Priv10Engine.ChangeArgs() { prog = GetProg(args[0]), rule = GetRule(args[1]), type = GetEnum <Priv10Engine.RuleEventType>(args[2]), action = GetEnum <Priv10Engine.RuleFixAction>(args[3]) }); })); } else if (func == "UpdateNotification") { Application.Current.Dispatcher.BeginInvoke(new Action(() => { UpdateNotification?.Invoke(this, new Priv10Engine.UpdateArgs() { guid = GetGuid(args[0]), type = GetEnum <Priv10Engine.UpdateArgs.Types>(args[1]) }); })); } else { throw new Exception("Unknown Notificacion"); } } //catch (Exception err) //{ // AppLog.Exception(err); //} }
public ActionResult Edit([Bind(Include = "UpdateNotificationId,UserId,Content,ContentDateTime")] UpdateNotification updatenotification) { if (ModelState.IsValid) { db.Entry(updatenotification).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(updatenotification)); }
public Task Handle(UpdateNotification <T, TId> notification, CancellationToken cancellationToken) { if (notification == default) { throw new ArgumentNullException(nameof(notification)); } _cache.SetCacheEntry(notification.Key, notification.Value, _options); return(_database.StringSetAsync(notification.Key.ToString(), Serialize(notification.Value), flags: FireAndForget)); }
private void CheckForUpdates() { var version = Assembly.GetExecutingAssembly().GetName().Version.ToString(); var updates = GithubRepository.HasUpdates(version).Result; if (updates) { UpdateNotification.Visibility = Visibility.Visible; UpdateNotification.UpdateLayout(); } }
public ActionResult Create([Bind(Include = "UpdateNotificationId,UserId,Content,ContentDateTime")] UpdateNotification updatenotification) { if (ModelState.IsValid) { db.UpdateNotifications.Add(updatenotification); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(updatenotification)); }
public void Handle(UpdateNotification update) { var connectionState = _protoService.GetConnectionState(); if (connectionState is ConnectionStateUpdating) { // This is an unsynced message, we don't want to show a notification for it as it has been probably pushed already by WNS return; } //ProcessNotification(update.NotificationGroupId, 0, update.Notification); }
//the view of the update notification public ActionResult Update(int id) { Notifications notification = db.Notifications.SqlQuery("select * from Notifications where id = @id", new SqlParameter("@id", id)).FirstOrDefault(); List <NotificationTypes> types = db.NotificationTypes.SqlQuery("select * from NotificationTypes").ToList(); UpdateNotification update = new UpdateNotification(); update.Notifications = notification; update.types = types; return(View(update)); }
// GET: /UpdateNotification/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } UpdateNotification updatenotification = db.UpdateNotifications.Find(id); if (updatenotification == null) { return(HttpNotFound()); } return(View(updatenotification)); }
private void SetupAndRunUpdateNotificationWindow() { Thread thread = new Thread(() => { UpdateNotification = new UpdateNotification(); UpdateNotification.Show(); Dispatcher.Run(); }) { Name = "updateNotificationThread" }; thread.SetApartmentState(ApartmentState.STA); thread.Start(); }
public async Task <IActionResult> UpdateNotification(string id, UpdateNotification request) { var items = await _notificationManager.ToggleSeen( new NotificationsQuery() { Ids = new[] { id }, UserId = _userManager.GetUserId(User) }, request.Seen); if (items.Count == 0) { return(NotificationNotFound()); } return(Ok(ToModel(items.First()))); }
private async void CheckForUpdate() { if (Application.ProductVersion == "1.0.0.0") { return; } var latestVersion = await UpdateNotification.GetLatestVersion(); if (UpdateNotification.GetLatestBuildNumber(latestVersion) > UpdateNotification.GetLatestBuildNumber(Application.ProductVersion)) { Logger.Info($"Local version: {Application.ProductVersion}. Remote version: {latestVersion}"); MessageBox.Show($"There's new version ({latestVersion}). Click OK to open download page."); Process.Start("https://github.com/NguyenDanPhuong/MangaRipper/releases"); } }
private void publishNotificationNonAdminButton_Click(object sender, EventArgs e) { if (notificationId == null) { throw new Exception("No notificationId known"); } UpdateNotification notification = new UpdateNotification() { NotificationId = notificationId, Published = true }; using (Connection conn = NewConnection()) { conn.UpdateNotification(notification); } AddLogLine(string.Format("Published (using update): {0}", notification.Data)); }
internal void Update() { if (UpdateNotification == null) { return; } if (!ShouldUpdate) { return; } ShouldUpdate = false; UpdateNotification.SetActive(Visible); UIManager.UnlockCursor = Visible; if (Visible) { UpdateText.text = GetUpdateMessage(); } }
public override void HandlePushNotification(string func, object args) { try { if (Application.Current == null) { return; // not ready yet } if (func == "ActivityNotification") { Application.Current.Dispatcher.BeginInvoke(new Action(() => { ActivityNotification?.Invoke(this, (Priv10Engine.FwEventArgs)args); })); } else if (func == "ChangeNotification") { Application.Current.Dispatcher.BeginInvoke(new Action(() => { ChangeNotification?.Invoke(this, (Priv10Engine.ChangeArgs)args); })); } else if (func == "UpdateNotification") { Application.Current.Dispatcher.BeginInvoke(new Action(() => { UpdateNotification?.Invoke(this, (Priv10Engine.UpdateArgs)args); })); } else { throw new Exception("Unknown Notificacion"); } } catch (Exception err) { AppLog.Exception(err); } }
private async void CheckForUpdate() { if (Application.ProductVersion == "1.0.0.0") { return; } var latestVersion = await UpdateNotification.GetLatestVersion(); if (UpdateNotification.GetLatestBuildNumber(latestVersion) > UpdateNotification.GetLatestBuildNumber(Application.ProductVersion)) { Logger.Info($"Local version: {Application.ProductVersion}. Remote version: {latestVersion}"); if (MessageBox.Show( $"There's a new version: ({latestVersion}) - Click OK to open download page.", Application.ProductName, MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == System.Windows.Forms.DialogResult.OK) { Process.Start("https://github.com/NguyenDanPhuong/MangaRipper/releases"); } } }
public void SentUpdateNotification(UpdateNotification Update) { Clients.All.updateNotification(Update); }
public void UpdateNotificationTest() { var buildNumber = UpdateNotification.GetLatestBuildNumber("1.2.333"); Assert.AreEqual(333, buildNumber); }