Пример #1
0
        public void Dispose()
        {
            importRepo.Dispose();
            ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings["PrismDatabase"];

            HibernateUtil.Initialize(settings.ConnectionString, false);
        }
Пример #2
0
        public DataImporter(IImportRepository importRepo, IHasher hasher, IEncryptor encryptor)
            : base(hasher, encryptor)
        {
            ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings["PrismDatabase"];

            HibernateUtil.Initialize(settings.ConnectionString, true);
            this.importRepo = Program.Kernel.Get <IImportRepository>();
        }
Пример #3
0
        public DataImporter(IImportRepository importRepo, IHasher hasher, IEncryptor encryptor)
            : base(hasher, encryptor)
        {
            this.IsDisposed = false;
            ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings["PrismDatabase"];

            HibernateUtil.Initialize(settings.ConnectionString, true);
            this.importRepo = Program.Kernel.Get <IImportRepository>();

            progressMessage = Program.LanguageManager.GetString(StringResources.Import_Progress_Message_Counter) + " {0} / {1} " + ". " +
                              Program.LanguageManager.GetString(StringResources.Import_Progress_Message_Type) + " {2}";

            currentStation = (importRepo.ProjectRepo.GetSingle()).WorkstationType;
        }
Пример #4
0
        private static void Main(string[] args)
        {
            #region SingleInstance
            if (!SingleInstance.Start())
            {
                SingleInstance.ShowFirstInstance();
                return;
            }
            #endregion

            foreach (var arg in args)
            {
                if (arg.Equals("seed"))
                {
                    isSeed = true;
                }
                if (arg.Equals("template"))
                {
                    using (StreamWriter file = new StreamWriter(
                               Path.Combine(Directories.LanguagesFolderName, "Strings.template.txt"), append: false, encoding: Encoding.UTF8))
                    {
                        foreach (var item in LanguageManager.EnumerateStringResources(typeof(StringResources)))
                        {
                            file.WriteLine(Environment.NewLine + ";" + item.Description + Environment.NewLine + item.Id + "=");
                        }
                    }
                    return;
                }
            }

            bool cmdLineMode = false;
            LanguageManager.LoadTranslation(new CultureInfo(Settings.Default.UsersLanguage));

            Thread.CurrentThread.CurrentCulture   = LanguageManager.CurrentCulture;
            Thread.CurrentThread.CurrentUICulture = LanguageManager.CurrentCulture;

            try
            {
                // Splash screen
                SplashScreenManager.ShowForm(typeof(AppSplashScreen), true, false);

                // Database
                ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings["PrismDatabase"];

                HibernateUtil.Initialize(settings.ConnectionString, false);

                // Ninject
                Kernel = new StandardKernel(new PrizmModule());

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                // Hide splash screen
                SplashScreenManager.CloseForm(false);

                //Event before closing program
                AppDomain.CurrentDomain.ProcessExit += new EventHandler(OnProcessExit);

                //Permissions setup
                CreatePermissions();

                while (!CreateProject())
                {
                }

                //Login
                string      failMessage = String.Empty;
                LoginResult loginResult = LoginResult.None;
                while (loginResult != LoginResult.LoggedIn)
                {
                    loginResult = Login(ref failMessage);
                    switch (loginResult)
                    {
                    case LoginResult.Failed:
                    case LoginResult.FailedUserInactive:
                        log.Warn(string.Format("Failed to login for the reason: {0}", failMessage));
                        MessageBox.Show(failMessage,
                                        Program.LanguageManager.GetString(StringResources.MainWindowHeader_Title),
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                        break;
                    }
                }

                mainForm = new PrizmApplicationXtraForm();
                Application.Run(mainForm);
            }
            catch (Exception ex)
            {
                String error = ex.ToString();
                if (cmdLineMode)
                {
                    Console.Error.WriteLine(error);
                }
                else
                {
                    MessageBox.Show(error);
                }
                log.Fatal(error);
            }
            finally
            {
                // Hide splash screen
                SplashScreenManager.CloseForm(false);
            }
        }