public static void CopyFrom(StorageSettings settings, StorageSettings other)
        {
            var comp = Get();

            if (comp == null)                   //fixed storage settings will copy do this copy on game load
            {
                return;
            }

            List <ThingFilter> otherRanks = comp.GetRanks(other, false);

            if (otherRanks == null)
            {
                comp.rankedSettings.Remove(settings);
            }
            else
            {
                comp.GetRanks(settings).Clear();
                foreach (ThingFilter otherFilter in otherRanks)
                {
                    comp.AddFilter(settings, otherFilter);
                }
            }

            comp.DetermineUsedFilter(settings, comp.GetRanks(settings, false));
        }
 public IActionResult Storage(StorageSettings viewModel)
 {
     return(RedirectToAction("StorageProvider", "Server", new
     {
         provider = viewModel.Provider.ToString()
     }));
 }
Esempio n. 3
0
        public void Start(int tenantId, StorageSettings newStorageSettings, StorageFactoryConfig storageFactoryConfig)
        {
            if (TokenSource.Token.IsCancellationRequested)
            {
                return;
            }

            MigrateOperation migrateOperation;

            lock (Locker)
            {
                migrateOperation = Cache.Get <MigrateOperation>(GetCacheKey(tenantId));
                if (migrateOperation != null)
                {
                    return;
                }

                migrateOperation = new MigrateOperation(ServiceProvider, CacheMigrationNotify, tenantId, newStorageSettings, storageFactoryConfig);
                Cache.Insert(GetCacheKey(tenantId), migrateOperation, DateTime.MaxValue);
            }

            var task = new Task(migrateOperation.RunJob, TokenSource.Token, TaskCreationOptions.LongRunning);

            task.ConfigureAwait(false)
            .GetAwaiter()
            .OnCompleted(() =>
            {
                lock (Locker)
                {
                    Cache.Remove(GetCacheKey(tenantId));
                }
            });

            task.Start(Scheduler);
        }
Esempio n. 4
0
 public AuthController(
     UserManager <ApplicationUser> userManager,
     RoleManager <IdentityRole> roleManager,
     IHttpContextAccessor contextAccessor,
     IJwtFactory jwtFactory,
     IRecaptchaService recaptcha,
     IOptions <JwtIssuerOptions> jwtOptions,
     IOptions <AppSettings> appSettings,
     IOptions <StorageSettings> storageSettings,
     IOptions <ImageFileStorageSettings> imageFileStorageSettings,
     IMailSender mailSender,
     IUnitOfWork unitOfWork,
     ILogger <AuthController> logger) : base(logger)
 {
     _userManager              = userManager;
     _jwtFactory               = jwtFactory;
     _recaptcha                = recaptcha;
     _emailSender              = mailSender;
     _unitOfWork               = unitOfWork;
     _roleManager              = roleManager;
     _contextAccessor          = contextAccessor;
     _appSettings              = appSettings.Value;
     _jwtOptions               = jwtOptions.Value;
     _storageSettings          = storageSettings.Value;
     _imageFileStorageSettings = imageFileStorageSettings.Value;
 }
        public static IDataStore GetStorage(string configpath, string tenant, string module, IQuotaController controller)
        {
            var tenantId = -2;

            if (string.IsNullOrEmpty(tenant))
            {
                tenant = DefaultTenantName;
            }
            else
            {
                tenantId = Convert.ToInt32(tenant);
            }

            //Make tennant path
            tenant = TennantPath.CreatePath(tenant);

            var store = DataStoreCache.Get(tenant, module);

            if (store == null)
            {
                var section = GetSection(configpath);
                if (section == null)
                {
                    throw new InvalidOperationException("config section not found");
                }

                var settings = StorageSettings.LoadForTenant(tenantId);

                store = GetStoreAndCache(tenant, module, section, settings.DataStoreConsumer, controller);
            }
            return(store);
        }
Esempio n. 6
0
        public static Thing findAmmo(Pawn pawn, AERIALSYSTEM aeriel)
        {
            StorageSettings   allowed   = pawn.IsColonist ? aeriel.gun.TryGetComp <AERIALChangeableProjectile>().allowedShellsSettings : null;
            Predicate <Thing> validator = (Thing t) => !t.IsForbidden(pawn) && pawn.CanReserve(t, 10, 1, null, false) && (allowed == null || allowed.AllowedToAccept(t));

            return(GenClosest.ClosestThingReachable(pawn.Position, pawn.Map, ThingRequest.ForGroup(ThingRequestGroup.Shell), PathEndMode.OnCell, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), 40f, validator, null, 0, -1, false, RegionType.Set_Passable, false));
        }
