NotificationResponse IHellaAPCECOInterface.Notification(NotificationRequest notificationrequest) { int NewCallCount = Interlocked.Increment(ref CallCount); string SendReceiveString; SendReceiveString = string.Format("Notification:{0}", CallCount); //更新可视化界面 OutPut(SendReceiveString); Task[] MyTaskList = null; if (notificationrequest != null && notificationrequest.notification_message != null) { MyTaskList = Preprocessing(notificationrequest.notification_message.Item); } else { OutPut("NotificationContainer is null"); } NotificationResponse MyNotificationResponse = new NotificationResponse(); AnswerContainer MyAnswerContainer = new AnswerContainer(); MyAnswerContainer.Items = MyTaskList; MyAnswerContainer.referenced_notification_ID = notificationrequest.notification_message.Item.notification_ID; MyAnswerContainer.server_response_type = SOAP_ServerError.SOAP_SERVER_OK; MyNotificationResponse.answer_message = MyAnswerContainer; return(MyNotificationResponse); }
public async Task <NotificationResponse> Send(NotificationRequest request, NotificationTemplate template) { var fromAddress = template.EmailAddress; var fromName = template.SenderName; var templateId = template.TemplateId; var toName = request.CustomerId; var toAddress = template.NotificationMethod == Method.SMS ? GetFullSMS(_countryCode, request.CustomerMobile, template.SMSDomain) : request.CustomerEmail; var mailResponse = await SendGridEmail(fromAddress, fromName, toAddress, toName, templateId, request); var response = new NotificationResponse { TransactionId = request.TransactionId, OrderNo = request.OrderNo, ServiceResult = new ServiceResult() { Code = mailResponse.Success ? 0 : 1, Message = string.IsNullOrEmpty(mailResponse.Message) ? "Success" : mailResponse.Message } }; return(response); }
public void TestGenericDeserialize() { NotificationResponse nr = new NotificationResponse(); nr.DestType = BaseResponse.DEST_TYPE.FACTION; nr.Destination = new List <long>() { 2194 }; nr.NotificationText = "Test String"; nr.Time = 2000; nr.Font = Sandbox.Common.MyFontEnum.Red; byte[] buffer = nr.serialize(); BaseResponse msg = BaseResponse.messageFromBytes(buffer); Assert.IsInstanceOfType(msg, typeof(NotificationResponse)); Assert.AreEqual(nr.MsgType, msg.MsgType); Assert.AreEqual(nr.DestType, msg.DestType); CollectionAssert.AreEqual(nr.Destination, msg.Destination); Assert.AreEqual(nr.NotificationText, (msg as NotificationResponse).NotificationText); Assert.AreEqual(nr.Time, (msg as NotificationResponse).Time); Assert.AreEqual(nr.Font, (msg as NotificationResponse).Font); }
public void DidReceiveNotificationResponse(UNUserNotificationCenter center, UNNotificationResponse response, Action completionHandler) { var parameters = GetParameters(response.Notification.Request.Content.UserInfo); var catType = NotificationCategoryType.Default; if (response.IsCustomAction) { catType = NotificationCategoryType.Custom; } else if (response.IsDismissAction) { catType = NotificationCategoryType.Dismiss; } var ident = $"{response.ActionIdentifier}".Equals("com.apple.UNNotificationDefaultActionIdentifier", StringComparison.CurrentCultureIgnoreCase) ? string.Empty : $"{response.ActionIdentifier}"; var notificationResponse = new NotificationResponse(parameters, ident, catType); if (string.IsNullOrEmpty(ident)) { _onNotificationOpened?.Invoke(this, new FirebasePushNotificationResponseEventArgs(notificationResponse.Data, notificationResponse.Identifier, notificationResponse.Type)); CrossFirebaseEssentials.Notifications.NotificationHandler?.OnOpened(notificationResponse); } else { _onNotificationAction?.Invoke(this, new FirebasePushNotificationResponseEventArgs(notificationResponse.Data, notificationResponse.Identifier, notificationResponse.Type)); // CrossFirebasePushNotification.Current.NotificationHandler?.OnOpened(notificationResponse); } // Inform caller it has been handled completionHandler(); }
public NotificationResponse UpdatePlayerId(string PlayerId) { NotificationResponse objUpdatePlayerId = new NotificationResponse(); try { var headers = Request.Headers; string token = headers.Authorization.Parameter.ToString(); Int64 UserId = _objFriendFitDBEntity.Database.SqlQuery <Int64>("select UserId from UserToken where TokenCode={0}", token).FirstOrDefault(); var _UpdatePlayerId = _objFriendFitDBEntity.UserProfiles.Where(x => x.Id == UserId).FirstOrDefault(); _UpdatePlayerId.DeviceId = PlayerId; _UpdatePlayerId.DeviceTypeId = 3; _objFriendFitDBEntity.Entry(_UpdatePlayerId).State = System.Data.Entity.EntityState.Modified; _objFriendFitDBEntity.SaveChanges(); objUpdatePlayerId.Responses.Message = "Player Id is Updated Successfully."; objUpdatePlayerId.Responses.StatusCode = 200; } catch (Exception ex) { objUpdatePlayerId.Responses.Message = Convert.ToString(ex); objUpdatePlayerId.Responses.StatusCode = 501; } return(objUpdatePlayerId); }
public async Task <NotificationResponse> SendRequest(string userId, string fromWho) { Logger.Debug(() => $"Sending friend request to {userId} from {fromWho}"); JObject json = new JObject(); json["type"] = "friendrequest"; json["message"] = $"{fromWho} wants to be your friend"; Logger.Debug(() => $"Prepared JSON to post: {json}"); StringContent content = new StringContent(json.ToString(), Encoding.UTF8); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); HttpResponseMessage response = await Global.HttpClient.PostAsync($"user/{userId}/notification?apiKey={Global.ApiKey}", content); NotificationResponse res = null; if (response.IsSuccessStatusCode) { var receivedJson = await response.Content.ReadAsStringAsync(); Logger.Debug(() => $"JSON received: {receivedJson}"); res = JsonConvert.DeserializeObject <NotificationResponse>(receivedJson); } return(res); }
public async Task GetByIdTest() { var notificationId = Guid.NewGuid(); var service = new Mock <INotificationHistoryService>(); var response = new NotificationResponse(NotificationEvent.ArticleCreated) { OwnerUserId = UserId }; GetNotificationRequest req = null; service.Setup(x => x.GetAsync(It.IsAny <GetNotificationRequest>())) .Callback <GetNotificationRequest>(request => req = request) .ReturnsAsync(response) .Verifiable(); var controller = new NotificationHistoryController(_logger, service.Object).WithUser(); var result = await controller.GetNotificationByIdAsync(notificationId); service.Verify(); Assert.NotNull(req); Assert.Equal(UserId, req.UserId); Assert.Equal(notificationId, req.NotificationId); var res = Assert.IsType <OkObjectResult>(result); Assert.Equal(response, res.Value); Assert.IsType <NotificationResponse>(res.Value); }
public void TestNotificationResponse() { NotificationResponse nr = new NotificationResponse(); nr.DestType = BaseResponse.DEST_TYPE.FACTION; nr.Destination = new List <long>() { 1, 2 }; nr.NotificationText = "Test String"; nr.Time = 2000; nr.Font = Sandbox.Common.MyFontEnum.Red; byte[] buffer = nr.serialize(); NotificationResponse nr2 = new NotificationResponse(); nr2.deserialize(new VRage.ByteStream(buffer, buffer.Length)); Assert.AreEqual(nr.MsgType, nr2.MsgType); Assert.AreEqual(nr.DestType, nr2.DestType); CollectionAssert.AreEqual(nr.Destination, nr2.Destination); Assert.AreEqual(nr.NotificationText, nr2.NotificationText); Assert.AreEqual(nr.Time, nr2.Time); Assert.AreEqual(nr.Font, nr2.Font); }
public async Task OnEntry(NotificationResponse response) { var notification = response.Notification; var payload = notification?.Payload; if (payload?.Any() == true && payload.ContainsKey(nameof(CatalogEntry.Id)) && payload.ContainsKey(nameof(CatalogEntry.Version)) && Application.Current.MainPage is NavigationPage navPage) { try { var packageId = payload[nameof(CatalogEntry.Id)]; var version = payload[nameof(CatalogEntry.Version)]; var packagePage = new PackagePage { PackageId = packageId, Version = version }; await navPage.PushAsync(packagePage); } catch (Exception ex) { _logger.Error(ex); } } }
public void Execute(string puppyName, string ownerName, NotificationResponse outPort) { repo.RemovePuppy(puppyName); repo.AddOwner(ownerName); outPort(); }
public void Execute(string puppyName, string ownerName, NotificationResponse port) { observedPuppy = puppyName; observedOwner = ownerName; port(); }
public static Notification CreateFromClientToServer(this NotificationResponse notification) { DateTime alertAppearDate = new DateTime(); switch (notification.AlertBefore) { case 1: alertAppearDate = DateTime.ParseExact(notification.AlertDate, "dd/MM/yyyy", new CultureInfo("en")).AddMonths(-1); break; case 2: alertAppearDate = DateTime.ParseExact(notification.AlertDate, "dd/MM/yyyy", new CultureInfo("en")).AddDays(-7); break; case 3: alertAppearDate = DateTime.ParseExact(notification.AlertDate, "dd/MM/yyyy", new CultureInfo("en")).AddDays(-1); break; } return(new Notification { NotificationId = notification.NotificationId, TitleA = notification.TitleA, TitleE = notification.TitleE, CategoryId = notification.CategoryId, AlertBefore = notification.AlertBefore, AlertDateType = notification.AlertDateType, AlertDate = DateTime.ParseExact(notification.AlertDate, "dd/MM/yyyy", new CultureInfo("en")), AlertAppearDate = alertAppearDate, EmployeeId = notification.EmployeeId, MobileNo = notification.MobileNo, Email = notification.Email, ReadStatus = notification.ReadStatus, SystemGenerated = notification.SystemGenerated, RecCreatedBy = notification.RecCreatedBy, RecCreatedDate = notification.RecCreatedDate, RecLastUpdatedBy = notification.RecLastUpdatedBy, RecLastUpdatedDate = notification.RecLastUpdatedDate }); }
public async Task PutAsyncTest() { // Arrange var mockNotificationRepository = GetDefaultINotificationRepositoryInstance(); var mockIUnitOfWork = GetDefaultIUnitOfWorkInstance(); var notificationId = 1; Notification n = new Notification(); n.Id = notificationId; n.Link = "google.com"; n.NotificationTypeId = 1; n.SendDate = new DateTime(2018, 5, 10); n.NotificationTypeId = 1; Notification expected = new Notification(); expected.Id = notificationId; expected.Link = "meet.es"; expected.SendDate = new DateTime(2019, 7, 23); expected.NotificationTypeId = 2; mockNotificationRepository.Setup(r => r.FindById(notificationId)) .Returns(Task.FromResult <Notification>(n)); var service = new NotificationService(mockNotificationRepository.Object, mockIUnitOfWork.Object); // Act NotificationResponse result = await service.UpdateAsync(notificationId, expected); // Assert Assert.AreEqual(expected.Id, result.Resource.Id); Assert.AreEqual(expected.Link, result.Resource.Link); Assert.AreEqual(expected.SendDate, result.Resource.SendDate); Assert.AreEqual(expected.NotificationTypeId, result.Resource.NotificationTypeId); }
private void ClientOnNotification(object sender, NotificationResponse e) { var data = new NotificationData { Title = e.Title, Content = e.Text, Attribution = Host }; if (e.Payload is JObject jobj) { var payload = jobj.ToObject <NotificationPayload>(); if (payload != null) { if (RoomMessage?.Invoke(payload.Rid) != true) { Rooms.FirstOrDefault(it => it.RoomsResult.Id == payload.Rid) ?.Let(it => it.SubscriptionResult.Alert = true); } data.Image = $"https://{Host}/avatar/{payload.Sender.Username}"; } } _notification?.Show(data); }
async Task DoChat(NotificationResponse response) { //var cat = response.Notification.Category; //if (!cat?.StartsWith("Chat") ?? false) // return; //cat = cat.Replace("Chat", String.Empty).ToLower(); //switch (cat) //{ // case "name": // var name = "Shy Person"; // if (!response.Text.IsEmpty()) // name = response.Text.Trim(); // await notifications.Send("Shiny Chat", $"Hi {name}, do you like me?", "ChatAnswer"); // break; // case "answer": // switch (response.ActionIdentifier.ToLower()) // { // case "yes": // await this.notifications.Send("Shiny Chat", "YAY!!"); // break; // case "no": // await this.notifications.Send("Shiny Chat", "Go away then!"); // break; // } // break; //} }
public Task OnEntry(NotificationResponse response) => this .delegates? .RunDelegates(x => x.OnEntry(new PushEntryArgs( response.Notification.Category, response.ActionIdentifier, response.Text, response.Notification.Payload ))) ?? Task.CompletedTask;
public Task OnEntry(NotificationResponse response) => this .pushDelegate .OnEntry(new PushEntryArgs( response.Notification.Category, response.ActionIdentifier, response.Text, response.Notification.Payload ));
public ABCNotificationResponse SendNotification(ABCNotification notification) { Notification notificationV1 = MapToXYZNotification(notification); NotificationResponse notificationResponse = this.xYZBroker.SendNotification(notificationV1); return(MapToABCNotificationResponse(notificationResponse)); }
private ABCNotificationResponse MapToABCNotificationResponse( NotificationResponse notificationResponseV2) { return(new ABCNotificationResponse { Id = notificationResponseV2.Id }); }
public Task OnEntry(NotificationResponse response) => this.Store(new NotificationEvent { NotificationId = response.Notification.Id, NotificationTitle = response.Notification.Title ?? response.Notification.Message, Action = response.ActionIdentifier, ReplyText = response.Text, IsEntry = true, Timestamp = DateTime.Now });
public async Task SendNotification(NotificationResponse notification) { var connectionId = await(from c in _context.Users where c.Id == notification.ToId select c.ConnectionId).FirstOrDefaultAsync(); await _hub.Clients.Clients(connectionId).SendAsync("transferData", notification); }
private static void ValidateRecords(NotificationRecord expected, NotificationResponse actual) { Assert.NotNull(actual); Assert.Equal(expected.Id, actual.Id); Assert.Equal(expected.Parameters, actual.Parameters); Assert.Equal(expected.OwnerUserId, actual.OwnerUserId); Assert.Equal(expected.Event, actual.Event); Assert.Equal(expected.Created, actual.Created); }
public async Task <IActionResult> Send([FromBody] NotificationRequest request) { if (request == null) { return(BadRequest(new NotificationResponse { ServiceResult = new ServiceResult { Code = 2, Message = "Request could not be parsed" } })); } var response = new NotificationResponse { TransactionId = request.TransactionId, OrderNo = request.OrderNo }; try { // Get a notification template by a given type and method var templatesTask = await _service.GetTemplates(request.BranchId, request.NotificationType, request.NotificationMethod); // Exit if Notification Template not found if (templatesTask.NotificationTemplates.Count == 0) { return(BadRequest(new NotificationResponse { TransactionId = request.TransactionId, OrderNo = request.OrderNo, ServiceResult = new ServiceResult { Code = 2, Message = $"Notification Template of Type {request.NotificationType} and Method {request.NotificationMethod} could not be found." } })); } // Get the template var template = templatesTask.NotificationTemplates.Where(o => o.NotificationMethod == request.NotificationMethod).FirstOrDefault(); // Send a Notification var responseTask = await _service.Send(request, template); response.ServiceResult = responseTask.ServiceResult; return(Ok(response)); } catch (Exception ex) { response.ServiceResult = new ServiceResult { Code = 1, Message = ex.Message }; return(StatusCode(500, response)); } }
public override void OnException(HttpActionExecutedContext context) { var httpMessage = new HttpResponseMessage(HttpStatusCode.InternalServerError); var messages = context.Exception.GetMessages(); var response = new NotificationResponse("Houve uma falha na requisicação", messages, "error"); httpMessage.Content = new ObjectContent <NotificationResponse>(response, new JsonMediaTypeFormatter()); context.Response = httpMessage; }
/// /// <summary> /// Parse inbound sms notification received in webhook. It parses the notification and returns /// simplified version of the response. /// </summary> /// /// <param name="json"> <b>string</b>JSON string received in the subscription webhook.</param> /// /// <returns> /// NotificationResponse /// </returns> /// public NotificationResponse Parse(string json) { var notification = JObject.Parse(json); var notificationResponse = new NotificationResponse(); JObject obj = null; if (notification.ContainsKey("inboundSMSMessageNotification") || notification.ContainsKey("outboundSMSMessageNotification")) { JObject parentObject = null; if (notification.ContainsKey("inboundSMSMessageNotification")) { parentObject = (JObject)notification["inboundSMSMessageNotification"]; obj = (JObject)parentObject["inboundSMSMessage"]; notificationResponse.notificationType = "inbound"; } else { parentObject = (JObject)notification["outboundSMSMessageNotification"]; obj = (JObject)parentObject["outboundSMSMessage"]; notificationResponse.notificationType = "outbound"; } notificationResponse.notificationId = (string)parentObject["id"]; notificationResponse.message = (string)obj["message"]; notificationResponse.notificationDateTime = (long)obj["dateTime"]; notificationResponse.messageId = (string)obj["messageId"]; notificationResponse.senderAddress = (string)obj["senderAddress"]; notificationResponse.destinationAddress = (string)obj["destinationAddress"]; } if (notification.ContainsKey("smsSubscriptionCancellationNotification")) { obj = (JObject)notification["smsSubscriptionCancellationNotification"]; notificationResponse.notificationType = "subscriptionCancel"; notificationResponse.notificationId = (string)obj["id"]; notificationResponse.notificationDateTime = (long)obj["dateTime"]; notificationResponse.subscriptionId = Util.IdFrom((string)obj["link"][0]["href"]); } if (notification.ContainsKey("smsEventNotification")) { obj = (JObject)notification["smsEventNotification"]; notificationResponse.eventDetails = new Dictionary <string, string>(); notificationResponse.notificationType = "event"; notificationResponse.notificationId = (string)obj["id"]; notificationResponse.notificationDateTime = (long)obj["dateTime"]; notificationResponse.subscriptionId = Util.IdFrom((string)obj["link"][0]["href"]); notificationResponse.eventDetails.Add("eventDescription", (string)obj["eventDescription"]); notificationResponse.eventDetails.Add("eventType", (string)obj["eventType"]); } return(notificationResponse); }
public NotificationResponse DatabaseMoveNeeded(Guid dbId, string currentActiveFqdn, bool mountDesired) { NotificationResponse rc = NotificationResponse.Incomplete; ExTraceGlobals.ThirdPartyClientTracer.TraceDebug <Guid, string, bool>((long)this.GetHashCode(), "Notify.DatabaseMoveNeeded({0},{1},{2}) attempted", dbId, currentActiveFqdn, mountDesired); ClientServices.CallService(delegate { rc = this.m_wcfClient.DatabaseMoveNeeded(dbId, currentActiveFqdn, mountDesired); }); return(rc); }
public void Handle(Response response) { if (_methodTypeDictionary.Keys.Contains(response.Method)) { var notificationResponse = new NotificationResponse(); notificationResponse.Notification = Activator.CreateInstance(_methodTypeDictionary[response.Method]); _responseParser.ParseToObject(response, notificationResponse); OnNotificationReceived(new NotificationEventArgs(notificationResponse.Notification)); } }
public async Task SendNext(NotificationEntity entity) { if (webSocket.State == WebSocketState.Open) { var res = new NotificationResponse(entity, userId); var json = JsonConvert.SerializeObject(res, JsonConverterOptions.JsonSettings); var bytes = Encoding.Unicode.GetBytes(json); var segment = new ArraySegment <byte>(bytes); await webSocket.SendAsync(segment, WebSocketMessageType.Text, true, CancellationToken.None); } }
public async Task <NotificationResponse> SendEmail(EmailMessage message) { var notificationRespose = new NotificationResponse { statusCode = "1", message = "Email sent Error" }; try { Console.WriteLine($"Estado del circuito: {_circuitBreakerPolicy.CircuitState}"); await _circuitBreakerPolicy.ExecuteAsync(async() => { try { var mimeMessage = await CreateMimeMessageFromEmailMessage(message); await _smtpClient.ConnectAsync(_notificationMetadata.SmtpServer, _notificationMetadata.Port, false); await _smtpClient.AuthenticateAsync(_notificationMetadata.UserName, _notificationMetadata.Password); await _smtpClient.SendAsync(mimeMessage); notificationRespose.statusCode = "0"; notificationRespose.message = "Email sent successfully"; } finally { await _smtpClient.DisconnectAsync(true); } }); } catch (Exception ex) { Console.WriteLine($"Erro al enviar correo: {ex.Message}"); } finally { var newNotification = new ApplicationCore.DTO.Notification { Message = message.Content, status = notificationRespose.statusCode, Type = "E", Reciever = message.Reciever, DateNotification = DateTime.UtcNow.ToLocalTime() }; await persistNotification(newNotification); } return(notificationRespose); }
public async Task Consume(ConsumeContext <NotificationCreatedEvent> context) { NotificationCreatedEvent notificationCreatedEvent = context.Message; NotificationResponse notificationResponse = new NotificationResponse(notificationCreatedEvent.CorrelationId, notificationCreatedEvent.Title, notificationCreatedEvent.Content, notificationCreatedEvent.IsSeen, notificationCreatedEvent.OperationDate); await _hubContext.Clients.User(notificationCreatedEvent.Username) .SendAsync(NotificationHub.NOTIFICATION_CREATED, notificationResponse) .ConfigureAwait(continueOnCapturedContext: false); }