Example #1
0
        /// <summary>
        ///   metodo della classe che si occupa di aggiornare lo stato operativo del mezzo
        /// </summary>
        /// <param name="codiceSede">il codice sede</param>
        /// <param name="codiceMezzo">il codice del mezzo (sigla.targa)</param>
        /// <param name="statoOperativo">lo stato operativo del mezzo</param>
        /// <param name="idRichiesta">l'id della richiesta a cui è associato il mezzo</param>
        public void Set(string codiceSede, string codiceMezzo, string statoOperativo, string idRichiesta)
        {
            var Richiesta = _dbContext.RichiestaAssistenzaCollection.Find(x => x.Codice.Equals(idRichiesta)).Single();

            foreach (var partenza in Richiesta.Partenze)
            {
                if (partenza.Partenza.Mezzo.Codice.Equals(codiceMezzo))
                {
                    partenza.Partenza.Mezzo.Stato = statoOperativo;
                }
            }

            _upDateRichiesta.UpDate(Richiesta);

            var statoMezzo = new StatoOperativoMezzo
            {
                CodiceMezzo     = codiceMezzo,
                CodiceSede      = codiceSede,
                CodiceRichiesta = idRichiesta,
                StatoOperativo  = statoOperativo
            };

            _dbContext.StatoMezzoCollection.FindOneAndReplace(Builders <StatoOperativoMezzo> .Filter.Eq(x => x.CodiceMezzo, codiceMezzo), statoMezzo, new FindOneAndReplaceOptions <StatoOperativoMezzo> {
                IsUpsert = true
            });
        }
Example #2
0
        public void Handle(PresaInCaricoCommand command)
        {
            var richiesta = _getRichiestaById.GetById(command.IdRichiesta);
            var utente    = _getUtenteById.GetUtenteByCodice(command.IdUtente);

            var nominativoPresaInCarico = utente.Nome + "." + utente.Cognome;

            if (richiesta.UtPresaInCarico != null)
            {
                new InizioPresaInCarico(richiesta, DateTime.UtcNow, richiesta.CodOperatore);

                if (!richiesta.UtPresaInCarico.Contains(nominativoPresaInCarico))
                {
                    richiesta.UtPresaInCarico.Add(nominativoPresaInCarico);
                }
            }
            else
            {
                richiesta.UtPresaInCarico = new List <string>
                {
                    nominativoPresaInCarico
                };
            }

            _updateRichiestaAssistenza.UpDate(richiesta);
        }
Example #3
0
        public void Handle(UpDateStatoRichiestaCommand command)
        {
            var richiesta = _getRichiestaById.GetById(command.IdRichiesta);

            if (command.Stato.Equals(Costanti.RichiestaChiusa) || command.Stato.Equals(Costanti.RichiestaSospesa))
            {
                foreach (var composizione in richiesta.Partenze)
                {
                    if (!composizione.Partenza.Mezzo.Stato.Equals(Costanti.MezzoInRientro) && !composizione.Partenza.Mezzo.Stato.Equals(Costanti.MezzoInSede))
                    {
                        if (!composizione.Partenza.Mezzo.Stato.Equals(Costanti.MezzoInSede) || !composizione.Partenza.Mezzo.Stato.Equals(Costanti.MezzoRientrato))
                        {
                            composizione.Partenza.Mezzo.Stato = Costanti.MezzoInRientro;
                        }

                        composizione.Partenza.Mezzo.IdRichiesta = null;

                        AggiornaStatoMezzoCommand statoMezzo = new AggiornaStatoMezzoCommand();
                        statoMezzo.CodiceSede = command.CodiceSede;
                        statoMezzo.IdMezzo    = composizione.Partenza.Mezzo.Codice;
                        statoMezzo.Richiesta  = richiesta;
                        statoMezzo.StatoMezzo = Costanti.MezzoInSede;
                        _upDatePartenza.Update(statoMezzo);
                    }
                }
            }

            richiesta.SincronizzaStatoRichiesta(command.Stato, richiesta.StatoRichiesta, command.IdOperatore, command.Note);
            if (command.Stato == Costanti.RichiestaRiaperta)
            {
                richiesta.IstanteChiusura = null;
            }

            _updateRichiestaAssistenza.UpDate(richiesta);
        }
Example #4
0
        /// <summary>
        ///   Il metodo accetta in firma il command, e aggiorna i dati relativi alla conferma della partenza
        /// </summary>
        /// <param name="command">il command in ingresso</param>
        /// <returns>ConfermaPartenze</returns>
        public ConfermaPartenze Update(ConfermaPartenzeCommand command)
        {
            var conferma = new ConfermaPartenze();

            _updateRichiesta.UpDate(command.ConfermaPartenze.richiesta);
            var tipologia = _getTipologieByCodice.Get(command.ConfermaPartenze.richiesta.Tipologie)[0];

            foreach (var partenza in command.ConfermaPartenze.Partenze)
            {
                var dataMovintazione = DateTime.UtcNow;

                //_setMovimentazione.Set(partenza.Mezzo.Codice, DateTime.UtcNow, command.ConfermaPartenze.IdRichiesta, tipologia.Codice, tipologia.Descrizione); //TODO IMPLEMENTARE CON GAC
                _setStatoOperativoMezzo.Set(command.ConfermaPartenze.CodiceSede, partenza.Mezzo.Codice, Costanti.MezzoInViaggio, command.ConfermaPartenze.IdRichiesta);

                foreach (var squadra in partenza.Squadre)
                {
                    _setStatoSquadra.SetStato(squadra.Codice, command.ConfermaPartenze.IdRichiesta, Costanti.MezzoInViaggio, command.ConfermaPartenze.CodiceSede);
                }
            }

            conferma.CodiceSede  = command.ConfermaPartenze.CodiceSede;
            conferma.IdRichiesta = command.ConfermaPartenze.IdRichiesta;
            conferma.richiesta   = command.ConfermaPartenze.richiesta;
            return(conferma);
        }