Esempio n. 7
0
        public async Task RemoveFile(StoredFile storedFile, StorageSettings configuration)
        {
            var providerConfiguration = GetProviderConfiguration(configuration);
            var provider = await GetStorageProvider(providerConfiguration);

            await provider.DeleteBlobAsync(providerConfiguration.ContainerName, storedFile.StorageFileName);
        }
Esempio n. 8
0
        public static IEnumerable <Gizmo> CopyPasteGizmosFor(StorageSettings s)
        {
            yield return(new Command_Action
            {
                icon = ContentFinder <Texture2D> .Get("UI/Commands/CopySettings", true),
                defaultLabel = "CommandCopyBioReactorSettingsLabel".Translate(),
                defaultDesc = "CommandCopyBioReactorSettingsDesc".Translate(),
                action = delegate()
                {
                    SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                    Copy(s);
                },
                hotKey = KeyBindingDefOf.Misc4
            });

            Command_Action command_Action = new Command_Action();

            command_Action.icon = ContentFinder <Texture2D> .Get("UI/Commands/PasteSettings", true);

            command_Action.defaultLabel = "CommandPasteBioReactorSettingsLabel".Translate();
            command_Action.defaultDesc  = "CommandPasteBioReactorSettingsDesc".Translate();
            command_Action.action       = delegate()
            {
                SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                PasteInto(s);
            };
            command_Action.hotKey = KeyBindingDefOf.Misc5;
            if (!HasCopiedSettings)
            {
                command_Action.Disable(null);
            }
            yield return(command_Action);

            yield break;
        }
Esempio n. 9
0
        public async Task <StoredFile> AddFile(IFormFile file, StorageSettings configuration)
        {
            //respect https://www.microsoftpressstore.com/articles/article.aspx?p=2224058&seqNum=8 in naming
            var storageFileName       = $"{Guid.NewGuid()}-{file.FileName.ToLowerInvariant()}";
            var providerConfiguration = GetProviderConfiguration(configuration);
            var provider = await GetStorageProvider(providerConfiguration);

            using (var fileStream = file.OpenReadStream())
            {
                await provider.SaveBlobStreamAsync(providerConfiguration.ContainerName, storageFileName, fileStream,
                                                   new BlobProperties()
                {
                    ContentType        = file.ContentType,
                    ContentDisposition = file.ContentDisposition,
                    Security           = BlobSecurity.Public,
                });
            }

            return(new StoredFile()
            {
                Timestamp = DateTime.Now,
                FileName = file.FileName,
                StorageFileName = storageFileName
            });
        }
        public QueueStorage(StorageSettings settings, ILoggerFactory logger)
        {
            _storageSettings = settings ?? throw new StorageSettingsNullException(logger);
            _storageSettings.Validate();

            _logger = logger?.CreateLogger(nameof(QueueStorage));
        }
Esempio n. 11
0
 public StorageSettings GetStorageSettings()
 {
     if (_storageSettings == null)
     {
         _storageSettings = this.GetSettings <StorageSettings>("StorageSettings") ?? StorageSettings.Default;
     }
     return(_storageSettings);
 }
Esempio n. 12
0
        private static void DoHysteresisBlock(Rect rect, StorageSettings settings)
        {
            StorageSettings_Hysteresis storageSettings_Hysteresis = StorageSettings_Mapping.Get(settings) ?? new StorageSettings_Hysteresis();

            storageSettings_Hysteresis.FillPercent = Widgets.HorizontalSlider(rect.LeftPart(0.8f), storageSettings_Hysteresis.FillPercent, 0f, 100f, false, RSAKeys.HaulingHysteresis_RefillCellsLabel.Translate());
            Widgets.Label(rect.RightPart(0.2f), storageSettings_Hysteresis.FillPercent.ToString("N0") + "%");
            StorageSettings_Mapping.Set(settings, storageSettings_Hysteresis);
        }
Esempio n. 13
0
        public void Init(IReadOnlyDictionary <string, string> storageParams)
        {
            var settings = new StorageSettings {
                Module = storageParams["module"], Props = storageParams.Where(r => r.Key != "module").ToDictionary(r => r.Key, r => r.Value)
            };

            Store = StorageSettingsHelper.DataStore(settings);
        }
 public void                         ResetResourceSettings()
 {
     //Log.Message( string.Format( "{0}.CompHopperUser.ResetResourceSettings()", this.parent.ThingID ) );
     recipeFilter.Clear();
     hopperSettings.Clear();
     resourceSettings = null;
     settingsBuilt    = false;
 }
