diff --git a/服务API.Model/AlarmTable.cs b/DataVAPI.Model/AlarmTable.cs
similarity index 86%
rename from 服务API.Model/AlarmTable.cs
rename to DataVAPI.Model/AlarmTable.cs
index 7b71551..16f53e8 100644
--- a/服务API.Model/AlarmTable.cs
+++ b/DataVAPI.Model/AlarmTable.cs
@@ -1,16 +1,16 @@
-using System;
+using DataVAPI.ServerDB.MongoDB;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
-using 服务API.ServerDB.MongoDB;
-namespace 服务API.Model
+namespace DataVAPI.Model
{
///
/// 告警消息表
///
- public class AlarmTable :BaseEntity
+ public class AlarmTable : BaseEntity
{
///
/// 告警时间
diff --git a/服务API.Model/CommandModel.cs b/DataVAPI.Model/CommandModel.cs
similarity index 87%
rename from 服务API.Model/CommandModel.cs
rename to DataVAPI.Model/CommandModel.cs
index 43d3f33..5aafafc 100644
--- a/服务API.Model/CommandModel.cs
+++ b/DataVAPI.Model/CommandModel.cs
@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace 服务API.Model
+namespace DataVAPI.Model
{
///
/// 命令实体类
@@ -22,6 +22,6 @@ namespace 服务API.Model
///
/// 命令变量:执行变量 key为属性或时间 value为值或者消息
///
- public Dictionary CommandValue { get; set; }
+ public Dictionary CommandValue { get; set; }
}
}
diff --git a/服务API.Model/服务API.Model.csproj b/DataVAPI.Model/DataVAPI.Model.csproj
similarity index 76%
rename from 服务API.Model/服务API.Model.csproj
rename to DataVAPI.Model/DataVAPI.Model.csproj
index 4b6109b..82be567 100644
--- a/服务API.Model/服务API.Model.csproj
+++ b/DataVAPI.Model/DataVAPI.Model.csproj
@@ -7,7 +7,7 @@
-
+
diff --git a/服务API.Model/DeviceTable.cs b/DataVAPI.Model/DeviceTable.cs
similarity index 87%
rename from 服务API.Model/DeviceTable.cs
rename to DataVAPI.Model/DeviceTable.cs
index ef63bc7..ea983b0 100644
--- a/服务API.Model/DeviceTable.cs
+++ b/DataVAPI.Model/DeviceTable.cs
@@ -1,16 +1,16 @@
-using System;
+using DataVAPI.ServerDB.MongoDB;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
-using 服务API.ServerDB.MongoDB;
-namespace 服务API.Model
+namespace DataVAPI.Model
{
///
/// 设备信息表
///
- public class DeviceTable :BaseEntity
+ public class DeviceTable : BaseEntity
{
///
/// 阿里云设备key
diff --git a/服务API.Model/JsonMsg.cs b/DataVAPI.Model/JsonMsg.cs
similarity index 75%
rename from 服务API.Model/JsonMsg.cs
rename to DataVAPI.Model/JsonMsg.cs
index b702d4e..62a9983 100644
--- a/服务API.Model/JsonMsg.cs
+++ b/DataVAPI.Model/JsonMsg.cs
@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace 服务API.Model
+namespace DataVAPI.Model
{
///
/// 返回消息
@@ -42,25 +42,25 @@ namespace 服务API.Model
public int icon { get; set; }
- public static JsonMsg OK(T obj,string msg = "接口名称",string mso="调用接口成功")
+ public static JsonMsg OK(T obj, string msg = "接口名称", string mso = "调用接口成功")
{
- string str = $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} 接口名称为“ {msg + "”调用成功,描述:" + mso+ obj}";
+ string str = $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} 接口名称为“ {msg + "”调用成功,描述:" + mso + obj}";
ConsoleColor currentForeColor = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine(str);
Console.ForegroundColor = currentForeColor;
;
- return new JsonMsg() { code = 1,ms= mso,msg = "成功",obj = obj,icon = 1,oTData = new IOTData { data = obj } };
+ return new JsonMsg() { code = 1, ms = mso, msg = "成功", obj = obj, icon = 1, oTData = new IOTData { data = obj } };
}
- public static JsonMsg Error(T obj,string msg = "接口名称",string mso = "调用接口成功失败")
+ public static JsonMsg Error(T obj, string msg = "接口名称", string mso = "调用接口成功失败")
{
- string str = $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} 接口名称为“ {msg + "”调用失败,描述:" + mso+ obj}";
+ string str = $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} 接口名称为“ {msg + "”调用失败,描述:" + mso + obj}";
ConsoleColor currentForeColor = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(str);
Console.ForegroundColor = currentForeColor;
- return new JsonMsg() { code = 0,ms = mso,msg = "失败",obj = obj,icon = 1,oTData = new IOTData { data = obj } };
+ return new JsonMsg() { code = 0, ms = mso, msg = "失败", obj = obj, icon = 1, oTData = new IOTData { data = obj } };
}
}
diff --git a/服务API.Model/LargeScreenTable.cs b/DataVAPI.Model/LargeScreenTable.cs
similarity index 70%
rename from 服务API.Model/LargeScreenTable.cs
rename to DataVAPI.Model/LargeScreenTable.cs
index b482bb0..7466899 100644
--- a/服务API.Model/LargeScreenTable.cs
+++ b/DataVAPI.Model/LargeScreenTable.cs
@@ -1,16 +1,16 @@
-using System;
+using DataVAPI.ServerDB.MongoDB;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
-using 服务API.ServerDB.MongoDB;
-namespace 服务API.Model
+namespace DataVAPI.Model
{
///
/// 大屏消息表
///
- public class LargeScreenTable :BaseEntity
+ public class LargeScreenTable : BaseEntity
{
///
/// Json值
diff --git a/服务API.Model/LogTable.cs b/DataVAPI.Model/LogTable.cs
similarity index 86%
rename from 服务API.Model/LogTable.cs
rename to DataVAPI.Model/LogTable.cs
index d44b662..1c82f45 100644
--- a/服务API.Model/LogTable.cs
+++ b/DataVAPI.Model/LogTable.cs
@@ -1,16 +1,16 @@
-using System;
+using DataVAPI.ServerDB.MongoDB;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
-using 服务API.ServerDB.MongoDB;
-namespace 服务API.Model
+namespace DataVAPI.Model
{
///
/// 日志表
///
- public class LogTable :BaseEntity
+ public class LogTable : BaseEntity
{
///
/// 日志时间
diff --git a/服务API.ProcessServices/AppConfig/AppConfigurtaionServices.cs b/DataVAPI.ProcessServices/AppConfig/AppConfigurtaionServices.cs
similarity index 95%
rename from 服务API.ProcessServices/AppConfig/AppConfigurtaionServices.cs
rename to DataVAPI.ProcessServices/AppConfig/AppConfigurtaionServices.cs
index 24fe5f4..8063240 100644
--- a/服务API.ProcessServices/AppConfig/AppConfigurtaionServices.cs
+++ b/DataVAPI.ProcessServices/AppConfig/AppConfigurtaionServices.cs
@@ -2,7 +2,7 @@
using Microsoft.Extensions.Configuration.Json;
using System;
-namespace 服务API.ProcessServices
+namespace DataVAPI.ProcessServices.AppConfig
{
public class AppConfigurtaionServices
{
diff --git a/服务API.ProcessServices/服务API.ProcessServices.csproj b/DataVAPI.ProcessServices/DataVAPI.ProcessServices.csproj
similarity index 81%
rename from 服务API.ProcessServices/服务API.ProcessServices.csproj
rename to DataVAPI.ProcessServices/DataVAPI.ProcessServices.csproj
index 1ed572f..9ca2c04 100644
--- a/服务API.ProcessServices/服务API.ProcessServices.csproj
+++ b/DataVAPI.ProcessServices/DataVAPI.ProcessServices.csproj
@@ -3,7 +3,7 @@
net6.0
Exe
- 服务API.ProcessServices.Program
+ DataVAPI.ProcessServices.Program
@@ -13,7 +13,7 @@
-
+
diff --git a/服务API.ProcessServices/Program.cs b/DataVAPI.ProcessServices/Program.cs
similarity index 66%
rename from 服务API.ProcessServices/Program.cs
rename to DataVAPI.ProcessServices/Program.cs
index f0d94a9..7ed61f0 100644
--- a/服务API.ProcessServices/Program.cs
+++ b/DataVAPI.ProcessServices/Program.cs
@@ -1,8 +1,7 @@
-using System;
-using 服务API.ProcessServices.阿里云处理流程One;
-using 服务API.Tool.控制台显示;
+using DataVAPI.ProcessServices.阿里云处理流程One;
+using DataVAPI.Tool.控制台显示;
-namespace 服务API.ProcessServices
+namespace DataVAPI.ProcessServices
{
internal class Program
{
diff --git a/服务API.ProcessServices/appsettings.json b/DataVAPI.ProcessServices/appsettings.json
similarity index 100%
rename from 服务API.ProcessServices/appsettings.json
rename to DataVAPI.ProcessServices/appsettings.json
diff --git a/服务API.ProcessServices/文件存储/SqlContext.cs b/DataVAPI.ProcessServices/文件存储/SqlContext.cs
similarity index 95%
rename from 服务API.ProcessServices/文件存储/SqlContext.cs
rename to DataVAPI.ProcessServices/文件存储/SqlContext.cs
index 99081b6..f1e6a0b 100644
--- a/服务API.ProcessServices/文件存储/SqlContext.cs
+++ b/DataVAPI.ProcessServices/文件存储/SqlContext.cs
@@ -8,9 +8,9 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace 服务API.ProcessServices.文件存储
+namespace DataVAPI.ProcessServices.文件存储
{
- public class SqlContext :DbContext where T : DataVModel, new()
+ public class SqlContext : DbContext where T : DataVModel, new()
{
public static SqlContext Base = new();
@@ -23,7 +23,7 @@ namespace 服务API.ProcessServices.文件存储
{
get
{
- Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"AccessFile"));
+ Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AccessFile"));
return $"{AppDomain.CurrentDomain.BaseDirectory}AccessFile\\{typeof(T).Name}.db";
}
}
diff --git a/服务API.ProcessServices/阿里云处理流程One/ALY_ProcessServer.cs b/DataVAPI.ProcessServices/阿里云处理流程One/ALY_ProcessServer.cs
similarity index 90%
rename from 服务API.ProcessServices/阿里云处理流程One/ALY_ProcessServer.cs
rename to DataVAPI.ProcessServices/阿里云处理流程One/ALY_ProcessServer.cs
index b52bd63..f7c33ca 100644
--- a/服务API.ProcessServices/阿里云处理流程One/ALY_ProcessServer.cs
+++ b/DataVAPI.ProcessServices/阿里云处理流程One/ALY_ProcessServer.cs
@@ -1,13 +1,14 @@
-using System;
+using DataVAPI.ProcessServices.AppConfig;
+using DataVAPI.Tool;
+using DataVAPI.Tool.API请求;
+using DataVAPI.Tool.IOT;
+using DataVAPI.Tool.控制台显示;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
-using 服务API.Tool;
-using 服务API.Tool.API请求;
-using 服务API.Tool.IOT;
-using 服务API.Tool.控制台显示;
-namespace 服务API.ProcessServices.阿里云处理流程One
+namespace DataVAPI.ProcessServices.阿里云处理流程One
{
///
/// 老服务代码
@@ -68,7 +69,7 @@ namespace 服务API.ProcessServices.阿里云处理流程One
//MQTT 数据接收处理
ConsoleHelper.WriteInfoLine("尝试连接阿里云.");
IOTDevServer.GetInstance().SetUrl(APIurl);
- if (IOTDevServer.GetInstance().CreateLinks(0,out device))
+ if (IOTDevServer.GetInstance().CreateLinks(0, out device))
{
ConsoleHelper.WriteSuccessLine("连接阿里云成功!");
}
@@ -183,7 +184,7 @@ namespace 服务API.ProcessServices.阿里云处理流程One
if (receiveModel?.deviceContext != null && receiveModel?.status != null)//状态变更消息
{
devModel?.operatingDeviceStatus.data?.Find(par => par.deviceName == receiveModel.deviceContext.deviceName)?.SetStatus(receiveModel.status.value);
- devModel.infoMessage.data.Add(new DeviceBase { DeviceMC = receiveModel.deviceContext.deviceName,DeviceMS = $"设备{receiveModel.status.value}了!",DeviceSJ = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") });
+ devModel.infoMessage.data.Add(new DeviceBase { DeviceMC = receiveModel.deviceContext.deviceName, DeviceMS = $"设备{receiveModel.status.value}了!", DeviceSJ = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") });
DevStatus dev = devModel?.operatingDeviceStatus.data?.Find(par => par.deviceName == receiveModel.deviceContext.deviceName);
if (dev != null)
@@ -191,11 +192,11 @@ namespace 服务API.ProcessServices.阿里云处理流程One
ApiAddLog(Tools.JsonConvertTools(new LogTable
{
devicename = receiveModel.deviceContext.deviceName,
- ClientId= dev.clientId,
- LogTime=DateTime.Now,
- LogType="1",
- LogMessage= $"设备{receiveModel.status.value}了!",
- LogVla="上下线"
+ ClientId = dev.clientId,
+ LogTime = DateTime.Now,
+ LogType = "1",
+ LogMessage = $"设备{receiveModel.status.value}了!",
+ LogVla = "上下线"
}));
}
}
@@ -205,11 +206,11 @@ namespace 服务API.ProcessServices.阿里云处理流程One
#region 1.设置data默认值
if (screen1Monitor.operatingDeviceStatus.data.Count == 0)
{
- screen1Monitor.operatingDeviceStatus.data.Add(new DevStatus { DeviceMC = "",DeviceMS = "",DeviceSJ = "",deviceName = "",DeviceZT = "",gmtCreate = "" });
+ screen1Monitor.operatingDeviceStatus.data.Add(new DevStatus { DeviceMC = "", DeviceMS = "", DeviceSJ = "", deviceName = "", DeviceZT = "", gmtCreate = "" });
}
if (screen1Monitor.infoMessage.data.Count == 0)
{
- screen1Monitor.infoMessage.data.Add(new DeviceBase { DeviceMC = "",DeviceMS = "",DeviceSJ = "" });
+ screen1Monitor.infoMessage.data.Add(new DeviceBase { DeviceMC = "", DeviceMS = "", DeviceSJ = "" });
}
#endregion
@@ -217,7 +218,7 @@ namespace 服务API.ProcessServices.阿里云处理流程One
if (!string.IsNullOrEmpty(JSON))
{
AddScreenCreateOrUpdate(JSON);
- IOTDevServer.GetInstance().IOT_Publish(IOTDevServer.ScreenShowPubTopic,JSON);
+ IOTDevServer.GetInstance().IOT_Publish(IOTDevServer.ScreenShowPubTopic, JSON);
}
if (devModel.infoMessage.data != null && devModel.infoMessage.data.Count > 0)
@@ -268,7 +269,7 @@ namespace 服务API.ProcessServices.阿里云处理流程One
}
}
- }),"队列任务执行");
+ }), "队列任务执行");
}
///
@@ -276,7 +277,7 @@ namespace 服务API.ProcessServices.阿里云处理流程One
///
///
///
- private void DevIOTActionHandler(string topic,string message)
+ private void DevIOTActionHandler(string topic, string message)
{
if (string.IsNullOrEmpty(topic)) return;
@@ -297,7 +298,7 @@ namespace 服务API.ProcessServices.阿里云处理流程One
}
else if (topic == IOTDevServer.HeartbeatSubTopic)//上下线订阅主题
{
- ReceiveModel receiveModel =Tools.JsonToObjectTools(message);
+ ReceiveModel receiveModel = Tools.JsonToObjectTools(message);
if (receiveModel != null && receiveModel.status != null)//上下线通知
{
if (receiveModel.deviceContext.deviceName == "hbldev") return;
@@ -328,7 +329,7 @@ namespace 服务API.ProcessServices.阿里云处理流程One
{
///api/Screen/CreateOrUpdate
string url = APIurl + "/api/Screen/CreateOrUpdate";
- HttpRequestHelper.HttpPostRequest(url,Tools.JsonConvertTools(new LargeScreen() { json = json,devicename = device.devicename,clientId = device.ClientId })); return true;
+ HttpRequestHelper.HttpPostRequest(url, Tools.JsonConvertTools(new LargeScreen() { json = json, devicename = device.devicename, clientId = device.ClientId })); return true;
}
catch (Exception ex)
{
@@ -374,7 +375,7 @@ namespace 服务API.ProcessServices.阿里云处理流程One
al.devicename = devModel?.operatingDeviceStatus.data?.Find(par => par.clientId == al.ClientId)?.deviceName;
}
string url = APIurl + "/api/Alarm/Create";
- HttpRequestHelper.HttpPostRequest(url,Tools.JsonConvertTools(al));
+ HttpRequestHelper.HttpPostRequest(url, Tools.JsonConvertTools(al));
}
}
@@ -400,7 +401,7 @@ namespace 服务API.ProcessServices.阿里云处理流程One
lo.devicename = devModel?.operatingDeviceStatus.data?.Find(par => par.clientId == lo.ClientId)?.deviceName;
}
string url = APIurl + "/api/Log/Create";
- HttpRequestHelper.HttpPostRequest(url,Tools.JsonConvertTools(lo));
+ HttpRequestHelper.HttpPostRequest(url, Tools.JsonConvertTools(lo));
}
}
catch (Exception ex)
diff --git a/服务API.ServerDB/服务API.ServerDB.csproj b/DataVAPI.ServerDB/DataVAPI.ServerDB.csproj
similarity index 100%
rename from 服务API.ServerDB/服务API.ServerDB.csproj
rename to DataVAPI.ServerDB/DataVAPI.ServerDB.csproj
diff --git a/服务API.ServerDB/MongoDB/MongodbHelper.cs b/DataVAPI.ServerDB/MongoDB/MongodbHelper.cs
similarity index 81%
rename from 服务API.ServerDB/MongoDB/MongodbHelper.cs
rename to DataVAPI.ServerDB/MongoDB/MongodbHelper.cs
index 2ee860a..b4d6365 100644
--- a/服务API.ServerDB/MongoDB/MongodbHelper.cs
+++ b/DataVAPI.ServerDB/MongoDB/MongodbHelper.cs
@@ -10,7 +10,7 @@ using System.Reflection;
using System.Text;
using System.Threading.Tasks;
-namespace 服务API.ServerDB.MongoDB
+namespace DataVAPI.ServerDB.MongoDB
{
public class Db
{
@@ -24,7 +24,7 @@ namespace 服务API.ServerDB.MongoDB
private Db() { }
- public static IMongoDatabase GetDb(string conn,string dbna)
+ public static IMongoDatabase GetDb(string conn, string dbna)
{
if (db == null)
{
@@ -47,16 +47,16 @@ namespace 服务API.ServerDB.MongoDB
private IMongoCollection collection = null;
- public MongoDbHelper(string conn,string dbna)
+ public MongoDbHelper(string conn, string dbna)
{
- this.db = Db.GetDb(conn,dbna);
+ db = Db.GetDb(conn, dbna);
collection = db.GetCollection(typeof(T).Name);
}
public T Insert(T entity)
{
var flag = ObjectId.GenerateNewId();
- entity.GetType().GetProperty("Id").SetValue(entity,flag);
+ entity.GetType().GetProperty("Id").SetValue(entity, flag);
entity.State = "y";
entity.CreateTime = DateTime.Now;//.ToString("yyyy-MM-dd HH:mm:ss");
entity.UpdateTime = DateTime.Now;//.ToString("yyyy-MM-dd HH:mm:ss");
@@ -66,10 +66,10 @@ namespace 服务API.ServerDB.MongoDB
public List Inserts(List entity)
{
- entity?.ForEach(par =>
+ entity?.ForEach(par =>
{
var flag = ObjectId.GenerateNewId();
- par.GetType().GetProperty("Id").SetValue(par,flag);
+ par.GetType().GetProperty("Id").SetValue(par, flag);
par.State = "y";
par.CreateTime = DateTime.Now;
par.UpdateTime = DateTime.Now;
@@ -78,11 +78,11 @@ namespace 服务API.ServerDB.MongoDB
return entity;
}
- public void Modify(string id,string field,string value)
+ public void Modify(string id, string field, string value)
{
- var filter = Builders.Filter.Eq("Id",ObjectId.Parse(id));
- var updated = Builders.Update.Set(field,value);
- UpdateResult result = collection.UpdateOneAsync(filter,updated).Result;
+ var filter = Builders.Filter.Eq("Id", ObjectId.Parse(id));
+ var updated = Builders.Update.Set(field, value);
+ UpdateResult result = collection.UpdateOneAsync(filter, updated).Result;
}
public void Update(T entity)
@@ -97,15 +97,15 @@ namespace 服务API.ServerDB.MongoDB
{
if (!newValue.ToString().Equals(oldValue.ToString()))
{
- old.GetType().GetProperty(prop.Name).SetValue(old,newValue.ToString());
+ old.GetType().GetProperty(prop.Name).SetValue(old, newValue.ToString());
}
}
}
old.State = "y";
old.UpdateTime = DateTime.Now;//.ToString("yyyy-MM-dd HH:mm:ss");
- var filter = Builders.Filter.Eq("Id",entity.Id);
- ReplaceOneResult result = collection.ReplaceOneAsync(filter,old).Result;
+ var filter = Builders.Filter.Eq("Id", entity.Id);
+ ReplaceOneResult result = collection.ReplaceOneAsync(filter, old).Result;
}
@@ -119,14 +119,14 @@ namespace 服务API.ServerDB.MongoDB
{
try
{
- var Type =prop.PropertyType.Name;
+ var Type = prop.PropertyType.Name;
var newValue = prop.GetValue(entity);
var oldValue = old.GetType().GetProperty(prop.Name).GetValue(old);
if (newValue != null)
{
if (!newValue.ToString().Equals(oldValue.ToString()))
{
- old.GetType().GetProperty(prop.Name).SetValue(old,newValue);
+ old.GetType().GetProperty(prop.Name).SetValue(old, newValue);
//if (Type == typeof(DateTime).Name)
}
}
@@ -140,19 +140,19 @@ namespace 服务API.ServerDB.MongoDB
old.State = "y";
old.UpdateTime = DateTime.Now;//.ToString("yyyy-MM-dd HH:mm:ss");
- var filter = Builders.Filter.Eq("IdStr",entity.IdStr);
- ReplaceOneResult result = collection.ReplaceOneAsync(filter,old).Result;
+ var filter = Builders.Filter.Eq("IdStr", entity.IdStr);
+ ReplaceOneResult result = collection.ReplaceOneAsync(filter, old).Result;
}
public void Delete(T entity)
{
- var filter = Builders.Filter.Eq("Id",entity.Id);
+ var filter = Builders.Filter.Eq("Id", entity.Id);
collection.DeleteOneAsync(filter);
}
public void Delete(string id)
{
- var filter = Builders.Filter.Eq("Id",ObjectId.Parse(id));
+ var filter = Builders.Filter.Eq("Id", ObjectId.Parse(id));
collection.DeleteOneAsync(filter);
}
@@ -161,27 +161,28 @@ namespace 服务API.ServerDB.MongoDB
return collection.Find(a => a.Id == ObjectId.Parse(id))?.ToList().FirstOrDefault();
}
- public List QueryAllTime(string clientId,DateTime datesta ,DateTime datastop )
+ public List QueryAllTime(string clientId, DateTime datesta, DateTime datastop)
{
if (string.IsNullOrEmpty(clientId))
{
if (datastop >= datesta && datastop > DateTime.Parse("2011-10-11 00:00:00"))
{
- return collection.Find(a => (a.CreateTime >= datesta) && (a.CreateTime <= datastop))?.ToList().OrderByDescending(a => a.CreateTime).ToList();
+ return collection.Find(a => a.CreateTime >= datesta && a.CreateTime <= datastop)?.ToList().OrderByDescending(a => a.CreateTime).ToList();
}
else
{
- return collection.Find(a => (a.CreateTime >= datesta))?.ToList().OrderByDescending(a => a.CreateTime).ToList();
+ return collection.Find(a => a.CreateTime >= datesta)?.ToList().OrderByDescending(a => a.CreateTime).ToList();
}
- } else
+ }
+ else
{
if (datastop >= datesta && datastop > DateTime.Parse("2011-10-11 00:00:00"))
{
- return collection.Find(a => a.ClientId == clientId && (a.CreateTime >= datesta) && (a.CreateTime <= datastop))?.ToList().OrderByDescending(a => a.CreateTime).ToList();
+ return collection.Find(a => a.ClientId == clientId && a.CreateTime >= datesta && a.CreateTime <= datastop)?.ToList().OrderByDescending(a => a.CreateTime).ToList();
}
else
{
- return collection.Find(a => a.ClientId == clientId && (a.CreateTime >= datesta))?.ToList().OrderByDescending(a => a.CreateTime).ToList();
+ return collection.Find(a => a.ClientId == clientId && a.CreateTime >= datesta)?.ToList().OrderByDescending(a => a.CreateTime).ToList();
}
}
}
@@ -193,12 +194,12 @@ namespace 服务API.ServerDB.MongoDB
public List QueryClientId(string clientId)
{
- return collection.Find(a => a.ClientId == clientId && (a.CreateTime >= DateTime.Now.Date) && a.State == "y")?.ToList().OrderByDescending(a => a.CreateTime).ToList();
+ return collection.Find(a => a.ClientId == clientId && a.CreateTime >= DateTime.Now.Date && a.State == "y")?.ToList().OrderByDescending(a => a.CreateTime).ToList();
}
public List QueryDeviceId(string clientId, string deviceId)
{
- return collection.Find(a => a.DeviceId == deviceId && a.ClientId==clientId && (a.CreateTime >= DateTime.Now.Date) && a.State == "y")?.ToList().OrderByDescending(a => a.CreateTime).ToList();
+ return collection.Find(a => a.DeviceId == deviceId && a.ClientId == clientId && a.CreateTime >= DateTime.Now.Date && a.State == "y")?.ToList().OrderByDescending(a => a.CreateTime).ToList();
}
public List QueryAll()
@@ -206,7 +207,7 @@ namespace 服务API.ServerDB.MongoDB
return collection.Find(a => a.State.Equals("y"))?.ToList();
}
- public PaginationListModel BasePagQuery(string chid,DateTime datesta,DateTime datastop,int PageNumber,int PageSize)
+ public PaginationListModel BasePagQuery(string chid, DateTime datesta, DateTime datastop, int PageNumber, int PageSize)
{
BasePaginationModel pagination = new BasePaginationModel()
{
@@ -214,14 +215,14 @@ namespace 服务API.ServerDB.MongoDB
PageSize = PageSize
};
- var RT = GetPagination(chid,datesta,datastop, ref pagination);
+ var RT = GetPagination(chid, datesta, datastop, ref pagination);
return RT;
}
- public PaginationListModel GetPagination(string chid,DateTime datesta,DateTime datastop,ref BasePaginationModel Pagination)
+ public PaginationListModel GetPagination(string chid, DateTime datesta, DateTime datastop, ref BasePaginationModel Pagination)
{
- var mongorResult = collection.AsQueryable().Where(A => !string.IsNullOrEmpty(A.ClientId) && A.ClientId==chid && A.CreateTime>=datesta && A.CreateTime<=datastop).OrderByDescending(item => item.CreateTime);
- var result = MongoPaginationService.BasePager(mongorResult,ref Pagination);
+ var mongorResult = collection.AsQueryable().Where(A => !string.IsNullOrEmpty(A.ClientId) && A.ClientId == chid && A.CreateTime >= datesta && A.CreateTime <= datastop).OrderByDescending(item => item.CreateTime);
+ var result = mongorResult.BasePager(ref Pagination);
PaginationListModel M = new PaginationListModel()
{
Data = result?.ToList(),
@@ -247,7 +248,7 @@ namespace 服务API.ServerDB.MongoDB
}
set
{
- _ID= value;
+ _ID = value;
IdStr = _ID.ToString();
}
}
@@ -294,7 +295,7 @@ namespace 服务API.ServerDB.MongoDB
///
///
///
- public static IQueryable BasePager(this IOrderedQueryable entitys,ref BasePaginationModel pagination)
+ public static IQueryable BasePager(this IOrderedQueryable entitys, ref BasePaginationModel pagination)
{
if (pagination != null)
{
@@ -311,7 +312,7 @@ namespace 服务API.ServerDB.MongoDB
/// 数据源IQueryable
/// 分页参数
///
- private static IQueryable GetBasePagination(this IOrderedQueryable source,BasePaginationModel pagination)
+ private static IQueryable GetBasePagination(this IOrderedQueryable source, BasePaginationModel pagination)
{
pagination.Total = source.Count();
return source.Skip((pagination.PageNumber - 1) * pagination.PageSize).Take(pagination.PageSize);
diff --git a/服务API.Tools/API请求/HttpRequest.cs b/DataVAPI.Tools/API请求/HttpRequest.cs
similarity index 91%
rename from 服务API.Tools/API请求/HttpRequest.cs
rename to DataVAPI.Tools/API请求/HttpRequest.cs
index 02b1ae2..060d1cb 100644
--- a/服务API.Tools/API请求/HttpRequest.cs
+++ b/DataVAPI.Tools/API请求/HttpRequest.cs
@@ -6,7 +6,7 @@ using System.Net;
using System.Text;
using System.Threading.Tasks;
-namespace 服务API.Tool.API请求
+namespace DataVAPI.Tool.API请求
{
///
/// HTTP请求类
@@ -49,7 +49,7 @@ namespace 服务API.Tool.API请求
/// http请求方式:GET/POST
/// http请求附带数据
///
- public HttpWebRequest CreateHttpRequest(string url, string requestType, int _timeout = 5000,params object[] strjson)
+ public HttpWebRequest CreateHttpRequest(string url, string requestType, int _timeout = 5000, params object[] strjson)
{
HttpWebRequest request = null;
const string get = "GET";
@@ -82,7 +82,7 @@ namespace 服务API.Tool.API请求
if (encoding == null || encoding.Length < 1)
encoding = "UTF-8";
}
- using (StreamReader reader = new StreamReader(response.GetResponseStream(),Encoding.GetEncoding(encoding)))
+ using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(encoding)))
{
resultData = reader.ReadToEnd();
}
@@ -98,7 +98,7 @@ namespace 服务API.Tool.API请求
/// 请求结果
private static HttpWebRequest CreateGetHttpRequest(string url)
{
- var getrequest = HttpWebRequest.Create(url) as HttpWebRequest;
+ var getrequest = WebRequest.Create(url) as HttpWebRequest;
getrequest.Method = "GET";
getrequest.Timeout = Timeout;
getrequest.ContentType = "application/json;charset=UTF-8";
@@ -114,7 +114,7 @@ namespace 服务API.Tool.API请求
/// 请求结果
private static HttpWebRequest CreatePostHttpRequest(string url, string postData)
{
- var postrequest = HttpWebRequest.Create(url) as HttpWebRequest;
+ var postrequest = WebRequest.Create(url) as HttpWebRequest;
//postrequest.KeepAlive = false;
postrequest.Timeout = Timeout;
postrequest.Method = "POST";
@@ -133,16 +133,16 @@ namespace 服务API.Tool.API请求
return postrequest;
}
- public static HttpWebRequest CreateDeleteHttpRequest(string url,string postJson, int _timeout = 5000)
+ public static HttpWebRequest CreateDeleteHttpRequest(string url, string postJson, int _timeout = 5000)
{
- var deleteRequest = HttpWebRequest.Create(url) as HttpWebRequest;
+ var deleteRequest = WebRequest.Create(url) as HttpWebRequest;
deleteRequest.Timeout = _timeout;
deleteRequest.Method = "DELETE";
deleteRequest.ContentType = "application/json;charset=UTF-8";
byte[] data = Encoding.UTF8.GetBytes(postJson);
using (Stream reqStream = deleteRequest.GetRequestStream())
{
- reqStream.Write(data,0,data.Length);
+ reqStream.Write(data, 0, data.Length);
reqStream.Close();
}
return deleteRequest;
diff --git a/服务API.Tools/API请求/HttpRequestHelper.cs b/DataVAPI.Tools/API请求/HttpRequestHelper.cs
similarity index 95%
rename from 服务API.Tools/API请求/HttpRequestHelper.cs
rename to DataVAPI.Tools/API请求/HttpRequestHelper.cs
index d9ce41b..1785860 100644
--- a/服务API.Tools/API请求/HttpRequestHelper.cs
+++ b/DataVAPI.Tools/API请求/HttpRequestHelper.cs
@@ -6,7 +6,7 @@ using System.Net;
using System.Text;
using System.Threading.Tasks;
-namespace 服务API.Tool.API请求
+namespace DataVAPI.Tool.API请求
{
///
/// 该类实现客户端http 同步请求
@@ -106,7 +106,7 @@ namespace 服务API.Tool.API请求
///
public static string GetHttpGetResponseWithHead(string url, HttpRequestHeader head, string headInfo)
{
- HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
+ HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "GET";
request.ContentType = "application/json;charset=UTF-8";
request.Timeout = 6000;
@@ -156,12 +156,12 @@ namespace 服务API.Tool.API请求
///
///
///
- public static string HttpPostResponseWithHead(string url, HttpRequestHeader head,string headInfo,string postParam,int Timeout=6000)
+ public static string HttpPostResponseWithHead(string url, HttpRequestHeader head, string headInfo, string postParam, int Timeout = 6000)
{
string resultData = string.Empty;
try
{
- var postrequest = HttpWebRequest.Create(url) as HttpWebRequest;
+ var postrequest = WebRequest.Create(url) as HttpWebRequest;
postrequest.Timeout = Timeout;
postrequest.Method = "POST";
postrequest.ContentType = "application/json;charset=UTF-8";
diff --git a/服务API.Tools/API请求/HttpResponseStatusBase.cs b/DataVAPI.Tools/API请求/HttpResponseStatusBase.cs
similarity index 89%
rename from 服务API.Tools/API请求/HttpResponseStatusBase.cs
rename to DataVAPI.Tools/API请求/HttpResponseStatusBase.cs
index 4455f2e..f5944fc 100644
--- a/服务API.Tools/API请求/HttpResponseStatusBase.cs
+++ b/DataVAPI.Tools/API请求/HttpResponseStatusBase.cs
@@ -1,8 +1,7 @@
-
+using DataVAPI.Tool.IOT;
using System;
-using 服务API.Tool.IOT;
-namespace 服务API.Tool.API请求
+namespace DataVAPI.Tool.API请求
{
///
/// Http状态字段基类
@@ -53,28 +52,28 @@ namespace 服务API.Tool.API请求
public int icon { get; set; }
- public static JsonMsg OK(T obj,string msg = "接口名称",string mso = "调用接口成功")
+ public static JsonMsg OK(T obj, string msg = "接口名称", string mso = "调用接口成功")
{
string str = $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} 接口名称为“ {msg + "”调用成功,描述:" + mso + obj}";
ConsoleColor currentForeColor = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine(str);
Console.ForegroundColor = currentForeColor;
- return new JsonMsg() { code = 1,ms = mso,msg = "成功",obj = obj,icon = 1 };
+ return new JsonMsg() { code = 1, ms = mso, msg = "成功", obj = obj, icon = 1 };
}
- public static JsonMsg Error(T obj,string msg = "接口名称",string mso = "调用接口成功失败")
+ public static JsonMsg Error(T obj, string msg = "接口名称", string mso = "调用接口成功失败")
{
string str = $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} 接口名称为“ {msg + "”调用失败,描述:" + mso + obj}";
ConsoleColor currentForeColor = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(str);
Console.ForegroundColor = currentForeColor;
- return new JsonMsg() { code = 0,ms = mso,msg = "失败",obj = obj,icon = 1 };
+ return new JsonMsg() { code = 0, ms = mso, msg = "失败", obj = obj, icon = 1 };
}
}
- public class DeviceTable :BaseEntity
+ public class DeviceTable : BaseEntity
{
///
/// 阿里云设备key
@@ -106,7 +105,7 @@ namespace 服务API.Tool.API请求
///
/// 告警消息表
///
- public class AlarmTable :BaseEntity
+ public class AlarmTable : BaseEntity
{
///
/// 告警时间
@@ -128,7 +127,7 @@ namespace 服务API.Tool.API请求
/// IP 地址
///
public string IP { get; set; }
-
+
public AlarmTable()
{
IP = Tools.GetLocalIp();
@@ -138,7 +137,7 @@ namespace 服务API.Tool.API请求
///
/// 日志表
///
- public class LogTable :BaseEntity
+ public class LogTable : BaseEntity
{
///
/// 日志时间
diff --git a/服务API.Tools/服务API.Tool.csproj b/DataVAPI.Tools/DataVAPI.Tool.csproj
similarity index 100%
rename from 服务API.Tools/服务API.Tool.csproj
rename to DataVAPI.Tools/DataVAPI.Tool.csproj
diff --git a/服务API.Tools/Executer.cs b/DataVAPI.Tools/Executer.cs
similarity index 84%
rename from 服务API.Tools/Executer.cs
rename to DataVAPI.Tools/Executer.cs
index 53adcc8..06a6aa9 100644
--- a/服务API.Tools/Executer.cs
+++ b/DataVAPI.Tools/Executer.cs
@@ -5,22 +5,22 @@ using System.Linq;
using System.Threading;
-namespace 服务API.Tool
+namespace DataVAPI.Tool
{
///
/// 线程集中处理委托
///
///
public delegate void ActionKeyHandle(string action);
- public delegate void ThreadExceptionHandle(string action,Exception ex);
+ public delegate void ThreadExceptionHandle(string action, Exception ex);
public delegate void ThreadExitHandle(string action);
///
/// 执行器
///
- public class Executer :Singleton
+ public class Executer : Singleton
{
private System.Timers.Timer _timer4Monitor = new System.Timers.Timer(1000);
- private ConcurrentDictionary _actions = new ConcurrentDictionary();
+ private ConcurrentDictionary _actions = new ConcurrentDictionary();
private object _async = new object();
public event ThreadExceptionHandle OnThreadException;
public event ThreadExitHandle ThreadExit;
@@ -49,7 +49,7 @@ namespace 服务API.Tool
///
public List GetActionInfos()
{
- Monitor.TryEnter(_async,200);
+ Monitor.TryEnter(_async, 200);
var actionInfos = _actions.Values.ToList();
Monitor.Exit(_async);
return actionInfos;
@@ -62,7 +62,7 @@ namespace 服务API.Tool
///
public void Abort(string key)
{
- Monitor.TryEnter(_async,200);
+ Monitor.TryEnter(_async, 200);
if (_actions.ContainsKey(key))
{
try { _actions[key].Abort(); }
@@ -77,7 +77,7 @@ namespace 服务API.Tool
///
public bool ContainsKey(string key)
{
- Monitor.TryEnter(_async,200);
+ Monitor.TryEnter(_async, 200);
var item = _actions[key];
Monitor.Exit(_async);
if (null != item)
@@ -93,7 +93,7 @@ namespace 服务API.Tool
///
///
///
- public void Start(Action action,string name,bool isBackground = false,ThreadPriority priority = ThreadPriority.Normal)
+ public void Start(Action action, string name, bool isBackground = false, ThreadPriority priority = ThreadPriority.Normal)
{
Thread thread = new Thread(() =>
{
@@ -104,14 +104,14 @@ namespace 服务API.Tool
}
catch (Exception ex)
{
- OnThreadException?.Invoke(name,ex);
+ OnThreadException?.Invoke(name, ex);
}
});
thread.IsBackground = isBackground;
thread.Priority = priority;
thread.Name = name;
thread.Start();
- Monitor.TryEnter(_async,50);
+ Monitor.TryEnter(_async, 50);
if (_actions.ContainsKey(name))
{
try { _actions[name].Abort(); }
@@ -126,7 +126,7 @@ namespace 服务API.Tool
///
///
///
- public bool StartWhiteReturn(Func action,int timeout = 3)
+ public bool StartWhiteReturn(Func action, int timeout = 3)
{
DateTime beginTime = DateTime.Now;
bool doResult = false;
diff --git a/服务API.Tools/IOT/CommandModel.cs b/DataVAPI.Tools/IOT/CommandModel.cs
similarity index 86%
rename from 服务API.Tools/IOT/CommandModel.cs
rename to DataVAPI.Tools/IOT/CommandModel.cs
index ed3578e..b48fea5 100644
--- a/服务API.Tools/IOT/CommandModel.cs
+++ b/DataVAPI.Tools/IOT/CommandModel.cs
@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace 服务API.Tool.IOT
+namespace DataVAPI.Tool.IOT
{
///
/// 命令实体类
@@ -22,6 +22,6 @@ namespace 服务API.Tool.IOT
///
/// 命令变量:执行变量 key为属性或时间 value为值或者消息
///
- public Dictionary CommandValue { get; set; }
+ public Dictionary CommandValue { get; set; }
}
}
diff --git a/服务API.Tools/IOT/IOTDevModel.cs b/DataVAPI.Tools/IOT/IOTDevModel.cs
similarity index 91%
rename from 服务API.Tools/IOT/IOTDevModel.cs
rename to DataVAPI.Tools/IOT/IOTDevModel.cs
index 2f8e361..b118657 100644
--- a/服务API.Tools/IOT/IOTDevModel.cs
+++ b/DataVAPI.Tools/IOT/IOTDevModel.cs
@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace 服务API.Tool.IOT
+namespace DataVAPI.Tool.IOT
{
///
/// IOT Model
@@ -98,7 +98,7 @@ namespace 服务API.Tool.IOT
try
{
IotModel iotModel = new IotModel { @params = this };
- string json = Tools.JsonConvertTools>(iotModel);
+ string json = Tools.JsonConvertTools(iotModel);
return json;
}
catch (Exception ex)
@@ -115,7 +115,7 @@ namespace 服务API.Tool.IOT
{
try
{
- JBSX = Tools.JsonConvertTools(devSX);
+ JBSX = Tools.JsonConvertTools(devSX);
}
catch (Exception ex)
{
@@ -127,19 +127,20 @@ namespace 服务API.Tool.IOT
///
///
///
- public void SetJBSXStatus(DevSXBase sXBase,bool Status)
+ public void SetJBSXStatus(DevSXBase sXBase, bool Status)
{
try
{
if (sXBase == null) return;
- DevSX dev= Tools.JsonToObjectTools(JBSX);
- dev.data?.ForEach(x => {
+ DevSX dev = Tools.JsonToObjectTools(JBSX);
+ dev.data?.ForEach(x =>
+ {
if (x.SXMC == sXBase.SXMC && x.SXLX == sXBase.SXLX)
{
- x.SXStatus= Status;
+ x.SXStatus = Status;
}
});
- JBSX = Tools.JsonConvertTools(dev);
+ JBSX = Tools.JsonConvertTools(dev);
}
catch (Exception ex)
{
@@ -154,7 +155,7 @@ namespace 服务API.Tool.IOT
{
try
{
- KZSX = Tools.JsonConvertTools(devSX);
+ KZSX = Tools.JsonConvertTools(devSX);
}
catch (Exception ex)
{
@@ -172,13 +173,14 @@ namespace 服务API.Tool.IOT
{
if (sXBase == null) return;
DevSX dev = Tools.JsonToObjectTools(KZSX);
- dev.data?.ForEach(x => {
+ dev.data?.ForEach(x =>
+ {
if (x.SXMC == sXBase.SXMC && x.SXLX == sXBase.SXLX)
{
x.SXStatus = Status;
}
});
- KZSX = Tools.JsonConvertTools(dev);
+ KZSX = Tools.JsonConvertTools(dev);
}
catch (Exception ex)
{
@@ -196,7 +198,7 @@ namespace 服务API.Tool.IOT
///
/// 告警Model
///
- public class AlarmModel :DeviceBase
+ public class AlarmModel : DeviceBase
{
///
/// 告警程度:提示 一般 严重
@@ -207,9 +209,9 @@ namespace 服务API.Tool.IOT
set
{
_AlarmCD = value;
- if (_AlarmCD == "提示") DeviceColor = new ALYColor { r = 13,g = 254,b = 73,a = 1 };
- else if (_AlarmCD == "一般") DeviceColor = new ALYColor { r = 245,g = 216,b = 13,a = 1 };
- else if (_AlarmCD == "严重") DeviceColor = new ALYColor { r = 245,g = 13,b = 13,a = 1 };
+ if (_AlarmCD == "提示") DeviceColor = new ALYColor { r = 13, g = 254, b = 73, a = 1 };
+ else if (_AlarmCD == "一般") DeviceColor = new ALYColor { r = 245, g = 216, b = 13, a = 1 };
+ else if (_AlarmCD == "严重") DeviceColor = new ALYColor { r = 245, g = 13, b = 13, a = 1 };
}
}
private string _AlarmCD { get; set; }
diff --git a/服务API.Tools/IOT/IOTDevServer.cs b/DataVAPI.Tools/IOT/IOTDevServer.cs
similarity index 87%
rename from 服务API.Tools/IOT/IOTDevServer.cs
rename to DataVAPI.Tools/IOT/IOTDevServer.cs
index 18f762b..9018c7f 100644
--- a/服务API.Tools/IOT/IOTDevServer.cs
+++ b/DataVAPI.Tools/IOT/IOTDevServer.cs
@@ -1,4 +1,5 @@
+using DataVAPI.Tool.API请求;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
@@ -10,9 +11,8 @@ using System.Text;
using System.Threading;
using uPLibrary.Networking.M2Mqtt;
using uPLibrary.Networking.M2Mqtt.Messages;
-using 服务API.Tool.API请求;
-namespace 服务API.Tool.IOT
+namespace DataVAPI.Tool.IOT
{
///
/// add fengyoufu
@@ -36,7 +36,7 @@ namespace 服务API.Tool.IOT
///
/// 设备消息数据回调
///
- public static Action DevIOTAction { get; set; }
+ public static Action DevIOTAction { get; set; }
///
/// 重连事件
///
@@ -124,7 +124,7 @@ namespace 服务API.Tool.IOT
///
///
///
- public void Set(string _ProductKey,string _DeviceName,string _DeviceSecret,string _RegionId = "cn-shanghai")
+ public void Set(string _ProductKey, string _DeviceName, string _DeviceSecret, string _RegionId = "cn-shanghai")
{
ProductKey = _ProductKey;
DeviceName = _DeviceName;
@@ -146,7 +146,7 @@ namespace 服务API.Tool.IOT
/// 创建连接
///
///
- public bool CreateLinks(int ClientId,out DeviceTable device)
+ public bool CreateLinks(int ClientId, out DeviceTable device)
{
try
{
@@ -156,27 +156,27 @@ namespace 服务API.Tool.IOT
if (jsonMsg.obj != null)
{
device = jsonMsg.obj.FirstOrDefault();
- if(device==null)return false;
+ if (device == null) return false;
- Set(device.productkey,device.devicename,device.devicesecret);
+ Set(device.productkey, device.devicename, device.devicesecret);
IPHostEntry host = Dns.GetHostEntry(Dns.GetHostName());
string clientId = host.AddressList.FirstOrDefault(
- ip => ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork).ToString();
+ ip => ip.AddressFamily == AddressFamily.InterNetwork).ToString();
string t = Convert.ToString(DateTimeOffset.Now.ToUnixTimeMilliseconds());
string signmethod = "hmacmd5";
- Dictionary dict = new Dictionary();
- dict.Add("productKey",ProductKey);
- dict.Add("deviceName",DeviceName);
- dict.Add("clientId",clientId);
- dict.Add("timestamp",t);
+ Dictionary dict = new Dictionary();
+ dict.Add("productKey", ProductKey);
+ dict.Add("deviceName", DeviceName);
+ dict.Add("clientId", clientId);
+ dict.Add("timestamp", t);
mqttUserName = DeviceName + "&" + ProductKey;
- mqttPassword = IotSignUtils.sign(dict,DeviceSecret,signmethod);
+ mqttPassword = IotSignUtils.sign(dict, DeviceSecret, signmethod);
mqttClientId = clientId + "|securemode=3,signmethod=" + signmethod + ",timestamp=" + t + "|";
targetServer = ProductKey + ".iot-as-mqtt." + RegionId + ".aliyuncs.com";
- ConnectMqtt(targetServer,mqttClientId,mqttUserName,mqttPassword);
+ ConnectMqtt(targetServer, mqttClientId, mqttUserName, mqttPassword);
return true;
}
else
@@ -228,9 +228,9 @@ namespace 服务API.Tool.IOT
///
///
///
- public void IOT_Publish(string topic,string message)
+ public void IOT_Publish(string topic, string message)
{
- var id = client.Publish(topic,Encoding.UTF8.GetBytes(message));
+ var id = client.Publish(topic, Encoding.UTF8.GetBytes(message));
}
///
@@ -243,7 +243,7 @@ namespace 服务API.Tool.IOT
{
SubTopicList.Add(topic);
}
- client.Subscribe(new string[] { topic },new byte[] { 0 });
+ client.Subscribe(new string[] { topic }, new byte[] { 0 });
}
#endregion
@@ -255,11 +255,11 @@ namespace 服务API.Tool.IOT
///
///
///
- private void ConnectMqtt(string targetServer,string mqttClientId,string mqttUserName,string mqttPassword)
+ private void ConnectMqtt(string targetServer, string mqttClientId, string mqttUserName, string mqttPassword)
{
client = new MqttClient(targetServer);
client.ProtocolVersion = MqttProtocolVersion.Version_3_1_1;
- client.Connect(mqttClientId,mqttUserName,mqttPassword,false,60);
+ client.Connect(mqttClientId, mqttUserName, mqttPassword, false, 60);
client.MqttMsgPublishReceived += Client_MqttMsgPublishReceived;
client.ConnectionClosed += Client_ConnectionClosed;
}
@@ -269,7 +269,7 @@ namespace 服务API.Tool.IOT
///
///
///
- private static void Client_ConnectionClosed(object sender,EventArgs e)
+ private static void Client_ConnectionClosed(object sender, EventArgs e)
{
// 尝试重连
_TryContinueConnect();
@@ -280,13 +280,13 @@ namespace 服务API.Tool.IOT
///
///
///
- private static void Client_MqttMsgPublishReceived(object sender,MqttMsgPublishEventArgs e)
+ private static void Client_MqttMsgPublishReceived(object sender, MqttMsgPublishEventArgs e)
{
string topic = e.Topic;
string message = Encoding.UTF8.GetString(e.Message);
if (DevIOTAction != null)
{
- DevIOTAction.Invoke(topic,message);
+ DevIOTAction.Invoke(topic, message);
}
}
@@ -305,14 +305,14 @@ namespace 服务API.Tool.IOT
{
client = new MqttClient(targetServer);
client.ProtocolVersion = MqttProtocolVersion.Version_3_1_1;
- client.Connect(mqttClientId,mqttUserName,mqttPassword,false,60);
+ client.Connect(mqttClientId, mqttUserName, mqttPassword, false, 60);
client.MqttMsgPublishReceived += Client_MqttMsgPublishReceived;
client.ConnectionClosed += Client_ConnectionClosed;
if (client.IsConnected)
{
- IOTDevServer.SubTopicList.ForEach(par =>
+ SubTopicList.ForEach(par =>
{
- client.Subscribe(new string[] { par },new byte[] { 0 });
+ client.Subscribe(new string[] { par }, new byte[] { 0 });
});
}
Thread.Sleep(3000);
@@ -321,12 +321,12 @@ namespace 服务API.Tool.IOT
try
{
- client.Connect(mqttClientId,mqttUserName,mqttPassword,false,60);
+ client.Connect(mqttClientId, mqttUserName, mqttPassword, false, 60);
if (client.IsConnected)
{
- IOTDevServer.SubTopicList.ForEach(par =>
+ SubTopicList.ForEach(par =>
{
- client.Subscribe(new string[] { par },new byte[] { 0 });
+ client.Subscribe(new string[] { par }, new byte[] { 0 });
});
UNConnectMqtt?.Invoke("重新连接阿里云MQTT成功!");
}
@@ -353,8 +353,8 @@ namespace 服务API.Tool.IOT
///
public class IotSignUtils
{
- public static string sign(Dictionary param,
- string deviceSecret,string signMethod)
+ public static string sign(Dictionary param,
+ string deviceSecret, string signMethod)
{
string[] sortedKey = param.Keys.ToArray();
Array.Sort(sortedKey);
@@ -373,7 +373,7 @@ namespace 服务API.Tool.IOT
StringBuilder signBuilder = new StringBuilder();
foreach (byte b in hashBytes)
- signBuilder.AppendFormat("{0:x2}",b);
+ signBuilder.AppendFormat("{0:x2}", b);
return signBuilder.ToString();
}
@@ -415,10 +415,10 @@ namespace 服务API.Tool.IOT
///
public static long ConvertDateTimeToLong(DateTime dt)
{
- DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970,1,1));
+ DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
TimeSpan toNow = dt.Subtract(dtStart);
long timeStamp = toNow.Ticks;
- timeStamp = long.Parse(timeStamp.ToString().Substring(0,timeStamp.ToString().Length - 4));
+ timeStamp = long.Parse(timeStamp.ToString().Substring(0, timeStamp.ToString().Length - 4));
return timeStamp;
}
@@ -429,7 +429,7 @@ namespace 服务API.Tool.IOT
///
public static DateTime ConvertLongToDateTime(long d)
{
- DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970,1,1));
+ DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
long lTime = long.Parse(d + "0000");
TimeSpan toNow = new TimeSpan(lTime);
DateTime dtResult = dtStart.Add(toNow);
diff --git a/服务API.Tools/IOT/ScreenMonitorModel.cs b/DataVAPI.Tools/IOT/ScreenMonitorModel.cs
similarity index 95%
rename from 服务API.Tools/IOT/ScreenMonitorModel.cs
rename to DataVAPI.Tools/IOT/ScreenMonitorModel.cs
index 8e23455..21933f4 100644
--- a/服务API.Tools/IOT/ScreenMonitorModel.cs
+++ b/DataVAPI.Tools/IOT/ScreenMonitorModel.cs
@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace 服务API.Tool.IOT
+namespace DataVAPI.Tool.IOT
{
///
@@ -32,7 +32,7 @@ namespace 服务API.Tool.IOT
{
try
{
- return Tools.JsonConvertTools(this);
+ return Tools.JsonConvertTools(this);
}
catch (Exception ex)
{
@@ -121,7 +121,7 @@ namespace 服务API.Tool.IOT
}
}
-
+
///
/// 通知消息
///
@@ -165,8 +165,8 @@ namespace 服务API.Tool.IOT
set
{
_IsAlarm = value;
- if (_IsAlarm) AlarmColor = new ALYColor { r = 245,g = 13,b = 13,a = 1 };
- else AlarmColor = new ALYColor { r = 245,g = 13,b = 13,a =0 };
+ if (_IsAlarm) AlarmColor = new ALYColor { r = 245, g = 13, b = 13, a = 1 };
+ else AlarmColor = new ALYColor { r = 245, g = 13, b = 13, a = 0 };
}
}
private bool _IsAlarm { get; set; }
@@ -185,8 +185,8 @@ namespace 服务API.Tool.IOT
public DevStatus()
{
IsAlarm = false;
- AlarmColor = new ALYColor { r = 245,g = 13,b = 13,a = 0 };
- DeviceColor = new ALYColor { r = 249,g = 191,b = 0,a = 1 };
+ AlarmColor = new ALYColor { r = 245, g = 13, b = 13, a = 0 };
+ DeviceColor = new ALYColor { r = 249, g = 191, b = 0, a = 1 };
}
///
/// 设置属性
diff --git a/服务API.Tools/Singleton.cs b/DataVAPI.Tools/Singleton.cs
similarity index 97%
rename from 服务API.Tools/Singleton.cs
rename to DataVAPI.Tools/Singleton.cs
index 3600d7d..e689642 100644
--- a/服务API.Tools/Singleton.cs
+++ b/DataVAPI.Tools/Singleton.cs
@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace 服务API.Tool
+namespace DataVAPI.Tool
{
///
/// 单例对象基类
diff --git a/服务API.Tools/控制台显示/ConsoleHelper.cs b/DataVAPI.Tools/控制台显示/ConsoleHelper.cs
similarity index 67%
rename from 服务API.Tools/控制台显示/ConsoleHelper.cs
rename to DataVAPI.Tools/控制台显示/ConsoleHelper.cs
index b4c6374..c715dce 100644
--- a/服务API.Tools/控制台显示/ConsoleHelper.cs
+++ b/DataVAPI.Tools/控制台显示/ConsoleHelper.cs
@@ -4,14 +4,14 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace 服务API.Tool.控制台显示
+namespace DataVAPI.Tool.控制台显示
{
///
/// 控制台帮助类
///
public static class ConsoleHelper
{
- static void WriteColorLine(string str,ConsoleColor color)
+ static void WriteColorLine(string str, ConsoleColor color)
{
str = $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} {str}";
ConsoleColor currentForeColor = Console.ForegroundColor;
@@ -24,36 +24,36 @@ namespace 服务API.Tool.控制台显示
///
/// 待打印的字符串
/// 想要打印的颜色
- public static void WriteErrorLine(this string str,ConsoleColor color = ConsoleColor.Red)
+ public static void WriteErrorLine(this string str, ConsoleColor color = ConsoleColor.Red)
{
- WriteColorLine(str,color);
+ WriteColorLine(str, color);
}
///
/// 打印警告信息
///
/// 待打印的字符串
/// 想要打印的颜色
- public static void WriteWarningLine(this string str,ConsoleColor color = ConsoleColor.Yellow)
+ public static void WriteWarningLine(this string str, ConsoleColor color = ConsoleColor.Yellow)
{
- WriteColorLine(str,color);
+ WriteColorLine(str, color);
}
///
/// 打印正常信息
///
/// 待打印的字符串
/// 想要打印的颜色
- public static void WriteInfoLine(this string str,ConsoleColor color = ConsoleColor.Green)
+ public static void WriteInfoLine(this string str, ConsoleColor color = ConsoleColor.Green)
{
- WriteColorLine(str,color);
+ WriteColorLine(str, color);
}
///
/// 打印成功的信息
///
/// 待打印的字符串
/// 想要打印的颜色
- public static void WriteSuccessLine(this string str,ConsoleColor color = ConsoleColor.Magenta)
+ public static void WriteSuccessLine(this string str, ConsoleColor color = ConsoleColor.Magenta)
{
- WriteColorLine(str,color);
+ WriteColorLine(str, color);
}
}
}
diff --git a/DataVAPI.sln b/DataVAPI.sln
new file mode 100644
index 0000000..a5d5eb7
--- /dev/null
+++ b/DataVAPI.sln
@@ -0,0 +1,61 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.1.32210.238
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataVIOT.Help", "IOT.Help\DataVIOT.Help.csproj", "{302A05E0-4AA1-4655-AE4B-0826B2C55EB9}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataVAPI", "DataVAPI\DataVAPI.csproj", "{FC535CBE-E799-41DD-83B6-79DC9F400A46}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataVAPI.Model", "DataVAPI.Model\DataVAPI.Model.csproj", "{A5F32B66-9528-4DA7-84C1-0611BE65757F}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataVApi.Order", "DataVApi.Order\DataVApi.Order.csproj", "{43B0F1B2-E1AB-4714-B5CD-B3F9D5ECDCAB}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataVAPI.ProcessServices", "DataVAPI.ProcessServices\DataVAPI.ProcessServices.csproj", "{849D3E3C-1296-4383-8B51-D35737B92DFE}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataVAPI.ServerDB", "DataVAPI.ServerDB\DataVAPI.ServerDB.csproj", "{EA6E3A76-591F-4170-A3D7-B48A09E1C2ED}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataVAPI.Tool", "DataVAPI.Tools\DataVAPI.Tool.csproj", "{B8B324F6-068C-4E6B-820F-0447524F7760}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {302A05E0-4AA1-4655-AE4B-0826B2C55EB9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {302A05E0-4AA1-4655-AE4B-0826B2C55EB9}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {302A05E0-4AA1-4655-AE4B-0826B2C55EB9}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {302A05E0-4AA1-4655-AE4B-0826B2C55EB9}.Release|Any CPU.Build.0 = Release|Any CPU
+ {FC535CBE-E799-41DD-83B6-79DC9F400A46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {FC535CBE-E799-41DD-83B6-79DC9F400A46}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {FC535CBE-E799-41DD-83B6-79DC9F400A46}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {FC535CBE-E799-41DD-83B6-79DC9F400A46}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A5F32B66-9528-4DA7-84C1-0611BE65757F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A5F32B66-9528-4DA7-84C1-0611BE65757F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A5F32B66-9528-4DA7-84C1-0611BE65757F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A5F32B66-9528-4DA7-84C1-0611BE65757F}.Release|Any CPU.Build.0 = Release|Any CPU
+ {43B0F1B2-E1AB-4714-B5CD-B3F9D5ECDCAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {43B0F1B2-E1AB-4714-B5CD-B3F9D5ECDCAB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {43B0F1B2-E1AB-4714-B5CD-B3F9D5ECDCAB}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {43B0F1B2-E1AB-4714-B5CD-B3F9D5ECDCAB}.Release|Any CPU.Build.0 = Release|Any CPU
+ {849D3E3C-1296-4383-8B51-D35737B92DFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {849D3E3C-1296-4383-8B51-D35737B92DFE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {849D3E3C-1296-4383-8B51-D35737B92DFE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {849D3E3C-1296-4383-8B51-D35737B92DFE}.Release|Any CPU.Build.0 = Release|Any CPU
+ {EA6E3A76-591F-4170-A3D7-B48A09E1C2ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {EA6E3A76-591F-4170-A3D7-B48A09E1C2ED}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {EA6E3A76-591F-4170-A3D7-B48A09E1C2ED}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {EA6E3A76-591F-4170-A3D7-B48A09E1C2ED}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B8B324F6-068C-4E6B-820F-0447524F7760}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B8B324F6-068C-4E6B-820F-0447524F7760}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B8B324F6-068C-4E6B-820F-0447524F7760}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B8B324F6-068C-4E6B-820F-0447524F7760}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {5E3567E1-6440-428F-A2E2-A7CF6A1EF45A}
+ EndGlobalSection
+EndGlobal
diff --git a/服务API/.config/dotnet-tools.json b/DataVAPI/.config/dotnet-tools.json
similarity index 100%
rename from 服务API/.config/dotnet-tools.json
rename to DataVAPI/.config/dotnet-tools.json
diff --git a/服务API/AppConfig/AppConfigurtaionServices.cs b/DataVAPI/AppConfig/AppConfigurtaionServices.cs
similarity index 76%
rename from 服务API/AppConfig/AppConfigurtaionServices.cs
rename to DataVAPI/AppConfig/AppConfigurtaionServices.cs
index b655373..af00a0f 100644
--- a/服务API/AppConfig/AppConfigurtaionServices.cs
+++ b/DataVAPI/AppConfig/AppConfigurtaionServices.cs
@@ -2,7 +2,7 @@
using Microsoft.Extensions.Configuration.Json;
using System;
-namespace 服务API.AppConfig
+namespace DataVAPI.AppConfig
{
public class AppConfigurtaionServices
{
@@ -17,8 +17,8 @@ namespace 服务API.AppConfig
.Add(new JsonConfigurationSource { Path = "appsettings.json", ReloadOnChange = true })
.Build();
- DataBus.DataBus.connStr = AppConfigurtaionServices.Configuration.GetSection("mongoDB:connStr").Value;
- DataBus.DataBus.dbName = AppConfigurtaionServices.Configuration.GetSection("mongoDB:dbName").Value;
+ DataBus.connStr = Configuration.GetSection("mongoDB:connStr").Value;
+ DataBus.dbName = Configuration.GetSection("mongoDB:dbName").Value;
}
}
diff --git a/服务API/ConfigureSwagger/ConfigureSwagger.cs b/DataVAPI/ConfigureSwagger/ConfigureSwagger.cs
similarity index 97%
rename from 服务API/ConfigureSwagger/ConfigureSwagger.cs
rename to DataVAPI/ConfigureSwagger/ConfigureSwagger.cs
index 57d5d6d..b70e072 100644
--- a/服务API/ConfigureSwagger/ConfigureSwagger.cs
+++ b/DataVAPI/ConfigureSwagger/ConfigureSwagger.cs
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.OpenApi.Models;
-namespace 服务API.ConfigureSwagger
+namespace DataVAPI.ConfigureSwagger
{
public static class ConfigureSwagger
{
diff --git a/服务API/Controllers/AlarmController.cs b/DataVAPI/Controllers/AlarmController.cs
similarity index 69%
rename from 服务API/Controllers/AlarmController.cs
rename to DataVAPI/Controllers/AlarmController.cs
index 35988fb..b39b6a7 100644
--- a/服务API/Controllers/AlarmController.cs
+++ b/DataVAPI/Controllers/AlarmController.cs
@@ -1,19 +1,19 @@
-using Microsoft.AspNetCore.Mvc;
+using DataVAPI.Model;
+using DataVAPI.ServerDB.MongoDB;
+using DataVAPI.Tool.IOT;
+using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
-using 服务API.Model;
-using 服务API.ServerDB.MongoDB;
-using 服务API.Tool.IOT;
-namespace 服务API.Controllers
+namespace DataVAPI.Controllers
{
///
/// MG数据库:告警表 AlarmTable
///
- public class AlarmController :BaseController
+ public class AlarmController : BaseController
{
- MongoDbHelper mg = new MongoDbHelper(DataBus.DataBus.connStr,DataBus.DataBus.dbName);
- MongoDbHelper mgsb = new MongoDbHelper(DataBus.DataBus.connStr,DataBus.DataBus.dbName);
+ MongoDbHelper mg = new MongoDbHelper(DataBus.connStr, DataBus.dbName);
+ MongoDbHelper mgsb = new MongoDbHelper(DataBus.connStr, DataBus.dbName);
string st = System.Reflection.MethodBase.GetCurrentMethod().Name;
@@ -28,14 +28,14 @@ namespace 服务API.Controllers
{
if (string.IsNullOrEmpty(auth.ClientId))
{
- return JsonMsg.Error(null,st,"设备ID不能为空"); ;
+ return JsonMsg.Error(null, st, "设备ID不能为空"); ;
}
mg.Insert(auth);
- return JsonMsg.OK(auth,st);
+ return JsonMsg.OK(auth, st);
}
- catch (System.Exception ex)
+ catch (Exception ex)
{
- return JsonMsg.Error(null,st,ex.Message);
+ return JsonMsg.Error(null, st, ex.Message);
}
}
///
@@ -49,11 +49,11 @@ namespace 服务API.Controllers
try
{
mg.Inserts(auth);
- return JsonMsg>.OK(auth,st);
+ return JsonMsg>.OK(auth, st);
}
- catch (System.Exception ex)
+ catch (Exception ex)
{
- return JsonMsg>.Error(null,st,ex.Message);
+ return JsonMsg>.Error(null, st, ex.Message);
}
}
///
@@ -68,11 +68,11 @@ namespace 服务API.Controllers
try
{
mg.Update(auth);
- return JsonMsg.OK(auth,st);
+ return JsonMsg.OK(auth, st);
}
- catch (System.Exception ex)
+ catch (Exception ex)
{
- return JsonMsg.Error(null,st,ex.Message);
+ return JsonMsg.Error(null, st, ex.Message);
}
}
///
@@ -86,11 +86,11 @@ namespace 服务API.Controllers
st = System.Reflection.MethodBase.GetCurrentMethod().Name;
try
{
- return JsonMsg.OK(mg.QueryOne(id),st);
+ return JsonMsg.OK(mg.QueryOne(id), st);
}
- catch (System.Exception ex)
+ catch (Exception ex)
{
- return JsonMsg.Error(null,st,ex.Message);
+ return JsonMsg.Error(null, st, ex.Message);
}
}
///
@@ -104,11 +104,11 @@ namespace 服务API.Controllers
st = System.Reflection.MethodBase.GetCurrentMethod().Name;
try
{
- return JsonMsg>.OK(mg.QueryClientId(clientId),st);
+ return JsonMsg>.OK(mg.QueryClientId(clientId), st);
}
- catch (System.Exception ex)
+ catch (Exception ex)
{
- return JsonMsg>.Error(null,st,ex.Message);
+ return JsonMsg>.Error(null, st, ex.Message);
}
}
///
@@ -117,16 +117,16 @@ namespace 服务API.Controllers
///
///
[HttpGet]
- public JsonMsg> QueryDeviceId(string clientId,string deviceId)
+ public JsonMsg> QueryDeviceId(string clientId, string deviceId)
{
st = System.Reflection.MethodBase.GetCurrentMethod().Name;
try
{
- if(string.IsNullOrEmpty(clientId))
+ if (string.IsNullOrEmpty(clientId))
return JsonMsg>.Error(null, st, "客户端ID不能为空"); ;
- return JsonMsg>.OK(mg.QueryDeviceId(clientId,deviceId), st);
+ return JsonMsg>.OK(mg.QueryDeviceId(clientId, deviceId), st);
}
- catch (System.Exception ex)
+ catch (Exception ex)
{
return JsonMsg>.Error(null, st, ex.Message);
}
@@ -137,30 +137,30 @@ namespace 服务API.Controllers
///
///
[HttpGet]
- public JsonMsg> QueryDeviceName(string DeviceName,string StartTime,string StopTime)
+ public JsonMsg> QueryDeviceName(string DeviceName, string StartTime, string StopTime)
{
st = System.Reflection.MethodBase.GetCurrentMethod().Name;
try
{
- DeviceTable device= mgsb.QueryDeviceName(DeviceName);
+ DeviceTable device = mgsb.QueryDeviceName(DeviceName);
//ConsoleHelper.WriteSuccessLine(Tools.JsonConvertTools(device)+ " "+Time);
if (device != null)
{
if (!string.IsNullOrEmpty(StartTime) && !string.IsNullOrEmpty(StopTime))
{
- DateTime starttime,stoptime;
+ DateTime starttime, stoptime;
starttime = Tools.ConvertLongToDateTime(long.Parse(StartTime));
stoptime = Tools.ConvertLongToDateTime(long.Parse(StopTime));
- return JsonMsg>.OK(mg.QueryAllTime(device.ClientId,starttime,stoptime),st);
+ return JsonMsg>.OK(mg.QueryAllTime(device.ClientId, starttime, stoptime), st);
}
- else return JsonMsg>.OK(mg.QueryClientId(device.ClientId),st);
+ else return JsonMsg>.OK(mg.QueryClientId(device.ClientId), st);
}
- return JsonMsg>.OK(null,st);
+ return JsonMsg>.OK(null, st);
}
- catch (System.Exception ex)
+ catch (Exception ex)
{
- return JsonMsg>.Error(null,st,ex.Message);
+ return JsonMsg>.Error(null, st, ex.Message);
}
}
///
@@ -171,16 +171,16 @@ namespace 服务API.Controllers
///
///
[HttpGet]
- public JsonMsg> Query(string clientId,DateTime datesta,DateTime datastop)
+ public JsonMsg> Query(string clientId, DateTime datesta, DateTime datastop)
{
st = System.Reflection.MethodBase.GetCurrentMethod().Name;
try
{
- return JsonMsg>.OK(mg.QueryAllTime(clientId,datesta,datastop),st);
+ return JsonMsg>.OK(mg.QueryAllTime(clientId, datesta, datastop), st);
}
- catch (System.Exception ex)
+ catch (Exception ex)
{
- return JsonMsg>.Error(null,st,ex.Message);
+ return JsonMsg>.Error(null, st, ex.Message);
}
}
///
@@ -193,16 +193,16 @@ namespace 服务API.Controllers
/// 大小
///
[HttpGet]
- public JsonMsg> BasePagQuery(string clientId,DateTime datesta,DateTime datastop,int PageNumber=1,int PageSize=100)
+ public JsonMsg> BasePagQuery(string clientId, DateTime datesta, DateTime datastop, int PageNumber = 1, int PageSize = 100)
{
st = System.Reflection.MethodBase.GetCurrentMethod().Name;
try
{
- return JsonMsg>.OK(mg.BasePagQuery(clientId,datesta,datastop,PageNumber,PageSize),st);
+ return JsonMsg>.OK(mg.BasePagQuery(clientId, datesta, datastop, PageNumber, PageSize), st);
}
- catch (System.Exception ex)
+ catch (Exception ex)
{
- return JsonMsg>.Error(null,st,ex.Message);
+ return JsonMsg>.Error(null, st, ex.Message);
}
}
///
@@ -218,17 +218,17 @@ namespace 服务API.Controllers
{
if (string.IsNullOrEmpty(id))
{
- return JsonMsg.Error(null,st,"设备ID不能为空"); ;
+ return JsonMsg.Error(null, st, "设备ID不能为空"); ;
}
else
{
- mg.Modify(id,"State","n");
- return JsonMsg.OK("success!",st);
+ mg.Modify(id, "State", "n");
+ return JsonMsg.OK("success!", st);
}
}
- catch (System.Exception ex)
+ catch (Exception ex)
{
- return JsonMsg.Error(null,st,ex.Message);
+ return JsonMsg.Error(null, st, ex.Message);
}
}
///
@@ -244,17 +244,17 @@ namespace 服务API.Controllers
{
if (string.IsNullOrEmpty(id))
{
- return JsonMsg.Error(null,st,"设备ID不能为空"); ;
+ return JsonMsg.Error(null, st, "设备ID不能为空"); ;
}
else
{
mg.Delete(id);
- return JsonMsg.OK("success!",st);
+ return JsonMsg.OK("success!", st);
}
}
- catch (System.Exception ex)
+ catch (Exception ex)
{
- return JsonMsg.Error(null,st,ex.Message);
+ return JsonMsg.Error(null, st, ex.Message);
}
}
}
diff --git a/服务API/Controllers/BaseController.cs b/DataVAPI/Controllers/BaseController.cs
similarity index 90%
rename from 服务API/Controllers/BaseController.cs
rename to DataVAPI/Controllers/BaseController.cs
index 33816d1..b065442 100644
--- a/服务API/Controllers/BaseController.cs
+++ b/DataVAPI/Controllers/BaseController.cs
@@ -2,7 +2,7 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
-namespace 服务API.Controllers
+namespace DataVAPI.Controllers
{
///
/// 自定义路由 基类
diff --git a/服务API/Controllers/DeviceController.cs b/DataVAPI/Controllers/DeviceController.cs
similarity index 67%
rename from 服务API/Controllers/DeviceController.cs
rename to DataVAPI/Controllers/DeviceController.cs
index 3a8d6fd..8aa330c 100644
--- a/服务API/Controllers/DeviceController.cs
+++ b/DataVAPI/Controllers/DeviceController.cs
@@ -1,18 +1,16 @@
-using Microsoft.AspNetCore.Mvc;
+using DataVAPI.Model;
+using DataVAPI.ServerDB.MongoDB;
+using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
-using 服务API.AppConfig;
-using 服务API.Model;
-using 服务API.ServerDB.MongoDB;
-
-namespace 服务API.Controllers
+namespace DataVAPI.Controllers
{
///
/// MG数据库:设备信息表 DeviceTable
///
- public class DeviceController :BaseController
+ public class DeviceController : BaseController
{
- MongoDbHelper mg = new MongoDbHelper(DataBus.DataBus.connStr,DataBus.DataBus.dbName);
+ MongoDbHelper mg = new MongoDbHelper(DataBus.connStr, DataBus.dbName);
string st = System.Reflection.MethodBase.GetCurrentMethod().Name;
@@ -27,14 +25,14 @@ namespace 服务API.Controllers
{
if (string.IsNullOrEmpty(auth.ClientId))
{
- return JsonMsg.Error(null,st,"设备ID不能为空"); ;
+ return JsonMsg.Error(null, st, "设备ID不能为空"); ;
}
mg.Insert(auth);
- return JsonMsg.OK(auth,st);
+ return JsonMsg.OK(auth, st);
}
- catch (System.Exception ex)
+ catch (Exception ex)
{
- return JsonMsg.Error(null,st,ex.Message);
+ return JsonMsg.Error(null, st, ex.Message);
}
}
///
@@ -47,11 +45,11 @@ namespace 服务API.Controllers
try
{
mg.Inserts(auth);
- return JsonMsg>.OK(auth,st);
+ return JsonMsg>.OK(auth, st);
}
- catch (System.Exception ex)
+ catch (Exception ex)
{
- return JsonMsg>.Error(null,st,ex.Message);
+ return JsonMsg>.Error(null, st, ex.Message);
}
}
///
@@ -64,11 +62,11 @@ namespace 服务API.Controllers
try
{
mg.UpdateID(auth);
- return JsonMsg.OK(auth,st);
+ return JsonMsg.OK(auth, st);
}
- catch (System.Exception ex)
+ catch (Exception ex)
{
- return JsonMsg.Error(null,st,ex.Message);
+ return JsonMsg.Error(null, st, ex.Message);
}
}
///
@@ -81,11 +79,11 @@ namespace 服务API.Controllers
st = System.Reflection.MethodBase.GetCurrentMethod().Name;
try
{
- return JsonMsg.OK(mg.QueryOne(id),st);
+ return JsonMsg.OK(mg.QueryOne(id), st);
}
- catch (System.Exception ex)
+ catch (Exception ex)
{
- return JsonMsg.Error(null,st,ex.Message);
+ return JsonMsg.Error(null, st, ex.Message);
}
}
///
@@ -96,16 +94,16 @@ namespace 服务API.Controllers
/// 结束时间
///
[HttpGet]
- public JsonMsg> Query(string clientId,DateTime starttime,DateTime endtime)
+ public JsonMsg> Query(string clientId, DateTime starttime, DateTime endtime)
{
st = System.Reflection.MethodBase.GetCurrentMethod().Name;
try
{
- return JsonMsg>.OK(mg.QueryAllTime(clientId,starttime,endtime),st);
+ return JsonMsg>.OK(mg.QueryAllTime(clientId, starttime, endtime), st);
}
- catch (System.Exception ex)
+ catch (Exception ex)
{
- return JsonMsg>.Error(null,st,ex.Message);
+ return JsonMsg>.Error(null, st, ex.Message);
}
}
///
@@ -118,16 +116,16 @@ namespace 服务API.Controllers
/// 每页大小
///
[HttpGet]
- public JsonMsg> BasePagQuery(string clientId,DateTime starttime,DateTime endtime,int PageNumber = 1,int PageSize = 100)
+ public JsonMsg> BasePagQuery(string clientId, DateTime starttime, DateTime endtime, int PageNumber = 1, int PageSize = 100)
{
st = System.Reflection.MethodBase.GetCurrentMethod().Name;
try
{
- return JsonMsg>.OK(mg.BasePagQuery(clientId,starttime,endtime,PageNumber,PageSize),st);
+ return JsonMsg>.OK(mg.BasePagQuery(clientId, starttime, endtime, PageNumber, PageSize), st);
}
- catch (System.Exception ex)
+ catch (Exception ex)
{
- return JsonMsg>.Error(null,st,ex.Message);
+ return JsonMsg>.Error(null, st, ex.Message);
}
}
///
@@ -142,17 +140,17 @@ namespace 服务API.Controllers
{
if (string.IsNullOrEmpty(id))
{
- return JsonMsg.Error(null,st,"设备ID不能为空"); ;
+ return JsonMsg.Error(null, st, "设备ID不能为空"); ;
}
else
{
- mg.Modify(id,"State","n");
- return JsonMsg.OK("success!",st);
+ mg.Modify(id, "State", "n");
+ return JsonMsg.OK("success!", st);
}
}
- catch (System.Exception ex)
+ catch (Exception ex)
{
- return JsonMsg.Error(null,st,ex.Message);
+ return JsonMsg.Error(null, st, ex.Message);
}
}
///
@@ -167,17 +165,17 @@ namespace 服务API.Controllers
{
if (string.IsNullOrEmpty(id))
{
- return JsonMsg.Error(null,st,"设备ID不能为空"); ;
+ return JsonMsg.Error(null, st, "设备ID不能为空"); ;
}
else
{
mg.Delete(id);
- return JsonMsg.OK("success!",st);
+ return JsonMsg.OK("success!", st);
}
}
- catch (System.Exception ex)
+ catch (Exception ex)
{
- return JsonMsg.Error(null,st,ex.Message);
+ return JsonMsg.Error(null, st, ex.Message);
}
}
}
diff --git a/服务API/Controllers/LogController.cs b/DataVAPI/Controllers/LogController.cs
similarity index 70%
rename from 服务API/Controllers/LogController.cs
rename to DataVAPI/Controllers/LogController.cs
index 700b99d..8edc649 100644
--- a/服务API/Controllers/LogController.cs
+++ b/DataVAPI/Controllers/LogController.cs
@@ -1,20 +1,20 @@
-using Microsoft.AspNetCore.Mvc;
+using DataVAPI.Model;
+using DataVAPI.ServerDB.MongoDB;
+using DataVAPI.Tool.IOT;
+using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
-using 服务API.Model;
-using 服务API.ServerDB.MongoDB;
-using 服务API.Tool.IOT;
-namespace 服务API.Controllers
+namespace DataVAPI.Controllers
{
///
/// MG数据库:日志表 LogTable
///
- public class LogController :BaseController
+ public class LogController : BaseController
{
- MongoDbHelper mg = new MongoDbHelper(DataBus.DataBus.connStr,DataBus.DataBus.dbName);
- MongoDbHelper mgsb = new MongoDbHelper(DataBus.DataBus.connStr,DataBus.DataBus.dbName);
+ MongoDbHelper mg = new MongoDbHelper(DataBus.connStr, DataBus.dbName);
+ MongoDbHelper mgsb = new MongoDbHelper(DataBus.connStr, DataBus.dbName);
string st = System.Reflection.MethodBase.GetCurrentMethod().Name;
@@ -29,14 +29,14 @@ namespace 服务API.Controllers
{
if (string.IsNullOrEmpty(auth.ClientId))
{
- return JsonMsg.Error(null,st,"设备ID不能为空"); ;
+ return JsonMsg.Error(null, st, "设备ID不能为空"); ;
}
mg.Insert(auth);
- return JsonMsg.OK(auth,st);
+ return JsonMsg.OK(auth, st);
}
- catch (System.Exception ex)
+ catch (Exception ex)
{
- return JsonMsg.Error(null,st,ex.Message);
+ return JsonMsg.Error(null, st, ex.Message);
}
}
///
@@ -50,11 +50,11 @@ namespace 服务API.Controllers
try
{
mg.Inserts(auth);
- return JsonMsg>.OK(auth,st);
+ return JsonMsg>.OK(auth, st);
}
- catch (System.Exception ex)
+ catch (Exception ex)
{
- return JsonMsg>.Error(null,st,ex.Message);
+ return JsonMsg>.Error(null, st, ex.Message);
}
}
///
@@ -69,11 +69,11 @@ namespace 服务API.Controllers
try
{
mg.Update(auth);
- return JsonMsg.OK(auth,st);
+ return JsonMsg.OK(auth, st);
}
- catch (System.Exception ex)
+ catch (Exception ex)
{
- return JsonMsg.Error(null,st,ex.Message);
+ return JsonMsg.Error(null, st, ex.Message);
}
}
///
@@ -87,11 +87,11 @@ namespace 服务API.Controllers
st = System.Reflection.MethodBase.GetCurrentMethod().Name;
try
{
- return JsonMsg.OK(mg.QueryOne(id),st);
+ return JsonMsg.OK(mg.QueryOne(id), st);
}
- catch (System.Exception ex)
+ catch (Exception ex)
{
- return JsonMsg.Error(null,st,ex.Message);
+ return JsonMsg.Error(null, st, ex.Message);
}
}
///
@@ -105,11 +105,11 @@ namespace 服务API.Controllers
st = System.Reflection.MethodBase.GetCurrentMethod().Name;
try
{
- return JsonMsg>.OK(mg.QueryClientId(clientId),st);
+ return JsonMsg>.OK(mg.QueryClientId(clientId), st);
}
- catch (System.Exception ex)
+ catch (Exception ex)
{
- return JsonMsg>.Error(null,st,ex.Message);
+ return JsonMsg>.Error(null, st, ex.Message);
}
}
///
@@ -118,7 +118,7 @@ namespace 服务API.Controllers
///
///
[HttpGet]
- public JsonMsg> QueryDeviceName(string DeviceName,string StartTime,string StopTime)
+ public JsonMsg