Example #5
0
        public void Handle(RimozionePresaInCaricoCommand command)
        {
            var richiesta = _getRichiestaById.GetById(command.IdRichiesta);

            new AnnullamentoPresaInCarico(richiesta, DateTime.UtcNow, richiesta.CodOperatore);

            _updateRichiestaAssistenza.UpDate(richiesta);
        }
Example #6
0
        public void Handle(UpDateInterventoCommand command)
        {
            var richiesta            = _getRichiestaById.GetByCodice(command.Chiamata.Codice);
            var priorita             = command.Chiamata.PrioritaRichiesta;
            var listaCodiciTipologie = new List <string>();
            var utentiInLavorazione  = new List <string>();
            var utentiPresaInCarico  = new List <string>();

            foreach (var tipologia in command.Chiamata.Tipologie)
            {
                listaCodiciTipologie.Add(tipologia.Codice);
            }
            foreach (var utente in command.Chiamata.ListaUtentiInLavorazione)
            {
                utentiInLavorazione.Add(utente.Nominativo);
            }
            foreach (var utente in command.Chiamata.ListaUtentiPresaInCarico)
            {
                utentiPresaInCarico.Add(utente.Nominativo);
            }

            richiesta.Tipologie          = listaCodiciTipologie;
            richiesta.CodZoneEmergenza   = command.Chiamata.ZoneEmergenza;
            richiesta.Richiedente        = command.Chiamata.Richiedente;
            richiesta.Localita           = command.Chiamata.Localita;
            richiesta.Descrizione        = command.Chiamata.Descrizione;
            richiesta.TipoTerreno        = command.Chiamata.TipoTerreno;
            richiesta.ObiettivoSensibile = command.Chiamata.ObiettivoSensibile;
            richiesta.UtInLavorazione    = utentiInLavorazione;
            richiesta.UtPresaInCarico    = utentiPresaInCarico;
            richiesta.NotePrivate        = command.Chiamata.NotePrivate;
            richiesta.NotePubbliche      = command.Chiamata.NotePubbliche;
            richiesta.CodEntiIntervenuti = command.Chiamata.listaEnti.Select(c => c.ToString()).ToList();

            if (command.Chiamata.Tags != null)
            {
                foreach (var t in command.Chiamata.Tags)
                {
                    richiesta.Tags.Add(t);
                }
            }

            richiesta.SincronizzaStatoRichiesta(command.Chiamata.Stato, richiesta.StatoRichiesta, command.CodUtente, command.Chiamata.Motivazione, DateTime.UtcNow);

            if (command.Chiamata.RilevanteGrave != richiesta.RilevanteGrave || command.Chiamata.RilevanteStArCu != richiesta.RilevanteStArCu)
            {
                new MarcaRilevante(richiesta, DateTime.UtcNow.AddMilliseconds(1.5), command.CodUtente, "", command.Chiamata.RilevanteGrave, command.Chiamata.RilevanteStArCu);
            }

            var prioritaRichiesta = (RichiestaAssistenza.Priorita)command.Chiamata.PrioritaRichiesta;

            if (richiesta.PrioritaRichiesta != prioritaRichiesta)
            {
                new AssegnazionePriorita(richiesta, prioritaRichiesta, DateTime.UtcNow, command.CodUtente);
            }

            _updateRichiestaAssistenza.UpDate(richiesta);
        }
Example #7
0
        public void Handle(RimozioneInLavorazioneCommand command)
        {
            var richiesta = _getRichiestaById.GetById(command.IdRichiesta);
            var utente    = _getUtenteById.GetUtenteByCodice(command.IdUtente);
            var attivita  = new AttivitaUtente();

            var nominativo = utente.Nome + "." + utente.Cognome;

            richiesta.UtInLavorazione.RemoveAll(x => x == nominativo);

            _updateRichiestaAssistenza.UpDate(richiesta);
        }
Example #8
0
        public void Handle(AllertaAltreSediCommand command)
        {
            var richiesta = _getRichiestaById.GetByCodice(command.CodiceRichiesta);

            if (richiesta.CodSOAllertate != null && richiesta.CodSOAllertate.Count > 0)
            {
                command.CodSediAllertateOld = richiesta.CodSOAllertate.ToArray();
            }

            richiesta.CodSOAllertate = command.CodSediAllertate.ToHashSet();

            new AllertaSedi(richiesta, DateTime.UtcNow, command.CodUtente, "Allerta", command.CodSediAllertate);

            _updateRichiestaAssistenza.UpDate(richiesta);
        }
Example #9
0
        public void Handle(RimozioneInLavorazioneCommand command)
        {
            var richiesta = _getRichiestaById.GetById(command.IdRichiesta);
            var attivita  = new AttivitaUtente();

            richiesta.UtInLavorazione.RemoveAll(x => x == command.IdUtente);

            //if (command.Chiamata.ListaUtentiInLavorazione != null)
            //    command.Chiamata.ListaUtentiInLavorazione = richiesta.UtInLavorazione;
            //else
            //{
            //    if (richiesta.UtInLavorazione.Count > 0)
            //    {
            //        command.Chiamata.ListaUtentiInLavorazione = new List<AttivitaUtente>();
            //        command.Chiamata.ListaUtentiInLavorazione = richiesta.UtInLavorazione;
            //    }
            //}

            _updateRichiestaAssistenza.UpDate(richiesta);
        }
        public void Handle(RimozionePresaInCaricoCommand command)
        {
            var richiesta = _getRichiestaById.GetByCodice(command.IdRichiesta);

            richiesta.Id = richiesta.Codice;

            richiesta.UtPresaInCarico.RemoveAll(x => x == command.IdUtente);

            //if (command.Chiamata.ListaUtentiPresaInCarico != null)
            //    command.Chiamata.ListaUtentiPresaInCarico = richiesta.UtPresaInCarico;
            //else
            //{
            //    if (richiesta.UtPresaInCarico.Count > 0)
            //    {
            //        command.Chiamata.ListaUtentiPresaInCarico = new List<AttivitaUtente>();
            //        command.Chiamata.ListaUtentiPresaInCarico = richiesta.UtPresaInCarico;
            //    }
            //}

            _updateRichiestaAssistenza.UpDate(richiesta);
        }
