コード例 #1
0
ファイル: Importer.cs プロジェクト: yanxuYX/examples
 private List <AnalysisMethod> GetAnalysisMethods()
 {
     using (var client = SamplesClient.CreateConnectedClient(Context.ServerUrl, Context.ApiToken))
     {
         return(client.Get(new GetAnalysisMethods()).DomainObjects);
     }
 }
コード例 #2
0
        private void Connect()
        {
            try
            {
                _client = SamplesClient.CreateConnectedClient(
                    serverTextBox.Text.Trim(),
                    apiTokenTextBox.Text.Trim());

                GetConnectionInfo();

                SaveConfig();

                ClearTripList();

                connectButton.Enabled     = false;
                disconnectButton.Enabled  = true;
                loadButton.Enabled        = true;
                serverTextBox.Enabled     = false;
                apiTokenTextBox.Enabled   = false;
                apiTokenLinkLabel.Enabled = false;
            }
            catch (Exception exception)
            {
                Disconnect();
                Error(exception);
            }
        }
コード例 #3
0
        public ImportClient(Context context)
        {
            _context = context;

            _httpClient      = GetInitializedHttpClient();
            _samplesClient   = SamplesClient.CreateConnectedClient(_context.ServerUrl, _context.ApiToken);
            _authHeaderValue = new AuthenticationHeaderValue("Token", _context.ApiToken);
        }
コード例 #4
0
        public void ForEachTest()
        {
            _fixture           = new Fixture();
            _mockServiceClient = Substitute.For <IServiceClient>();

            SetupMockClient();

            _client = SamplesClient.CreateTestClient(_mockServiceClient);
        }
コード例 #5
0
        private static void Validate(Context context, ValidationResult result)
        {
            var rules = RuleReader.ReadFromDefaultFile();

            if (!rules.Any())
            {
                throw new ArgumentException("No rules are found.");
            }

            Log.Info($"Got {rules.Count} rules from the file.");
            var validator = new Validator(rules);

            Log.Debug($"Connecting to server with URL {context.SamplesApiBaseUrl}.");

            using (var client = SamplesClient.CreateConnectedClient(context.SamplesApiBaseUrl, context.SamplesAuthToken))
            {
                var largeEnoughToGetAllObservationsInNamedSpecimens = 10000;
                var queryFromTime = GetLastRunStartTimeAtMinuteLevel(context.LastRunStartTimeUtc);

                Log.Info($"Examining observations modified from {queryFromTime}.");

                foreach (var specimen in client.LazyGet <Specimen, GetSpecimens, SearchResultSpecimen>(new GetSpecimens()).DomainObjects)
                {
                    if (result.ProcessedSpecimenNames.Contains(specimen.Name))
                    {
                        continue;
                    }

                    Log.Debug($"Examining specimen '{specimen.Name}'.");
                    result.ProcessedSpecimenCount++;


                    var observationResponse = client.Get(new GetObservations
                    {
                        SpecimenName        = specimen.Name,
                        QualityControlTypes = new List <string> {
                            "NORMAL"
                        },
                        DataClassifications = new List <string> {
                            "LAB"
                        },
                        StartModificationTime = queryFromTime,
                        Limit = largeEnoughToGetAllObservationsInNamedSpecimens
                    });

                    var observations = observationResponse.DomainObjects;
                    result.ExaminedObservationsCount += observations.Count;

                    var invalidObservations = validator.GetInvalidObservations(observations);

                    var flaggedCount = PutBackFlaggedObservations(client, context, invalidObservations);
                    result.InvalidObservationsTotal += flaggedCount;

                    result.ProcessedSpecimenNames.Add(specimen.Name);
                }
            }
        }
コード例 #6
0
        private IEnumerable <ObservationV2> LoadAll()
        {
            using (var client = SamplesClient.CreateConnectedClient(Context.ServerUrl, Context.ApiToken))
            {
                AnalysisMethods = client.Get(new GetAnalysisMethods()).DomainObjects;
                Locations       = client.LazyGet <SamplingLocation, GetSamplingLocations, SearchResultSamplingLocation>(
                    new GetSamplingLocations()).DomainObjects.ToList();
                ObservedProperties = client.Get(new GetObservedProperties()).DomainObjects;
                Units = client.Get(new GetUnits()).DomainObjects;
            }

            return(Context
                   .Files
                   .SelectMany(LoadAllObservations));
        }
コード例 #7
0
ファイル: Exporter.cs プロジェクト: PizzaShift/examples
        private ISamplesClient Connect()
        {
            Log.Info($"{ExeHelper.ExeNameAndVersion} connecting to {Context.ServerUrl} ...");

            return(SamplesClient.CreateConnectedClient(Context.ServerUrl, Context.ApiToken));
        }