コード例 #1
0
 public static Config getInstance()
 {
     if (instanceSingleton == null)
     {
         instanceSingleton = Deserialize(CONFIG_PATH);
     }
     return instanceSingleton;
 }
コード例 #2
0
ファイル: Config.cs プロジェクト: haighis/hocon
        /// <summary>
        /// Initializes a new instance of the <see cref="Config"/> class.
        /// </summary>
        /// <param name="source">The configuration to use as the primary source.</param>
        /// <param name="fallback">The configuration to use as a secondary source.</param>
        /// <exception cref="ArgumentNullException">The source configuration cannot be null.</exception>
        public Config(Config source, Config fallback)
        {
            if (source == null)
                throw new ArgumentNullException("source");

            Root = source.Root;
            Fallback = fallback;
        }
コード例 #3
0
ファイル: ApiUrlBuilder.cs プロジェクト: NasC0/LeagueComparer
        public static string BuildApiStaticDataUrl(Regions region, Config currentConfiguration)
        {
            string staticDataFormat = "{0}{1}/{2}/{3}";
            string baseUrl = Config.GetBaseUrl(Regions.global);
            string staticDataUrl = string.Format(staticDataFormat, baseUrl, currentConfiguration.StaticData, region, currentConfiguration.ApiLatestStaticDataVersion);

            return staticDataUrl;
        }
コード例 #4
0
 public static void Serialize(string file, Config c)
 {
     System.Xml.Serialization.XmlSerializer xs
        = new System.Xml.Serialization.XmlSerializer(c.GetType());
     StreamWriter writer = File.CreateText(file);
     xs.Serialize(writer, c);
     writer.Flush();
     writer.Close();
 }
コード例 #5
0
ファイル: UploadSpec.cs プロジェクト: siarheimilkevich/VSSync
 public UploadSpec(Config config, string fieldName, string fileName)
 {
     FieldName = fieldName;
     var dir = config == null ? string.Empty : config.GetOutputFolder();
     this.fileName = Path.Combine(dir, fileName);
     var fi2 = new FileInfo(this.fileName);
     contents = new byte[fi2.Length];
     using (var file = File.OpenRead(this.fileName))
     {
         file.Read(contents, 0, (int) fi2.Length);
     }
 }
コード例 #6
0
ファイル: Factory.cs プロジェクト: zerkms/shary
        public Interfaces.IStorage Storage(Config config)
        {
            var storages = config.Storages;

            switch (storages.Current)
            {
                case "Clipboard":
                    return new ClipboardStorage();

                default:
                    return new ClipboardStorage();
            }
        }
コード例 #7
0
 public void Cloneable()
 {
     var cmd = (CommandType) CommandType.DefInventoryCommand.Clone();
       cmd.OutputFileName = "";
       if (cmd.OutputFileName == CommandType.DefInventoryCommand.OutputFileName)
           throw new Exception();
       var tasks = new Task {Mailer = new List<MailerSubscriber> {new MailerSubscriber {CC = "CC"}}};
       var cfg = new Config {VMSConfigList = new List<VMSConfig> {new VMSConfig {Enabled = true, Task = tasks}}};
       var cfg2 = (Config) cfg.Clone();
       var vmsConfig2 = cfg2.VMSConfigList[0];
       var mailerSubscribers = vmsConfig2.Task.Mailer;
       mailerSubscribers[0].CC = "CC2";
       if (mailerSubscribers[0].CC == cfg.VMSConfigList[0].Task.Mailer[0].CC)
           throw new Exception();
 }