Example #11
0
        public void Handle(UpDateInterventoCommand command)
        {
            var richiesta = _getRichiestaById.Get(command.Chiamata.Codice);
            var priorita  = command.Chiamata.PrioritaRichiesta;

            richiesta.Tipologie                = command.Chiamata.Tipologie;
            richiesta.ZoneEmergenza            = command.Chiamata.ZoneEmergenza;
            richiesta.Operatore                = command.Chiamata.Operatore;
            richiesta.Richiedente              = command.Chiamata.Richiedente;
            richiesta.Localita                 = command.Chiamata.Localita;
            richiesta.Descrizione              = command.Chiamata.Descrizione;
            richiesta.TurnoInserimentoChiamata = command.Chiamata.TurnoInserimentoChiamata;
            richiesta.TipoTerreno              = command.Chiamata.TipoTerreno;
            richiesta.ListaEntiIntervenuti     = command.Chiamata.ListaEntiIntervenuti;
            richiesta.ObiettivoSensibile       = command.Chiamata.ObiettivoSensibile;
            richiesta.ListaUtentiInLavorazione = command.Chiamata.ListaUtentiInLavorazione;
            richiesta.ListaUtentiPresaInCarico = command.Chiamata.ListaUtentiPresaInCarico;
            richiesta.NotePrivate              = command.Chiamata.NotePrivate;
            richiesta.NotePubbliche            = command.Chiamata.NotePubbliche;
            richiesta.Id = command.Chiamata.Codice;

            if (command.Chiamata.Tags != null)
            {
                foreach (var t in command.Chiamata.Tags)
                {
                    richiesta.Tags.Add(t);
                }
            }

            richiesta.SincronizzaRilevanza(command.Chiamata.RilevanteGrave, command.Chiamata.RilevanteStArCu, command.Chiamata.Operatore.Id, command.Chiamata.Descrizione, DateTime.UtcNow);

            richiesta.SincronizzaStatoRichiesta(command.Chiamata.Stato, richiesta.StatoRichiesta, command.Chiamata.Operatore.Id, command.Chiamata.Motivazione);

            if (richiesta.PrioritaRichiesta != command.Chiamata.PrioritaRichiesta)
            {
                new AssegnazionePriorita(richiesta, priorita, DateTime.UtcNow, command.Chiamata.Operatore.Id);
            }

            _updateRichiestaAssistenza.UpDate(richiesta);
        }
        public void Handle(PresaInCaricoCommand command)
        {
            var richiesta = _getRichiestaById.Get(command.IdRichiesta);
            var utente    = _getUtenteById.GetUtenteById(command.IdUtente);
            var attivita  = new AttivitaUtente
            {
                IdUtente           = utente.Id,
                Nominativo         = utente.Nome + " " + utente.Cognome,
                DataInizioAttivita = DateTime.UtcNow
            };

            richiesta.Id = richiesta.Codice;
            if (richiesta.ListaUtentiPresaInCarico != null)
            {
                new InizioPresaInCarico(richiesta, DateTime.UtcNow, richiesta.Operatore.Id);

                richiesta.ListaUtentiPresaInCarico.Add(attivita);
            }
            else
            {
                richiesta.ListaUtentiPresaInCarico = new List <AttivitaUtente>
                {
                    attivita
                };
            }

            if (command.Chiamata.ListaUtentiPresaInCarico != null)
            {
                command.Chiamata.ListaUtentiPresaInCarico.Add(attivita);
            }
            else
            {
                richiesta.ListaUtentiPresaInCarico = new List <AttivitaUtente>();
                command.Chiamata.ListaUtentiPresaInCarico.Add(attivita);
            }

            _updateRichiestaAssistenza.UpDate(richiesta);
        }
Example #13
0
        public void Handle(AnnullaPartenzaCommand command)
        {
            var PartenzaToDelete = command.Richiesta.Partenze.Where(x => x.Partenza.Mezzo.Codice.Equals(command.TargaMezzo)).FirstOrDefault();

            switch (command.CodMotivazione)
            {
            case 1:
                new RevocaPerInterventoNonPiuNecessario(command.Richiesta, command.TargaMezzo, DateTime.Now, command.IdOperatore, PartenzaToDelete.Partenza.Codice);
                break;

            case 2:
                var richiestaSubentrata = _getRichiestaById.GetByCodice(command.CodRichiestaSubentrata);
                if (richiestaSubentrata == null)
                {
                    richiestaSubentrata = _getRichiestaById.GetByCodiceRichiesta(command.CodRichiestaSubentrata);
                }

                new RevocaPerRiassegnazione(command.Richiesta, richiestaSubentrata, command.TargaMezzo, DateTime.Now, command.IdOperatore, PartenzaToDelete.Partenza.Codice);
                break;

            case 3:
                new RevocaPerFuoriServizio(command.Richiesta, command.TargaMezzo, DateTime.Now, command.IdOperatore, PartenzaToDelete.Partenza.Codice);
                break;

            case 4:
                new RevocaPerAltraMotivazione(command.Richiesta, command.TargaMezzo, DateTime.Now, command.IdOperatore, command.TestoMotivazione, PartenzaToDelete.Partenza.Codice);
                break;
            }
            _upDateRichiestaAssistenza.UpDate(command.Richiesta);

            AggiornaStatoMezzoCommand commandStatoMezzo = new AggiornaStatoMezzoCommand();

            commandStatoMezzo.CodiciSede = new string[] { PartenzaToDelete.Partenza.Mezzo.Distaccamento.Codice };
            commandStatoMezzo.IdMezzo    = command.TargaMezzo;
            commandStatoMezzo.StatoMezzo = Costanti.MezzoInSede;
            commandStatoMezzo.Richiesta  = command.Richiesta;
            _updateStatoPartenze.Update(commandStatoMezzo);
        }