Esempio n. 15
0
 public void SetUpStorageSettings()
 {
     if (GetParentStoreSettings() != null)
     {
         settings = new StorageSettings(this);
         settings.CopyFrom(GetParentStoreSettings());
     }
 }
        public ConsumerBackupStorage(IReadOnlyDictionary <string, string> storageParams)
        {
            var settings = new StorageSettings {
                Module = storageParams["module"], Props = storageParams.Where(r => r.Key != "module").ToDictionary(r => r.Key, r => r.Value)
            };

            store = settings.DataStore;
        }
Esempio n. 17
0
    //=======================================================================
    //============================== Other stuff ============================
    //=======================================================================
    public override void PostMake()
    {
        base.PostMake();
        settings = new StorageSettings(this);

        if( def.defaultStorageSettings != null )
            settings.CopyFrom( def.defaultStorageSettings );
    }
Esempio n. 18
0
        public void test()
        {
            var blobStorageSettings = A.Fake <ISettingsBlobStoreSettings>();
            var sut = new StorageSettings("", blobStorageSettings, A.Fake <IExceptionLogger>());

            sut.GetByKey("IsProcessingSamsaraLocation").ShouldBeNull();
            sut.GetByKey("IsProcessingSamsaraLocation", false).ShouldBeFalse();
        }
        public List <StorageWrapper> GetAllStorages()
        {
            SecurityContext.DemandPermissions(Tenant, SecutiryConstants.EditPortalSettings);

            var current   = StorageSettings.Load();
            var consumers = ConsumerFactory.GetAll <DataStoreConsumer>().ToList();

            return(consumers.Select(consumer => new StorageWrapper(consumer, current)).ToList());
        }
 public EventHubFactoryConfigurator()
 {
     _observers             = new RiderObservable();
     _endpointObservers     = new ReceiveEndpointObservable();
     _endpoints             = new List <IEventHubReceiveEndpointSpecification>();
     _hostSettings          = new HostSettings();
     _storageSettings       = new StorageSettings();
     _producerSpecification = new EventHubProducerSpecification(_hostSettings);
 }
Esempio n. 21
0
        public static StorageSettings GetStorageSettings()
        {
            if (settings == null)
            {
                settings = new StorageSettings();
            }

            return(settings);
        }
 public override void PostMake()
 {
     base.PostMake();
     allowedCorpseFilterSettings = new StorageSettings(this);
     if (def.building.defaultStorageSettings != null)
     {
         allowedCorpseFilterSettings.CopyFrom(def.building.defaultStorageSettings);
     }
 }
        //[Read("storage/backup")]
        //public List<StorageWrapper> GetAllBackupStorages()
        //{
        //    SecurityContext.DemandPermissions(Tenant, SecutiryConstants.EditPortalSettings);

        //    var schedule = new BackupAjaxHandler().GetSchedule();
        //    var current = new StorageSettings();

        //    if (schedule != null && schedule.StorageType == Contracts.BackupStorageType.ThirdPartyConsumer)
        //    {
        //        current = new StorageSettings
        //        {
        //            Module = schedule.StorageParams["module"],
        //            Props = schedule.StorageParams.Where(r => r.Key != "module").ToDictionary(r => r.Key, r => r.Value)
        //        };
        //    }

        //    var consumers = ConsumerFactory.GetAll<DataStoreConsumer>().ToList();
        //    return consumers.Select(consumer => new StorageWrapper(consumer, current)).ToList();
        //}

        private void StartMigrate(StorageSettings settings)
        {
            using (var migrateClient = new ServiceClient())
            {
                migrateClient.Migrate(Tenant.TenantId, settings);
            }

            Tenant.SetStatus(TenantStatus.Migrating);
        }
        private static async Task LoadSecretSettings(
            StorageSettings storageSettings,
            AppSettings appSettings,
            KeyVaultSettings keyVaultSettings)
        {
            var store = new SecretsStore(appSettings.KeyVaultBaseUrl, keyVaultSettings.ClientId, keyVaultSettings.ClientSecret);

            storageSettings.ConnectionString = await store.GetOrLoadSettingAsync(storageSettings.ConnectionString);
        }
Esempio n. 25
0
        public static void Prefix(StorageSettings __instance, ref StoragePriority value)
        {
            Building_Shelf shelf = __instance.owner as Building_Shelf;

            if (value != __instance.Priority)
            {
                shelf?.Notify_PriorityChanging(value);
            }
        }
Esempio n. 26
0
        public static ref int GetLimit(StorageSettings settings)
        {
            if (!limits.ContainsKey(settings))
            {
                limits.Add(settings, new IntHolder(-1));
            }

            return(ref limits[settings].Int);
        }
