Esempio n. 1
0
        /// <summary>
        /// Uses the specified application configuration section to set the current type resolver object.
        /// </summary>
        /// <param name="configurationSectionName"></param>
        public static void Configure(string configurationSectionName = null)
        {
            configurationSectionName = configurationSectionName ?? DEFAULT_SECTION_NAME;
            var settings = AppConfigurationManager.GetSettings <TypeResolverConfigurationSettings>(configurationSectionName);

            Configure(settings);
        }
Esempio n. 2
0
 /// <summary>
 /// Resets the resource connection provider to its original state
 /// </summary>
 public static void Reset()
 {
     if (AppConfigurationManager.IsSectionDefined(DEFAULT_SECTION_NAME))
     {
         Configure(DEFAULT_SECTION_NAME);
     }
 }
Esempio n. 3
0
        private async void DoLogin()
        {
            Context.ProgressRingVisibility = Visibility.Visible;
            await Task.Delay(2000);

            LoginErrorMessage = "";
            if (string.IsNullOrEmpty(Username) || string.IsNullOrEmpty(Password))
            {
                LoginErrorMessage = "Please input username and password to log in";
                Context.ProgressRingVisibility = Visibility.Collapsed;
                return;
            }
            var user = UserAccountManager.GetInstance().DoLogIn(Username.ToLower(), Password);

            if (user == null)
            {
                LoginErrorMessage = "Incorrect User Name or Password. Please try again.";
                Context.ProgressRingVisibility = Visibility.Collapsed;
                return;
            }
            var appConfig = AppConfigurationManager.GetInstance().GetAppConfiguration();

            if (appConfig == null)
            {
                appConfig = new AppConfiguration();
            }
            appConfig.UserAccountId = user.Id;
            AppConfigurationManager.GetInstance().SaveAppConfiguration(appConfig);
            user.ModifiedDate = DateTime.Now;
            UserAccountManager.GetInstance().UpdateUserAccount(user);
            Context.HideLoginDialog();
            Context.RefreshPageHeader();
            Context.ProgressRingVisibility = Visibility.Collapsed;
            ApplicationViewModel.Default.NavigateToMyWorkPage();
        }
Esempio n. 4
0
        /// <summary>
        /// Uses the specified application configuration section to set the current
        /// resource connection provider registry object.
        /// </summary>
        /// <param name="configurationSectionName"></param>
        public static void Configure(string configurationSectionName = null)
        {
            configurationSectionName = configurationSectionName ?? DEFAULT_SECTION_NAME;
            var settings = AppConfigurationManager.GetSettings <ResourceConnectionFactorySettings>(configurationSectionName);

            Configure(settings);
        }
Esempio n. 5
0
        public void TestSerializeConfiguration()
        {
            var config = new ConfigurationContainer();

            config.Global = new List <ConfigurationEntry>
            {
                new ConfigurationEntry {
                    Key = "maximum_orderposition_amount", Value = "50000"
                },
                new ConfigurationEntry {
                    Key = "another_configuration_entry", Value = "anothervalue"
                },
                new ConfigurationEntry {
                    Key = "settings_flyout_developer_available", Value = "false"
                }
            };
            config.Roles = new List <RoleConfigurationContainer>
            {
                new RoleConfigurationContainer {
                    Role = "developer", Entries = new List <ConfigurationEntry>
                    {
                        new ConfigurationEntry {
                            Key = "settings_flyout_developer_available", Value = "true"
                        }
                    }
                }
            };
            var configManager = new AppConfigurationManager();
            var result        = configManager.SerializeConfiguration(config);

            Trace.WriteLine("Trace: " + result);
            Assert.IsNotNull(result);
        }