Example #14
0
        public void Handle(RimozionePresaInCaricoCommand command)
        {
            var richiesta = _getRichiestaById.Get(command.IdRichiesta);

            richiesta.Id = richiesta.Codice;

            richiesta.ListaUtentiPresaInCarico.RemoveAll(x => x.IdUtente == command.IdUtente);

            if (command.Chiamata.ListaUtentiPresaInCarico != null)
            {
                command.Chiamata.ListaUtentiPresaInCarico = richiesta.ListaUtentiPresaInCarico;
            }
            else
            {
                if (richiesta.ListaUtentiPresaInCarico.Count > 0)
                {
                    command.Chiamata.ListaUtentiPresaInCarico = new List <AttivitaUtente>();
                    command.Chiamata.ListaUtentiPresaInCarico = richiesta.ListaUtentiPresaInCarico;
                }
            }

            _updateRichiestaAssistenza.UpDate(richiesta);
        }
Example #15
0
        public void Handle(RimozioneInLavorazioneCommand command)
        {
            var richiesta = _getRichiestaById.Get(command.IdRichiesta);
            var attivita  = new AttivitaUtente();

            richiesta.ListaUtentiInLavorazione.RemoveAll(x => x.IdUtente == command.IdUtente);

            richiesta.Id = richiesta.Codice;

            if (command.Chiamata.ListaUtentiInLavorazione != null)
            {
                command.Chiamata.ListaUtentiInLavorazione = richiesta.ListaUtentiInLavorazione;
            }
            else
            {
                if (richiesta.ListaUtentiInLavorazione.Count > 0)
                {
                    command.Chiamata.ListaUtentiInLavorazione = new List <AttivitaUtente>();
                    command.Chiamata.ListaUtentiInLavorazione = richiesta.ListaUtentiInLavorazione;
                }
            }

            _updateRichiestaAssistenza.UpDate(richiesta);
        }
Example #16
0
        public void Handle(UpDateStatoRichiestaCommand command)
        {
            var richiesta = _getRichiestaById.Get(command.IdRichiesta);

            if (command.Stato.Equals(Costanti.RichiestaChiusa) || command.Stato.Equals(Costanti.RichiestaSospesa))
            {
                foreach (var composizione in richiesta.Partenze)
                {
                    if (!composizione.Partenza.Mezzo.Stato.Equals(Costanti.MezzoInRientro) && !composizione.Partenza.Mezzo.Stato.Equals(Costanti.MezzoInSede))
                    {
                        composizione.Partenza.Mezzo.Stato       = Costanti.MezzoInRientro;
                        composizione.Partenza.Mezzo.IdRichiesta = null;
                    }
                }
            }

            richiesta.SincronizzaStatoRichiesta(command.Stato, richiesta.StatoRichiesta, command.IdOperatore, command.Note);
            if (command.Stato == Costanti.RichiestaRiaperta)
            {
                richiesta.IstanteChiusura = null;
            }

            _updateRichiestaAssistenza.UpDate(richiesta);
        }
Example #17
0
        /// <summary>
        ///   Query che estrae i valori dei Box presenti in Home Page
        /// </summary>
        /// <param name="query">Filtri utilizzati per l'estrazione</param>
        /// <returns>Elenco dei mezzi disponibili</returns>
        public void Handle(ConfermaPartenzeCommand command)
        {
            /// preparazione del DTO
            var richiesta            = _getRichiestaById.Get(command.ConfermaPartenze.IdRichiesta);
            var richiestaDaSganciare = new RichiestaAssistenza();

            var attivita = new AttivitaUtente();
            var idComposizioneDaSganciare = 0;

            ///Gestione Sganciamento
            if (command.ConfermaPartenze.IdRichiestaDaSganciare != null)
            {
                richiestaDaSganciare = _getRichiestaById.Get(command.ConfermaPartenze.IdRichiestaDaSganciare);

                foreach (var composizione in richiestaDaSganciare.Eventi.Where(x => x is ComposizionePartenze).ToList())
                {
                    if (((ComposizionePartenze)composizione).Partenza.Mezzo.Codice.Equals(command.ConfermaPartenze.IdMezzoDaSganciare))
                    {
                        ((ComposizionePartenze)composizione).Partenza.Sganciata = true;
                    }

                    idComposizioneDaSganciare++;
                }

                foreach (var composizione in richiestaDaSganciare.Partenze)
                {
                    if (composizione.Partenza.Mezzo.Codice.Equals(command.ConfermaPartenze.IdMezzoDaSganciare))
                    {
                        composizione.Partenza.Sganciata = true;
                    }
                }

                if (idComposizioneDaSganciare == 1)
                {
                    richiestaDaSganciare.SincronizzaStatoRichiesta(Costanti.RichiestaSospesa, richiestaDaSganciare.StatoRichiesta, richiestaDaSganciare.Operatore.Id, "");
                }

                //new RevocaPerRiassegnazione(richiesta, richiestaDaSganciare, command.ConfermaPartenze.IdMezzoDaSganciare, DateTime.UtcNow, richiesta.Operatore.Id);
                _updateRichiestaAssistenza.UpDate(richiestaDaSganciare);
            }

            if (richiesta.Eventi.Where(x => x is InizioPresaInCarico).ToList().Count == 0)
            {
                new InizioPresaInCarico(richiesta, DateTime.UtcNow, richiesta.Operatore.Id);
            }

            foreach (var partenza in command.ConfermaPartenze.Partenze)
            {
                new ComposizionePartenze(richiesta, DateTime.UtcNow, richiesta.Operatore.Id, false)
                {
                    Partenza = partenza
                };
            }

            richiesta.SincronizzaStatoRichiesta(Costanti.RichiestaAssegnata, richiesta.StatoRichiesta, richiesta.Operatore.Id, "");

            richiesta.Id = command.ConfermaPartenze.IdRichiesta;
            command.ConfermaPartenze.richiesta = richiesta;

            var sedeRichiesta = command.ConfermaPartenze.richiesta.Operatore.Sede.Codice;

            richiesta.CodiceRichiesta = _generaCodiceRichiesta.Genera(sedeRichiesta, DateTime.UtcNow.Year);

            foreach (var partenza in command.ConfermaPartenze.Partenze)
            {
                partenza.Mezzo.IdRichiesta = richiesta.CodiceRichiesta;
            }

            attivita.IdUtente           = command.ConfermaPartenze.richiesta.Operatore.Id;
            attivita.Nominativo         = command.ConfermaPartenze.richiesta.Operatore.Nome + " " + command.ConfermaPartenze.richiesta.Operatore.Cognome;
            attivita.DataInizioAttivita = DateTime.UtcNow;

            if (richiesta.ListaUtentiPresaInCarico != null)
            {
                richiesta.ListaUtentiPresaInCarico.Add(attivita);
            }
            else
            {
                richiesta.ListaUtentiPresaInCarico = new List <AttivitaUtente>
                {
                    attivita
                };
            }

            foreach (var partenze in command.ConfermaPartenze.Partenze)
            {
                foreach (var squadra in partenze.Squadre)
                {
                    squadra.Stato = MappaStatoSquadraDaStatoMezzo.MappaStato(partenze.Mezzo.Stato);
                }
            }
            var confermaPartenze = _updateConfermaPartenze.Update(command);

            command.ConfermaPartenze.CodiceSede = confermaPartenze.CodiceSede;
        }
