private bool controllaFaseDelGiorno()
        {
            if (faseDelGiorno != null)
            {
                return(true);
            }

            FaseDelGiorno faseDelGiornoCorrente = FaseDelGiornoUtil.getFaseDelGiorno(DateTime.Now);

            StringBuilder msg = new StringBuilder("Attenzione : non hai assegnato nessuna fase del giorno");

            msg.AppendFormat(".\nVuoi assegnare automaticamente la fase {0} a tutte le foto che si stanno per scaricare?", faseDelGiornoCorrente.ToString().ToUpper());

            MessageBoxResult procediPure = MessageBoxResult.Cancel;

            dialogProvider.ShowConfirmationAnnulla(msg.ToString(), "Richiesta conferma",
                                                   (confermato) => {
                procediPure = confermato;
            });

            if (procediPure == MessageBoxResult.Yes)
            {
                faseDelGiorno = faseDelGiornoCorrente;
            }

            return((procediPure == MessageBoxResult.Yes) ||
                   (procediPure == MessageBoxResult.No));
        }
Пример #2
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value != null)
            {
                return(FaseDelGiornoUtil.getFaseDelGiorno((short)value));
            }

            return(null);
        }
Пример #3
0
        public bool  modificaMetadatiFotografie(IEnumerable <Fotografia> fotografie, MetadatiFoto metadati)
        {
            bool esito = false;

            try
            {
                // riattacco l'entità che non si sa mai
                if (metadati.evento != null)
                {
                    try {
                        Evento e = metadati.evento;
                        OrmUtil.forseAttacca <Evento>(ref e);
                    } catch (Exception ee) {
                        _giornale.Debug("Potenziale errore", ee);
                    }
                }

                foreach (Fotografia f in fotografie)
                {
                    Fotografia fotografia = f;
                    try {
                        OrmUtil.forseAttacca(ref fotografia);
                    } catch (Exception ee) {
                        _giornale.Debug("Potenziale errore", ee);
                        fotografia = UnitOfWorkScope.currentDbContext.Fotografie.Single(f2 => f2.id == f.id);
                    }

#if DEBUG
                    String didascaliaNew = null;
                    if (metadati.usoDidascalia)
                    {
                        if (!String.IsNullOrWhiteSpace(metadati.didascalia))
                        {
                            didascaliaNew = metadati.didascalia.TrimEnd().ToUpper();
                        }
                    }

                    string strDidascaliaOld    = fotografia.didascalia;
                    string strFaseDelGiornoOld = fotografia.faseDelGiorno == null ? "empty" : FaseDelGiornoUtil.valoreToString(fotografia.faseDelGiorno);
                    string strEventoOld        = fotografia.evento == null ? "empty" : fotografia.evento.descrizione;

                    string strFaseDelGiornoNew = metadati.faseDelGiorno == null ? "empty" : metadati.faseDelGiorno.ToString();
                    string strEventoNew        = metadati.evento == null ? "empty" : metadati.evento.descrizione;

                    String msg = String.Format("Modificati metadati: {0} da: dida:{1} faseGG:{2} evento:{3} in dida:{4} faseGG:{5} evento:{6}",
                                               fotografia.ToString(),
                                               strDidascaliaOld,
                                               strFaseDelGiornoOld,
                                               strEventoOld,
                                               didascaliaNew,
                                               strFaseDelGiornoNew,
                                               strEventoNew
                                               );
#endif

                    modificaMetadatiFotografie(fotografia, metadati);

#if DEBUG
                    _giornale.Debug(msg);
#endif
                }

                UnitOfWorkScope.currentDbContext.SaveChanges();
                _giornale.Debug("Modifica metadati salvataggio eseguito. Ora committo la transazione");

                _giornale.Info("Commit metadati andato a buon fine");

                esito = true;
            } catch (Exception eee) {
                _giornale.Error("Modifica metadati", eee);
                esito = false;
                _giornale.Error("Impossibile modificare metadati", eee);
            }

            return(esito);
        }
