public static void Load() { try { SettingsReader r = new SettingsReader(Reg, "Settings"); Settings.Ports = r.Read<List<int>>("Ports"); Settings.Passwords = r.Read<List<string>>("Passwords"); Settings.DupPrevnt = r.Read<bool>("Dup"); Settings.LogConnected = r.Read<bool>("LogConnect"); Settings.LogDisconnected = r.Read<bool>("LogDis"); Settings.NotifyConnected = r.Read<bool>("NotifyCon"); Settings.NotifyDisconnected = r.Read<bool>("NotifyDis"); r.Dispose(); } catch { } try { SettingsReader r = new SettingsReader(Reg, "Plugins"); GlobalProperties.RawPlugins = r.Read<SortedList<Guid, byte[]>>("Plugins"); r.Dispose(); PluginHelper.InitializePlugins(); PluginHelper.pluginChanged(); } catch { } }
public JavaCompilerProcess() { AppSettingsReader = new SettingsReader(); StartInfo.UseShellExecute = false; StartInfo.RedirectStandardOutput = true; StartInfo.RedirectStandardError = true; StartInfo.FileName = AppSettingsReader.GetValueAsString("javac_path"); }
public void OneLevelTest() { var settingsPath = GetSettingsPath(); var reader = new SettingsReader(settingsPath); var result = reader.Read(); Assert.AreEqual(result["Acropolis.SolutionFolder"].Value, @"Please specify Acropolis.SolutionFolder in your configuration!"); }
public void TwoLevelTest() { var settingsPath = Path.Combine(GetSettingsPath(), "DmitrySchetnikovich"); var reader = new SettingsReader(settingsPath); var result = reader.Read(); Assert.AreEqual(result["Acropolis.SolutionFolder"].Value, @"d:\Projects\Ajeva Project"); }
public void ThreeLevelTest() { var settingsPath = Path.Combine(GetSettingsPath(), "Production\\Test"); var reader = new SettingsReader(settingsPath); var result = reader.Read(); Assert.AreEqual(result["Xomo.Application.RootUrl"].Value, @"http://xomo.epear.com"); }
public LogDescriptionConfig(string configFileName):base(configFileName) { Id = ConfigFileName; SettingsReader settingsReader = new SettingsReader(ConfigFileName); FileMask = new Regex(settingsReader.GetConfigParam("FileMask"), RegexOptions.Compiled); Encoding = Encoding.GetEncoding(settingsReader.GetConfigParam("Encoding")); IEnumerable<string> possibleLogDirectories = settingsReader.GetConfigParams("LogDirectory").SelectMany(FilePathHelpers.FindDirectoriesOnFixedDisks); List<string> directories = possibleLogDirectories.SelectMany(FilePathHelpers.GetDirectoriesByMaskedPath).Distinct().ToList(); LogDirectories = directories; _ruleManager = new EvaluatorRuleManager(Path.ChangeExtension(configFileName, "EventDescriptions")); }
public static int GetTotal() { try { SettingsReader r = new SettingsReader(Reg, "Total"); int res = r.Read<int>("TOTAL"); r.Dispose(); return res; } catch { } return 0; }
public EvaluatorRuleConfig(string configFileName): base(configFileName) { SettingsReader settingsReader = new SettingsReader(ConfigFileName); EventType = GetLogEventType(settingsReader.GetConfigParam("Type")); EventSource = settingsReader.GetConfigParam("Source"); CounterCategory = settingsReader.GetConfigParam("Category"); CounterName = settingsReader.GetConfigParam("Counter"); CounterInstance = settingsReader.GetConfigParam("Instance", false); ExtendedData = settingsReader.GetConfigParam("ExtendedData", false); Value = settingsReader.GetConfigParam("Value"); DateTime = settingsReader.GetConfigParam("DateTime"); DateFormat = settingsReader.GetConfigParam("DateFormat"); Regex = new Regex(settingsReader.GetConfigParam("Regex"),RegexOptions.Compiled); }
// Use this for initialization void Start() { //VideoRecorder vr = new VideoRecorder(); settings = new SettingsReader("settings.xml"); car = carObject.GetComponent<Car>(); car.speed = settings.velocity; car.cameraRotationError = settings.cameraRorationError; car.positionError = settings.sensorPositionError; sceneContent = new SceneContentReader("scene.xml"); foreach(SceneItem item in sceneContent.itemList) { cube.transform.localScale = item.size; Instantiate(cube, item.position, Quaternion.Euler(item.rotation)); } LogFlag = false; if (menuScript.mode == menuScript.CarMode.Save || menuScript.mode == menuScript.CarMode.Play) { if (menuScript.sensorsMode == menuScript.SensorsMode.GoodSensors) sensors = new SensorsReader(settings.goodSensorsXMLPath); else sensors = new SensorsReader(settings.badSensorsXMLPath); if (menuScript.mode == menuScript.CarMode.Save) { Debug.Log("read " + sensors.sensorsInfoList.Count + " sensors"); savePath = System.IO.Directory.GetCurrentDirectory().ToString() + "\\CarSensorsFrames_" + System.DateTime.Now.ToString("dd-MM-yyyy_HH-mm-ss"); Debug.Log(savePath); System.IO.Directory.CreateDirectory(savePath); } } }
public RootModule() { Get["/"] = parameters => { var model = new RootUrls { KnownEndpointsUrl = "/endpoints/known", // relative URI to allow proxying MessageSearchUrl = BaseUrl + "/messages/search/{keyword}/{?page,per_page,direction,sort}", EndpointsMessageSearchUrl = BaseUrl + "/endpoints/{name}/messages/search/{keyword}/{?page,per_page,direction,sort}", EndpointsMessagesUrl = BaseUrl + "/endpoints/{name}/messages/{?page,per_page,direction,sort}", Name = SettingsReader <string> .Read("Name", "ServiceControl.Audit"), Description = SettingsReader <string> .Read("Description", "The audit backend for the Particular Service Platform"), Configuration = BaseUrl + "/configuration" }; return(Negotiate .WithModel(model)); }; Func <dynamic, dynamic> configuration = p => Negotiate .WithModel(new { Host = new { Settings.ServiceName, RavenDBPath = Settings.DbPath, Logging = new { LoggingSettings.LogPath, LoggingLevel = LoggingSettings.LoggingLevel.Name, RavenDBLogLevel = LoggingSettings.RavenDBLogLevel.Name } }, DataRetention = new { Settings.AuditRetentionPeriod, }, PerformanceTunning = new { Settings.MaxBodySizeToStore, Settings.HttpDefaultConnectionLimit, Settings.ExpirationProcessBatchSize, Settings.ExpirationProcessTimerInSeconds }, Transport = new { Settings.TransportCustomizationType, Settings.AuditLogQueue, Settings.AuditQueue, Settings.ForwardAuditMessages, }, Plugins = new { } }); Get["/instance-info"] = Get["/configuration"] = configuration; }
private void frmBatch_Load(object sender, EventArgs e) { textBox1.Hide(); //SettingsReader sr = new SettingsReader("CUE Tools", "settings.txt", Application.ExecutablePath); //_profile.Load(sr); //_reducePriority = sr.LoadBoolean("ReducePriority") ?? true; _reducePriority = true; _profile = new CUEToolsProfile(_profileName); SettingsReader sr = new SettingsReader("CUE Tools", string.Format("profile-{0}.txt", _profileName), Application.ExecutablePath); _profile.Load(sr); if (_reducePriority) Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.Idle; if (_profile._action != CUEAction.Verify) txtOutputFile.Show(); StartConvert(); }
public SettingsWnd() { _settings = SettingsReader.GetSettings(); InitializeComponent(); SettingsGrd.ItemsSource = _settings.List; }
void LoadProfile(string name) { try { SettingsReader r = new SettingsReader(Net_Weave_R.Misc.Settings.Reg, name); ProfileData d = r.Read<ProfileData>("DATA"); r.Dispose(); ListViewItem i = new ListViewItem(); i.Text = d.Name; i.SubItems.Add(d.LastModified); i.Tag = d; lstProfiles.Items.Add(i); } catch { } }
static TestBase() { Console.WriteLine("Tests started in {0}...", #if NETSTANDARD1_6 System.IO.Directory.GetCurrentDirectory() #else Environment.CurrentDirectory #endif ); Console.WriteLine("CLR Version: {0}...", #if NETSTANDARD1_6 System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription #else Environment.Version #endif ); var traceCount = 0; DataConnection.WriteTraceLine = (s1, s2) => { if (traceCount < 10000) { Console.WriteLine("{0}: {1}", s2, s1); Debug.WriteLine(s1, s2); } if (traceCount++ > 10000) { DataConnection.TurnTraceSwitchOn(TraceLevel.Error); } }; // Configuration.RetryPolicy.Factory = db => new Retry(); // Configuration.AvoidSpecificDataProviderAPI = true; Configuration.Linq.TraceMapperExpression = false; // Configuration.Linq.GenerateExpressionTest = true; var assemblyPath = typeof(TestBase).AssemblyEx().GetPath(); #if !NETSTANDARD1_6 && !NETSTANDARD2_0 try { SqlServerTypes.Utilities.LoadNativeAssemblies(assemblyPath); } catch // this can fail during tests discovering with NUnitTestAdapter { } #endif #if NETSTANDARD1_6 System.IO.Directory.SetCurrentDirectory(assemblyPath); #else Environment.CurrentDirectory = assemblyPath; #endif var dataProvidersJsonFile = GetFilePath(assemblyPath, @"DataProviders.json"); var userDataProvidersJsonFile = GetFilePath(assemblyPath, @"UserDataProviders.json"); var dataProvidersJson = File.ReadAllText(dataProvidersJsonFile); var userDataProvidersJson = File.Exists(userDataProvidersJsonFile) ? File.ReadAllText(userDataProvidersJsonFile) : null; #if NETSTANDARD1_6 var configName = "CORE1"; #elif NETSTANDARD2_0 var configName = "CORE2"; #else var configName = "NET45"; #endif #if APPVEYOR #warning "AppVeyor configuration detected." Console.WriteLine("AppVeyor configuration detected."); configName += ".AppVeyor"; #endif #if TRAVIS #warning "Travis configuration detected." Console.WriteLine("Travis configuration detected."); configName += ".Travis"; #endif var testSettings = SettingsReader.Deserialize(configName, dataProvidersJson, userDataProvidersJson); var databasePath = Path.GetFullPath(Path.Combine("Database")); var dataPath = Path.Combine(databasePath, "Data"); if (Directory.Exists(dataPath)) { Directory.Delete(dataPath, true); } Directory.CreateDirectory(dataPath); foreach (var file in Directory.GetFiles(databasePath, "*.*")) { var destination = Path.Combine(dataPath, Path.GetFileName(file)); Console.WriteLine("{0} => {1}", file, destination); File.Copy(file, destination, true); } UserProviders = new HashSet <string>(testSettings.Providers, StringComparer.OrdinalIgnoreCase); var logLevel = testSettings.TraceLevel; var traceLevel = TraceLevel.Info; if (!string.IsNullOrEmpty(logLevel)) { if (!Enum.TryParse(logLevel, true, out traceLevel)) { traceLevel = TraceLevel.Info; } } DataConnection.TurnTraceSwitchOn(traceLevel); Console.WriteLine("Connection strings:"); #if NETSTANDARD1_6 || NETSTANDARD2_0 DataConnection.DefaultSettings = TxtSettings.Instance; TxtSettings.Instance.DefaultConfiguration = "SQLiteMs"; foreach (var provider in testSettings.Connections /*.Where(c => UserProviders.Contains(c.Key))*/) { if (string.IsNullOrWhiteSpace(provider.Value.ConnectionString)) { throw new InvalidOperationException("ConnectionString should be provided"); } Console.WriteLine($"\tName=\"{provider.Key}\", Provider=\"{provider.Value.Provider}\", ConnectionString=\"{provider.Value.ConnectionString}\""); TxtSettings.Instance.AddConnectionString( provider.Key, provider.Value.Provider ?? provider.Key, provider.Value.ConnectionString); } #else foreach (var provider in testSettings.Connections) { Console.WriteLine($"\tName=\"{provider.Key}\", Provider=\"{provider.Value.Provider}\", ConnectionString=\"{provider.Value.ConnectionString}\""); DataConnection.AddOrSetConfiguration( provider.Key, provider.Value.ConnectionString, provider.Value.Provider ?? ""); } #endif Console.WriteLine("Providers:"); foreach (var userProvider in UserProviders) { Console.WriteLine($"\t{userProvider}"); } var defaultConfiguration = testSettings.DefaultConfiguration; if (!string.IsNullOrEmpty(defaultConfiguration)) { DataConnection.DefaultConfiguration = defaultConfiguration; #if NETSTANDARD1_6 || NETSTANDARD2_0 TxtSettings.Instance.DefaultConfiguration = defaultConfiguration; #endif } #if !NETSTANDARD1_6 && !NETSTANDARD2_0 LinqService.TypeResolver = str => { switch (str) { case "Tests.Model.Gender": return(typeof(Gender)); case "Tests.Model.Person": return(typeof(Person)); default: return(null); } }; #endif }
public void UseSettingsToReadAppConfig() { var settingsReader = new SettingsReader(); Assert.True(!string.IsNullOrEmpty(settingsReader.CanRead)); }
public RootModule() { Get["/"] = parameters => { var model = new RootUrls { EndpointsUrl = BaseUrl + "/endpoints", KnownEndpointsUrl = "/endpoints/known", // relative URI to allow proxying SagasUrl = BaseUrl + "/sagas", ErrorsUrl = BaseUrl + "/errors/{?page,per_page,direction,sort}", EndpointsErrorUrl = BaseUrl + "/endpoints/{name}/errors/{?page,per_page,direction,sort}", MessageSearchUrl = BaseUrl + "/messages/search/{keyword}/{?page,per_page,direction,sort}", EndpointsMessageSearchUrl = BaseUrl + "/endpoints/{name}/messages/search/{keyword}/{?page,per_page,direction,sort}", EndpointsMessagesUrl = BaseUrl + "/endpoints/{name}/messages/{?page,per_page,direction,sort}", Name = SettingsReader <string> .Read("Name", "ServiceControl"), Description = SettingsReader <string> .Read("Description", "The management backend for the Particular Service Platform"), LicenseStatus = License.IsValid ? "valid" : "invalid", LicenseDetails = BaseUrl + "/license", Configuration = BaseUrl + "/configuration" }; return(Negotiate .WithModel(model)); }; Func <dynamic, dynamic> configuration = p => Negotiate .WithModel(new { Host = new { Settings.ServiceName, RavenDBPath = Settings.DbPath, Logging = new { LoggingSettings.LogPath, LoggingLevel = LoggingSettings.LoggingLevel.Name, RavenDBLogLevel = LoggingSettings.RavenDBLogLevel.Name } }, DataRetention = new { Settings.AuditRetentionPeriod, Settings.ErrorRetentionPeriod }, PerformanceTunning = new { Settings.MaxBodySizeToStore, Settings.HttpDefaultConnectionLimit, Settings.ExternalIntegrationsDispatchingBatchSize, Settings.ExpirationProcessBatchSize, Settings.ExpirationProcessTimerInSeconds }, Transport = new { Settings.TransportCustomizationType, Settings.AuditLogQueue, Settings.AuditQueue, Settings.ErrorLogQueue, Settings.ErrorQueue, Settings.ForwardAuditMessages, Settings.ForwardErrorMessages }, Plugins = new { Settings.HeartbeatGracePeriod } }); Get["/instance-info"] = Get["/configuration"] = configuration; }
private SettingsModel GetSettings() { return(SettingsReader.GetSettings <SettingsModel>(Program.SettingsFileName)); }
private static void RegisterSettings(Container container) { var settings = ConfigurationManager.AppSettings; container.Register(() => SettingsReader.ReadFileStorage(settings), Lifestyle.Singleton); }
static TestBase() { Console.WriteLine("Tests started in {0}...", Environment.CurrentDirectory); Console.WriteLine("CLR Version: {0}...", Environment.Version); var traceCount = 0; DataConnection.TurnTraceSwitchOn(TraceLevel.Info); DataConnection.WriteTraceLine = (message, name, level) => { var ctx = CustomTestContext.Get(); var trace = ctx.Get <StringBuilder>(CustomTestContext.TRACE); if (trace == null) { trace = new StringBuilder(); ctx.Set(CustomTestContext.TRACE, trace); } trace.AppendLine($"{name}: {message}"); if (traceCount < TRACES_LIMIT || level == TraceLevel.Error) { ctx.Set(CustomTestContext.LIMITED, true); Console.WriteLine("{0}: {1}", name, message); Debug.WriteLine(message, name); } traceCount++; }; // Configuration.RetryPolicy.Factory = db => new Retry(); Configuration.Linq.TraceMapperExpression = false; // Configuration.Linq.GenerateExpressionTest = true; var assemblyPath = typeof(TestBase).Assembly.GetPath(); #if NET46 try { SqlServerTypes.Utilities.LoadNativeAssemblies(assemblyPath); } catch // this can fail during tests discovering with NUnitTestAdapter { } #endif Environment.CurrentDirectory = assemblyPath; var dataProvidersJsonFile = GetFilePath(assemblyPath, @"DataProviders.json"); var userDataProvidersJsonFile = GetFilePath(assemblyPath, @"UserDataProviders.json"); var dataProvidersJson = File.ReadAllText(dataProvidersJsonFile); var userDataProvidersJson = File.Exists(userDataProvidersJsonFile) ? File.ReadAllText(userDataProvidersJsonFile) : null; #if NETCOREAPP2_1 var configName = "CORE21"; #elif NETCOREAPP3_1 var configName = "CORE31"; #elif NET46 var configName = "NET46"; #else var configName = ""; #error Unknown framework #endif #if AZURE Console.WriteLine("Azure configuration detected."); configName += ".Azure"; #endif var testSettings = SettingsReader.Deserialize(configName, dataProvidersJson, userDataProvidersJson); var databasePath = Path.GetFullPath(Path.Combine("Database")); var dataPath = Path.Combine(databasePath, "Data"); if (Directory.Exists(dataPath)) { Directory.Delete(dataPath, true); } Directory.CreateDirectory(dataPath); foreach (var file in Directory.GetFiles(databasePath, "*.*")) { var destination = Path.Combine(dataPath, Path.GetFileName(file)); Console.WriteLine("{0} => {1}", file, destination); File.Copy(file, destination, true); } UserProviders = new HashSet <string>(testSettings.Providers ?? Array <string> .Empty, StringComparer.OrdinalIgnoreCase); SkipCategories = new HashSet <string>(testSettings.Skip ?? Array <string> .Empty, StringComparer.OrdinalIgnoreCase); var logLevel = testSettings.TraceLevel; var traceLevel = TraceLevel.Info; if (!string.IsNullOrEmpty(logLevel)) { if (!Enum.TryParse(logLevel, true, out traceLevel)) { traceLevel = TraceLevel.Info; } } if (!string.IsNullOrEmpty(testSettings.NoLinqService)) { DataSourcesBaseAttribute.NoLinqService = ConvertTo <bool> .From(testSettings.NoLinqService); } DataConnection.TurnTraceSwitchOn(traceLevel); Console.WriteLine("Connection strings:"); #if !NET46 DataConnection.DefaultSettings = TxtSettings.Instance; TxtSettings.Instance.DefaultConfiguration = "SQLiteMs"; foreach (var provider in testSettings.Connections /*.Where(c => UserProviders.Contains(c.Key))*/) { if (string.IsNullOrWhiteSpace(provider.Value.ConnectionString)) { throw new InvalidOperationException("ConnectionString should be provided"); } Console.WriteLine($"\tName=\"{provider.Key}\", Provider=\"{provider.Value.Provider}\", ConnectionString=\"{provider.Value.ConnectionString}\""); TxtSettings.Instance.AddConnectionString( provider.Key, provider.Value.Provider ?? "", provider.Value.ConnectionString); } #else foreach (var provider in testSettings.Connections) { Console.WriteLine($"\tName=\"{provider.Key}\", Provider=\"{provider.Value.Provider}\", ConnectionString=\"{provider.Value.ConnectionString}\""); DataConnection.AddOrSetConfiguration( provider.Key, provider.Value.ConnectionString, provider.Value.Provider ?? ""); } #endif Console.WriteLine("Providers:"); foreach (var userProvider in UserProviders) { Console.WriteLine($"\t{userProvider}"); } DefaultProvider = testSettings.DefaultConfiguration; if (!DefaultProvider.IsNullOrEmpty()) { DataConnection.DefaultConfiguration = DefaultProvider; #if !NET46 TxtSettings.Instance.DefaultConfiguration = DefaultProvider; #endif } #if NET46 LinqService.TypeResolver = str => { return(str switch { "Tests.Model.Gender" => typeof(Gender), "Tests.Model.Person" => typeof(Person), _ => null, }); };
public void Load(SettingsReader sr) { int version = sr.LoadInt32("Version", null, null) ?? 202; fixOffsetMinimumConfidence = sr.LoadUInt32("ArFixWhenConfidence", 1, 1000) ?? 2; fixOffsetMinimumTracksPercent = sr.LoadUInt32("ArFixWhenPercent", 1, 100) ?? 51; encodeWhenConfidence = sr.LoadUInt32("ArEncodeWhenConfidence", 1, 1000) ?? 2; encodeWhenPercent = sr.LoadUInt32("ArEncodeWhenPercent", 1, 100) ?? 100; encodeWhenZeroOffset = sr.LoadBoolean("ArEncodeWhenZeroOffset") ?? false; noUnverifiedOutput = sr.LoadBoolean("ArNoUnverifiedOutput") ?? false; fixOffset = sr.LoadBoolean("ArFixOffset") ?? false; writeArTagsOnEncode = sr.LoadBoolean("ArWriteCRC") ?? writeArTagsOnEncode; writeArLogOnConvert = sr.LoadBoolean("ArWriteLog") ?? true; writeArTagsOnVerify = sr.LoadBoolean("ArWriteTagsOnVerify") ?? false; writeArLogOnVerify = sr.LoadBoolean("ArWriteLogOnVerify") ?? false; preserveHTOA = sr.LoadBoolean("PreserveHTOA") ?? true; detectGaps = sr.LoadBoolean("DetectGaps") ?? true; autoCorrectFilenames = sr.LoadBoolean("AutoCorrectFilenames") ?? true; keepOriginalFilenames = sr.LoadBoolean("KeepOriginalFilenames") ?? false; singleFilenameFormat = sr.Load("SingleFilenameFormat") ?? singleFilenameFormat; trackFilenameFormat = sr.Load("TrackFilenameFormat") ?? trackFilenameFormat; removeSpecial = sr.LoadBoolean("RemoveSpecialCharacters") ?? false; specialExceptions = sr.Load("SpecialCharactersExceptions") ?? "-()"; replaceSpaces = sr.LoadBoolean("ReplaceSpaces") ?? false; embedLog = sr.LoadBoolean("EmbedLog") ?? true; extractLog = sr.LoadBoolean("ExtractLog") ?? true; fillUpCUE = sr.LoadBoolean("FillUpCUE") ?? true; overwriteCUEData = sr.LoadBoolean("OverwriteCUEData") ?? false; filenamesANSISafe = sr.LoadBoolean("FilenamesANSISafe") ?? true; bruteForceDTL = sr.LoadBoolean("BruteForceDTL") ?? false; createEACLOG = sr.LoadBoolean("CreateEACLOG") ?? createEACLOG; detectHDCD = sr.LoadBoolean("DetectHDCD") ?? true; wait750FramesForHDCD = sr.LoadBoolean("Wait750FramesForHDCD") ?? true; decodeHDCD = sr.LoadBoolean("DecodeHDCD") ?? false; createM3U = sr.LoadBoolean("CreateM3U") ?? false; createCUEFileWhenEmbedded = sr.LoadBoolean("CreateCUEFileWhenEmbedded") ?? true; truncate4608ExtraSamples = sr.LoadBoolean("Truncate4608ExtraSamples") ?? true; decodeHDCDtoLW16 = sr.LoadBoolean("DecodeHDCDToLossyWAV16") ?? false; decodeHDCDto24bit = sr.LoadBoolean("DecodeHDCDTo24bit") ?? true; oneInstance = sr.LoadBoolean("OneInstance") ?? true; checkForUpdates = sr.LoadBoolean("CheckForUpdates") ?? true; writeBasicTagsFromCUEData = sr.LoadBoolean("WriteBasicTagsFromCUEData") ?? true; copyBasicTags = sr.LoadBoolean("CopyBasicTags") ?? true; copyUnknownTags = sr.LoadBoolean("CopyUnknownTags") ?? true; CopyAlbumArt = sr.LoadBoolean("CopyAlbumArt") ?? true; embedAlbumArt = sr.LoadBoolean("EmbedAlbumArt") ?? true; extractAlbumArt = sr.LoadBoolean("ExtractAlbumArt") ?? true; maxAlbumArtSize = sr.LoadInt32("MaxAlbumArtSize", 100, 10000) ?? maxAlbumArtSize; arLogToSourceFolder = sr.LoadBoolean("ArLogToSourceFolder") ?? arLogToSourceFolder; arLogVerbose = sr.LoadBoolean("ArLogVerbose") ?? arLogVerbose; fixOffsetToNearest = sr.LoadBoolean("FixOffsetToNearest") ?? fixOffsetToNearest; ArLogFilenameFormat = sr.Load("ArLogFilenameFormat") ?? ArLogFilenameFormat; AlArtFilenameFormat = sr.Load("AlArtFilenameFormat") ?? AlArtFilenameFormat; separateDecodingThread = sr.LoadBoolean("SeparateDecodingThread") ?? separateDecodingThread; try { using (TextReader reader = new StringReader(sr.Load("Advanced"))) advanced = CUEConfigAdvanced.serializer.Deserialize(reader) as CUEConfigAdvanced; } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message); } int totalEncoders = sr.LoadInt32("ExternalEncoders", 0, null) ?? 0; for (int nEncoders = 0; nEncoders < totalEncoders; nEncoders++) { string name = sr.Load(string.Format("ExternalEncoder{0}Name", nEncoders)); string extension = sr.Load(string.Format("ExternalEncoder{0}Extension", nEncoders)); string settings = sr.Load(string.Format("ExternalEncoder{0}Settings", nEncoders)); bool lossless = sr.LoadBoolean(string.Format("ExternalEncoder{0}Lossless", nEncoders)) ?? true; CUEToolsUDC encoder; if (name == null || extension == null) { continue; } if (!encoders.TryGetValue(extension, lossless, name, out encoder)) { encoder = new CUEToolsUDC(name, extension, lossless, "", "", "", ""); encoders.Add(encoder); } try { using (TextReader reader = new StringReader(settings)) encoder.settings = encoder.settingsSerializer.Deserialize(reader) as AudioEncoderSettings; if (encoder.settings is UserDefinedEncoderSettings && (encoder.settings as UserDefinedEncoderSettings).Path == "") { throw new Exception(); } } catch { if (version == 203 && encoder.settings is UserDefinedEncoderSettings) { (encoder.settings as UserDefinedEncoderSettings).SupportedModes = sr.Load(string.Format("ExternalEncoder{0}Modes", nEncoders)); (encoder.settings as UserDefinedEncoderSettings).EncoderMode = sr.Load(string.Format("ExternalEncoder{0}Mode", nEncoders)); (encoder.settings as UserDefinedEncoderSettings).Path = sr.Load(string.Format("ExternalEncoder{0}Path", nEncoders)); (encoder.settings as UserDefinedEncoderSettings).Parameters = sr.Load(string.Format("ExternalEncoder{0}Parameters", nEncoders)); } else { encoders.Remove(encoder); } } } int totalDecoders = sr.LoadInt32("ExternalDecoders", 0, null) ?? 0; for (int nDecoders = 0; nDecoders < totalDecoders; nDecoders++) { string name = sr.Load(string.Format("ExternalDecoder{0}Name", nDecoders)); string extension = sr.Load(string.Format("ExternalDecoder{0}Extension", nDecoders)); string path = sr.Load(string.Format("ExternalDecoder{0}Path", nDecoders)); string parameters = sr.Load(string.Format("ExternalDecoder{0}Parameters", nDecoders)); CUEToolsUDC decoder; if (!decoders.TryGetValue(extension, true, name, out decoder)) { decoders.Add(new CUEToolsUDC(name, extension, path, parameters)); } else { decoder.extension = extension; decoder.path = path; decoder.parameters = parameters; } } int totalFormats = sr.LoadInt32("CustomFormats", 0, null) ?? 0; for (int nFormats = 0; nFormats < totalFormats; nFormats++) { string extension = sr.Load(string.Format("CustomFormat{0}Name", nFormats)); string encoderLossless = sr.Load(string.Format("CustomFormat{0}EncoderLossless", nFormats)) ?? ""; string encoderLossy = sr.Load(string.Format("CustomFormat{0}EncoderLossy", nFormats)) ?? ""; string decoder = sr.Load(string.Format("CustomFormat{0}Decoder", nFormats)); CUEToolsTagger tagger = (CUEToolsTagger)(sr.LoadInt32(string.Format("CustomFormat{0}Tagger", nFormats), 0, 2) ?? 0); bool allowLossless = sr.LoadBoolean(string.Format("CustomFormat{0}AllowLossless", nFormats)) ?? false; bool allowLossy = sr.LoadBoolean(string.Format("CustomFormat{0}AllowLossy", nFormats)) ?? false; bool allowEmbed = sr.LoadBoolean(string.Format("CustomFormat{0}AllowEmbed", nFormats)) ?? false; CUEToolsFormat format; CUEToolsUDC udcLossless, udcLossy, udcDecoder; if (encoderLossless == "" || !encoders.TryGetValue(extension, true, encoderLossless, out udcLossless)) { udcLossless = encoders.GetDefault(extension, true); } if (encoderLossy == "" || !encoders.TryGetValue(extension, false, encoderLossy, out udcLossy)) { udcLossy = encoders.GetDefault(extension, false); } if (decoder == "" || !decoders.TryGetValue(extension, true, decoder, out udcDecoder)) { udcDecoder = decoders.GetDefault(extension, true); } if (!formats.TryGetValue(extension, out format)) { formats.Add(extension, new CUEToolsFormat(extension, tagger, allowLossless, allowLossy, allowEmbed, false, udcLossless, udcLossy, udcDecoder)); } else { format.encoderLossless = udcLossless; format.encoderLossy = udcLossy; format.decoder = udcDecoder; if (!format.builtin) { format.tagger = tagger; format.allowLossless = allowLossless; format.allowLossy = allowLossy; format.allowEmbed = allowEmbed; } } } defaultVerifyScript = sr.Load("DefaultVerifyScript") ?? "default"; defaultEncodeScript = sr.Load("DefaultVerifyAndConvertScript") ?? "default"; gapsHandling = (CUEStyle?)sr.LoadInt32("GapsHandling", null, null) ?? gapsHandling; language = sr.Load("Language") ?? Thread.CurrentThread.CurrentUICulture.Name; if (ArLogFilenameFormat.Contains("%F")) { ArLogFilenameFormat = "%filename%.accurip"; } if (singleFilenameFormat.Contains("%F")) { singleFilenameFormat = "%filename%"; } if (trackFilenameFormat.Contains("%N")) { trackFilenameFormat = "%tracknumber%. %title%"; } }
public void GetApiKey(string serviceName, string serviceVersion) { SettingsReader <List <ApiKey> > reader = new SettingsReader <List <ApiKey> >(); Key = reader.Read(apiKeyPath).FirstOrDefault(x => x.ServiceName == serviceName && x.ServiceVersion == serviceVersion); }
public override void Execute() { var eventModel = CurrentActionProperties(TargetCollection, this.GetType().Name); eventModel.Summary.Processed = 1; OnTrigger(new PreingestEventArgs { Description = "Start indexing metadata", Initiate = DateTimeOffset.Now, ActionType = PreingestActionStates.Started, PreingestAction = eventModel }); bool isSuccess = false; var anyMessages = new List <String>(); try { base.Execute(); BodySettings settings = new SettingsReader(this.ApplicationSettings.DataFolderName, SessionGuid).GetSettings(); if (settings == null) { throw new ApplicationException("Settings are not saved!"); } StyleName = "Noord.Hollands.Archief.Preingest.WebApi.Stylesheet.flatten.xsl"; SchemaName = String.IsNullOrEmpty(settings.SchemaToValidate) ? String.Format("Noord.Hollands.Archief.Preingest.WebApi.Schema.{0}", IsToPX ? "ToPX-2.3_2.xsd" : IsMDTO ? "MDTO-XML 1.0.xsd" : throw new ApplicationException("Cannot determine ToPX either MDTO!")) : String.Format("Noord.Hollands.Archief.Preingest.WebApi.Schema.{0}", settings.SchemaToValidate); IgnoreErrorValidationErrors = settings.IgnoreValidation.Equals("Ja", StringComparison.InvariantCultureIgnoreCase); //if argument from call is set, settings is empty: use values from argument //if argument from call is set, settings is set, but different sequence or content, use values from settings if (!String.IsNullOrEmpty(settings.RootNamesExtraXml)) { var inputRootNamesExtraXml = settings.RootNamesExtraXml.Split(';', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); bool isSequenceEqual = Enumerable.SequenceEqual <String>(RootNames, inputRootNamesExtraXml); if (!isSequenceEqual) { RootNames = inputRootNamesExtraXml; } } List <ResultPair> totalResult = new List <ResultPair>(); var result = ContinueDefaultCollectionItems(TargetFolder); eventModel.Summary.Processed = result.TotalContentData.Count; if (result.TotalContentData != null && result.TotalContentData.Count > 0) { totalResult.Add(result); } else { _validationResultList.Add(new ProcessResultItem { Error = new ApplicationException(String.Format("No metadata files found.")), Metadata = null, Type = ProcessType.SchemaValidation }); } if (RootNames != null && RootNames.Length > 0) { foreach (string rootName in RootNames) { var extraResult = ContinueExtraCollectionItems(TargetFolder, rootName); eventModel.Summary.Processed = eventModel.Summary.Processed + extraResult.TotalContentData.Count; if (extraResult.TotalContentData.Count == 0) { _validationResultList.Add(new ProcessResultItem { Error = new ApplicationException(String.Format("No extra XML files found with root element '{0}'.", rootName)), Metadata = null, Type = ProcessType.XmlOthers }); } else { totalResult.Add(extraResult); } } if (_validationResultList.Count > 0 && !IgnoreErrorValidationErrors) { throw new ApplicationException("Error(s) found looking for extra XML files!"); } } CreateExcel(totalResult); eventModel.Summary.Accepted = (eventModel.Summary.Processed - _validationResultList.Count); eventModel.Summary.Rejected = 0; eventModel.ActionData = new string[] { }; if (eventModel.Summary.Rejected > 0) { eventModel.ActionResult.ResultValue = PreingestActionResults.Error; } else { eventModel.ActionResult.ResultValue = PreingestActionResults.Success; } isSuccess = true; } catch (Exception e) { isSuccess = false; Logger.LogError(e, "An exception occured while indexing the metadata files!"); anyMessages.Clear(); anyMessages.Add("An exception occured while indexing the metadata files!"); anyMessages.Add(e.Message); anyMessages.Add(e.StackTrace); anyMessages.AddRange(_validationResultList.Select(item => item.ToString())); eventModel.Summary.Accepted = (eventModel.Summary.Processed - _validationResultList.Count); eventModel.Summary.Rejected = 1; eventModel.ActionResult.ResultValue = PreingestActionResults.Failed; eventModel.Properties.Messages = anyMessages.ToArray(); OnTrigger(new PreingestEventArgs { Description = "An exception occured while indexing the metadata files!", Initiate = DateTimeOffset.Now, ActionType = PreingestActionStates.Failed, PreingestAction = eventModel }); } finally { if (isSuccess) { OnTrigger(new PreingestEventArgs { Description = "Indexing metadata files is done.", Initiate = DateTimeOffset.Now, ActionType = PreingestActionStates.Completed, PreingestAction = eventModel }); } } }
private void LoadSettings() { SettingsReader sr = new SettingsReader("CUE Tools", "settings.txt", Application.ExecutablePath); profilePath = sr.ProfilePath; _profile.Load(sr); lastMOTD = sr.LoadDate("LastMOTD") ?? DateTime.FromBinary(0); _choiceWidth = sr.LoadInt32("ChoiceWidth", null, null) ?? 0; _choiceHeight = sr.LoadInt32("ChoiceHeight", null, null) ?? 0; _choiceMaxed = sr.LoadBoolean("ChoiceMaxed") ?? false; _defaultLosslessFormat = sr.Load("DefaultLosslessFormat") ?? "flac"; _defaultLossyFormat = sr.Load("DefaultLossyFormat") ?? "mp3"; _defaultHybridFormat = sr.Load("DefaultHybridFormat") ?? "lossy.flac"; _defaultNoAudioFormat = sr.Load("DefaultNoAudioFormat") ?? "wav"; int iFormat, nFormats = sr.LoadInt32("OutputPathUseTemplates", 0, 10) ?? 0; for (iFormat = 0; iFormat < OutputPathUseTemplates.Length; iFormat++) comboBoxOutputFormat.Items.Add(OutputPathUseTemplates[iFormat]); for (iFormat = nFormats - 1; iFormat >= 0; iFormat--) comboBoxOutputFormat.Items.Add(sr.Load(string.Format("OutputPathUseTemplate{0}", iFormat)) ?? ""); OutputPathUseTemplate = !(sr.LoadBoolean("DontGenerate") ?? false); ActivateProfile(); _usePregapForFirstTrackInSingleFile = sr.LoadBoolean("UsePregapForFirstTrackInSingleFile") ?? false; _reducePriority = sr.LoadBoolean("ReducePriority") ?? true; CorrectorMode = (CorrectorModeEnum)(sr.LoadInt32("CorrectorLookup", null, null) ?? (int)CorrectorModeEnum.Locate); toolStripButtonCorrectorOverwrite.Checked = sr.LoadBoolean("CorrectorOverwrite") ?? true; string correctorFormat = sr.Load("CorrectorFormat") ?? "flac"; foreach (KeyValuePair<string, CUEToolsFormat> format in _profile._config.formats) { ToolStripItem item = new ToolStripMenuItem(format.Key); item.ImageKey = "." + format.Value.extension; toolStripDropDownButtonCorrectorFormat.DropDownItems.Add(item); if (correctorFormat == format.Key) { toolStripDropDownButtonCorrectorFormat.Text = item.Text; toolStripDropDownButtonCorrectorFormat.ImageKey = item.ImageKey; } } SizeIncrement.Width = sr.LoadInt32("WidthIncrement", 0, null) ?? 0; SizeIncrement.Height = sr.LoadInt32("HeightIncrement", 0, null) ?? 0; Size = OpenMinimumSize + SizeIncrement; Top = sr.LoadInt32("Top", 0, null) ?? Top; Left = sr.LoadInt32("Left", 0, null) ?? Left; if (InputPath == "") { InputPath = sr.Load("InputPath") ?? ""; FileBrowserState = (FileBrowserStateEnum)(sr.LoadInt32("FileBrowserState", (int)FileBrowserStateEnum.Tree, (int)FileBrowserStateEnum.Hidden) ?? (int)FileBrowserStateEnum.Hidden); } else FileBrowserState = FileBrowserStateEnum.Hidden; ReportState = sr.LoadBoolean("ReportState") ?? false; PerformLayout(); string profiles = sr.Load("Profiles") ?? "verify convert fix"; foreach (string prof in profiles.Split(' ')) toolStripDropDownButtonProfile.DropDownItems.Add(prof); }
private void Init() { Logger.Log.Info("--- Инициализация ---"); if (_tbi == null) { _notificationManager = new NotificationManager(); CreateTaskBarIcon(); ShowMessage += AddTextToConsole; ShowBalloonMsg += ShowBalloonTip; } try { _settings = SettingsReader.GetSettings(); if (string.IsNullOrEmpty(_settings.Password)) { Logger.Log.Error("Пустой пароль в настройках!"); MessageBox.Show("Password is empty!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); return; } var secureString = SettingsReader.DecryptString(_settings.Password); var rawPass = SettingsReader.ToInsecureString(secureString); _requestSender.Init(ShowMessage, ShowBalloonMsg, _settings.Login, rawPass); } catch (Exception e) { AddTextToConsole(e.Message); Logger.Log.ErrorFormat("Ошибка чтения настроек. {0}", e.InnerException); } if (_settings != null) { //bind controls to settings DbList.Items.Clear(); SelectedFolder.Text = _settings.DefaultPath; FileNameTb.Text = _settings.SelectedDb; foreach (var listItem in _settings.List) { DbList.Items.Add(listItem.DbName); } if (!string.IsNullOrEmpty(_settings.SelectedDb)) { DbList.SelectedValue = _settings.SelectedDb; UrlTb.Text = _settings.List.FirstOrDefault(i => i.DbName == _settings.SelectedDb)?.Url ?? string.Empty; } } //hide instead of close Loaded += delegate { HwndSource source = (HwndSource)PresentationSource.FromDependencyObject(this); source?.AddHook(WindowProc); }; Closing += (x, y) => { switch (_closeReason) { case CloseReason.EndTask: break; case CloseReason.Logoff: break; case CloseReason.User: WindowState = WindowState.Minimized; y.Cancel = true; break; case CloseReason.Manually: break; default: throw new ArgumentOutOfRangeException(); } }; Logger.Log.Info("--- Конец инициализации ---"); }
public HostArguments(string[] args) { if (SettingsReader <bool> .Read("MaintenanceMode")) { args = args.Concat(new[] { "-m" }).ToArray(); } var executionMode = ExecutionMode.Run; Commands = new List <Type> { typeof(RunCommand) }; ServiceName = Settings.DEFAULT_SERVICE_NAME; var defaultOptions = new OptionSet { { "?|h|help", "Help about the command line options.", key => { Help = true; } }, }; var maintenanceOptions = new OptionSet { { "m|maint|maintenance", @"Run RavenDB only - use for DB maintenance", s => { Commands = new List <Type> { typeof(MaintCommand) }; executionMode = ExecutionMode.Maintenance; } } }; // Not documented in help - Used by SC installer only var externalInstallerOptions = new OptionSet { { "s|setup", @"Internal use - for new installer" , s => { Commands = new List <Type> { typeof(SetupCommand) }; executionMode = ExecutionMode.RunInstallers; } }, { "serviceName=", @"Specify the service name for the installed service." , s => { ServiceName = s; } }, { "userName="******"Username for the account the service should run under." , s => { Username = s; } } }; var externalUnitTestRunnerOptions = new OptionSet { { "p|portable", @"Internal use - runs as a console app, even non-interactively", s => { Portable = true; } } }; try { externalInstallerOptions.Parse(args); if (executionMode == ExecutionMode.RunInstallers) { return; } maintenanceOptions.Parse(args); if (executionMode == ExecutionMode.Maintenance) { return; } defaultOptions.Parse(args); externalUnitTestRunnerOptions.Parse(args); } catch (Exception e) { Console.WriteLine(e.Message); Help = true; } }
private Boolean firstrun = true; //If it's the first run, add an aditional line break to the text-log public LogWriter(SettingsReader settingsBuffer) { sett = settingsBuffer; }
static ViewModelBase() { RestServiceAddress = SettingsReader.GetAppSetting("RestServiceAddress"); }
public override void Execute() { var eventModel = CurrentActionProperties(TargetCollection, this.GetType().Name); OnTrigger(new PreingestEventArgs { Description = "Start prewashing/transformation *.metadata files.", Initiate = DateTimeOffset.Now, ActionType = PreingestActionStates.Started, PreingestAction = eventModel }); var anyMessages = new List <String>(); bool isSucces = false; var transformation = new List <WashedItem>(); try { base.Execute(); if (this.IsToPX) { string[] metadatas = Directory.GetFiles(TargetFolder, "*.metadata", SearchOption.AllDirectories); eventModel.Summary.Processed = metadatas.Count(); BodySettings settings = new SettingsReader(this.ApplicationSettings.DataFolderName, SessionGuid).GetSettings(); if (settings == null) { throw new ApplicationException("Settings are not saved!"); } if (String.IsNullOrEmpty(settings.Prewash)) { throw new ApplicationException("Prewash setting is empty!"); } settings.Prewash = settings.Prewash.EndsWith(".xslt") ? settings.Prewash.Replace(".xslt", string.Empty) : settings.Prewash; var keyValueContent = settings.ToKeyValue(); var formUrlEncodedContent = new FormUrlEncodedContent(keyValueContent); var urlEncodedString = formUrlEncodedContent.ReadAsStringAsync().Result; if (String.IsNullOrEmpty(urlEncodedString)) { throw new ApplicationException("Post data is empty!"); } foreach (string file in metadatas) { Logger.LogInformation("Prewashing/transformation : {0}", file); string requestUri = GetProcessingUrl(ApplicationSettings.XslWebServerName, ApplicationSettings.XslWebServerPort, file); using (WebClient wc = new WebClient()) { wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded"; string result = wc.UploadString(requestUri, urlEncodedString); XDocument xDoc = XDocument.Parse(result); try { if (xDoc.Root.Name.Equals("message")) { transformation.Add(new WashedItem { IsWashed = false, MetadataFilename = file, RequestUri = requestUri, ErrorMessage = new string[] { String.Format("Voorbewerking/transformatie niet gelukt voor '{0}'. Antwoord: {1}", requestUri, xDoc.ToString()) } }); } else { //overwrite new with old. xDoc.Save(file); transformation.Add(new WashedItem { IsWashed = true, MetadataFilename = file, RequestUri = requestUri, ErrorMessage = new string[0] }); } } catch (Exception e) { var errorMessages = new List <String>(); Logger.LogError(e, String.Format("Exception occured in prewashing/transformation with request '{0}' for metadata file '{1}'!", requestUri, file)); errorMessages.Add(String.Format("Exception occured in prewashing/transformation with request '{0}' for metadata file '{1}'!", requestUri, file)); errorMessages.Add(e.Message); errorMessages.Add(e.StackTrace); //error transformation.Add(new WashedItem { IsWashed = false, ErrorMessage = errorMessages.ToArray(), MetadataFilename = file, RequestUri = requestUri }); } } OnTrigger(new PreingestEventArgs { Description = String.Format("Processing file '{0}'", file), Initiate = DateTimeOffset.Now, ActionType = PreingestActionStates.Executing, PreingestAction = eventModel }); } eventModel.Summary.Accepted = transformation.Where(item => item.IsWashed).Count(); eventModel.Summary.Rejected = transformation.Where(item => !item.IsWashed).Count(); eventModel.ActionData = transformation.ToArray(); } if (this.IsMDTO) { //TODO throw new ApplicationException("Not supported in this current version yet!"); } if (eventModel.Summary.Rejected > 0) { eventModel.ActionResult.ResultValue = PreingestActionResults.Error; } else { eventModel.ActionResult.ResultValue = PreingestActionResults.Success; } isSucces = true; } catch (WebException e) { isSucces = false; anyMessages.Clear(); Logger.LogError(e, "An exception occured in prewashing/transformation metadata!", e.Message); anyMessages.Add("An exception occured in prewashing/transformation metadata!"); if (e.Status == WebExceptionStatus.ProtocolError) { Logger.LogError(String.Format("Status Code : {0}", ((HttpWebResponse)e.Response).StatusCode)); Logger.LogError(String.Format("Status Description : {0}", ((HttpWebResponse)e.Response).StatusDescription)); anyMessages.Add(String.Format("Status Code : {0}", ((HttpWebResponse)e.Response).StatusCode)); anyMessages.Add(String.Format("Status Description : {0}", ((HttpWebResponse)e.Response).StatusDescription)); using (StreamReader r = new StreamReader(((HttpWebResponse)e.Response).GetResponseStream())) { Logger.LogError(String.Format("Content: {0}", r.ReadToEnd())); anyMessages.Add(String.Format("Content: {0}", r.ReadToEnd())); } } anyMessages.Add(e.Message); anyMessages.Add(e.StackTrace); //eventModel.Summary.Processed = 0; eventModel.Summary.Accepted = 0; eventModel.Summary.Rejected = eventModel.Summary.Processed; eventModel.ActionResult.ResultValue = PreingestActionResults.Failed; eventModel.Properties.Messages = anyMessages.ToArray(); OnTrigger(new PreingestEventArgs { Description = "An exception occured in prewashing/transformation metadata!", Initiate = DateTimeOffset.Now, ActionType = PreingestActionStates.Failed, PreingestAction = eventModel }); } catch (Exception e) { isSucces = false; Logger.LogError(e, "An exception occured in prewashing/transformation metadata!"); anyMessages.Clear(); anyMessages.Add("An exception occured in prewashing/transformation metadata!"); anyMessages.Add(e.Message); anyMessages.Add(e.StackTrace); //eventModel.Summary.Processed = 0; eventModel.Summary.Accepted = 0; eventModel.Summary.Rejected = eventModel.Summary.Processed; eventModel.ActionResult.ResultValue = PreingestActionResults.Failed; eventModel.Properties.Messages = anyMessages.ToArray(); OnTrigger(new PreingestEventArgs { Description = "An exception occured in prewashing/transformation metadata!", Initiate = DateTimeOffset.Now, ActionType = PreingestActionStates.Failed, PreingestAction = eventModel }); } finally { if (isSucces) { OnTrigger(new PreingestEventArgs { Description = "Prewashing/transformation is done.", Initiate = DateTimeOffset.Now, ActionType = PreingestActionStates.Completed, PreingestAction = eventModel }); } } }
private void ResetBtn_OnClick(object sender, RoutedEventArgs e) { _settings = SettingsReader.GetSettings(); SettingsGrd.ItemsSource = null; SettingsGrd.ItemsSource = _settings.List; }
private void Awake() { instance = this; }
private void SaveBtn_OnClick(object sender, RoutedEventArgs e) { SettingsReader.Save(_settings); Close(); }
public override void Execute() { var eventModel = CurrentActionProperties(TargetCollection, this.GetType().Name); OnTrigger(new PreingestEventArgs { Description = String.Format("Start building Opex for container '{0}'.", TargetCollection), Initiate = DateTimeOffset.Now, ActionType = PreingestActionStates.Started, PreingestAction = eventModel }); var anyMessages = new List <String>(); bool isSuccess = false; try { base.Execute(); string sessionFolder = Path.Combine(ApplicationSettings.DataFolderName, SessionGuid.ToString()); BodySettings settings = new SettingsReader(this.ApplicationSettings.DataFolderName, SessionGuid).GetSettings(); if (settings == null) { throw new ApplicationException("Settings are not saved!"); } if (!String.IsNullOrEmpty(settings.MergeRecordAndFile)) { bool doMerge = settings.MergeRecordAndFile.Equals("Ja", StringComparison.InvariantCultureIgnoreCase); if (doMerge && InheritanceSetting.MethodResult == InheritanceMethod.None) { //true && true this.InheritanceSetting.MethodResult = InheritanceMethod.Combine; } } string addNameSpaces = Path.Combine(ApplicationSettings.PreWashFolder, OpexItem.ADD_NAMESPACE); string stripNameSpaces = Path.Combine(ApplicationSettings.PreWashFolder, OpexItem.STRIP_NAMESPACE); string opexFolders = Path.Combine(ApplicationSettings.PreWashFolder, OpexItem.OPEX_FOLDERS); string opexFolderFiles = Path.Combine(ApplicationSettings.PreWashFolder, OpexItem.OPEX_FOLDER_FILES); string opexFiles = Path.Combine(ApplicationSettings.PreWashFolder, OpexItem.OPEX_FILES); string opexFinalize = Path.Combine(ApplicationSettings.PreWashFolder, OpexItem.OPEX_FINALIZE); if (!File.Exists(addNameSpaces)) { throw new FileNotFoundException(String.Format("Stylesheet file not found '{0}'!", addNameSpaces)); } if (!File.Exists(stripNameSpaces)) { throw new FileNotFoundException(String.Format("Stylesheet file not found '{0}'!", stripNameSpaces)); } if (!File.Exists(opexFolders)) { throw new FileNotFoundException(String.Format("Stylesheet file not found '{0}'!", opexFolders)); } if (!File.Exists(opexFolderFiles)) { throw new FileNotFoundException(String.Format("Stylesheet file not found '{0}'!", opexFolderFiles)); } if (!File.Exists(opexFiles)) { throw new FileNotFoundException(String.Format("Stylesheet file not found '{0}'!", opexFiles)); } if (!File.Exists(opexFinalize)) { throw new FileNotFoundException(String.Format("Stylesheet file not found '{0}'!", opexFinalize)); } List <StylesheetItem> stylesheetList = new List <StylesheetItem>(); OnTrigger(new PreingestEventArgs { Description = String.Format("Load settings for building Opex.", TargetCollection), Initiate = DateTimeOffset.Now, ActionType = PreingestActionStates.Executing, PreingestAction = eventModel }); var stylesheets = Directory.GetFiles(ApplicationSettings.PreWashFolder, "*-opex-*.xsl").Select(item => new StylesheetItem { KeyLocation = item, XmlContent = XDocument.Load(item).ToString() }).ToArray(); stylesheetList.AddRange(stylesheets); List <OpexItem> potentionalOpexList = new List <OpexItem>(); OnTrigger(new PreingestEventArgs { Description = String.Format("Reading collection to build Opex for container '{0}'.", TargetCollection), Initiate = DateTimeOffset.Now, ActionType = PreingestActionStates.Executing, PreingestAction = eventModel }); //trigger event read collections if (this.IsToPX) { var listOfMetadata = new DirectoryInfo(Path.Combine(ApplicationSettings.DataFolderName, SessionGuid.ToString())).GetFiles("*.metadata", SearchOption.AllDirectories).Select(item => new OpexItem(this.TargetFolder, item.FullName, XDocument.Load(item.FullName).ToString(), item.Directory.GetFiles("*.metadata", SearchOption.TopDirectoryOnly).Count())).ToArray(); potentionalOpexList.AddRange(listOfMetadata); OnTrigger(new PreingestEventArgs { Description = String.Format("Found '{0}' metadata ({1}) files.", potentionalOpexList.Count, this.IsToPX ? "ToPX" : "MDTO"), Initiate = DateTimeOffset.Now, ActionType = PreingestActionStates.Executing, PreingestAction = eventModel }); } if (this.IsMDTO) { var listOfMetadata = new DirectoryInfo(Path.Combine(ApplicationSettings.DataFolderName, SessionGuid.ToString())).GetFiles("*.xml", SearchOption.AllDirectories).Where(item => item.Name.EndsWith(".mdto.xml", StringComparison.InvariantCultureIgnoreCase)).Select(item => new OpexItem(this.TargetFolder, item.FullName, XDocument.Load(item.FullName).ToString(), item.Directory.GetFiles("*.xml", SearchOption.TopDirectoryOnly).Where(item => item.Name.EndsWith(".mdto.xml", StringComparison.InvariantCultureIgnoreCase)).Count())).ToArray(); potentionalOpexList.AddRange(listOfMetadata); OnTrigger(new PreingestEventArgs { Description = String.Format("Found '{0}' metadata ({1}) files.", potentionalOpexList.Count, this.IsToPX ? "ToPX" : "MDTO"), Initiate = DateTimeOffset.Now, ActionType = PreingestActionStates.Executing, PreingestAction = eventModel }); } OnTrigger(new PreingestEventArgs { Description = String.Format("Creating Opex files."), Initiate = DateTimeOffset.Now, ActionType = PreingestActionStates.Executing, PreingestAction = eventModel }); //trigger event process opex potentionalOpexList.ForEach(item => { item.InitializeOpex(stylesheetList); }); var jsonData = new List <String>(); OnTrigger(new PreingestEventArgs { Description = String.Format("Removing original metadata files."), Initiate = DateTimeOffset.Now, ActionType = PreingestActionStates.Executing, PreingestAction = eventModel }); //remove the old metadata files topx or mdto potentionalOpexList.ForEach(item => { try { File.Delete(item.KeyLocation); } catch (Exception delete) { anyMessages.Add(String.Format("Deleting file '{0}' failed! {1} {2}", item.KeyLocation, delete.Message, delete.StackTrace)); } }); OnTrigger(new PreingestEventArgs { Description = String.Format("Saving Opex files (only file level)."), Initiate = DateTimeOffset.Now, ActionType = PreingestActionStates.Executing, PreingestAction = eventModel }); var sortedPotentionalOpexList = new List <OpexItem>(); if (InheritanceSetting.MethodResult == InheritanceMethod.Combine) { var sorted = potentionalOpexList.Where(item => !item.IsFile).GroupBy(item => item.Level, (key, opex) => new { Level = key, Item = opex }).OrderByDescending(item => item.Level).FirstOrDefault(); sortedPotentionalOpexList.AddRange(sorted.Item.OfType <OpexItem>()); } //save bestand level first potentionalOpexList.Where(item => item.IsFile).ToList().ForEach(item => { try { var metadataList = new List <System.Xml.XmlElement>(); if (InheritanceSetting.MethodResult == InheritanceMethod.Combine) { var parts = item.KeyLocation.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).ToArray(); var startsWith = parts.Skip(0).Take(parts.Count() - 1).ToArray(); var currentItemPath = "/" + Path.Combine(startsWith); var profile = sortedPotentionalOpexList.FirstOrDefault(sorted => sorted.KeyLocation.StartsWith(currentItemPath)); if (profile == null) { throw new ApplicationException(String.Format("Adding profile to DescriptiveMetadata failed! Cannot find profile record in '{0}'", currentItemPath)); } var xmlProfileDoc = new System.Xml.XmlDocument(); xmlProfileDoc.LoadXml(profile.OriginalMetadata); metadataList.Add(xmlProfileDoc.DocumentElement); } if (InheritanceSetting.MethodResult == InheritanceMethod.None) { metadataList.Clear(); } item.UpdateOpexFileLevel(ApplicationSettings.ChecksumServerName, ApplicationSettings.ChecksumServerPort, metadataList, true); var xml = XDocument.Parse(item.FinalUpdatedOpexMetadata); xml.Save(item.KeyOpexLocation); } catch (Exception save) { anyMessages.Add(String.Format("Saving Opex file '{0}' failed! {1} {2}", item.KeyOpexLocation, save.Message, save.StackTrace)); } }); OnTrigger(new PreingestEventArgs { Description = String.Format("Saving Opex files (folder levels)."), Initiate = DateTimeOffset.Now, ActionType = PreingestActionStates.Executing, PreingestAction = eventModel }); //update mappen levels //save the rest of the folder levels potentionalOpexList.Where(item => !item.IsFile).ToList().ForEach(item => { try { item.UpdateOpexFolderLevel(); var xml = XDocument.Parse(item.FinalUpdatedOpexMetadata); xml.Save(item.KeyOpexLocation); } catch (Exception save) { anyMessages.Add(String.Format("Saving Opex file '{0}' failed! {1} {2}", item.KeyOpexLocation, save.Message, save.StackTrace)); } }); OnTrigger(new PreingestEventArgs { Description = String.Format("Rounding up Opex."), Initiate = DateTimeOffset.Now, ActionType = PreingestActionStates.Executing, PreingestAction = eventModel }); //create container opex file, //move the result to a folder named 'opex'; //this folder will be used by the bucket container for upload to S3 var currentCollectionDI = new DirectoryInfo(TargetFolder); var currentCollectionFoldername = currentCollectionDI.GetDirectories().OrderBy(item => item.CreationTime).FirstOrDefault(); if (currentCollectionFoldername == null) { throw new DirectoryNotFoundException("Expanded collection folder not found!"); } var opexContainerFilename = CreateContainerOpexMetadata(currentCollectionDI, currentCollectionFoldername.Name); var opexUploadFolder = Directory.CreateDirectory(Path.Combine(TargetFolder, "opex")); opexContainerFilename.MoveTo(Path.Combine(opexUploadFolder.FullName, opexContainerFilename.Name), true); currentCollectionFoldername.MoveTo(Path.Combine(opexUploadFolder.FullName, currentCollectionFoldername.Name)); OnTrigger(new PreingestEventArgs { Description = String.Format("Reading Opex files for XSD schema validation."), Initiate = DateTimeOffset.Now, ActionType = PreingestActionStates.Executing, PreingestAction = eventModel }); var newOpexFiles = opexUploadFolder.GetFiles("*.opex").ToList(); var schemaList = SchemaHandler.GetSchemaList(); var strXsd = schemaList["Noord.Hollands.Archief.Preingest.WebApi.Schema.OPEX-Metadata.xsd"]; var xsdTmpFilename = Path.GetTempFileName(); var xsd = XDocument.Parse(strXsd); xsd.Save(xsdTmpFilename); OnTrigger(new PreingestEventArgs { Description = String.Format("Validate Opex files with XSD schema."), Initiate = DateTimeOffset.Now, ActionType = PreingestActionStates.Executing, PreingestAction = eventModel }); newOpexFiles.ForEach(opex => { try { if (String.IsNullOrEmpty(opex.FullName) || !File.Exists(opex.FullName)) { throw new FileNotFoundException(String.Format("Opex file with location '{0}' is empty or not found!", opex.FullName)); } XDocument xml = XDocument.Load(opex.FullName); SchemaValidationHandler.Validate(xml.ToString(), xsdTmpFilename); } catch (Exception validate) { anyMessages.Add(String.Format("Schema validation error for Opex file '{0}'! {1} {2}", opex.FullName, validate.Message, validate.StackTrace)); } }); try { File.Delete(xsdTmpFilename); } catch { } var result = potentionalOpexList.Select(item => String.Format("{0} >> {1}", item.KeyLocation, item.KeyOpexLocation)).ToArray(); jsonData.AddRange(result); opexContainerFilename.Refresh(); jsonData.Add("All moved to folder 'opex'."); jsonData.Add(opexContainerFilename.FullName); eventModel.ActionData = jsonData.ToArray(); eventModel.Summary.Processed = potentionalOpexList.Count; eventModel.Summary.Accepted = potentionalOpexList.Count; eventModel.Summary.Rejected = anyMessages.Count(); eventModel.Properties.Messages = anyMessages.ToArray(); if (eventModel.Summary.Rejected > 0) { eventModel.ActionResult.ResultValue = PreingestActionResults.Error; } else { eventModel.ActionResult.ResultValue = PreingestActionResults.Success; } isSuccess = true; } catch (Exception e) { isSuccess = false; anyMessages.Clear(); anyMessages.Add(String.Format("Build Opex with collection: '{0}' failed!", TargetCollection)); anyMessages.Add(e.Message); anyMessages.Add(e.StackTrace); Logger.LogError(e, "Build Opex with collection: '{0}' failed!", TargetCollection); eventModel.ActionResult.ResultValue = PreingestActionResults.Failed; eventModel.Properties.Messages = anyMessages.ToArray(); eventModel.Summary.Processed = 1; eventModel.Summary.Accepted = 0; eventModel.Summary.Rejected = 1; OnTrigger(new PreingestEventArgs { Description = "An exception occured while building opex!", Initiate = DateTimeOffset.Now, ActionType = PreingestActionStates.Failed, PreingestAction = eventModel }); } finally { if (isSuccess) { OnTrigger(new PreingestEventArgs { Description = "Build Opex with a collection is done.", Initiate = DateTimeOffset.Now, ActionType = PreingestActionStates.Completed, PreingestAction = eventModel }); } } }
public void list_all_keys() { var keys = new SettingsReader("key1 = 123\r\nkey2 = 124\r\n# key3 = 12838"); keys.Keys.Should().ContainInOrder(new[] { "key1", "key2", "key3" }); }
public void Load(SettingsReader sr) { int version = sr.LoadInt32("Version", null, null) ?? 202; fixOffsetMinimumConfidence = sr.LoadUInt32("ArFixWhenConfidence", 1, 1000) ?? 2; fixOffsetMinimumTracksPercent = sr.LoadUInt32("ArFixWhenPercent", 1, 100) ?? 51; encodeWhenConfidence = sr.LoadUInt32("ArEncodeWhenConfidence", 1, 1000) ?? 2; encodeWhenPercent = sr.LoadUInt32("ArEncodeWhenPercent", 1, 100) ?? 100; encodeWhenZeroOffset = sr.LoadBoolean("ArEncodeWhenZeroOffset") ?? false; noUnverifiedOutput = sr.LoadBoolean("ArNoUnverifiedOutput") ?? false; fixOffset = sr.LoadBoolean("ArFixOffset") ?? false; writeArTagsOnEncode = sr.LoadBoolean("ArWriteCRC") ?? writeArTagsOnEncode; writeArLogOnConvert = sr.LoadBoolean("ArWriteLog") ?? true; writeArTagsOnVerify = sr.LoadBoolean("ArWriteTagsOnVerify") ?? false; writeArLogOnVerify = sr.LoadBoolean("ArWriteLogOnVerify") ?? false; preserveHTOA = sr.LoadBoolean("PreserveHTOA") ?? true; detectGaps = sr.LoadBoolean("DetectGaps") ?? true; autoCorrectFilenames = sr.LoadBoolean("AutoCorrectFilenames") ?? true; keepOriginalFilenames = sr.LoadBoolean("KeepOriginalFilenames") ?? false; singleFilenameFormat = sr.Load("SingleFilenameFormat") ?? singleFilenameFormat; trackFilenameFormat = sr.Load("TrackFilenameFormat") ?? trackFilenameFormat; removeSpecial = sr.LoadBoolean("RemoveSpecialCharacters") ?? false; specialExceptions = sr.Load("SpecialCharactersExceptions") ?? "-()"; replaceSpaces = sr.LoadBoolean("ReplaceSpaces") ?? false; embedLog = sr.LoadBoolean("EmbedLog") ?? true; extractLog = sr.LoadBoolean("ExtractLog") ?? true; fillUpCUE = sr.LoadBoolean("FillUpCUE") ?? true; overwriteCUEData = sr.LoadBoolean("OverwriteCUEData") ?? false; filenamesANSISafe = sr.LoadBoolean("FilenamesANSISafe") ?? true; bruteForceDTL = sr.LoadBoolean("BruteForceDTL") ?? false; createEACLOG = sr.LoadBoolean("CreateEACLOG") ?? createEACLOG; detectHDCD = sr.LoadBoolean("DetectHDCD") ?? true; wait750FramesForHDCD = sr.LoadBoolean("Wait750FramesForHDCD") ?? true; decodeHDCD = sr.LoadBoolean("DecodeHDCD") ?? false; createM3U = sr.LoadBoolean("CreateM3U") ?? false; createCUEFileWhenEmbedded = sr.LoadBoolean("CreateCUEFileWhenEmbedded") ?? true; truncate4608ExtraSamples = sr.LoadBoolean("Truncate4608ExtraSamples") ?? true; decodeHDCDtoLW16 = sr.LoadBoolean("DecodeHDCDToLossyWAV16") ?? false; decodeHDCDto24bit = sr.LoadBoolean("DecodeHDCDTo24bit") ?? true; oneInstance = sr.LoadBoolean("OneInstance") ?? true; checkForUpdates = sr.LoadBoolean("CheckForUpdates") ?? true; writeBasicTagsFromCUEData = sr.LoadBoolean("WriteBasicTagsFromCUEData") ?? true; copyBasicTags = sr.LoadBoolean("CopyBasicTags") ?? true; copyUnknownTags = sr.LoadBoolean("CopyUnknownTags") ?? true; CopyAlbumArt = sr.LoadBoolean("CopyAlbumArt") ?? true; embedAlbumArt = sr.LoadBoolean("EmbedAlbumArt") ?? true; extractAlbumArt = sr.LoadBoolean("ExtractAlbumArt") ?? true; maxAlbumArtSize = sr.LoadInt32("MaxAlbumArtSize", 100, 10000) ?? maxAlbumArtSize; arLogToSourceFolder = sr.LoadBoolean("ArLogToSourceFolder") ?? arLogToSourceFolder; arLogVerbose = sr.LoadBoolean("ArLogVerbose") ?? arLogVerbose; fixOffsetToNearest = sr.LoadBoolean("FixOffsetToNearest") ?? fixOffsetToNearest; ArLogFilenameFormat = sr.Load("ArLogFilenameFormat") ?? ArLogFilenameFormat; AlArtFilenameFormat = sr.Load("AlArtFilenameFormat") ?? AlArtFilenameFormat; separateDecodingThread = sr.LoadBoolean("SeparateDecodingThread") ?? separateDecodingThread; var jsonConfig = sr.Load("Advanced"); if (jsonConfig != null) { var backup = advanced; try { var jsonObject = JsonConvert.DeserializeObject(jsonConfig, typeof(CUEConfigAdvanced), new JsonSerializerSettings { DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, TypeNameHandling = TypeNameHandling.Auto, Error = (sender, ev) => { System.Diagnostics.Trace.WriteLine(ev.ErrorContext.Error.ToString()); ev.ErrorContext.Handled = true; } }); if (jsonObject as CUEConfigAdvanced == null) { throw new Exception(); } advanced = jsonObject as CUEConfigAdvanced; // Add missing codecs backup.encoders.Where(x => advanced.encoders .FindAll(y => y.Extension == x.Extension && y.Lossless == x.Lossless && y.Name == x.Name).Count == 0) .ToList().ForEach(x => advanced.encoders.Add(x)); backup.decoders.Where(x => advanced.decoders .FindAll(y => y.Extension == x.Extension && y.Name == x.Name).Count == 0) .ToList().ForEach(x => advanced.decoders.Add(x)); // Reset the ViewModel advanced.encodersViewModel = new EncoderListViewModel(advanced.encoders); advanced.decodersViewModel = new DecoderListViewModel(advanced.decoders); // Reset the links in formats foreach (var extension in formats.Keys) { var format = formats[extension]; AudioEncoderSettingsViewModel encoderLossless, encoderLossy; AudioDecoderSettingsViewModel decoder; if (format.encoderLossless == null || !Encoders.TryGetValue(extension, true, format.encoderLossless.Name, out encoderLossless)) { encoderLossless = Encoders.GetDefault(extension, true); } if (format.encoderLossy == null || !Encoders.TryGetValue(extension, false, format.encoderLossy.Name, out encoderLossy)) { encoderLossy = Encoders.GetDefault(extension, false); } if (format.decoder == null || !Decoders.TryGetValue(extension, format.decoder.Name, out decoder)) { decoder = Decoders.GetDefault(extension); } format.encoderLossless = encoderLossless; format.encoderLossy = encoderLossy; format.decoder = decoder; } } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message); advanced = backup; } } int totalFormats = sr.LoadInt32("CustomFormats", 0, null) ?? 0; for (int nFormats = 0; nFormats < totalFormats; nFormats++) { string extension = sr.Load(string.Format("CustomFormat{0}Name", nFormats)); string encoderLossless = sr.Load(string.Format("CustomFormat{0}EncoderLossless", nFormats)) ?? ""; string encoderLossy = sr.Load(string.Format("CustomFormat{0}EncoderLossy", nFormats)) ?? ""; string decoder = sr.Load(string.Format("CustomFormat{0}Decoder", nFormats)); CUEToolsTagger tagger = (CUEToolsTagger)(sr.LoadInt32(string.Format("CustomFormat{0}Tagger", nFormats), 0, 2) ?? 0); bool allowLossless = sr.LoadBoolean(string.Format("CustomFormat{0}AllowLossless", nFormats)) ?? false; bool allowLossy = sr.LoadBoolean(string.Format("CustomFormat{0}AllowLossy", nFormats)) ?? false; bool allowEmbed = sr.LoadBoolean(string.Format("CustomFormat{0}AllowEmbed", nFormats)) ?? false; CUEToolsFormat format; AudioEncoderSettingsViewModel udcLossless, udcLossy; AudioDecoderSettingsViewModel udcDecoder; if (encoderLossless == "" || !Encoders.TryGetValue(extension, true, encoderLossless, out udcLossless)) { udcLossless = Encoders.GetDefault(extension, true); } if (encoderLossy == "" || !Encoders.TryGetValue(extension, false, encoderLossy, out udcLossy)) { udcLossy = Encoders.GetDefault(extension, false); } if (decoder == "" || !Decoders.TryGetValue(extension, decoder, out udcDecoder)) { udcDecoder = Decoders.GetDefault(extension); } if (!formats.TryGetValue(extension, out format)) { formats.Add(extension, new CUEToolsFormat(extension, tagger, allowLossless, allowLossy, allowEmbed, false, udcLossless, udcLossy, udcDecoder)); } else { format.encoderLossless = udcLossless; format.encoderLossy = udcLossy; format.decoder = udcDecoder; if (!format.builtin) { format.tagger = tagger; format.allowLossless = allowLossless; format.allowLossy = allowLossy; format.allowEmbed = allowEmbed; } } } defaultVerifyScript = sr.Load("DefaultVerifyScript") ?? "default"; defaultEncodeScript = sr.Load("DefaultVerifyAndConvertScript") ?? "default"; gapsHandling = (CUEStyle?)sr.LoadInt32("GapsHandling", null, null) ?? gapsHandling; language = sr.Load("Language") ?? Thread.CurrentThread.CurrentUICulture.Name; if (ArLogFilenameFormat.Contains("%F")) { ArLogFilenameFormat = "%filename%.accurip"; } if (singleFilenameFormat.Contains("%F")) { singleFilenameFormat = "%filename%"; } if (trackFilenameFormat.Contains("%N")) { trackFilenameFormat = "%tracknumber%. %title%"; } }
public static LogEventEvaluationRule LoadFromConfigFile(string fileName) { SettingsReader settingsReader = new SettingsReader(fileName); string type = settingsReader.GetConfigParam("Type"); string source = settingsReader.GetConfigParam("Source"); string counterCategory = settingsReader.GetConfigParam("Category"); string counterName = settingsReader.GetConfigParam("Counter"); string instance = settingsReader.GetConfigParam("Instance", false); string extendedData = settingsReader.GetConfigParam("ExtendedData", false); string value = settingsReader.GetConfigParam("Value"); string dateTime = settingsReader.GetConfigParam("DateTime"); string dateFormat = settingsReader.GetConfigParam("DateFormat"); string regex = settingsReader.GetConfigParam("Regex"); LogEventEvaluationRule result = new LogEventEvaluationRule(fileName, regex, type, source, counterCategory, counterName, instance, extendedData, value, dateTime, dateFormat); return result; }
private void Awake() { Dt = new PlayerData(); _st = SettingsReader.GetInstance(); }
public static IEnumerable<LogDescription> ProcessLogDescription(string fileName) { _logger.Info("Processing LogDescription " + fileName); SettingsReader settingsReader = new SettingsReader(fileName); string fileMask = settingsReader.GetConfigParam("FileMask"); string encoding = settingsReader.GetConfigParam("Encoding"); List<string> possibleLogDirectories = settingsReader.GetConfigParams("LogDirectory").SelectMany(FilePathHelpers.FindDirectoriesOnFixedDisks).ToList(); List<LogEventDescription> logEventDescriptions = GetLogEventDescrptions(Path.ChangeExtension(fileName, "EventDescripions")); _logger.Info("Total " + possibleLogDirectories.Count + " log directories: " + String.Join("\r\n", possibleLogDirectories.ToArray())); foreach (string logDirectory in possibleLogDirectories) { foreach (string path in FilePathHelpers.GetDirectoriesByMaskedPath(logDirectory)) { yield return new LogDescription(fileName, fileMask, encoding, logEventDescriptions, path); } } IEnumerable<string> possibleLogDirectories = settingsReader.GetConfigParams("LogDirectory").SelectMany(FilePathHelpers.FindDirectoriesOnFixedDisks); List<string> directories = possibleLogDirectories.SelectMany(FilePathHelpers.GetDirectoriesByMaskedPath).Distinct().ToList(); _logger.Info(String.Format("Total {0} log directories:\r\n{1}", directories.Count, String.Join("\r\n", directories.ToArray()))); string eventDescriptionsDir = Path.ChangeExtension(fileName, "EventDescriptions"); List<LogEventDescription> logEventDescriptions = GetLogEventEvaluationRules(eventDescriptionsDir); foreach (string logDirectory in directories) { foreach (string path in FilePathHelpers.GetDirectoriesByMaskedPath(logDirectory)) { yield return new LogDescription(fileName, fileMask, encoding, logEventDescriptions, path); } } }
public void ReadConfigurationFiles() { SettingsReader.ReadAndParse(); CustomCommandsReader.ReadAndParse(); }
private void ActivateProfile(string profileName) { if (profileName == _defaultProfile._name) return; _profile = new CUEToolsProfile(profileName); SettingsReader sr = new SettingsReader("CUE Tools", string.Format("profile-{0}.txt", _profile._name), Application.ExecutablePath); _profile.Load(sr); _profile._config.encoders = _defaultProfile._config.encoders; _profile._config.decoders = _defaultProfile._config.decoders; _profile._config.formats = _defaultProfile._config.formats; _profile._config.scripts = _defaultProfile._config.scripts; ActivateProfile(); }
public override void Execute() { var eventModel = CurrentActionProperties(TargetCollection, this.GetType().Name); OnTrigger(new PreingestEventArgs { Description = String.Format("Start polishing Opex for container '{0}'.", TargetCollection), Initiate = DateTimeOffset.Now, ActionType = PreingestActionStates.Started, PreingestAction = eventModel }); var anyMessages = new List <String>(); bool isSuccess = false; try { string sessionFolder = Path.Combine(ApplicationSettings.DataFolderName, SessionGuid.ToString()); BodySettings settings = new SettingsReader(this.ApplicationSettings.DataFolderName, SessionGuid).GetSettings(); if (settings == null) { throw new ApplicationException("Settings are not saved!"); } if (String.IsNullOrEmpty(settings.Polish)) { throw new ApplicationException("Polish setting is empty!"); } DirectoryInfo directoryInfoSessionFolder = new DirectoryInfo(sessionFolder); List <FileInfo> opexFiles = directoryInfoSessionFolder.GetFiles("*.opex", SearchOption.AllDirectories).ToList(); if (opexFiles.Count == 0) { throw new ApplicationException("Zero OPEX files found!"); } string xsltTranformationServiceUrl = String.Format("http://{0}:{1}/hooks/xslt-transformation", ApplicationSettings.TransformationServerName, ApplicationSettings.TransformationServerPort); string stylesheetFileLocation = Path.Combine(ApplicationSettings.PreWashFolder, settings.Polish); var jsonData = new List <string>(); int countTotal = opexFiles.Count; OnTrigger(new PreingestEventArgs { Description = String.Format("Transforming: {0} files", countTotal), Initiate = DateTimeOffset.Now, ActionType = PreingestActionStates.Executing, PreingestAction = eventModel }); if (!String.IsNullOrEmpty(settings.UseSaxon)) { bool useSaxon = settings.UseSaxon.Equals("Ja", StringComparison.InvariantCultureIgnoreCase); if (TransformationSetting.UseSaxon != useSaxon) { TransformationSetting.UseSaxon = useSaxon; } } opexFiles.ForEach(file => { string result = string.Empty; try { if (TransformationSetting.UseSaxon) { using (HttpClient client = new HttpClient()) { client.Timeout = Timeout.InfiniteTimeSpan; HttpResponseMessage response = client.GetAsync(String.Format("{0}?xsl={1}&xml={2}", xsltTranformationServiceUrl, stylesheetFileLocation, file.FullName)).Result; response.EnsureSuccessStatusCode(); result = response.Content.ReadAsStringAsync().Result; } } else { var opex = XDocument.Load(file.FullName).ToString(); var xsl = XDocument.Load(stylesheetFileLocation).ToString(); result = Transform(xsl, opex); } } catch (Exception e) { anyMessages.Add(String.Format("Transformation with Opex file '{0}' failed! {1} {2}", file.FullName, e.Message, e.StackTrace)); } finally { if (!String.IsNullOrEmpty(result)) { try { XDocument doc = XDocument.Parse(result); doc.Save(file.FullName); } catch (Exception ie) { anyMessages.Add(String.Format("Saving Opex file '{0}' failed! {1} {2}", file.FullName, ie.Message, ie.StackTrace)); } finally { jsonData.Add(String.Format("Transformation processed: {0}", file.FullName)); } } } }); //update opex var profiles = opexFiles.Select(item => new { Xml = XDocument.Load(item.FullName).ToString(), FullName = item.FullName }).Where(item => item.Xml.Contains("<Files>")).ToList(); countTotal = profiles.Count; OnTrigger(new PreingestEventArgs { Description = String.Format("Updating profile (Opex files): Total {0} files.", countTotal), Initiate = DateTimeOffset.Now, ActionType = PreingestActionStates.Executing, PreingestAction = eventModel }); profiles.ForEach(item => { FileInfo opex = new FileInfo(item.FullName); FileInfo[] currentContent = opex.Directory.GetFiles().Where(content => content.FullName != item.FullName).ToArray(); var currentOpexMetadataFile = Preingest.WebApi.Utilities.DeserializerHelper.DeSerializeObjectFromXmlFile <Noord.Hollands.Archief.Entities.Opex.opexMetadata>(item.Xml); //overwrite if (currentContent.Count() > 0) { currentOpexMetadataFile.Transfer.Manifest = new Noord.Hollands.Archief.Entities.Opex.manifest(); currentOpexMetadataFile.Transfer.Manifest.Files = currentContent.Select(item => new Noord.Hollands.Archief.Entities.Opex.file { size = item.Length, typeSpecified = true, type = item.Extension.Equals(".opex", StringComparison.InvariantCultureIgnoreCase) ? Noord.Hollands.Archief.Entities.Opex.fileType.metadata : Noord.Hollands.Archief.Entities.Opex.fileType.content, sizeSpecified = true, Value = item.Name }).ToArray(); string output = Preingest.WebApi.Utilities.SerializerHelper.SerializeObjectToString(currentOpexMetadataFile); var newDoc = XDocument.Parse(output); newDoc.Save(item.FullName); } }); OnTrigger(new PreingestEventArgs { Description = String.Format("Reading Opex files for XSD schema validation."), Initiate = DateTimeOffset.Now, ActionType = PreingestActionStates.Executing, PreingestAction = eventModel }); var newOpexFiles = directoryInfoSessionFolder.GetFiles("*.opex").ToList(); var schemaList = SchemaHandler.GetSchemaList(); var strXsd = schemaList["Noord.Hollands.Archief.Preingest.WebApi.Schema.OPEX-Metadata.xsd"]; var xsdTmpFilename = Path.GetTempFileName(); var xsd = XDocument.Parse(strXsd); xsd.Save(xsdTmpFilename); OnTrigger(new PreingestEventArgs { Description = String.Format("Validate Opex files with XSD schema."), Initiate = DateTimeOffset.Now, ActionType = PreingestActionStates.Executing, PreingestAction = eventModel }); newOpexFiles.ForEach(opex => { try { if (String.IsNullOrEmpty(opex.FullName) || !File.Exists(opex.FullName)) { throw new FileNotFoundException(String.Format("Opex file with location '{0}' is empty or not found!", opex.FullName)); } XDocument xml = XDocument.Load(opex.FullName); SchemaValidationHandler.Validate(xml.ToString(), xsdTmpFilename); } catch (Exception validate) { anyMessages.Add(String.Format("Schema validation error for Opex file '{0}'! {1} {2}", opex.FullName, validate.Message, validate.StackTrace)); } }); try { File.Delete(xsdTmpFilename); } catch { } eventModel.Properties.Messages = anyMessages.ToArray(); eventModel.ActionData = jsonData.ToArray(); eventModel.ActionResult.ResultValue = PreingestActionResults.Success; eventModel.Summary.Processed = opexFiles.Count; eventModel.Summary.Accepted = (opexFiles.Count - anyMessages.Count); eventModel.Summary.Rejected = anyMessages.Count; if (eventModel.Summary.Rejected > 0) { eventModel.ActionResult.ResultValue = PreingestActionResults.Error; } else { eventModel.ActionResult.ResultValue = PreingestActionResults.Success; } isSuccess = true; } catch (Exception e) { isSuccess = false; anyMessages.Clear(); anyMessages.Add(String.Format("Run polish with collection: '{0}' failed!", TargetCollection)); anyMessages.Add(e.Message); anyMessages.Add(e.StackTrace); Logger.LogError(e, "Run polish with collection: '{0}' failed!", TargetCollection); eventModel.ActionResult.ResultValue = PreingestActionResults.Failed; eventModel.Properties.Messages = anyMessages.ToArray(); eventModel.Summary.Processed = 1; eventModel.Summary.Accepted = 0; eventModel.Summary.Rejected = 1; OnTrigger(new PreingestEventArgs { Description = "An exception occured while running checksum!", Initiate = DateTimeOffset.Now, ActionType = PreingestActionStates.Failed, PreingestAction = eventModel }); } finally { if (isSuccess) { OnTrigger(new PreingestEventArgs { Description = "Polish run with a collection is done.", Initiate = DateTimeOffset.Now, ActionType = PreingestActionStates.Completed, PreingestAction = eventModel }); } } }
public string Execute(CommandOption fetchScope, CommandOption sortOrder, CommandOption period) { FetchScope scope = FetchScope.All; if (fetchScope.HasValue()) { switch (fetchScope.Value().ToUpperInvariant()) { case "MINE": scope = FetchScope.Mine; break; case "ALL": break; default: Console.WriteLine($"Fetch value {fetchScope.Value()} couldn't be parsed - fetching all"); scope = FetchScope.All; break; } } string[] cinemasToCheck = null; if (scope == FetchScope.Mine) { cinemasToCheck = new SettingsReader().GetCinemas(); } SortOrder sort = SortOrder.Date; if (sortOrder.HasValue()) { switch (sortOrder.Value().ToUpperInvariant()) { case "D": sort = SortOrder.Date; break; case "F": sort = SortOrder.Film; break; case "C": sort = SortOrder.Cinema; break; default: Console.WriteLine($"Sort value {sortOrder.Value()} couldn't be parsed - sorting by Date"); sort = SortOrder.Date; break; } } Period periodToFetch = Period.All; if (period.HasValue()) { switch (period.Value().ToUpperInvariant()) { case "T": periodToFetch = Period.Today; break; case "M": periodToFetch = Period.Tomorrow; break; default: Console.WriteLine($"Period value {period.Value()} couldn't be parsed - fetching all"); periodToFetch = Period.All; break; } } var checker = new SiteChecker(); var result = checker.GetShowings(cinemasToCheck); result = result.SortThisBy(sort); result = result.JustThisPeriod(periodToFetch); var formatter = new ResultsFormatter(); var toPrint = formatter.GetResultsTable(result); return(toPrint.ToString()); //Console.WriteLine(toPrint); //Console.ReadLine(); //return 0; }
private void Start() { _settingsReader = SettingsReader.GetInstance(); }