Added solution files
This commit is contained in:
parent
47313e4ed8
commit
dcbd5e6033
28
DataCore.sln
Normal file
28
DataCore.sln
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 14
|
||||||
|
VisualStudioVersion = 14.0.24720.0
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataCore", "DataCore\DataCore.csproj", "{66E8542C-6814-4845-A5E9-4B09A8C11B56}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataCore_Console", "DataCore_Console\DataCore_Console.csproj", "{18E6D4B8-4E08-4ACB-B7A9-8AE8E2B68D21}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{66E8542C-6814-4845-A5E9-4B09A8C11B56}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{66E8542C-6814-4845-A5E9-4B09A8C11B56}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{66E8542C-6814-4845-A5E9-4B09A8C11B56}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{66E8542C-6814-4845-A5E9-4B09A8C11B56}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{18E6D4B8-4E08-4ACB-B7A9-8AE8E2B68D21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{18E6D4B8-4E08-4ACB-B7A9-8AE8E2B68D21}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{18E6D4B8-4E08-4ACB-B7A9-8AE8E2B68D21}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{18E6D4B8-4E08-4ACB-B7A9-8AE8E2B68D21}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
54
DataCore/DataCore.csproj
Normal file
54
DataCore/DataCore.csproj
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{66E8542C-6814-4845-A5E9-4B09A8C11B56}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>DataCore</RootNamespace>
|
||||||
|
<AssemblyName>DataCore</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="GetAdapterStats.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
133
DataCore/GetAdapterStats.cs
Normal file
133
DataCore/GetAdapterStats.cs
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.NetworkInformation;
|
||||||
|
using System.Text;
|
||||||
|
using System.Timers;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DataCore
|
||||||
|
{
|
||||||
|
public static class GetAdapterStats
|
||||||
|
{
|
||||||
|
static NetworkInterface[] systemAdapters = NetworkInterface.GetAllNetworkInterfaces();
|
||||||
|
|
||||||
|
static long[] currentAdapterTransfers = new long[systemAdapters.Length];
|
||||||
|
|
||||||
|
static long uploadStart = 0;
|
||||||
|
static long dowloadStart = 0;
|
||||||
|
|
||||||
|
// currentOverwriteStatus will equal zero on first pass, meaning no values should be read after the current value
|
||||||
|
// one means all values before should be read before the values following the current position
|
||||||
|
public static byte currentOverwriteStatus = 0;
|
||||||
|
public static int ratesIndex = 0;
|
||||||
|
static long[] UploadRateHistory = new long[1000];
|
||||||
|
static long[] DownloadRateHistory = new long[1000];
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the rate of input data flow from the host computer
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sum">Declares that the input rates of multiple adapters should be summed. If false, returns the value of the highest transfer. Less accurate as a shorter response time is needed</param>
|
||||||
|
/// <returns>The number of bytes received since the last run</returns>
|
||||||
|
public static long InputRate(bool sum = true)
|
||||||
|
{
|
||||||
|
long returnRate = 0;
|
||||||
|
|
||||||
|
//foreach (NetworkInterface adapter in systemAdapters)
|
||||||
|
for(int i=0; i<systemAdapters.Length; i++)
|
||||||
|
{
|
||||||
|
if (sum)
|
||||||
|
{
|
||||||
|
long totalRate = systemAdapters[i].GetIPStatistics().BytesReceived;
|
||||||
|
Thread.Sleep(100);
|
||||||
|
returnRate = returnRate + ((systemAdapters[i].GetIPStatistics().BytesReceived - totalRate) * 10);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
long totalRate = systemAdapters[i].GetIPStatistics().BytesReceived;
|
||||||
|
Thread.Sleep(10);
|
||||||
|
currentAdapterTransfers[i] = ((systemAdapters[i].GetIPStatistics().BytesReceived - totalRate) * 100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!sum)
|
||||||
|
{
|
||||||
|
returnRate = currentAdapterTransfers.Max();
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the rate of output data flow from the host computer
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sum">Declares that the output rates of multiple adapters should be summed. If false, returns the value of the highest transfer</param>
|
||||||
|
/// <returns>The number of bytes sent since the last run</returns>
|
||||||
|
public static long OutputRate(bool sum = true)
|
||||||
|
{
|
||||||
|
long returnRate = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < systemAdapters.Length; i++)
|
||||||
|
{
|
||||||
|
if (sum)
|
||||||
|
{
|
||||||
|
long totalRate = systemAdapters[i].GetIPStatistics().BytesSent;
|
||||||
|
Thread.Sleep(100);
|
||||||
|
returnRate = returnRate + ((systemAdapters[i].GetIPStatistics().BytesSent - totalRate)* 10);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
long totalRate = systemAdapters[i].GetIPStatistics().BytesSent;
|
||||||
|
Thread.Sleep(10);
|
||||||
|
currentAdapterTransfers[i] = ((systemAdapters[i].GetIPStatistics().BytesSent - totalRate) * 100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!sum)
|
||||||
|
{
|
||||||
|
returnRate = currentAdapterTransfers.Max();
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnRate;
|
||||||
|
}
|
||||||
|
public static void logRates()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < systemAdapters.Length; i++)
|
||||||
|
{
|
||||||
|
uploadStart = uploadStart + systemAdapters[i].GetIPStatistics().BytesSent;
|
||||||
|
dowloadStart = dowloadStart + systemAdapters[i].GetIPStatistics().BytesReceived;
|
||||||
|
}
|
||||||
|
System.Timers.Timer logTime = new System.Timers.Timer(1000);
|
||||||
|
logTime.Elapsed += DoLog;
|
||||||
|
logTime.AutoReset = true;
|
||||||
|
logTime.Enabled = true;
|
||||||
|
logTime.Start();
|
||||||
|
}
|
||||||
|
private static void DoLog(Object source, ElapsedEventArgs e)
|
||||||
|
{
|
||||||
|
if(ratesIndex == UploadRateHistory.Length)
|
||||||
|
{
|
||||||
|
ratesIndex = 0;
|
||||||
|
}
|
||||||
|
long currentUp = 0;
|
||||||
|
long currentDown = 0;
|
||||||
|
|
||||||
|
|
||||||
|
long tempUp = 0;
|
||||||
|
long tempDown = 0;
|
||||||
|
for (int i = 0; i < systemAdapters.Length; i++)
|
||||||
|
{
|
||||||
|
currentUp = systemAdapters[i].GetIPStatistics().BytesSent;
|
||||||
|
currentDown = systemAdapters[i].GetIPStatistics().BytesReceived;
|
||||||
|
|
||||||
|
tempUp = tempUp + (currentUp - uploadStart);
|
||||||
|
tempDown = tempDown + (currentDown - dowloadStart);
|
||||||
|
}
|
||||||
|
uploadStart = tempUp;
|
||||||
|
dowloadStart = tempDown;
|
||||||
|
ratesIndex++;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
36
DataCore/Properties/AssemblyInfo.cs
Normal file
36
DataCore/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("DataCore")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("DataCore")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2016")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("66e8542c-6814-4845-a5e9-4b09a8c11b56")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
6
DataCore_Console/App.config
Normal file
6
DataCore_Console/App.config
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
|
||||||
|
</startup>
|
||||||
|
</configuration>
|
66
DataCore_Console/DataCore_Console.csproj
Normal file
66
DataCore_Console/DataCore_Console.csproj
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{18E6D4B8-4E08-4ACB-B7A9-8AE8E2B68D21}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>DataCore_Console</RootNamespace>
|
||||||
|
<AssemblyName>DataCore_Console</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="App.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\DataCore\DataCore.csproj">
|
||||||
|
<Project>{66e8542c-6814-4845-a5e9-4b09a8c11b56}</Project>
|
||||||
|
<Name>DataCore</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
26
DataCore_Console/Program.cs
Normal file
26
DataCore_Console/Program.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using DataCore;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
|
namespace DataCore_Console
|
||||||
|
{
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
for(int i=0; i< 1000; i++)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Download data rate: {0} kB/s;\t\t Upload: {1} kB/s", (double)GetAdapterStats.InputRate() /1024, (double)GetAdapterStats.OutputRate() / 1024);
|
||||||
|
Thread.Sleep(100);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Console.ReadKey();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
36
DataCore_Console/Properties/AssemblyInfo.cs
Normal file
36
DataCore_Console/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("DataCore_Console")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("DataCore_Console")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2016")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("18e6d4b8-4e08-4acb-b7a9-8ae8e2b68d21")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
Reference in New Issue
Block a user