Esempio n. 6
0
        public MediaPM SaveMedia(Stream inputStream, int contentLength, string fileName, string contentType, int userId)
        {
            var    extention          = Path.GetExtension(fileName).ToLower();
            var    mediaType          = GetFileMediaType(extention);
            var    userMediaDirectory = AppConfigurationManager.GetUserMediaDirectory();
            var    newFileName        = Guid.NewGuid().ToString();
            var    newFileNameWithExt = $"{newFileName}{extention}";
            var    filePath           = $"{userMediaDirectory}\\{newFileName}{extention}";
            string thumbnailPath      = null;

            try {
                using (FileStream fileStream = new FileStream(filePath, FileMode.CreateNew)) {
                    inputStream.CopyTo(fileStream);
                }

                if (mediaType == MediaType.Image)
                {
                    thumbnailPath = $"{userMediaDirectory}\\{newFileName}-thumb{extention}";
                    var task = CreateThumbnailImageAsync(inputStream, thumbnailPath);
                }

                var media = MediaBiz.AddMedia(newFileNameWithExt, contentLength, mediaType, userId);
                UnitOfWork.SaveChanges();
                return(media.GetPresentationModel());
            }
            catch {
                File.Delete(filePath);
                if (thumbnailPath != null)
                {
                    File.Delete(thumbnailPath);
                }
                throw;
            }
        }
Esempio n. 7
0
        public void WithInstancePrefixWorksAsExpected()
        {
            // --- Arrange
            var configSettings = new AppConfigurationSettings(
                typeof(AppConfigProvider), null, null, "TestInstancePrefix", "TestInstanceName");

            AppConfigurationManager.Configure(configSettings);
            WindowsEventLogger.LogSourceMapper = new DefaultLogSourceNameMapper();
            var eventLog = new EventLog(SEEMPLEST_LOG2);

            // --- Act
            WindowsEventLogger.Log <WithStringNameAttribute>("Message");

            // --- Assert
            var after      = eventLog.Entries;
            var afterCount = after.Count;

            afterCount.ShouldEqual(1);
            var lastentry = after[after.Count - 1];

            lastentry.Category.ShouldEqual("(5)");
            lastentry.InstanceId.ShouldEqual(3);
            lastentry.Message.ShouldEqual("Message");
            lastentry.Source.ShouldEqual("TestInstancePrefix" + SEEMPLEST_SOURCE);
            lastentry.EntryType.ShouldEqual(EventLogEntryType.Information);
            eventLog.Dispose();
        }
Esempio n. 8
0
        public void GetSettingValueWorks()
        {
            // --- Act
            var value = AppConfigurationManager.GetSettingValue <string>("setting1");

            // --- Assert
            value.ShouldEqual("value1");
        }
Esempio n. 9
0
        public void CreateThumbnails()
        {
            ZigmaWebContext c   = new ZigmaWebContext();
            var             dir = AppConfigurationManager.GetUserMediaDirectory();

            c.Medias.ToList().ForEach(m => {
                var path = $"z:\\public_html\\usermedia\\{m.FileName}";
            });
        }
Esempio n. 10
0
 public void Intialize()
 {
     _configurationChangedVisited = false;
     _before = null;
     _after  = null;
     AppConfigurationManager.Reset();
     AppConfigurationManager.ConfigurationProviderChanged += AppConfigurationManagerOnConfigurationProviderChanged;
     SetDefaultSectionName("AppConfiguration");
 }
Esempio n. 11
0
        public void IsSeectionDefinedWorksAsExpected()
        {
            // --- Act
            var test1 = AppConfigurationManager.IsSectionDefined("TypeResolver");
            var test2 = AppConfigurationManager.IsSectionDefined("nonExisting");

            // --- Assert
            test1.ShouldBeTrue();
            test2.ShouldBeFalse();
        }
Esempio n. 12
0
        public void IsSettingValueDefinedWorksAsExpected()
        {
            // --- Act
            var test1 = AppConfigurationManager.IsSettingValueDefined("setting1");
            var test2 = AppConfigurationManager.IsSettingValueDefined("nonExisting");

            // --- Assert
            test1.ShouldBeTrue();
            test2.ShouldBeFalse();
        }
