Temperature Logger Codes

This commit is contained in:
GERALD V. SORIANO 2025-02-07 16:30:55 +08:00
commit 0ecbbb949b
2046 changed files with 145004 additions and 0 deletions

Binary file not shown.

View File

@ -0,0 +1,106 @@
{
"Version": 1,
"WorkspaceRootPath": "C:\\Users\\soriano.gv\\source\\repos\\TempLogServices\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{AF840345-72E9-4090-B0A3-B07B3D404625}|TempLogServices\\TempLogServices.csproj|C:\\Users\\soriano.gv\\source\\repos\\TempLogServices\\templogservices\\templogservice.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}|Form",
"RelativeMoniker": "D:0:0:{AF840345-72E9-4090-B0A3-B07B3D404625}|TempLogServices\\TempLogServices.csproj|solutionrelative:templogservices\\templogservice.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}|Form"
},
{
"AbsoluteMoniker": "D:0:0:{AF840345-72E9-4090-B0A3-B07B3D404625}|TempLogServices\\TempLogServices.csproj|C:\\Users\\soriano.gv\\source\\repos\\TempLogServices\\templogservices\\projectinstaller.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{AF840345-72E9-4090-B0A3-B07B3D404625}|TempLogServices\\TempLogServices.csproj|solutionrelative:templogservices\\projectinstaller.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{AF840345-72E9-4090-B0A3-B07B3D404625}|TempLogServices\\TempLogServices.csproj|c:\\users\\soriano.gv\\source\\repos\\templogservices\\templogservices\\templogservice.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{AF840345-72E9-4090-B0A3-B07B3D404625}|TempLogServices\\TempLogServices.csproj|solutionrelative:templogservices\\templogservice.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{AF840345-72E9-4090-B0A3-B07B3D404625}|TempLogServices\\TempLogServices.csproj|C:\\Users\\soriano.gv\\source\\repos\\TempLogServices\\templogservices\\projectinstaller.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}|Form",
"RelativeMoniker": "D:0:0:{AF840345-72E9-4090-B0A3-B07B3D404625}|TempLogServices\\TempLogServices.csproj|solutionrelative:templogservices\\projectinstaller.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}|Form"
},
{
"AbsoluteMoniker": "D:0:0:{AF840345-72E9-4090-B0A3-B07B3D404625}|TempLogServices\\TempLogServices.csproj|C:\\Users\\soriano.gv\\source\\repos\\TempLogServices\\templogservices\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{AF840345-72E9-4090-B0A3-B07B3D404625}|TempLogServices\\TempLogServices.csproj|solutionrelative:templogservices\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
}
],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 5,
"Children": [
{
"$type": "Document",
"DocumentIndex": 2,
"Title": "TempLogService.cs",
"DocumentMoniker": "C:\\Users\\soriano.gv\\source\\repos\\TempLogServices\\TempLogServices\\TempLogService.cs",
"RelativeDocumentMoniker": "TempLogServices\\TempLogService.cs",
"ToolTip": "C:\\Users\\soriano.gv\\source\\repos\\TempLogServices\\TempLogServices\\TempLogService.cs",
"RelativeToolTip": "TempLogServices\\TempLogService.cs",
"ViewState": "AQIAACYAAAAAAAAAAAAEwB0AAAAuAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-02-05T08:22:42.174Z",
"EditorCaption": ""
},
{
"$type": "Bookmark",
"Name": "ST:0:0:{cce594b6-0c39-4442-ba28-10c64ac7e89f}"
},
{
"$type": "Document",
"DocumentIndex": 1,
"Title": "ProjectInstaller.cs",
"DocumentMoniker": "C:\\Users\\soriano.gv\\source\\repos\\TempLogServices\\TempLogServices\\ProjectInstaller.cs",
"RelativeDocumentMoniker": "TempLogServices\\ProjectInstaller.cs",
"ToolTip": "C:\\Users\\soriano.gv\\source\\repos\\TempLogServices\\TempLogServices\\ProjectInstaller.cs",
"RelativeToolTip": "TempLogServices\\ProjectInstaller.cs",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAA0AAAAJAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-02-06T08:39:21.575Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 4,
"Title": "Program.cs",
"DocumentMoniker": "C:\\Users\\soriano.gv\\source\\repos\\TempLogServices\\TempLogServices\\Program.cs",
"RelativeDocumentMoniker": "TempLogServices\\Program.cs",
"ToolTip": "C:\\Users\\soriano.gv\\source\\repos\\TempLogServices\\TempLogServices\\Program.cs*",
"RelativeToolTip": "TempLogServices\\Program.cs*",
"ViewState": "AQIAAAAAAAAAAAAAAAAAABIAAAAnAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-02-06T08:38:29.195Z"
},
{
"$type": "Document",
"DocumentIndex": 3,
"Title": "ProjectInstaller.cs [Design]",
"DocumentMoniker": "C:\\Users\\soriano.gv\\source\\repos\\TempLogServices\\TempLogServices\\ProjectInstaller.cs",
"RelativeDocumentMoniker": "TempLogServices\\ProjectInstaller.cs",
"ToolTip": "C:\\Users\\soriano.gv\\source\\repos\\TempLogServices\\TempLogServices\\ProjectInstaller.cs [Design]",
"RelativeToolTip": "TempLogServices\\ProjectInstaller.cs [Design]",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-02-05T08:44:13.308Z",
"EditorCaption": " [Design]"
},
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "TempLogService.cs [Design]",
"DocumentMoniker": "C:\\Users\\soriano.gv\\source\\repos\\TempLogServices\\TempLogServices\\TempLogService.cs",
"RelativeDocumentMoniker": "TempLogServices\\TempLogService.cs",
"ToolTip": "C:\\Users\\soriano.gv\\source\\repos\\TempLogServices\\TempLogServices\\TempLogService.cs [Design]",
"RelativeToolTip": "TempLogServices\\TempLogService.cs [Design]",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-02-05T08:22:38.026Z",
"EditorCaption": " [Design]"
}
]
}
]
}
]
}

