Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
CWFranklin committed May 9, 2014
2 parents 4bc5041 + 29bb718 commit 0200b79
Show file tree
Hide file tree
Showing 24 changed files with 8,671 additions and 92 deletions.
21 changes: 21 additions & 0 deletions CadenceHost.Tests/StatisticsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,27 @@ public void TestCpu()
{
var statsHelper = new Statistics();
Assert.IsNotNull(statsHelper.GetCurrentCpu());
}

[TestMethod]
public void TestOsName()
{
var statsHelper = new Statistics();
Assert.AreEqual(statsHelper.GetOsName(),"Microsoft Windows 8.1 Pro");
}

[TestMethod]
public void TestOsVersion()
{
var statsHelper = new Statistics();
Assert.AreEqual(statsHelper.GetOsVersion(), "6.3.9600");
}

[TestMethod]
public void TestTotalDiskSpace()
{
var statsHelper = new Statistics();
Assert.IsNotNull(statsHelper.GetTotalDiskStorage());
}
}
}
32 changes: 31 additions & 1 deletion CadenceHost/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,36 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="CadenceHost.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<appSettings>
<add key="PubnubMessaging.LogLevel" value="0" />
<add key="PubnubMessaging.PubnubErrorFilterLevel" value="2" />
<add key="PubnubMessaging.LogMessageLengthLimit" value="0" />
</appSettings><system.diagnostics>
<trace autoflush="true" indentsize="4">
<listeners>
<add name="pubnubListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="pubnub-messaging.log" />
<remove name="Default" />
</listeners>
</trace>
</system.diagnostics><system.net>
<connectionManagement>
<add address="*" maxconnection="30" />
</connectionManagement>
</system.net><userSettings>
<CadenceHost.Properties.Settings>
<setting name="ServerGUID" serializeAs="String">
<value />
</setting>
<setting name="ServerID" serializeAs="String">
<value>0</value>
</setting>
</CadenceHost.Properties.Settings>
</userSettings>
</configuration>
2 changes: 1 addition & 1 deletion CadenceHost/App.xaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Application x:Class="CadenceHost.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
StartupUri="Windows/MainWindow.xaml">
<Application.Resources>

</Application.Resources>
Expand Down
36 changes: 29 additions & 7 deletions CadenceHost/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,33 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
// ---------------------------------------------------------------------------------------
// <copyright file="App.xaml.cs" company="Cadence">
// Copyright © 2013-2014 by Brandon Scott and Christopher Franklin.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software is furnished to do
// so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// </copyright>
// ---------------------------------------------------------------------------------------

#region

using System.Windows;

#endregion

namespace CadenceHost
{
/// <summary>
Expand All @@ -14,4 +36,4 @@ namespace CadenceHost
public partial class App : Application
{
}
}
}
22 changes: 19 additions & 3 deletions CadenceHost/CadenceHost.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,13 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Pubnub.3.6.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Management" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
Expand All @@ -53,7 +58,16 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="MainWindow.xaml">
<Compile Include="Helpers\Cadence.cs" />
<Compile Include="Models\DebugInfo.cs" />
<Compile Include="PubnubCore\ClientNetworkStatus.cs" />
<Compile Include="PubnubCore\LoggingMethod.cs" />
<Compile Include="PubnubCore\MD5.cs" />
<Compile Include="PubnubCore\Pubnub.cs" />
<Compile Include="PubnubCore\PubnubCore.cs" />
<Compile Include="PubnubCore\PubnubWin.cs" />
<Compile Include="PubnubCore\ReconnectState.cs" />
<Page Include="Windows\MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
Expand All @@ -62,7 +76,7 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="Helpers\Statistics.cs" />
<Compile Include="MainWindow.xaml.cs">
<Compile Include="Windows\MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
Expand All @@ -85,6 +99,7 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
Expand All @@ -95,7 +110,8 @@
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Resource Include="PulseOnlyTrimmed.png" />
<Folder Include="Enums\" />
<Folder Include="Interfaces\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
105 changes: 105 additions & 0 deletions CadenceHost/Helpers/Cadence.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
// ---------------------------------------------------------------------------------------
// <copyright file="Cadence.cs" company="Cadence">
// Copyright © 2013-2014 by Brandon Scott and Christopher Franklin.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software is furnished to do
// so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// </copyright>
// ---------------------------------------------------------------------------------------

#region

using System;
using System.Collections.Specialized;
using System.Net;
using System.Text;
using Newtonsoft.Json.Linq;
using PubNubMessaging.Core;

#endregion

namespace CadenceHost.Helpers
{
/// <summary>
/// Sends and retrieves data from Cadence
/// </summary>
public static class Cadence
{
public static readonly String ServerUri = "http://cadence-bu.cloudapp.net/servers";
public static readonly String PulseUri = "http://cadence-bu.cloudapp.net/pulses";

public static readonly String Username = "[email protected]";
public static readonly String Password = "Cadenc3!";

/// <summary>
/// Creates a Cadence server instance
/// </summary>
/// <param name="kvpData">The server data passed to Cadence</param>
public static int CreateServer(NameValueCollection kvpData)
{
return PostRequest(kvpData, ServerUri);
}

/// <summary>
/// Sends a pulse for the current server
/// </summary>
/// <param name="kvpData">The pulse data to pass to Cadence</param>
public static int SendPulse(NameValueCollection kvpData)
{
return PostRequest(kvpData, PulseUri);
}

/// <summary>
/// Updates the current Cadence server instance
/// </summary>
/// <param name="kvpData">The server data to update for the current server</param>
public static void UpdateServer(NameValueCollection kvpData)
{
PutRequest(kvpData);
}

/// <summary>
/// The base Put web request to send to the server
/// </summary>
/// <param name="kvpData">The data to send to the server</param>
private static void PutRequest(NameValueCollection kvpData)
{
using (var wb = new WebClient())
{
var response = wb.UploadValues(ServerUri, "PUT", kvpData);
}
}

/// <summary>
/// The base Post web request to send to the server
/// </summary>
/// <param name="kvpData">The data to send to the server</param>
/// <param name="uri">The URI to send the request to</param>
private static int PostRequest(NameValueCollection kvpData, String uri)
{
var nc = new NetworkCredential("[email protected]", "Cadenc3!");
string responseJson;
using (var wb = new WebClient {Credentials = nc})
{
var response = wb.UploadValues(uri, "POST", kvpData);
responseJson = wb.Encoding.GetString(response);
}
return JObject.Parse(responseJson).GetValue("id").Value<int>();
}
}
}
Loading

0 comments on commit 0200b79

Please sign in to comment.