private void NotifyAlert(SupervisorNotificationDTO alertToNotify) { CanvasEventArgs canvasEventArgs = null; if (_AlertNotificationMapViewModel.CurrentUserId == alertToNotify.ReceiverId && alertToNotify.ResponseToId != null && alertToNotify.ResponseToId > 0) { var alertControl = new AlertOperatorUserControl(alertToNotify); alertControl.ProcessNextAlert += alertControl_ProcessNextAlert; alertControl.AddChildContent += alertControl_AddChildContent; alertControl.GoToNextStep += alertControl_GoToNextStep; canvasEventArgs = new CanvasEventArgs { ChildControl = alertControl, Width = 400 }; } else { var alertControl = new AlertSuperVisorUserControl(alertToNotify); alertControl.ProcessNextAlert += alertControl_ProcessNextAlert; alertControl.AddChildContent += alertControl_AddChildContent; canvasEventArgs = new CanvasEventArgs { ChildControl = alertControl, Width = 400 }; } OnAddChildContent(this, canvasEventArgs); }
public NotifiedAlertViolatorDetailsUserControlViewModel(SupervisorNotificationDTO supervisorNotificationDTO) { _supervisorNotificationDTO = supervisorNotificationDTO; _ADPUTSclient = new ADPUTSServiceClient(); client = new ServiceLayerClient(); if (supervisorNotificationDTO.DangerousViolatorDetails != null && !string.IsNullOrEmpty(supervisorNotificationDTO.DangerousViolatorDetails.PlateNumber)) { GetDangerousVehicleDetails(supervisorNotificationDTO.DangerousViolatorDetails.PlateNumber); } GetLicenseDetails(); GetTrafficProfile(); if (supervisorNotificationDTO.DangerousViolatorDetails != null && supervisorNotificationDTO.DangerousViolatorDetails.BusinessRuleId != null) { GetBusinessRuleName(Convert.ToInt32(supervisorNotificationDTO.DangerousViolatorDetails.BusinessRuleId)); } if (supervisorNotificationDTO.DangerousViolatorDetails != null && !string.IsNullOrEmpty(supervisorNotificationDTO.DangerousViolatorDetails.MediaURL)) { IsAttachmentAvailable = true; } GetVehicleDetails(); _violatorDetailsExpanded = true; }
private void SaveNotificationResult(bool result, bool isApprove, SupervisorNotificationDTO req) { if (result) { SupervisorNotificationDTO.Status = isApprove ? SupervisorNotificationStatus.Approved : SupervisorNotificationStatus.Rejected; if (isApprove) { //string plateDetails = req.DangerousViolatorDetails.PlateNumber + "," + req.DangerousViolatorDetails.PlateKind + "," + req.DangerousViolatorDetails.PlateAuthority + "," + req.DangerousViolatorDetails.PlateColor; //var wantedCar = client.AddWantedCarEventAsync(plateDetails, SupervisorNotificationDTO.NotificationTime, Utility.GetLang(), businessRuleName, req.DangerousViolatorDetails.BusinessRuleId.ToString()); var wantedCar = client.AddWantedCarEventManualyAsync(req.DangerousViolatorDetails.PlateNumber, req.DangerousViolatorDetails.PlateKind, req.DangerousViolatorDetails.PlateAuthority, req.DangerousViolatorDetails.PlateColor, req.NotificationTime, Utility.GetLang(), businessRuleName, req.DangerousViolatorDetails.BusinessRuleId.ToString(), Convert.ToDouble(req.DangerousViolatorDetails.Lat), Convert.ToDouble(req.DangerousViolatorDetails.Lon)); wantedCar.ContinueWith(x => WantedCarResult(x.Status, x.IsCompleted)); } } else { SupervisorNotificationDTO.Status = SupervisorNotificationStatus.Pending; } var handler = NotificationHandled; if (handler != null) { handler(this, new EventArgs()); } }
public bool AddDangerousViolator(int senderUserId, int businessRuleId, double lat, double lon, string plateNumber, string plateColor, string plateSource, string plateKind, string ImageB64String, MediaTypes MediafileType, string MediaFileExtension) { SupervisorNotificationDTO violatorDetails = new SupervisorNotificationDTO(); violatorDetails.IsNoticed = false; violatorDetails.NotificationTime = DateTime.Now; violatorDetails.ReceiverId = new ServiceLayer().GetSupervisorId(); violatorDetails.SenderId = senderUserId; violatorDetails.Status = SupervisorNotificationStatus.Pending; violatorDetails.DangerousViolatorDetails = new SupervisorNotificationReportDangerousDTO { PlateNumber = plateNumber, PlateColor = plateColor, PlateAuthority = plateSource, PlateKind = plateKind, BusinessRuleId = businessRuleId, Lat = lat, Lon = lon, NotificationText = "Dangerous violator report from the smart officer", MediaURL = ImageB64String, MediaType = MediafileType, MediaFileFormat = MediaFileExtension }; return(new SupervisorNotificationDAL().SaveSupervisorNotification(violatorDetails)); }
private void NotifyRemainingAlerts() { while (!IsAlertProcessing && NotificationsToNotify != null && NotificationsToNotify.Count > 0) { SupervisorNotificationDTO alertToNotify = null; //get next alert from the list NotifyAlert(alertToNotify); } }
public AlertUserControlViewModel(SupervisorNotificationDTO supervisorNotificationDTO) { client = new ServiceLayerClient(); _supervisorNotificationDTO = supervisorNotificationDTO; if (_supervisorNotificationDTO != null && _supervisorNotificationDTO.ResponseToId == null) { GetUserName(_supervisorNotificationDTO.SenderId); } }
public bool SaveSupervisorNotification(SupervisorNotificationDTO supervisorNotification) { var notification = operationalDataContext.SupervisorNotifications.FirstOrDefault(x => x.SupervisorNotificationId == supervisorNotification.SupervisorNoticationId); if (notification == null) { notification = new SupervisorNotification(); notification.NotificationTime = supervisorNotification.NotificationTime; notification.SenderId = supervisorNotification.SenderId; notification.ReceiverId = supervisorNotification.ReceiverId; notification.IsNoticed = false; if (supervisorNotification.ResponseToId == 0) { notification.ResponseToId = null; } else { notification.ResponseToId = supervisorNotification.ResponseToId; if (notification.ResponseToId != null) { SetSupervisorNotificationNoticed(notification.ResponseToId.Value); } } notification.StatusId = (int)supervisorNotification.Status; operationalDataContext.SupervisorNotifications.Add(notification); notification.ReportDangerous.Add(new ReportDangerou { NotificationText = supervisorNotification.DangerousViolatorDetails.NotificationText, PlateNumber = supervisorNotification.DangerousViolatorDetails.PlateNumber, PlateAuthority = supervisorNotification.DangerousViolatorDetails.PlateAuthority, PlateColor = supervisorNotification.DangerousViolatorDetails.PlateColor, PlateKind = supervisorNotification.DangerousViolatorDetails.PlateKind, BusinessRuleId = supervisorNotification.DangerousViolatorDetails.BusinessRuleId, Lat = supervisorNotification.DangerousViolatorDetails.Lat, Lon = supervisorNotification.DangerousViolatorDetails.Lon, MediaURL = supervisorNotification.DangerousViolatorDetails.MediaURL, MediaType = (int)supervisorNotification.DangerousViolatorDetails.MediaType, SupervisorNotificationId = notification.SupervisorNotificationId, }); } else { //already exists } return(operationalDataContext.SaveChanges() > 0); }
private void ShowNotifiedAlertDetails(SupervisorNotificationDTO supervisorNotificationDTO) { var detailsCtrl = new NotifiedAlertViolatorDetailsUserControl(supervisorNotificationDTO); detailsCtrl.CloseCanvas += OnCloseCanvas; detailsCtrl.GoToNextStep += OnGoToNextStep; CanvasEventArgs canvasEventArgs = new CanvasEventArgs { ChildControl = detailsCtrl, Width = 400 }; OnAddChildContent(this, canvasEventArgs); }
public NotifiedAlertViolatorDetailsUserControl(SupervisorNotificationDTO supervisorNotificationDTO) { Properties.Resources.Culture = new CultureInfo(Utility.GetLang()); InitializeComponent(); _NotifiedAlertViolatorDetailsUcVM = new NotifiedAlertViolatorDetailsUserControlViewModel(supervisorNotificationDTO); _NotifiedAlertViolatorDetailsUcVM.NotificationHandled += _NotifiedAlertViolatorDetailsUcVM_NotificationHandled; DataContext = _NotifiedAlertViolatorDetailsUcVM; this.Loaded += NotifiedAlertViolatorDetailsUserControl_Loaded; //OnProcessNextAlert(new ProcessNextItemEventArgs() { CanProcessNextItem = false}); }
public AlertOperatorUserControl(SupervisorNotificationDTO supervisorNotificationDTO) { Properties.Resources.Culture = new CultureInfo(Utility.GetLang()); InitializeComponent(); _AlertUserControlVM = new AlertUserControlViewModel(supervisorNotificationDTO); DataContext = _AlertUserControlVM; Storyboard sb = new Storyboard(); sb = (Storyboard)TryFindResource("showAndHideAlertOpUC"); sb.Begin(); }
public List <SupervisorNotificationDTO> GetSupervisorNotificationsByUserId(int userId) { List <SupervisorNotificationDTO> lst = new List <SupervisorNotificationDTO>(); SupervisorNotificationDTO dto = null; var notifications = operationalDataContext.SupervisorNotifications.Where(x => (x.IsNoticed.HasValue && x.IsNoticed.Value == false) && x.ReceiverId == userId).ToList(); foreach (var y in notifications) { dto = new SupervisorNotificationDTO(); dto.SupervisorNoticationId = y.SupervisorNotificationId; dto.NotificationTime = y.NotificationTime.Value; dto.SenderId = y.SenderId.Value; dto.ReceiverId = y.ReceiverId.Value; dto.IsNoticed = y.IsNoticed.Value; dto.ResponseToId = y.ResponseToId == null ? 0 : y.ResponseToId.Value; dto.Status = (SupervisorNotificationStatus)y.StatusId; if (y.ReportDangerous != null && y.ReportDangerous.Count > 0) { dto.DangerousViolatorDetails = new SupervisorNotificationReportDangerousDTO(); dto.DangerousViolatorDetails.NotificationText = y.ReportDangerous.First().NotificationText; dto.DangerousViolatorDetails.ReportDangerousId = y.ReportDangerous.First().ReportDangerousId; dto.DangerousViolatorDetails.SupervisorNotificationId = y.SupervisorNotificationId; dto.DangerousViolatorDetails.PlateNumber = y.ReportDangerous.First().PlateNumber; dto.DangerousViolatorDetails.PlateAuthority = y.ReportDangerous.First().PlateAuthority; dto.DangerousViolatorDetails.PlateColor = y.ReportDangerous.First().PlateColor; dto.DangerousViolatorDetails.PlateKind = y.ReportDangerous.First().PlateKind; dto.DangerousViolatorDetails.BusinessRuleId = y.ReportDangerous.First().BusinessRuleId; dto.DangerousViolatorDetails.Lat = y.ReportDangerous.First().Lat; dto.DangerousViolatorDetails.Lon = y.ReportDangerous.First().Lon; dto.DangerousViolatorDetails.MediaURL = y.ReportDangerous.First().MediaURL; dto.DangerousViolatorDetails.BusinessRuleName = y.ReportDangerous.First().NewCorrelationRule != null?y.ReportDangerous.First().NewCorrelationRule.RuleName : ""; dto.DangerousViolatorDetails.MediaType = (MediaTypes)(y.ReportDangerous.First().MediaType ?? 0); } lst.Add(dto); } return(lst); }
private void UpdateSupervisorNotificationsBySignalR(SupervisorNotificationDTO newNotification) { //SupervisorNotifications = new ObservableCollection<SupervisorNotificationDTO>(supervisorNotifications); Application.Current.Dispatcher.Invoke(() => { if (newNotification == null) { return; } NewNotificationToNotify = newNotification; //if (CurrentUserId == SuperVisorId) // SupervisorNotifications = new ObservableCollection<SupervisorNotificationDTO>(dtoObj.Where(n => n.IsNoticed == false && n.Status == SupervisorNotificationStatus.Pending).ToList()); //else // SupervisorNotifications = new ObservableCollection<SupervisorNotificationDTO>(dtoObj.Where(n => n.IsNoticed == false && n.Status != SupervisorNotificationStatus.Pending).ToList()); }); }
public SupervisorNotificationDTO GetSupervisorNotificationById(int supervisorNotificationId) { SupervisorNotificationDTO dto = null; var y = operationalDataContext.SupervisorNotifications.Where(x => x.SupervisorNotificationId == supervisorNotificationId).FirstOrDefault(); if (y == null) { return(null); } dto = new SupervisorNotificationDTO(); dto.SupervisorNoticationId = y.SupervisorNotificationId; dto.NotificationTime = y.NotificationTime.Value; dto.SenderId = y.SenderId.Value; dto.ReceiverId = y.ReceiverId.Value; dto.IsNoticed = y.IsNoticed.Value; dto.ResponseToId = y.ResponseToId == null ? 0 : y.ResponseToId.Value; dto.Status = (SupervisorNotificationStatus)y.StatusId; if (y.ReportDangerous != null && y.ReportDangerous.Count > 0) { dto.DangerousViolatorDetails = new SupervisorNotificationReportDangerousDTO(); dto.DangerousViolatorDetails.NotificationText = y.ReportDangerous.First().NotificationText; dto.DangerousViolatorDetails.ReportDangerousId = y.ReportDangerous.First().ReportDangerousId; dto.DangerousViolatorDetails.SupervisorNotificationId = y.SupervisorNotificationId; dto.DangerousViolatorDetails.PlateNumber = y.ReportDangerous.First().PlateNumber; dto.DangerousViolatorDetails.PlateAuthority = y.ReportDangerous.First().PlateAuthority; dto.DangerousViolatorDetails.PlateColor = y.ReportDangerous.First().PlateColor; dto.DangerousViolatorDetails.PlateKind = y.ReportDangerous.First().PlateKind; dto.DangerousViolatorDetails.BusinessRuleId = y.ReportDangerous.First().BusinessRuleId; dto.DangerousViolatorDetails.Lat = y.ReportDangerous.First().Lat; dto.DangerousViolatorDetails.Lon = y.ReportDangerous.First().Lon; dto.DangerousViolatorDetails.MediaURL = y.ReportDangerous.First().MediaURL; dto.DangerousViolatorDetails.MediaType = (MediaTypes)y.ReportDangerous.First().MediaType; } return(dto); }
private void SubmitExecute() { ResponseMsg = string.Empty; string closeMsg = Properties.Resources.strAlertOpRoomConfMsg; //string closeMsg = Utility.GetLang() == "en" ? "Are you sure, want to Alert the Operation Room?" : "؟"; MessageBoxControl.MessageBoxUserControl closeMsgBox = new MessageBoxUserControl(closeMsg, true); //closeMsgBox.Owner = Window.GetWindow(this); closeMsgBox.ShowDialog(); var res = closeMsgBox.GetResult(); if (res == true) { SupervisorNotificationDTO req = new SupervisorNotificationDTO(); req.SenderId = currentUserId; req.ReceiverId = client.GetSupervisorId(); DateTime dtNow = DateTime.Now; //req.NotificationTime = dtNow; req.NotificationTime = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day, dtNow.Hour, dtNow.Minute, dtNow.Second, dtNow.Millisecond); req.IsNoticed = false; if (DangerousVehicleDetailsDTOobj != null) { req.DangerousViolatorDetails = new SupervisorNotificationReportDangerousDTO(); req.DangerousViolatorDetails.NotificationText = ReportMessage; req.DangerousViolatorDetails.PlateNumber = DangerousVehicleDetailsDTOobj.PlateNumber; req.DangerousViolatorDetails.PlateKind = DangerousVehicleDetailsDTOobj.PlateKind; req.DangerousViolatorDetails.PlateColor = DangerousVehicleDetailsDTOobj.PlateColor; req.DangerousViolatorDetails.PlateAuthority = DangerousVehicleDetailsDTOobj.PlateSource; } var saveRes = client.SaveSupervisorNotificationAsync(req); saveRes.ContinueWith(x => AlertOperationRoomResult(x.Result)); //AddBusinessRuleResult(true); } }
private void NotifyAlert(SupervisorNotificationDTO alertToNotify) { }
public void SetSupervisorNotificationNoticed(SupervisorNotificationDTO notification, bool isNoticed) { client.SetSupervisorNotificationNoticedAsync(notification.SupervisorNoticationId, isNoticed); }