Example #18
0
 /// <summary>
 ///   Il metodo accetta in firma la richiesta, e in seguito alla chiusura o riapertura della
 ///   richiesta aggiorna i dati relativi a quella richiesta
 /// </summary>
 /// <param name="richiestaAssistenza">la richiesta assistenza</param>
 public void UpDate(RichiestaAssistenza richiestaAssistenza)
 {
     _upDateRichiestaAssistenza.UpDate(richiestaAssistenza);
 }
Example #19
0
        /// <summary>
        ///   Il metodo accetta in firma il command, e aggiorna i dati relativi alla conferma della partenza
        /// </summary>
        /// <param name="command">il command in ingresso</param>
        /// <returns>ConfermaPartenze</returns>
        public ConfermaPartenze Update(ConfermaPartenzeCommand command)
        {
            var conferma = new ConfermaPartenze();

            _updateRichiesta.UpDate(command.ConfermaPartenze.richiesta);

            var codiceSede = command.ConfermaPartenze.CodiceSede.Split(",", StringSplitOptions.RemoveEmptyEntries)[0];

            foreach (var partenza in command.ConfermaPartenze.Partenze)
            {
                var dataMovintazione = DateTime.UtcNow;

                _setStatoOperativoMezzo.Set(codiceSede, partenza.Mezzo.Codice, partenza.Mezzo.Stato, command.ConfermaPartenze.richiesta.Codice);

                foreach (var squadra in partenza.Squadre)
                {
                    _setStatoSquadra.SetStato(squadra.Codice, command.ConfermaPartenze.IdRichiesta, partenza.Mezzo.Stato, codiceSede, partenza.Mezzo.Codice);
                }

                var dataIntervento = command.Richiesta.ListaEventi.OfType <Telefonata>().FirstOrDefault(p => p.CodiceRichiesta.Equals(command.Richiesta.Codice)).Istante;

                //GAC USCITA/ENTRATA
                if (!partenza.Mezzo.Stato.Equals(Costanti.MezzoInUscita))
                {
                    if (partenza.Mezzo.Stato.Equals(Costanti.MezzoInSede) || partenza.Mezzo.Stato.Equals(Costanti.MezzoRientrato))
                    {
                        var dataRientro = command.Richiesta.ListaEventi.OfType <PartenzaRientrata>().FirstOrDefault(p => p.CodicePartenza.Equals(partenza.Codice)).Istante;
                        _setRientroMezzo.Set(new RientroGAC()
                        {
                            targa            = partenza.Mezzo.Codice.Split('.')[1],
                            tipoMezzo        = partenza.Mezzo.Codice.Split('.')[0],
                            idPartenza       = partenza.Codice.ToString(),
                            numeroIntervento = command.Richiesta.CodRichiesta,
                            dataIntervento   = dataIntervento,
                            dataRientro      = dataRientro,
                            autista          = ""
                        });
                    }
                    else if (partenza.Mezzo.Stato.Equals(Costanti.MezzoInViaggio))
                    {
                        var dataUscita = command.Richiesta.ListaEventi.OfType <ComposizionePartenze>().FirstOrDefault(p => p.Partenza.Codice.Equals(partenza.Codice)).Istante;
                        _setUscitaMezzo.Set(new UscitaGAC()
                        {
                            targa            = partenza.Mezzo.Codice.Split('.')[1],
                            tipoMezzo        = partenza.Mezzo.Codice.Split('.')[0],
                            idPartenza       = partenza.Codice.ToString(),
                            numeroIntervento = command.Richiesta.CodRichiesta,
                            dataIntervento   = dataIntervento,
                            dataUscita       = dataUscita,
                            autista          = "",
                            tipoUscita       = new TipoUscita()
                            {
                                codice      = "",
                                descrizione = "Servizio"
                            },
                            comune = new ComuneGAC()
                            {
                                codice      = "",
                                descrizione = command.Richiesta.Localita.Citta,
                            },
                            provincia = new Models.Classi.Gac.ProvinciaGAC()
                            {
                                codice      = "",
                                descrizione = command.Richiesta.Localita.Provincia
                            },
                            localita    = command.Richiesta.Localita.Citta,
                            latitudine  = command.Richiesta.Localita.Coordinate.Latitudine.ToString(),
                            longitudine = command.Richiesta.Localita.Coordinate.Longitudine.ToString(),
                        });
                    }
                }
            }

            conferma.CodiceSede  = command.ConfermaPartenze.CodiceSede;
            conferma.IdRichiesta = command.ConfermaPartenze.IdRichiesta;
            conferma.richiesta   = command.ConfermaPartenze.richiesta;
            return(conferma);
        }
