Example #1
0
 private Task ProduceTagsAsync(
     TaggerContext <IClassificationTag> context, DocumentSnapshotSpan snapshotSpan,
     IClassificationService classificationService, ClassificationOptions options, ClassificationType type, CancellationToken cancellationToken)
 {
     return(ClassificationUtilities.ProduceTagsAsync(
                context, snapshotSpan, classificationService, _owner._typeMap, options, type, cancellationToken));
 }
Example #2
0
 public InventoryReport(HoldingService holdingService, IClassificationService classificationService, BranchService branchService)
 {
     this.holdingService        = holdingService;
     this.classificationService = classificationService;
     this.branchService         = branchService;
     congress = new LibraryOfCongress();
 }
        //private readonly ILogger logger;

        public EArchiveController(IHttpContextAccessor accessor,
                                  IMapper mapper,
                                  IMailArchiveService mailArchiveService,
                                  IWorkPlaceService workPlaceService,
                                  IClassificationService classificationService,
                                  IMailTypeService mailTypeService,
                                  IPostTypeService postTypeService,
                                  ISecurityService securityService,
                                  IStatusService statusService,
                                  IImageArchiveService imageArchiveService,
                                  IUserService userService
                                  //ILogger logger
                                  ) : base(accessor, userService)
        {
            this.accessor              = accessor;
            this.mapper                = mapper;
            this.mailArchiveService    = mailArchiveService;
            this.workPlaceService      = workPlaceService;
            this.classificationService = classificationService;
            this.mailTypeService       = mailTypeService;
            this.postTypeService       = postTypeService;
            this.securityService       = securityService;
            this.statusService         = statusService;
            this.imageArchiveService   = imageArchiveService;
            //this.logger = logger;
        }
Example #4
0
 public Service(IDocumentService documentService, IProcessService processService, ISubProcessService subProcessService, IClassificationService classificationService)
 {
     this.documentService = documentService;
     this.processService = processService;
     this.subProcessService = subProcessService;
     this.classificationService = classificationService;
 }
Example #5
0
 public Service(IProcessService processService, ISubProcessService subProcessService, IClassificationService classificationService, IRoleService roleService)
 {
     this.subProcessService = subProcessService;
     this.processService = processService;
     this.classificationService = classificationService;
     this.roleService = roleService;
 }
 public ClassificationController(IClassificationService classificationService, ISubProcessService subProcessService, IProcessService processService)
 {
     this.classificationService = classificationService;
     this.subProcessService = subProcessService;
     this.processService = processService;
     this.service = new Service(this.subProcessService);
 }
Example #7
0
 public InventoryReport(IRepository <Holding> holdingRepo, IClassificationService classificationService, IRepository <Branch> branchRepo)
 {
     this.holdingRepo           = holdingRepo;
     this.branchRepo            = branchRepo;
     this.classificationService = classificationService;
     congress = new LibraryOfCongress();
 }
        public void Persists()
        {
            service.AddBook("QA123", "The Trial", "Kafka, Franz", "1927");

            service = new MasterClassificationService();
            AssertBook(service.Retrieve("QA123"), "QA123", "The Trial", "Kafka, Franz", "1927");
        }
