Exemplo n.º 1
0
        //==================================

        /// <summary>
        /// Load and translate the services from app.config
        /// </summary>
        private void LoadServicesFromConfigurationFile()
        {
            //base configuration
            foreach (ServiceElement serviceElement in EdgeServicesConfiguration.Current.Services)
            {
                ServiceConfiguration serviceConfiguration = ServiceConfiguration.FromLegacyConfiguration(serviceElement);
                serviceConfiguration.Lock();
                _serviceBaseConfigurations.Add(serviceConfiguration.Name, serviceConfiguration);
            }

            foreach (AccountElement account in EdgeServicesConfiguration.Current.Accounts)
            {
                // Create matching profile
                Profile profile = new Profile()
                {
                    Name     = account.ID.ToString(),
                    ID       = account.ID,
                    Settings = new Dictionary <string, object>()
                    {
                        { "AccountID", account.ID },
                        { "AccountName", account.Name },
                    },
                    ServiceConfigurations = new List <ServiceConfiguration>()
                };
                _profiles.Add(profile);

                foreach (AccountServiceElement accountService in account.Services)
                {
                    ServiceConfiguration serviceConfiguration = ServiceConfiguration.FromLegacyConfiguration(
                        accountService,
                        _serviceBaseConfigurations[accountService.Uses.Element.Name],
                        profile
                        );
                    serviceConfiguration.Lock();

                    profile.ServiceConfigurations.Add(serviceConfiguration);
                    _serviceConfigurationsToSchedule.Add(serviceConfiguration);

                    // TODO: load relevant history for this service
                    foreach (SchedulingRule rule in serviceConfiguration.SchedulingRules)
                    {
                        // TODO: select the saved scheduling requests from the DB according to the scope of the fule
                        //throw new NotImplementedException();
                    }
                }
            }
        }