Ejemplo n.º 1
0
 public TimersController(ILogger <TimersController> logger, DbService dbService, RepoInfoCache repoInfo)
 {
     _logger    = logger;
     _dbService = dbService;
     _repoInfo  = repoInfo;
     _indexInfo = dbService.CachedColIndexInfo;
 }
Ejemplo n.º 2
0
 public ConfigurationController(ILogger <ConfigurationController> logger, RepoInfoCache repoInfo, DbService dbService, GitInfoService gitInfo, MongoDBConfig dBConfig)
 {
     _repoInfo  = repoInfo;
     _dbService = dbService;
     _indexInfo = dbService.CachedColIndexInfo;
     _gitInfo   = gitInfo;
     _logger    = logger;
     _dBConfig  = dBConfig;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Remove a user group from the UniFi controller
        /// </summary>
        /// <param name="item">User group to remove</param>
        /// <returns><c>TRUE</c> if there was an item to remove, otherwise <c>FALSE</c></returns>
        public async Task <bool> Remove(UserGroup item)
        {
            if (!CachedCollection.Contains(item))
            {
                return(false);
            }

            await API.SiteUserGroupsDelete(item.UserGroupId);

            await Refresh();

            return(true);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Remove a port forwarding rule from the UniFi controller
        /// </summary>
        /// <param name="item">Port forwarding rule to remove</param>
        /// <returns><c>TRUE</c> if there was an item to remove, otherwise <c>FALSE</c></returns>
        public async Task <bool> Remove(PortForward item)
        {
            if (!CachedCollection.Contains(item))
            {
                return(false);
            }

            await API.SitePortForwardsDelete(item.PortForwardId);

            await Refresh();

            return(true);
        }
Ejemplo n.º 5
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            var asm = Assembly.GetExecutingAssembly();

            CrashReport.Init();

            m_database = new LiteDatabase(Path.GetFileNameWithoutExtension(asm.Location) + ".db");
            m_database.Engine.UserVersion = 0;

            Config.Load(m_database);

            LyricCollection = new CachedCollection <LyricArchive>(
                m_database.GetCollection <LyricArchive>("lyrics"),
                le => le.LyricArchiveId);

            foreach (var itemInvaild in LyricCollection.FindAll().Where(le => le.IsInvalid).ToArray())
            {
                Debug.WriteLine($"Invaild : {itemInvaild.LyricArchiveId}");
                LyricCollection.Delete(itemInvaild.LyricArchiveId);
            }
        }
Ejemplo n.º 6
0
        public DbService(MongoDBConfig dBConfig)
        {
            _dBConfig = dBConfig;
            _client   = new MongoClient(new MongoClientSettings()
            {
                Server     = MongoServerAddress.Parse(_dBConfig.Host),
                Credential = MongoCredential.CreateCredential(
                    _dBConfig.AuthSource,
                    _dBConfig.Username,
                    _dBConfig.Password
                    )
            });

            _dB = _client.GetDatabase(_dBConfig.Database);

            ColScheduler = _dB.GetCollection <ColScheduler>(_dBConfig.CollectionScheduler);
            ColTimers    = _dB.GetCollection <ColTimers>(_dBConfig.CollectionTimers);
            ColRepoInfo  = _dB.GetCollection <ColRepoInfo>(_dBConfig.CollectionRepoInfo);
            ColIndexInfo = _dB.GetCollection <ColIndexInfo>(_dBConfig.CollectionIndexInfo);

            CachedColIndexInfo = new CachedCollection <ColIndexInfo>(ColIndexInfo);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Retrieve a user group by its User Group ID
 /// </summary>
 /// <param name="id">User Group ID</param>
 /// <returns>User group or <c>NULL</c></returns>
 public UserGroup GetById(string id)
 {
     return(CachedCollection.FirstOrDefault(g => g.UserGroupId.Equals(id)));
 }
Ejemplo n.º 8
0
 public GitController(RepoInfoCache repoInfo, DbService dbService)
 {
     _repoInfo  = repoInfo;
     _indexInfo = dbService.CachedColIndexInfo;
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Retrieve a client device by its Port Forward ID
 /// </summary>
 /// <param name="id">Port Forward ID</param>
 /// <returns>Port forwarding entry or <c>NULL</c></returns>
 public PortForward GetById(string id)
 {
     return(CachedCollection.FirstOrDefault(g => g.PortForwardId.Equals(id)));
 }
Ejemplo n.º 10
0
 public Blog First()
 {
     return(CachedCollection.FirstOrDefault());
 }
Ejemplo n.º 11
0
 public Feature GetByName(string name)
 {
     return(CachedCollection.SingleOrDefault(o => o.Name == name) ?? new Feature());
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Retrieve an infrastructure device by its Device ID
 /// </summary>
 /// <param name="id">Device ID of infrastructure device</param>
 /// <returns>Infrastructure device or <c>NULL</c></returns>
 public IInfrastructureNetworkedDevice GetById(string id)
 {
     return(CachedCollection.FirstOrDefault(c => c.Id.Equals(id)));
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Retrieve an infrastructure device by its MAC address
 /// </summary>
 /// <param name="macAddress">MAC Address of infrastructure device</param>
 /// <returns>Infrastructure device or <c>NULL</c></returns>
 public IInfrastructureNetworkedDevice GetByMac(string macAddress)
 {
     return(CachedCollection.FirstOrDefault(c => c.MacAddress.Equals(macAddress, StringComparison.OrdinalIgnoreCase)));
 }