View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.10.35122.118
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TempLogServices", "TempLogServices\TempLogServices.csproj", "{AF840345-72E9-4090-B0A3-B07B3D404625}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AF840345-72E9-4090-B0A3-B07B3D404625}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AF840345-72E9-4090-B0A3-B07B3D404625}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AF840345-72E9-4090-B0A3-B07B3D404625}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AF840345-72E9-4090-B0A3-B07B3D404625}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1E53185F-0FC1-4490-AC72-154670B601C4}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceProcess;
using System.Text;
namespace TempLogServices
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main(string[] args)
{
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new TempLogService(args)
};
ServiceBase.Run(ServicesToRun);
}
}
}

View File

@ -0,0 +1,60 @@
namespace TempLogServices
{
partial class ProjectInstaller
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.serviceProcessInstaller1 = new System.ServiceProcess.ServiceProcessInstaller();
this.TempLogService = new System.ServiceProcess.ServiceInstaller();
//
// serviceProcessInstaller1
//
this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem;
this.serviceProcessInstaller1.Password = null;
this.serviceProcessInstaller1.Username = null;
//
// TempLogService
//
this.TempLogService.Description = "Temperature Logger Service App";
this.TempLogService.DisplayName = "Temperature Logger Service";
this.TempLogService.ServiceName = "Service1";
this.TempLogService.StartType = System.ServiceProcess.ServiceStartMode.Automatic;
//
// ProjectInstaller
//
this.Installers.AddRange(new System.Configuration.Install.Installer[] {
this.serviceProcessInstaller1,
this.TempLogService});
}
#endregion
private System.ServiceProcess.ServiceProcessInstaller serviceProcessInstaller1;
private System.ServiceProcess.ServiceInstaller TempLogService;
}
}

View File

@ -0,0 +1,24 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.Linq;
namespace TempLogServices
{
[RunInstaller(true)]
public partial class ProjectInstaller : System.Configuration.Install.Installer
{
public ProjectInstaller()
{
InitializeComponent();
}
protected override void OnBeforeInstall(IDictionary savedState)
{
string parameter = "MySource1\" \"MyLogFile1";
Context.Parameters["assemblypath"] = "\"" + Context.Parameters["assemblypath"] + "\" \"" + parameter + "\"";
base.OnBeforeInstall(savedState);
}
}
}

View File

@ -0,0 +1,129 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="serviceProcessInstaller1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="TempLogService.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>194, 17</value>
</metadata>
<metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
</root>

View 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("TempLogServices")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TempLogServices")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[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("af840345-72e9-4090-b0a3-b07b3d404625")]
// 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")]

View File

@ -0,0 +1,48 @@
namespace TempLogServices
{
partial class TempLogService
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.eventLog1 = new System.Diagnostics.EventLog();
this.serialPort1 = new System.IO.Ports.SerialPort(this.components);
((System.ComponentModel.ISupportInitialize)(this.eventLog1)).BeginInit();
//
// TempLogService
//
this.ServiceName = "Service1";
((System.ComponentModel.ISupportInitialize)(this.eventLog1)).EndInit();
}
#endregion
private System.Diagnostics.EventLog eventLog1;
private System.IO.Ports.SerialPort serialPort1;
}
}

