示例#1
0
        public ActionResult SaveBackupProvider(BackupProvider model)
        {
            using (var db = new MTCDbContext())
            {
                if (model.Id == 0)
                {
                    model.CreatedOn  = DateTime.Now;
                    model.CreatedBy  = HttpContext.User.Identity.Name;
                    model.ModifiedOn = DateTime.Now;
                    model.ModifiedBy = HttpContext.User.Identity.Name;
                    db.BackupProviders.Add(model);
                }
                else
                {
                    var bp = db.BackupProviders.Find(model.Id);
                    bp.ContractorId   = model.ContractorId;
                    bp.BackupBeatId   = model.BackupBeatId;
                    bp.FleetVehicleId = model.FleetVehicleId;
                    bp.ModifiedOn     = DateTime.Now;
                    bp.ModifiedBy     = HttpContext.User.Identity.Name;
                }

                db.SaveChanges();

                return(Json(true, JsonRequestBehavior.AllowGet));
            }
        }
示例#2
0
        public static long GetBackupsQuotaUsed(Service service, BackupProvider provider)
        {
            var backups = Models.Objects.Backup.GetBackupsForService(service);

            backups.RemoveAll(x => x.Provider.Id != provider.Id);
            var value = backups.Sum(backup => backup.FileSize);

            return(value);
        }
示例#3
0
        public static List <BackupProvider> AccessibleProviders(Service service)
        {
            var backupProviders = new BackupProvider().GetAll <BackupProvider>();

            return((from backupProvider in backupProviders
                    let config = backupProvider.Configuration.Parse <BackupProviderConfiguration>()
                                 where config.Enabled && backupProvider.GetQuota(service) > 0
                                 select backupProvider).ToList());
        }
 public SystemController(JobProvider jobProvider, IndexerProvider indexerProvider,
                         ConfigProvider configProvider, DiskProvider diskProvider,
                         BackupProvider backupProvider, StatsProvider statsProvider)
 {
     _jobProvider     = jobProvider;
     _indexerProvider = indexerProvider;
     _configProvider  = configProvider;
     _diskProvider    = diskProvider;
     _backupProvider  = backupProvider;
     _statsProvider   = statsProvider;
 }
        public FtpProvider()
        {
            var settings = new BackupProvider().FindByType(typeof(FtpProvider)).Configuration
                           .Parse <FtpProviderConfiguration>();
            var host     = settings.Host;
            var username = settings.Username;
            var password = settings.Password;

            FtpClient = new FtpClient(host, settings.Port, new NetworkCredential(username, password));
            FtpClient.Connect();
        }
示例#6
0
        public S3Provider()
        {
            var settings = new BackupProvider().FindByType(typeof(S3Provider)).Configuration
                           .Parse <S3ProviderConfiguration>();
            var host     = settings.Host;
            var username = settings.AccessId;
            var password = settings.AccessSecret;

            _region = settings.Region;

            MinioClient = new MinioClient(host, username, password, _region).WithSSL();
            MinioClient.SetTraceOn();
            this.AllowsDirectDownload = true;
        }
        public System.Net.WebRequest Create(Uri uri)
        {
            var providerUri = new StorageUri(uri);
            var provider    = this.GetProviderByUri(providerUri);


            // Pipeline: Backup => Cache => Basic Provider

            if (_configService.PluginConfiguration.IsOfflineCacheEnabled)
            {
                provider = _cacheManagerService.WrapInCacheProvider(provider, uri);
            }

            if (_configService.PluginConfiguration.IsBackupToLocalEnabled ||
                _configService.PluginConfiguration.IsBackupToRemoteEnabled)
            {
                provider = BackupProvider.WrapInBackupProvider(provider, providerUri, _configService);
            }

            var itemPath = providerUri.GetPath();

            return(new KeeAnywhereWebRequest(provider, itemPath));
        }
示例#8
0
 public static long GetBackupsQuota(Service service, BackupProvider provider)
 {
     return(provider.GetQuota(service));
 }