Esempio n. 13
0
        public void GetSettingValueWorksWithDefaultProvider()
        {
            // --- Act
            var value1 = AppConfigurationManager.GetSettingValue("setting1");
            var value2 = AppConfigurationManager.GetSettingValue("setting2");

            // --- Assert
            value1.ShouldEqual("value1");
            value2.ShouldBeNull();
        }
        public void ReadAndWriteWorksWithConfigFileAsExpected()
        {
            // --- Arrange
            const string PROVIDER_KEY = "queue";

            // --- Act
            var config = AppConfigurationManager.GetSettings <BackgroundTaskHostSettings>("BackgroundTaskHost1");

            // --- Assert
            config.DefaultContext.ShouldNotBeNull();
            config.DefaultContext.ProviderKey.ShouldEqual(PROVIDER_KEY);
            config.DefaultContext.Properties.ShouldHaveCountOf(3);
            config.DefaultContext.Properties["prop1"].Type.ShouldEqual(typeof(int));
            config.DefaultContext.Properties["prop1"].Value.ShouldEqual("23");
            config.DefaultContext.Properties["prop2"].Type.ShouldEqual(typeof(int));
            config.DefaultContext.Properties["prop2"].Value.ShouldEqual("24");
            config.DefaultContext.Properties["prop3"].Type.ShouldEqual(typeof(string));
            config.DefaultContext.Properties["prop3"].Value.ShouldEqual("23");

            var taskProcessors = config.GetTaskProcessors();

            taskProcessors.ShouldHaveCountOf(3);
            taskProcessors[0].Name.ShouldEqual("Proc1");
            taskProcessors[0].ProcessorType.ShouldEqual(TaskProcessorSettings.SCHEDULED_TYPE);
            taskProcessors[0].TaskType.ShouldEqual(typeof(TaskBase));
            taskProcessors[0].InstanceCount.ShouldEqual(3);
            taskProcessors[0].Context.ShouldNotBeNull();
            taskProcessors[0].Context.Properties.ShouldHaveCountOf(3);
            taskProcessors[0].Context.Properties["prop1"].Type.ShouldEqual(typeof(int));
            taskProcessors[0].Context.Properties["prop1"].Value.ShouldEqual("99");
            taskProcessors[0].Context.Properties["prop2"].Type.ShouldEqual(typeof(int));
            taskProcessors[0].Context.Properties["prop2"].Value.ShouldEqual("100");
            taskProcessors[0].Context.Properties["prop3"].Type.ShouldEqual(typeof(string));
            taskProcessors[0].Context.Properties["prop3"].Value.ShouldEqual("101");
            taskProcessors[0].Properties.ShouldHaveCountOf(2);
            taskProcessors[0].Properties["prop1"].Value.ShouldEqual("1000");
            taskProcessors[0].Properties["prop2"].Value.ShouldEqual("1001");

            taskProcessors[1].Name.ShouldEqual("Proc2");
            taskProcessors[1].ProcessorType.ShouldEqual(TaskProcessorSettings.QUEUED_TYPE);
            taskProcessors[1].TaskType.ShouldEqual(typeof(TaskBase));
            taskProcessors[1].InstanceCount.ShouldEqual(2);
            taskProcessors[1].Context.ShouldBeNull();
            taskProcessors[1].Properties.ShouldHaveCountOf(2);
            taskProcessors[1].Properties["prop1"].Value.ShouldEqual("1000");
            taskProcessors[1].Properties["prop2"].Value.ShouldEqual("1001");

            taskProcessors[2].Name.ShouldEqual("Proc3");
            taskProcessors[2].ProcessorType.ShouldEqual(TaskProcessorSettings.DOUBLE_QUEUED);
            taskProcessors[2].TaskType.ShouldEqual(typeof(TaskBase));
            taskProcessors[2].InstanceCount.ShouldEqual(1);
            taskProcessors[2].Context.ShouldBeNull();
            taskProcessors[2].Properties.ShouldHaveCountOf(0);
        }
Esempio n. 15
0
        /// <summary>
        /// Configures the configurable part of the service manager from the
        /// specified section
        /// </summary>
        /// <param name="sectionName">Name of the configuration section</param>
        public static void ConfigureFrom(string sectionName)
        {
            var registry = new DefaultServiceRegistry();

            if (AppConfigurationManager.IsSectionDefined(sectionName))
            {
                registry.GetConfigurableContainer().ConfigureFrom(AppConfigurationManager
                                                                  .GetSettings <ServiceContainerSettings>(sectionName));
            }
            ServiceRegistry = registry;
        }
