/// <summary> /// Builds a new instance of the specified IConnectionHandler type /// </summary> public TConnectionHandler BuildHandler <TConnectionHandler>(MetadataLookup metadataLookup) where TConnectionHandler : class, IConnectionHandler { if (typeof(IOutboundHandler).IsAssignableFrom(typeof(TConnectionHandler))) { return(Bootstrapper.Container.Resolve <TConnectionHandler>(this.ConnectionFactory.Adapter.ChannelName)); } if (typeof(IInboundHandler).IsAssignableFrom(typeof(TConnectionHandler))) { return(Bootstrapper.Container.Resolve <TConnectionHandler>(this.ConnectionFactory.Adapter.ChannelName)); } if (typeof(IMetadataResolverHandler).IsAssignableFrom(typeof(TConnectionHandler))) { return(new GenericAdapterMetadataResolverHandler() as TConnectionHandler); } if (typeof(IMetadataBrowseHandler).IsAssignableFrom(typeof(TConnectionHandler))) { return(new GenericAdapterMetadataBrowseHandler() as TConnectionHandler); } if (typeof(IMetadataSearchHandler).IsAssignableFrom(typeof(TConnectionHandler))) { return(new GenericAdapterMetadataSearchHandler() as TConnectionHandler); } return(default(TConnectionHandler)); }
/// <summary> /// Initializes a new instance of the <see cref="MockAdapterHandlerBase"/> class /// </summary> /// <param name="connection">The mock adapter connection instance</param> /// <param name="metadataLookup">The instance of the metadata lookup object</param> protected MockAdapterHandlerBase( MockAdapterConnection connection, MetadataLookup metadataLookup) { this.connection = connection; this.metadataLookup = metadataLookup; }
static void dumpAllLookupTypes(RetsMetadata metadata, MetadataLookup lookup) { IEnumerable lookupTypes = metadata.GetAllLookupTypes(lookup); foreach (MetadataLookupType lookupType in lookupTypes) { Console.WriteLine("Lookup value: " + lookupType.GetValue() + " (" + lookupType.GetShortValue() + ", " + lookupType.GetLongValue() + ")"); } }
/// <summary> /// Initializes a new instance of the ScheduleAdapterInboundHandler class /// </summary> public ScheduleAdapterInboundHandler(ScheduleAdapterConnection connection , MetadataLookup metadataLookup) : base(connection, metadataLookup) { uri = connection.ConnectionFactory.ConnectionUri.Uri; scheduleName = connection.ConnectionFactory.ConnectionUri.ScheduleName; action = string.Format("{0}/{1}#Event", ScheduleAdapter.SERVICENAMESPACE, scheduleName); job = Activator.CreateInstance(connection.ConnectionFactory.Adapter.JobType) as IScheduleJob; }
/// <summary> /// Initializes a new instance of the <see cref="MockAdapterInboundHandler"/> class /// </summary> /// <param name="connection">The connection object for the inbound handler</param> /// <param name="metadataLookup">The metadata lookup object for the handler</param> public MockAdapterInboundHandler( MockAdapterConnection connection, MetadataLookup metadataLookup) : base(connection, metadataLookup) { if (connection == null) { throw new ArgumentNullException("connection"); } this.propertiesToPromote = connection.ConnectionFactory.Adapter.PromotedProperties; this.propertyParser = new AdapterPropertyParser(); }
public TConnectionHandler BuildHandler <TConnectionHandler>(MetadataLookup metadataLookup) where TConnectionHandler : class, IConnectionHandler { if (typeof(IOutboundHandler).IsAssignableFrom(typeof(TConnectionHandler))) { return(new MockAdapterOutboundHandler(this, metadataLookup) as TConnectionHandler); } if (typeof(IInboundHandler).IsAssignableFrom(typeof(TConnectionHandler))) { return(new MockAdapterInboundHandler(this, metadataLookup) as TConnectionHandler); } return(default(TConnectionHandler)); }
/// <summary> /// Initializes a new instance of the FtpAdapterInboundHandler class /// </summary> public FtpAdapterInboundHandler(FtpAdapterConnection connection , MetadataLookup metadataLookup) : base(connection, metadataLookup) { connectionUri = connection.ConnectionFactory.ConnectionUri; filter = new Wildcard(connectionUri.FileName); pollingType = connection.ConnectionFactory.Adapter.PollingType; if (pollingType == PollingType.Simple) { pollingInterval = connection.ConnectionFactory.Adapter.PollingInterval; pollingTimer = new Timer(new TimerCallback(t => GetFiles())); } else scheduleName = connection.ConnectionFactory.Adapter.ScheduleName; }
/// <summary> /// Initializes a new instance of the FileAdapterInboundHandler class /// </summary> public FileAdapterInboundHandler(FileAdapterConnection connection , MetadataLookup metadataLookup) : base(connection, metadataLookup) { connectionUri = connection.ConnectionFactory.ConnectionUri; pollingType = connection.ConnectionFactory.Adapter.PollingType; if (pollingType == PollingType.Event || pollingType == PollingType.Simple) { if (pollingType == PollingType.Event) { watcher = new FileSystemWatcher(connectionUri.Path, connectionUri.FileName); watcher.Changed += FileEvent; } pollingInterval = connection.ConnectionFactory.Adapter.PollingInterval; pollingTimer = new Timer(new TimerCallback(t => GetFiles())); } else scheduleName = connection.ConnectionFactory.Adapter.ScheduleName; }
/// <summary> /// Initializes a new instance of the AdoNetAdapterInboundHandler class /// </summary> public AdoNetAdapterInboundHandler(AdoNetAdapterConnection connection , MetadataLookup metadataLookup) : base(connection, metadataLookup) { pollingType = connection.ConnectionFactory.Adapter.PollingType; if (pollingType == PollingType.Simple) { pollingInterval = connection.ConnectionFactory.Adapter.PollingInterval * 1000; pollingTimer = new Timer(new TimerCallback(t => ExecutePolling())); } else { scheduleName = connection.ConnectionFactory.Adapter.ScheduleName; } UriBuilder actionBuilder = new UriBuilder(AdoNetAdapter.SERVICENAMESPACE); actionBuilder.Path = System.IO.Path.Combine(actionBuilder.Path, connection.ConnectionFactory.ConnectionUri.ConnectionName); actionBuilder.Path = System.IO.Path.Combine(actionBuilder.Path, connection.ConnectionFactory.ConnectionUri.InboundID); action = actionBuilder.ToString() + "#Receive"; }
protected FtpAdapterHandlerBase(FtpAdapterConnection connection , MetadataLookup metadataLookup) { this.connection = connection; this.metadataLookup = metadataLookup; }
/// <summary> /// Initializes a new instance of the SocketAdapterOutboundHandler class /// </summary> public SocketAdapterOutboundHandler(SocketAdapterConnection connection , MetadataLookup metadataLookup) : base(connection, metadataLookup) { }
/// <summary> /// Initializes a new instance of the AdoNetAdapterMetadataBrowseHandler class /// </summary> public AdoNetAdapterMetadataBrowseHandler(AdoNetAdapterConnection connection , MetadataLookup metadataLookup) : base(connection, metadataLookup) { }
/// <summary> /// Initializes a new instance of the <see cref="MockAdapterOutboundHandler"/> class /// </summary> /// <param name="connection">The connection object for the outbound handler</param> /// <param name="metadataLookup">The metadata lookup object for the outbound handler</param> public MockAdapterOutboundHandler( MockAdapterConnection connection, MetadataLookup metadataLookup) : base(connection, metadataLookup) { }
public async Task <ApiResourceMetadataView> FromMetadata([FromQuery] MetadataLookup lookupInfo, [FromServices] IMetadataClient client, [FromServices] IMapper mapper) { return(mapper.Map <ApiResourceMetadataView>(await client.ScopeAsync(lookupInfo.TargetUrl))); }
/// <summary> /// Initializes a new instance of the FileAdapterOutboundHandler class /// </summary> public FileAdapterOutboundHandler(FileAdapterConnection connection , MetadataLookup metadataLookup) : base(connection, metadataLookup) { }
public void WritePoints(List <TimeSeriesPoint> points, List <TimeSeriesNote> notes) { var timeSeriesIdentifier = CreateTimeSeriesIdentifier(); var csvPath = Directory.Exists(Context.SaveCsvPath) ? Path.Combine(Context.SaveCsvPath, SanitizeFilename($"{timeSeriesIdentifier.Identifier}.{CreatePeriod(Context.SourceQueryFrom, Context.SourceQueryTo)}.csv")) : Context.SaveCsvPath; Log.Info($"Saving {PointSummarizer.Summarize(points, "extracted point")} to '{csvPath}' ..."); var dir = Path.GetDirectoryName(csvPath); if (!string.IsNullOrEmpty(dir)) { Directory.CreateDirectory(dir); } var publishNotes = notes .Select(Convert) .ToList(); var notesLookup = new MetadataLookup <PublishNote>(publishNotes); using (var writer = new StreamWriter(csvPath)) { var offsetPattern = OffsetPattern.CreateWithInvariantCulture("m"); var utcOffsetText = $"UTC{offsetPattern.Format(Context.UtcOffset ?? Offset.Zero)}"; var period = CreatePeriod(Context.SourceQueryFrom ?? Instant.MinValue, Context.SourceQueryTo ?? Instant.MaxValue); writer.WriteLine($"# {Path.GetFileName(csvPath)} generated by {Context.ExecutingFileVersion}"); writer.WriteLine($"#"); writer.WriteLine($"# Time series identifier: {timeSeriesIdentifier.Identifier}"); writer.WriteLine($"# Location: {timeSeriesIdentifier.LocationIdentifier}"); writer.WriteLine($"# UTC offset: ({utcOffsetText})"); writer.WriteLine($"# Value units: {Context.Unit}"); writer.WriteLine($"# Value parameter: {timeSeriesIdentifier.Parameter}"); writer.WriteLine($"# Interpolation type: {Context.InterpolationType}"); writer.WriteLine($"# Time series type: {Context.TimeSeriesType}"); writer.WriteLine($"#"); writer.WriteLine($"# Export options: Corrected signal from {period.StartText} to {period.EndText}"); writer.WriteLine($"#"); writer.WriteLine($"# CSV data starts at line 15."); writer.WriteLine($"#"); var optionalNotesHeader = Context.SaveNotesMode == SaveNotesMode.WithPoints ? ", Notes" : string.Empty; writer.WriteLine($"ISO 8601 UTC, Value, Grade, Qualifiers{optionalNotesHeader}"); foreach (var point in points) { var time = point.Time ?? Instant.MinValue; var line = $"{InstantPattern.ExtendedIso.Format(time)}, {point.Value:G12}, {point.GradeCode}, {FormatQualifiers(point.Qualifiers)}"; if (Context.SaveNotesMode == SaveNotesMode.WithPoints) { var pointNotes = string.Join("\r\n", notesLookup.GetMany(time.ToDateTimeOffset()).Select(note => note.NoteText)); line += $", {CsvEscapedColumn(pointNotes)}"; } writer.WriteLine(line); } if (Context.SaveNotesMode == SaveNotesMode.SeparateCsv) { var notesCsvPath = Path.ChangeExtension(csvPath, ".Notes.csv"); Log.Info($"Saving {"extracted note".ToQuantity(notes.Count)} to '{notesCsvPath}' ..."); // ReSharper disable once AssignNullToNotNullAttribute using (var notesWriter = new StreamWriter(notesCsvPath)) { notesWriter.WriteLine($"# {Path.GetFileName(notesCsvPath)} generated by {Context.ExecutingFileVersion}"); notesWriter.WriteLine($"#"); notesWriter.WriteLine($"# Time series identifier: {timeSeriesIdentifier.Identifier}"); notesWriter.WriteLine($"# Location: {timeSeriesIdentifier.LocationIdentifier}"); notesWriter.WriteLine($"# UTC offset: ({utcOffsetText})"); notesWriter.WriteLine($"#"); notesWriter.WriteLine($"# Export options: Corrected signal notes from {period.StartText} to {period.EndText}"); notesWriter.WriteLine($"#"); notesWriter.WriteLine($"# CSV data starts at line 11."); notesWriter.WriteLine($"#"); notesWriter.WriteLine($"StartTime, EndTime, NoteText"); foreach (var note in notes) { if (!note.TimeRange.HasValue) { continue; } notesWriter.WriteLine($"{InstantPattern.ExtendedIso.Format(note.TimeRange.Value.Start)}, {InstantPattern.ExtendedIso.Format(note.TimeRange.Value.End)}, {CsvEscapedColumn(note.NoteText)}"); } } } } }
public async Task <ClientMetadataView> FromClientCredentialsMetadata([FromQuery] MetadataLookup lookupInfo, [FromServices] IMetadataClient client, [FromServices] IMapper mapper) { return(mapper.Map <ClientMetadataView>(await client.ClientCredentialsAsync(lookupInfo.TargetUrl))); }
public async Task <ClientMetadataView> FromMetadata([FromQuery] MetadataLookup lookupInfo, [FromServices] IMetadataClient client, [FromServices] IMapper mapper) { var metadataView = mapper.Map <ClientMetadataView>(await client.ClientAsync(lookupInfo.TargetUrl)); return(metadataView); }