Example #9
0
 public BusinessController(ILoggingService loggingService, IUnitOfWorkManager unitOfWorkManager, IMembershipService membershipService,
                           IRoleService roleService, ISettingsService settingsService, IBusinessService businessService, IClassificationService classificationService)
     : base(loggingService, unitOfWorkManager, membershipService, roleService, settingsService)
 {
     _businessService       = businessService;
     _classificationService = classificationService;
 }
        private static async Task ClassifySpansAsync(
            TaggerContext <IClassificationTag> context,
            DocumentSnapshotSpan spanToTag,
            IClassificationService classificationService,
            ClassificationTypeMap typeMap)
        {
            try
            {
                var document     = spanToTag.Document;
                var snapshotSpan = spanToTag.SnapshotSpan;
                var snapshot     = snapshotSpan.Snapshot;

                var cancellationToken = context.CancellationToken;
                using (Logger.LogBlock(FunctionId.Tagger_SemanticClassification_TagProducer_ProduceTags, cancellationToken))
                {
                    var classifiedSpans = ClassificationUtilities.GetOrCreateClassifiedSpanList();

                    await AddSemanticClassificationsAsync(
                        document, snapshotSpan.Span.ToTextSpan(), classificationService, classifiedSpans, cancellationToken : cancellationToken).ConfigureAwait(false);

                    ClassificationUtilities.Convert(typeMap, snapshotSpan.Snapshot, classifiedSpans, context.AddTag);
                    ClassificationUtilities.ReturnClassifiedSpanList(classifiedSpans);

                    var version = await document.Project.GetDependentSemanticVersionAsync(cancellationToken).ConfigureAwait(false);

                    // Let the context know that this was the span we actually tried to tag.
                    context.SetSpansTagged(SpecializedCollections.SingletonEnumerable(spanToTag));
                    context.State = version;
                }
            }
            catch (Exception e) when(FatalError.ReportAndPropagateUnlessCanceled(e))
            {
                throw ExceptionUtilities.Unreachable;
            }
        }
        public static async Task ProduceTagsAsync(
            TaggerContext <IClassificationTag> context,
            DocumentSnapshotSpan spanToTag,
            IClassificationService classificationService,
            ClassificationTypeMap typeMap)
        {
            var document = spanToTag.Document;

            if (document == null)
            {
                return;
            }

            var classified = await TryClassifyContainingMemberSpanAsync(
                context, spanToTag, classificationService, typeMap).ConfigureAwait(false);

            if (classified)
            {
                return;
            }

            // We weren't able to use our specialized codepaths for semantic classifying.
            // Fall back to classifying the full span that was asked for.
            await ClassifySpansAsync(
                context, spanToTag, classificationService, typeMap).ConfigureAwait(false);
        }
Example #12
0
        public static CheckoutPolicy RetrievePolicy(string barcode, IClassificationService classificationService)
        {
            var classification = Holding.ClassificationFromBarcode(barcode);
            var material       = classificationService.Retrieve(classification);

            return(material.CheckoutPolicy);
        }
        private static async Task AddSemanticClassificationsAsync(
            Document document,
            TextSpan textSpan,
            IClassificationService classificationService,
            ArrayBuilder <ClassifiedSpan> classifiedSpans,
            CancellationToken cancellationToken)
        {
            var workspaceStatusService = document.Project.Solution.Workspace.Services.GetRequiredService <IWorkspaceStatusService>();

            // Importantly, we do not await/wait on the fullyLoadedStateTask.  We do not want to ever be waiting on work
            // that may end up touching the UI thread (As we can deadlock if GetTagsSynchronous waits on us).  Instead,
            // we only check if the Task is completed.  Prior to that we will assume we are still loading.  Once this
            // task is completed, we know that the WaitUntilFullyLoadedAsync call will have actually finished and we're
            // fully loaded.
            var isFullyLoadedTask = workspaceStatusService.IsFullyLoadedAsync(cancellationToken);
            var isFullyLoaded     = isFullyLoadedTask.IsCompleted && isFullyLoadedTask.GetAwaiter().GetResult();

            // If we're not fully loaded try to read from the cache instead so that classifications appear up to date.
            // New code will not be semantically classified, but will eventually when the project fully loads.
            if (await TryAddSemanticClassificationsFromCacheAsync(document, textSpan, classifiedSpans, isFullyLoaded, cancellationToken).ConfigureAwait(false))
            {
                return;
            }

            await classificationService.AddSemanticClassificationsAsync(
                document, textSpan, classifiedSpans, cancellationToken).ConfigureAwait(false);
        }
