示例#1
0
文件: Program.cs 项目: to2y/CmisSync
        static void Main(string[] args)
        {
            ServicePointManager.CertificatePolicy = new TrustAlways();
            bool firstRun = !File.Exists(ConfigManager.CurrentConfigFile);

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

            string path = null;

            foreach (string arg in args)
            {
                if (File.Exists(arg))
                {
                    path = arg;
                    break;
                }
            }

            File.Delete(ConfigManager.CurrentConfig.GetLogFilePath());
            log4net.Config.XmlConfigurator.Configure(ConfigManager.CurrentConfig.GetLog4NetConfig());

            //new CmisSyncTests().TestCrypto();
            test(path == null ? "../../../TestLibrary/test-servers.json" : path);
            //testFuzzy();
        }
示例#2
0
        /// <summary>
        /// The entry point of the program, where the program control starts and ends.
        /// </summary>
        /// <param name="args">The command-line arguments.</param>
        static void Main(string[] args)
        {
            // Only allow one instance of DataSpace Sync (on Windows)
            if (!programMutex.WaitOne(0, false))
            {
                System.Console.WriteLine("DataSpaceSync is already running.");
                Environment.Exit(-1);
            }

            if (File.Exists(ConfigManager.CurrentConfigFile))
            {
                ConfigMigration.Migrate();
            }

            log4net.Config.XmlConfigurator.Configure(ConfigManager.CurrentConfig.GetLog4NetConfig());
            CmisSync.Lib.Utils.EnsureNeededDependenciesAreAvailable();
            if (args.Length != 0)
            {
                foreach (string arg in args)
                {
                    // Check, if the user would like to read console logs
                    if (arg.Equals("-v") || arg.Equals("--verbose"))
                    {
                        verbose = true;
                    }
                }
            }

            // Add Console Logging if user wants to
            if (verbose)
            {
                BasicConfigurator.Configure();
            }

            Logger.Info("Starting.");

            List <Repository> repositories = new List <Repository>();
            var transmissionManager        = new ActiveActivitiesManager();

            foreach (RepoInfo repoInfo in ConfigManager.CurrentConfig.Folders)
            {
                string path = repoInfo.LocalPath;
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }

                Repository repo = new Repository(repoInfo, new ActivityListenerAggregator(new ActivityListener(), transmissionManager));
                repositories.Add(repo);
                repo.Initialize();
            }

            while (true)
            {
                System.Threading.Thread.Sleep(100);
            }
        }
示例#3
0
        static void Main(string[] args)
        {
            ServicePointManager.CertificatePolicy = new TrustAlways();
            bool firstRun = !File.Exists(ConfigManager.CurrentConfigFile);

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

            string path = null;

            foreach (string arg in args)
            {
                if (File.Exists(arg))
                {
                    path = arg;
                    break;
                }
            }

            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());
            }

            IEnumerable <object[]> servers = JsonConvert.DeserializeObject <List <object[]> >(
                File.ReadAllText("../../../TestLibrary/test-servers.json"));

            object[] server = servers.ElementAt(serverId);
            Dictionary <string, string> prop = new Dictionary <string, string>();

            prop["name"]         = (string)server[0];
            prop["localFolder"]  = (string)server[1];
            prop["remoteFolder"] = (string)server[2];
            prop["url"]          = (string)server[3];
            prop["user"]         = (string)server[4];
            prop["password"]     = (string)server[5];
            prop["repoId"]       = (string)server[6];

            //new CmisSyncTests().TestCrypto();
            //test(path == null ? "../../../TestLibrary/test-servers.json" : path);
            //testFuzzy();
        }
示例#4
0
        static void Main(string[] args)
        {
            //testExternal();
            //return;

            ServicePointManager.CertificatePolicy = new TrustAlways();
            bool firstRun = !File.Exists(ConfigManager.CurrentConfigFile);

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

            string path = null;

            foreach (string arg in args)
            {
                if (File.Exists(arg))
                {
                    path = arg;
                    break;
                }
            }

            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());
            }

            test(path == null ? "../../../TestLibrary/test-servers.json" : path);
            //testFuzzy();
            //new CmisSyncTests().TestCrypto();

            Console.WriteLine("Press enter to close...");
            Console.ReadLine();
        }
示例#5
0
文件: Program.cs 项目: to2y/CmisSync
        public static void Main(string[] args)
        {
            bool firstRun = !File.Exists(ConfigManager.CurrentConfigFile);

            ServicePointManager.CertificatePolicy = new CertPolicyHandler();

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

            // Clear log file.
            File.Delete(ConfigManager.CurrentConfig.GetLogFilePath());

            log4net.Config.XmlConfigurator.Configure(ConfigManager.CurrentConfig.GetLog4NetConfig());
            Logger.Info("Starting.");

            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) 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: 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
        }
示例#6
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();
                    }
                }
            }
        }
示例#7
0
        public static void Main(string[] args)
        {
            bool firstRun = !File.Exists(ConfigManager.CurrentConfigFile);

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

            log4net.Config.XmlConfigurator.Configure(ConfigManager.CurrentConfig.GetLog4NetConfig());
            Logger.Info("Starting.");

            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) 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: 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);
            }

            //#if !DEBUG
            try
            {
                //#endif
                Controller = new Controller();
                Controller.Initialize(firstRun);

                UI = new UI();
                UI.Run();

                //#if !DEBUG
            }
            catch (Exception e)
            {
                Logger.Fatal("Exception in Program.Main", e);
                Environment.Exit(-1);
            }
            //#endif

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

            Controller = new Controller();

            // Custom configuration file specified from command line.
            if (args.Length > 0)
            {
                ConfigManager.CurrentConfigFile = args[0];
            }

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

            ServicePointManager.CertificatePolicy = new CertPolicyHandler();

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

            CmisSync.Lib.Utils.ConfigureLogging();

            Logger.Info("Starting CmisSync 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 (args.Length == 0 &&     // Allow more than one instance if using a custom config file.
                !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 DotCMIS bug 632 is solved.
            // See https://github.com/aegif/CmisSync/issues/140
            ServicePointManager.DefaultConnectionLimit = 1000;

            try
            {
                Controller.Initialize(firstRun);

                gui = new GUI();
                gui.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
        }