コード例 #8
0
        public Linq2DbWriteJournal(Configuration.Config config)
        {
            try
            {
                _journalConfig = new JournalConfig(config);
                _mat           = Materializer.CreateSystemMaterializer((ExtendedActorSystem)Context.System,
                                                                       ActorMaterializerSettings.Create(Context.System)
                                                                       .WithDispatcher(_journalConfig.MaterializerDispatcher)
                                                                       ,
                                                                       "l2dbWriteJournal"
                                                                       );

                try
                {
                    _journal = new ByteArrayJournalDao(
                        Context.System.Scheduler.Advanced, _mat,
                        new AkkaPersistenceDataConnectionFactory(
                            _journalConfig),
                        _journalConfig, Context.System.Serialization, Context.GetLogger());
                }
                catch (Exception e)
                {
                    Context.GetLogger().Error(e, "Error Initializing Journal!");
                    throw;
                }

                if (_journalConfig.TableConfig.AutoInitialize)
                {
                    try
                    {
                        _journal.InitializeTables();
                    }
                    catch (Exception e)
                    {
                        Context.GetLogger().Warning(e,
                                                    "Unable to Initialize Persistence Journal Table!");
                    }
                }
            }
            catch (Exception ex)
            {
                Context.GetLogger().Warning(ex, "Unexpected error initializing journal!");
                throw;
            }
        }