View File

@ -0,0 +1,96 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Runtime.InteropServices;
namespace TempLogServices
{
public partial class TempLogService : ServiceBase
{
public enum ServiceState
{
SERVICE_STOPPED = 0x00000001,
SERVICE_START_PENDING = 0x00000002,
SERVICE_STOP_PENDING = 0x00000003,
SERVICE_RUNNING = 0x00000004,
SERVICE_CONTINUE_PENDING = 0x00000005,
SERVICE_PAUSE_PENDING = 0x00000006,
SERVICE_PAUSED = 0x00000007,
}
[StructLayout(LayoutKind.Sequential)]
public struct ServiceStatus
{
public int dwServiceType;
public ServiceState dwCurrentState;
public int dwControlsAccepted;
public int dwWin32ExitCode;
public int dwServiceSpecificExitCode;
public int dwCheckPoint;
public int dwWaitHint;
};
[DllImport("advapi32.dll", SetLastError = true)]
private static extern bool SetServiceStatus(System.IntPtr handle, ref ServiceStatus serviceStatus);
public TempLogService(string[] args)
{
InitializeComponent();
eventLog1 = new EventLog();
if (!EventLog.SourceExists("TempLogService")) {
EventLog.CreateEventSource("TempLogApp", "TempLogService");
}
eventLog1.Source = "TempLogApp";
eventLog1.Log = "TempLogService";
if (args != null)
{
eventLog1.WriteEntry("Args Count: " + args.Length.ToString());
}
}
protected override void OnStart(string[] args)
{
// Update the service state to Start Pending.
ServiceStatus serviceStatus = new ServiceStatus();
serviceStatus.dwCurrentState = ServiceState.SERVICE_START_PENDING;
serviceStatus.dwWaitHint = 100000;
SetServiceStatus(this.ServiceHandle, ref serviceStatus);
eventLog1.WriteEntry("Service Started.");
// Update the service state to Running.
serviceStatus.dwCurrentState = ServiceState.SERVICE_RUNNING;
SetServiceStatus(this.ServiceHandle, ref serviceStatus);
}
protected override void OnStop()
{
// Update the service state to Stop Pending.
ServiceStatus serviceStatus = new ServiceStatus();
serviceStatus.dwCurrentState = ServiceState.SERVICE_STOP_PENDING;
serviceStatus.dwWaitHint = 100000;
SetServiceStatus(this.ServiceHandle, ref serviceStatus);
// Update the service state to Stopped.
serviceStatus.dwCurrentState = ServiceState.SERVICE_STOPPED;
SetServiceStatus(this.ServiceHandle, ref serviceStatus);
eventLog1.WriteEntry("Service Stopped.");
}
protected override void OnContinue()
{
eventLog1.WriteEntry("Service continue.");
}
}
}

View File

@ -0,0 +1,129 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="eventLog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 54</value>
</metadata>
<metadata name="serialPort1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>117, 56</value>
</metadata>
<metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
</root>

View File

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" 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>{AF840345-72E9-4090-B0A3-B07B3D404625}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>TempLogServices</RootNamespace>
<AssemblyName>TempLogServices</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</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>
<PropertyGroup>
<StartupObject>TempLogServices.Program</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Configuration.Install" />
<Reference Include="System.Core" />
<Reference Include="System.Management" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ProjectInstaller.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="ProjectInstaller.Designer.cs">
<DependentUpon>ProjectInstaller.cs</DependentUpon>
</Compile>
<Compile Include="TempLogService.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="TempLogService.Designer.cs">
<DependentUpon>TempLogService.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="ProjectInstaller.resx">
<DependentUpon>ProjectInstaller.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="TempLogService.resx">
<DependentUpon>TempLogService.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -0,0 +1,14 @@

Running a transacted installation.
Beginning the Install phase of the installation.
See the contents of the log file for the C:\Users\soriano.gv\source\repos\TempLogServices\TempLogServices\bin\Debug\TempLogServices.exe assembly's progress.
The file is located at C:\Users\soriano.gv\source\repos\TempLogServices\TempLogServices\bin\Debug\TempLogServices.InstallLog.
The Install phase completed successfully, and the Commit phase is beginning.
See the contents of the log file for the C:\Users\soriano.gv\source\repos\TempLogServices\TempLogServices\bin\Debug\TempLogServices.exe assembly's progress.
The file is located at C:\Users\soriano.gv\source\repos\TempLogServices\TempLogServices\bin\Debug\TempLogServices.InstallLog.
The Commit phase completed successfully.
The transacted install has completed.

