Beispiel #1
0
        public bool WriteTree()
        {
            string configFile = FilesAndFolders.GetConfigPath(createFolder: true);

            var sDict = ExplicitPaths.ToSortedDictionary();

            var config = new VaultEagleConfig();

            try
            {
                config = ReadConfig(VaultName, VaultURI);
            }
            catch (Exception) { }

            string vaultId = GetVaultId(VaultName, VaultURI);

            config.Vaults[vaultId] = sDict;

            var jsonSettings = new JsonSerializerSettings()
            {
                Converters = new[] { new StringEnumConverter() }
            };
            var json = JsonConvert.SerializeObject(config, Formatting.Indented, jsonSettings);

            try
            {
                using (var writer = new StreamWriter(System.IO.File.Open(configFile, FileMode.Create, FileAccess.Write)))
                    writer.WriteLine(json);
            }
            catch
            {
                return(false);
            }
            return(true);
        }
Beispiel #2
0
        public void WriteTree_Old()
        {
            string configFile = FilesAndFolders.GetConfigPath(createFolder: true);

            using (var writer = new StreamWriter(System.IO.File.Open(configFile, FileMode.Create, FileAccess.Write)))
                WriteTree_Old(writer);
        }
Beispiel #3
0
        public static VaultEagleConfig ReadConfig(string vaultName, string vaultURI, bool getEmptyIfFailed = false)
        {
            string treePath = FilesAndFolders.GetConfigPath();

            if (!File.Exists(treePath))
            {
                return(new VaultEagleConfig());
            }

            try
            {
                using (var stream = new FileStream(treePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                    using (var sr = new StreamReader(stream, Encoding.UTF8))
                        return(ParseForest(sr, vaultName, vaultURI) ?? new VaultEagleConfig());
            }
            catch (Exception ex)
            {
                if (getEmptyIfFailed)
                {
                    return(new VaultEagleConfig());
                }
#if DEBUG
                throw new Exception("Failed to read configuration file at: '" + treePath + "'. Error: " + ex.Message, ex);
#else
                throw new Exception("Failed to read configuration file at: '" + treePath + "'.", ex);
#endif
            }
        }
Beispiel #4
0
        public void StartSyncThread(bool showProgressWindow)
        {
            if (thread != null)
            {
                thread.Stop();
            }
            thread = new SynchronizationThread(application, invokeControl);
            var log = new ProgressWindow(this, FilesAndFolders.GetLogPath());

            log.Initialize();

            VaultEagleSynchronizer.LogVersion(log, System.Reflection.Assembly.GetExecutingAssembly());

            if (showProgressWindow)
            {
                log.Show();
            }
            thread.logWindow = log;
            thread.Start();
        }
Beispiel #5
0
 private void showLogButton_Click(object sender, EventArgs e)
 {
     System.Diagnostics.Process.Start(FilesAndFolders.GetLogPath());
 }