Exemplo n.º 1
0
        private void saveLogLevel()
        {
            try
            {
                Settings.Default.LogLevel = aboutControl1.LogLevel.ToString();
                Settings.Default.Save();

                Log4netConfigure.SetLevel(aboutControl1.LogLevel);
            }
            catch (Exception e)
            {
                log4net.LogManager.GetLogger(GetType()).Warn("Unable to set debug log level: " + aboutControl1.LogLevel.ToString(), e);
            }
        }
Exemplo n.º 2
0
        static void Main()
        {
            if (Environment.GetCommandLineArgs().Contains("--close-all-processes"))
            {
                forceCloseAllProcesses();
                return;
            }

            Boolean bCreatedNew;

            var cultureName = (string)Registry.GetValue(@"HKEY_CURRENT_USER\Software\BunnyHome", "Culture", "");

            if (!string.IsNullOrEmpty(cultureName))
            {
                var cultureInfo   = new CultureInfo(cultureName);
                var currentThread = Thread.CurrentThread;

                currentThread.CurrentCulture   = cultureInfo;
                currentThread.CurrentUICulture = cultureInfo;
            }

            m_InstanceMutex = new System.Threading.Mutex(false, Application.ProductName + Environment.UserName, out bCreatedNew);

            if (!bCreatedNew)
            {
                invokeAnotherRunningProcess();
                return;
            }

            Application.EnableVisualStyles();
            Application.ApplicationExit += new EventHandler(Application_ApplicationExit);

            AppDomain.CurrentDomain.UnhandledException += NBug.Handler.UnhandledException;
            Application.ThreadException += NBug.Handler.ThreadException;

            Log4netConfigure.InitLog4net();

            log4net.LogManager.GetLogger("main").Warn("==== program started ====");

            if (!Settings.Default.IsUpgraded)
            {
                Settings.Default.Upgrade();
                Settings.Default.IsUpgraded = true;
                Settings.Default.Save();
            }

            if (string.IsNullOrEmpty(Settings.Default.ServerId))
            {
                Settings.Default.ServerId             = generateSameServerIdForSameUserOnSamePC();
                Settings.Default.SingleFolderLocation = (string)Registry.GetValue(@"HKEY_CURRENT_USER\Software\BunnyHome", "ResourceFolder", "");
                Settings.Default.OrganizeMethod       = (int)OrganizeMethod.YearMonth;
                Settings.Default.LocationType         = (int)LocationType.SingleFolder;
                Settings.Default.Save();

                if (!Directory.Exists(Settings.Default.SingleFolderLocation))
                {
                    Directory.CreateDirectory(Settings.Default.SingleFolderLocation);
                }
            }
            try
            {
                NginxUtility.Instance.PrepareNginxConfig(12888, Settings.Default.SingleFolderLocation);
            }
            catch (Exception err)
            {
                log4net.LogManager.GetLogger("main").Warn("Unable to write nginx config", err);
            }

            if (string.IsNullOrEmpty(Settings.Default.LibraryName))
            {
                Settings.Default.LibraryName = string.Format(Resources.DefLibraryName, Environment.UserName);
                Settings.Default.Save();
            }

            SynchronizationContextHelper.SetMainSyncContext();
            DBInitializer.InitialzeDatabaseSchema();
            SeqNum.InitFromDB();

            if (HomeSharing.Enabled)
            {
                NginxUtility.Instance.Start();
            }

            server = new StationServer();
            server.Start();

            BonjourServiceRegistrator.Instance.Register(false);

            if (!Environment.GetCommandLineArgs().Contains("--minimized"))
            {
                ImportUIPresenter.Instance.StartViewer();
            }

            Application.Run();
        }