提交 7c95dda7 编写于 作者: 麦壳饼's avatar 麦壳饼

删除了部分扩展并使用Silkier进行替代

上级 64701e1b
.dockerignore
.env
.git
.gitignore
.vs
.vscode
*/bin
*/obj
**/.toolstarget
\ No newline at end of file
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
\ No newline at end of file
......@@ -32,9 +32,6 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="CoAP.NET, Version=1.1.0.0, Culture=neutral, PublicKeyToken=e2c10a743037308b, processorArchitecture=MSIL">
<HintPath>..\packages\CoAP.1.1.0\lib\net40\CoAP.NET.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
......@@ -48,8 +45,12 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="readme.md" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CoAP">
<Version>1.1.0</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
using CoAP;

using CoAP;
using CoAP.Util;
using System;
using System.Collections.Generic;
......
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text;
using Microsoft.Extensions.Configuration;
namespace IoTSharp.Extensions.AspNetCore
{
public static class HostExtension
{
public static IHostBuilder ConfigureWindowsServices(this IHostBuilder hostBuilder)
{
bool IsWindowsService = false;
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
using (var process = GetParent(Process.GetCurrentProcess()))
{
IsWindowsService = process != null && process.ProcessName == "services";
}
}
if (Environment.CommandLine.Contains("--usebasedirectory") || (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && IsWindowsService))
{
hostBuilder.UseContentRoot(AppContext.BaseDirectory);
System.IO.Directory.SetCurrentDirectory(AppContext.BaseDirectory);
hostBuilder.UseWindowsService();
}
return hostBuilder;
}
public static IHostBuilder UseJsonToSettings(this IHostBuilder hostBuilder, string filename)
{
return hostBuilder.ConfigureAppConfiguration(builder =>
{
try
{
if (System.IO.File.Exists(filename))
{
builder.AddJsonFile(filename, true);
}
}
catch (System.Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
});
}
/// Hashes an email with MD5. Suitable for use with Gravatar profile
/// image urls
public static string Gravatar(this IdentityUser user)
{
string email = user.Email;
// Create a new instance of the MD5CryptoServiceProvider object.
MD5 md5Hasher = MD5.Create();
// Convert the input string to a byte array and compute the hash.
byte[] data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(email));
// Create a new Stringbuilder to collect the bytes
// and create a string.
StringBuilder sBuilder = new StringBuilder();
// Loop through each byte of the hashed data
// and format each one as a hexadecimal string.
for (int i = 0; i < data.Length; i++)
{
sBuilder.Append(data[i].ToString("x2"));
}
return string.Format("http://www.gravatar.com/avatar/{0}", sBuilder.ToString()); ; // Return the hexadecimal string.
}
public static BadRequestObjectResult ExceptionRequest(this ControllerBase @base, Exception exception)
{
MethodBase mb = new StackTrace(exception).GetFrame(0).GetMethod();
MethodBase cu = new StackTrace(true).GetFrame(0).GetMethod();
return @base.BadRequest(new
{
exception.Message,
exception.StackTrace,
ExceptionMethod = mb.DeclaringType.FullName + "." + mb.Name,
MethodName = cu.Name
});
}
public static BadRequestObjectResult ExceptionRequest<T>(this ControllerBase @base, T code,string msg, Exception exception)
{
MethodBase mb = new StackTrace(exception).GetFrame(0).GetMethod();
MethodBase cu = new StackTrace(true).GetFrame(0).GetMethod();
return @base.BadRequest(new
{
code,
msg,
data = new
{
ExceptionMethod = mb.DeclaringType.FullName + "." + mb.Name,
MethodName = cu.Name
}
});
}
public static BadRequestObjectResult ExceptionRequest(this ControllerBase @base, int code, string msg, Exception exception)
=> ExceptionRequest<int>(@base, code, msg, exception);
public static IWebHostBuilder UseContentRootAsEnv(this IWebHostBuilder hostBuilder)
{
bool IsWindowsService = false;
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
using (var process = GetParent(Process.GetCurrentProcess()))
{
IsWindowsService = process != null && process.ProcessName == "services";
}
}
if (Environment.CommandLine.Contains("--usebasedirectory") || (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && IsWindowsService))
{
hostBuilder.UseContentRoot(AppContext.BaseDirectory);
}
else
{
if (!Debugger.IsAttached)
{
hostBuilder.UseContentRoot(System.IO.Directory.GetCurrentDirectory());
}
}
return hostBuilder;
}
private static Process GetParent(Process child)
{
var parentId = 0;
var handle = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (handle == IntPtr.Zero)
{
return null;
}
var processInfo = new PROCESSENTRY32
{
dwSize = (uint)Marshal.SizeOf(typeof(PROCESSENTRY32))
};
if (!Process32First(handle, ref processInfo))
{
return null;
}
do
{
if (child.Id == processInfo.th32ProcessID)
{
parentId = (int)processInfo.th32ParentProcessID;
}
} while (parentId == 0 && Process32Next(handle, ref processInfo));
if (parentId > 0)
{
return Process.GetProcessById(parentId);
}
return null;
}
private static uint TH32CS_SNAPPROCESS = 2;
[DllImport("kernel32.dll")]
public static extern bool Process32Next(IntPtr hSnapshot, ref PROCESSENTRY32 lppe);
[DllImport("kernel32.dll", SetLastError = true)]
public static extern IntPtr CreateToolhelp32Snapshot(uint dwFlags, uint th32ProcessID);
[DllImport("kernel32.dll")]
public static extern bool Process32First(IntPtr hSnapshot, ref PROCESSENTRY32 lppe);
[StructLayout(LayoutKind.Sequential)]
public struct PROCESSENTRY32
{
public uint dwSize;
public uint cntUsage;
public uint th32ProcessID;
public IntPtr th32DefaultHeapID;
public uint th32ModuleID;
public uint cntThreads;
public uint th32ParentProcessID;
public int pcPriClassBase;
public uint dwFlags;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
public string szExeFile;
}
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageIconUrl></PackageIconUrl>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
<Authors>MaiKeBing</Authors>
<Company>IoTSharp</Company>
<Product>IoTSharp</Product>
<PackageProjectUrl>https://github.com/IoTSharp/IoTSharp</PackageProjectUrl>
<RepositoryUrl>https://github.com/IoTSharp/IoTSharp</RepositoryUrl>
<PackageIcon>200x200.png</PackageIcon>
<Version>1.0.1</Version>
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="3.1.1" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.7.0" />
</ItemGroup>
<ItemGroup>
<None Include="..\docs\images\200x200.png">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
<None Include="..\LICENSE.txt">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
</ItemGroup>
</Project>
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.Text;
namespace IoTSharp.Extensions.AspNetCore
{
public static class NTPHealthChecksExtension
{
// 小端存储与大端存储的转换
private static uint swapEndian(ulong x)
{
return (uint)(((x & 0x000000ff) << 24) +
((x & 0x0000ff00) << 8) +
((x & 0x00ff0000) >> 8) +
((x & 0xff000000) >> 24));
}
public static DateTime getWebTime(string ntpServer)
{
// NTP message size - 16 bytes of the digest (RFC 2030)
byte[] ntpData = new byte[48];
// Setting the Leap Indicator, Version Number and Mode values
ntpData[0] = 0x1B; // LI = 0 (no warning), VN = 3 (IPv4 only), Mode = 3 (Client Mode)
IPAddress ip = IPAddress.Parse(ntpServer);
// The UDP port number assigned to NTP is 123
IPEndPoint ipEndPoint = new IPEndPoint(ip, 123);//addresses[0]
// NTP uses UDP
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
socket.Connect(ipEndPoint);
// Stops code hang if NTP is blocked
socket.ReceiveTimeout = 3000;
socket.Send(ntpData);
socket.Receive(ntpData);
socket.Close();
// Offset to get to the "Transmit Timestamp" field (time at which the reply
// departed the server for the client, in 64-bit timestamp format."
const byte serverReplyTime = 40;
// Get the seconds part
ulong intPart = BitConverter.ToUInt32(ntpData, serverReplyTime);
// Get the seconds fraction
ulong fractPart = BitConverter.ToUInt32(ntpData, serverReplyTime + 4);
// Convert From big-endian to little-endian
intPart = swapEndian(intPart);
fractPart = swapEndian(fractPart);
ulong milliseconds = (intPart * 1000) + ((fractPart * 1000) / 0x100000000UL);
// UTC time
DateTime webTime = (new DateTime(1900, 1, 1, 0, 0, 0, DateTimeKind.Utc)).AddMilliseconds(milliseconds);
string localTime = DateTime.Now.ToString("yyyyMMddHHmmss");
// Local time
DateTime dt = webTime.ToLocalTime();
return dt;
}
public static IHealthChecksBuilder AddNTPHealthCheck(this IHealthChecksBuilder builder, string ntpserver, double toleratesec = 10, string name = "NTPServer")
{
return builder.AddCheck(name, () =>
{
HealthCheckResult result;
try
{
var webtime = getWebTime(ntpserver);
var dt = DateTime.Now;
double ts = Math.Abs(dt.Subtract(webtime).TotalSeconds);
var hs = ts <= toleratesec ? HealthStatus.Healthy : (ts > toleratesec && ts < toleratesec * 2) ? HealthStatus.Degraded : HealthStatus.Unhealthy;
result = new HealthCheckResult(hs, description: hs != HealthStatus.Healthy ? $"NTP Server Date Time: {webtime}, Local Date Time:{dt}" : string.Empty);
}
catch (Exception ex)
{
result = new HealthCheckResult(HealthStatus.Unhealthy, ex.Message, ex);
}
return result;
});
}
}
}
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
namespace IoTSharp.Extensions
{
public static class DataExtension
{
public static string ToISO8601(this System.DateTime time) => time.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:sssZ");
public static T ToJson<T>(this IDataReader dataReader) where T : class
{
return dataReader.ToJson().ToObject<T>();
}
public static JArray ToJson(this IDataReader dataReader)
{
JArray jArray = new JArray();
try
{
while (dataReader.Read())
{
JObject jObject = new JObject();
for (int i = 0; i < dataReader.FieldCount; i++)
{
try
{
string strKey = dataReader.GetName(i);
if (dataReader[i] != DBNull.Value)
{
object obj = Convert.ChangeType(dataReader[i], dataReader.GetFieldType(i));
jObject.Add(strKey, JToken.FromObject(obj));
}
}
catch (Exception)
{
}
}
jArray.Add(jObject);
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
return jArray;
}
public static JArray ToJson(this DataTable dt)
{
JArray jArray = new JArray();
try
{
for (int il = 0; il < dt.Rows.Count; il++)
{
JObject jObject = new JObject();
for (int i = 0; i < dt.Columns.Count; i++)
{
try
{
string strKey = dt.Columns[i].ColumnName;
if (dt.Rows[il].ItemArray[i] != DBNull.Value)
{
object obj = Convert.ChangeType(dt.Rows[il].ItemArray[i], dt.Columns[i].DataType);
jObject.Add(strKey, JToken.FromObject(obj));
}
}
catch (Exception)
{
}
}
jArray.Add(jObject);
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
return jArray;
}
public static List<T> ToList<T>(this DataTable dt) where T : class
{
List<T> jArray = new List<T>();
var prs = typeof(T).GetProperties();
try
{
for (int il = 0; il < dt.Rows.Count; il++)
{
T jObject = Activator.CreateInstance<T>();
for (int i = 0; i < dt.Columns.Count; i++)
{
try
{
string strKey = dt.Columns[i].ColumnName;
if (dt.Rows[il].ItemArray[i] != DBNull.Value)
{
object obj = Convert.ChangeType(dt.Rows[il].ItemArray[i], dt.Columns[i].DataType);
var p = prs.FirstOrDefault(px => px.Name.ToLower() == strKey.ToLower());
if (p != null)
{
SetValue(jObject, dt.Columns[i].DataType, obj, p);
}
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
}
jArray.Add(jObject);
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
return jArray;
}
public static List<T> ToList<T>(this IDataReader dataReader) where T : class
{
List<T> jArray = new List<T>();
var prs = typeof(T).GetProperties();
try
{
while (dataReader.Read())
{
T jObject = Activator.CreateInstance<T>();
for (int i = 0; i < dataReader.FieldCount; i++)
{
try
{
string strKey = dataReader.GetName(i);
if (dataReader[i] != DBNull.Value)
{
var ft = dataReader.GetFieldType(i);
var _v = dataReader[i];
object obj = Convert.ChangeType(_v, ft);
var p = prs.FirstOrDefault(px => px.Name.ToLower() == strKey.ToLower());
if (p != null)
{
SetValue(jObject, ft, obj, p);
}
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
}
jArray.Add(jObject);
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
return jArray;
}
public static List<T> ToTupleList<T>(this IDataReader dataReader)
{
List<T> jArray = new List<T>();
var prs = typeof(T).GetFields();
try
{
while (dataReader.Read())
{
T jObject = Activator.CreateInstance<T>();
object jObjectEx = jObject;
for (int i = 0; i < dataReader.FieldCount; i++)
{
try
{
string strKey = dataReader.GetName(i);
if (dataReader[i] != DBNull.Value)
{
var ft = dataReader.GetFieldType(i);
var _v = dataReader[i];
object obj = Convert.ChangeType(_v, ft);
var p = prs[i];
if (p != null)
{
SetValue(jObjectEx, ft, obj, p);
}
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
}
jObject = (T)Convert.ChangeType(jObjectEx, typeof(T));
jArray.Add(jObject);
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
return jArray;
}
private static void SetValue<T>(T jObject, Type ft, object obj, System.Reflection.FieldInfo p)
{
if (p.FieldType == ft)
{
p.SetValue(jObject, obj);
}
else if (p.FieldType == typeof(DateTime) && ft == typeof(string))
{
if (DateTime.TryParse((string)obj, out DateTime dt))
{
p.SetValue(jObject, dt);
}
}
else
{
p.SetValue(jObject, Convert.ChangeType(obj, p.FieldType));
}
}
private static void SetValue<T>(T jObject, Type ft, object obj, System.Reflection.PropertyInfo p) where T : class
{
if (p.PropertyType == ft)
{
p.SetValue(jObject, obj);
}
else if (p.PropertyType == typeof(DateTime) && ft == typeof(string))
{
if (DateTime.TryParse((string)obj, out DateTime dt))
{
p.SetValue(jObject, dt);
}
}
else
{
p.SetValue(jObject, Convert.ChangeType(obj, p.PropertyType));
}
}
}
}
\ No newline at end of file
using System;
using System.Runtime.InteropServices;
namespace IoTSharp.Extensions
{
public static class EndianExtensions
{
public static byte[] ToBytes(this short v) => BitConverter.GetBytes(v);
public static short ToShort(this byte[] v) => BitConverter.ToInt16(v, 0);
public static ushort ToUShort(this byte[] v) => BitConverter.ToUInt16(v, 0);
public static byte[] ToBytes(this ushort v) => BitConverter.GetBytes(v);
public static byte[] ToBytes(this int v) => BitConverter.GetBytes(v);
public static int ToInt(this byte[] v) => BitConverter.ToInt32(v, 0);
public static byte[] ToBytes(this uint v) => BitConverter.GetBytes(v);
public static uint ToUInt(this byte[] v) => BitConverter.ToUInt32(v, 0);
public static byte[] ToBytes(this long v) => BitConverter.GetBytes(v);
public static ulong ToULong(this byte[] v) => BitConverter.ToUInt64(v, 0);
public static byte[] ToBytes(this ulong v) => BitConverter.GetBytes(v);
public static long ToLong(this byte[] v) => BitConverter.ToInt64(v, 0);
public static int ToInt(this short v) => v;
public static ushort ToUShort(this short v) => (ushort)v;
public static uint ToUInt(this short v) => (uint)v;
public static long ToLong(this short v) => v;
public static ulong ToULong(this short v) => (ulong)v;
public static int ToInt(this ushort v) => v;
public static short ToShort(this short v) => v;
public static uint ToUInt(this ushort v) => v;
public static long ToLong(this ushort v) => v;
public static ulong ToULong(this ushort v) => v;
public static ushort ToUShort(this int v) => (ushort)v;
public static short ToShort(this int v) => (short)v;
public static uint ToUInt(this int v) => (uint)v;
public static long ToLong(this int v) => v;
public static ulong ToULong(this int v) => (ulong)v;
public static ushort ToUShort(this uint v) => (ushort)v;
public static short ToShort(this uint v) => (short)v;
public static int ToInt(this uint v) => (int)v;
public static long ToLong(this uint v) => v;
public static ulong ToULong(this uint v) => v;
public static ushort ToUShort(this long v) => (ushort)v;
public static short ToShort(this long v) => (short)v;
public static int ToInt(this long v) => (int)v;
public static uint ToUInt(this long v) => (uint)v;
public static ulong ToULong(this long v) => (ulong)v;
public static ushort ToUShort(this ulong v) => (ushort)v;
public static short ToShort(this ulong v) => (short)v;
public static int ToInt(this ulong v) => (int)v;
public static uint ToUInt(this ulong v) => (uint)v;
public static long ToLong(this ulong v) => (long)v;
public static short Swap(this short v)
{
return (short)(((v & 0xff) << 8) | ((v >> 8) & 0xff));
}
public static ushort Swap(this ushort v)
{
return (ushort)(((v & 0xff) << 8) | ((v >> 8) & 0xff));
}
public static int Swap(this int v)
{
return (int)(((Swap((short)v) & 0xffff) << 0x10) |
(Swap((short)(v >> 0x10)) & 0xffff));
}
public static uint Swap(this uint v)
{
return (uint)(((Swap((ushort)v) & 0xffff) << 0x10) |
(Swap((ushort)(v >> 0x10)) & 0xffff));
}
public static long Swap(this long v)
{
return (long)(((Swap((int)v) & 0xffffffffL) << 0x20) |
(Swap((int)(v >> 0x20)) & 0xffffffffL));
}
public static ulong Swap(this ulong v)
{
return (ulong)(((Swap((uint)v) & 0xffffffffL) << 0x20) |
(Swap((uint)(v >> 0x20)) & 0xffffffffL));
}
public static byte[] ToHexBytes(this string hexString)
{
hexString = hexString.Replace(" ", "");   //去除空格
            if ((hexString.Length % 2) != 0)     //判断hexstring的长度是否为偶数
            {
hexString += "";
}
byte[] returnBytes = new byte[hexString.Length / 2];  //声明一个长度为hexstring长度一半的字节组returnBytes
            for (int i = 0; i < returnBytes.Length; i++)
{
returnBytes[i] = Convert.ToByte(hexString.Substring(i * 2, 2), 16);  //将hexstring的两个字符转换成16进制的字节组
            }
return returnBytes;
}
        //字节组转换成16进制的字符串:
        public static string ToHexStr(this byte[] bytes)
{
string returnStr = "";
if (bytes != null)
{
for (int i = 0; i < bytes.Length; i++)
{
returnStr += bytes[i].ToString("X2");      //byte转16进制字符
                }
}
return returnStr;
}
static ushort[] crc_table = new ushort[] { 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF, 0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6, 0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE, 0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485, 0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D, 0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4, 0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC, 0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823, 0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B, 0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12, 0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A, 0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41, 0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49, 0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70, 0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78, 0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F, 0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067, 0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E, 0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256, 0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D, 0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, 0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C, 0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634, 0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB, 0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3, 0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A, 0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92, 0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9, 0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1, 0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8, 0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0 };
public static ushort ToCRC16(this byte[] buffer)
{
return ToShort16(buffer, (uint)buffer.Length, 0x00);
}
public static ushort ToShort16(this byte[] buffer, ushort precrc = 0x00)
{
return ToShort16(buffer, (uint)buffer.Length, precrc);
}
public static ushort ToShort16(this byte[] buffer, uint buffer_length, ushort precrc = 0x00)
{
ushort crc = precrc;
for (uint i = 0; i < buffer_length; i++)
{
crc = (ushort)(crc_table[((crc >> 8) ^ buffer[i]) & 0xFF] ^ (crc << 8));
}
return crc;
}
public static byte[] StructToBytes<T>(this T obj) where T : struct
{
int rawsize = Marshal.SizeOf<T>();
IntPtr buffer = Marshal.AllocHGlobal(rawsize);
Marshal.StructureToPtr(obj, buffer, true);
byte[] rawdatas = new byte[rawsize];
Marshal.Copy(buffer, rawdatas, 0, rawsize);
Marshal.FreeHGlobal(buffer);
return rawdatas;
}
public static T BytesToStruct<T>(this byte[] bytes) where T : struct
{
T obj = default(T);
Type anytype = typeof(T);
int rawsize = Marshal.SizeOf<T>();
if (bytes != null && bytes.Length >= rawsize)
{
IntPtr buffer = Marshal.AllocHGlobal(rawsize);
Marshal.Copy(bytes, 0, buffer, rawsize);
object retobj = Marshal.PtrToStructure(buffer, anytype);
Marshal.FreeHGlobal(buffer);
obj = (T)retobj;
}
return obj;
}
}
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Security.Cryptography;
using System.Text;
namespace IoTSharp.Extensions
{
public static class FileExtension
{
public static DriveInfo GetDriveInfo(this FileInfo file)
{
return new DriveInfo(file.Directory.Root.FullName);
}
public static string GetSHA1(this FileInfo s)
{
string result = string.Empty;
SHA1 sha1 = new SHA1CryptoServiceProvider();
byte[] retval = sha1.ComputeHash(s.ReadAllBytes());
result = BitConverter.ToString(retval).Replace("-", "");
return result;
}
public static string GetMd5Sum(this FileInfo s)
{
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
string t2 = BitConverter.ToString(md5.ComputeHash(s.ReadAllBytes()));
t2 = t2.Replace("-", "");
return t2;
}
public static byte[] ReadAllBytes(this FileInfo fi) => File.ReadAllBytes(fi.FullName);
public static byte[] ReadBytes(this FileInfo fi, int count) => ReadBytes(fi, 0, count);
public static byte[] ReadBytes(this FileInfo fi, int offset, int count)
{
byte[] buffer = new byte[count];
using (var fs = fi.OpenRead())
{
fs.Seek(offset, SeekOrigin.Begin);
fs.Read(buffer, 0, count);
}
return buffer;
}
public static void WriteAllText(this FileInfo fi, string contents) => File.WriteAllText(fi.FullName, contents);
public static bool Exists(this FileInfo fi) => File.Exists(fi.FullName);
public static void Delete(this FileInfo fi) => File.Delete(fi.FullName);
public static string ReadAllText(this FileInfo fi) => File.ReadAllText(fi.FullName);
public static void WriteAllBytes(this FileInfo fi, byte[] bytes) => File.WriteAllBytes(fi.FullName, bytes);
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageProjectUrl>https://github.com/IoTSharp/IoTSharp/tree/master/IoTSharp.Extensions</PackageProjectUrl>
<RepositoryUrl>https://github.com/IoTSharp/IoTSharp</RepositoryUrl>
<PackageTags>Endian;Json;XML</PackageTags>
<Copyright>IoTSharp</Copyright>
<PackageIconUrl></PackageIconUrl>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
<Company>IoTSharp</Company>
<Product>IoTSharp</Product>
<Authors>MaiKeBing</Authors>
<PackageIcon>200x200.png</PackageIcon>
<Version>1.0.1</Version>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="RestSharp" Version="106.10.1" />
</ItemGroup>
<ItemGroup>
<None Include="..\docs\images\200x200.png">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
<None Include="..\LICENSE.txt">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
</ItemGroup>
</Project>

using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Security.Cryptography;
using System.Threading.Tasks;
using System.Threading;
using Microsoft.Extensions.DependencyInjection;
namespace IoTSharp.Extensions
{
public static class MiscExtensions
{
public static string MD5Sum(this string text) => BitConverter.ToString(MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(text))).Replace("-", "");
public static T GetRequiredService<T>(this IServiceScopeFactory scopeFactor) =>
scopeFactor.CreateScope().ServiceProvider.GetRequiredService<T>();
}
}
using Newtonsoft.Json.Linq;
using RestSharp;
using System;
using System.Collections.Generic;
using System.Net;
using System.Text;
using System.Linq;
namespace IoTSharp.Extensions
{
public static class RestClientExtensions
{
public static T ReqResp<T>(this RestClient client, string resource, Method method = Method.GET, DataFormat dataFormat = DataFormat.Json, Action<int, string> __log = null, List<HttpCookie> cookies = null)
=> client.ReqResp<T>(new RestRequest(resource, method, dataFormat), __log, cookies);
public static T ReqResp<T>(this RestClient client, Uri resource, Method method = Method.GET, DataFormat dataFormat = DataFormat.Json, Action<int, string> __log = null, List<HttpCookie> cookies = null)
=> client.ReqResp<T>(new RestRequest(resource, method, dataFormat), __log, cookies);
public static T ReqResp<T>(this RestClient client, RestRequest rest, Action<int, string> __log = null, List<HttpCookie> cookies = null)
{
T result = default;
try
{
if (cookies != null && cookies.Count > 0)
{
cookies.ForEach(co =>
{
rest.AddCookie(co.Name, co.Value);
});
}
var response = client.Execute(rest);
if (response.StatusCode == HttpStatusCode.OK && !string.IsNullOrEmpty(response.Content)
&& JToken.Parse(response.Content).ToObject<T>() is T jDResult)
{
result = jDResult;
if (cookies != null)
{
cookies.Clear();
cookies.AddRange(response.Cookies.Select(s => s.HttpCookie));
}
}
else
{
__log?.Invoke((int)response.StatusCode, response.Content);
}
}
catch (Exception ex)
{
__log?.Invoke(-999, ex.Message);
}
return result;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace IoTSharp.Extensions
{
public static class StringExtension
{
public static string ToTitleCase(this string str)
{
return System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(str.ToLower());
}
public static string Left(this string str, int length)
{
str = (str ?? string.Empty);
return str.Substring(0, Math.Min(length, str.Length));
}
public static string Right(this string str, int length)
{
str = (str ?? string.Empty);
return (str.Length >= length)
? str.Substring(str.Length - length, length)
: str;
}
public static char[] Right(this char[] str, int length)
{
return str.Skip(str.Length - length).Take(length).ToArray();
}
public static char[] Left(this char[] str, int length)
{
return str.Take(length).ToArray();
}
public static byte[] Right(this byte[] str, int length)
{
return str.Skip(str.Length - length).Take(length).ToArray();
}
public static byte[] Left(this byte[] str, int length)
{
return str.Take(length).ToArray();
}
}
}
using System;
using System.Threading.Tasks;
namespace IoTSharp.Extensions
{
public static class TaskExtension
{
public static Task Forget(this Task task)
{
return Task.CompletedTask;
}
}
}
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
namespace IoTSharp.Extensions
{
public static class XmlExtensions
{
public static bool XML2Json(System.IO.MemoryStream xml, out object obj)
{
bool ok = false;
obj = null;
try
{
XmlDocument doc = new XmlDocument();
xml.Seek(0, System.IO.SeekOrigin.Begin);
doc.Load(xml);
string jsonText = JsonConvert.SerializeXmlNode(doc.DocumentElement);
obj = JsonConvert.DeserializeObject(jsonText);
ok = true;
}
catch (Exception)
{
}
return ok;
}
public static bool XML2Json(FileInfo xml, out object obj)
{
bool ok = false;
obj = null;
try
{
XmlDocument doc = new XmlDocument();
doc.Load(xml.FullName);
string jsonText = JsonConvert.SerializeXmlNode(doc.DocumentElement);
obj = JsonConvert.DeserializeObject(jsonText);
ok = true;
}
catch (Exception)
{
}
return ok;
}
public static bool XML2Json(string xml, out object obj)
{
bool ok = false;
obj = null;
try
{
if (!IsValidXmlString(xml))
{
xml = RemoveInvalidXmlChars(xml);
}
XmlDocument doc = new XmlDocument();
doc.LoadXml(xml);
string jsonText = JsonConvert.SerializeXmlNode(doc.DocumentElement);
obj = JsonConvert.DeserializeObject(jsonText);
ok = true;
}
catch (Exception)
{
}
return ok;
}
private static string RemoveInvalidXmlChars(string text)
{
var validXmlChars = text.Where(ch => XmlConvert.IsXmlChar(ch)).ToArray();
return new string(validXmlChars);
}
private static bool IsValidXmlString(string text)
{
try
{
XmlConvert.VerifyXmlChars(text);
return true;
}
catch
{
return false;
}
}
public static List<T> ToList<T>(this List<System.Xml.Linq.XElement> _Nodes)
{
if (_Nodes == null)
{
throw new ArgumentNullException(nameof(_Nodes));
}
List<T> ts = new List<T>();
try
{
var ems = from ex in _Nodes where ex.Name.LocalName == "diffgram" select ex;
ems.ToList().ForEach(em =>
{
var emls = from exx in em.Elements().FirstOrDefault(xe => xe.Name.LocalName == typeof(T).Name).Elements() select JObject.FromObject(exx).GetValue("Table").ToObject<T>();
ts.AddRange(emls.ToArray());
});
}
catch (Exception)
{
}
return ts;
}
}
}
......@@ -7,8 +7,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.0" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.0" />
</ItemGroup>
......
......@@ -24,9 +24,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MQTTClient", "Clients\MQTTC
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MQTT-C-Client", "Clients\MQTT-C-Client\MQTT-C-Client.vcxproj", "{DD36544C-2E7C-4388-B34F-FF705E141E4A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IoTSharp.Extensions", "IoTSharp.Extensions\IoTSharp.Extensions.csproj", "{551E62E3-51DA-4C1D-8DBB-7346A29EE817}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IoTSharp.Extensions.AspNetCore", "IoTSharp.Extensions.AspNetCore\IoTSharp.Extensions.AspNetCore.csproj", "{EA1A2F33-BFF3-4CE2-B18C-992B78AD6FDB}"
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{91C3C01F-68D2-4D9C-8932-B91B264EFBE6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
......@@ -148,46 +146,26 @@ Global
{DD36544C-2E7C-4388-B34F-FF705E141E4A}.Release|x86.ActiveCfg = Release|x86
{DD36544C-2E7C-4388-B34F-FF705E141E4A}.Release|x86.Build.0 = Release|x86
{DD36544C-2E7C-4388-B34F-FF705E141E4A}.Release|x86.Deploy.0 = Release|x86
{551E62E3-51DA-4C1D-8DBB-7346A29EE817}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{551E62E3-51DA-4C1D-8DBB-7346A29EE817}.Debug|Any CPU.Build.0 = Debug|Any CPU
{551E62E3-51DA-4C1D-8DBB-7346A29EE817}.Debug|ARM.ActiveCfg = Debug|Any CPU
{551E62E3-51DA-4C1D-8DBB-7346A29EE817}.Debug|ARM.Build.0 = Debug|Any CPU
{551E62E3-51DA-4C1D-8DBB-7346A29EE817}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{551E62E3-51DA-4C1D-8DBB-7346A29EE817}.Debug|ARM64.Build.0 = Debug|Any CPU
{551E62E3-51DA-4C1D-8DBB-7346A29EE817}.Debug|x64.ActiveCfg = Debug|Any CPU
{551E62E3-51DA-4C1D-8DBB-7346A29EE817}.Debug|x64.Build.0 = Debug|Any CPU
{551E62E3-51DA-4C1D-8DBB-7346A29EE817}.Debug|x86.ActiveCfg = Debug|Any CPU
{551E62E3-51DA-4C1D-8DBB-7346A29EE817}.Debug|x86.Build.0 = Debug|Any CPU
{551E62E3-51DA-4C1D-8DBB-7346A29EE817}.Release|Any CPU.ActiveCfg = Release|Any CPU
{551E62E3-51DA-4C1D-8DBB-7346A29EE817}.Release|Any CPU.Build.0 = Release|Any CPU
{551E62E3-51DA-4C1D-8DBB-7346A29EE817}.Release|ARM.ActiveCfg = Release|Any CPU
{551E62E3-51DA-4C1D-8DBB-7346A29EE817}.Release|ARM.Build.0 = Release|Any CPU
{551E62E3-51DA-4C1D-8DBB-7346A29EE817}.Release|ARM64.ActiveCfg = Release|Any CPU
{551E62E3-51DA-4C1D-8DBB-7346A29EE817}.Release|ARM64.Build.0 = Release|Any CPU
{551E62E3-51DA-4C1D-8DBB-7346A29EE817}.Release|x64.ActiveCfg = Release|Any CPU
{551E62E3-51DA-4C1D-8DBB-7346A29EE817}.Release|x64.Build.0 = Release|Any CPU
{551E62E3-51DA-4C1D-8DBB-7346A29EE817}.Release|x86.ActiveCfg = Release|Any CPU
{551E62E3-51DA-4C1D-8DBB-7346A29EE817}.Release|x86.Build.0 = Release|Any CPU
{EA1A2F33-BFF3-4CE2-B18C-992B78AD6FDB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EA1A2F33-BFF3-4CE2-B18C-992B78AD6FDB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EA1A2F33-BFF3-4CE2-B18C-992B78AD6FDB}.Debug|ARM.ActiveCfg = Debug|Any CPU
{EA1A2F33-BFF3-4CE2-B18C-992B78AD6FDB}.Debug|ARM.Build.0 = Debug|Any CPU
{EA1A2F33-BFF3-4CE2-B18C-992B78AD6FDB}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{EA1A2F33-BFF3-4CE2-B18C-992B78AD6FDB}.Debug|ARM64.Build.0 = Debug|Any CPU
{EA1A2F33-BFF3-4CE2-B18C-992B78AD6FDB}.Debug|x64.ActiveCfg = Debug|Any CPU
{EA1A2F33-BFF3-4CE2-B18C-992B78AD6FDB}.Debug|x64.Build.0 = Debug|Any CPU
{EA1A2F33-BFF3-4CE2-B18C-992B78AD6FDB}.Debug|x86.ActiveCfg = Debug|Any CPU
{EA1A2F33-BFF3-4CE2-B18C-992B78AD6FDB}.Debug|x86.Build.0 = Debug|Any CPU
{EA1A2F33-BFF3-4CE2-B18C-992B78AD6FDB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EA1A2F33-BFF3-4CE2-B18C-992B78AD6FDB}.Release|Any CPU.Build.0 = Release|Any CPU
{EA1A2F33-BFF3-4CE2-B18C-992B78AD6FDB}.Release|ARM.ActiveCfg = Release|Any CPU
{EA1A2F33-BFF3-4CE2-B18C-992B78AD6FDB}.Release|ARM.Build.0 = Release|Any CPU
{EA1A2F33-BFF3-4CE2-B18C-992B78AD6FDB}.Release|ARM64.ActiveCfg = Release|Any CPU
{EA1A2F33-BFF3-4CE2-B18C-992B78AD6FDB}.Release|ARM64.Build.0 = Release|Any CPU
{EA1A2F33-BFF3-4CE2-B18C-992B78AD6FDB}.Release|x64.ActiveCfg = Release|Any CPU
{EA1A2F33-BFF3-4CE2-B18C-992B78AD6FDB}.Release|x64.Build.0 = Release|Any CPU
{EA1A2F33-BFF3-4CE2-B18C-992B78AD6FDB}.Release|x86.ActiveCfg = Release|Any CPU
{EA1A2F33-BFF3-4CE2-B18C-992B78AD6FDB}.Release|x86.Build.0 = Release|Any CPU
{91C3C01F-68D2-4D9C-8932-B91B264EFBE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{91C3C01F-68D2-4D9C-8932-B91B264EFBE6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{91C3C01F-68D2-4D9C-8932-B91B264EFBE6}.Debug|ARM.ActiveCfg = Debug|Any CPU
{91C3C01F-68D2-4D9C-8932-B91B264EFBE6}.Debug|ARM.Build.0 = Debug|Any CPU
{91C3C01F-68D2-4D9C-8932-B91B264EFBE6}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{91C3C01F-68D2-4D9C-8932-B91B264EFBE6}.Debug|ARM64.Build.0 = Debug|Any CPU
{91C3C01F-68D2-4D9C-8932-B91B264EFBE6}.Debug|x64.ActiveCfg = Debug|Any CPU
{91C3C01F-68D2-4D9C-8932-B91B264EFBE6}.Debug|x64.Build.0 = Debug|Any CPU
{91C3C01F-68D2-4D9C-8932-B91B264EFBE6}.Debug|x86.ActiveCfg = Debug|Any CPU
{91C3C01F-68D2-4D9C-8932-B91B264EFBE6}.Debug|x86.Build.0 = Debug|Any CPU
{91C3C01F-68D2-4D9C-8932-B91B264EFBE6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{91C3C01F-68D2-4D9C-8932-B91B264EFBE6}.Release|Any CPU.Build.0 = Release|Any CPU
{91C3C01F-68D2-4D9C-8932-B91B264EFBE6}.Release|ARM.ActiveCfg = Release|Any CPU
{91C3C01F-68D2-4D9C-8932-B91B264EFBE6}.Release|ARM.Build.0 = Release|Any CPU
{91C3C01F-68D2-4D9C-8932-B91B264EFBE6}.Release|ARM64.ActiveCfg = Release|Any CPU
{91C3C01F-68D2-4D9C-8932-B91B264EFBE6}.Release|ARM64.Build.0 = Release|Any CPU
{91C3C01F-68D2-4D9C-8932-B91B264EFBE6}.Release|x64.ActiveCfg = Release|Any CPU
{91C3C01F-68D2-4D9C-8932-B91B264EFBE6}.Release|x64.Build.0 = Release|Any CPU
{91C3C01F-68D2-4D9C-8932-B91B264EFBE6}.Release|x86.ActiveCfg = Release|Any CPU
{91C3C01F-68D2-4D9C-8932-B91B264EFBE6}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
......@@ -20,7 +20,7 @@ using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Options;
using IoTSharp.Extensions.AspNetCore;
using Silkier.AspNetCore;
namespace IoTSharp.Controllers
{
......
......@@ -18,7 +18,7 @@ using System.Net.Http.Headers;
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using IoTSharp.Extensions.AspNetCore;
using Silkier.AspNetCore;
namespace IoTSharp.Controllers
{
......@@ -89,7 +89,7 @@ namespace IoTSharp.Controllers
}
catch (Exception ex)
{
actionResult = this.ExceptionRequest(ApiCode.Exception, ex.Message, ex);
actionResult =this.ExceptionRequest(ApiCode.Exception, ex.Message, ex);
}
return actionResult;
}
......
......@@ -8,24 +8,16 @@ namespace IoTSharp.Data
{
public class ApplicationDbContext : IdentityDbContext
{
private IConfiguration _configuration;
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options, IConfiguration configuration)
: base(options)
{
_configuration = configuration;
var _DataBase = configuration["DataBase"] ?? "sqlite";
if (Enum.TryParse(_DataBase, out DatabaseType databaseType))
{
DatabaseType = databaseType;
}
if (Database.GetPendingMigrations().Count() > 0)
{
Database.Migrate();
}
}
public DatabaseType DatabaseType { get; private set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
......@@ -47,27 +39,9 @@ namespace IoTSharp.Data
modelBuilder.Entity<AttributeLatest>().HasDiscriminator<DataCatalog>(nameof(Data.DataStorage.Catalog));
modelBuilder.Entity<TelemetryData>().HasDiscriminator<DataCatalog>(nameof(Data.DataStorage.Catalog));
modelBuilder.Entity<TelemetryLatest>().HasDiscriminator<DataCatalog>(nameof(Data.DataStorage.Catalog));
modelBuilder.Entity<Device>().HasDiscriminator<DeviceType>(nameof(Data.Device.DeviceType)).HasValue<Gateway>(DeviceType.Gateway).HasValue<Device>(DeviceType.Device);
modelBuilder.Entity<Gateway>().HasDiscriminator<DeviceType>(nameof(Data.Device.DeviceType));
switch (DatabaseType)
{
case DatabaseType.mssql:
ForSqlServer(modelBuilder);
break;
case DatabaseType.npgsql:
ForNpgsql(modelBuilder);
break;
case DatabaseType.sqlite:
break;
default:
break;
}
ForNpgsql(modelBuilder);
}
private void ForNpgsql(ModelBuilder modelBuilder)
......@@ -112,26 +86,7 @@ namespace IoTSharp.Data
.Property(b => b.ActionResult)
.HasColumnType("jsonb");
}
private void ForSqlServer(ModelBuilder modelBuilder)
{
modelBuilder.Entity<TelemetryData>()
.Property(b => b.Value_XML)
.HasColumnType("xml");
modelBuilder.Entity<AttributeLatest>()
.Property(b => b.Value_XML)
.HasColumnType("xml");
modelBuilder.Entity<DataStorage>()
.Property(b => b.Value_XML)
.HasColumnType("xml");
modelBuilder.Entity<TelemetryLatest>()
.Property(b => b.Value_XML)
.HasColumnType("xml");
}
public DbSet<Tenant> Tenant { get; set; }
public DbSet<Customer> Customer { get; set; }
public DbSet<Relationship> Relationship { get; set; }
......
......@@ -2,13 +2,12 @@
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
WORKDIR /app
EXPOSE 2927
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY ["IoTSharp/IoTSharp.csproj", "IoTSharp/"]
COPY ["IoTSharp.Extensions/IoTSharp.Extensions.csproj", "IoTSharp.Extensions/"]
COPY ["IoTSharp.Extensions.AspNetCore/IoTSharp.Extensions.AspNetCore.csproj", "IoTSharp.Extensions.AspNetCore/"]
RUN dotnet restore "IoTSharp/IoTSharp.csproj"
COPY . .
WORKDIR "/src/IoTSharp"
......@@ -20,4 +19,4 @@ RUN dotnet publish "IoTSharp.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "IoTSharp.dll"]
\ No newline at end of file
ENTRYPOINT ["dotnet", "IoTSharp.dll"]
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
WORKDIR /app
EXPOSE 2927
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY ["IoTSharp/IoTSharp.csproj", "IoTSharp/"]
RUN dotnet restore "IoTSharp/IoTSharp.csproj"
COPY . .
WORKDIR "/src/IoTSharp"
RUN dotnet build "IoTSharp.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "IoTSharp.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "IoTSharp.dll"]
\ No newline at end of file
......@@ -10,6 +10,8 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using IoTSharp.Extensions;
using Silkier.AspNetCore;
namespace IoTSharp.Handlers
{
public class RetainedMessageHandler : IMqttServerStorage
......
......@@ -22,6 +22,7 @@
<ApplicationIcon>Resources\Logo.ico</ApplicationIcon>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<PackageIconUrl />
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
......@@ -44,34 +45,36 @@
<PackageReference Include="IoTSharp.X509Extensions" Version="1.3.3" />
<PackageReference Include="LiteDB" Version="5.0.1" />
<PackageReference Include="IoTSharp.X509Extensions" Version="1.4.9" />
<PackageReference Include="LiteDB" Version="5.0.3" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.9.10" />
<PackageReference Include="MQTTnet" Version="3.0.8" />
<PackageReference Include="MQTTnet.AspNetCore" Version="3.0.8" />
<PackageReference Include="MQTTnet.Extensions.Rpc" Version="3.0.8" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.1.1" />
<PackageReference Include="NSwag.AspNetCore" Version="13.2.2" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.2" />
<PackageReference Include="NSwag.AspNetCore" Version="13.2.5" />
<PackageReference Include="QuartzHostedServiceEx" Version="0.0.7" />
<PackageReference Include="Silkier" Version="1.0.12" />
<PackageReference Include="Silkier.AspNetCore" Version="1.0.12" />
<PackageReference Include="Silkier.EFCore" Version="1.0.12" />
<PackageReference Include="System.ServiceModel.Primitives" Version="4.7.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.7.0" />
<PackageReference Include="CoAP.NET.Core" Version="1.1.0" />
<PackageReference Include="Quartz.Plugins.RecentHistory" Version="1.0.3" />
<PackageReference Include="QuartzminFork" Version="1.0.15" />
<PackageReference Include="EntityFrameworkCore.RawSQLExtensions" Version="1.1.24" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Hosting.WindowsServices" Version="3.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.1" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="3.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.1.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="3.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Hosting.WindowsServices" Version="3.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.2" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="3.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.2" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.2" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.1.2" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="3.1.2" />
<PackageReference Include="MQTTnet.AspNetCoreEx" Version="3.0.8" />
<PackageReference Include="MQTTnet.Extensions.ManagedClient" Version="3.0.8" />
......@@ -96,9 +99,4 @@
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\IoTSharp.Extensions.AspNetCore\IoTSharp.Extensions.AspNetCore.csproj" />
<ProjectReference Include="..\IoTSharp.Extensions\IoTSharp.Extensions.csproj" />
</ItemGroup>
</Project>
......@@ -4,10 +4,10 @@ using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using IoTSharp.Extensions.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using QuartzHostedService;
using Silkier.AspNetCore;
namespace IoTSharp
{
......
......@@ -7,7 +7,7 @@
}
},
"ConnectionStrings": {
"IoTSharp": "Server=host.docker.internal;Database=IoTSharp;Username=postgres;Password=future;"
"IoTSharp": "Server=localhost;Database=IoTSharp;Username=postgres;Password=future;"
},
"JwtKey": "kissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissme",
"JwtExpireHours": 24,
......
......@@ -4,18 +4,11 @@
"Default": "Warning"
}
},
"Kestrel": {
"EndPoints": {
"Http": {
"Url": "http://*:2927"
}
}
},
"HealthChecks-UI": {
"HealthChecks": [
{
"Name": "HTTP-Api-Basic",
"Uri": "http://localhost:2927/health"
"Uri": "http://localhost/health"
}
],
"Webhooks": [
......
<?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>{EE801BD6-5757-4A55-BC94-7FBA6E98F393}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>CoAPClient</RootNamespace>
<AssemblyName>CoAPClient</AssemblyName>
<TargetFrameworkVersion>v4.0</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>
<ItemGroup>
<Reference Include="CoAP.NET, Version=1.1.0.0, Culture=neutral, PublicKeyToken=e2c10a743037308b, processorArchitecture=MSIL">
<HintPath>..\packages\CoAP.1.1.0\lib\net40\CoAP.NET.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="readme.md" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
<!DOCTYPE html>
<!-- saved from url=(0014)about:internet -->
<html xmlns:msxsl="urn:schemas-microsoft-com:xslt"><head><meta content="en-us" http-equiv="Content-Language" /><meta content="text/html; charset=utf-16" http-equiv="Content-Type" /><title _locID="NuGetUpgradeReportTitle">
NuGetMigrationLog
</title><style>
/* Body style, for the entire document */
body
{
background: #F3F3F4;
color: #1E1E1F;
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
font-size: 12pt;
padding: 0;
margin: 0;
}
/* Header1 style, used for the main title */
h1
{
padding: 10px 0px 10px 10px;
font-size: 21pt;
background-color: #E2E2E2;
border-bottom: 1px #C1C1C2 solid;
color: #201F20;
margin: 0;
font-weight: normal;
}
/* Header2 style, used for "Overview" and other sections */
h2
{
font-size: 18pt;
font-weight: normal;
padding: 15px 0 5px 0;
margin: 0;
}
/* Header3 style, used for sub-sections, such as project name */
h3
{
font-weight: normal;
font-size: 15pt;
margin: 0;
padding: 15px 0 5px 0;
background-color: transparent;
}
.info-text
{
margin: 0px 0 0.75em 0;
}
/* Color all hyperlinks one color */
a
{
color: #1382CE;
}
/* Table styles */
table
{
border-spacing: 0 0;
border-collapse: collapse;
font-size: 11pt;
}
table th
{
background: #E7E7E8;
text-align: left;
text-decoration: none;
font-weight: normal;
padding: 3px 6px 3px 6px;
}
table td
{
vertical-align: top;
padding: 3px 6px 5px 5px;
margin: 0px;
border: 1px solid #E7E7E8;
background: #F7F7F8;
}
/* Local link is a style for hyperlinks that link to file:/// content, there are lots so color them as 'normal' text until the user mouse overs */
.localLink
{
color: #1E1E1F;
background: #EEEEED;
text-decoration: none;
}
.localLink:hover
{
color: #1382CE;
background: #FFFF99;
text-decoration: none;
}
.issueCell
{
width: 100%;
}
.packageIssue
{
margin-left: 25px;
}
/* Padding around the content after the h1 */
#content
{
padding: 0px 20px 20px 20px;
}
.issues table
{
width: 97%;
}
/* All Icons */
.IconSuccessEncoded, .IconInfoEncoded, .IconWarningEncoded, .IconErrorEncoded
{
min-width:18px;
min-height:18px;
background-repeat:no-repeat;
background-position:center;
}
.IconSuccessEncoded
{
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABcElEQVR4Xq2TsUsCURzHv15g8ZJcBWlyiYYgCIWcb9DFRRwMW5TA2c0/QEFwFkxxUQdxVlBwCYWOi6IhWgQhBLHJUCkhLr/BW8S7gvrAg+N+v8/v+x68Z8MGy+XSCyABQAXgBgHGALoASkIIDWSLeLBetdHryMjd5IxQPWT4rn1c/P7+xxp72Cs9m5SZ0Bq2vPnbPFafK2zDvmNHypdC0BPkLlQhxJsCAhQoZwdZU5mwxh720qGo8MzTxTTKZDPCx2HoVzp6lz0Q9tKhyx0kGs8Ny+TkWRKk8lCROwEduhyg9l/6lunOPSfmH3NUH6uQ0KHLAe7JYvJjevm+DAMGJHToKtigE+vwvIidxLamb8IBY9e+C5LiXREkfho3TSd06HJA13/oh6T51MTsfQbHrsMynQ5dDihFjiK8JJAU9AKIWTp76dCVN7HWHrajmUEGvyF9nkbAE6gLIS7kTUyuf2gscLoJrElZo/Mvj+nPz/kLTmfnEwP3tB0AAAAASUVORK5CYII=);
}
.IconInfoEncoded
{
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABHElEQVR4Xs2TsUoDQRRF7wwoziokjZUKadInhdhukR9YP8DMX1hYW+QvdsXa/QHBbcXC7W0CamWTQnclFutceIQJwwaWNLlwm5k5d94M76mmaeCrrmsLYOocY12FcxZFUeozCqKqqgYA8uevv1H6VuPxcwlfk5N92KHBxfFeCSAxxswlYAW/Xr989x/mv9gkhtyMDhcAxgzRsp7flj8B/HF1RsMXq+NZMkopaHe7lbKxQUEIGbKsYNoGn969060hZBkQex/W8oRQwsQaW2o3Ago2SVcJUzAgY3N0lTCZZm+zPS8HB51gMmS1DEYyOz9acKO1D8JWTlafKIMxdhvlfdyT94Vv5h7P8Ky7nQzACmhvKq3zk3PjW9asz9D/1oigecsioooAAAAASUVORK5CYII=);
}
.IconWarningEncoded
{
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAx0lEQVR4XpWSMQ7CMAxFf4xAyBMLCxMrO8dhaBcuwdCJS3RJBw7SA/QGTCxdWJgiQYWKXJWKIXHIlyw5lqr34tQgEOdcBsCOx5yZK3hCCKdYXneQkh4pEfqzLfu+wVDSyyzFoJjfz9NB+pAF+eizx2Vruts0k15mPgvS6GYvpVtQhB61IB/dk6AF6fS4Ben0uIX5odtFe8Q/eW1KvFeH4e8khT6+gm5B+t3juyDt7n0jpe+CANTd+oTUjN/U3yVaABnSUjFz/gFq44JaVSCXeQAAAABJRU5ErkJggg==);
}
.IconErrorEncoded
{
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABQElEQVR4XqWTvUoEQRCE6wYPZUA80AfwAQz23uCMjA7MDRQEIzPBVEyNTQUFIw00vcQTTMzuAh/AxEQQT8HF/3G/oGGnEUGuoNnd6qoZuqltyKEsyzVJq5I6rnUp6SjGeGhESikzzlc1eL7opfuVbrqbU1Zw9NCgtQMaZpY0eNnaaL2fHusvTK5vKu7sjSS1Y4y3QUA6K3e3Mau5UFDyMP7tYF9o8cAHZv68vipoIJg971PZIZ5HiwdvYGGvFVFHmGmZ2MxwmQYPXubPl9Up0tfoMQGetXd6mRbvhBw+boZ6WF7Mbv1+GsHRk0fQmPAH1GfmZirbCfDJ61tw3Px8/8pZsPAG4jlVhcPgZ7adwNWBB68lkRQWFiTgFlbnLY3DGGM7izIJIyT/jjIvEJw6fdJTc6krDzh6aMwMP9bvDH4ADSsa9uSWVJkAAAAASUVORK5CYII=);
}
</style></head><body><h1>
NuGet Migration Report - Clients\CoAPClient</h1><div id="content"><h2 _locID="OverviewTitle">Overview</h2><div class="info-text">Migration to PackageReference was completed successfully. Please build and run your solution to verify that all packages are available.</div><div class="info-text">
If you run into any problems, have feedback, questions, or concerns, please
<a href="https://github.com/NuGet/Home/issues/">file an issue on the NuGet GitHub repository.</a></div><div class="info-text">
Changed files and this report have been backed up here:
<a href="D:\GitHub\IoTSharp\IoTSharp\MigrationBackup\4f889639\Clients\CoAPClient">D:\GitHub\IoTSharp\IoTSharp\MigrationBackup\4f889639\Clients\CoAPClient</a></div><div class="info-text"><a href="https://aka.ms/nuget-pc2pr-migrator-rollback">Help me rollback to packages.config</a></div><h2 _locID="PackagesTitle">Packages processed</h2><h3 _locID="IncludePackagesTitle">Top-level dependencies:</h3><div class="issues"><table><tr><th class="issueCell">Package Id</th><th>Version</th></tr><tr><td class="issueCell"><span>CoAP</span></td><td><span>
v1.1.0</span></td></tr></table></div><p /><h3 _locID="IncludePackagesTitle">Transitive dependencies:</h3><div class="issues"><table><tr><th class="issueCell">Package Id</th><th>Version</th></tr><tr><td class="issueCell">
No transitive dependencies found.
</td><td /></tr></table></div><h2 _locID="IssuesTitle">Package compatibility issues</h2><div class="issues"><table><tr><th /><th class="issueCell" _locID="DescriptionTableHeader">Description</th></tr><tr><td class="IconInfoEncoded" /><td class="issueCell">
No issues were found.
</td></tr></table></div></div></body></html>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" Sdk="Microsoft.Docker.Sdk">
<PropertyGroup Label="Globals">
<ProjectVersion>2.1</ProjectVersion>
<DockerTargetOS>Linux</DockerTargetOS>
<ProjectGuid>91c3c01f-68d2-4d9c-8932-b91b264efbe6</ProjectGuid>
<DockerLaunchAction>LaunchBrowser</DockerLaunchAction>
<DockerServiceUrl>{Scheme}://localhost:{ServicePort}</DockerServiceUrl>
<DockerServiceName>iotsharp</DockerServiceName>
</PropertyGroup>
<ItemGroup>
<None Include="docker-compose.override.yml">
<DependentUpon>docker-compose.yml</DependentUpon>
</None>
<None Include="docker-compose.yml" />
<None Include=".dockerignore" />
</ItemGroup>
</Project>
\ No newline at end of file
version: '3.4'
services:
iotsharp:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=https://+:443;http://+:80
ports:
- "80"
- "443"
volumes:
- ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro
- ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro
\ No newline at end of file
version: '3.4'
services:
iotsharp:
image: ${DOCKER_REGISTRY-}iotsharp
build:
context: .
dockerfile: IoTSharp/Dockerfile
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册