Example #14
0
 public DevicesController(IDeviceService deviceService, IClassificationService classificationService, IDeviceLocationService locationService, IDetailedStatusService statusService, IDeviceModelService modelService)
 {
     _deviceService         = deviceService;
     _classificationService = classificationService;
     _locationService       = locationService;
     _statusService         = statusService;
     _modelService          = modelService;
 }
Example #15
0
 private static void AddClassifiedSpansForTokens(
     IClassificationService classificationService,
     SnapshotSpan span,
     List <ClassifiedSpan> classifiedSpans)
 {
     classificationService.AddLexicalClassifications(
         span.Snapshot.AsText(), span.Span.ToTextSpan(), classifiedSpans, CancellationToken.None);
 }
Example #16
0
 public ScanStation(int branchId, IClassificationService classificationService, IRepository <Holding> holdingRepo, IRepository <Patron> patronRepo)
 {
     this.classificationService = classificationService;
     this.holdingRepo           = holdingRepo;
     this.patronRepo            = patronRepo;
     BranchId = branchId;
     brId     = BranchId;
 }
Example #17
0
 public ScanStation(LibraryContext _context, int branchId, IClassificationService classificationService,
                    HoldingsService holdingsService, PatronsService patronsService)
 {
     this.classificationService = classificationService;
     this.holdingsService       = holdingsService;
     this.patronsService        = patronsService;
     BranchId = branchId;
     brId     = BranchId;
 }
Example #18
0
 public WorkflowController(IWorkflowService workflowService, IProcessService processService, ISubProcessService subProcessService, IClassificationService classificationService, IRoleService roleService)
 {
     this.workflowService = workflowService;
     this.processService = processService;
     this.subProcessService= subProcessService;;
     this.classificationService= classificationService;
     this.roleService = roleService;
     this.service = new Service(this.processService, this.subProcessService, this.classificationService, this.roleService);
 }
 public ClassificationController(IClassificationService classificationService,
                                 IQualityAlertService qualityAlertService,
                                 IPermissionService permissionService,
                                 IWorkContext workContext)
 {
     _classificationService = classificationService;
     _qualityAlertService   = qualityAlertService;
     _permissionService     = permissionService;
     _workContext           = workContext;
 }
 public WorkflowMappingController(IProcessService processService, ISubProcessService subProcessService, IClassificationService classificationService, IWorkflowService workflowService, IDocumentMappingService documentMappingService, IDocumentService documentService, INodeService nodeService)
 {
     this.processService = processService;
     this.subProcessService = subProcessService;
     this.classificationService = classificationService;
     this.workflowService = workflowService;
     this.documentMappingService = documentMappingService;
     this.documentService = documentService;
     this.nodeService = nodeService;
     this.service = new Service(documentService, processService, subProcessService, classificationService);
 }
 public DeviceEventService(IBaseService <DeviceEventData> baseService,
                           IClassificationService classificationService,
                           IDeviceLocationService locationService,
                           IDetailedStatusService detailedStatusService,
                           IMapper mapper)
 {
     _deviceEventService    = baseService;
     _groupService          = classificationService;
     _locationService       = locationService;
     _detailedStatusService = detailedStatusService;
     _mapper = mapper;
 }
 public DeviceFileController(Stream stream,
                             IDetailedStatusService statusService,
                             IClassificationService classificationService,
                             IDeviceModelService deviceModelService,
                             IDeviceLocationService deviceLocationService,
                             IDeviceService deviceService)
 {
     _stream                = stream;
     _devices               = new Dictionary <string, List <Device> >();
     _statusService         = statusService;
     _groupService          = classificationService;
     _deviceModelService    = deviceModelService;
     _deviceLocationService = deviceLocationService;
     _deviceService         = deviceService;
 }