Пример #4
0
        /// <summary>
        /// Carico lo stato dei metadati prendendolo dalle foto selezionate
        /// </summary>
        protected void caricareStatoMetadati()
        {
            bool   didascalieDiscordanti = false;
            string didascaliaNew         = null;

            bool   eventiDiscordanti = false;
            Guid?  eventoIdNew       = null;       // Non posso usare l'oggetto "Evento" perché entity framework sulle entità non idratate mi torna null anche se non è vero :-(
            Evento eventoNew         = null;

            bool  fasiDelGiornoDiscordanti = false;
            short?faseDelGiornoNew         = null;

            IEnumerator <Fotografia> itera = getEnumeratorElementiSelezionati();
            int conta = 0;

            while (itera.MoveNext())
            {
                Fotografia f = itera.Current;
                ++conta;

                // -- didascalia

                if (String.IsNullOrWhiteSpace(f.didascalia))
                {
                    if (didascaliaNew != null)
                    {
                        didascalieDiscordanti = true;
                    }
                }
                else
                {
                    if (f.didascalia != didascaliaNew && conta > 1)
                    {
                        didascalieDiscordanti = true;
                    }
                }
                didascaliaNew = String.IsNullOrWhiteSpace(f.didascalia) ? null : f.didascalia;

                // -- evento

                if (f.evento_id == null)
                {
                    if (eventoIdNew != null)
                    {
                        eventiDiscordanti = true;
                    }
                }
                else
                {
                    if (f.evento_id != eventoIdNew && conta > 1)
                    {
                        eventiDiscordanti = true;
                    }
                }
                eventoIdNew = f.evento_id;
                if (f.evento != null)
                {
                    eventoNew = f.evento;                      // Se la foto è staccata, questo è null (mentre il suo ID è valorizzato)
                }
                // -- fase del giorno

                if (f.faseDelGiorno == null)
                {
                    if (faseDelGiornoNew != null)
                    {
                        fasiDelGiornoDiscordanti = true;
                    }
                }
                else
                {
                    if (f.faseDelGiorno != faseDelGiornoNew && conta > 1)
                    {
                        fasiDelGiornoDiscordanti = true;
                    }
                }
                faseDelGiornoNew = f.faseDelGiorno;
            }


            // -- ora travaso i dati che sono concordanti
            MetadatiFoto metadatiNew = new MetadatiFoto();


            if (didascalieDiscordanti)
            {
                metadatiNew.didascalia    = null;
                metadatiNew.usoDidascalia = false;
            }
            else
            {
                metadatiNew.didascalia    = String.IsNullOrWhiteSpace(didascaliaNew) ? null : didascaliaNew;
                metadatiNew.usoDidascalia = (metadatiNew.didascalia != null);
            }

            if (eventiDiscordanti)
            {
                metadatiNew.evento    = null;
                metadatiNew.usoEvento = false;
            }
            else
            {
                if (eventoIdNew != null)
                {
                    if (eventoNew == null)
                    {
                        // L'oggetto era staccato. Lo rileggo
                        // Devo ricaricare l'oggetto evento dall'ID
                        IEntityRepositorySrv <Evento> repo = LumenApplication.Instance.getServizioAvviato <IEntityRepositorySrv <Evento> >();
                        metadatiNew.evento = repo.getById(eventoIdNew);
                    }
                    else
                    {
                        metadatiNew.evento = eventoNew;
                    }
                }
                metadatiNew.usoEvento = (metadatiNew.evento != null);
            }
            selettoreEventoViewModel.eventoSelezionato = metadatiNew.evento;              // ribalto questo valore nel vm del componente perché è li che sta il valore buono

            if (fasiDelGiornoDiscordanti)
            {
                metadatiNew.faseDelGiorno    = null;
                metadatiNew.usoFaseDelGiorno = false;
            }
            else
            {
                if (faseDelGiornoNew != null)
                {
                    metadatiNew.faseDelGiorno = FaseDelGiornoUtil.getFaseDelGiorno((short)faseDelGiornoNew);
                }
                metadatiNew.usoFaseDelGiorno = (metadatiNew.faseDelGiorno != null);
            }

            this.metadati = metadatiNew;
        }