View File

@ -0,0 +1,13 @@
Installing assembly 'C:\Users\soriano.gv\source\repos\TempLogServices\TempLogServices\bin\Debug\TempLogServices.exe'.
Affected parameters are:
logtoconsole =
logfile = C:\Users\soriano.gv\source\repos\TempLogServices\TempLogServices\bin\Debug\TempLogServices.InstallLog
assemblypath = C:\Users\soriano.gv\source\repos\TempLogServices\TempLogServices\bin\Debug\TempLogServices.exe
Installing service Service1...
Service Service1 has been successfully installed.
Creating EventLog source Service1 in log Application...
Committing assembly 'C:\Users\soriano.gv\source\repos\TempLogServices\TempLogServices\bin\Debug\TempLogServices.exe'.
Affected parameters are:
logtoconsole =
logfile = C:\Users\soriano.gv\source\repos\TempLogServices\TempLogServices\bin\Debug\TempLogServices.InstallLog
assemblypath = C:\Users\soriano.gv\source\repos\TempLogServices\TempLogServices\bin\Debug\TempLogServices.exe

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
d37fd97383241adfe76fb67a62209ea87c56606c3a185ff262e44f95fd0e7f23

View File

@ -0,0 +1,9 @@
C:\Users\soriano.gv\source\repos\TempLogServices\TempLogServices\obj\Debug\TempLogServices.csproj.AssemblyReference.cache
C:\Users\soriano.gv\source\repos\TempLogServices\TempLogServices\obj\Debug\TempLogServices.ProjectInstaller.resources
C:\Users\soriano.gv\source\repos\TempLogServices\TempLogServices\obj\Debug\TempLogServices.TempLogService.resources
C:\Users\soriano.gv\source\repos\TempLogServices\TempLogServices\obj\Debug\TempLogServices.csproj.GenerateResource.cache
C:\Users\soriano.gv\source\repos\TempLogServices\TempLogServices\obj\Debug\TempLogServices.csproj.CoreCompileInputs.cache
C:\Users\soriano.gv\source\repos\TempLogServices\TempLogServices\bin\Debug\TempLogServices.exe
C:\Users\soriano.gv\source\repos\TempLogServices\TempLogServices\bin\Debug\TempLogServices.pdb
C:\Users\soriano.gv\source\repos\TempLogServices\TempLogServices\obj\Debug\TempLogServices.exe
C:\Users\soriano.gv\source\repos\TempLogServices\TempLogServices\obj\Debug\TempLogServices.pdb

View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.10.35122.118
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TemperatureLoggerAPI", "TemperatureLoggerAPI\TemperatureLoggerAPI.csproj", "{0B883E02-A272-4C64-8EBE-D311C8B47DD9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0B883E02-A272-4C64-8EBE-D311C8B47DD9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0B883E02-A272-4C64-8EBE-D311C8B47DD9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0B883E02-A272-4C64-8EBE-D311C8B47DD9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0B883E02-A272-4C64-8EBE-D311C8B47DD9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2F14467E-6A05-482B-B427-ABF44F0EFB5D}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,13 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "9.0.0",
"commands": [
"dotnet-ef"
],
"rollForward": false
}
}
}

View File

@ -0,0 +1,30 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using TemperatureLoggerAPI.Models;
namespace TemperatureLoggerAPI.Controllers
{
[Route("[controller]")]
[ApiController]
public class TempLogController : ControllerBase
{
private readonly TemperatureLoggerAPIContext _context;
public TempLogController() {
_context = new TemperatureLoggerAPIContext();
}
[HttpPost]
public ActionResult PostTemp(TempLogs log) {
var res = 0;
if (log != null)
{
if (log.templog == null) log.templog = DateTime.Now;
_context.TempLogs.Add(log);
res = _context.SaveChanges();
}
return Ok(new { is_success = res > 0 });
}
}
}

View File

