示例#1
0
        public async Task <IActionResult> SendPushNotification([FromBody] EventQueueModel model)
        {
            BaseResult <EventModel> baseResult = new BaseResult <EventModel>();
            bool  isSuccess = false;
            Event _event    = _SEvent.GetById(model.eventId);
            int   userId    = Convert.ToInt32(HttpContext.User.Identity.Name);

            if (_event.userId == userId)
            {
                await notificationDispatcher.SendEventPushNotification(model);

                baseResult.errMessage = "Bildirim Gönderilmek Üzere İşlenilmeye Başlandı!";
                isSuccess             = true;
            }
            else
            {
                baseResult.errMessage = "Kendinize Ait Olmayan Bir Etkinliğe Müdahale Edemezsiniz";
            }
            if (isSuccess)
            {
                return(Json(baseResult));
            }
            else
            {
                baseResult.statusCode = HttpStatusCode.NotFound;
                return(new NotFoundObjectResult(baseResult));
            }
        }
        public bool Save(EventQueueModel model)
        {
            return(sqlService.OpenConnection((conn) =>
            {
                if (string.IsNullOrWhiteSpace(model.Id))
                {
                    model.Id = Guid.NewGuid().ToString();
                }

                int affectedRows = 0;
                foreach (var target in GetEventTargets())
                {
                    var dbModel = new TargetEventQueueModel
                    {
                        Args = model.Args,
                        CreateDateTime = model.CreateDateTime,
                        CreateUserId = model.CreateUserId,
                        EventName = model.EventName,
                        Handled = model.Handled,
                        Id = $"{target.MachineName}_{target.ServiceName}_{model.Id}",
                        MachineName = target.MachineName,
                        ServiceName = target.ServiceName
                    };

                    affectedRows += conn.Execute($"INSERT INTO {FlowEventQueueTableName} " +
                                                 $" (Id, EventName, Args, CreateDateTime, CreateUserId, Handled, MachineName, ServiceName) " +
                                                 $" ON EXISTING UPDATE VALUES (:Id, :EventName, :Args, :CreateDateTime, " +
                                                 $" :CreateUserId, :Handled, :MachineName, :ServiceName)", dbModel);
                }

                return affectedRows > 0;
            }));
        }
        public bool Save(EventQueueModel model)
        {
            if (model.CreateDateTime == default(DateTime))
            {
                model.CreateDateTime = DateTime.Now;
            }

            return(flowEventQueueRepository.Save(model));
        }
示例#4
0
 public async Task SendEventPushNotification(EventQueueModel model)
 {
     await this._hubContext.Clients.All.SendAsync("sendEventPushNotification", model);
 }