Esempio n. 16
0
        public void RefreshPage()
        {
            var appConfig = AppConfigurationManager.GetInstance().GetAppConfiguration();

            if (appConfig != null && ActiveSpints != null && ActiveSpints.Count > 0)
            {
                LoadFutureBacklog(appConfig.UserAccountId, ActiveSpints[CurrentSprintIndex].SprintNum);
                LoadInprogressBacklog(appConfig.UserAccountId, ActiveSpints[CurrentSprintIndex].SprintNum);
                LoadDoneBacklog(appConfig.UserAccountId, ActiveSpints[CurrentSprintIndex].SprintNum);
                LoadAcceptBacklog(appConfig.UserAccountId, ActiveSpints[CurrentSprintIndex].SprintNum);
            }
        }
        public void TestInit()
        {
            AppConfigurationManager.Reset();
            TypeResolver.Reset();
            ResourceConnectionProviderRegistry.Reset();
            ResourceConnectionFactory.Reset();
            var settings = new TaskExecutionContextSettings("queue");

            s_Context = new DefaultTaskExecutionContext(settings);

            s_PeekPolicy = new TestPeekPolicy(TimeSpan.FromMilliseconds(10));
        }
Esempio n. 18
0
        private void GotoMyWorkPage()
        {
            var config = AppConfigurationManager.GetInstance().GetAppConfiguration();

            if (config != null)
            {
                ApplicationViewModel.Default.NavigateToMyWorkPage();
            }
            else
            {
                ShowLoginDialog();
            }
        }
Esempio n. 19
0
        public void RefreshPageHeader()
        {
            var config = AppConfigurationManager.GetInstance().GetAppConfiguration();

            if (config != null)
            {
                var currentUser = UserAccountManager.GetInstance().GetUserAccountById(config.UserAccountId);
                if (currentUser != null)
                {
                    EditButtonVisibility = currentUser.IsAdmin ? Visibility.Visible : Visibility.Collapsed;
                }
            }
        }
Esempio n. 20
0
        private async void SaveBacklogItem()
        {
            Context.ProgressRingVisibility = Visibility.Visible;
            await Task.Delay(2000);

            if (string.IsNullOrEmpty(CurrentBacklog.BacklogTitle))
            {
                AddNewBacklogErrorMessage      = "Please input title for new Backlog.";
                Context.ProgressRingVisibility = Visibility.Collapsed;
                return;
            }
            if (CurrentBacklog.EstimateHour <= 0 && CurrentBacklog.Id == 0)
            {
                AddNewBacklogErrorMessage      = "Please input Positive number for estimate hours.";
                Context.ProgressRingVisibility = Visibility.Collapsed;
                return;
            }
            if (ActiveSpints == null || ActiveSpints.Count == 0)
            {
                AddNewBacklogErrorMessage      = "There are no active sprint to add.";
                Context.ProgressRingVisibility = Visibility.Collapsed;
                return;
            }
            var appConfig = AppConfigurationManager.GetInstance().GetAppConfiguration();

            if (appConfig == null)
            {
                AddNewBacklogErrorMessage      = "There is an error when create new backlog. Please try it again later.";
                Context.ProgressRingVisibility = Visibility.Collapsed;
                return;
            }
            var user = UserAccountManager.GetInstance().GetUserAccountById(appConfig.UserAccountId);

            if (user == null)
            {
                AddNewBacklogErrorMessage      = "There is an error when create new backlog. Please try it again later.";
                Context.ProgressRingVisibility = Visibility.Collapsed;
                return;
            }
            CurrentBacklog.UserId   = appConfig.UserAccountId;
            CurrentBacklog.UserName = user.UserName;
            CurrentBacklog.Sprint   = ActiveSpints[SprintIndex].SprintNum;
            BacklogManager.GetInstance().SaveBacklog(CurrentBacklog);
            Context.ProgressRingVisibility = Visibility.Collapsed;
            //AddNewBacklogErrorMessage = "";
            //CurrentBacklog = new Backlog();
            //SprintIndex = 0;
            //Context.CloseAddNewBacklogDialog();
            CancelAction();
            Context.RefreshPage();
        }
        static void Main(string[] args)
        {
            //get the configuraiton manager of Application.Configuration
            AppConfigurationManager cm1 = (AppConfigurationManager)ConfigurationSettings.GetConfig("MyApplication");
            //retrieve the configuraiton data by calling the properties and methods of configuration manager.
            string connection = cm1.DatabaseConfig.GetDatabaseConnection();
            //these two calls involve the agents which retrieve the configuraiton data via web service
            //at http://localhost/ConfigurationData/ConfigurationService.asmx
            string customerQueueLocation = cm1.MessageQueueConfig.GetCustomerQueueLocation();
            string accountQueueLocation  = cm1.MessageQueueConfig.GetAccountQueueLocation();

            //get the configuration manager of SAF.Configuration
            ConfigurationManager cm2 = (ConfigurationManager)ConfigurationSettings.GetConfig("Framework");
            string eventServerUrl    = cm2.EventNotificationConfig.GetEventServerUrl();
        }
