public AuditingDocumentDbService(IUserResolverService userResolverService, IEventService eventService, Decorator <IDocumentDbService> decorator, ISerializationSettings serializationSettings) { _serializationSettings = serializationSettings; _eventService = eventService ?? throw new ArgumentNullException(nameof(eventService)); _innerDocumentDbService = decorator.Instance ?? throw new ArgumentNullException(nameof(decorator)); _userResolveService = userResolverService ?? throw new ArgumentNullException(nameof(userResolverService)); }
public QueryEditorViewModel(IMessenger messenger, IDocumentDbService dbService, IDialogService dialogService, IUIServices uiServices) : base(messenger, uiServices) { EditorViewModel = SimpleIoc.Default.GetInstanceWithoutCaching <JsonViewerViewModel>(); EditorViewModel.IsReadOnly = true; HeaderViewModel = SimpleIoc.Default.GetInstanceWithoutCaching <HeaderEditorViewModel>(); HeaderViewModel.IsReadOnly = true; _dbService = dbService; _dialogService = dialogService; _requestChargeStatusBarItem = new StatusBarItem(new StatusBarItemContext { Value = RequestCharge, IsVisible = IsRunning }, StatusBarItemType.SimpleText, "Request Charge", System.Windows.Controls.Dock.Left); StatusBarItems.Add(_requestChargeStatusBarItem); _queryInformationStatusBarItem = new StatusBarItem(new StatusBarItemContext { Value = QueryInformation, IsVisible = IsRunning }, StatusBarItemType.SimpleText, "Information", System.Windows.Controls.Dock.Left); StatusBarItems.Add(_queryInformationStatusBarItem); _progessBarStatusBarItem = new StatusBarItem(new StatusBarItemContextCancellableCommand { Value = CancelCommand, IsVisible = IsRunning, IsCancellable = true }, StatusBarItemType.ProgessBar, "Progress", System.Windows.Controls.Dock.Left); StatusBarItems.Add(_progessBarStatusBarItem); }
/// <summary> /// Delete all jobs and model files associated with a document. /// </summary> /// <param name="doc">Document to delete jobs for.</param> /// <param name="docDbService">IDocDbService.</param> /// <param name="storageService">IStorageService.</param> /// <param name="batchService">Azure Batch Service</param> /// <param name="logger">Logger</param> /// <returns></returns> public static async Task DeleteJobsAndResourcesFromDoc(Document doc, IDocumentDbService docDbService, IStorageService storageService, IBatchService batchService, ILogger logger) { Contract.Requires(docDbService != null, nameof(docDbService)); Contract.Requires(doc != null, nameof(doc)); var jobs = await docDbService.GetDocuments <BatchJob>((j) => j.DocumentId == doc.Id); List <Task> taskList = new List <Task>(); foreach (var job in jobs) { taskList.Add(DeleteJobAndResources(job, docDbService, storageService, batchService, logger)); } try { await Task.WhenAll(taskList); } catch (AggregateException ex) { var message = $"Not able to delete {ex.InnerExceptions.Count} of the {taskList.Count} jobs for document {doc.Id}."; foreach (var e in ex.InnerExceptions) { message += $" {e.Message}"; } throw new BrowseCloudServiceException(message); } }
public CouchDbPermissionStore( IDocumentDbService dbService, ILogger logger, IEventContextResolverService eventContextResolverService, IIdentifierFormatter identifierFormatter) : base(dbService, logger, eventContextResolverService, identifierFormatter) { }
/// <summary> /// Initialises a new instance of the <see cref="DocumentDbAccess"/> class for testing. /// </summary> /// <param name="dbConfig">The database config,</param> /// <param name="configManager">The document config manager.</param> /// <param name="documentClient">The document client.</param> /// <param name="dbService">The document db service.</param> /// <param name="queryPolicy">The document query policy.</param> /// <remarks> /// <para>This constructor should be used for internal testing only.</para> /// </remarks> internal DocumentDbAccess( DocumentDbConfig dbConfig, ServiceDbConfigManager configManager, IDocumentClient documentClient, IDocumentDbService dbService, IDocumentQueryPolicy queryPolicy) { if (dbConfig == null) { throw new ArgumentNullException(nameof(dbConfig)); } if (configManager == null) { throw new ArgumentNullException(nameof(configManager)); } if (documentClient == null) { throw new ArgumentNullException(nameof(documentClient)); } if (dbService == null) { throw new ArgumentNullException(nameof(dbService)); } if (queryPolicy == null) { throw new ArgumentNullException(nameof(queryPolicy)); } _dbConfig = dbConfig; _configManager = configManager; _queryPolicy = queryPolicy; _client = documentClient; _dbService = dbService; }
protected IDocumentDbService DbService() { if (dbService == null) { ICouchDbSettings config = new CouchDbSettings() { DatabaseName = "integration-" + DateTime.UtcNow.Ticks, Username = "", Password = "", Server = "http://127.0.0.1:5984" }; var couchDbServer = Environment.GetEnvironmentVariable(CouchDbServerEnvironmentVariable); if (!string.IsNullOrEmpty(couchDbServer)) { config.Server = couchDbServer; } var innerDbService = new CouchDbAccessService(config, new Mock <ILogger>().Object); innerDbService.Initialize().Wait(); innerDbService.AddViews("roles", CouchDbRoleStore.GetViews()).Wait(); innerDbService.AddViews("permissions", CouchDbPermissionStore.GetViews()).Wait(); var auditingDbService = new AuditingDocumentDbService(new Mock <IEventService>().Object, innerDbService); var cachingDbService = new CachingDocumentDbService(auditingDbService, new MemoryCache(new MemoryCacheOptions())); dbService = cachingDbService; } return(dbService); }
public UserNodeViewModel(User user, UsersNodeViewModel parent) : base(parent, parent.MessengerInstance, true) { User = user; _parent = parent; _dbService = SimpleIoc.Default.GetInstance <IDocumentDbService>(); }
public UsersNodeViewModel(Database database, DatabaseNodeViewModel parent) : base(parent, parent.MessengerInstance, true) { Database = database; _parent = parent; _dbService = SimpleIoc.Default.GetInstance <IDocumentDbService>(); }
protected CouchDbGenericStore(IDocumentDbService dbService, ILogger logger, IEventContextResolverService eventContextResolverService) { _dbService = dbService; _logger = logger; _eventContextResolverService = eventContextResolverService ?? throw new ArgumentNullException(nameof(eventContextResolverService)); }
public CouchDbUserStore( IDocumentDbService dbService, ILogger logger, IEventContextResolverService eventContextResolverService, IIdentifierFormatter identifierFormatter) : base(dbService, logger, eventContextResolverService) { _identifierFormatter = identifierFormatter; }
public AuditedDocumentDbService(IDocumentDbService documentDbService, DbInfo dbInfo, RequestContext requestContext, bool useNeutralGroup) { _documentDbService = documentDbService; _collectionId = dbInfo.CollectionId; _requestContext = requestContext; _useNeutralGroup = useNeutralGroup; }
public UserEditViewModel(IMessenger messenger, IDocumentDbService dbService, IDialogService dialogService, IUIServices uiServices) : base(messenger, uiServices) { _dbService = dbService; _dialogService = dialogService; Header = "New User"; Title = "User"; }
protected FormattableIdentifierStore( IDocumentDbService dbService, ILogger logger, IEventContextResolverService eventContextResolverService, IIdentifierFormatter identifierFormatter ) : base(dbService, logger, eventContextResolverService) { IdentifierFormatter = identifierFormatter; }
public PermissionEditViewModel(IMessenger messenger, IDocumentDbService dbService, IDialogService dialogService, IUIServices uiServices) : base(messenger, uiServices) { _dbService = dbService; _dialogService = dialogService; Header = "New Permission"; Title = "Permission"; PropertyChanged += (s, e) => IsDirty = IsEntityChanged(); }
public TestEventDbService(string groupId, IDocumentDbService documentDbService) : base(documentDbService, new DbInfo { DatabaseId = "YawnMassagedb", EventsCollectionId = "YawnMassage_events" }, new RequestContext { GroupId = groupId, UserId = "unit-test-user", UserDisplayName = "" }) { }
protected AssetTabViewModelBase(IMessenger messenger, IDialogService dialogService, IDocumentDbService dbService, IUIServices uiServices) : base(messenger, uiServices) { Content = new TextDocument(GetDefaultContent()); _dialogService = dialogService; _dbService = dbService; Header = GetDefaultHeader(); Title = GetDefaultTitle(); ContentId = Guid.NewGuid().ToString(); }
public CouchDbBootstrapper( IDocumentDbService documentDbService, ICouchDbSettings couchDbSettings, ILogger logger) { _couchDbSettings = couchDbSettings; _dbConnectionInfo = MakeDbConnectionInfo(); _documentDbService = documentDbService; _logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
public AddCollectionViewModel(IMessenger messenger, IDialogService dialogService, IDocumentDbService dbService, IUIServices uiServices) : base(messenger, uiServices) { IsFixedStorage = true; Throughput = 400; Title = "New Collection"; _dbService = dbService; DatabaseNames = new ObservableCollection <string>(); _dialogService = dialogService; }
public TestGroupDataContext(string groupId, IDocumentDbService documentDbService) : base(documentDbService, new DbInfo { DatabaseId = "YawnMassagedb", CollectionId = "YawnMassage_default" }, new RequestContext { GroupId = groupId, UserId = "unit-test-user", UserDisplayName = "" }, useNeutralGroup: false) { }
public CouchDbGroupStore( IDocumentDbService dbService, ILogger logger, IEventContextResolverService eventContextResolverService, IIdentifierFormatter identifierFormatter, IRoleStore roleStore, IUserStore userStore) : base(dbService, logger, eventContextResolverService, identifierFormatter) { _roleStore = roleStore; _userStore = userStore; }
public TestSystemDataContext(IDocumentDbService documentDbService) : base(documentDbService, new DbInfo { DatabaseId = "YawnMassagedb", CollectionId = "YawnMassage_default" }, new RequestContext { UserId = "unit-test-user", UserDisplayName = "" }, useNeutralGroup: true) { }
public ImportDocumentViewModel(IMessenger messenger, IDialogService dialogService, IDocumentDbService dbService, IUIServices uiServices) : base(messenger, uiServices) { Content = new TextDocument(); _dialogService = dialogService; _dbService = dbService; _progessBarStatusBarItem = new StatusBarItem(new StatusBarItemContextCancellableCommand { Value = CancelCommand, IsVisible = IsRunning, IsCancellable = false }, StatusBarItemType.ProgessBar, "Progress", System.Windows.Controls.Dock.Left); StatusBarItems.Add(_progessBarStatusBarItem); }
public DatabaseViewModel(IMessenger messenger, IDocumentDbService dbService, ISettingsService settingsService, IUIServices uiServices) : base(messenger, uiServices) { Header = "Connections"; Title = Header; IsVisible = true; _dbService = dbService; _settingsService = settingsService; RegisterMessages(); }
/// <summary> /// Initializes a new instance of the <see cref="DocumentController"/> class. /// </summary> /// <param name="storageService">Azure Storage Location</param> /// <param name="docDbService">Document DB Service</param> /// <param name="batchService">Azure Batch</param> /// <param name="graphService">Graph Service</param> /// <param name="logger">Logger</param> /// <param name="config">General Config</param> public DocumentController( IStorageService storageService, IDocumentDbService docDbService, IBatchService batchService, IGraphService graphService, ILogger <DocumentController> logger, IOptions <GeneralConfig> config) : base(logger, config) { this.storageService = storageService; this.documentDbService = docDbService; this.batchService = batchService; this.graphService = graphService; }
public ScaleAndSettingsTabViewModel(IMessenger messenger, IDialogService dialogService, IDocumentDbService dbService, IUIServices uiServices) : base(messenger, uiServices) { Content = new TextDocument(); _textChangedObservable = Observable.FromEventPattern <EventArgs>(Content, nameof(Content.TextChanged)) .Select(evt => ((TextDocument)evt.Sender).Text) .Throttle(TimeSpan.FromMilliseconds(600)) .Where(text => !string.IsNullOrEmpty(text)) .DistinctUntilChanged() .Subscribe(OnContentTextChanged); _dbService = dbService; _dialogService = dialogService; }
/// <summary> /// Initializes a new instance of the <see cref="JobController"/> class. /// </summary> /// <param name="storageService">Azure Storage Location</param> /// <param name="docDbService">Document DB Service</param> /// <param name="batchService">Azure Batch</param> /// <param name="graphService">Graph Service</param> /// <param name="logger">Logger</param> /// <param name="hubContext">SignalR Hub Context</param> /// <param name="config">General Config</param> public JobController( IStorageService storageService, IDocumentDbService docDbService, IBatchService batchService, ILogger <JobController> logger, IOptions <GeneralConfig> config, IHubContext <JobUpdateHub> hubContext, IGraphService graphService) : base(logger, config) { this.storageService = storageService; this.documentDbService = docDbService; this.batchService = batchService; this.jobUpdateHubContext = hubContext; this.graphService = graphService; }
public StoredProcedureTabViewModel(IMessenger messenger, IDialogService dialogService, IDocumentDbService dbService, IUIServices uiServices) : base(messenger, dialogService, dbService, uiServices) { _dialogService = dialogService; _dbService = dbService; ResultViewModel = SimpleIoc.Default.GetInstanceWithoutCaching <JsonViewerViewModel>(); ResultViewModel.IsReadOnly = true; HeaderViewModel = SimpleIoc.Default.GetInstanceWithoutCaching <HeaderEditorViewModel>(); HeaderViewModel.IsReadOnly = true; _requestChargeStatusBarItem = new StatusBarItem(new StatusBarItemContext { Value = RequestCharge, IsVisible = IsBusy }, StatusBarItemType.SimpleText, "Request Charge", System.Windows.Controls.Dock.Left); StatusBarItems.Add(_requestChargeStatusBarItem); }
/// <summary> /// Delete job and model files. /// </summary> /// <param name="job">Job to delete.</param> /// <param name="docDbService">IDocDbService.</param> /// <param name="storageService">IStorageService.</param> /// <param name="batchService">Azure Batch Service</param> /// <param name="logger">Logger</param> /// <returns></returns> public static async Task DeleteJobAndResources(BatchJob job, IDocumentDbService docDbService, IStorageService storageService, IBatchService batchService, ILogger logger) { Contract.Requires(docDbService != null, nameof(docDbService)); Contract.Requires(storageService != null, nameof(storageService)); Contract.Requires(batchService != null, nameof(batchService)); Contract.Requires(job != null, nameof(job)); await RetryHelper.RetryTask(batchService.TerminateTask(job.Id.ToString())); logger.LogInformation($"Terminated batch job task for job {job.Id.ToString()}."); await RetryHelper.RetryTask(storageService.DeleteContainer(StorageAccount.Model, job.Id.ToString())); logger.LogInformation($"Deleted model data container for job {job.Id.ToString()}."); await RetryHelper.RetryTask(docDbService.DeleteDocument <BatchJob>(job.Id.ToString())); logger.LogInformation($"Deleted DocumentDB entity for job {job.Id.ToString()}."); }
public CollectionMetricsTabViewModel(IMessenger messenger, IUIServices uiServices, IDialogService dialogService, IDocumentDbService dbService) : base(messenger, uiServices) { _dbService = dbService; _dialogService = dialogService; Title = "Collection Metrics"; Header = Title; _requestChargeStatusBarItem = new StatusBarItem(new StatusBarItemContext { Value = RequestCharge, IsVisible = IsBusy }, StatusBarItemType.SimpleText, "Request Charge", System.Windows.Controls.Dock.Left); StatusBarItems.Add(_requestChargeStatusBarItem); ChartConfiguration(); }
/// <summary> /// Initialises a new instance of the <see cref="DocumentDbAccess"/> class. /// </summary> /// <param name="dbConfig">The database config.</param> /// <param name="configManager">The document config manager.</param> public DocumentDbAccess(DocumentDbConfig dbConfig, ServiceDbConfigManager configManager) { if (dbConfig == null) { throw new ArgumentNullException(nameof(dbConfig)); } if (configManager == null) { throw new ArgumentNullException(nameof(configManager)); } _dbConfig = dbConfig; _configManager = configManager; _queryPolicy = new DocumentQueryPolicy(); var dbService = new DocumentDbService(configManager, dbConfig); _dbService = dbService; _client = dbService.Client; }