public async Task SetValueAsync(GlobalConfigItems key, string data)
        {
            Configuration[key.ToString()] = data;

            using var scope      = ServiceProvider.CreateScope();
            using var repository = scope.ServiceProvider.GetService <IGrillBotRepository>();

            var item = await repository.GlobalConfigRepository.GetItemAsync(key);

            if (item == null)
            {
                item = new GlobalConfigItem()
                {
                    Key   = key.ToString(),
                    Value = data
                };

                await repository.AddAsync(item);
            }
            else
            {
                item.Value = data;
            }

            await repository.CommitAsync();
        }
        public bool TestNode(GlobalConfigItem parameters)
        {
            var directory = parameters.Value;

            try
            {
                DirectoryInfo dirInfo  = new DirectoryInfo(directory);
                bool          response = dirInfo.Exists;
                if (dirInfo.Exists)
                {
                    // Attempt to get a list of security permissions from the folder.
                    // This will raise an exception if the path is read only or do not have access to view the permissions.
                    System.Security.AccessControl.DirectorySecurity ds = Directory.GetAccessControl(directory);
                }
                return(response);
            }
            catch (UnauthorizedAccessException e)
            {
                return(false);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
        public bool TestFileStoreConnection(FileStore fStore)
        {
            GlobalConfigItem item = new GlobalConfigItem();

            item.Value = fStore.FolderPath;
            return(_deployBusLogic.TestFileStoreConnection(item));
        }
        public void SaveFileStoreConfiguration(FileStore fileStore)
        {
            var info = _deployBusLogic.GetFileStoreConfiguration();

            if (info != null)
            {
                info.Value = fileStore.FolderPath;
            }
            else
            {
                info = new GlobalConfigItem()
                {
                    Value = fileStore.FolderPath
                };
            }

            _deployBusLogic.SaveFileStoreConfiguration(info);
        }
        private void SaveGlobalConfigItem(GlobalConfigItem info, string configItemName)
        {
            using (var session = DocumentStoreLocator.Resolve(DocumentStoreLocator.RootLocation))
            {
                var item = session.Load <GlobalConfigItem>(configItemName);
                if (item != null)
                {
                    item.Value = info.Value;
                }
                else
                {
                    item = new GlobalConfigItem
                    {
                        Value = info.Value,
                        Name  = configItemName
                    };
                    session.Store(item);
                }

                session.SaveChanges();
            }
        }
        public void SaveGlobalConfigItem(GlobalConfigItem info)
        {
            using (var session = DocumentStoreLocator.Resolve(DocumentStoreLocator.RootLocation))
            {
                var item = session.Load <GlobalConfigItem>(GlobalConfigItemEnum.DistributedFileShare.ToString());
                if (item != null)
                {
                    item.Value = info.Value;
                }
                else
                {
                    item = new GlobalConfigItem
                    {
                        Value = info.Value,
                        Name  = GlobalConfigItemEnum.DistributedFileShare.ToString()
                    };
                    session.Store(item);
                }

                session.SaveChanges();
            }
        }
Beispiel #7
0
        public async Task UpdateItemAsync(GlobalConfigItems item, string value)
        {
            var key = item.ToString();

            var result = await Context.GlobalConfig
                         .SingleOrDefaultAsync(o => o.Key == key);

            if (result == null)
            {
                result = new GlobalConfigItem()
                {
                    Key   = key,
                    Value = value
                };

                Context.GlobalConfig.Add(result);
            }
            else
            {
                result.Value = value;
            }

            await Context.SaveChangesAsync();
        }
Beispiel #8
0
        public void RegisterServerConfig()
        {
            try
            {
                Catalog.Services.Register <IConfig>(SpecialFactoryContexts.Safe, _ => new ApplicationConfiguration());
                Catalog.Services.Register <IRecurrence <object> >(_AppDomain => new ThreadedRecurrence <object>());

                var globalConfig = Catalog.Preconfigure()
                                   .Add(ApplicationTopologyLocalConfig.CompanyKey, TopologyPath.Company)
                                   .Add(ApplicationTopologyLocalConfig.ApplicationKey, TopologyPath.Product)
                                   .ConfiguredCreate(() => new RavenGlobalConfig());

                Catalog.Services.Register <IConfig>(
                    _ => new AggregateConfiguration(globalConfig, new ApplicationConfiguration())).AsAssemblerSingleton();
                Catalog.Services.Register <IConfig>(SpecialFactoryContexts.Safe, _ => globalConfig);

                globalConfig.Start();

                using (var dc = DocumentStoreLocator.Resolve(DocumentStoreLocator.RootLocation))
                {
                    var db = dc.Load <DatabaseInfo>(TopologyPath.Product);
                    if (null == db)
                    {
                        db = new DatabaseInfo
                        {
                            Application           = TopologyPath.Product,
                            DatabaseSchemaVersion = TopologyPath.DBVersion,
                            InstallDate           = DateTime.UtcNow,
                            Url = "http://localhost:8080/raven/"
                        };
                        dc.Store(db);

                        var fc = new GlobalConfigItem
                        {
                            Name  = "DistributedFileShare",
                            Value = "C:\\Lok\\AppData"
                        };

                        dc.Store(fc);

                        var email = new EmailServerInfo()
                        {
                            Application    = TopologyPath.EmailServerShared,
                            ConfiguredDate = DateTime.UtcNow,
                            IsSsl          = false,
                            SmtpServer     = "localhost",
                            Username       = "******",
                            Password       = "******",
                            Port           = 10
                        };

                        dc.Store(email);

                        dc.SaveChanges();
                    }
                }

                var installer = Catalog.Preconfigure()
                                .Add(ApplicationTopologyLocalConfig.CompanyKey, TopologyPath.Company)
                                .Add(ApplicationTopologyLocalConfig.ApplicationKey, TopologyPath.Product)
                                .ConfiguredCreate(() => new RavenTopologyInstaller());

                installer.LocalInstall(
                    Guid.NewGuid().ToString(),
                    "Development Environment",
                    TopologyPath.Version,
                    TopologyPath.DBVersion,
                    "http://localhost:8080",
                    "Control",
                    "Admin",
                    "b1f08cc1-7130-49d4-bffa-cd1211d2a743");

                Console.WriteLine("Complete.");
            }

            catch (Exception ex)
            {
                Console.WriteLine(ex.TraceInformation());
            }
        }
Beispiel #9
0
 public void SaveFileStoreConfiguration(GlobalConfigItem info)
 {
     _manager.SaveGlobalConfigItem(info);
 }
Beispiel #10
0
        public bool TestFileStoreConnection(GlobalConfigItem item)
        {
            var provider = new FileServerTestingProvider();

            return(provider.TestNode(item));
        }