Esempio n. 22
0
        public void TestParseConfiguration()
        {
            var configManager = new AppConfigurationManager();
            var stream        = this.GetType()
                                .Assembly.GetManifestResourceStream("Microsoft.PortableApps.AppConfiguration.Tests.config.json");
            var reader            = new StreamReader(stream);
            var testConfiguration = reader.ReadToEnd();

            Trace.WriteLine(testConfiguration);
            var result = configManager.ParseConfiguration(testConfiguration, roles: new [] { "developer" });

            Assert.IsTrue(result.Entries != null);
            Assert.IsTrue(result.Entries.Count == 3);
            Trace.WriteLine(JsonConvert.SerializeObject(result, Formatting.Indented));
        }
Esempio n. 23
0
        public void ConfigurationWorksWithNullSectionName()
        {
            // --- Act
            var before = AppConfigurationManager.CurrentProvider;

            AppConfigurationManager.Configure();
            var after = AppConfigurationManager.CurrentProvider;

            // --- Assert
            _configurationChangedVisited.ShouldBeTrue();
            before.ShouldBeOfType(typeof(AppConfigProvider));
            after.ShouldBeOfType(typeof(AppConfigProvider));
            before.ShouldEqual(_before);
            after.ShouldEqual(_after);
        }
Esempio n. 24
0
        public void TestInit()
        {
            if (EventLog.Exists(SEEMPLEST_LOG))
            {
                EventLog.Delete(SEEMPLEST_LOG);
            }
            if (EventLog.Exists(SEEMPLEST_LOG2))
            {
                EventLog.Delete(SEEMPLEST_LOG2);
            }
            var configSettings = new AppConfigurationSettings(typeof(AppConfigProvider));

            AppConfigurationManager.Configure(configSettings);
            WindowsEventLogger.LogSourceMapper = new DefaultLogSourceNameMapper();
            WindowsEventLogger.Reset();
        }
        private DefaultConfigurationProvider()
        {
            var resolver = MockRepository.GenerateMock <IConfigurationAssemblyResolver>();

            resolver.Stub(r => r.GetTypesWithConfiguration()).Return(new List <Type>
            {
                typeof(TransportConfig),
                typeof(Config)
            });

            _manager = new AppConfigurationManager(resolver);
            _manager.Configure();

            //_manager.GetCustomConfig<TransportConfig>();
            _manager.GetCustomConfig <Config>().Idn     = "LAMBDA,GENH30-25";
            _manager.GetCustomConfig <Config>().Voltage = 27.0f;
            _manager.GetCustomConfig <Config>().Current = 6.0f;
        }
