Inheritance: IDisposable
示例#1
0
        public static void Main(string[] args)
        {
#if __MonoCS__
            Environment.SetEnvironmentVariable("MONO_XMLSERIALIZER_THS", "no");
#endif

            bool firstRun = !File.Exists(ConfigManager.CurrentConfigFile);

            // Disable SSLv3 to avoid POODLE Attack
            ServicePointManager.SecurityProtocol = ServicePointManager.SecurityProtocol & ~SecurityProtocolType.Ssl3;

            ServicePointManager.CertificatePolicy = new CertPolicyHandler();

            // Migrate config.xml from past versions, if necessary.
            if (!firstRun)
            {
                ConfigMigration.Migrate();
            }

            FileInfo alternativeLog4NetConfigFile = new FileInfo(Path.Combine(Directory.GetParent(ConfigManager.CurrentConfigFile).FullName, "log4net.config"));
            if (alternativeLog4NetConfigFile.Exists)
            {
                log4net.Config.XmlConfigurator.ConfigureAndWatch(alternativeLog4NetConfigFile);
            }
            else
            {
                log4net.Config.XmlConfigurator.Configure(ConfigManager.CurrentConfig.GetLog4NetConfig());
            }

            Logger.Info("Starting. Version: " + CmisSync.Lib.Backend.Version);
            using (var listener = new CmisSync.Lib.Cmis.DotCMISLogListener()) {
                Trace.Listeners.Add(listener);
                if (args.Length != 0 && !args[0].Equals("start") &&
                    Backend.Platform != PlatformID.MacOSX &&
                    Backend.Platform != PlatformID.Win32NT)
                {
                    string n = Environment.NewLine;

                    Console.WriteLine(n + Properties_Resources.ApplicationName +
                                      " is a collaboration and sharing tool that is" + n +
                                      "designed to keep things simple and to stay out of your way." + n +
                                      n +
                                      "Version: " + CmisSync.Lib.Backend.Version + n +
                                      "Copyright (C) 2014 GRAU DATA AG" + n +
                                      "Copyright (C) 2010 Hylke Bons" + n +
                                      "This program comes with ABSOLUTELY NO WARRANTY." + n +
                                      n +
                                      "This is free software, and you are welcome to redistribute it" + n +
                                      "under certain conditions. Please read the GNU GPLv3 for details." + n +
                                      n +
                                      "Usage: dataspacesync [start|stop|restart]");
                    Environment.Exit(-1);
                }

                // Only allow one instance of CmisSync (on Windows)
                if (!programMutex.WaitOne(0, false))
                {
                    Logger.Error(Properties_Resources.ApplicationName + " is already running.");
                    Environment.Exit(-1);
                }

                try {
                    CmisSync.Lib.Utils.EnsureNeededDependenciesAreAvailable();
                } catch (Exception e) {
                    string message = string.Format("Missing Dependency: {0}{1}{2}", e.Message, Environment.NewLine, e.StackTrace);
                    Logger.Error(message);
                    Console.Error.WriteLine(message);
                    Environment.Exit(-1);
                }

                // Increase the number of concurrent requests to each server,
                // as an unsatisfying workaround until this DotCMIS bug 632 is solved.
                // See https://github.com/nicolas-raoul/CmisSync/issues/140
                ServicePointManager.DefaultConnectionLimit = 1000;

                try {
                    Controller = new Controller();
                    Controller.Initialize(firstRun);

                    UI = new UI();
                    UI.Run();
                } catch (Exception e) {
                    Logger.Fatal("Exception in Program.Main", e);
                    Environment.Exit(-1);
                } finally {
                    if (Controller != null)
                    {
                        Controller.Dispose();
                    }
                }
            }
        }