Example #20
0
        public async void Handle(SostituzionePartenzaCommand command)
        {
            Parallel.ForEach(command.sostituzione.Sostituzioni, sostituzione =>
            {
                #region GESTIONE NOTE

                string NoteSquadreSmontanti = "";
                string NoteSquadreMontanti  = "";
                if (sostituzione.SquadreSmontanti.Count() > 1)
                {
                    foreach (var squadra in sostituzione.SquadreSmontanti)
                    {
                        NoteSquadreSmontanti = NoteSquadreSmontanti + squadra + ",";
                    }

                    NoteSquadreSmontanti = "Le squadre " + NoteSquadreSmontanti.Substring(0, NoteSquadreSmontanti.Length - 1) + " vengono sostituite ";
                }
                else
                {
                    NoteSquadreSmontanti = "La squadra " + sostituzione.SquadreSmontanti[0] + " viene sostituita ";
                }

                if (sostituzione.SquadreMontanti.Count() > 1)
                {
                    foreach (var squadra in sostituzione.SquadreMontanti)
                    {
                        NoteSquadreMontanti = NoteSquadreMontanti + squadra + ",";
                    }

                    NoteSquadreMontanti = " dalle squadre " + NoteSquadreMontanti.Substring(0, NoteSquadreMontanti.Length - 1);
                }
                else
                {
                    NoteSquadreMontanti = " dalla squadra " + sostituzione.SquadreMontanti[0];
                }

                string Note = NoteSquadreSmontanti + NoteSquadreMontanti + " sul mezzo " + sostituzione.CodMezzoSmontante + " tornando in sede con il mezzo " + sostituzione.CodMezzoMontante;

                #endregion

                #region GESTIONE RICHIESTA E EVENTI RICIHESTA

                new SostituzionePartenzaFineTurno(command.Richiesta, sostituzione.CodMezzoSmontante, command.sostituzione.DataOraOperazione, command.sostituzione.idOperatore, Note);

                var PartenzaMontante  = command.Richiesta.Partenze.FirstOrDefault(x => x.Partenza.Mezzo.Codice.Equals(sostituzione.CodMezzoMontante) && x.PartenzaAnnullata == false && x.Partenza.Terminata == false && x.Partenza.Sganciata == false);
                var PartenzaSmontante = command.Richiesta.Partenze.FirstOrDefault(x => x.Partenza.Mezzo.Codice.Equals(sostituzione.CodMezzoSmontante) && x.PartenzaAnnullata == false && x.Partenza.Terminata == false && x.Partenza.Sganciata == false);
                var SquadreSwitch     = PartenzaSmontante.Partenza.Squadre;

                //GESTIONE PARTENZA SMONTANTE
                PartenzaSmontante.Partenza.Squadre   = PartenzaMontante.Partenza.Squadre;
                PartenzaSmontante.Partenza.Terminata = true;

                //GESTIONE PARTENZA MONTANTE
                PartenzaMontante.Partenza.Squadre   = PartenzaSmontante.Partenza.Squadre;
                PartenzaMontante.Partenza.Terminata = true;

                //GESTIONE NUOVA PARTENZA SMONTANTE
                var PartenzaSmontanteNuova = new ComposizionePartenze(command.Richiesta, DateTime.Now, command.sostituzione.idOperatore, false)
                {
                    Partenza = new Partenza()
                    {
                        Codice  = command.Richiesta.CodiceUltimaPartenza + 1,
                        Mezzo   = PartenzaSmontante.Partenza.Mezzo,
                        Squadre = PartenzaMontante.Partenza.Squadre
                    }
                };

                //GESTIONE NUOVA PARTENZA MONTANTE
                var PartenzaMontanteNuova = new ComposizionePartenze(command.Richiesta, DateTime.Now, command.sostituzione.idOperatore, false)
                {
                    Partenza = new Partenza()
                    {
                        Codice  = command.Richiesta.CodiceUltimaPartenza + 1,
                        Mezzo   = PartenzaMontante.Partenza.Mezzo,
                        Squadre = SquadreSwitch
                    }
                };

                var CodSede = PartenzaSmontante.Partenza.Mezzo.Distaccamento.Codice;

                _updateRichiesta.UpDate(command.Richiesta);

                #endregion

                #region Comunicazione a servizi GAC

                //RIENTRO SMONTANTE

                Task.Factory.StartNew(async() =>
                {
                    _rientroMezzo.Set(new RientroGAC()
                    {
                        idPartenza       = PartenzaSmontante.Partenza.Codice.ToString(),
                        dataIntervento   = PartenzaSmontante.DataOraInserimento,
                        numeroIntervento = command.Richiesta.CodRichiesta,
                        dataRientro      = PartenzaSmontante.DataOraInserimento,
                        targa            = PartenzaSmontante.Partenza.Mezzo.Codice,
                        tipoMezzo        = PartenzaSmontante.Partenza.Mezzo.Genere
                    });

                    //RIENTRO MONTANTE
                    _rientroMezzo.Set(new RientroGAC()
                    {
                        idPartenza       = PartenzaMontante.Partenza.Codice.ToString(),
                        dataIntervento   = PartenzaMontante.DataOraInserimento,
                        numeroIntervento = command.Richiesta.CodRichiesta,
                        dataRientro      = PartenzaMontante.DataOraInserimento,
                        targa            = PartenzaMontante.Partenza.Mezzo.Codice,
                        tipoMezzo        = PartenzaMontante.Partenza.Mezzo.Genere
                    });

                    //USCITA NUOVA PARTENZA MONTANTE
                    _uscitaMezzo.Set(new UscitaGAC()
                    {
                        idPartenza       = PartenzaMontanteNuova.Partenza.Codice.ToString(),
                        dataIntervento   = PartenzaMontanteNuova.DataOraInserimento,
                        numeroIntervento = command.Richiesta.CodRichiesta,
                        dataUscita       = PartenzaMontanteNuova.DataOraInserimento,
                        targa            = PartenzaMontanteNuova.Partenza.Mezzo.Codice,
                        tipoMezzo        = PartenzaMontanteNuova.Partenza.Mezzo.Genere
                    });

                    //USCITA NUOVA PARTENZA SMONTANTE
                    _uscitaMezzo.Set(new UscitaGAC()
                    {
                        idPartenza       = PartenzaSmontanteNuova.Partenza.Codice.ToString(),
                        dataIntervento   = PartenzaSmontanteNuova.DataOraInserimento,
                        numeroIntervento = command.Richiesta.CodRichiesta,
                        dataUscita       = PartenzaSmontanteNuova.DataOraInserimento,
                        targa            = PartenzaSmontanteNuova.Partenza.Mezzo.Codice,
                        tipoMezzo        = PartenzaSmontanteNuova.Partenza.Mezzo.Genere
                    });
                });

                #endregion
            });
        }
