Beispiel #1
0
        public IList <IBackgroundOperation> LoadOperations(string paramName)
        {
            string value = _settings.GetValueAsString(paramName);

            BackgroundOperationSettingsItem[] items = new BackgroundOperationSettingsItem[0];
            items = JsonConvert.DeserializeObject(value, items.GetType()) as BackgroundOperationSettingsItem[];

            if (items == null)
            {
                throw new InvalidOperationException("Item did not create the public url");
            }

            if (_factoryRagistry == null)
            {
                IUnityContainer container = ContainerConfiguration.GetContainer().Container;
                _factoryRagistry = container.Resolve <FileStorages.FactoryRagistry.IFactoryRagistry>();
            }
            List <IBackgroundOperation> result = new List <IBackgroundOperation>(items.Length);

            foreach (var item in items)
            {
                var operation = _factoryRagistry.ParseBackgroundOperation(item.Action, item.State, item.ServerName);
                if (operation != null)
                {
                    result.Add(operation);
                }
            }

            return(result);
        }
Beispiel #2
0
        public void SaveOperations(string paramName, IList <IBackgroundOperation> backgroundOperations)
        {
            var items = new BackgroundOperationSettingsItem[backgroundOperations.Count];

            int i = 0;

            foreach (var operation in backgroundOperations)
            {
                items[i] = new BackgroundOperationSettingsItem()
                {
                    ServerName = operation.RemoteFile.Account.ServerName,
                    State      = operation.ToString(),
                    Action     = operation.Action
                };
                i++;
            }

            _settings.SetValueAsString(paramName, JsonConvert.SerializeObject(items));
        }