public ResourceService() { string accessKeyId = ConfigurationManager.AppSettings["oss_key_id"]; string accessKeySecret = ConfigurationManager.AppSettings["oss_key_secret"]; string format = ConfigurationManager.AppSettings["oss_host"]; string root = ConfigurationManager.AppSettings["oss_root"]; _publicBucket = ConfigurationManager.AppSettings["oss_public_bucket"]; string host = string.Format(format, _publicBucket); _privateBucket = ConfigurationManager.AppSettings["oss_private_bucket"]; string privateHost = string.Format(format, _privateBucket); _publicStorage = new AliOssStorage(accessKeyId, accessKeySecret, _publicBucket, host, root); _privateStorage = new AliOssStorage(accessKeyId, accessKeySecret, _privateBucket, privateHost, root); _pathBuilder = new AccurateToHourPathBuilder(); _publicHost = ConfigurationManager.AppSettings["resource_public_host"]; if (string.IsNullOrWhiteSpace(_publicHost)) { _publicHost = _publicStorage.Host; } _privateHost = ConfigurationManager.AppSettings["resource_private_host"]; if (string.IsNullOrWhiteSpace(_privateHost)) { _privateHost = _privateStorage.Host; } _privateWatermarkHost = ConfigurationManager.AppSettings["watermark_host"]; }
public WorkplaceManager(UserConnection uc) { _workplaceRepository = ClassFactory.Get <IWorkplaceRepository>(new ConstructorArgument("uc", uc)); _sectionRepository = ClassFactory.Get <ISectionRepository>("General", new ConstructorArgument("uc", uc)); _resourceStorage = uc.ResourceStorage; _currentUserId = uc.CurrentUser.Id; }
public SectionRepository(UserConnection uc) { UserConnection = uc; EntitySchemaManager = uc.EntitySchemaManager; ApplicationCache = uc.ApplicationCache; ResourceStorage = uc.ResourceStorage; }
public void Initialize(IResourceStorage storage) { storage.AddResources(ResourceType.Money, STARTING_MONEY); storage.AddResources(ResourceType.Power, STARTING_POWER); storage.AddResources(ResourceType.Coal, STARTING_COAL); storage.AddResources(ResourceType.Population, STARTING_POPULATION); }
public WorkplaceRepository(UserConnection uc) { _userConnection = uc; _entitySchemaManager = uc.EntitySchemaManager; _applicationCache = uc.ApplicationCache; _resourceStorage = uc.ResourceStorage; }
/// <summary> /// Finds out expired resources in the <paramref name="resourceStorage"/> and deletes them. /// </summary> /// <typeparam name="T"> The type of an identifier of a resource. </typeparam> /// <param name="resourceStorage"> /// The storage where to perform cleanup in. /// </param> /// <param name="expirationPolicy"> /// The resource expiration policy. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="resourceStorage"/> is <see langword="null"/> or /// <paramref name="expirationPolicy"/> is <see langword="null"/>. /// </exception> public async Task ExecuteStorageCleanup <T>( [NotNull] IResourceStorage <T> resourceStorage, [NotNull] IResourceExpirationPolicy expirationPolicy) { AssertArg.NotNull(resourceStorage, nameof(resourceStorage)); AssertArg.NotNull(expirationPolicy, nameof(expirationPolicy)); _log?.Debug($"Calling {resourceStorage.GetType().Name} storage for resource details."); var resources = (await resourceStorage.GetResourceDetails()).ToArray(); _log?.Debug($"Fetched details about {resources.Length} resources."); var resourceIdsToDelete = expirationPolicy .FindExpiredResources(resources) .ToArray(); if (!resourceIdsToDelete.Any()) { _log?.Info("No expired resources were found thus no resource is deleted."); return; } _log?.Debug($"Calling {resourceStorage.GetType().Name} storage for expired resources deletion."); await resourceStorage.DeleteResources(resourceIdsToDelete); _log?.Debug($"Deleted {resourceIdsToDelete.Length} expired resources."); }
private static string GetErrorMessage(IResourceStorage storage, Guid currencyId, string parameterName, object value) { string errorMessageTemplate = CurrencyErrorMessageHelper .GetErrorMessageTemplate(storage, "CurrencyParameterLessOrEqualsZeroExceptionMessage"); return string.Format(errorMessageTemplate, value, parameterName, currencyId); }
private void InitNewResourceSystem() { var resourceSystem = new ClientResourcesStorage(); _resourceStorage = resourceSystem; _clientResourceOperations = resourceSystem; _serverResourceOperations = resourceSystem; }
/// <summary> /// Returns resource value. /// </summary> /// <param name="resourceName">Resource name.</param> /// <returns>Resource value</returns> protected string GetResourceValue(string resourceName) { IResourceStorage resourceStorage = _userConnection.Workspace.ResourceStorage; var resource = new LocalizableString(resourceStorage, "QueuesUpdateUtilities", string.Format("LocalizableStrings.{0}.Value", resourceName)); return(resource.Value); }
public SspEntityRepository(UserConnection uc) { _userConnection = uc; _entitySchemaManager = _userConnection.EntitySchemaManager; _securityEngine = _userConnection.DBSecurityEngine; _resourceStorage = uc.ResourceStorage; _utils = new SchemaDesignerUtilities(_userConnection); _packageUId = GetCurrentPackageUId(); }
public static bool HasAll(IResourceStorage target, IResourceStorage required) { bool can = true; foreach (ResourceType type in System.Enum.GetValues(typeof(ResourceType))) { can &= target.HasResource(type, required.GetResourceAmmount(type)); } return(can); }
/// <summary> /// Constructs a localizer. /// </summary> /// <param name="assembly">The assembly containing the report file.</param> /// <param name="embeddedReportName">Embedded report full name: {default namespace}.{folder path inside assembly}.{report name with extension}</param> /// <param name="embeddedReportId">Report identifier that will be used to load resource strings related to this report.</param> /// <param name="resourceStorage"><see cref="IResourceStorage"/> instance.</param> public EmbeddedReportLocalizer(Assembly assembly, string embeddedReportName, string embeddedReportId, IResourceStorage resourceStorage) : base(embeddedReportName, embeddedReportId, resourceStorage) { if (assembly == null) { throw new ArgumentNullException("assembly"); } this.assembly = assembly; }
public PermissionGrantManager( IDataProviderPolicyApplicator applicator, IPermissionGrantStorage storage, IPermissionValidator validator, IResourceStorage resources) { this.applicator = applicator; this.storage = storage; this.validator = validator; this.resources = resources; }
public void Init(IServices services) { _storage = services.ResourceService.ResourceStorage; _storage.ResourceTypes.ObserveAdd().Subscribe(newItem => { var resourceId = newItem.Value; var amount = _storage.GetResourceAmount(resourceId); var limit = _storage.GetResourceLimit(resourceId); _resourceItems.Add(new ResourceItemData(resourceId, amount, limit)); }).AddTo(_disposables); }
public static IResourceStorage Setup(this IResourceStorage storage) { foreach (var r in All()) { storage.Add(r); } foreach (var a in ResourceActions.All()) { storage.AddAction(a); } return(storage); }
/// <summary> /// Base constructor for every report localizer. /// </summary> /// <param name="reportName">Name of the report to localize.</param> /// <param name="reportIdentifier">Identifier of the report inside the resource file.</param> /// <param name="resourceStorage">Instance of the class used to get the strings from localization resource file.</param> /// <exception cref="ArgumentNullException">When <paramref name="reportName"/> or <paramref name="resourceStorage"/> is null.</exception> public AbstractReportLocalizer(string reportName, string reportIdentifier, IResourceStorage resourceStorage) { if (String.IsNullOrEmpty(reportName)) { throw new ArgumentNullException("reportName", "Please, specify the name of the report to view."); } if (resourceStorage == null) { throw new ArgumentNullException("resourceStorage"); } this.reportName = reportName; this.reportIdentifier = reportIdentifier; this.resourceStorage = resourceStorage; }
/// <summary> /// Initializes a new instance of the <see cref="App{T}" /> class. /// </summary> /// <param name="cleanupExecutor"> /// The executor of cleanup of the <paramref name="storage"/>. /// </param> /// <param name="storage"> /// The storage to be cleanup up. /// </param> /// <param name="expirationPolicy"> /// The resource expiration policy. /// </param> /// <param name="log"> /// The log where to write messages to. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="cleanupExecutor"/> is <see langword="null"/> or /// <paramref name="storage"/> is <see langword="null"/> or /// <paramref name="expirationPolicy"/> is <see langword="null"/> or /// <paramref name="log"/> is <see langword="null"/>. /// </exception> public App( [NotNull] CleanupExecutor cleanupExecutor, [NotNull] IResourceStorage <T> storage, [NotNull] IResourceExpirationPolicy expirationPolicy, [NotNull] ILog log) { AssertArg.NotNull(cleanupExecutor, nameof(cleanupExecutor)); AssertArg.NotNull(storage, nameof(storage)); AssertArg.NotNull(expirationPolicy, nameof(expirationPolicy)); AssertArg.NotNull(log, nameof(log)); _cleanupExecutor = cleanupExecutor; _storage = storage; _expirationPolicy = expirationPolicy; _log = log; }
/// <summary> /// ######### ####### ############ ########## ######## ####### ####. /// </summary> /// <param name="userConnection">################ ###########.</param> public static void UpdateQueuesTrigger(UserConnection userConnection) { try { if (GetIsSchedulerDisabled(userConnection)) { AppScheduler.RemoveJob(UpdateQueuesJobName, UpdateQueuesJobGroup); IResourceStorage resourceStorage = userConnection.Workspace.ResourceStorage; var message = new LocalizableString(resourceStorage, "QueuesUtilities", "LocalizableStrings.SchedulerDisabledMessage.Value"); _log.DebugFormat(message); NotifySubscribers("Debug", message); return; } string userName = userConnection.CurrentUser.Name; string workspaceName = userConnection.Workspace.Name; int periodInMinutes = GetQueuesUpdateInterval(userConnection); AppScheduler.ScheduleMinutelyProcessJob(UpdateQueuesJobName, UpdateQueuesJobGroup, UpdateQueuesProcessName, workspaceName, userName, periodInMinutes, null, true); } catch (Exception e) { LogError(e.Message, e); throw; } }
/// <summary> /// Constructs the class to function. /// </summary> /// <param name="reportName">Actually, the full path to the report file.</param> /// <param name="reportIdentifier"> /// String used to identify report file related strings in resources. /// The following string format is used to assosiate report and its strings: {report name}.{localiation id} /// </param> /// <param name="resourceStorage"><see cref="IResourceStorage"/> instance.</param> public FileSystemReportLocalizer(string reportName, string reportIdentifier, IResourceStorage resourceStorage) : base(reportName, reportIdentifier, resourceStorage) { }
/// <summary> /// Creates instance of type <see cref="FundTypeDuplicateException"/>. /// </summary> /// <param name="storage">Resource storage.</param> public FundTypeDuplicateException(IResourceStorage storage) : base( new LocalizableString(storage, "PRMExceptions", "LocalizableStrings.FundTypeDuplicateException.Value")) { }
public static void RemoveAll(IResourceStorage target, IResourceStorage remove) { DoForEachResource((t) => target.RemoveResource(t, remove.GetResourceAmmount(t))); }
/// <summary> /// Creates instance of type <see cref="EmptyDataException"/>. /// </summary> /// <param name="storage">Resource storage.</param> public EmptyDataException(IResourceStorage storage) : base(new LocalizableString(storage, "FileImportExceptions", "LocalizableStrings.EmptyDataExceptionMessage.Value")) { }
public ResourceController(IResourceStorage storage) { this.storage = storage; }
/// <summary> /// Shorter constructor that assume that report file is located in the assembly where this type is declared. /// </summary> /// <param name="embeddedReportName">Embedded report full name: {default namespace}.{folder path inside assembly}.{report name with extension}</param> /// <param name="embeddedReportId">Report identifier that will be used to load resource strings related to this report.</param> /// <param name="resourceStorage"><see cref="IResourceStorage"/> instance.</param> public EmbeddedReportLocalizer(string embeddedReportName, string embeddedReportId, IResourceStorage resourceStorage) : base(embeddedReportName, embeddedReportId, resourceStorage) { this.assembly = this.GetType().Assembly; }
public static void AddAll(IResourceStorage target, IResourceStorage add) { DoForEachResource((t) => target.AddResource(t, add.GetResourceAmmount(t))); }
/// <summary> /// 构造函数。 /// </summary> internal ResourceFactory(IResourceStorage rs) { if (rs == null) throw new ArgumentNullException("资源存储未配置。"); this.storage = rs; }
/// <summary> /// 构造函数。 /// </summary> /// <param name="rs"></param> public ResourceProviderFactory(IResourceStorage rs) : base(rs) { this.resouceFactory = new ResourceFactory(rs); this.culture = CultureInfo.CurrentCulture; }
public ResourceValidator(IResourceStorage storage) { this.storage = storage; }
public ResourceFinder(IResourceStorage storage) { this.storage = storage; }
/// <summary> /// 构造函数。 /// </summary> public ResourceProvider(IResourceStorage resourceStorage) { this.resourceStorage = resourceStorage; }
public FileUploadInfo(Stream fileContent, MS.HttpRequestBase request, IResourceStorage storage) { _request = request; _fileContent = fileContent; _storage = storage; }
/// <summary> /// Creates instance of type <see cref="InvalidFileSizeException"/>. /// </summary> /// <param name="storage">Resource storage.</param> public InvalidFileSizeException(IResourceStorage storage) : base(new LocalizableString(storage, "FileUploadExceptions", "LocalizableStrings.InvalidFileSizeExceptionMessage.Value")) { }
/// <summary> /// Returns localizable string to error message. /// </summary> /// <param name="storage">Resource storage.</param> /// <param name="localizableStringName">Localizable string name.</param> /// <returns></returns> public static string GetErrorMessageTemplate(IResourceStorage storage, string localizableStringName) { var errorMessageTemplate = new LocalizableString(storage, "CurrencyException", $"LocalizableStrings.{localizableStringName}.Value"); return errorMessageTemplate.ToString(); }