Exemplo n.º 1
0
        /// <summary>
        /// Inizializza il nuovo Core.DataBase collegato al dbName che rappresenta l'ambiente Prod|Test|Dev.
        /// </summary>
        /// <param name="dbName">Nome (corrisponde all'ambiente) del Database.</param>
        public static void CreateNew(string ambiente, bool checkDB = true)
        {
            if (_db == null || _db.Ambiente != ambiente)
            {
                _db = new Core.DataBase(ambiente, checkDB);
            }

            IsInitialized = true;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Cambio ambiente tra Prod|Test|Prod.
        /// </summary>
        /// <param name="ambiente">Nuovo ambiente.</param>
        public static bool SwitchEnvironment(string ambiente)
        {
            if (_db.Ambiente != ambiente)
            {
                Workbook.Ambiente = ambiente;

                Delegate[] list = _db.GetPropertyChangedInvocationList();

                _db = new Core.DataBase(ambiente);
                _db.SetParameters(Workbook.DataAttiva, Workbook.IdUtente, Workbook.IdApplicazione);
                foreach (Delegate d in list)
                {
                    EventInfo ei = _db.GetType().GetEvent("PropertyChanged");
                    ei.AddEventHandler(_db, d);
                }
                return(true);
            }
            return(false);
        }