Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions example/SeqQuery/SeqQuery.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net46;netcoreapp1.0</TargetFrameworks>
<TargetFrameworks>netstandard1.5;net46;net45</TargetFrameworks>
<AssemblyName>seq-query</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>SeqQuery</PackageId>
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">$(PackageTargetFallback);dnxcore50;portable-net45+win8</PackageTargetFallback>
<RuntimeFrameworkVersion Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">1.0.4</RuntimeFrameworkVersion>
</PropertyGroup>

<ItemGroup>
Expand All @@ -26,4 +24,9 @@
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

</Project>
19 changes: 11 additions & 8 deletions example/SeqTail/SeqTail.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net46;netcoreapp1.0</TargetFrameworks>
<TargetFrameworks>netstandard1.5;net46;net45</TargetFrameworks>
<AssemblyName>seq-tail</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>SeqTail</PackageId>
<RuntimeIdentifiers>win</RuntimeIdentifiers>
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">$(PackageTargetFallback);dnxcore50;portable-net45+win8</PackageTargetFallback>
<RuntimeFrameworkVersion Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">1.0.4</RuntimeFrameworkVersion>
</PropertyGroup>

<ItemGroup>
Expand All @@ -19,17 +17,22 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Threading.Tasks" Version="4.0.11" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="System.Threading.Tasks" Version="4.3.0" />
<PackageReference Include="docopt.net" Version="0.6.1.9" />
<PackageReference Include="Serilog.Formatting.Compact.Reader" Version="1.0.0-dev-00008" />
<PackageReference Include="Serilog.Sinks.Literate" Version="2.0.0" />
<PackageReference Include="System.Reactive" Version="3.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
<PackageReference Include="Serilog.Formatting.Compact.Reader" Version="1.0.1" />
<PackageReference Include="Serilog.Sinks.Literate" Version="3.0.0" />
<PackageReference Include="System.Reactive" Version="3.1.1" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net46' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

</Project>
90 changes: 82 additions & 8 deletions example/SignalCopy/Program.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using DocoptNet;
using Seq.Api;
using Seq.Api.Model.Signals;
using System.Collections.Generic;