コード例 #9
0
ファイル: Export.cs プロジェクト: siarheimilkevich/VSSync
        protected override void OnStart(string[] args)
        {
            XmlConfigurator.Configure();
            Log.Info("VSSync Export Service started");
            config = Config.GetConfig(Log);

            this.sendErrorsThread = new Thread(this.SendErrors);
            //this.sendErrorsThread.IsBackground = true;
            this.sendErrorsThread.Start();

            try
            {
                var tasks = config.GetTasks();

                foreach (var task in tasks)
                {
                    var taskBase =  task as TaskBase;
                    if (taskBase != null)
                    {
                        if (taskBase.Config.RunAtStart)
                        {
                            taskManager.AddIntervalTask(task, DateTime.Now.AddSeconds(1), 0, (DateTime?)null);
                        }
                    }
                    var taskInterval = task as IInterval;

                    if (taskInterval == null) continue;
                    var interval = taskInterval.Interval*1000*60;
                    var startDateTime = taskInterval.StartDateTime;
                    taskManager.AddIntervalTask(task, startDateTime, interval, (DateTime?) null);
                    var vsSyncExportTask = task as VSSyncExportTask;
                    if (vsSyncExportTask != null)
                    {
                        vSSyncExportTask = vsSyncExportTask;
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error("Service starting error:", ex);
                throw;
            }
        }
コード例 #10
0
ファイル: Config.cs プロジェクト: siarheimilkevich/VSSync
        public static Config GetConfig(ILog logger, bool versionCheck = true)
        {
            var path = Path.GetDirectoryName(typeof (Config).Assembly.Location) ?? "";
            var tasksConfigPath = Path.Combine(path, "TaskConfig.xml");
            #if DEBUG
            if (!File.Exists(tasksConfigPath))
                GenerateTestXml(tasksConfigPath);
            #endif
            if (!File.Exists(tasksConfigPath))
                throw new ConfigurationErrorsException("The TaskConfig.xml is not found");
            var xml = new StreamReader(tasksConfigPath, Encoding.Default).ReadToEnd();
            logger.Info("Task config:\n" + xml);
            var validator = XmlValidator.Create("taskConfig", typeof (Config), "TaskConfig.xsd");
            validator.Validate(xml);
            var config = Deserialize(xml);
            if (versionCheck)
            {
                var version = config.Version;
                if (version.IsNullOrEmpty())
                    throw new ConfigurationErrorsException(@"The Config.Version attribute was not found in the config file.
            Looks like you use the old version of config file.

            Please
            - deinstall application,
            - clear application directory,
            - install again.");
                var cfgVersion = new Version(version);

                if (cfgVersion != typeof(Config).Assembly.GetName().Version)
                    throw new ConfigurationErrorsException("Incorrect version attribute was found in the config file");
            }

            Instance = config;
            config.Log = logger;
            return config;
        }
コード例 #11
0
ファイル: MainWindow.xaml.cs プロジェクト: zerkms/shary
 public void SetConfig(Config config)
 {
     _config = config;
 }
コード例 #12
0
ファイル: MainWindow.xaml.cs プロジェクト: zerkms/shary
 public MainWindow()
 {
     InitializeComponent();
     _config = ((App)App.Current).Config;
 }
コード例 #13
0
ファイル: RuneTypes.cs プロジェクト: NasC0/LeagueComparer
 public RuneTypes(HttpClient httpClient, Config currentConfiguration)
     : base(httpClient, currentConfiguration)
 {
     this.apiEndpoint = ApiUrlBuilder.BuildApiStaticDataUrl(Regions.euw, currentConfiguration);
     this.apiMethod = ApiMethod;
 }
コード例 #14
0
ファイル: Config.cs プロジェクト: siarheimilkevich/VSSync
        private static void GenerateTestXml(string tasksConfigPath)
        {
            var contacts = new List<Contact>();
            var subscriber = new MailerSubscriber
                                 {
                                     IsCompleted = true,
                                     IsStarted = true,
                                     IsError = true,
                                     ErrorMessageTemplate = "User: {5}\r\n{0} - {2}\r\nThe task result is wrong. \r\n{3} ",
                                     CompleteMessageTemplate = "User: {5}\r\n{0} - {1} - {2} - \r\nThe task is completed. \r\n{3} ",
                                     To = @"[email protected],
            [email protected]",
                                 };

            var mailer = new List<MailerSubscriber>
                             {
                                 subscriber
                             };

            var task = new Task
                           {
                               Interval = 1,
                               StartDateTime = DateTime.Now.AddMinutes(1),
                               Mailer = mailer,
                               Commands = new List<CommandType>()
                                              {
                                                  CommandType.DefInventoryCommand.CopyTo(new CommandType()),
                                                  (CommandType) CommandType.DefProductsCommand.Clone()
                                              }
                           };
            var tc = new Config
                         {
                             Version = "1.0.10.1",
                             Login = "******",
                             Password = "******",
                             Contacts = contacts,
                             SmtpSettings = new List<SmtpSetting>
                                                {
                                                    new SmtpSetting
                                                        {
                                                            EnableEmailSSL = false,
                                                            From = "*****@*****.**",
                                                            Host = "smtp.mail.ru",
                                                            Port = 25,
                                                            Login = "******",
                                                            Password = "******"
                                                        },
                                                    new SmtpSetting
                                                        {
                                                            EnableEmailSSL = false,
                                                            From = "*****@*****.**",
                                                            Host = "ssbmsrv000.VendScreen.by",
                                                            Port = 25,
                                                            Login = "******"
                                                        }
                                                },
                             HoldFileHours = 150,
                             IsMei = false,
                             Mei = new Mei
                                       {
                                           EasitraxDatabase = "sx7://10.0.0.2/f:/shared databases",
                                           Login = "******",
                                           Password = "******",
                                           ExecutablePath = @"D:\Downloads\ProcessExplorer\Procexp.exe",
                                           OutputDirectory = @"D:\output",
                                           ConnectionCommandLineParam = "d 63 r VS0003 . 12",
                                           CommandLineParam1 = ""
                                       },
                             VendMax = new VendMax
                                           {
                                               Server = "SSBMSRV000",
                                               Database = "QA50333_qa",
                                               Login = "******",
                                               Password = "******",
                                               OutputDirectory = @"D:\output",
                                               IsIntegrated = false
                                           },
                             UseDefaultEmail = true,
                             WebService = new WebService()
                                              {
                                                  Login = "******",
                                                  Password = "******",
                                                  DoArchiving = false,
                                                  Url = "https://vsm2m.net/import/upload/automatic"
                                              },
                             VMSConfigList = new List<VMSConfig>
                                                 {
                                                     new VMSConfig {Enabled = true, Task = task},
                                                     new VMSConfig
                                                         {
                                                             Enabled = true,
                                                             Task =
                                                                 new Task
                                                                     {
                                                                         Interval = 15,
                                                                         Mailer = task.Mailer,
                                                                         StartDateTime = task.StartDateTime,
                                                                         StartDateTimeSpecified =
                                                                             task.StartDateTimeSpecified,
                                                                         Commands = new List<CommandType>()
                                                                                        {
                                                                                            (CommandType)
                                                                                            CommandType.
                                                                                                DefServiceCallsCommand.
                                                                                                Clone()
                                                                                            //Select * from ServiceCalls where status = 'P'
                                                                                        }
                                                                     }
                                                         },
                                                 }
                         };

            tc.Validate();
            tc.SaveToFile(tasksConfigPath);
        }
コード例 #15
0
ファイル: App.xaml.cs プロジェクト: zerkms/shary
 private void InitializeConfig()
 {
     _config = new Config(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), APPLICATION_NAME));
 }
コード例 #16
0
ファイル: AnalysisBase.cs プロジェクト: NasC0/LeagueComparer
 public AnalysisBase(HttpClient apiQueryExecutor, Config currentConfiguration)
 {
     this.apiQueryExecutor = apiQueryExecutor;
     this.currentConfiguration = currentConfiguration;
 }
コード例 #17
0
ファイル: MainForm.cs プロジェクト: siarheimilkevich/VSSync
        /// <summary>
        ///     Form load event handler
        /// </summary>
        /// <param name="sender"> </param>
        /// <param name="e"> </param>
        private void MainForm_Load(object sender, EventArgs e)
        {
            Text += " {0}".F(GetType().Assembly.GetName().Version.ToString());
            FillAboutInfo();
            config = Config.GetConfig(Logger);
            if (!CheckLogin())
            {
                Close();
                return;
            }
            ScheduleDateTime.SuspendLayout();
            ReadSettings();
            ScheduleDateTime.ResumeLayout();
            try
            {
                var serviceControllerStatus = serviceController1.Status;
                Status.Text = serviceControllerStatus.ToString();
                Start.Enabled = serviceControllerStatus == ServiceControllerStatus.Stopped;
            }
            catch
            {
            }

            Stop.Enabled = !Start.Enabled;
            UpdateLastSent();
            this.InitializeStateChecker();

            this.ResetSaveButtons();
            Updater.URL = this.UpdateURL.Text;
        }
コード例 #18
0
ファイル: Config.cs プロジェクト: haighis/hocon
        /// <summary>
        /// Configure the current configuration with a secondary source.
        /// </summary>
        /// <param name="fallback">The configuration to use as a secondary source.</param>
        /// <returns>The current configuration configured with the specified fallback.</returns>
        /// <exception cref="ArgumentException">Config can not have itself as fallback.</exception>
        public virtual Config WithFallback(Config fallback)
        {
            if (fallback == this)
                throw new ArgumentException("Config can not have itself as fallback", "fallback");

            Config clone = Copy();

            Config current = clone;
            while (current.Fallback != null)
            {
                current = current.Fallback;
            }
            current.Fallback = fallback;

            return clone;
        }
コード例 #19
0
ファイル: Config.cs プロジェクト: haighis/hocon
 /// <summary>
 /// Retrieves the current configuration or the fallback
 /// configuration if the current one is null.
 /// </summary>
 /// <param name="config">The configuration used as the source.</param>
 /// <param name="fallback">The configuration to use as a secondary source.</param>
 /// <returns>The current configuration or the fallback configuration if the current one is null.</returns>
 public static Config SafeWithFallback(this Config config, Config fallback)
 {
     return config == null
         ? fallback
         : ReferenceEquals(config, fallback)
             ? config
             : config.WithFallback(fallback);
 }
コード例 #20
0
 public ChampionResourcesAnalyser(HttpClient apiQueryExecutor, Config currentConfiguration)
     : base(apiQueryExecutor, currentConfiguration)
 {
     this.apiEndpoint = ApiUrlBuilder.BuildApiStaticDataUrl(Regions.euw, currentConfiguration);
     this.apiMethod = ApiMethod;
 }