Example #23
0
        public FilesController(IDetailedStatusService statusService,
                               IClassificationService classification,
                               IDeviceModelService modelService,
                               IDeviceLocationService locationSerivce,
                               IDeviceService deviceService,
                               IConfiguration configuration)
        {
            _statusService         = statusService;
            _groupingService       = classification;
            _deviceModelService    = modelService;
            _deviceLocationService = locationSerivce;
            _deviceService         = deviceService;

            _documentStoragePath = configuration["DocumentStorage"];
        }
            private void AddClassifiedSpans(
                IClassificationService classificationService,
                SnapshotSpan span,
                List <ClassifiedSpan> classifiedSpans)
            {
                // First, get the tree and snapshot that we'll be operating over.
                // From this point on we'll do all operations over these values.
                ITextSnapshot lastSnapshot;
                Document      lastDocument;
                object        lastCachedData;

                lock (_gate)
                {
                    lastSnapshot   = _lastProcessedSnapshot;
                    lastDocument   = _lastProcessedDocument;
                    lastCachedData = _lastProcessedCachedData;
                }

                if (lastDocument == null)
                {
                    // We don't have a syntax tree yet.  Just do a lexical classification of the document.
                    AddClassifiedSpansForTokens(classificationService, span, classifiedSpans);
                    return;
                }

                // We have a tree.  However, the tree may be for an older version of the snapshot.
                // If it is for an older version, then classify that older version and translate
                // the classifications forward.  Otherwise, just classify normally.

                if (lastSnapshot.Version.ReiteratedVersionNumber == span.Snapshot.Version.ReiteratedVersionNumber)
                {
                    AddClassifiedSpansForCurrentTree(
                        classificationService, span, lastDocument, classifiedSpans);
                }
                else
                {
                    // Slightly more complicated.  We have a parse tree, it's just not for the snapshot
                    // we're being asked for.
                    AddClassifiedSpansForPreviousTree(
                        classificationService, span, lastSnapshot, lastDocument, classifiedSpans);
                }

                // Ensure the cached data stays alive for as long as we're calling into the classification service to do
                // the computation.
                GC.KeepAlive(lastCachedData);
            }
Example #25
0
 public AnalyzerController(
     IMailRepository mailKitRepository,
     IClassificationService classificationService,
     IInformationExtractorService informationExtractorService,
     ITextPreparerService textPreparerService,
     IGrannyRepository grannyRepository,
     IGrannyModelAccessorService grannyModelAccessorService,
     IRawEmailsRepository rawEmailsRepository)
 {
     _mailKitRepository           = mailKitRepository;
     _classificationService       = classificationService;
     _informationExtractorService = informationExtractorService;
     _textPreparerService         = textPreparerService;
     _grannyRepository            = grannyRepository;
     _grannyModelAccessorService  = grannyModelAccessorService;
     _rawEmailsRepository         = rawEmailsRepository;
 }