@ -0,0 +1,92 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using TemperatureLoggerAPI;
#nullable disable
namespace TemperatureLoggerAPI.Migrations
{
[DbContext(typeof(TemperatureLoggerAPIContext))]
[Migration("20241216052346_initial")]
partial class initial
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("TemperatureLoggerAPI.Models.DeviceInfo", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("DeviceInfo");
});
modelBuilder.Entity("TemperatureLoggerAPI.Models.TempLogs", b =>
{
b.Property<long>("id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
b.Property<decimal?>("Humidity")
.HasColumnType("decimal(18,2)");
b.Property<decimal?>("TempC")
.HasColumnType("decimal(18,2)");
b.Property<decimal?>("TempF")
.HasColumnType("decimal(18,2)");
b.Property<int>("deviceId")
.HasColumnType("int");
b.Property<DateTime>("templog")
.HasColumnType("datetime2");
b.HasKey("id");
b.HasIndex("deviceId");
b.ToTable("TempLogs");
});
modelBuilder.Entity("TemperatureLoggerAPI.Models.TempLogs", b =>
{
b.HasOne("TemperatureLoggerAPI.Models.DeviceInfo", "device")
.WithMany()
.HasForeignKey("deviceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("device");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,67 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace TemperatureLoggerAPI.Migrations
{
/// <inheritdoc />
public partial class initial : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "DeviceInfo",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
Description = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DeviceInfo", x => x.Id);
});
migrationBuilder.CreateTable(
name: "TempLogs",
columns: table => new
{
id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
templog = table.Column<DateTime>(type: "datetime2", nullable: false),
Humidity = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
TempC = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
TempF = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
deviceId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_TempLogs", x => x.id);
table.ForeignKey(
name: "FK_TempLogs_DeviceInfo_deviceId",
column: x => x.deviceId,
principalTable: "DeviceInfo",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_TempLogs_deviceId",
table: "TempLogs",
column: "deviceId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "TempLogs");
migrationBuilder.DropTable(
name: "DeviceInfo");
}
}
}

View File

@ -0,0 +1,90 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using TemperatureLoggerAPI;
#nullable disable
namespace TemperatureLoggerAPI.Migrations
{
[DbContext(typeof(TemperatureLoggerAPIContext))]
[Migration("20241216053437_update-deviceinfo")]
partial class updatedeviceinfo
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("TemperatureLoggerAPI.Models.DeviceInfo", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("DeviceInfo");
});
modelBuilder.Entity("TemperatureLoggerAPI.Models.TempLogs", b =>
{
b.Property<long>("id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
b.Property<decimal?>("Humidity")
.HasColumnType("decimal(18,2)");
b.Property<decimal?>("TempC")
.HasColumnType("decimal(18,2)");
b.Property<decimal?>("TempF")
.HasColumnType("decimal(18,2)");
b.Property<int?>("deviceId")
.HasColumnType("int");
b.Property<DateTime>("templog")
.HasColumnType("datetime2");
b.HasKey("id");
b.HasIndex("deviceId");
b.ToTable("TempLogs");
});
modelBuilder.Entity("TemperatureLoggerAPI.Models.TempLogs", b =>
{
b.HasOne("TemperatureLoggerAPI.Models.DeviceInfo", "device")
.WithMany()
.HasForeignKey("deviceId");
b.Navigation("device");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,59 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace TemperatureLoggerAPI.Migrations
{
/// <inheritdoc />
public partial class updatedeviceinfo : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_TempLogs_DeviceInfo_deviceId",
table: "TempLogs");
migrationBuilder.AlterColumn<int>(
name: "deviceId",
table: "TempLogs",
type: "int",
nullable: true,
oldClrType: typeof(int),
oldType: "int");
migrationBuilder.AddForeignKey(
name: "FK_TempLogs_DeviceInfo_deviceId",
table: "TempLogs",
column: "deviceId",
principalTable: "DeviceInfo",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_TempLogs_DeviceInfo_deviceId",
table: "TempLogs");
migrationBuilder.AlterColumn<int>(
name: "deviceId",
table: "TempLogs",
type: "int",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "int",
oldNullable: true);
migrationBuilder.AddForeignKey(
name: "FK_TempLogs_DeviceInfo_deviceId",
table: "TempLogs",
column: "deviceId",
principalTable: "DeviceInfo",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

View File

@ -0,0 +1,90 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using TemperatureLoggerAPI;
#nullable disable
namespace TemperatureLoggerAPI.Migrations
{
[DbContext(typeof(TemperatureLoggerAPIContext))]
[Migration("20241216053702_update-deviceinfo-add-deviceid")]
partial class updatedeviceinfoadddeviceid
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("TemperatureLoggerAPI.Models.DeviceInfo", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("DeviceInfo");
});
modelBuilder.Entity("TemperatureLoggerAPI.Models.TempLogs", b =>
{
b.Property<long>("id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
b.Property<decimal?>("Humidity")
.HasColumnType("decimal(18,2)");
b.Property<decimal?>("TempC")
.HasColumnType("decimal(18,2)");
b.Property<decimal?>("TempF")
.HasColumnType("decimal(18,2)");
b.Property<int?>("deviceID")
.HasColumnType("int");
b.Property<DateTime>("templog")
.HasColumnType("datetime2");
b.HasKey("id");
b.HasIndex("deviceID");
b.ToTable("TempLogs");
});
modelBuilder.Entity("TemperatureLoggerAPI.Models.TempLogs", b =>
{
b.HasOne("TemperatureLoggerAPI.Models.DeviceInfo", "device")
.WithMany()
.HasForeignKey("deviceID");
b.Navigation("device");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,60 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace TemperatureLoggerAPI.Migrations
{
/// <inheritdoc />
public partial class updatedeviceinfoadddeviceid : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_TempLogs_DeviceInfo_deviceId",
table: "TempLogs");
migrationBuilder.RenameColumn(
name: "deviceId",
table: "TempLogs",
newName: "deviceID");
migrationBuilder.RenameIndex(
name: "IX_TempLogs_deviceId",
table: "TempLogs",
newName: "IX_TempLogs_deviceID");
migrationBuilder.AddForeignKey(
name: "FK_TempLogs_DeviceInfo_deviceID",
table: "TempLogs",
column: "deviceID",
principalTable: "DeviceInfo",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_TempLogs_DeviceInfo_deviceID",
table: "TempLogs");
migrationBuilder.RenameColumn(
name: "deviceID",
table: "TempLogs",
newName: "deviceId");
migrationBuilder.RenameIndex(
name: "IX_TempLogs_deviceID",
table: "TempLogs",
newName: "IX_TempLogs_deviceId");
migrationBuilder.AddForeignKey(
name: "FK_TempLogs_DeviceInfo_deviceId",
table: "TempLogs",
column: "deviceId",
principalTable: "DeviceInfo",
principalColumn: "Id");
}
}
}

View File

@ -0,0 +1,93 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using TemperatureLoggerAPI;
#nullable disable
namespace TemperatureLoggerAPI.Migrations
{
[DbContext(typeof(TemperatureLoggerAPIContext))]
[Migration("20241216054111_update-deviceinfo-add-dev_id")]
partial class updatedeviceinfoadddev_id
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("TemperatureLoggerAPI.Models.DeviceInfo", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("DeviceInfo");
});
modelBuilder.Entity("TemperatureLoggerAPI.Models.TempLogs", b =>
{
b.Property<long>("id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
b.Property<decimal?>("Humidity")
.HasColumnType("decimal(18,2)");
b.Property<decimal?>("TempC")
.HasColumnType("decimal(18,2)");
b.Property<decimal?>("TempF")
.HasColumnType("decimal(18,2)");
b.Property<int?>("dev_ID")
.HasColumnType("int");
b.Property<int?>("deviceId")
.HasColumnType("int");
b.Property<DateTime>("templog")
.HasColumnType("datetime2");
b.HasKey("id");
b.HasIndex("deviceId");
b.ToTable("TempLogs");
});
modelBuilder.Entity("TemperatureLoggerAPI.Models.TempLogs", b =>
{
b.HasOne("TemperatureLoggerAPI.Models.DeviceInfo", "device")
.WithMany()
.HasForeignKey("deviceId");
b.Navigation("device");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,70 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace TemperatureLoggerAPI.Migrations
{
/// <inheritdoc />
public partial class updatedeviceinfoadddev_id : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_TempLogs_DeviceInfo_deviceID",
table: "TempLogs");
migrationBuilder.RenameColumn(
name: "deviceID",
table: "TempLogs",
newName: "deviceId");
migrationBuilder.RenameIndex(
name: "IX_TempLogs_deviceID",
table: "TempLogs",
newName: "IX_TempLogs_deviceId");
migrationBuilder.AddColumn<int>(
name: "dev_ID",
table: "TempLogs",
type: "int",
nullable: true);
migrationBuilder.AddForeignKey(
name: "FK_TempLogs_DeviceInfo_deviceId",
table: "TempLogs",
column: "deviceId",
principalTable: "DeviceInfo",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_TempLogs_DeviceInfo_deviceId",
table: "TempLogs");
migrationBuilder.DropColumn(
name: "dev_ID",
table: "TempLogs");
migrationBuilder.RenameColumn(
name: "deviceId",
table: "TempLogs",
newName: "deviceID");
migrationBuilder.RenameIndex(
name: "IX_TempLogs_deviceId",
table: "TempLogs",
newName: "IX_TempLogs_deviceID");
migrationBuilder.AddForeignKey(
name: "FK_TempLogs_DeviceInfo_deviceID",
table: "TempLogs",
column: "deviceID",
principalTable: "DeviceInfo",
principalColumn: "Id");
}
}
}

View File

@ -0,0 +1,129 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using TemperatureLoggerAPI;
#nullable disable
namespace TemperatureLoggerAPI.Migrations
{
[DbContext(typeof(TemperatureLoggerAPIContext))]
[Migration("20241218071240_add_group_area")]
partial class add_group_area
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("TemperatureLoggerAPI.Models.DeviceInfo", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int?>("GA_Id")
.HasColumnType("int");
b.Property<int>("GroupAreaId")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("GroupAreaId");
b.ToTable("DeviceInfo");
});
modelBuilder.Entity("TemperatureLoggerAPI.Models.GroupArea", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("GAName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("GroupArea");
});
modelBuilder.Entity("TemperatureLoggerAPI.Models.TempLogs", b =>
{
b.Property<long>("id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
b.Property<decimal?>("Humidity")
.HasColumnType("decimal(18,2)");
b.Property<decimal?>("TempC")
.HasColumnType("decimal(18,2)");
b.Property<decimal?>("TempF")
.HasColumnType("decimal(18,2)");
b.Property<int?>("dev_ID")
.HasColumnType("int");
b.Property<int?>("deviceId")
.HasColumnType("int");
b.Property<DateTime?>("templog")
.HasColumnType("datetime2");
b.HasKey("id");
b.HasIndex("deviceId");
b.ToTable("TempLogs");
});
modelBuilder.Entity("TemperatureLoggerAPI.Models.DeviceInfo", b =>
{
b.HasOne("TemperatureLoggerAPI.Models.GroupArea", "GroupArea")
.WithMany()
.HasForeignKey("GroupAreaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("GroupArea");
});
modelBuilder.Entity("TemperatureLoggerAPI.Models.TempLogs", b =>
{
b.HasOne("TemperatureLoggerAPI.Models.DeviceInfo", "device")
.WithMany()
.HasForeignKey("deviceId");
b.Navigation("device");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,95 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace TemperatureLoggerAPI.Migrations
{
/// <inheritdoc />
public partial class add_group_area : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<DateTime>(
name: "templog",
table: "TempLogs",
type: "datetime2",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "datetime2");
migrationBuilder.AddColumn<int>(
name: "GA_Id",
table: "DeviceInfo",
type: "int",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "GroupAreaId",
table: "DeviceInfo",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateTable(
name: "GroupArea",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
GAName = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_GroupArea", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_DeviceInfo_GroupAreaId",
table: "DeviceInfo",
column: "GroupAreaId");
migrationBuilder.AddForeignKey(
name: "FK_DeviceInfo_GroupArea_GroupAreaId",
table: "DeviceInfo",
column: "GroupAreaId",
principalTable: "GroupArea",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_DeviceInfo_GroupArea_GroupAreaId",
table: "DeviceInfo");
migrationBuilder.DropTable(
name: "GroupArea");
migrationBuilder.DropIndex(
name: "IX_DeviceInfo_GroupAreaId",
table: "DeviceInfo");
migrationBuilder.DropColumn(
name: "GA_Id",
table: "DeviceInfo");
migrationBuilder.DropColumn(
name: "GroupAreaId",
table: "DeviceInfo");
migrationBuilder.AlterColumn<DateTime>(
name: "templog",
table: "TempLogs",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldNullable: true);
}
}
}

View File

@ -0,0 +1,126 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using TemperatureLoggerAPI;
#nullable disable
namespace TemperatureLoggerAPI.Migrations
{
[DbContext(typeof(TemperatureLoggerAPIContext))]
partial class TemperatureLoggerAPIContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("TemperatureLoggerAPI.Models.DeviceInfo", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int?>("GA_Id")
.HasColumnType("int");
b.Property<int>("GroupAreaId")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("GroupAreaId");
b.ToTable("DeviceInfo");
});
modelBuilder.Entity("TemperatureLoggerAPI.Models.GroupArea", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("GAName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("GroupArea");
});
modelBuilder.Entity("TemperatureLoggerAPI.Models.TempLogs", b =>
{
b.Property<long>("id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
b.Property<decimal?>("Humidity")
.HasColumnType("decimal(18,2)");
b.Property<decimal?>("TempC")
.HasColumnType("decimal(18,2)");
b.Property<decimal?>("TempF")
.HasColumnType("decimal(18,2)");
b.Property<int?>("dev_ID")
.HasColumnType("int");
b.Property<int?>("deviceId")
.HasColumnType("int");
b.Property<DateTime?>("templog")
.HasColumnType("datetime2");
b.HasKey("id");
b.HasIndex("deviceId");
b.ToTable("TempLogs");
});
modelBuilder.Entity("TemperatureLoggerAPI.Models.DeviceInfo", b =>
{
b.HasOne("TemperatureLoggerAPI.Models.GroupArea", "GroupArea")
.WithMany()
.HasForeignKey("GroupAreaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("GroupArea");
});
modelBuilder.Entity("TemperatureLoggerAPI.Models.TempLogs", b =>
{
b.HasOne("TemperatureLoggerAPI.Models.DeviceInfo", "device")
.WithMany()
.HasForeignKey("deviceId");
b.Navigation("device");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,11 @@
namespace TemperatureLoggerAPI.Models
{
public class DeviceInfo
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public int? GA_Id { get; set; }
public GroupArea GroupArea { get; set; }
}
}

View File

@ -0,0 +1,8 @@
namespace TemperatureLoggerAPI.Models
{
public class GroupArea
{
public int Id { get; set; }
public string GAName { get; set; }
}
}

View File

@ -0,0 +1,14 @@
namespace TemperatureLoggerAPI.Models
{
public class TempLogs
{
public long id { get; set; }
public DateTime? templog { get; set; }
public decimal? Humidity { get; set; }
public decimal? TempC { get; set; }
public decimal? TempF { get; set; }
public int? dev_ID { get; set; }
public DeviceInfo? device { get; set; }
}
}

View File

@ -0,0 +1,41 @@
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var allowedOrigins = "_allowedOrigins";
builder.Services.AddCors(opts => opts.AddPolicy(allowedOrigins, policy =>
{
//policy.WithOrigins("http://tasq.local&quot;, "http://localhost&quot;)
policy.AllowAnyOrigin()
.AllowAnyHeader()
.AllowAnyMethod();
}));
var app = builder.Build();
/*
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
} */
app.UseSwagger();
app.UseSwaggerUI();
app.UseHttpsRedirection();
app.UseAuthorization();
app.UseRouting();
app.MapControllers();
app.UseCors();
app.Run();

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<DeleteExistingFiles>false</DeleteExistingFiles>
<ExcludeApp_Data>false</ExcludeApp_Data>
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>bin\Release\net8.0\publish\</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
<_TargetId>Folder</_TargetId>
<SiteUrlToLaunchAfterPublish />
<TargetFramework>net8.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<ProjectGuid>0b883e02-a272-4c64-8ebe-d311c8b47dd9</ProjectGuid>
<SelfContained>false</SelfContained>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<_PublishTargetUrl>D:\Hospital Files\PROJECTS\TemperatureLoggerAPI\TemperatureLoggerAPI\bin\Release\net8.0\publish\</_PublishTargetUrl>
<History>True|2024-12-20T07:15:18.3593028Z||;True|2024-12-18T16:34:32.3289540+08:00||;True|2024-12-18T15:16:51.2232418+08:00||;True|2024-12-16T13:49:08.6133214+08:00||;True|2024-12-16T13:45:33.4698005+08:00||;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>

View File

@ -0,0 +1,41 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:8312",
"sslPort": 44324
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5147",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7201;http://localhost:5147",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ActiveDebugProfile>https</ActiveDebugProfile>
<Controller_SelectedScaffolderID>MvcControllerWithActionsScaffolder</Controller_SelectedScaffolderID>
<Controller_SelectedScaffolderCategoryPath>root/Common/MVC/Controller</Controller_SelectedScaffolderCategoryPath>
<NameOfLastUsedPublishProfile>D:\Hospital Files\PROJECTS\TemperatureLoggerAPI\TemperatureLoggerAPI\Properties\PublishProfiles\FolderProfile.pubxml</NameOfLastUsedPublishProfile>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,6 @@
@TemperatureLoggerAPI_HostAddress = http://localhost:5147
GET {{TemperatureLoggerAPI_HostAddress}}/weatherforecast/
Accept: application/json
###

View File

@ -0,0 +1,17 @@
using Microsoft.EntityFrameworkCore;
using TemperatureLoggerAPI.Models;
namespace TemperatureLoggerAPI
{
public class TemperatureLoggerAPIContext : DbContext
{
public TemperatureLoggerAPIContext()
: base(new DbContextOptionsBuilder().UseSqlServer("Data Source=localhost;Initial Catalog=TemperatureLog;Persist Security Info=True;User ID=sa;Password=s@password1;TrustServerCertificate=True").Options)
{
}
public DbSet<TemperatureLoggerAPI.Models.DeviceInfo> DeviceInfo { get; set; }
public DbSet<TemperatureLoggerAPI.Models.TempLogs> TempLogs { get; set; }
public DbSet<TemperatureLoggerAPI.Models.GroupArea> GroupArea { get; set; }
}
}

View File

@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}

Some files were not shown because too many files have changed in this diff Show More