diff --git a/Service/App.config b/Service/App.config new file mode 100644 index 0000000..95c997a --- /dev/null +++ b/Service/App.config @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Service/Device.cs b/Service/Device.cs new file mode 100644 index 0000000..b7c1d3e --- /dev/null +++ b/Service/Device.cs @@ -0,0 +1,30 @@ +using System.Runtime.Serialization; + +namespace SystemTemperatureService +{ + [DataContract] + public enum DeviceType + { + [EnumMember] + Cpu, + + [EnumMember] + Gpu, + + [EnumMember] + Hdd + } + + [DataContract] + public class Device + { + [DataMember] + public string Id { get; set; } + + [DataMember] + public DeviceType Type { get; set; } + + [DataMember] + public double Temperature { get; set; } + } +} diff --git a/Service/Framework/ConsoleHarness.cs b/Service/Framework/ConsoleHarness.cs new file mode 100644 index 0000000..b4d5111 --- /dev/null +++ b/Service/Framework/ConsoleHarness.cs @@ -0,0 +1,70 @@ +using System; + +namespace SystemTemperatureService.Framework +{ + public static class ConsoleHarness + { + // Run a service from the console given a service implementation + public static void Run(string[] args, IWindowsService service) + { + bool isRunning = true; + + // simulate starting the windows service + service.OnStart(args); + + // let it run as long as Q is not pressed + while (isRunning) + { + WriteToConsole(ConsoleColor.Yellow, "Enter either [Q]uit, [P]ause, [R]esume : "); + isRunning = HandleConsoleInput(service, Console.ReadLine()); + } + + // stop and shutdown + service.OnStop(); + service.OnShutdown(); + } + + // Private input handler for console commands. + private static bool HandleConsoleInput(IWindowsService service, string line) + { + bool canContinue = true; + + // check input + if (line != null) + { + switch (line.ToUpper()) + { + case "Q": + canContinue = false; + break; + + case "P": + service.OnPause(); + break; + + case "R": + service.OnContinue(); + break; + + default: + WriteToConsole(ConsoleColor.Red, "Did not understand that input, try again."); + break; + } + } + + return canContinue; + } + + // Helper method to write a message to the console at the given foreground color. + internal static void WriteToConsole(ConsoleColor foregroundColor, string format, params object[] formatArguments) + { + ConsoleColor originalColor = Console.ForegroundColor; + Console.ForegroundColor = foregroundColor; + + Console.WriteLine(format, formatArguments); + Console.Out.Flush(); + + Console.ForegroundColor = originalColor; + } + } +} diff --git a/Service/Framework/IWindowsService.cs b/Service/Framework/IWindowsService.cs new file mode 100644 index 0000000..92341fe --- /dev/null +++ b/Service/Framework/IWindowsService.cs @@ -0,0 +1,46 @@ +using System; + +namespace SystemTemperatureService.Framework +{ + /// + /// The interface that any windows service should implement to be used + /// with the GenericWindowsService executable. + /// + public interface IWindowsService : IDisposable + { + /// + /// This method is called when the service gets a request to start. + /// + /// Any command line arguments + void OnStart(string[] args); + + /// + /// This method is called when the service gets a request to stop. + /// + void OnStop(); + + /// + /// This method is called when a service gets a request to pause, + /// but not stop completely. + /// + void OnPause(); + + /// + /// This method is called when a service gets a request to resume + /// after a pause is issued. + /// + void OnContinue(); + + /// + /// This method is called when the machine the service is running on + /// is being shutdown. + /// + void OnShutdown(); + + /// + /// This method is called when a custom command is issued to the service. + /// + /// The command identifier to execute. + void OnCustomCommand(int command); + } +} diff --git a/Service/Framework/TypeExtensions.cs b/Service/Framework/TypeExtensions.cs new file mode 100644 index 0000000..44d064a --- /dev/null +++ b/Service/Framework/TypeExtensions.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace SystemTemperatureService.Framework +{ + /// + /// Extension methods for the Type class + /// + public static class TypeExtensions + { + /// + /// Loads the configuration from assembly attributes + /// + /// The type of the custom attribute to find. + /// The calling assembly to search. + /// The custom attribute of type T, if found. + public static T GetAttribute(this Type typeWithAttributes) + where T : Attribute + { + return GetAttributes(typeWithAttributes).FirstOrDefault(); + } + + /// + /// Loads the configuration from assembly attributes + /// + /// The type of the custom attribute to find. + /// The calling assembly to search. + /// An enumeration of attributes of type T that were found. + public static IEnumerable GetAttributes(this Type typeWithAttributes) + where T : Attribute + { + // Try to find the configuration attribute for the default logger if it exists + object[] configAttributes = Attribute.GetCustomAttributes(typeWithAttributes, + typeof(T), false); + + // get just the first one + if (configAttributes != null && configAttributes.Length > 0) + { + foreach (T attribute in configAttributes) + { + yield return attribute; + } + } + } + } +} \ No newline at end of file diff --git a/Service/Framework/WindowsServiceAttribute.cs b/Service/Framework/WindowsServiceAttribute.cs new file mode 100644 index 0000000..96ab732 --- /dev/null +++ b/Service/Framework/WindowsServiceAttribute.cs @@ -0,0 +1,90 @@ +using System; +using System.ServiceProcess; + +namespace SystemTemperatureService.Framework +{ + [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)] + public class WindowsServiceAttribute : Attribute + { + /// + /// The name of the service. + /// + public string Name { get; set; } + + /// + /// The displayable name that shows in service manager (defaults to Name). + /// + public string DisplayName { get; set; } + + /// + /// A textural description of the service name (defaults to Name). + /// + public string Description { get; set; } + + /// + /// The user to run the service under (defaults to null). A null or empty + /// UserName field causes the service to run as ServiceAccount.LocalService. + /// + public string UserName { get; set; } + + /// + /// The password to run the service under (defaults to null). Ignored + /// if the UserName is empty or null, this property is ignored. + /// + public string Password { get; set; } + + /// + /// Specifies the event log source to set the service's EventLog to. If this is + /// empty or null (the default) no event log source is set. If set, will auto-log + /// start and stop events. + /// + public string EventLogSource { get; set; } + + /// + /// The method to start the service when the machine reboots (defaults to Manual). + /// + public ServiceStartMode StartMode { get; set; } + + /// + /// True if service supports pause and continue (defaults to true). + /// + public bool CanPauseAndContinue { get; set; } + + /// + /// True if service supports shutdown event (defaults to true). + /// + public bool CanShutdown { get; set; } + + /// + /// True if service supports stop event (defaults to true). + /// + public bool CanStop { get; set; } + + /// + /// The service account to use if the UserName is not specified. + /// + public ServiceAccount ServiceAccount { get; set; } + + /// + /// Marks an IWindowsService with configuration and installation attributes. + /// + /// The name of the windows service. + public WindowsServiceAttribute(string name) + { + // set name and default description and display name to name. + Name = name; + Description = name; + DisplayName = name; + + // default all other attributes. + CanStop = true; + CanShutdown = true; + CanPauseAndContinue = true; + StartMode = ServiceStartMode.Manual; + EventLogSource = null; + Password = null; + UserName = null; + ServiceAccount = ServiceAccount.LocalService; + } + } +} \ No newline at end of file diff --git a/Service/Framework/WindowsServiceHarness.Designer.cs b/Service/Framework/WindowsServiceHarness.Designer.cs new file mode 100644 index 0000000..efeee0a --- /dev/null +++ b/Service/Framework/WindowsServiceHarness.Designer.cs @@ -0,0 +1,37 @@ +namespace SystemTemperatureService.Framework +{ + public partial class WindowsServiceHarness + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + this.ServiceName = "UsageService"; + } + + #endregion + } +} diff --git a/Service/Framework/WindowsServiceHarness.cs b/Service/Framework/WindowsServiceHarness.cs new file mode 100644 index 0000000..fa9f1e1 --- /dev/null +++ b/Service/Framework/WindowsServiceHarness.cs @@ -0,0 +1,129 @@ +using System; +using System.ServiceProcess; + +namespace SystemTemperatureService.Framework +{ + /// + /// A generic Windows Service that can handle any assembly that + /// implements IWindowsService (including AbstractWindowsService) + /// + public partial class WindowsServiceHarness : ServiceBase + { + /// + /// Get the class implementing the windows service + /// + public IWindowsService ServiceImplementation { get; private set; } + + /// + /// Constructor a generic windows service from the given class + /// + /// Service implementation. + public WindowsServiceHarness(IWindowsService serviceImplementation) + { + // make sure service passed in is valid + if (serviceImplementation == null) + { + throw new ArgumentNullException("serviceImplementation", + "IWindowsService cannot be null in call to GenericWindowsService"); + } + + // set instance and backward instance + ServiceImplementation = serviceImplementation; + + // configure our service + ConfigureServiceFromAttributes(serviceImplementation); + } + + /// + /// Override service control on continue + /// + protected override void OnContinue() + { + // perform class specific behavior + ServiceImplementation.OnContinue(); + } + + /// + /// Called when service is paused + /// + protected override void OnPause() + { + // perform class specific behavior + ServiceImplementation.OnPause(); + } + + /// + /// Called when a custom command is requested + /// + /// Id of custom command + protected override void OnCustomCommand(int command) + { + // perform class specific behavior + ServiceImplementation.OnCustomCommand(command); + } + + /// + /// Called when the Operating System is shutting down + /// + protected override void OnShutdown() + { + // perform class specific behavior + ServiceImplementation.OnShutdown(); + } + + /// + /// Called when service is requested to start + /// + /// The startup arguments array. + protected override void OnStart(string[] args) + { + ServiceImplementation.OnStart(args); + } + + /// + /// Called when service is requested to stop + /// + protected override void OnStop() + { + ServiceImplementation.OnStop(); + } + + /// + /// Set configuration data + /// + /// The service with configuration settings. + private void ConfigureServiceFromAttributes(IWindowsService serviceImplementation) + { + var attribute = serviceImplementation.GetType().GetAttribute(); + + if (attribute != null) + { + // wire up the event log source, if provided + if (!string.IsNullOrWhiteSpace(attribute.EventLogSource)) + { + // assign to the base service's EventLog property for auto-log events. + EventLog.Source = attribute.EventLogSource; + } + + CanStop = attribute.CanStop; + CanPauseAndContinue = attribute.CanPauseAndContinue; + CanShutdown = attribute.CanShutdown; + + // we don't handle: laptop power change event + CanHandlePowerEvent = false; + + // we don't handle: Term Services session event + CanHandleSessionChangeEvent = false; + + // always auto-event-log + AutoLog = true; + } + else + { + throw new InvalidOperationException( + string.Format("IWindowsService implementer {0} must have a WindowsServiceAttribute.", + serviceImplementation.GetType().FullName)); + } + } + } +} diff --git a/Service/Framework/WindowsServiceInstaller.Designer.cs b/Service/Framework/WindowsServiceInstaller.Designer.cs new file mode 100644 index 0000000..475fa95 --- /dev/null +++ b/Service/Framework/WindowsServiceInstaller.Designer.cs @@ -0,0 +1,36 @@ +namespace SystemTemperatureService.Framework +{ + public partial class WindowsServiceInstaller + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + } + + #endregion + } +} \ No newline at end of file diff --git a/Service/Framework/WindowsServiceInstaller.cs b/Service/Framework/WindowsServiceInstaller.cs new file mode 100644 index 0000000..b0e050e --- /dev/null +++ b/Service/Framework/WindowsServiceInstaller.cs @@ -0,0 +1,212 @@ +using System; +using System.Collections; +using System.ComponentModel; +using System.Configuration.Install; +using System.Diagnostics; +using System.Linq; +using System.Reflection; +using System.ServiceProcess; + +namespace SystemTemperatureService.Framework +{ + /// + /// A generic windows service installer + /// + [RunInstaller(true)] + public partial class WindowsServiceInstaller : Installer + { + /// + /// Gets or sets the type of the windows service to install. + /// + public WindowsServiceAttribute Configuration { get; set; } + + + /// + /// Creates a blank windows service installer with configuration in ServiceImplementation + /// + public WindowsServiceInstaller() + : this(typeof(ServiceImplementation)) + { + } + + + /// + /// Creates a windows service installer using the type specified. + /// + /// The type of the windows service to install. + public WindowsServiceInstaller(Type windowsServiceType) + { + if (!windowsServiceType.GetInterfaces().Contains(typeof(IWindowsService))) + { + throw new ArgumentException("Type to install must implement IWindowsService.", + "windowsServiceType"); + } + + var attribute = windowsServiceType.GetAttribute(); + + if (attribute == null) + { + throw new ArgumentException("Type to install must be marked with a WindowsServiceAttribute.", + "windowsServiceType"); + } + + Configuration = attribute; + } + + + /// + /// Performs a transacted installation at run-time of the AutoCounterInstaller and any other listed installers. + /// + /// The IWindowsService implementer to install. + public static void RuntimeInstall() + where T : IWindowsService + { + string path = "/assemblypath=" + Assembly.GetEntryAssembly().Location; + + using (var ti = new TransactedInstaller()) + { + ti.Installers.Add(new WindowsServiceInstaller(typeof(T))); + ti.Context = new InstallContext(null, new[] { path }); + ti.Install(new Hashtable()); + } + } + + + /// + /// Performs a transacted un-installation at run-time of the AutoCounterInstaller and any other listed installers. + /// + /// The other installers to include in the transaction + /// The IWindowsService implementer to install. + public static void RuntimeUnInstall(params Installer[] otherInstallers) + where T : IWindowsService + { + string path = "/assemblypath=" + Assembly.GetEntryAssembly().Location; + + using (var ti = new TransactedInstaller()) + { + ti.Installers.Add(new WindowsServiceInstaller(typeof(T))); + ti.Context = new InstallContext(null, new[] { path }); + ti.Uninstall(null); + } + } + + + /// + /// Installer class, to use run InstallUtil against this .exe + /// + /// The saved state for the installation. + public override void Install(IDictionary savedState) + { + ConsoleHarness.WriteToConsole(ConsoleColor.White, "Installing service {0}.", Configuration.Name); + + // install the service + ConfigureInstallers(); + base.Install(savedState); + + // wire up the event log source, if provided + if (!string.IsNullOrWhiteSpace(Configuration.EventLogSource)) + { + // create the source if it doesn't exist + if (!EventLog.SourceExists(Configuration.EventLogSource)) + { + EventLog.CreateEventSource(Configuration.EventLogSource, "Application"); + } + } + } + + + /// + /// Removes the counters, then calls the base uninstall. + /// + /// The saved state for the installation. + public override void Uninstall(IDictionary savedState) + { + ConsoleHarness.WriteToConsole(ConsoleColor.White, "Un-Installing service {0}.", Configuration.Name); + + // load the assembly file name and the config + ConfigureInstallers(); + base.Uninstall(savedState); + + // wire up the event log source, if provided + if (!string.IsNullOrWhiteSpace(Configuration.EventLogSource)) + { + // create the source if it doesn't exist + if (EventLog.SourceExists(Configuration.EventLogSource)) + { + EventLog.DeleteEventSource(Configuration.EventLogSource); + } + } + } + + + /// + /// Rolls back to the state of the counter, and performs the normal rollback. + /// + /// The saved state for the installation. + public override void Rollback(IDictionary savedState) + { + ConsoleHarness.WriteToConsole(ConsoleColor.White, "Rolling back service {0}.", Configuration.Name); + + // load the assembly file name and the config + ConfigureInstallers(); + base.Rollback(savedState); + } + + + /// + /// Method to configure the installers + /// + private void ConfigureInstallers() + { + // load the assembly file name and the config + Installers.Add(ConfigureProcessInstaller()); + Installers.Add(ConfigureServiceInstaller()); + } + + + /// + /// Helper method to configure a process installer for this windows service + /// + /// Process installer for this service + private ServiceProcessInstaller ConfigureProcessInstaller() + { + var result = new ServiceProcessInstaller(); + + // if a user name is not provided, will run under local service acct + if (string.IsNullOrEmpty(Configuration.UserName)) + { + result.Account = Configuration.ServiceAccount; + result.Username = null; + result.Password = null; + } + else + { + // otherwise, runs under the specified user authority + result.Account = ServiceAccount.User; + result.Username = Configuration.UserName; + result.Password = Configuration.Password; + } + + return result; + } + + + /// + /// Helper method to configure a service installer for this windows service + /// + /// Process installer for this service + private ServiceInstaller ConfigureServiceInstaller() + { + // create and config a service installer + var result = new ServiceInstaller + { + ServiceName = Configuration.Name, + DisplayName = Configuration.DisplayName, + Description = Configuration.Description, + StartType = Configuration.StartMode, + }; + + return result; + } + } +} \ No newline at end of file diff --git a/Service/ISystemTemperatureService.cs b/Service/ISystemTemperatureService.cs new file mode 100644 index 0000000..4c85960 --- /dev/null +++ b/Service/ISystemTemperatureService.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; +using System.ServiceModel; + +namespace SystemTemperatureService +{ + [ServiceContract] + interface ISystemTemperatureService + { + [OperationContract] + List GetDeviceList(); + } +} diff --git a/Service/Program.cs b/Service/Program.cs new file mode 100644 index 0000000..681ea71 --- /dev/null +++ b/Service/Program.cs @@ -0,0 +1,61 @@ +using Common.Debug; +using System; +using System.Diagnostics; +using System.Globalization; +using System.Linq; +using System.ServiceProcess; +using SystemTemperatureService.Framework; + +namespace SystemTemperatureService +{ + class Program + { + static void Main(string[] args) + { + Tracer.Initialize(null, null, Process.GetCurrentProcess().Id.ToString(CultureInfo.InvariantCulture), Environment.UserInteractive); + + if (args.Contains("-install", StringComparer.InvariantCultureIgnoreCase)) + { + Tracer.WriteLine("Starting install..."); + + try + { + WindowsServiceInstaller.RuntimeInstall(); + } + catch (Exception exception) + { + Tracer.WriteException("Service install", exception); + } + + Tracer.WriteLine("Install complete"); + } + else if (args.Contains("-uninstall", StringComparer.InvariantCultureIgnoreCase)) + { + Tracer.WriteLine("Starting uninstall..."); + + try + { + WindowsServiceInstaller.RuntimeUnInstall(); + } + catch (Exception exception) + { + Tracer.WriteException("Service uninstall", exception); + } + + Tracer.WriteLine("Uninstall complete"); + } + else + { + Tracer.WriteLine("Starting service"); + + var implementation = new ServiceImplementation(); + + if (Environment.UserInteractive) + ConsoleHarness.Run(args, implementation); + else + ServiceBase.Run(new WindowsServiceHarness(implementation)); + } + + } + } +} diff --git a/Service/Properties/AssemblyInfo.cs b/Service/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..740dc6a --- /dev/null +++ b/Service/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +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("Service")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Service")] +[assembly: AssemblyCopyright("Copyright © 2014")] +[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("9cf103fa-d59f-4abd-b1bd-797119b4843e")] + +// 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")] diff --git a/Service/ServiceImplementation.cs b/Service/ServiceImplementation.cs new file mode 100644 index 0000000..2831e4a --- /dev/null +++ b/Service/ServiceImplementation.cs @@ -0,0 +1,57 @@ +using Common.Debug; +using System; +using System.ServiceModel; +using System.ServiceProcess; +using SystemTemperatureService.Framework; + +namespace SystemTemperatureService +{ + [WindowsService("SystemTemperatureStatus", DisplayName = "System Temperature Status", Description = "", StartMode = ServiceStartMode.Automatic, ServiceAccount = ServiceAccount.LocalSystem)] + public class ServiceImplementation : IWindowsService + { + private ServiceHost _serviceHost; + + public void OnStart(string[] args) + { + using (new BeginEndTracer(GetType().Name)) + { + try + { + _serviceHost = new ServiceHost(typeof(SystemTemperatureService)); + _serviceHost.Open(); + } + catch (Exception exception) + { + Tracer.WriteException("ServiceImplementation.OnStart", exception); + throw; + } + } + } + + public void OnStop() + { + using (new BeginEndTracer(GetType().Name)) + { + try + { + _serviceHost.Close(); + } + catch (Exception exception) + { + Tracer.WriteException("ServiceImplementation.OnStop", exception); + throw; + } + } + } + + public void OnPause() { } + + public void OnContinue() { } + + public void OnShutdown() { } + + public void Dispose() { } + + public void OnCustomCommand(int command) { } + } +} diff --git a/Service/SystemTemperatureService.cs b/Service/SystemTemperatureService.cs new file mode 100644 index 0000000..8f2c9de --- /dev/null +++ b/Service/SystemTemperatureService.cs @@ -0,0 +1,60 @@ +using OpenHardwareMonitor.Hardware; +using System.Collections.Generic; +using System.Linq; + +namespace SystemTemperatureService +{ + public class SystemTemperatureService : ISystemTemperatureService + { + private static Computer _computer; + + public List GetDeviceList() + { + if (_computer == null) + { + _computer = new Computer { HDDEnabled = true, FanControllerEnabled = false, GPUEnabled = true, MainboardEnabled = true, CPUEnabled = true }; + _computer.Open(); + } + + var deviceList = new List(); + + foreach (var hardware in _computer.Hardware) + { + hardware.Update(); + + var averageValue = hardware.Sensors.Where(sensor => sensor.SensorType == SensorType.Temperature).Average(sensor => sensor.Value); + + if (averageValue.HasValue) + { + Device device = null; + + switch (hardware.HardwareType) + { + case HardwareType.CPU: + device = new Device { Type = DeviceType.Cpu }; + break; + + case HardwareType.GpuAti: + case HardwareType.GpuNvidia: + device = new Device { Type = DeviceType.Gpu }; + break; + + case HardwareType.HDD: + device = new Device { Type = DeviceType.Hdd }; + break; + } + + if (device != null) + { + device.Id = hardware.Identifier.ToString(); + device.Temperature = averageValue.Value; + } + + deviceList.Add(device); + } + } + + return deviceList; + } + } +} diff --git a/Service/SystemTemperatureService.csproj b/Service/SystemTemperatureService.csproj new file mode 100644 index 0000000..cdea2cc --- /dev/null +++ b/Service/SystemTemperatureService.csproj @@ -0,0 +1,98 @@ + + + + + Debug + AnyCPU + {94DE06A9-4F37-487B-96E9-663B9A98F05D} + Exe + Properties + SystemTemperatureService + SystemTemperatureService + v4.5 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + app.manifest + + + + + + + + + + + + + + + + + + Component + + + WindowsServiceHarness.cs + + + Component + + + WindowsServiceInstaller.cs + + + + + + + + + + + + + + + {b0397530-545a-471d-bb74-027ae456df1a} + OpenHardwareMonitorLib + + + {17864D82-457D-4A0A-BC10-1D07F2B3A5D6} + Common + + + + + + + + + + \ No newline at end of file diff --git a/app.manifest b/Service/app.manifest similarity index 100% rename from app.manifest rename to Service/app.manifest diff --git a/Service/packages.config b/Service/packages.config new file mode 100644 index 0000000..25b6d61 --- /dev/null +++ b/Service/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/SystemTemperatureStatusWindow.sln b/SystemTemperatureStatusWindow.sln index 48fef20..e5645c2 100644 --- a/SystemTemperatureStatusWindow.sln +++ b/SystemTemperatureStatusWindow.sln @@ -1,26 +1,62 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 -VisualStudioVersion = 12.0.30324.0 +VisualStudioVersion = 12.0.30501.0 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SystemTemperatureStatusWindow", "SystemTemperatureStatusWindow.csproj", "{E45425FD-4302-4555-8F24-18F2373DE1CE}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenHardwareMonitorLib", "..\..\Public\OpenHardwareMonitor\OpenHardwareMonitorLib.csproj", "{B0397530-545A-471D-BB74-027AE456DF1A}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SystemTemperatureStatusWindow", "Window\SystemTemperatureStatusWindow.csproj", "{E45425FD-4302-4555-8F24-18F2373DE1CE}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SystemTemperatureService", "Service\SystemTemperatureService.csproj", "{94DE06A9-4F37-487B-96E9-663B9A98F05D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "..\Common\Common.csproj", "{17864D82-457D-4A0A-BC10-1D07F2B3A5D6}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E45425FD-4302-4555-8F24-18F2373DE1CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E45425FD-4302-4555-8F24-18F2373DE1CE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E45425FD-4302-4555-8F24-18F2373DE1CE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E45425FD-4302-4555-8F24-18F2373DE1CE}.Release|Any CPU.Build.0 = Release|Any CPU {B0397530-545A-471D-BB74-027AE456DF1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B0397530-545A-471D-BB74-027AE456DF1A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0397530-545A-471D-BB74-027AE456DF1A}.Debug|x64.ActiveCfg = Debug|Any CPU + {B0397530-545A-471D-BB74-027AE456DF1A}.Debug|x86.ActiveCfg = Debug|Any CPU {B0397530-545A-471D-BB74-027AE456DF1A}.Release|Any CPU.ActiveCfg = Release|Any CPU {B0397530-545A-471D-BB74-027AE456DF1A}.Release|Any CPU.Build.0 = Release|Any CPU + {B0397530-545A-471D-BB74-027AE456DF1A}.Release|x64.ActiveCfg = Release|Any CPU + {B0397530-545A-471D-BB74-027AE456DF1A}.Release|x86.ActiveCfg = Release|Any CPU + {E45425FD-4302-4555-8F24-18F2373DE1CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E45425FD-4302-4555-8F24-18F2373DE1CE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E45425FD-4302-4555-8F24-18F2373DE1CE}.Debug|x64.ActiveCfg = Debug|Any CPU + {E45425FD-4302-4555-8F24-18F2373DE1CE}.Debug|x86.ActiveCfg = Debug|Any CPU + {E45425FD-4302-4555-8F24-18F2373DE1CE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E45425FD-4302-4555-8F24-18F2373DE1CE}.Release|Any CPU.Build.0 = Release|Any CPU + {E45425FD-4302-4555-8F24-18F2373DE1CE}.Release|x64.ActiveCfg = Release|Any CPU + {E45425FD-4302-4555-8F24-18F2373DE1CE}.Release|x86.ActiveCfg = Release|Any CPU + {94DE06A9-4F37-487B-96E9-663B9A98F05D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {94DE06A9-4F37-487B-96E9-663B9A98F05D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {94DE06A9-4F37-487B-96E9-663B9A98F05D}.Debug|x64.ActiveCfg = Debug|Any CPU + {94DE06A9-4F37-487B-96E9-663B9A98F05D}.Debug|x86.ActiveCfg = Debug|Any CPU + {94DE06A9-4F37-487B-96E9-663B9A98F05D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {94DE06A9-4F37-487B-96E9-663B9A98F05D}.Release|Any CPU.Build.0 = Release|Any CPU + {94DE06A9-4F37-487B-96E9-663B9A98F05D}.Release|x64.ActiveCfg = Release|Any CPU + {94DE06A9-4F37-487B-96E9-663B9A98F05D}.Release|x86.ActiveCfg = Release|Any CPU + {17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Debug|x64.ActiveCfg = Debug|x64 + {17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Debug|x64.Build.0 = Debug|x64 + {17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Debug|x86.ActiveCfg = Debug|x86 + {17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Debug|x86.Build.0 = Debug|x86 + {17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Release|Any CPU.Build.0 = Release|Any CPU + {17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Release|x64.ActiveCfg = Release|x64 + {17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Release|x64.Build.0 = Release|x64 + {17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Release|x86.ActiveCfg = Release|x86 + {17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/App.config b/Window/App.config similarity index 66% rename from App.config rename to Window/App.config index 6ad5b04..59b8a36 100644 --- a/App.config +++ b/Window/App.config @@ -5,7 +5,7 @@
- + @@ -30,4 +30,21 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/App.xaml b/Window/App.xaml similarity index 100% rename from App.xaml rename to Window/App.xaml diff --git a/App.xaml.cs b/Window/App.xaml.cs similarity index 100% rename from App.xaml.cs rename to Window/App.xaml.cs diff --git a/Properties/AssemblyInfo.cs b/Window/Properties/AssemblyInfo.cs similarity index 100% rename from Properties/AssemblyInfo.cs rename to Window/Properties/AssemblyInfo.cs diff --git a/Properties/Resources.Designer.cs b/Window/Properties/Resources.Designer.cs similarity index 100% rename from Properties/Resources.Designer.cs rename to Window/Properties/Resources.Designer.cs diff --git a/Properties/Resources.resx b/Window/Properties/Resources.resx similarity index 100% rename from Properties/Resources.resx rename to Window/Properties/Resources.resx diff --git a/Properties/Settings.Designer.cs b/Window/Properties/Settings.Designer.cs similarity index 100% rename from Properties/Settings.Designer.cs rename to Window/Properties/Settings.Designer.cs diff --git a/Properties/Settings.settings b/Window/Properties/Settings.settings similarity index 100% rename from Properties/Settings.settings rename to Window/Properties/Settings.settings diff --git a/Resources/ApplicationIcon.ico b/Window/Resources/ApplicationIcon.ico similarity index 100% rename from Resources/ApplicationIcon.ico rename to Window/Resources/ApplicationIcon.ico diff --git a/Window/Service References/SystemTemperatureService/Reference.cs b/Window/Service References/SystemTemperatureService/Reference.cs new file mode 100644 index 0000000..91da377 --- /dev/null +++ b/Window/Service References/SystemTemperatureService/Reference.cs @@ -0,0 +1,153 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.34209 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SystemTemperatureStatusWindow.SystemTemperatureService { + using System.Runtime.Serialization; + using System; + + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")] + [System.Runtime.Serialization.DataContractAttribute(Name="Device", Namespace="http://schemas.datacontract.org/2004/07/SystemTemperatureService")] + [System.SerializableAttribute()] + public partial class Device : object, System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged { + + [System.NonSerializedAttribute()] + private System.Runtime.Serialization.ExtensionDataObject extensionDataField; + + [System.Runtime.Serialization.OptionalFieldAttribute()] + private string IdField; + + [System.Runtime.Serialization.OptionalFieldAttribute()] + private double TemperatureField; + + [System.Runtime.Serialization.OptionalFieldAttribute()] + private SystemTemperatureStatusWindow.SystemTemperatureService.DeviceType TypeField; + + [global::System.ComponentModel.BrowsableAttribute(false)] + public System.Runtime.Serialization.ExtensionDataObject ExtensionData { + get { + return this.extensionDataField; + } + set { + this.extensionDataField = value; + } + } + + [System.Runtime.Serialization.DataMemberAttribute()] + public string Id { + get { + return this.IdField; + } + set { + if ((object.ReferenceEquals(this.IdField, value) != true)) { + this.IdField = value; + this.RaisePropertyChanged("Id"); + } + } + } + + [System.Runtime.Serialization.DataMemberAttribute()] + public double Temperature { + get { + return this.TemperatureField; + } + set { + if ((this.TemperatureField.Equals(value) != true)) { + this.TemperatureField = value; + this.RaisePropertyChanged("Temperature"); + } + } + } + + [System.Runtime.Serialization.DataMemberAttribute()] + public SystemTemperatureStatusWindow.SystemTemperatureService.DeviceType Type { + get { + return this.TypeField; + } + set { + if ((this.TypeField.Equals(value) != true)) { + this.TypeField = value; + this.RaisePropertyChanged("Type"); + } + } + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected void RaisePropertyChanged(string propertyName) { + System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged; + if ((propertyChanged != null)) { + propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } + } + + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")] + [System.Runtime.Serialization.DataContractAttribute(Name="DeviceType", Namespace="http://schemas.datacontract.org/2004/07/SystemTemperatureService")] + public enum DeviceType : int { + + [System.Runtime.Serialization.EnumMemberAttribute()] + Cpu = 0, + + [System.Runtime.Serialization.EnumMemberAttribute()] + Gpu = 1, + + [System.Runtime.Serialization.EnumMemberAttribute()] + Hdd = 2, + } + + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + [System.ServiceModel.ServiceContractAttribute(ConfigurationName="SystemTemperatureService.ISystemTemperatureService")] + public interface ISystemTemperatureService { + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ISystemTemperatureService/GetDeviceList", ReplyAction="http://tempuri.org/ISystemTemperatureService/GetDeviceListResponse")] + System.Collections.Generic.List GetDeviceList(); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ISystemTemperatureService/GetDeviceList", ReplyAction="http://tempuri.org/ISystemTemperatureService/GetDeviceListResponse")] + System.Threading.Tasks.Task> GetDeviceListAsync(); + } + + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + public interface ISystemTemperatureServiceChannel : SystemTemperatureStatusWindow.SystemTemperatureService.ISystemTemperatureService, System.ServiceModel.IClientChannel { + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + public partial class SystemTemperatureServiceClient : System.ServiceModel.ClientBase, SystemTemperatureStatusWindow.SystemTemperatureService.ISystemTemperatureService { + + public SystemTemperatureServiceClient() { + } + + public SystemTemperatureServiceClient(string endpointConfigurationName) : + base(endpointConfigurationName) { + } + + public SystemTemperatureServiceClient(string endpointConfigurationName, string remoteAddress) : + base(endpointConfigurationName, remoteAddress) { + } + + public SystemTemperatureServiceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : + base(endpointConfigurationName, remoteAddress) { + } + + public SystemTemperatureServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : + base(binding, remoteAddress) { + } + + public System.Collections.Generic.List GetDeviceList() { + return base.Channel.GetDeviceList(); + } + + public System.Threading.Tasks.Task> GetDeviceListAsync() { + return base.Channel.GetDeviceListAsync(); + } + } +} diff --git a/Window/Service References/SystemTemperatureService/Reference.svcmap b/Window/Service References/SystemTemperatureService/Reference.svcmap new file mode 100644 index 0000000..39d57fe --- /dev/null +++ b/Window/Service References/SystemTemperatureService/Reference.svcmap @@ -0,0 +1,37 @@ + + + + false + true + true + + false + false + false + + + + + true + Auto + true + true + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Window/Service References/SystemTemperatureService/SystemTemperatureService1.disco b/Window/Service References/SystemTemperatureService/SystemTemperatureService1.disco new file mode 100644 index 0000000..a985d86 --- /dev/null +++ b/Window/Service References/SystemTemperatureService/SystemTemperatureService1.disco @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Window/Service References/SystemTemperatureService/SystemTemperatureService1.wsdl b/Window/Service References/SystemTemperatureService/SystemTemperatureService1.wsdl new file mode 100644 index 0000000..328b2ed --- /dev/null +++ b/Window/Service References/SystemTemperatureService/SystemTemperatureService1.wsdl @@ -0,0 +1,182 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + http://localhost/SystemTemperatureService/SystemTemperatureService.svc + + localhost + + + + + \ No newline at end of file diff --git a/Window/Service References/SystemTemperatureService/SystemTemperatureService3.xsd b/Window/Service References/SystemTemperatureService/SystemTemperatureService3.xsd new file mode 100644 index 0000000..9148573 --- /dev/null +++ b/Window/Service References/SystemTemperatureService/SystemTemperatureService3.xsd @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Window/Service References/SystemTemperatureService/SystemTemperatureService31.xsd b/Window/Service References/SystemTemperatureService/SystemTemperatureService31.xsd new file mode 100644 index 0000000..5bf52ae --- /dev/null +++ b/Window/Service References/SystemTemperatureService/SystemTemperatureService31.xsd @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Window/Service References/SystemTemperatureService/SystemTemperatureService32.xsd b/Window/Service References/SystemTemperatureService/SystemTemperatureService32.xsd new file mode 100644 index 0000000..d58e7f3 --- /dev/null +++ b/Window/Service References/SystemTemperatureService/SystemTemperatureService32.xsd @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Window/Service References/SystemTemperatureService/SystemTemperatureStatusWindow.SystemTemperatureService.Device.datasource b/Window/Service References/SystemTemperatureService/SystemTemperatureStatusWindow.SystemTemperatureService.Device.datasource new file mode 100644 index 0000000..00ca8d3 --- /dev/null +++ b/Window/Service References/SystemTemperatureService/SystemTemperatureStatusWindow.SystemTemperatureService.Device.datasource @@ -0,0 +1,10 @@ + + + + SystemTemperatureStatusWindow.SystemTemperatureService.Device, Service References.SystemTemperatureService.Reference.cs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/Window/Service References/SystemTemperatureService/configuration.svcinfo b/Window/Service References/SystemTemperatureService/configuration.svcinfo new file mode 100644 index 0000000..1d28bbe --- /dev/null +++ b/Window/Service References/SystemTemperatureService/configuration.svcinfo @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Window/Service References/SystemTemperatureService/configuration91.svcinfo b/Window/Service References/SystemTemperatureService/configuration91.svcinfo new file mode 100644 index 0000000..74610fe --- /dev/null +++ b/Window/Service References/SystemTemperatureService/configuration91.svcinfo @@ -0,0 +1,216 @@ + + + + + + + WSHttpBinding_ISystemTemperatureService + + + + + + + + + + + + + + + + + + False + + + StrongWildcard + + + + + + + + + Text + + + + + + System.ServiceModel.Configuration.XmlDictionaryReaderQuotasElement + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + System.ServiceModel.Configuration.StandardBindingOptionalReliableSessionElement + + + True + + + 00:10:00 + + + False + + + System.Text.UTF8Encoding + + + + + + + + + System.ServiceModel.Configuration.WSHttpSecurityElement + + + Message + + + System.ServiceModel.Configuration.WSHttpTransportSecurityElement + + + Windows + + + None + + + System.Security.Authentication.ExtendedProtection.Configuration.ExtendedProtectionPolicyElement + + + Never + + + TransportSelected + + + (Collection) + + + + + + System.ServiceModel.Configuration.NonDualMessageSecurityOverHttpElement + + + Windows + + + True + + + Default + + + True + + + + + + + + + http://localhost/SystemTemperatureService/SystemTemperatureService.svc + + + + + + wsHttpBinding + + + WSHttpBinding_ISystemTemperatureService + + + SystemTemperatureService.ISystemTemperatureService + + + System.ServiceModel.Configuration.AddressHeaderCollectionElement + + + <Header /> + + + System.ServiceModel.Configuration.IdentityElement + + + System.ServiceModel.Configuration.UserPrincipalNameElement + + + + + + System.ServiceModel.Configuration.ServicePrincipalNameElement + + + + + + System.ServiceModel.Configuration.DnsElement + + + localhost + + + System.ServiceModel.Configuration.RsaElement + + + + + + System.ServiceModel.Configuration.CertificateElement + + + + + + System.ServiceModel.Configuration.CertificateReferenceElement + + + My + + + LocalMachine + + + FindBySubjectDistinguishedName + + + + + + False + + + WSHttpBinding_ISystemTemperatureService + + + + + + + + + + + \ No newline at end of file diff --git a/SystemTemperatureStatusWindow.csproj b/Window/SystemTemperatureStatusWindow.csproj similarity index 67% rename from SystemTemperatureStatusWindow.csproj rename to Window/SystemTemperatureStatusWindow.csproj index 4dbe8d3..ef9c4dd 100644 --- a/SystemTemperatureStatusWindow.csproj +++ b/Window/SystemTemperatureStatusWindow.csproj @@ -33,15 +33,15 @@ prompt 4 - - app.manifest - + - ..\FloatingStatusWindowLibrary\FloatingStatusWindowLibrary\bin\Debug\FloatingStatusWindowLibrary.dll + ..\..\FloatingStatusWindowLibrary\FloatingStatusWindowLibrary\bin\Debug\FloatingStatusWindowLibrary.dll + + @@ -60,6 +60,11 @@ App.xaml Code + + True + True + Reference.svcmap + @@ -80,12 +85,24 @@ ResXFileCodeGenerator Resources.Designer.cs - SettingsSingleFileGenerator Settings.Designer.cs + + + Designer + + + Designer + + + Designer + + + Reference.svcmap + @@ -94,10 +111,25 @@ - - {b0397530-545a-471d-bb74-027ae456df1a} - OpenHardwareMonitorLib - + + + + + + + + + + + + + + WCF Proxy Generator + Reference.cs + + + +