Example #26
0
 public ArchiveController(IHttpContextAccessor accessor,
                          IMapper mapper,
                          IClassificationService classification,
                          IMailTypeService mailType,
                          IPostTypeService postType,
                          ISecurityService security,
                          IStatusService status,
                          IUserService userService) : base(accessor, userService)
 {
     this.mapper         = mapper;
     this.classification = classification;
     this.mailType       = mailType;
     this.postType       = postType;
     this.security       = security;
     this.status         = status;
     this.userService    = userService;
 }
        public static async Task ProduceTagsAsync(
            TaggerContext <IClassificationTag> context,
            DocumentSnapshotSpan spanToTag,
            IClassificationService classificationService,
            ClassificationTypeMap typeMap
            )
        {
            var document = spanToTag.Document;

            if (document == null)
            {
                return;
            }

            // Don't block getting classifications on building the full compilation.  This may take a significant amount
            // of time and can cause a very latency sensitive operation (copying) to block the user while we wait on this
            // work to happen.
            //
            // It's also a better experience to get classifications to the user faster versus waiting a potentially
            // large amount of time waiting for all the compilation information to be built.  For example, we can
            // classify types that we've parsed in other files, or partially loaded from metadata, even if we're still
            // parsing/loading.  For cross language projects, this also produces semantic classifications more quickly
            // as we do not have to wait on skeletons to be built.

            document  = document.WithFrozenPartialSemantics(context.CancellationToken);
            spanToTag = new DocumentSnapshotSpan(document, spanToTag.SnapshotSpan);

            var classified = await TryClassifyContainingMemberSpanAsync(
                context,
                spanToTag,
                classificationService,
                typeMap
                )
                             .ConfigureAwait(false);

            if (classified)
            {
                return;
            }

            // We weren't able to use our specialized codepaths for semantic classifying.
            // Fall back to classifying the full span that was asked for.
            await ClassifySpansAsync(context, spanToTag, classificationService, typeMap)
            .ConfigureAwait(false);
        }
 public TransactionController(IWorkflowService workflowService, 
                    IProcessService processService, 
                    ISubProcessService subProcessService, 
                    IClassificationService classificationService, INodeService nodeService,
                    IDocumentMappingService documentMappingService,
                    IWorkflowMappingService workflowMappingService,
                    INotificationMappingService notificationMappingService )
 {
     this.workflowService = workflowService;
     this.processService = processService;
     this.subProcessService= subProcessService;;
     this.classificationService= classificationService;
     this.documentMappingService = documentMappingService;
     this.notificationMappingService = notificationMappingService;
     this.workflowMappingService = workflowMappingService;
     this.nodeService = nodeService;
     this.service = new Service(this.processService, this.subProcessService, this.classificationService);
 }
        public ScanStation_WhenNewMaterialCheckedOutTest(DbContextFixture fixture)
        {
            fixture.Seed();
            context         = new LibraryContext(fixture.ContextOptions);
            holdingsService = new HoldingsService(context);
            patronsService  = new PatronsService(context);

            classificationServiceMock = new Mock <IClassificationService>();
            classificationService     = classificationServiceMock.Object;

            scanner = new ScanStation(context, 1, classificationService, holdingsService, patronsService);

            savedPatronId = patronsService.Create(new Patron {
                Name = ""
            });

            CheckOutNewMaterial();
        }
        public ScanStation_WhenNothingCheckedOutTest(DbContextFixture fixture)
        {
            fixture.Seed();
            context         = new LibraryContext(fixture.ContextOptions);
            patronsService  = new PatronsService(context);
            holdingsService = new HoldingsService(context);

            classificationServiceMock = new Mock <IClassificationService>();
            classificationService     = classificationServiceMock.Object;
            AlwaysReturnBookMaterial(classificationServiceMock);

            somePatronId = patronsService.Create(new Patron {
                Name = "x"
            });

            scanner = new ScanStation(context, 1, classificationService, new HoldingsService(context),
                                      new PatronsService(context));
        }
Example #31
0
        private static async Task ClassifySpansAsync(
            TaggerContext <IClassificationTag> context,
            DocumentSnapshotSpan spanToTag,
            IClassificationService classificationService,
            ClassificationTypeMap typeMap,
            ClassificationOptions options,
            CancellationToken cancellationToken)
        {
            try
            {
                var document     = spanToTag.Document;
                var snapshotSpan = spanToTag.SnapshotSpan;
                var snapshot     = snapshotSpan.Snapshot;

                using (Logger.LogBlock(FunctionId.Tagger_SemanticClassification_TagProducer_ProduceTags, cancellationToken))
                {
                    using var _ = ArrayBuilder <ClassifiedSpan> .GetInstance(out var classifiedSpans);

                    await classificationService.AddSemanticClassificationsAsync(
                        document,
                        snapshotSpan.Span.ToTextSpan(),
                        options,
                        classifiedSpans,
                        cancellationToken).ConfigureAwait(false);

                    foreach (var span in classifiedSpans)
                    {
                        context.AddTag(ClassificationUtilities.Convert(typeMap, snapshotSpan.Snapshot, span));
                    }

                    var version = await document.Project.GetDependentSemanticVersionAsync(cancellationToken).ConfigureAwait(false);

                    // Let the context know that this was the span we actually tried to tag.
                    context.SetSpansTagged(SpecializedCollections.SingletonEnumerable(spanToTag));
                    context.State = version;
                }
            }
            catch (Exception e) when(FatalError.ReportAndPropagateUnlessCanceled(e, cancellationToken))
            {
                throw ExceptionUtilities.Unreachable;
            }
        }