Esempio n. 26
0
        public void GetSettingValueWorksWithCustomProvider()
        {
            // --- Arrange
            var newSettings = new AppConfigurationSettings(
                typeof(TestConfigProvider), null, null, "instance1", "name");

            AppConfigurationManager.Configure(newSettings);

            // --- Act
            var value1 = AppConfigurationManager.GetSettingValue("key1");
            var value2 = AppConfigurationManager.GetSettingValue("key2");
            var value3 = AppConfigurationManager.GetSettingValue("key3");

            // --- Assert
            value1.ShouldEqual("value1");
            value2.ShouldEqual("value2");
            value3.ShouldBeNull();
        }
Esempio n. 27
0
        public void ConfigurationWorksWithSettings()
        {
            // --- Arrange
            var settings = new AppConfigurationSettings(typeof(TestConfigProvider),
                                                        new ConstructorParameterSettingsCollection(),
                                                        new PropertySettingsCollection(),
                                                        "Prefix", "Name");

            // --- Act
            var before = AppConfigurationManager.CurrentProvider;

            AppConfigurationManager.Configure(settings);
            var after = AppConfigurationManager.CurrentProvider;

            // --- Assert
            _configurationChangedVisited.ShouldBeTrue();
            before.ShouldBeOfType(typeof(AppConfigProvider));
            after.ShouldBeOfType(typeof(TestConfigProvider));
            before.ShouldEqual(_before);
            after.ShouldEqual(_after);
        }
        public static void Main(string[] args)
        {
            Console.WriteLine("RedSpiderTech Securities Research");
            Console.WriteLine("Supported arguments:\nhistoric <symbol>\nupdate-existing\nfile-based <filePath>");

            _appConfigurationManager = new AppConfigurationManager();

            string logFile = _appConfigurationManager.GetLogFile();

            Log.Logger = new LoggerConfiguration()
                         .WriteTo.Console(LogEventLevel.Verbose)
                         .WriteTo.File(logFile, rollingInterval: RollingInterval.Day, restrictedToMinimumLevel: LogEventLevel.Verbose)
                         .CreateLogger();

            _logger = Log.Logger;

            args = GetTestArguments();
            var       argumentParser = new ArgumentParser(args);
            IDataArgs dataArgs       = argumentParser.GetArgumentData();

            _logger.Information("RedSpiderTech Securities Research");
            _logger.Information("======================================");
            _logger.Information("Starting Security Data Research - Data Grab");
            _logger.Information("");

            InitialiseContainer();

            var           dataGrabTaskFactory = _container.Resolve <IDataGrabTaskFactory>();
            IDataGrabTask dataGrabTask        = dataGrabTaskFactory.GetDataGrabTask(_container, dataArgs);

            dataGrabTask.Execute();

            _logger.Information("");
            _logger.Information("Data Grab complete");
            _logger.Information("======================================");
        }
Esempio n. 29
0
        public void DefaultLogSourceMapperWorksAsExpected()
        {
            // --- Arrange
            var configSettings = new AppConfigurationSettings(
                typeof(AppConfigProvider), null, null, "TestInstancePrefix", "TestInstanceName");

            AppConfigurationManager.Configure(configSettings);
            var mapper1 = new DefaultLogSourceNameMapper();

            configSettings = new AppConfigurationSettings(typeof(AppConfigProvider));
            AppConfigurationManager.Configure(configSettings);
            var mapper2 = new DefaultLogSourceNameMapper();
            var mapper3 = new DefaultLogSourceNameMapper("Dummy");

            // --- Act
            var name1 = mapper1.Map("Hi");
            var name2 = mapper2.Map("Hello");
            var name3 = mapper3.Map("Howdy");

            // --- Assert
            name1.ShouldEqual("TestInstancePrefixHi");
            name2.ShouldEqual("Hello");
            name3.ShouldEqual("DummyHowdy");
        }
Esempio n. 30
0
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            AppConfigurationManager appDb = new AppConfigurationManager();

            optionsBuilder.UseMySql(string.Format(@"Server={0};Port={1};Database={2};Uid={3};Pwd={4};", appDb.HostDb(), appDb.PortaDb(), appDb.DatabaseDb(), appDb.UserDb(), appDb.SenhaDb()));
        }