Пример #1
0
        public ActionResult Put(int id, [FromBody] AlertDTO alert)
        {
            var dao = new AlertDAO();
            int resultNonQuery;

            try
            {
                resultNonQuery = dao.editAlert(id, alert);
            }
            catch (Exception e)
            {
                return(this.BadRequest($"Operacion de Modificar fallo: {e.Message}"));

                throw;
            }
            return(this.GetQueryResponse(resultNonQuery, "Modificar"));

            /*
             * var connection = new SqlConnection("data source=104.217.253.86;initial catalog=tracking;user id=alumno;password=12345678");
             * connection.Open();
             *
             * var sql =   @$"UPDATE alert
             *          set name = '{alert.Name}', notifywhenarriving = '{alert.Notifywhenarriving}',
             *          notifywhenleaving = '{alert.Notifywhenleaving}',
             *          enterpriseid = {alert.enterpriseid}, active = '{alert.Active}'
             *          WHERE id = {id}";
             *
             * var command = new SqlCommand(sql, connection);
             * string response = GetQueryResponse(command, "Modificar");
             *
             * connection.Close();
             * return Ok(response);
             */
        }
Пример #2
0
 public static void CancelAlertOfProduct(AlertDTO alert)
 {
     using (ProjectDBEntities db = new ProjectDBEntities())
     {
         Alert alert1 = new Alert();
         alert1             = db.Alerts.FirstOrDefault(a => a.AlertId == alert.AlertId);
         alert1.IsActivated = false;
         //    db.alerts.remove(alert1);
         db.SaveChanges();
     }
 }
Пример #3
0
 public void ConvertAlertDTOToClassMember(AlertDTO alert)
 {
     if (alert != null)
     {
         IdAlert = alert.IdAlert;
         IdAlertTypeEnum = (AlertDefinitionEnum)System.Enum.Parse(typeof(AlertDefinitionEnum), alert.IdAlertType.ToString());
         TitleAlert = alert.Title;
         if (alert.IdMode != null) IdMode = alert.IdMode.Value;
         ContentAlert = alert.Content;
     }
 }
Пример #4
0
 public static Alert ConvertAlertToDAL(AlertDTO a)
 {
     return(new Alert
     {
         AlertId = a.AlertId,
         Date = a.Date,
         Days = a.days,
         FollowUpListId = a.FollowUpListId,
         IsActivated = a.IsActivated,
         ProductId = a.ProductId.Value
     });
 }
Пример #5
0
        public IActionResult PushAlert([FromBody] AlertDTO alert)
        {
            var result = _userService.PushAlert(alert.UserKey, alert.When);

            if (result.Exception == null)
            {
                return(new JsonResult(result.Value));
            }
            else
            {
                return(new JsonResult(null));
            }
        }
Пример #6
0
        public ActionResult Post([FromBody] AlertDTO alert)
        {
            var dao = new AlertDAO();
            int resultNonQuery;

            try
            {
                resultNonQuery = dao.addAlert(alert);
            }
            catch (Exception e)
            {
                return(this.BadRequest($"Operacion de Modificar fallo: {e.Message}"));

                throw;
            }
            return(this.GetQueryResponse(resultNonQuery, "Agregar"));
        }
        public async Task <IActionResult> PostMessageToClient([FromBody] Message message)
        {
            //await AlertHub.Send(message.Text);

            // var timestamp = DateTime.Now.ToShortTimeString();
            var msg = message.Text;

            var testAlert = new AlertDTO()
            {
                Id            = Guid.NewGuid(),
                Name          = "Alert Signalr 1",
                Severity      = 1,
                Description   = "Lorem ipsum dolor sit amet,consectetur adipiscing elit.Curabitur tristique sit amet felis ac semper.Morbi luctus metus nibh.Pellentesque sodales mattis urna.Aliquam in nisl id quam aliquam malesuada in in velit.Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec vitae libero id quam ultricies volutpat.Fusce gravida est ante. Pellentesque non nisi vel nisl sagittis varius sed semper purus. Maecenas fringilla massa in nisl tincidunt, eget accumsan eros ultrices.Sed quis lorem pharetra, vulputate orci et, vehicula arcu.Etiam eget feugiat libero. Proin ullamcorper non dolor in dignissim.Integer ultrices leo arcu.",
                Priority      = 1,
                Source        = "signalr computer.local",
                TimeGenerated = DateTime.Now,
                AlertSolution = new AlertSolutionDTO
                {
                    Id   = Guid.NewGuid(),
                    Text = "solution Lorem ipsum dolor sit amet,consectetur adipiscing elit"
                },
                AlertExplanation = new AlertExplanationDTO()
                {
                    Id   = Guid.NewGuid(),
                    Text = "explanation Lorem ipsum dolor sit amet,consectetur adipiscing elit"
                },
                AlertConclusion = new AlertConclusionDTO()
                {
                    Id   = Guid.NewGuid(),
                    Text = "conclusion Lorem ipsum dolor sit amet,consectetur adipiscing elit"
                },
                MonitoredDevice = new MonitoredDeviceDTO()
                {
                    Id        = Guid.NewGuid(),
                    Name      = "pawel signalr server",
                    CompanyId = Guid.NewGuid()
                }
            };

            await _alertHubContext.Clients.All.SendAlert(testAlert);

            return(Ok(testAlert));
        }
