private bool AddIncident(PatrolsListViewModel ViewModel)
        {
            var serviceClient = new TFMIntegrationServiceClient();

            var result = serviceClient.AddIncidentAsync(ViewModel.SelectedPatrol.PatrolOriginalId, DateTime.Now, ViewModel.Latitude, ViewModel.Longitude, txtBlkComments.Text);

            return(result.Result);
        }
        public PatrolsListUserControl()
        {
            Properties.Resources.Culture = new CultureInfo(Utility.GetLang());

            InitializeComponent();
            vm          = new PatrolsListViewModel();
            DataContext = vm;
            listViewPatrolsList.Loaded += listViewPatrolsList_Loaded;
        }
Esempio n. 3
0
        private void PatrolsListUserControl_OnLoaded(object Sender, RoutedEventArgs E)
        {
            try
            {
                var sender = Sender as PatrolsListUserControl;
                if (sender == null)
                    return;

                PatrolsListViewModel vm = sender.DataContext as PatrolsListViewModel;
                if (vm == null)
                    return;
                var drawPatrolMessage = new DrawPatrolsMessage()
                {
                    Latitude = vm.Latitude,
                    Longitude = vm.Longitude,
                };

                drawPatrolMessage.PatrolsList = new ObservableCollection<PatrolLastLocationDTO>();
                foreach (var patrolLastLocationDto in vm.PatrolsList)
                {
                    drawPatrolMessage.PatrolsList.Add(new PatrolLastLocationDTO()
                    {
                        Latitude = patrolLastLocationDto.Latitude,
                        Altitude = patrolLastLocationDto.Altitude,
                        Longitude = patrolLastLocationDto.Longitude,
                        NumberOfAssignedIncident = patrolLastLocationDto.NumberOfAssignedIncident,
                        PatrolId = patrolLastLocationDto.PatrolId,
                        PatrolPlateNo = patrolLastLocationDto.PatrolPlateNo,
                        PatrolCode = patrolLastLocationDto.PatrolCode,
                        IsNoticed = patrolLastLocationDto.IsNoticed,
                        LocationDate = patrolLastLocationDto.LocationDate,
                        PatrolLatLocationId = patrolLastLocationDto.PatrolLatLocationId,
                        Speed = patrolLastLocationDto.Speed,
                        StatusName = patrolLastLocationDto.StatusName,
                        PatrolOriginalId = patrolLastLocationDto.PatrolOriginalId,
                        StatusId = patrolLastLocationDto.StatusId,
                        IsRecommended = patrolLastLocationDto.IsRecommended,
                        ETATime = patrolLastLocationDto.ETATime,
                        CreationDate = patrolLastLocationDto.CreationDate,
                        OfficerName = patrolLastLocationDto.OfficerName,
                        isPatrol = patrolLastLocationDto.isPatrol,
                        PatrolImage = patrolLastLocationDto.PatrolImage,
                        isDeleted = patrolLastLocationDto.isDeleted
                    });
                }

                this.Publish(drawPatrolMessage);
            }
            catch (Exception ex)
            {
                Utility.WriteLog(ex);
                MessageBox.Show(Utility.GetErrorMessage());
                Utility.LogOut();
            }
        }
        private bool AddDuty(PatrolsListViewModel ViewModel)
        {
            var serviceClient = new TFMIntegrationServiceClient();

            if (!serviceClient.ValidateBeforeAssignPatrol(ViewModel.NotificationId, ViewModel.SelectedPatrol.PatrolId))
            {
                //TODO: Show Message to tell the user that the patrol is already assigned.
                var msgBox = new MessageBoxUserControl(Properties.Resources.strPatrolAssignment, false);
                msgBox.Owner = Window.GetWindow(this);
                msgBox.ShowDialog();
                return(false);//Or true (Based on the scenario).
            }

            var result = serviceClient.AddDutyAsync(ViewModel.SelectedPatrol.PatrolOriginalId, txtBlkComments.Text, DateTime.Now, ViewModel.Latitude, ViewModel.Longitude, ViewModel.NotificationId, (int)ViewModel.SelectedPatrol.PatrolId);

            if (result.Result > 0)
            {
                serviceClient.UpdatePatrolCurrentTask(ViewModel.SelectedPatrol.PatrolOriginalId, result.Result);

                return(true);
            }

            return(false);
        }