Example #21
0
        /// <summary>
        ///   Il metodo accetta in firma il command, e in seguito al cambio di stato di uno o più
        ///   mezzi aggiorna le informazioni relative alla richiesta a cui quel mezzo è associato
        /// </summary>
        /// <param name="command">il command in ingresso</param>

        public void Update(AggiornaStatoMezzoCommand command)
        {
            _upDateRichiesta.UpDate(command.Richiesta);

            var codiceSedeMezzo = command.CodiciSede.First();

            _setStatoOperativoMezzo.Set(codiceSedeMezzo, command.IdMezzo, command.StatoMezzo, command.Richiesta.Codice);

            var dataMovintazione = DateTime.Now;

            var dataIntervento = command.Richiesta.ListaEventi.OfType <Telefonata>().FirstOrDefault(p => p.CodiceRichiesta.Equals(command.Richiesta.Codice)).Istante;

            foreach (var partenza in command.Richiesta.Partenze.Where(c => c.Partenza.Mezzo.Codice == command.IdMezzo))
            {
                foreach (var squadra in partenza.Partenza.Squadre)
                {
                    _setStatoSquadra.SetStato(squadra.Codice, command.Richiesta.Id, command.StatoMezzo, codiceSedeMezzo, command.IdMezzo);
                }

                if (!partenza.Partenza.Mezzo.Stato.Equals(Costanti.MezzoInUscita))
                {
                    if (partenza.Partenza.Mezzo.Stato.Equals(Costanti.MezzoInSede) || partenza.Partenza.Mezzo.Stato.Equals(Costanti.MezzoRientrato))
                    {
                        var dataRientro = command.Richiesta.ListaEventi.OfType <PartenzaRientrata>().FirstOrDefault(p => p.CodicePartenza.Equals(partenza.Partenza.Codice)).Istante;
                        _setRientroMezzo.Set(new RientroGAC()
                        {
                            targa            = partenza.Partenza.Mezzo.Codice.Split('.')[1],
                            tipoMezzo        = partenza.Partenza.Mezzo.Codice.Split('.')[0],
                            idPartenza       = partenza.Partenza.Codice.ToString(),
                            numeroIntervento = command.Richiesta.CodRichiesta,
                            dataIntervento   = dataIntervento,
                            dataRientro      = dataRientro,
                            autista          = ""
                        });
                    }
                    else if (partenza.Partenza.Mezzo.Stato.Equals(Costanti.MezzoInViaggio))
                    {
                        var dataUscita = command.Richiesta.ListaEventi.OfType <ComposizionePartenze>().FirstOrDefault(p => p.Partenza.Codice.Equals(partenza.Partenza.Codice)).Istante;
                        _setUscitaMezzo.Set(new UscitaGAC()
                        {
                            targa            = partenza.Partenza.Mezzo.Codice.Split('.')[1],
                            tipoMezzo        = partenza.Partenza.Mezzo.Codice.Split('.')[0],
                            idPartenza       = partenza.Partenza.Codice.ToString(),
                            numeroIntervento = command.Richiesta.CodRichiesta,
                            dataIntervento   = dataIntervento,
                            dataUscita       = dataUscita,
                            autista          = "",
                            tipoUscita       = new TipoUscita()
                            {
                                codice      = "",
                                descrizione = "Servizio"
                            },
                            comune = new ComuneGAC()
                            {
                                codice      = "",
                                descrizione = command.Richiesta.Localita.Citta,
                            },
                            provincia = new Models.Classi.Gac.ProvinciaGAC()
                            {
                                codice      = "",
                                descrizione = command.Richiesta.Localita.Provincia
                            },
                            localita    = command.Richiesta.Localita.Citta,
                            latitudine  = command.Richiesta.Localita.Coordinate.Latitudine.ToString(),
                            longitudine = command.Richiesta.Localita.Coordinate.Longitudine.ToString()
                        });
                    }
                }
            }
        }
