Ejemplo n.º 1
0
        private void Init()
        {
            if (_settings != null)
            {
                return;
            }

            try
            {
                var configFile = IOHelper.MapPath(
                    Path.Combine(SystemDirectories.Config, "uSyncBackOffice.Config"));

                if (System.IO.File.Exists(configFile))
                {
                    XmlSerializer serializer = new XmlSerializer(typeof(uSyncBackOfficeSettings));
                    using (FileStream fs = new FileStream(configFile, FileMode.Open))
                    {
                        _settings = (uSyncBackOfficeSettings)serializer.Deserialize(fs);
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Warn <uSyncBackOfficeConfig>("Unable to load the settings: {0}", () => ex);
            }

            if (_settings == null)
            {
                // default settings...
                _settings = new uSyncBackOfficeSettings
                {
                    Import              = true,
                    ExportAtStartup     = false,
                    ExportOnSave        = true,
                    WatchForFileChanges = false,
                    ArchiveVersions     = false,

                    Folder        = "~/uSync/data/",
                    ArchiveFolder = "~/uSync/Archive/",
                    BackupFolder  = "~/uSync/Backup/",

                    Handlers = new List <HandlerConfig>()
                };

                foreach (var handler in uSyncBackOfficeContext.Instance.Handlers)
                {
                    _settings.Handlers.Add(new HandlerConfig
                    {
                        Name    = handler.Name,
                        Enabled = true
                    });
                }

                // save the defaults to disk...
                SaveSettings(_settings);
            }
        }
Ejemplo n.º 2
0
        private void Init()
        {
            if (_settings != null) return;

            try
            {
                var configFile = IOHelper.MapPath(
                    Path.Combine(SystemDirectories.Config, "uSyncBackOffice.Config"));

                if (System.IO.File.Exists(configFile))
                {
                    XmlSerializer serializer = new XmlSerializer(typeof(uSyncBackOfficeSettings));
                    using (FileStream fs = new FileStream(configFile, FileMode.Open))
                    {
                        _settings = (uSyncBackOfficeSettings)serializer.Deserialize(fs);
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Warn<uSyncBackOfficeConfig>("Unable to load the settings: {0}", () => ex);
            }

            if (_settings == null)
            {
                // default settings...
                _settings = new uSyncBackOfficeSettings
                {
                    Import = true,
                    ExportAtStartup = false,
                    ExportOnSave = true,
                    WatchForFileChanges = false,
                    ArchiveVersions = false,

                    Folder = "~/uSync/data/",
                    ArchiveFolder = "~/uSync/Archive/",
                    BackupFolder = "~/uSync/Backup/",

                    Handlers = new List<HandlerConfig>()
                };

                foreach(var handler in uSyncBackOfficeContext.Instance.Handlers)
                {
                    _settings.Handlers.Add(new HandlerConfig
                    {
                        Name = handler.Name,
                        Enabled = true
                    });
                }

                // save the defaults to disk...
                SaveSettings(_settings);
            }
        }
Ejemplo n.º 3
0
        public void SaveSettings(uSyncBackOfficeSettings settings)
        {
            var configFile = IOHelper.MapPath(
                Path.Combine(SystemDirectories.Config, "uSyncBackOffice.Config"));

            if (File.Exists(configFile))
                File.Delete(configFile);

            XmlSerializer serializer = new XmlSerializer(typeof(uSyncBackOfficeSettings));

            using (StreamWriter w = new StreamWriter(configFile))
            {
                serializer.Serialize(w, settings);
            }
        }
Ejemplo n.º 4
0
        public void SaveSettings(uSyncBackOfficeSettings settings)
        {
            var configFile = IOHelper.MapPath(
                Path.Combine(SystemDirectories.Config, "uSyncBackOffice.Config"));

            if (File.Exists(configFile))
            {
                File.Delete(configFile);
            }

            XmlSerializer serializer = new XmlSerializer(typeof(uSyncBackOfficeSettings));

            using (StreamWriter w = new StreamWriter(configFile))
            {
                serializer.Serialize(w, settings);
            }
        }