Ejemplo n.º 1
0
        public string GetJson(string sectionName)
        {
            string result = null;

            Failover
            .Execute(() =>
            {
                XmlNode config;

                lock (_syncRoot)
                {
                    config = GetXmlNode(sectionName);
                }

                if (config != null)
                {
                    result = JsonConvert.SerializeXmlNode(config, Formatting.None, true);
                }
            });
            return(result);
        }
Ejemplo n.º 2
0
        public string GetXml(string sectionName)
        {
            string result = null;

            Failover
            .Execute(() =>
            {
                XmlNode config;

                lock (_syncRoot)
                {
                    config = GetXmlNode(sectionName);
                }

                if (config != null)
                {
                    result = config.OuterXml;
                }
            });
            return(result);
        }
Ejemplo n.º 3
0
        public T Get <T>()
        {
            var result = default(T);

            Failover
            .Execute(() =>
            {
                var sectionName = typeof(T).Name;

                object config;

                lock (_syncRoot)
                {
                    if (!_parsedConfigurationsCache.TryGetValue(sectionName, out config))
                    {
                        config = ParseConfigData <T>(sectionName);
                    }
                }

                result = (T)config;
            });

            return(result);
        }
Ejemplo n.º 4
0
        public static int Run(string[] args)
        {
            var exitCode = 0;

            var options = new DbManagerOptions();

            Failover.Execute(() =>
            {
                Parser.Default.ParseArguments(args, options);

                if (!CheckInitOptions(options))
                {
                    Logger.Info(options.GetUsage());
                    return;
                }

                if (options.ShowAll)
                {
                    ShowAll(options);
                    return;
                }


                if (options.Backup)
                {
                    BackupDatabase(options);
                    return;
                }

                if (options.RestoreBackup)
                {
                    RestoreBackupDatabase(options);
                    return;
                }

                if (options.Upgrade)
                {
                    UpdateDatabase(options);
                    return;
                }
                if (options.Downgrade)
                {
                    DowngradeDatabase(options);
                    return;
                }
                if (options.Check)
                {
                    Logger.Info(Check(options));
                    return;
                }
                if (options.Recreate)
                {
                    DropDataBase();
                    UpdateDatabase(options);
                }
                if (options.DropDatabase)
                {
                    DropDataBase();
                }
            }, exception => { exitCode = -1; });

            if (options.Wait)
            {
                Console.ReadKey();
            }

            return(exitCode);
        }
Ejemplo n.º 5
0
 public void Execute(IJobExecutionContext context)
 {
     Failover.Execute(() => typeof(ExecuteSingletonJobEx <TExecution>).ExecuteInMonitor(() => Current <TExecution> .Instance.Execute(context)));
 }
Ejemplo n.º 6
0
 public void Execute(IJobExecutionContext context)
 {
     Failover.Execute(() => typeof(ExecutePerCallJob <TExecution>).ExecuteInMonitor(new TExecution().Execute));
 }
Ejemplo n.º 7
0
 public static int[] ParseString2IntArray(this string source)
 {
     return
         (Failover.Execute(
              () => source.Split(SEPARATORS).Select(_ => _.Trim()).Select(_ => Int32.Parse(_)).ToArray(), exception => new int[0]));
 }