Example #1
0
 public StorageAccountService(IStorageAccountRepository storageAccountRepository,
                              IStoragePluginsService storagePluginsService,
                              IStorageAccountSettingsRepository storageAccountSettingsRepository,
                              IConnectionProvider connectionProvider)
 {
     _storageAccountRepository         = storageAccountRepository;
     _storagePluginsService            = storagePluginsService;
     _storageAccountSettingsRepository = storageAccountSettingsRepository;
     _connectionProvider = connectionProvider;
 }
 public StorageAccountService(IStorageAccountRepository storageAccountRepository, 
     IStoragePluginsService storagePluginsService,
     IStorageAccountSettingsRepository storageAccountSettingsRepository,
     IConnectionProvider connectionProvider)
 {
     _storageAccountRepository = storageAccountRepository;
     _storagePluginsService = storagePluginsService;
     _storageAccountSettingsRepository = storageAccountSettingsRepository;
     _connectionProvider = connectionProvider;
 }
 public StorageAccountsCollection Init(IStorageAccountService storageAccountService, IStoragePluginsService storagePluginsService, int userId)
 {
     var accounts = storageAccountService.GetActiveStorageAccounts(userId);
     UserId = userId;
     _accounts = accounts.Where(a => storagePluginsService.GetStoragePlugin(a.Item2.Id) != null)
         .Select(a => new AccountItem()
         {
             AccountId = a.Item1.Id,
             AccountName = a.Item1.AccountName,
             StoragePluginId = a.Item1.StoragePluginId,
             StoragePluginName = storagePluginsService.GetStoragePlugin(a.Item2.Id).Name
         }).ToList();
     return this;
 }
        protected static void InitializePlugins()
        {
            IStoragePluginsService storageSerive = IocContainer.Instance.Resolve <IStoragePluginsService>();

            storageSerive.ResetStorages();
            IEnumerable <IStoragePlugin> storagePlugins = IocContainer.Instance.GetAllInstances <IStoragePlugin>();

            if (storagePlugins.FirstOrDefault() == null)
            {
                Logger.Warn("No storage plugins found");
                return;
            }
            storageSerive.InitStorges(storagePlugins);
        }
 public UserController(IStorageAccountService accountService, IStoragePluginsService storageService, IUserService userService)
 {
     _accountService = accountService;
     _storageService = storageService;
     _userService = userService;
 }
Example #6
0
 public UserController(IStorageAccountService accountService, IStoragePluginsService storageService, IUserService userService)
 {
     _accountService = accountService;
     _storageService = storageService;
     _userService    = userService;
 }
 public StorageAccountController(IStoragePluginsService storagePluginsService, IStorageAccountService storageAccountService, ICacheService cacheService)
 {
     _storagePluginsService = storagePluginsService;
     _storageAccountService = storageAccountService;
     _cacheService          = cacheService;
 }
Example #8
0
        public StorageAccountsCollection Init(IStorageAccountService storageAccountService, IStoragePluginsService storagePluginsService, int userId)
        {
            var accounts = storageAccountService.GetActiveStorageAccounts(userId);

            UserId    = userId;
            _accounts = accounts.Where(a => storagePluginsService.GetStoragePlugin(a.Item2.Id) != null)
                        .Select(a => new AccountItem()
            {
                AccountId         = a.Item1.Id,
                AccountName       = a.Item1.AccountName,
                StoragePluginId   = a.Item1.StoragePluginId,
                StoragePluginName = storagePluginsService.GetStoragePlugin(a.Item2.Id).Name
            }).ToList();
            return(this);
        }
        public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            NameValueCollection form = controllerContext.HttpContext.Request.Form;

            if (!form.AllKeys.Contains(Constants.StorageAccountIdFormKey))
            {
                bindingContext.ModelState.AddModelError("storage_account", ValidationResources.StorageAccountNotFoundError);
                return(null);
            }

            string pluginFormValue = form[Constants.StorageAccountIdFormKey];

            int accountId;

            if (!int.TryParse(pluginFormValue, NumberStyles.Integer, CultureInfo.InvariantCulture, out accountId))
            {
                bindingContext.ModelState.AddModelError("storage_account", ValidationResources.StorageAccountNotFoundError);
                return(null);
            }

            IStorageAccountService accountService = IocContainer.Instance.Resolve <IStorageAccountService>();
            StorageAccount         account        = accountService.Load(accountId);

            if (account == null)
            {
                bindingContext.ModelState.AddModelError("storage_account", ValidationResources.StorageAccountNotFoundError);
                return(null);
            }

            IStoragePluginsService storageService = IocContainer.Instance.Resolve <IStoragePluginsService>();

            IStoragePlugin storagePlugin = storageService.GetStoragePlugin(account.StoragePluginId);

            if (storagePlugin == null)
            {
                bindingContext.ModelState.AddModelError("storage_plugin", ValidationResources.StoragePluginNotFoundError);
                return(null);
            }

            Type modelType = storagePlugin.GetAccountConfigurationModel().GetType();

            if (!String.IsNullOrEmpty(bindingContext.ModelName) && !bindingContext.ValueProvider.ContainsPrefix(bindingContext.ModelName))
            {
                if (!bindingContext.FallbackToEmptyPrefix)
                {
                    return(null);
                }

                bindingContext = new ModelBindingContext
                {
                    ModelMetadata  = bindingContext.ModelMetadata,
                    ModelState     = bindingContext.ModelState,
                    PropertyFilter = bindingContext.PropertyFilter,
                    ValueProvider  = bindingContext.ValueProvider
                };
            }

            //object model = bindingContext.Model ?? CreateModel(controllerContext, bindingContext, bindingContext.ModelType);
            object model = bindingContext.Model ?? CreateModel(controllerContext, bindingContext, modelType);

            bindingContext = new ModelBindingContext
            {
                //ModelMetadata = ModelMetadataProviders.Current.GetMetadataForType(() => model, bindingContext.ModelType),
                ModelMetadata  = ModelMetadataProviders.Current.GetMetadataForType(() => model, modelType),
                ModelName      = bindingContext.ModelName,
                ModelState     = bindingContext.ModelState,
                PropertyFilter = bindingContext.PropertyFilter,
                ValueProvider  = bindingContext.ValueProvider
            };

            if (OnModelUpdating(controllerContext, bindingContext))
            {
                foreach (PropertyDescriptor descriptor in GetFilteredModelProperties(controllerContext, bindingContext))
                {
                    BindProperty(controllerContext, bindingContext, descriptor);
                }

                OnModelUpdated(controllerContext, bindingContext);
            }

            return(model);
        }
 public StorageAccountController(IStoragePluginsService storagePluginsService, IStorageAccountService storageAccountService, ICacheService cacheService)
 {
     _storagePluginsService = storagePluginsService;
     _storageAccountService = storageAccountService;
     _cacheService = cacheService;
 }