コード例 #1
0
 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));
 }
コード例 #2
0
        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);
        }
コード例 #3
0
ファイル: JobHelper.cs プロジェクト: vdedyukhin/browsecloud
        /// <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);
            }
        }
コード例 #4
0
 public CouchDbPermissionStore(
     IDocumentDbService dbService,
     ILogger logger,
     IEventContextResolverService eventContextResolverService,
     IIdentifierFormatter identifierFormatter) : base(dbService, logger, eventContextResolverService, identifierFormatter)
 {
 }
コード例 #5
0
        /// <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;
        }
コード例 #6
0
        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);
        }
コード例 #7
0
 public UserNodeViewModel(User user, UsersNodeViewModel parent)
     : base(parent, parent.MessengerInstance, true)
 {
     User       = user;
     _parent    = parent;
     _dbService = SimpleIoc.Default.GetInstance <IDocumentDbService>();
 }
コード例 #8
0
 public UsersNodeViewModel(Database database, DatabaseNodeViewModel parent)
     : base(parent, parent.MessengerInstance, true)
 {
     Database   = database;
     _parent    = parent;
     _dbService = SimpleIoc.Default.GetInstance <IDocumentDbService>();
 }
コード例 #9
0
 protected CouchDbGenericStore(IDocumentDbService dbService, ILogger logger,
                               IEventContextResolverService eventContextResolverService)
 {
     _dbService = dbService;
     _logger    = logger;
     _eventContextResolverService = eventContextResolverService ??
                                    throw new ArgumentNullException(nameof(eventContextResolverService));
 }
コード例 #10
0
 public CouchDbUserStore(
     IDocumentDbService dbService,
     ILogger logger,
     IEventContextResolverService eventContextResolverService,
     IIdentifierFormatter identifierFormatter) : base(dbService, logger, eventContextResolverService)
 {
     _identifierFormatter = identifierFormatter;
 }
コード例 #11
0
        public AuditedDocumentDbService(IDocumentDbService documentDbService, DbInfo dbInfo, RequestContext requestContext, bool useNeutralGroup)
        {
            _documentDbService = documentDbService;
            _collectionId      = dbInfo.CollectionId;

            _requestContext  = requestContext;
            _useNeutralGroup = useNeutralGroup;
        }
コード例 #12
0
 public UserEditViewModel(IMessenger messenger, IDocumentDbService dbService, IDialogService dialogService, IUIServices uiServices)
     : base(messenger, uiServices)
 {
     _dbService     = dbService;
     _dialogService = dialogService;
     Header         = "New User";
     Title          = "User";
 }
コード例 #13
0
 protected FormattableIdentifierStore(
     IDocumentDbService dbService,
     ILogger logger,
     IEventContextResolverService eventContextResolverService,
     IIdentifierFormatter identifierFormatter
     ) : base(dbService, logger, eventContextResolverService)
 {
     IdentifierFormatter = identifierFormatter;
 }
コード例 #14
0
 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();
 }
コード例 #15
0
 public TestEventDbService(string groupId, IDocumentDbService documentDbService)
     : base(documentDbService,
            new DbInfo {
     DatabaseId = "YawnMassagedb", EventsCollectionId = "YawnMassage_events"
 },
            new RequestContext {
     GroupId = groupId, UserId = "unit-test-user", UserDisplayName = ""
 })
 {
 }
コード例 #16
0
 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();
 }
コード例 #17
0
 public CouchDbBootstrapper(
     IDocumentDbService documentDbService,
     ICouchDbSettings couchDbSettings,
     ILogger logger)
 {
     _couchDbSettings   = couchDbSettings;
     _dbConnectionInfo  = MakeDbConnectionInfo();
     _documentDbService = documentDbService;
     _logger            = logger ?? throw new ArgumentNullException(nameof(logger));
 }
コード例 #18
0
 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;
 }
コード例 #19
0
 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)
 {
 }
コード例 #20
0
 public CouchDbGroupStore(
     IDocumentDbService dbService,
     ILogger logger,
     IEventContextResolverService eventContextResolverService,
     IIdentifierFormatter identifierFormatter,
     IRoleStore roleStore,
     IUserStore userStore) : base(dbService, logger, eventContextResolverService, identifierFormatter)
 {
     _roleStore = roleStore;
     _userStore = userStore;
 }
コード例 #21
0
 public TestSystemDataContext(IDocumentDbService documentDbService)
     : base(documentDbService,
            new DbInfo {
     DatabaseId = "YawnMassagedb", CollectionId = "YawnMassage_default"
 },
            new RequestContext {
     UserId = "unit-test-user", UserDisplayName = ""
 },
            useNeutralGroup: true)
 {
 }
コード例 #22
0
        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);
        }
コード例 #23
0
        public DatabaseViewModel(IMessenger messenger, IDocumentDbService dbService, ISettingsService settingsService, IUIServices uiServices)
            : base(messenger, uiServices)
        {
            Header    = "Connections";
            Title     = Header;
            IsVisible = true;

            _dbService       = dbService;
            _settingsService = settingsService;

            RegisterMessages();
        }
コード例 #24
0
 /// <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;
 }
コード例 #25
0
        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;
        }
コード例 #26
0
 /// <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;
 }
コード例 #27
0
        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);
        }
コード例 #28
0
ファイル: JobHelper.cs プロジェクト: vdedyukhin/browsecloud
        /// <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()}.");
        }
コード例 #29
0
        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();
        }
コード例 #30
0
        /// <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;
        }