/// <summary> /// Load the configuration /// </summary> public void Load() { // Configuration exists? if (this.IsConfigured) using (var fs = File.OpenRead(this.m_configPath)) { this.m_configuration = OpenIZConfiguration.Load(fs); } }
/// <summary> /// Loads the user configuration for the specified user key /// </summary> public override OpenIZConfiguration GetUserConfiguration(string userId) { try { var userPrefDir = this.Configuration.GetSection <ApplicationConfigurationSection>().UserPrefDir; if (!Directory.Exists(userPrefDir)) { Directory.CreateDirectory(userPrefDir); } // Now we want to load String configFile = Path.ChangeExtension(Path.Combine(userPrefDir, userId), "userpref"); if (!File.Exists(configFile)) { return new OpenIZConfiguration() { Sections = new System.Collections.Generic.List <object>() { new AppletConfigurationSection(), new ApplicationConfigurationSection() } } } ; else { using (var fs = File.OpenRead(configFile)) return(OpenIZConfiguration.Load(fs)); } } catch (Exception ex) { this.m_tracer.TraceError("Error getting user configuration data {0}: {1}", userId, ex); throw; } }
/// <summary> /// Restore the configuration /// </summary> public void Restore() { using (var lzs = new LZipStream(File.OpenRead(Path.ChangeExtension(this.m_configPath, "bak.7z")), SharpCompress.Compressors.CompressionMode.Decompress)) this.m_configuration = OpenIZConfiguration.Load(lzs); this.Save(); }
/// <summary> /// Load the configuration file /// </summary> public void Load() { if (!String.IsNullOrEmpty(this.m_configPath)) { using (var fs = File.OpenRead(this.m_configPath)) { this.m_configuration = OpenIZConfiguration.Load(fs); } } else { this.m_configuration = new OpenIZConfiguration(); // Inital data source DataConfigurationSection dataSection = new DataConfigurationSection() { MainDataSourceConnectionStringName = "openIzData", MessageQueueConnectionStringName = "openIzData", ConnectionString = new System.Collections.Generic.List <ConnectionString>() { new ConnectionString() { Name = "openIzData", Value = String.IsNullOrEmpty(this.m_dataPath) ? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Minims", "OpenIZ.sqlite") : this.m_dataPath } } }; // Initial Applet configuration AppletConfigurationSection appletSection = new AppletConfigurationSection() { Security = new AppletSecurityConfiguration() { AllowUnsignedApplets = true, TrustedPublishers = new List <string>() { "84BD51F0584A1F708D604CF0B8074A68D3BEB973" } } }; // Initial applet style ApplicationConfigurationSection appSection = new ApplicationConfigurationSection() { Style = StyleSchemeType.Dark, UserPrefDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "OizDebug", "userpref"), ServiceTypes = new List <string>() { typeof(LocalPolicyDecisionService).AssemblyQualifiedName, typeof(LocalPolicyInformationService).AssemblyQualifiedName, typeof(LocalPatientService).AssemblyQualifiedName, typeof(LocalPlaceService).AssemblyQualifiedName, //typeof(LocalAlertService).AssemblyQualifiedName, typeof(LocalConceptService).AssemblyQualifiedName, typeof(LocalEntityRepositoryService).AssemblyQualifiedName, typeof(LocalOrganizationService).AssemblyQualifiedName, typeof(LocalRoleProviderService).AssemblyQualifiedName, typeof(LocalSecurityService).AssemblyQualifiedName, typeof(LocalMaterialService).AssemblyQualifiedName, typeof(LocalBatchService).AssemblyQualifiedName, typeof(LocalActService).AssemblyQualifiedName, typeof(LocalProviderService).AssemblyQualifiedName, typeof(LocalTagPersistenceService).AssemblyQualifiedName, typeof(NetworkInformationService).AssemblyQualifiedName, typeof(BusinessRulesDaemonService).AssemblyQualifiedName, typeof(LocalEntitySource).AssemblyQualifiedName, typeof(MemoryCacheService).AssemblyQualifiedName, typeof(OpenIZThreadPool).AssemblyQualifiedName, typeof(MemorySessionManagerService).AssemblyQualifiedName, typeof(AmiUpdateManager).AssemblyQualifiedName, typeof(AppletClinicalProtocolRepository).AssemblyQualifiedName, typeof(MemoryQueryPersistenceService).AssemblyQualifiedName, typeof(SimpleQueueFileProvider).AssemblyQualifiedName, typeof(SimpleCarePlanService).AssemblyQualifiedName, typeof(SimplePatchService).AssemblyQualifiedName, typeof(DebugAppletManagerService).AssemblyQualifiedName, typeof(SQLiteConnectionManager).AssemblyQualifiedName, typeof(LocalPersistenceService).AssemblyQualifiedName }, Cache = new CacheConfiguration() { MaxAge = new TimeSpan(0, 5, 0).Ticks, MaxSize = 1000, MaxDirtyAge = new TimeSpan(0, 20, 0).Ticks, MaxPressureAge = new TimeSpan(0, 2, 0).Ticks } }; appSection.ServiceTypes.Add(typeof(SQLite.Net.Platform.Generic.SQLitePlatformGeneric).AssemblyQualifiedName); // Security configuration SecurityConfigurationSection secSection = new SecurityConfigurationSection() { DeviceName = Environment.MachineName, AuditRetention = new TimeSpan(30, 0, 0, 0, 0) }; // Device key //var certificate = X509CertificateUtils.FindCertificate(X509FindType.FindBySubjectName, StoreLocation.LocalMachine, StoreName.My, String.Format("DN={0}.mobile.openiz.org", macAddress)); //secSection.DeviceSecret = certificate?.Thumbprint; // Rest Client Configuration ServiceClientConfigurationSection serviceSection = new ServiceClientConfigurationSection() { RestClientType = typeof(RestClient) }; // Trace writer DiagnosticsConfigurationSection diagSection = new DiagnosticsConfigurationSection() { TraceWriter = new System.Collections.Generic.List <TraceWriterConfiguration>() { new TraceWriterConfiguration() { Filter = System.Diagnostics.Tracing.EventLevel.Error, InitializationData = "OpenIZ", TraceWriter = new ConsoleTraceWriter(System.Diagnostics.Tracing.EventLevel.Warning, "OpenIZ") }, new TraceWriterConfiguration() { Filter = System.Diagnostics.Tracing.EventLevel.LogAlways, InitializationData = "OpenIZ", TraceWriter = new FileTraceWriter(System.Diagnostics.Tracing.EventLevel.Warning, "OpenIZ") } } }; this.m_configuration.Sections.Add(appletSection); this.m_configuration.Sections.Add(dataSection); this.m_configuration.Sections.Add(diagSection); this.m_configuration.Sections.Add(appSection); this.m_configuration.Sections.Add(secSection); this.m_configuration.Sections.Add(serviceSection); this.m_configuration.Sections.Add(new SynchronizationConfigurationSection() { PollInterval = new TimeSpan(0, 5, 0) }); } }