namespace SeqQuery
namespace SignalCopy
{
class Program
{
const string Usage = @"signal-copy: copy Seq signals from one server to another.
const string Usage = @"signal-copy: copy/print/delete Seq signals from one server to another.

Usage:
signal-copy.exe <src> <dst> [--srckey=<sk>] [--dstkey=<dk>]
signal-copy.exe [--action=<a>] <src> <dst> [--srckey=<sk>] [--dstkey=<dk>]
signal-copy.exe [--action=<a>] <src> [--srckey=<sk>] [--signal=<sg>]
signal-copy.exe [--action=<a>] <src> [--srckey=<sk>]
signal-copy.exe (-h | --help)

Options:
-h --help Show this screen.
--action=<a> Action, can be 'copy', 'print' or 'delete'.
--srckey=<sk> Source server API key.
--dstkey=<dk> Destination server API key.
--signal=<sg> Signal title.

";

Expand All @@ -30,12 +34,28 @@ static void Main(string[] args)
{
var arguments = new Docopt().Apply(Usage, args, version: "Seq Signal Copy 0.1", exit: true);

var src = arguments["<src>"].ToString();
var dst = arguments["<dst>"].ToString();
var action = Normalize(arguments["--action"]);
var src = arguments["<src>"].Value.ToString();
var dst = arguments["<dst>"]?.Value?.ToString();
var srcKey = Normalize(arguments["--srckey"]);
var dstKey = Normalize(arguments["--dstkey"]);
var signal = Normalize(arguments["--signal"]);

await Run(src, srcKey, dst, dstKey);
switch (action)
{
case "copy":
await RunCopy(src, srcKey, dst, dstKey);
break;
case "delete":
await RunDelete(src, srcKey, signal);
break;
case "print":
await RunPrint(src, srcKey);
break;
default:
Console.WriteLine($"Unknown action: '{action}'");
break;
}
}
catch (Exception ex)
{
Expand All @@ -55,7 +75,61 @@ static string Normalize(ValueObject v)
return string.IsNullOrWhiteSpace(s) ? null : s;
}

static async Task Run(string src, string srcKey, string dst, string dstKey)
static async Task RunPrint(string src, string srcKey)
{
var srcConnection = new SeqConnection(src, srcKey);
var count = 0;
var countAll = 0;

foreach (var signal in await srcConnection.Signals.ListAsync())
{
Console.WriteLine();
Console.WriteLine($"---- Signal Title: '{signal.Title}', Id: '{signal.Id}' ----");
Console.WriteLine($"Restricted: '{signal.IsRestricted}', Watched: '{signal.IsWatched}:'");
Console.WriteLine($"Description: '{signal.Description}'");
foreach (var property in signal.TaggedProperties)
{
Console.Write($"Property {count}: {property.PropertyName}; ");
count++;
}
Console.WriteLine();
count = 0;
foreach (var filter in signal.Filters)
{
Console.Write($"Filter {count}: {filter.Filter}, {filter.Description}; ");
count++;
}
Console.WriteLine();
countAll++;
}
Console.WriteLine($"Done, {countAll} signals printed.");
}

static async Task RunDelete(string src, string srcKey, string signalName)
{
var srcConnection = new SeqConnection(src, srcKey);
var count = 0;

foreach (var signal in await srcConnection.Signals.ListAsync())
{
if (signalName != null && signal.Title == signalName)
{
Console.WriteLine($"Deleting signal '{signal.Title}' with id='{signal.Id}'");
await srcConnection.Signals.RemoveAsync(signal);
++count;
}
else if (signalName == null)
{
Console.WriteLine($"Deleting signal '{signal.Title}' with id='{signal.Id}'");
await srcConnection.Signals.RemoveAsync(signal);
++count;
}
}

Console.WriteLine($"Done, {count} signals deleted.");
}

static async Task RunCopy(string src, string srcKey, string dst, string dstKey)
{
var srcConnection = new SeqConnection(src, srcKey);
var dstConnection = new SeqConnection(dst, dstKey);
Expand Down
9 changes: 6 additions & 3 deletions example/SignalCopy/SignalCopy.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net46;netcoreapp1.0</TargetFrameworks>
<TargetFrameworks>netstandard1.5;net46;net45</TargetFrameworks>
<AssemblyName>signal-copy</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>SignalCopy</PackageId>
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">$(PackageTargetFallback);dnxcore50;portable-net45+win8</PackageTargetFallback>
<RuntimeFrameworkVersion Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">1.0.4</RuntimeFrameworkVersion>
</PropertyGroup>

<ItemGroup>
Expand All @@ -26,4 +24,9 @@
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

</Project>
19 changes: 12 additions & 7 deletions src/Seq.Api/Seq.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Description>Client library for the Seq HTTP API.</Description>
<VersionPrefix>4.0.1</VersionPrefix>
<Authors>Datalust;Contributors</Authors>
<TargetFrameworks>netstandard1.3;net45</TargetFrameworks>
<TargetFrameworks>netstandard1.3;net46;net45</TargetFrameworks>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand All @@ -14,7 +14,6 @@
<PackageIconUrl>https://getseq.net/images/seq-nuget.pngg</PackageIconUrl>
<PackageProjectUrl>https://github.com/datalust/seq-api</PackageProjectUrl>
<PackageLicenseUrl>http://www.apache.org/licenses/LICENSE-2.0</PackageLicenseUrl>
<NetStandardImplicitPackageVersion Condition=" '$(TargetFramework)' == 'netstandard1.3' ">1.6.1</NetStandardImplicitPackageVersion>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
Expand All @@ -27,14 +26,20 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
<PackageReference Include="Tavis.UriTemplates" Version="1.1.0" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="Tavis.UriTemplates" Version="1.1.1" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
<PackageReference Include="System.Collections.Concurrent" Version="4.0.12" />
<PackageReference Include="System.Net.Http" Version="4.1.1" />
<PackageReference Include="System.Net.WebSockets.Client" Version="4.0.0" />
<PackageReference Include="System.Collections.Concurrent" Version="4.3.0" />
<PackageReference Include="System.Net.Http" Version="4.3.3" />
<PackageReference Include="System.Net.WebSockets.Client" Version="4.3.1" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net46' ">
<Reference Include="System.Net.Http" />
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
Expand Down
9 changes: 6 additions & 3 deletions test/Seq.Api.Tests/Seq.Api.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp1.0;net46</TargetFrameworks>
<TargetFrameworks>netstandard1.5;net46;net45</TargetFrameworks>
<AssemblyName>Seq.Api.Tests</AssemblyName>
<PackageId>Seq.Api.Tests</PackageId>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">$(PackageTargetFallback);dnxcore50;portable-net45+win8</PackageTargetFallback>
<RuntimeFrameworkVersion Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">1.0.4</RuntimeFrameworkVersion>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
Expand All @@ -27,4 +25,9 @@
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

</Project>