示例#2
0
        public static void Main(string[] args)
        {
#if __MonoCS__
            Environment.SetEnvironmentVariable("MONO_MANAGED_WATCHER", "enabled");
            Environment.SetEnvironmentVariable("MONO_XMLSERIALIZER_THS", "no");
#endif

            bool firstRun = ! File.Exists(ConfigManager.CurrentConfigFile);

            ServicePointManager.CertificatePolicy = new CertPolicyHandler();

            // Migrate config.xml from past versions, if necessary.
            if ( ! firstRun )
                ConfigMigration.Migrate();

            FileInfo alternativeLog4NetConfigFile = new FileInfo(Path.Combine(Directory.GetParent(ConfigManager.CurrentConfigFile).FullName, "log4net.config"));
            if(alternativeLog4NetConfigFile.Exists)
            {
                log4net.Config.XmlConfigurator.ConfigureAndWatch(alternativeLog4NetConfigFile);
            }
            else
            {
                log4net.Config.XmlConfigurator.Configure(ConfigManager.CurrentConfig.GetLog4NetConfig());
            }

            Logger.Info("Starting. Version: " + CmisSync.Lib.Backend.Version);

            if (args.Length != 0 && !args[0].Equals("start") &&
                Backend.Platform != PlatformID.MacOSX &&
                Backend.Platform != PlatformID.Win32NT)
            {

                string n = Environment.NewLine;

                Console.WriteLine(n +
                    "CmisSync is a collaboration and sharing tool that is" + n +
                    "designed to keep things simple and to stay out of your way." + n +
                    n +
                    "Version: " + CmisSync.Lib.Backend.Version + n +
                    "Copyright (C) 2014 Aegif" + n +
                    "This program comes with ABSOLUTELY NO WARRANTY." + n +
                    n +
                    "This is free software, and you are welcome to redistribute it" + n +
                    "under certain conditions. Please read the GNU GPLv3 for details." + n +
                    n +
                    "Usage: CmisSync [start|stop|restart]");
                Environment.Exit(-1);
            }

            // Only allow one instance of CmisSync (on Windows)
            if (!program_mutex.WaitOne(0, false))
            {
                Logger.Error("CmisSync is already running.");
                Environment.Exit(-1);
            }

            // Increase the number of concurrent requests to each server,
            // as an unsatisfying workaround until this DotCMIS bug 632 is solved.
            // See https://github.com/nicolas-raoul/CmisSync/issues/140
            ServicePointManager.DefaultConnectionLimit = 1000;

            try
            {
                Controller = new Controller();
                Controller.Initialize(firstRun);

                UI = new UI();
                UI.Run();
            }
            catch (Exception e)
            {
                Logger.Fatal("Exception in Program.Main", e);
                Environment.Exit(-1);
            }

#if !__MonoCS__
            //// Suppress assertion messages in debug mode
            //GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
            //GC.WaitForPendingFinalizers();
#endif
        }
示例#3
0
        public static void Main(string[] args) {
#if __MonoCS__
            Environment.SetEnvironmentVariable("MONO_XMLSERIALIZER_THS", "no");
#endif

            bool firstRun = !File.Exists(ConfigManager.CurrentConfigFile);

            // Disable SSLv3 to avoid POODLE Attack
            ServicePointManager.SecurityProtocol = ServicePointManager.SecurityProtocol & ~SecurityProtocolType.Ssl3;

            ServicePointManager.CertificatePolicy = new CertPolicyHandler();

            // Migrate config.xml from past versions, if necessary.
            if (!firstRun) {
                ConfigMigration.Migrate();
            }

            FileInfo alternativeLog4NetConfigFile = new FileInfo(Path.Combine(Directory.GetParent(ConfigManager.CurrentConfigFile).FullName, "log4net.config"));
            if (alternativeLog4NetConfigFile.Exists) {
                log4net.Config.XmlConfigurator.ConfigureAndWatch(alternativeLog4NetConfigFile);
            } else {
                log4net.Config.XmlConfigurator.Configure(ConfigManager.CurrentConfig.GetLog4NetConfig());
            }

            Logger.Info("Starting. Version: " + CmisSync.Lib.Backend.Version);
            using (var listener = new CmisSync.Lib.Cmis.DotCMISLogListener()) {
                Trace.Listeners.Add(listener);
                if (args.Length != 0 && !args[0].Equals("start") &&
                Backend.Platform != PlatformID.MacOSX &&
                Backend.Platform != PlatformID.Win32NT) {
                    string n = Environment.NewLine;

                    Console.WriteLine(n + Properties_Resources.ApplicationName +
                    " is a collaboration and sharing tool that is" + n +
                    "designed to keep things simple and to stay out of your way." + n +
                    n +
                    "Version: " + CmisSync.Lib.Backend.Version + n +
                    "Copyright (C) 2014 GRAU DATA AG" + n +
                    "Copyright (C) 2010 Hylke Bons" + n +
                    "This program comes with ABSOLUTELY NO WARRANTY." + n +
                    n +
                    "This is free software, and you are welcome to redistribute it" + n +
                    "under certain conditions. Please read the GNU GPLv3 for details." + n +
                    n +
                    "Usage: dataspacesync [start|stop|restart]");
                    Environment.Exit(-1);
                }

                // Only allow one instance of CmisSync (on Windows)
                if (!programMutex.WaitOne(0, false)) {
                    Logger.Error(Properties_Resources.ApplicationName + " is already running.");
                    Environment.Exit(-1);
                }

                try {
                    CmisSync.Lib.Utils.EnsureNeededDependenciesAreAvailable();
                } catch (Exception e) {
                    string message = string.Format("Missing Dependency: {0}{1}{2}", e.Message, Environment.NewLine, e.StackTrace);
                    Logger.Error(message);
                    Console.Error.WriteLine(message);
                    Environment.Exit(-1);
                }

                // Increase the number of concurrent requests to each server,
                // as an unsatisfying workaround until this DotCMIS bug 632 is solved.
                // See https://github.com/nicolas-raoul/CmisSync/issues/140
                ServicePointManager.DefaultConnectionLimit = 1000;

                try {
                    Controller = new Controller();
                    Controller.Initialize(firstRun);

                    UI = new UI();
                    UI.Run();
                } catch (Exception e) {
                    Logger.Fatal("Exception in Program.Main", e);
                    Environment.Exit(-1);
                } finally {
                    if (Controller != null) {
                        Controller.Dispose();
                    }
                }
            }
        }