Example #32
0
        public ClassificationModule(IClassificationService classificationService) : base("lookup")
        {
            this._classificationService = classificationService;

            this.Get(
                "/classifications",
                parameters =>
            {
                try
                {
                    var classifications = this._classificationService.Get().ToList();

                    return(this.GetJsonResponse(classifications));
                }
                catch (Exception e)
                {
                    return(this.Negotiate.WithStatusCode(HttpStatusCode.InternalServerError));
                }
            });
        }
Example #33
0
        public InvestecOpenBankingClient(IOptions <InvestecOpenBankingClientOptions> optionsAccessor,
                                         IClassificationService classificationService)
        {
            if (optionsAccessor == null)
            {
                throw new ArgumentNullException(nameof(optionsAccessor));
            }

            _options = optionsAccessor.Value;
            _classificationService = classificationService;
            _httpClient            = new HttpClient(
                new AuthenticatedHttpClientHandler(GetAccessToken))
            {
                Timeout     = TimeSpan.FromMinutes(1),
                BaseAddress = new Uri(InvestecOpenBankingClientConstants.ApiUrl)
            };

            _identityEndpoint = RestService.For <IIdentity>(InvestecOpenBankingClientConstants.BaseUrl);
            _accountsEndpoint = RestService.For <IAccounts>(_httpClient);
        }
        public void Initialize()
        {
            classificationService = new StubClassificationService();
            classificationService.AddBook(Classification1, "T1", "A1", "2001");
            classificationService.AddBook(Classification2, "T2", "A2", "2002");

            scanner = new ScanStation(Branch1Id, classificationService);

            holdingService = new HoldingService();
            holdingService.DeleteAllHoldings();

            patronService = new PatronService();
            PatronService.DeleteAllPatrons();

            patronId1 = patronService.Add("Joe");
            patronId2 = patronService.Add("Jane");

            var holding = scanner.AddNewMaterial(Isbn1);

            Assert.That(holding.Barcode, Is.EqualTo(barcode1));
        }
Example #35
0
            private void AddClassifiedSpansForCurrentTree(
                IClassificationService classificationService,
                SnapshotSpan span,
                Document document,
                List <ClassifiedSpan> classifiedSpans)
            {
                if (!_lastLineCache.TryUseCache(span, out var tempList))
                {
                    tempList = ClassificationUtilities.GetOrCreateClassifiedSpanList();

                    classificationService.AddSyntacticClassificationsAsync(
                        document, span.Span.ToTextSpan(), tempList, CancellationToken.None).Wait(CancellationToken.None);

                    _lastLineCache.Update(span, tempList);
                }

                // simple case.  They're asking for the classifications for a tree that we already have.
                // Just get the results from the tree and return them.

                classifiedSpans.AddRange(tempList);
            }
        public ScanStation_WhenMaterialCheckedInTest(DbContextFixture fixture)
        {
            fixture.Seed();
            context         = new LibraryContext(fixture.ContextOptions);
            patronsService  = new PatronsService(context);
            holdingsService = new HoldingsService(context);

            classificationServiceMock = new Mock <IClassificationService>();
            classificationService     = classificationServiceMock.Object;

            somePatronId = patronsService.Create(new Patron {
                Name = "x"
            });

            scanner = new ScanStation(context, 1, classificationService, holdingsService, patronsService);

            scanner.ScanNewMaterial(SomeBarcode, classificationServiceMock);
            scanner.CheckOut(SomeBarcode, somePatronId, now);
            scanner.CompleteCheckout();
            scanner.CheckIn(SomeBarcode, now);
        }