Example #22
0
        /// <summary>
        ///   Query che estrae i valori dei Box presenti in Home Page
        /// </summary>
        /// <param name="command">Filtri utilizzati per l'estrazione</param>
        /// <returns>Elenco dei mezzi disponibili</returns>
        public void Handle(ConfermaPartenzeCommand command)
        {
            /// preparazione del DTO
            var stato_mezzo = _getStatoMezzi.Get(new string[] { command.ConfermaPartenze.CodiceSede });

            foreach (var partenza in command.ConfermaPartenze.Partenze)
            {
                var listaMezzi = _getStatoMezzi.Get(new string[] { command.ConfermaPartenze.CodiceSede }, partenza.Mezzo.Codice);
                if (listaMezzi.Count > 0)
                {
                    if (listaMezzi[0].IdOpPrenotazione != null && !listaMezzi[0].IdOpPrenotazione.Equals(command.ConfermaPartenze.IdOperatore))
                    {
                        throw new Exception(Costanti.MezzoErroreGiaOccupato);
                    }
                }
            }

            var attivita = new AttivitaUtente();
            var idComposizioneDaSganciare = 0;
            var StatoInViaggio            = 0;
            var StatoSulPosto             = 0;

            bool PartenzaEsistente = false;

            foreach (var partenza in command.ConfermaPartenze.Partenze)
            {
                PartenzaEsistente = command.Richiesta.Partenze.Select(x => x.Partenza.Mezzo.Codice.Equals(partenza.Mezzo.Codice) && !x.Partenza.Terminata && !x.Partenza.PartenzaAnnullata && !x.Partenza.Sganciata).FirstOrDefault();

                if (PartenzaEsistente)
                {
                    throw new Exception(Costanti.PartenzaGiaPresente);
                }
            }

            #region SGANCIAMENTO

            if (command.ConfermaPartenze.IdRichiestaDaSganciare != null)
            {
                command.RichiestaDaSganciare = _getRichiestaById.GetByCodice(command.ConfermaPartenze.IdRichiestaDaSganciare);

                foreach (var composizione in command.RichiestaDaSganciare.Eventi.Where(x => x is ComposizionePartenze).ToList())
                {
                    var CompPartenza = ((ComposizionePartenze)composizione).Partenza;
                    if (!CompPartenza.PartenzaAnnullata && !CompPartenza.Terminata &&
                        !CompPartenza.Sganciata && !CompPartenza.Mezzo.Stato.Equals(Costanti.MezzoInRientro))
                    {
                        if (CompPartenza.Mezzo.Codice.Equals(command.ConfermaPartenze.IdMezzoDaSganciare))
                        {
                            CompPartenza.Sganciata = true;
                        }

                        if (CompPartenza.Mezzo.Stato == Costanti.MezzoInViaggio && !CompPartenza.Mezzo.Codice.Equals(command.ConfermaPartenze.IdMezzoDaSganciare))
                        {
                            StatoInViaggio++;
                        }

                        if (CompPartenza.Mezzo.Stato == Costanti.MezzoSulPosto && !CompPartenza.Mezzo.Codice.Equals(command.ConfermaPartenze.IdMezzoDaSganciare))
                        {
                            StatoSulPosto++;
                        }

                        idComposizioneDaSganciare++;
                    }
                }

                foreach (var composizione in command.RichiestaDaSganciare.Partenze)
                {
                    if (composizione.Partenza.Mezzo.Codice.Equals(command.ConfermaPartenze.IdMezzoDaSganciare))
                    {
                        composizione.Partenza.Sganciata = true;
                    }
                }

                if (idComposizioneDaSganciare == 1)
                {
                    command.RichiestaDaSganciare.SincronizzaStatoRichiesta(Costanti.RichiestaSospesa, command.RichiestaDaSganciare.StatoRichiesta, command.RichiestaDaSganciare.CodOperatore, "", DateTime.UtcNow);
                }
                else
                {
                    if (StatoSulPosto > 0)
                    {
                        command.RichiestaDaSganciare.SincronizzaStatoRichiesta(Costanti.RichiestaPresidiata, command.RichiestaDaSganciare.StatoRichiesta, command.RichiestaDaSganciare.CodOperatore, "", DateTime.UtcNow);
                    }
                    else if (StatoInViaggio > 0)
                    {
                        command.RichiestaDaSganciare.SincronizzaStatoRichiesta(Costanti.RichiestaAssegnata, command.RichiestaDaSganciare.StatoRichiesta, command.RichiestaDaSganciare.CodOperatore, "", DateTime.UtcNow);
                    }
                }

                //new RevocaPerRiassegnazione(richiesta, richiestaDaSganciare, command.ConfermaPartenze.IdMezzoDaSganciare, DateTime.UtcNow, richiesta.CodOperatore);
                _updateRichiestaAssistenza.UpDate(command.RichiestaDaSganciare);
            }

            #endregion SGANCIAMENTO

            if (command.Richiesta.Eventi.Where(x => x is InizioPresaInCarico).ToList().Count == 0)
            {
                new InizioPresaInCarico(command.Richiesta, DateTime.UtcNow, command.Utente.Id);
            }

            foreach (var partenza in command.ConfermaPartenze.Partenze)
            {
                partenza.Sganciata = false;
                new ComposizionePartenze(command.Richiesta, DateTime.UtcNow, command.Utente.Id, false)
                {
                    Partenza = partenza
                };
            }

            command.Richiesta.SincronizzaStatoRichiesta(Costanti.RichiestaAssegnata, command.Richiesta.StatoRichiesta, command.Utente.Id, "", DateTime.UtcNow);

            command.ConfermaPartenze.richiesta = command.Richiesta;

            var sedeRichiesta = command.Richiesta.CodSOCompetente;

            if (command.Richiesta.CodRichiesta == null)
            {
                command.Richiesta.CodRichiesta = _generaCodiceRichiesta.Genera(sedeRichiesta, DateTime.UtcNow.Year);
            }

            foreach (var partenza in command.ConfermaPartenze.Partenze)
            {
                partenza.Mezzo.IdRichiesta = command.Richiesta.Id;
            }
            var nominativo = command.Utente.Nome + "." + command.Utente.Cognome;

            if (command.Richiesta.UtPresaInCarico != null)
            {
                command.Richiesta.UtPresaInCarico.Add(nominativo);
            }
            else
            {
                command.Richiesta.UtPresaInCarico = new List <String>
                {
                    nominativo
                };
            }

            foreach (var partenza in command.ConfermaPartenze.Partenze)
            {
                foreach (var squadra in partenza.Squadre)
                {
                    squadra.Stato = MappaStatoSquadraDaStatoMezzo.MappaStato(partenza.Mezzo.Stato);
                }
            }

            int ContatorePartenze = 1;
            foreach (var partenza in command.Richiesta.Partenze)
            {
                if (partenza.Partenza.Codice == 0)
                {
                    partenza.Partenza.Codice = ContatorePartenze;
                }

                ContatorePartenze++;
            }

            command.ConfermaPartenze.IdRichiesta = command.Richiesta.Id;

            var confermaPartenze = _updateConfermaPartenze.Update(command);

            command.ConfermaPartenze.CodiceSede = confermaPartenze.CodiceSede;
        }