Пример #8
0
        public IHttpActionResult GetAlerts()
        {
            subManager = new SubscriptionManager();
            IEnumerable <UserAlert> userAlerts = subManager.GetUserAlerts(User.Identity.GetUserId());
            IEnumerable <SubAlert>  subAlerts  = subManager.GetSubAlerts(User.Identity.GetUserId());

            if (userAlerts == null || subAlerts == null || (userAlerts.Count() == 0 && subAlerts.Count() == 0))
            {
                return(StatusCode(HttpStatusCode.NoContent));
            }

            //Made DTO class to prevent circular references
            List <AlertDTO> alerts = new List <AlertDTO>();

            foreach (SubAlert alert in subAlerts)
            {
                AlertDTO alertDTO = new AlertDTO()
                {
                    AlertId   = alert.AlertId,
                    Name      = alert.Subscription.SubscribedItem.Name,
                    TimeStamp = alert.TimeStamp,
                    IsRead    = alert.IsRead,
                    AlertType = alert.AlertType
                };
                alerts.Add(alertDTO);
            }
            foreach (UserAlert alert in userAlerts)
            {
                AlertDTO alertDTO = new AlertDTO()
                {
                    AlertId   = alert.AlertId,
                    Name      = alert.Subject,
                    TimeStamp = alert.TimeStamp,
                    IsRead    = alert.IsRead,
                    AlertType = alert.AlertType
                };
                alerts.Add(alertDTO);
            }

            return(Ok(alerts));
        }
        public IHttpActionResult GetAlerts()
        {
            subManager = new SubscriptionManager();
            string userId = User.Identity.GetUserId();
            IEnumerable <UserAlert> userAlerts = subManager.GetUserAlerts(userId);
            IEnumerable <SubAlert>  subAlerts  = subManager.GetSubAlerts(userId);

            if (userAlerts == null || subAlerts == null || (userAlerts.Count() == 0 && subAlerts.Count() == 0))
            {
                return(StatusCode(HttpStatusCode.NoContent));
            }

            List <AlertDTO> lijst = new List <AlertDTO>();

            foreach (SubAlert alert in subAlerts)
            {
                AlertDTO alertDTO = new AlertDTO()
                {
                    AlertId   = alert.AlertId,
                    Name      = alert.Subscription.SubscribedItem.Name,
                    TimeStamp = alert.TimeStamp,
                    IsRead    = alert.IsRead,
                    ItemId    = alert.Subscription.SubscribedItem.ItemId
                };
                lijst.Add(alertDTO);
            }
            foreach (UserAlert alert in userAlerts)
            {
                AlertDTO alertDTO = new AlertDTO()
                {
                    AlertId   = alert.AlertId,
                    Name      = alert.Subject,
                    TimeStamp = alert.TimeStamp,
                    IsRead    = alert.IsRead,
                };
                lijst.Add(alertDTO);
            }

            return(Ok(lijst.AsEnumerable()));
        }
        private void SetData()
        {
            _user = new UserDTO()
            {
                DateLastConnection = DateTime.Now,
                DateLocation       = DateTime.Now,
                DefaultTheme       = 0,
                Email                = "*****@*****.**",
                FirstName            = "TestFirstName",
                GCMRegistrationToken = "noToken",
                IsValidate           = true,
                LastName             = "TestLastName",
                LocationLatitude     = 0,
                LocationLongitude    = 0,
                NumberView           = 1,
                Password             = "******",
                PhoneNumber          = "33|64564866",
                RemainingRequest     = 1000,
                SocialNetworkType    = 0,
                SocialNetworkUserId  = null,
                UserPicture          = null
            };

            DataService.Email = _user.Email;
            DataService.Pass  = _user.Password;

            _seekios = new SeekiosDTO()
            {
                Idseekios                              = _idseekios,
                SeekiosName                            = "UnitTestSeekios",
                SeekiosPicture                         = null,
                SeekiosDateCreation                    = DateTime.Now,
                BatteryLife                            = 99,
                SignalQuality                          = 50,
                DateLastCommunication                  = DateTime.Now,
                LastKnownLocation_longitude            = 0.0,
                LastKnownLocation_latitude             = 0.0,
                LastKnownLocation_altitude             = 0.0,
                LastKnownLocation_accuracy             = 0.0,
                LastKnownLocation_dateLocationCreation = DateTime.Now,
                Subscription_idsubscription            = 2,
                Category_idcategory                    = 1,
                User_iduser                            = _iduser,
                HasGetLastInstruction                  = true,
                IsAlertLowBattery                      = true,
                IsInPowerSaving                        = false,
                PowerSaving_hourStart                  = 0,
                PowerSaving_hourEnd                    = 0,
                AlertSOS_idalert                       = null,
                IsRefreshingBattery                    = false,
                FreeCredit                             = 100000000
            };

            _mode = new ModeDTO()
            {
                DateModeCreation                    = DateTime.Now,
                Trame                               = "1",
                NotificationPush                    = 0,
                CountOfTriggeredAlert               = 0,
                LastTriggeredAlertDate              = DateTime.Now,
                Seekios_idseekios                   = _idseekios,
                ModeDefinition_idmodeDefinition     = (int)SeekiosApp.Enum.ModeDefinitionEnum.ModeTracking,
                StatusDefinition_idstatusDefinition = 1
            };

            alertes.Add(new AlertWithRecipientDTO()
            {
                IdAlertType = 1,
                Title       = "Test",
                Content     = "Test"
            });

            _alert = new AlertDTO()
            {
                IdAlertType = 1,
                IdMode      = _idmode,
                Title       = "Test",
                Content     = "Test"
            };

            var recipients = new List <AlertRecipientDTO>();

            recipients.Add(new AlertRecipientDTO()
            {
                Email       = "*****@*****.**",
                DisplayName = "TestDisplayname",
            });

            _alertwithrecipient = new AlertWithRecipientDTO()
            {
                IdAlert      = _idalert,
                IdAlertType  = 3,
                IdMode       = _idmode,
                Title        = "Test",
                Content      = "Test",
                LsRecipients = recipients
            };

            _listAlertWithRecipient.Add(_alertwithrecipient);
        }
Пример #11
0
 public IHttpActionResult CancelAlertOfProduct([FromBody] AlertDTO alert)
 {
     BL.FollowUpBL.CancelAlertOfProduct(alert);
     return(Ok(true));
 }
Пример #12
0
 public void Update(AlertDTO item)
 {
     item.TimeStamps = DateTime.Now;
     _unitOfWork.EFRepository <Alert>().Update(_mapper.Map <Alert>(item));
 }
Пример #13
0
 public void Create(AlertDTO item)
 {
     item.Id         = Guid.NewGuid().ToString();
     item.TimeStamps = DateTime.Now;
     _unitOfWork.EFRepository <Alert>().CreateAsync(_mapper.Map <Alert>(item));
 }
 public void GoToAlert(AlertDTO item)
 {
     App.Locator.Alert.IsNew = false;
     App.Locator.Alert.ConvertAlertDTOToClassMember(item);
     _navigationService.NavigateTo(App.ALERT_PAGE);
 }
Пример #15
0
 public async void Send(AlertDTO alert)
 {
     await Clients.All.SendAlert(alert);
 }