Esempio n. 27
0
 public override void PostMake()
 {
     base.PostMake();
     storageSettings = new StorageSettings(this);
     if (def.building.defaultStorageSettings != null)
     {
         storageSettings.CopyFrom(this.def.building.defaultStorageSettings);
     }
 }
Esempio n. 28
0
        protected virtual async Task <CloudTable> GetTableAsync()
        {
            var storageAccount = StorageSettings.CreateCloudStorageAccount();
            var tableClient    = storageAccount.CreateCloudTableClient();
            var table          = tableClient.GetTableReference(StorageSettings.TableName);
            await table.CreateIfNotExistsAsync();

            return(table);
        }
Esempio n. 29
0
 public static void Postfix(StorageSettings __instance)
 {
     LazySettings settings = LazySettingsManager.AddOrGetSettings(__instance);
     {
         Scribe_Values.Look(ref settings.type, "settings.type", LazyType.Normal);
         Scribe_Values.Look(ref settings.CacheThreshold, "settings.CacheThreshold", LazySettings.DefaultCache);
         Scribe_Values.Look(ref settings.BufferThreshold, "settings.BufferThreshold", LazySettings.DefaultBuffer);
     }
 }
        protected async Task <CloudQueue> GetQueueAsync()
        {
            var storageAccount = StorageSettings.CreateCloudStorageAccount();
            var queueClient    = storageAccount.CreateCloudQueueClient();
            var queue          = queueClient.GetQueueReference(StorageSettings.QueueName);
            await queue.CreateIfNotExistsAsync();

            return(queue);
        }
Esempio n. 31
0
 public StorageSettings GetStoreSettings()
 {
     if (settings == null)
     {
         settings = new StorageSettings();
         settings.CopyFrom(GetParentStoreSettings());
     }
     return(settings);
 }
Esempio n. 32
0
 public static void BlockDefaultAcceptanceFilters( this ThingFilter filter, StorageSettings parentSettings = null )
 {
     // Explicitly remove auto-added special filters unless they are explicitly added
     foreach( var sf in DefDatabase<SpecialThingFilterDef>.AllDefsListForReading )
     {
         if( sf.allowedByDefault )
         {
             var blockIt = false;
             if(
                 ( filter.specialFiltersToAllow.NullOrEmpty() )||
                 ( !filter.specialFiltersToAllow.Contains( sf.defName ) )
             )
             {
                 blockIt = true;
             }
             if(
                 ( parentSettings != null )&&
                 (
                     ( parentSettings.filter.specialFiltersToAllow.NullOrEmpty() )||
                     ( !parentSettings.filter.specialFiltersToAllow.Contains( sf.defName ) )
                 )
             )
             {
                 blockIt = true;
             }
             if( blockIt )
             {
                 if( filter.specialFiltersToDisallow.NullOrEmpty() )
                 {
                     filter.specialFiltersToDisallow = new List<string>();
                 }
                 filter.specialFiltersToDisallow.Add( sf.defName );
                 filter.SetAllow( sf, false );
             }
         }
     }
 }
 public void ResetResourceSettings()
 {
     //Log.Message( string.Format( "{0}.CompHopperUser.ResetResourceSettings()", this.parent.ThingID ) );
     recipeFilter.Clear();
     hopperSettings.Clear();
     resourceSettings = null;
     settingsBuilt = false;
 }
Esempio n. 34
0
 public override void PostMake()
 {
     base.PostMake();
     settings = new StorageSettings((IStoreSettingsParent) this);
     if( def.building.defaultStorageSettings != null )
     {
         settings.CopyFrom(def.building.defaultStorageSettings);
     }
     settings.filter.BlockDefaultAcceptanceFilters();
     settings.filter.ResolveReferences();
 }
        public void ProgramHopper( StorageSettings HopperUserSettings )
        {
            if(
                ( WasProgrammed )||
                ( Building == null )||
                ( HopperUserSettings == null )
            )
            {
                // Already programmed or not a valid hopper
                return;
            }

            var hopperSettings = Building.GetStoreSettings();
            if( hopperSettings == null )
            {
                // No storage settings
                return;
            }

            // Copy the settings from the controller
            hopperSettings.CopyFrom( HopperUserSettings );

            // Set the programming flag
            WasProgrammed = true;
        }
 public override void PostMake()
 {
     //Log.Message( string.Format( "{0}.PostName()", this.ThingID ) );
     base.PostMake();
     settings = new StorageSettings((IStoreSettingsParent) this);
     if( def.building.defaultStorageSettings != null )
     {
         settings.CopyFrom( def.building.defaultStorageSettings );
     }
     //settings.filter.BlockDefaultAcceptanceFilters();
     settings.filter.ResolveReferences();
 }