@@ -1,16 +1,16 @@ | |||||
using System; | |||||
using DataVAPI.ServerDB.MongoDB; | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Linq; | using System.Linq; | ||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using 服务API.ServerDB.MongoDB; | |||||
namespace 服务API.Model | |||||
namespace DataVAPI.Model | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 告警消息表 | /// 告警消息表 | ||||
/// </summary> | /// </summary> | ||||
public class AlarmTable :BaseEntity | |||||
public class AlarmTable : BaseEntity | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 告警时间 | /// 告警时间 |
@@ -4,7 +4,7 @@ using System.Linq; | |||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
namespace 服务API.Model | |||||
namespace DataVAPI.Model | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 命令实体类 | /// 命令实体类 | ||||
@@ -22,6 +22,6 @@ namespace 服务API.Model | |||||
/// <summary> | /// <summary> | ||||
/// 命令变量:执行变量 key为属性或时间 value为值或者消息 | /// 命令变量:执行变量 key为属性或时间 value为值或者消息 | ||||
/// </summary> | /// </summary> | ||||
public Dictionary<string,string> CommandValue { get; set; } | |||||
public Dictionary<string, string> CommandValue { get; set; } | |||||
} | } | ||||
} | } |
@@ -7,7 +7,7 @@ | |||||
</PropertyGroup> | </PropertyGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<ProjectReference Include="..\服务API.ServerDB\服务API.ServerDB.csproj" /> | |||||
<ProjectReference Include="..\DataVAPI.ServerDB\DataVAPI.ServerDB.csproj" /> | |||||
</ItemGroup> | </ItemGroup> | ||||
</Project> | </Project> |
@@ -1,16 +1,16 @@ | |||||
using System; | |||||
using DataVAPI.ServerDB.MongoDB; | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Linq; | using System.Linq; | ||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using 服务API.ServerDB.MongoDB; | |||||
namespace 服务API.Model | |||||
namespace DataVAPI.Model | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 设备信息表 | /// 设备信息表 | ||||
/// </summary> | /// </summary> | ||||
public class DeviceTable :BaseEntity | |||||
public class DeviceTable : BaseEntity | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 阿里云设备key | /// 阿里云设备key |
@@ -4,7 +4,7 @@ using System.Linq; | |||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
namespace 服务API.Model | |||||
namespace DataVAPI.Model | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 返回消息 | /// 返回消息 | ||||
@@ -42,25 +42,25 @@ namespace 服务API.Model | |||||
public int icon { get; set; } | public int icon { get; set; } | ||||
public static JsonMsg<T> OK(T obj,string msg = "接口名称",string mso="调用接口成功") | |||||
public static JsonMsg<T> 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; | ConsoleColor currentForeColor = Console.ForegroundColor; | ||||
Console.ForegroundColor = ConsoleColor.Green; | Console.ForegroundColor = ConsoleColor.Green; | ||||
Console.WriteLine(str); | Console.WriteLine(str); | ||||
Console.ForegroundColor = currentForeColor; | Console.ForegroundColor = currentForeColor; | ||||
; | ; | ||||
return new JsonMsg<T>() { code = 1,ms= mso,msg = "成功",obj = obj,icon = 1,oTData = new IOTData<T> { data = obj } }; | |||||
return new JsonMsg<T>() { code = 1, ms = mso, msg = "成功", obj = obj, icon = 1, oTData = new IOTData<T> { data = obj } }; | |||||
} | } | ||||
public static JsonMsg<T> Error(T obj,string msg = "接口名称",string mso = "调用接口成功失败") | |||||
public static JsonMsg<T> 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; | ConsoleColor currentForeColor = Console.ForegroundColor; | ||||
Console.ForegroundColor = ConsoleColor.Red; | Console.ForegroundColor = ConsoleColor.Red; | ||||
Console.WriteLine(str); | Console.WriteLine(str); | ||||
Console.ForegroundColor = currentForeColor; | Console.ForegroundColor = currentForeColor; | ||||
return new JsonMsg<T>() { code = 0,ms = mso,msg = "失败",obj = obj,icon = 1,oTData = new IOTData<T> { data = obj } }; | |||||
return new JsonMsg<T>() { code = 0, ms = mso, msg = "失败", obj = obj, icon = 1, oTData = new IOTData<T> { data = obj } }; | |||||
} | } | ||||
} | } | ||||
@@ -1,16 +1,16 @@ | |||||
using System; | |||||
using DataVAPI.ServerDB.MongoDB; | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Linq; | using System.Linq; | ||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using 服务API.ServerDB.MongoDB; | |||||
namespace 服务API.Model | |||||
namespace DataVAPI.Model | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 大屏消息表 | /// 大屏消息表 | ||||
/// </summary> | /// </summary> | ||||
public class LargeScreenTable :BaseEntity | |||||
public class LargeScreenTable : BaseEntity | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// Json值 | /// Json值 |
@@ -1,16 +1,16 @@ | |||||
using System; | |||||
using DataVAPI.ServerDB.MongoDB; | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Linq; | using System.Linq; | ||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using 服务API.ServerDB.MongoDB; | |||||
namespace 服务API.Model | |||||
namespace DataVAPI.Model | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 日志表 | /// 日志表 | ||||
/// </summary> | /// </summary> | ||||
public class LogTable :BaseEntity | |||||
public class LogTable : BaseEntity | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 日志时间 | /// 日志时间 |
@@ -2,7 +2,7 @@ | |||||
using Microsoft.Extensions.Configuration.Json; | using Microsoft.Extensions.Configuration.Json; | ||||
using System; | using System; | ||||
namespace 服务API.ProcessServices | |||||
namespace DataVAPI.ProcessServices.AppConfig | |||||
{ | { | ||||
public class AppConfigurtaionServices | public class AppConfigurtaionServices | ||||
{ | { |
@@ -3,7 +3,7 @@ | |||||
<PropertyGroup> | <PropertyGroup> | ||||
<TargetFramework>net6.0</TargetFramework> | <TargetFramework>net6.0</TargetFramework> | ||||
<OutputType>Exe</OutputType> | <OutputType>Exe</OutputType> | ||||
<StartupObject>服务API.ProcessServices.Program</StartupObject> | |||||
<StartupObject>DataVAPI.ProcessServices.Program</StartupObject> | |||||
</PropertyGroup> | </PropertyGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
@@ -13,7 +13,7 @@ | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<ProjectReference Include="..\服务API.Tools\服务API.Tool.csproj" /> | |||||
<ProjectReference Include="..\DataVAPI.Tools\DataVAPI.Tool.csproj" /> | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> |
@@ -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 | internal class Program | ||||
{ | { |
@@ -8,9 +8,9 @@ using System.Linq; | |||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
namespace 服务API.ProcessServices.文件存储 | |||||
namespace DataVAPI.ProcessServices.文件存储 | |||||
{ | { | ||||
public class SqlContext<T> :DbContext where T : DataVModel, new() | |||||
public class SqlContext<T> : DbContext where T : DataVModel, new() | |||||
{ | { | ||||
public static SqlContext<T> Base = new(); | public static SqlContext<T> Base = new(); | ||||
@@ -23,7 +23,7 @@ namespace 服务API.ProcessServices.文件存储 | |||||
{ | { | ||||
get | 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"; | return $"{AppDomain.CurrentDomain.BaseDirectory}AccessFile\\{typeof(T).Name}.db"; | ||||
} | } | ||||
} | } |
@@ -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.Collections.Generic; | ||||
using System.Linq; | using System.Linq; | ||||
using System.Threading; | 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 | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 老服务代码 | /// 老服务代码 | ||||
@@ -68,7 +69,7 @@ namespace 服务API.ProcessServices.阿里云处理流程One | |||||
//MQTT 数据接收处理 | //MQTT 数据接收处理 | ||||
ConsoleHelper.WriteInfoLine("尝试连接阿里云."); | ConsoleHelper.WriteInfoLine("尝试连接阿里云."); | ||||
IOTDevServer.GetInstance().SetUrl(APIurl); | IOTDevServer.GetInstance().SetUrl(APIurl); | ||||
if (IOTDevServer.GetInstance().CreateLinks(0,out device)) | |||||
if (IOTDevServer.GetInstance().CreateLinks(0, out device)) | |||||
{ | { | ||||
ConsoleHelper.WriteSuccessLine("连接阿里云成功!"); | ConsoleHelper.WriteSuccessLine("连接阿里云成功!"); | ||||
} | } | ||||
@@ -183,7 +184,7 @@ namespace 服务API.ProcessServices.阿里云处理流程One | |||||
if (receiveModel?.deviceContext != null && receiveModel?.status != null)//状态变更消息 | if (receiveModel?.deviceContext != null && receiveModel?.status != null)//状态变更消息 | ||||
{ | { | ||||
devModel?.operatingDeviceStatus.data?.Find(par => par.deviceName == receiveModel.deviceContext.deviceName)?.SetStatus(receiveModel.status.value); | 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); | DevStatus dev = devModel?.operatingDeviceStatus.data?.Find(par => par.deviceName == receiveModel.deviceContext.deviceName); | ||||
if (dev != null) | if (dev != null) | ||||
@@ -191,11 +192,11 @@ namespace 服务API.ProcessServices.阿里云处理流程One | |||||
ApiAddLog(Tools.JsonConvertTools(new LogTable | ApiAddLog(Tools.JsonConvertTools(new LogTable | ||||
{ | { | ||||
devicename = receiveModel.deviceContext.deviceName, | 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默认值 | #region 1.设置data默认值 | ||||
if (screen1Monitor.operatingDeviceStatus.data.Count == 0) | 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) | 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 | #endregion | ||||
@@ -217,7 +218,7 @@ namespace 服务API.ProcessServices.阿里云处理流程One | |||||
if (!string.IsNullOrEmpty(JSON)) | if (!string.IsNullOrEmpty(JSON)) | ||||
{ | { | ||||
AddScreenCreateOrUpdate(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) | if (devModel.infoMessage.data != null && devModel.infoMessage.data.Count > 0) | ||||
@@ -268,7 +269,7 @@ namespace 服务API.ProcessServices.阿里云处理流程One | |||||
} | } | ||||
} | } | ||||
}),"队列任务执行"); | |||||
}), "队列任务执行"); | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -276,7 +277,7 @@ namespace 服务API.ProcessServices.阿里云处理流程One | |||||
/// </summary> | /// </summary> | ||||
/// <param name="topic"></param> | /// <param name="topic"></param> | ||||
/// <param name="message"></param> | /// <param name="message"></param> | ||||
private void DevIOTActionHandler(string topic,string message) | |||||
private void DevIOTActionHandler(string topic, string message) | |||||
{ | { | ||||
if (string.IsNullOrEmpty(topic)) return; | if (string.IsNullOrEmpty(topic)) return; | ||||
@@ -297,7 +298,7 @@ namespace 服务API.ProcessServices.阿里云处理流程One | |||||
} | } | ||||
else if (topic == IOTDevServer.HeartbeatSubTopic)//上下线订阅主题 | else if (topic == IOTDevServer.HeartbeatSubTopic)//上下线订阅主题 | ||||
{ | { | ||||
ReceiveModel receiveModel =Tools.JsonToObjectTools<ReceiveModel>(message); | |||||
ReceiveModel receiveModel = Tools.JsonToObjectTools<ReceiveModel>(message); | |||||
if (receiveModel != null && receiveModel.status != null)//上下线通知 | if (receiveModel != null && receiveModel.status != null)//上下线通知 | ||||
{ | { | ||||
if (receiveModel.deviceContext.deviceName == "hbldev") return; | if (receiveModel.deviceContext.deviceName == "hbldev") return; | ||||
@@ -328,7 +329,7 @@ namespace 服务API.ProcessServices.阿里云处理流程One | |||||
{ | { | ||||
///api/Screen/CreateOrUpdate | ///api/Screen/CreateOrUpdate | ||||
string url = APIurl + "/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) | catch (Exception ex) | ||||
{ | { | ||||
@@ -374,7 +375,7 @@ namespace 服务API.ProcessServices.阿里云处理流程One | |||||
al.devicename = devModel?.operatingDeviceStatus.data?.Find(par => par.clientId == al.ClientId)?.deviceName; | al.devicename = devModel?.operatingDeviceStatus.data?.Find(par => par.clientId == al.ClientId)?.deviceName; | ||||
} | } | ||||
string url = APIurl + "/api/Alarm/Create"; | 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; | lo.devicename = devModel?.operatingDeviceStatus.data?.Find(par => par.clientId == lo.ClientId)?.deviceName; | ||||
} | } | ||||
string url = APIurl + "/api/Log/Create"; | string url = APIurl + "/api/Log/Create"; | ||||
HttpRequestHelper.HttpPostRequest(url,Tools.JsonConvertTools(lo)); | |||||
HttpRequestHelper.HttpPostRequest(url, Tools.JsonConvertTools(lo)); | |||||
} | } | ||||
} | } | ||||
catch (Exception ex) | catch (Exception ex) |
@@ -10,7 +10,7 @@ using System.Reflection; | |||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
namespace 服务API.ServerDB.MongoDB | |||||
namespace DataVAPI.ServerDB.MongoDB | |||||
{ | { | ||||
public class Db | public class Db | ||||
{ | { | ||||
@@ -24,7 +24,7 @@ namespace 服务API.ServerDB.MongoDB | |||||
private Db() { } | private Db() { } | ||||
public static IMongoDatabase GetDb(string conn,string dbna) | |||||
public static IMongoDatabase GetDb(string conn, string dbna) | |||||
{ | { | ||||
if (db == null) | if (db == null) | ||||
{ | { | ||||
@@ -47,16 +47,16 @@ namespace 服务API.ServerDB.MongoDB | |||||
private IMongoCollection<T> collection = null; | private IMongoCollection<T> 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<T>(typeof(T).Name); | collection = db.GetCollection<T>(typeof(T).Name); | ||||
} | } | ||||
public T Insert(T entity) | public T Insert(T entity) | ||||
{ | { | ||||
var flag = ObjectId.GenerateNewId(); | var flag = ObjectId.GenerateNewId(); | ||||
entity.GetType().GetProperty("Id").SetValue(entity,flag); | |||||
entity.GetType().GetProperty("Id").SetValue(entity, flag); | |||||
entity.State = "y"; | entity.State = "y"; | ||||
entity.CreateTime = DateTime.Now;//.ToString("yyyy-MM-dd HH:mm:ss"); | entity.CreateTime = DateTime.Now;//.ToString("yyyy-MM-dd HH:mm:ss"); | ||||
entity.UpdateTime = 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<T> Inserts(List<T> entity) | public List<T> Inserts(List<T> entity) | ||||
{ | { | ||||
entity?.ForEach(par => | |||||
entity?.ForEach(par => | |||||
{ | { | ||||
var flag = ObjectId.GenerateNewId(); | var flag = ObjectId.GenerateNewId(); | ||||
par.GetType().GetProperty("Id").SetValue(par,flag); | |||||
par.GetType().GetProperty("Id").SetValue(par, flag); | |||||
par.State = "y"; | par.State = "y"; | ||||
par.CreateTime = DateTime.Now; | par.CreateTime = DateTime.Now; | ||||
par.UpdateTime = DateTime.Now; | par.UpdateTime = DateTime.Now; | ||||
@@ -78,11 +78,11 @@ namespace 服务API.ServerDB.MongoDB | |||||
return entity; | return entity; | ||||
} | } | ||||
public void Modify(string id,string field,string value) | |||||
public void Modify(string id, string field, string value) | |||||
{ | { | ||||
var filter = Builders<T>.Filter.Eq("Id",ObjectId.Parse(id)); | |||||
var updated = Builders<T>.Update.Set(field,value); | |||||
UpdateResult result = collection.UpdateOneAsync(filter,updated).Result; | |||||
var filter = Builders<T>.Filter.Eq("Id", ObjectId.Parse(id)); | |||||
var updated = Builders<T>.Update.Set(field, value); | |||||
UpdateResult result = collection.UpdateOneAsync(filter, updated).Result; | |||||
} | } | ||||
public void Update(T entity) | public void Update(T entity) | ||||
@@ -97,15 +97,15 @@ namespace 服务API.ServerDB.MongoDB | |||||
{ | { | ||||
if (!newValue.ToString().Equals(oldValue.ToString())) | 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.State = "y"; | ||||
old.UpdateTime = DateTime.Now;//.ToString("yyyy-MM-dd HH:mm:ss"); | old.UpdateTime = DateTime.Now;//.ToString("yyyy-MM-dd HH:mm:ss"); | ||||
var filter = Builders<T>.Filter.Eq("Id",entity.Id); | |||||
ReplaceOneResult result = collection.ReplaceOneAsync(filter,old).Result; | |||||
var filter = Builders<T>.Filter.Eq("Id", entity.Id); | |||||
ReplaceOneResult result = collection.ReplaceOneAsync(filter, old).Result; | |||||
} | } | ||||
@@ -119,14 +119,14 @@ namespace 服务API.ServerDB.MongoDB | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
var Type =prop.PropertyType.Name; | |||||
var Type = prop.PropertyType.Name; | |||||
var newValue = prop.GetValue(entity); | var newValue = prop.GetValue(entity); | ||||
var oldValue = old.GetType().GetProperty(prop.Name).GetValue(old); | var oldValue = old.GetType().GetProperty(prop.Name).GetValue(old); | ||||
if (newValue != null) | if (newValue != null) | ||||
{ | { | ||||
if (!newValue.ToString().Equals(oldValue.ToString())) | 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) | //if (Type == typeof(DateTime).Name) | ||||
} | } | ||||
} | } | ||||
@@ -140,19 +140,19 @@ namespace 服务API.ServerDB.MongoDB | |||||
old.State = "y"; | old.State = "y"; | ||||
old.UpdateTime = DateTime.Now;//.ToString("yyyy-MM-dd HH:mm:ss"); | old.UpdateTime = DateTime.Now;//.ToString("yyyy-MM-dd HH:mm:ss"); | ||||
var filter = Builders<T>.Filter.Eq("IdStr",entity.IdStr); | |||||
ReplaceOneResult result = collection.ReplaceOneAsync(filter,old).Result; | |||||
var filter = Builders<T>.Filter.Eq("IdStr", entity.IdStr); | |||||
ReplaceOneResult result = collection.ReplaceOneAsync(filter, old).Result; | |||||
} | } | ||||
public void Delete(T entity) | public void Delete(T entity) | ||||
{ | { | ||||
var filter = Builders<T>.Filter.Eq("Id",entity.Id); | |||||
var filter = Builders<T>.Filter.Eq("Id", entity.Id); | |||||
collection.DeleteOneAsync(filter); | collection.DeleteOneAsync(filter); | ||||
} | } | ||||
public void Delete(string id) | public void Delete(string id) | ||||
{ | { | ||||
var filter = Builders<T>.Filter.Eq("Id",ObjectId.Parse(id)); | |||||
var filter = Builders<T>.Filter.Eq("Id", ObjectId.Parse(id)); | |||||
collection.DeleteOneAsync(filter); | collection.DeleteOneAsync(filter); | ||||
} | } | ||||
@@ -161,27 +161,28 @@ namespace 服务API.ServerDB.MongoDB | |||||
return collection.Find(a => a.Id == ObjectId.Parse(id))?.ToList().FirstOrDefault(); | return collection.Find(a => a.Id == ObjectId.Parse(id))?.ToList().FirstOrDefault(); | ||||
} | } | ||||
public List<T> QueryAllTime(string clientId,DateTime datesta ,DateTime datastop ) | |||||
public List<T> QueryAllTime(string clientId, DateTime datesta, DateTime datastop) | |||||
{ | { | ||||
if (string.IsNullOrEmpty(clientId)) | if (string.IsNullOrEmpty(clientId)) | ||||
{ | { | ||||
if (datastop >= datesta && datastop > DateTime.Parse("2011-10-11 00:00:00")) | 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 | 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")) | 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 | 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<T> QueryClientId(string clientId) | public List<T> 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<T> QueryDeviceId(string clientId, string deviceId) | public List<T> 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<T> QueryAll() | public List<T> QueryAll() | ||||
@@ -206,7 +207,7 @@ namespace 服务API.ServerDB.MongoDB | |||||
return collection.Find(a => a.State.Equals("y"))?.ToList(); | return collection.Find(a => a.State.Equals("y"))?.ToList(); | ||||
} | } | ||||
public PaginationListModel<T> BasePagQuery(string chid,DateTime datesta,DateTime datastop,int PageNumber,int PageSize) | |||||
public PaginationListModel<T> BasePagQuery(string chid, DateTime datesta, DateTime datastop, int PageNumber, int PageSize) | |||||
{ | { | ||||
BasePaginationModel pagination = new BasePaginationModel() | BasePaginationModel pagination = new BasePaginationModel() | ||||
{ | { | ||||
@@ -214,14 +215,14 @@ namespace 服务API.ServerDB.MongoDB | |||||
PageSize = PageSize | PageSize = PageSize | ||||
}; | }; | ||||
var RT = GetPagination(chid,datesta,datastop, ref pagination); | |||||
var RT = GetPagination(chid, datesta, datastop, ref pagination); | |||||
return RT; | return RT; | ||||
} | } | ||||
public PaginationListModel<T> GetPagination(string chid,DateTime datesta,DateTime datastop,ref BasePaginationModel Pagination) | |||||
public PaginationListModel<T> GetPagination(string chid, DateTime datesta, DateTime datastop, ref BasePaginationModel Pagination) | |||||
{ | { | ||||
var mongorResult = collection.AsQueryable<T>().Where(A => !string.IsNullOrEmpty(A.ClientId) && A.ClientId==chid && A.CreateTime>=datesta && A.CreateTime<=datastop).OrderByDescending(item => item.CreateTime); | |||||
var result = MongoPaginationService.BasePager<T>(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<T> M = new PaginationListModel<T>() | PaginationListModel<T> M = new PaginationListModel<T>() | ||||
{ | { | ||||
Data = result?.ToList(), | Data = result?.ToList(), | ||||
@@ -247,7 +248,7 @@ namespace 服务API.ServerDB.MongoDB | |||||
} | } | ||||
set | set | ||||
{ | { | ||||
_ID= value; | |||||
_ID = value; | |||||
IdStr = _ID.ToString(); | IdStr = _ID.ToString(); | ||||
} | } | ||||
} | } | ||||
@@ -294,7 +295,7 @@ namespace 服务API.ServerDB.MongoDB | |||||
/// <param name="json"></param> | /// <param name="json"></param> | ||||
/// <param name="pagination"></param> | /// <param name="pagination"></param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
public static IQueryable<T> BasePager<T>(this IOrderedQueryable<T> entitys,ref BasePaginationModel pagination) | |||||
public static IQueryable<T> BasePager<T>(this IOrderedQueryable<T> entitys, ref BasePaginationModel pagination) | |||||
{ | { | ||||
if (pagination != null) | if (pagination != null) | ||||
{ | { | ||||
@@ -311,7 +312,7 @@ namespace 服务API.ServerDB.MongoDB | |||||
/// <param name="source">数据源IQueryable</param> | /// <param name="source">数据源IQueryable</param> | ||||
/// <param name="pagination">分页参数</param> | /// <param name="pagination">分页参数</param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
private static IQueryable<T> GetBasePagination<T>(this IOrderedQueryable<T> source,BasePaginationModel pagination) | |||||
private static IQueryable<T> GetBasePagination<T>(this IOrderedQueryable<T> source, BasePaginationModel pagination) | |||||
{ | { | ||||
pagination.Total = source.Count(); | pagination.Total = source.Count(); | ||||
return source.Skip((pagination.PageNumber - 1) * pagination.PageSize).Take(pagination.PageSize); | return source.Skip((pagination.PageNumber - 1) * pagination.PageSize).Take(pagination.PageSize); |
@@ -6,7 +6,7 @@ using System.Net; | |||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
namespace 服务API.Tool.API请求 | |||||
namespace DataVAPI.Tool.API请求 | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// HTTP请求类 | /// HTTP请求类 | ||||
@@ -49,7 +49,7 @@ namespace 服务API.Tool.API请求 | |||||
/// <param name="requestType">http请求方式:GET/POST</param> | /// <param name="requestType">http请求方式:GET/POST</param> | ||||
/// <param name="strjson">http请求附带数据</param> | /// <param name="strjson">http请求附带数据</param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
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; | HttpWebRequest request = null; | ||||
const string get = "GET"; | const string get = "GET"; | ||||
@@ -82,7 +82,7 @@ namespace 服务API.Tool.API请求 | |||||
if (encoding == null || encoding.Length < 1) | if (encoding == null || encoding.Length < 1) | ||||
encoding = "UTF-8"; | 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(); | resultData = reader.ReadToEnd(); | ||||
} | } | ||||
@@ -98,7 +98,7 @@ namespace 服务API.Tool.API请求 | |||||
/// <returns>请求结果</returns> | /// <returns>请求结果</returns> | ||||
private static HttpWebRequest CreateGetHttpRequest(string url) | private static HttpWebRequest CreateGetHttpRequest(string url) | ||||
{ | { | ||||
var getrequest = HttpWebRequest.Create(url) as HttpWebRequest; | |||||
var getrequest = WebRequest.Create(url) as HttpWebRequest; | |||||
getrequest.Method = "GET"; | getrequest.Method = "GET"; | ||||
getrequest.Timeout = Timeout; | getrequest.Timeout = Timeout; | ||||
getrequest.ContentType = "application/json;charset=UTF-8"; | getrequest.ContentType = "application/json;charset=UTF-8"; | ||||
@@ -114,7 +114,7 @@ namespace 服务API.Tool.API请求 | |||||
/// <returns>请求结果</returns> | /// <returns>请求结果</returns> | ||||
private static HttpWebRequest CreatePostHttpRequest(string url, string postData) | 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.KeepAlive = false; | ||||
postrequest.Timeout = Timeout; | postrequest.Timeout = Timeout; | ||||
postrequest.Method = "POST"; | postrequest.Method = "POST"; | ||||
@@ -133,16 +133,16 @@ namespace 服务API.Tool.API请求 | |||||
return postrequest; | 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.Timeout = _timeout; | ||||
deleteRequest.Method = "DELETE"; | deleteRequest.Method = "DELETE"; | ||||
deleteRequest.ContentType = "application/json;charset=UTF-8"; | deleteRequest.ContentType = "application/json;charset=UTF-8"; | ||||
byte[] data = Encoding.UTF8.GetBytes(postJson); | byte[] data = Encoding.UTF8.GetBytes(postJson); | ||||
using (Stream reqStream = deleteRequest.GetRequestStream()) | using (Stream reqStream = deleteRequest.GetRequestStream()) | ||||
{ | { | ||||
reqStream.Write(data,0,data.Length); | |||||
reqStream.Write(data, 0, data.Length); | |||||
reqStream.Close(); | reqStream.Close(); | ||||
} | } | ||||
return deleteRequest; | return deleteRequest; |
@@ -6,7 +6,7 @@ using System.Net; | |||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
namespace 服务API.Tool.API请求 | |||||
namespace DataVAPI.Tool.API请求 | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 该类实现客户端http 同步请求 | /// 该类实现客户端http 同步请求 | ||||
@@ -106,7 +106,7 @@ namespace 服务API.Tool.API请求 | |||||
/// <returns></returns> | /// <returns></returns> | ||||
public static string GetHttpGetResponseWithHead(string url, HttpRequestHeader head, string headInfo) | 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.Method = "GET"; | ||||
request.ContentType = "application/json;charset=UTF-8"; | request.ContentType = "application/json;charset=UTF-8"; | ||||
request.Timeout = 6000; | request.Timeout = 6000; | ||||
@@ -156,12 +156,12 @@ namespace 服务API.Tool.API请求 | |||||
/// <param name="headInfo"></param> | /// <param name="headInfo"></param> | ||||
/// <param name="postParam"></param> | /// <param name="postParam"></param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
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; | string resultData = string.Empty; | ||||
try | try | ||||
{ | { | ||||
var postrequest = HttpWebRequest.Create(url) as HttpWebRequest; | |||||
var postrequest = WebRequest.Create(url) as HttpWebRequest; | |||||
postrequest.Timeout = Timeout; | postrequest.Timeout = Timeout; | ||||
postrequest.Method = "POST"; | postrequest.Method = "POST"; | ||||
postrequest.ContentType = "application/json;charset=UTF-8"; | postrequest.ContentType = "application/json;charset=UTF-8"; |
@@ -1,8 +1,7 @@ | |||||
| |||||
using DataVAPI.Tool.IOT; | |||||
using System; | using System; | ||||
using 服务API.Tool.IOT; | |||||
namespace 服务API.Tool.API请求 | |||||
namespace DataVAPI.Tool.API请求 | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// Http状态字段基类 | /// Http状态字段基类 | ||||
@@ -53,28 +52,28 @@ namespace 服务API.Tool.API请求 | |||||
public int icon { get; set; } | public int icon { get; set; } | ||||
public static JsonMsg<T> OK(T obj,string msg = "接口名称",string mso = "调用接口成功") | |||||
public static JsonMsg<T> 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; | ConsoleColor currentForeColor = Console.ForegroundColor; | ||||
Console.ForegroundColor = ConsoleColor.Green; | Console.ForegroundColor = ConsoleColor.Green; | ||||
Console.WriteLine(str); | Console.WriteLine(str); | ||||
Console.ForegroundColor = currentForeColor; | Console.ForegroundColor = currentForeColor; | ||||
return new JsonMsg<T>() { code = 1,ms = mso,msg = "成功",obj = obj,icon = 1 }; | |||||
return new JsonMsg<T>() { code = 1, ms = mso, msg = "成功", obj = obj, icon = 1 }; | |||||
} | } | ||||
public static JsonMsg<T> Error(T obj,string msg = "接口名称",string mso = "调用接口成功失败") | |||||
public static JsonMsg<T> 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; | ConsoleColor currentForeColor = Console.ForegroundColor; | ||||
Console.ForegroundColor = ConsoleColor.Red; | Console.ForegroundColor = ConsoleColor.Red; | ||||
Console.WriteLine(str); | Console.WriteLine(str); | ||||
Console.ForegroundColor = currentForeColor; | Console.ForegroundColor = currentForeColor; | ||||
return new JsonMsg<T>() { code = 0,ms = mso,msg = "失败",obj = obj,icon = 1 }; | |||||
return new JsonMsg<T>() { code = 0, ms = mso, msg = "失败", obj = obj, icon = 1 }; | |||||
} | } | ||||
} | } | ||||
public class DeviceTable :BaseEntity | |||||
public class DeviceTable : BaseEntity | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 阿里云设备key | /// 阿里云设备key | ||||
@@ -106,7 +105,7 @@ namespace 服务API.Tool.API请求 | |||||
/// <summary> | /// <summary> | ||||
/// 告警消息表 | /// 告警消息表 | ||||
/// </summary> | /// </summary> | ||||
public class AlarmTable :BaseEntity | |||||
public class AlarmTable : BaseEntity | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 告警时间 | /// 告警时间 | ||||
@@ -128,7 +127,7 @@ namespace 服务API.Tool.API请求 | |||||
/// IP 地址 | /// IP 地址 | ||||
/// </summary> | /// </summary> | ||||
public string IP { get; set; } | public string IP { get; set; } | ||||
public AlarmTable() | public AlarmTable() | ||||
{ | { | ||||
IP = Tools.GetLocalIp(); | IP = Tools.GetLocalIp(); | ||||
@@ -138,7 +137,7 @@ namespace 服务API.Tool.API请求 | |||||
/// <summary> | /// <summary> | ||||
/// 日志表 | /// 日志表 | ||||
/// </summary> | /// </summary> | ||||
public class LogTable :BaseEntity | |||||
public class LogTable : BaseEntity | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 日志时间 | /// 日志时间 |
@@ -5,22 +5,22 @@ using System.Linq; | |||||
using System.Threading; | using System.Threading; | ||||
namespace 服务API.Tool | |||||
namespace DataVAPI.Tool | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 线程集中处理委托 | /// 线程集中处理委托 | ||||
/// </summary> | /// </summary> | ||||
/// <param name="action"></param> | /// <param name="action"></param> | ||||
public delegate void ActionKeyHandle(string action); | 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 delegate void ThreadExitHandle(string action); | ||||
/// <summary> | /// <summary> | ||||
/// 执行器 | /// 执行器 | ||||
/// </summary> | /// </summary> | ||||
public class Executer :Singleton<Executer> | |||||
public class Executer : Singleton<Executer> | |||||
{ | { | ||||
private System.Timers.Timer _timer4Monitor = new System.Timers.Timer(1000); | private System.Timers.Timer _timer4Monitor = new System.Timers.Timer(1000); | ||||
private ConcurrentDictionary<string,Thread> _actions = new ConcurrentDictionary<string,Thread>(); | |||||
private ConcurrentDictionary<string, Thread> _actions = new ConcurrentDictionary<string, Thread>(); | |||||
private object _async = new object(); | private object _async = new object(); | ||||
public event ThreadExceptionHandle OnThreadException; | public event ThreadExceptionHandle OnThreadException; | ||||
public event ThreadExitHandle ThreadExit; | public event ThreadExitHandle ThreadExit; | ||||
@@ -49,7 +49,7 @@ namespace 服务API.Tool | |||||
/// <returns></returns> | /// <returns></returns> | ||||
public List<Thread> GetActionInfos() | public List<Thread> GetActionInfos() | ||||
{ | { | ||||
Monitor.TryEnter(_async,200); | |||||
Monitor.TryEnter(_async, 200); | |||||
var actionInfos = _actions.Values.ToList(); | var actionInfos = _actions.Values.ToList(); | ||||
Monitor.Exit(_async); | Monitor.Exit(_async); | ||||
return actionInfos; | return actionInfos; | ||||
@@ -62,7 +62,7 @@ namespace 服务API.Tool | |||||
/// <param name="key"></param> | /// <param name="key"></param> | ||||
public void Abort(string key) | public void Abort(string key) | ||||
{ | { | ||||
Monitor.TryEnter(_async,200); | |||||
Monitor.TryEnter(_async, 200); | |||||
if (_actions.ContainsKey(key)) | if (_actions.ContainsKey(key)) | ||||
{ | { | ||||
try { _actions[key].Abort(); } | try { _actions[key].Abort(); } | ||||
@@ -77,7 +77,7 @@ namespace 服务API.Tool | |||||
/// <returns></returns> | /// <returns></returns> | ||||
public bool ContainsKey(string key) | public bool ContainsKey(string key) | ||||
{ | { | ||||
Monitor.TryEnter(_async,200); | |||||
Monitor.TryEnter(_async, 200); | |||||
var item = _actions[key]; | var item = _actions[key]; | ||||
Monitor.Exit(_async); | Monitor.Exit(_async); | ||||
if (null != item) | if (null != item) | ||||
@@ -93,7 +93,7 @@ namespace 服务API.Tool | |||||
/// <param name="name"></param> | /// <param name="name"></param> | ||||
/// <param name="isBackground"></param> | /// <param name="isBackground"></param> | ||||
/// <param name="priority"></param> | /// <param name="priority"></param> | ||||
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(() => | Thread thread = new Thread(() => | ||||
{ | { | ||||
@@ -104,14 +104,14 @@ namespace 服务API.Tool | |||||
} | } | ||||
catch (Exception ex) | catch (Exception ex) | ||||
{ | { | ||||
OnThreadException?.Invoke(name,ex); | |||||
OnThreadException?.Invoke(name, ex); | |||||
} | } | ||||
}); | }); | ||||
thread.IsBackground = isBackground; | thread.IsBackground = isBackground; | ||||
thread.Priority = priority; | thread.Priority = priority; | ||||
thread.Name = name; | thread.Name = name; | ||||
thread.Start(); | thread.Start(); | ||||
Monitor.TryEnter(_async,50); | |||||
Monitor.TryEnter(_async, 50); | |||||
if (_actions.ContainsKey(name)) | if (_actions.ContainsKey(name)) | ||||
{ | { | ||||
try { _actions[name].Abort(); } | try { _actions[name].Abort(); } | ||||
@@ -126,7 +126,7 @@ namespace 服务API.Tool | |||||
/// <param name="action"></param> | /// <param name="action"></param> | ||||
/// <param name="timeout"></param> | /// <param name="timeout"></param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
public bool StartWhiteReturn(Func<bool> action,int timeout = 3) | |||||
public bool StartWhiteReturn(Func<bool> action, int timeout = 3) | |||||
{ | { | ||||
DateTime beginTime = DateTime.Now; | DateTime beginTime = DateTime.Now; | ||||
bool doResult = false; | bool doResult = false; |
@@ -4,7 +4,7 @@ using System.Linq; | |||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
namespace 服务API.Tool.IOT | |||||
namespace DataVAPI.Tool.IOT | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 命令实体类 | /// 命令实体类 | ||||
@@ -22,6 +22,6 @@ namespace 服务API.Tool.IOT | |||||
/// <summary> | /// <summary> | ||||
/// 命令变量:执行变量 key为属性或时间 value为值或者消息 | /// 命令变量:执行变量 key为属性或时间 value为值或者消息 | ||||
/// </summary> | /// </summary> | ||||
public Dictionary<string,string> CommandValue { get; set; } | |||||
public Dictionary<string, string> CommandValue { get; set; } | |||||
} | } | ||||
} | } |
@@ -4,7 +4,7 @@ using System.Linq; | |||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
namespace 服务API.Tool.IOT | |||||
namespace DataVAPI.Tool.IOT | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// IOT Model | /// IOT Model | ||||
@@ -98,7 +98,7 @@ namespace 服务API.Tool.IOT | |||||
try | try | ||||
{ | { | ||||
IotModel<IOTDevSXModel> iotModel = new IotModel<IOTDevSXModel> { @params = this }; | IotModel<IOTDevSXModel> iotModel = new IotModel<IOTDevSXModel> { @params = this }; | ||||
string json = Tools.JsonConvertTools<IotModel<IOTDevSXModel>>(iotModel); | |||||
string json = Tools.JsonConvertTools(iotModel); | |||||
return json; | return json; | ||||
} | } | ||||
catch (Exception ex) | catch (Exception ex) | ||||
@@ -115,7 +115,7 @@ namespace 服务API.Tool.IOT | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
JBSX = Tools.JsonConvertTools<DevSX>(devSX); | |||||
JBSX = Tools.JsonConvertTools(devSX); | |||||
} | } | ||||
catch (Exception ex) | catch (Exception ex) | ||||
{ | { | ||||
@@ -127,19 +127,20 @@ namespace 服务API.Tool.IOT | |||||
/// </summary> | /// </summary> | ||||
/// <param name="devSX"></param> | /// <param name="devSX"></param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
public void SetJBSXStatus(DevSXBase sXBase,bool Status) | |||||
public void SetJBSXStatus(DevSXBase sXBase, bool Status) | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
if (sXBase == null) return; | if (sXBase == null) return; | ||||
DevSX dev= Tools.JsonToObjectTools<DevSX>(JBSX); | |||||
dev.data?.ForEach(x => { | |||||
DevSX dev = Tools.JsonToObjectTools<DevSX>(JBSX); | |||||
dev.data?.ForEach(x => | |||||
{ | |||||
if (x.SXMC == sXBase.SXMC && x.SXLX == sXBase.SXLX) | if (x.SXMC == sXBase.SXMC && x.SXLX == sXBase.SXLX) | ||||
{ | { | ||||
x.SXStatus= Status; | |||||
x.SXStatus = Status; | |||||
} | } | ||||
}); | }); | ||||
JBSX = Tools.JsonConvertTools<DevSX>(dev); | |||||
JBSX = Tools.JsonConvertTools(dev); | |||||
} | } | ||||
catch (Exception ex) | catch (Exception ex) | ||||
{ | { | ||||
@@ -154,7 +155,7 @@ namespace 服务API.Tool.IOT | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
KZSX = Tools.JsonConvertTools<DevSX>(devSX); | |||||
KZSX = Tools.JsonConvertTools(devSX); | |||||
} | } | ||||
catch (Exception ex) | catch (Exception ex) | ||||
{ | { | ||||
@@ -172,13 +173,14 @@ namespace 服务API.Tool.IOT | |||||
{ | { | ||||
if (sXBase == null) return; | if (sXBase == null) return; | ||||
DevSX dev = Tools.JsonToObjectTools<DevSX>(KZSX); | DevSX dev = Tools.JsonToObjectTools<DevSX>(KZSX); | ||||
dev.data?.ForEach(x => { | |||||
dev.data?.ForEach(x => | |||||
{ | |||||
if (x.SXMC == sXBase.SXMC && x.SXLX == sXBase.SXLX) | if (x.SXMC == sXBase.SXMC && x.SXLX == sXBase.SXLX) | ||||
{ | { | ||||
x.SXStatus = Status; | x.SXStatus = Status; | ||||
} | } | ||||
}); | }); | ||||
KZSX = Tools.JsonConvertTools<DevSX>(dev); | |||||
KZSX = Tools.JsonConvertTools(dev); | |||||
} | } | ||||
catch (Exception ex) | catch (Exception ex) | ||||
{ | { | ||||
@@ -196,7 +198,7 @@ namespace 服务API.Tool.IOT | |||||
/// <summary> | /// <summary> | ||||
/// 告警Model | /// 告警Model | ||||
/// </summary> | /// </summary> | ||||
public class AlarmModel :DeviceBase | |||||
public class AlarmModel : DeviceBase | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 告警程度:提示 一般 严重 | /// 告警程度:提示 一般 严重 | ||||
@@ -207,9 +209,9 @@ namespace 服务API.Tool.IOT | |||||
set | set | ||||
{ | { | ||||
_AlarmCD = value; | _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; } | private string _AlarmCD { get; set; } |
@@ -1,4 +1,5 @@ | |||||
| | ||||
using DataVAPI.Tool.API请求; | |||||
using Newtonsoft.Json; | using Newtonsoft.Json; | ||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
@@ -10,9 +11,8 @@ using System.Text; | |||||
using System.Threading; | using System.Threading; | ||||
using uPLibrary.Networking.M2Mqtt; | using uPLibrary.Networking.M2Mqtt; | ||||
using uPLibrary.Networking.M2Mqtt.Messages; | using uPLibrary.Networking.M2Mqtt.Messages; | ||||
using 服务API.Tool.API请求; | |||||
namespace 服务API.Tool.IOT | |||||
namespace DataVAPI.Tool.IOT | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// add fengyoufu | /// add fengyoufu | ||||
@@ -36,7 +36,7 @@ namespace 服务API.Tool.IOT | |||||
/// <summary> | /// <summary> | ||||
/// 设备消息数据回调 | /// 设备消息数据回调 | ||||
/// </summary> | /// </summary> | ||||
public static Action<string,string> DevIOTAction { get; set; } | |||||
public static Action<string, string> DevIOTAction { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 重连事件 | /// 重连事件 | ||||
/// </summary> | /// </summary> | ||||
@@ -124,7 +124,7 @@ namespace 服务API.Tool.IOT | |||||
/// <param name="_DeviceName"></param> | /// <param name="_DeviceName"></param> | ||||
/// <param name="_DeviceSecret"></param> | /// <param name="_DeviceSecret"></param> | ||||
/// <param name="_RegionId"></param> | /// <param name="_RegionId"></param> | ||||
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; | ProductKey = _ProductKey; | ||||
DeviceName = _DeviceName; | DeviceName = _DeviceName; | ||||
@@ -146,7 +146,7 @@ namespace 服务API.Tool.IOT | |||||
/// 创建连接 | /// 创建连接 | ||||
/// </summary> | /// </summary> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
public bool CreateLinks(int ClientId,out DeviceTable device) | |||||
public bool CreateLinks(int ClientId, out DeviceTable device) | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
@@ -156,27 +156,27 @@ namespace 服务API.Tool.IOT | |||||
if (jsonMsg.obj != null) | if (jsonMsg.obj != null) | ||||
{ | { | ||||
device = jsonMsg.obj.FirstOrDefault(); | 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()); | IPHostEntry host = Dns.GetHostEntry(Dns.GetHostName()); | ||||
string clientId = host.AddressList.FirstOrDefault( | 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 t = Convert.ToString(DateTimeOffset.Now.ToUnixTimeMilliseconds()); | ||||
string signmethod = "hmacmd5"; | string signmethod = "hmacmd5"; | ||||
Dictionary<string,string> dict = new Dictionary<string,string>(); | |||||
dict.Add("productKey",ProductKey); | |||||
dict.Add("deviceName",DeviceName); | |||||
dict.Add("clientId",clientId); | |||||
dict.Add("timestamp",t); | |||||
Dictionary<string, string> dict = new Dictionary<string, string>(); | |||||
dict.Add("productKey", ProductKey); | |||||
dict.Add("deviceName", DeviceName); | |||||
dict.Add("clientId", clientId); | |||||
dict.Add("timestamp", t); | |||||
mqttUserName = DeviceName + "&" + ProductKey; | mqttUserName = DeviceName + "&" + ProductKey; | ||||
mqttPassword = IotSignUtils.sign(dict,DeviceSecret,signmethod); | |||||
mqttPassword = IotSignUtils.sign(dict, DeviceSecret, signmethod); | |||||
mqttClientId = clientId + "|securemode=3,signmethod=" + signmethod + ",timestamp=" + t + "|"; | mqttClientId = clientId + "|securemode=3,signmethod=" + signmethod + ",timestamp=" + t + "|"; | ||||
targetServer = ProductKey + ".iot-as-mqtt." + RegionId + ".aliyuncs.com"; | targetServer = ProductKey + ".iot-as-mqtt." + RegionId + ".aliyuncs.com"; | ||||
ConnectMqtt(targetServer,mqttClientId,mqttUserName,mqttPassword); | |||||
ConnectMqtt(targetServer, mqttClientId, mqttUserName, mqttPassword); | |||||
return true; | return true; | ||||
} | } | ||||
else | else | ||||
@@ -228,9 +228,9 @@ namespace 服务API.Tool.IOT | |||||
/// </summary> | /// </summary> | ||||
/// <param name="topic"></param> | /// <param name="topic"></param> | ||||
/// <param name="message"></param> | /// <param name="message"></param> | ||||
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)); | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -243,7 +243,7 @@ namespace 服务API.Tool.IOT | |||||
{ | { | ||||
SubTopicList.Add(topic); | SubTopicList.Add(topic); | ||||
} | } | ||||
client.Subscribe(new string[] { topic },new byte[] { 0 }); | |||||
client.Subscribe(new string[] { topic }, new byte[] { 0 }); | |||||
} | } | ||||
#endregion | #endregion | ||||
@@ -255,11 +255,11 @@ namespace 服务API.Tool.IOT | |||||
/// <param name="mqttClientId"></param> | /// <param name="mqttClientId"></param> | ||||
/// <param name="mqttUserName"></param> | /// <param name="mqttUserName"></param> | ||||
/// <param name="mqttPassword"></param> | /// <param name="mqttPassword"></param> | ||||
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 = new MqttClient(targetServer); | ||||
client.ProtocolVersion = MqttProtocolVersion.Version_3_1_1; | 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.MqttMsgPublishReceived += Client_MqttMsgPublishReceived; | ||||
client.ConnectionClosed += Client_ConnectionClosed; | client.ConnectionClosed += Client_ConnectionClosed; | ||||
} | } | ||||
@@ -269,7 +269,7 @@ namespace 服务API.Tool.IOT | |||||
/// </summary> | /// </summary> | ||||
/// <param name="sender"></param> | /// <param name="sender"></param> | ||||
/// <param name="e"></param> | /// <param name="e"></param> | ||||
private static void Client_ConnectionClosed(object sender,EventArgs e) | |||||
private static void Client_ConnectionClosed(object sender, EventArgs e) | |||||
{ | { | ||||
// 尝试重连 | // 尝试重连 | ||||
_TryContinueConnect(); | _TryContinueConnect(); | ||||
@@ -280,13 +280,13 @@ namespace 服务API.Tool.IOT | |||||
/// </summary> | /// </summary> | ||||
/// <param name="sender"></param> | /// <param name="sender"></param> | ||||
/// <param name="e"></param> | /// <param name="e"></param> | ||||
private static void Client_MqttMsgPublishReceived(object sender,MqttMsgPublishEventArgs e) | |||||
private static void Client_MqttMsgPublishReceived(object sender, MqttMsgPublishEventArgs e) | |||||
{ | { | ||||
string topic = e.Topic; | string topic = e.Topic; | ||||
string message = Encoding.UTF8.GetString(e.Message); | string message = Encoding.UTF8.GetString(e.Message); | ||||
if (DevIOTAction != null) | if (DevIOTAction != null) | ||||
{ | { | ||||
DevIOTAction.Invoke(topic,message); | |||||
DevIOTAction.Invoke(topic, message); | |||||
} | } | ||||
} | } | ||||
@@ -305,14 +305,14 @@ namespace 服务API.Tool.IOT | |||||
{ | { | ||||
client = new MqttClient(targetServer); | client = new MqttClient(targetServer); | ||||
client.ProtocolVersion = MqttProtocolVersion.Version_3_1_1; | 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.MqttMsgPublishReceived += Client_MqttMsgPublishReceived; | ||||
client.ConnectionClosed += Client_ConnectionClosed; | client.ConnectionClosed += Client_ConnectionClosed; | ||||
if (client.IsConnected) | 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); | Thread.Sleep(3000); | ||||
@@ -321,12 +321,12 @@ namespace 服务API.Tool.IOT | |||||
try | try | ||||
{ | { | ||||
client.Connect(mqttClientId,mqttUserName,mqttPassword,false,60); | |||||
client.Connect(mqttClientId, mqttUserName, mqttPassword, false, 60); | |||||
if (client.IsConnected) | 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成功!"); | UNConnectMqtt?.Invoke("重新连接阿里云MQTT成功!"); | ||||
} | } | ||||
@@ -353,8 +353,8 @@ namespace 服务API.Tool.IOT | |||||
/// </summary> | /// </summary> | ||||
public class IotSignUtils | public class IotSignUtils | ||||
{ | { | ||||
public static string sign(Dictionary<string,string> param, | |||||
string deviceSecret,string signMethod) | |||||
public static string sign(Dictionary<string, string> param, | |||||
string deviceSecret, string signMethod) | |||||
{ | { | ||||
string[] sortedKey = param.Keys.ToArray(); | string[] sortedKey = param.Keys.ToArray(); | ||||
Array.Sort(sortedKey); | Array.Sort(sortedKey); | ||||
@@ -373,7 +373,7 @@ namespace 服务API.Tool.IOT | |||||
StringBuilder signBuilder = new StringBuilder(); | StringBuilder signBuilder = new StringBuilder(); | ||||
foreach (byte b in hashBytes) | foreach (byte b in hashBytes) | ||||
signBuilder.AppendFormat("{0:x2}",b); | |||||
signBuilder.AppendFormat("{0:x2}", b); | |||||
return signBuilder.ToString(); | return signBuilder.ToString(); | ||||
} | } | ||||
@@ -415,10 +415,10 @@ namespace 服务API.Tool.IOT | |||||
/// <returns></returns> | /// <returns></returns> | ||||
public static long ConvertDateTimeToLong(DateTime dt) | 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); | TimeSpan toNow = dt.Subtract(dtStart); | ||||
long timeStamp = toNow.Ticks; | 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; | return timeStamp; | ||||
} | } | ||||
@@ -429,7 +429,7 @@ namespace 服务API.Tool.IOT | |||||
/// <returns></returns> | /// <returns></returns> | ||||
public static DateTime ConvertLongToDateTime(long d) | 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"); | long lTime = long.Parse(d + "0000"); | ||||
TimeSpan toNow = new TimeSpan(lTime); | TimeSpan toNow = new TimeSpan(lTime); | ||||
DateTime dtResult = dtStart.Add(toNow); | DateTime dtResult = dtStart.Add(toNow); |
@@ -4,7 +4,7 @@ using System.Linq; | |||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
namespace 服务API.Tool.IOT | |||||
namespace DataVAPI.Tool.IOT | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
@@ -32,7 +32,7 @@ namespace 服务API.Tool.IOT | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
return Tools.JsonConvertTools<ScreenMonitorModel>(this); | |||||
return Tools.JsonConvertTools(this); | |||||
} | } | ||||
catch (Exception ex) | catch (Exception ex) | ||||
{ | { | ||||
@@ -121,7 +121,7 @@ namespace 服务API.Tool.IOT | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 通知消息 | /// 通知消息 | ||||
/// </summary> | /// </summary> | ||||
@@ -165,8 +165,8 @@ namespace 服务API.Tool.IOT | |||||
set | set | ||||
{ | { | ||||
_IsAlarm = value; | _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; } | private bool _IsAlarm { get; set; } | ||||
@@ -185,8 +185,8 @@ namespace 服务API.Tool.IOT | |||||
public DevStatus() | public DevStatus() | ||||
{ | { | ||||
IsAlarm = false; | 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 }; | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 设置属性 | /// 设置属性 |
@@ -4,7 +4,7 @@ using System.Linq; | |||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
namespace 服务API.Tool | |||||
namespace DataVAPI.Tool | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 单例对象基类 | /// 单例对象基类 |
@@ -4,14 +4,14 @@ using System.Linq; | |||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
namespace 服务API.Tool.控制台显示 | |||||
namespace DataVAPI.Tool.控制台显示 | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 控制台帮助类 | /// 控制台帮助类 | ||||
/// </summary> | /// </summary> | ||||
public static class ConsoleHelper | 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}"; | str = $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} {str}"; | ||||
ConsoleColor currentForeColor = Console.ForegroundColor; | ConsoleColor currentForeColor = Console.ForegroundColor; | ||||
@@ -24,36 +24,36 @@ namespace 服务API.Tool.控制台显示 | |||||
/// </summary> | /// </summary> | ||||
/// <param name="str">待打印的字符串</param> | /// <param name="str">待打印的字符串</param> | ||||
/// <param name="color">想要打印的颜色</param> | /// <param name="color">想要打印的颜色</param> | ||||
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); | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 打印警告信息 | /// 打印警告信息 | ||||
/// </summary> | /// </summary> | ||||
/// <param name="str">待打印的字符串</param> | /// <param name="str">待打印的字符串</param> | ||||
/// <param name="color">想要打印的颜色</param> | /// <param name="color">想要打印的颜色</param> | ||||
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); | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 打印正常信息 | /// 打印正常信息 | ||||
/// </summary> | /// </summary> | ||||
/// <param name="str">待打印的字符串</param> | /// <param name="str">待打印的字符串</param> | ||||
/// <param name="color">想要打印的颜色</param> | /// <param name="color">想要打印的颜色</param> | ||||
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); | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 打印成功的信息 | /// 打印成功的信息 | ||||
/// </summary> | /// </summary> | ||||
/// <param name="str">待打印的字符串</param> | /// <param name="str">待打印的字符串</param> | ||||
/// <param name="color">想要打印的颜色</param> | /// <param name="color">想要打印的颜色</param> | ||||
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); | |||||
} | } | ||||
} | } | ||||
} | } |
@@ -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 |
@@ -2,7 +2,7 @@ | |||||
using Microsoft.Extensions.Configuration.Json; | using Microsoft.Extensions.Configuration.Json; | ||||
using System; | using System; | ||||
namespace 服务API.AppConfig | |||||
namespace DataVAPI.AppConfig | |||||
{ | { | ||||
public class AppConfigurtaionServices | public class AppConfigurtaionServices | ||||
{ | { | ||||
@@ -17,8 +17,8 @@ namespace 服务API.AppConfig | |||||
.Add(new JsonConfigurationSource { Path = "appsettings.json", ReloadOnChange = true }) | .Add(new JsonConfigurationSource { Path = "appsettings.json", ReloadOnChange = true }) | ||||
.Build(); | .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; | |||||
} | } | ||||
} | } |
@@ -6,7 +6,7 @@ using System.Threading.Tasks; | |||||
using Microsoft.Extensions.DependencyInjection; | using Microsoft.Extensions.DependencyInjection; | ||||
using Microsoft.OpenApi.Models; | using Microsoft.OpenApi.Models; | ||||
namespace 服务API.ConfigureSwagger | |||||
namespace DataVAPI.ConfigureSwagger | |||||
{ | { | ||||
public static class ConfigureSwagger | public static class ConfigureSwagger | ||||
{ | { |
@@ -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; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using 服务API.Model; | |||||
using 服务API.ServerDB.MongoDB; | |||||
using 服务API.Tool.IOT; | |||||
namespace 服务API.Controllers | |||||
namespace DataVAPI.Controllers | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// MG数据库:告警表 AlarmTable | /// MG数据库:告警表 AlarmTable | ||||
/// </summary> | /// </summary> | ||||
public class AlarmController :BaseController | |||||
public class AlarmController : BaseController | |||||
{ | { | ||||
MongoDbHelper<AlarmTable> mg = new MongoDbHelper<AlarmTable>(DataBus.DataBus.connStr,DataBus.DataBus.dbName); | |||||
MongoDbHelper<DeviceTable> mgsb = new MongoDbHelper<DeviceTable>(DataBus.DataBus.connStr,DataBus.DataBus.dbName); | |||||
MongoDbHelper<AlarmTable> mg = new MongoDbHelper<AlarmTable>(DataBus.connStr, DataBus.dbName); | |||||
MongoDbHelper<DeviceTable> mgsb = new MongoDbHelper<DeviceTable>(DataBus.connStr, DataBus.dbName); | |||||
string st = System.Reflection.MethodBase.GetCurrentMethod().Name; | string st = System.Reflection.MethodBase.GetCurrentMethod().Name; | ||||
@@ -28,14 +28,14 @@ namespace 服务API.Controllers | |||||
{ | { | ||||
if (string.IsNullOrEmpty(auth.ClientId)) | if (string.IsNullOrEmpty(auth.ClientId)) | ||||
{ | { | ||||
return JsonMsg<AlarmTable>.Error(null,st,"设备ID不能为空"); ; | |||||
return JsonMsg<AlarmTable>.Error(null, st, "设备ID不能为空"); ; | |||||
} | } | ||||
mg.Insert(auth); | mg.Insert(auth); | ||||
return JsonMsg<AlarmTable>.OK(auth,st); | |||||
return JsonMsg<AlarmTable>.OK(auth, st); | |||||
} | } | ||||
catch (System.Exception ex) | |||||
catch (Exception ex) | |||||
{ | { | ||||
return JsonMsg<AlarmTable>.Error(null,st,ex.Message); | |||||
return JsonMsg<AlarmTable>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -49,11 +49,11 @@ namespace 服务API.Controllers | |||||
try | try | ||||
{ | { | ||||
mg.Inserts(auth); | mg.Inserts(auth); | ||||
return JsonMsg<List<AlarmTable>>.OK(auth,st); | |||||
return JsonMsg<List<AlarmTable>>.OK(auth, st); | |||||
} | } | ||||
catch (System.Exception ex) | |||||
catch (Exception ex) | |||||
{ | { | ||||
return JsonMsg<List<AlarmTable>>.Error(null,st,ex.Message); | |||||
return JsonMsg<List<AlarmTable>>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -68,11 +68,11 @@ namespace 服务API.Controllers | |||||
try | try | ||||
{ | { | ||||
mg.Update(auth); | mg.Update(auth); | ||||
return JsonMsg<AlarmTable>.OK(auth,st); | |||||
return JsonMsg<AlarmTable>.OK(auth, st); | |||||
} | } | ||||
catch (System.Exception ex) | |||||
catch (Exception ex) | |||||
{ | { | ||||
return JsonMsg<AlarmTable>.Error(null,st,ex.Message); | |||||
return JsonMsg<AlarmTable>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -86,11 +86,11 @@ namespace 服务API.Controllers | |||||
st = System.Reflection.MethodBase.GetCurrentMethod().Name; | st = System.Reflection.MethodBase.GetCurrentMethod().Name; | ||||
try | try | ||||
{ | { | ||||
return JsonMsg<AlarmTable>.OK(mg.QueryOne(id),st); | |||||
return JsonMsg<AlarmTable>.OK(mg.QueryOne(id), st); | |||||
} | } | ||||
catch (System.Exception ex) | |||||
catch (Exception ex) | |||||
{ | { | ||||
return JsonMsg<AlarmTable>.Error(null,st,ex.Message); | |||||
return JsonMsg<AlarmTable>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -104,11 +104,11 @@ namespace 服务API.Controllers | |||||
st = System.Reflection.MethodBase.GetCurrentMethod().Name; | st = System.Reflection.MethodBase.GetCurrentMethod().Name; | ||||
try | try | ||||
{ | { | ||||
return JsonMsg<List<AlarmTable>>.OK(mg.QueryClientId(clientId),st); | |||||
return JsonMsg<List<AlarmTable>>.OK(mg.QueryClientId(clientId), st); | |||||
} | } | ||||
catch (System.Exception ex) | |||||
catch (Exception ex) | |||||
{ | { | ||||
return JsonMsg<List<AlarmTable>>.Error(null,st,ex.Message); | |||||
return JsonMsg<List<AlarmTable>>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -117,16 +117,16 @@ namespace 服务API.Controllers | |||||
/// <param name="clientId"></param> | /// <param name="clientId"></param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
[HttpGet] | [HttpGet] | ||||
public JsonMsg<List<AlarmTable>> QueryDeviceId(string clientId,string deviceId) | |||||
public JsonMsg<List<AlarmTable>> QueryDeviceId(string clientId, string deviceId) | |||||
{ | { | ||||
st = System.Reflection.MethodBase.GetCurrentMethod().Name; | st = System.Reflection.MethodBase.GetCurrentMethod().Name; | ||||
try | try | ||||
{ | { | ||||
if(string.IsNullOrEmpty(clientId)) | |||||
if (string.IsNullOrEmpty(clientId)) | |||||
return JsonMsg<List<AlarmTable>>.Error(null, st, "客户端ID不能为空"); ; | return JsonMsg<List<AlarmTable>>.Error(null, st, "客户端ID不能为空"); ; | ||||
return JsonMsg<List<AlarmTable>>.OK(mg.QueryDeviceId(clientId,deviceId), st); | |||||
return JsonMsg<List<AlarmTable>>.OK(mg.QueryDeviceId(clientId, deviceId), st); | |||||
} | } | ||||
catch (System.Exception ex) | |||||
catch (Exception ex) | |||||
{ | { | ||||
return JsonMsg<List<AlarmTable>>.Error(null, st, ex.Message); | return JsonMsg<List<AlarmTable>>.Error(null, st, ex.Message); | ||||
} | } | ||||
@@ -137,30 +137,30 @@ namespace 服务API.Controllers | |||||
/// <param name="clientId"></param> | /// <param name="clientId"></param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
[HttpGet] | [HttpGet] | ||||
public JsonMsg<List<AlarmTable>> QueryDeviceName(string DeviceName,string StartTime,string StopTime) | |||||
public JsonMsg<List<AlarmTable>> QueryDeviceName(string DeviceName, string StartTime, string StopTime) | |||||
{ | { | ||||
st = System.Reflection.MethodBase.GetCurrentMethod().Name; | st = System.Reflection.MethodBase.GetCurrentMethod().Name; | ||||
try | try | ||||
{ | { | ||||
DeviceTable device= mgsb.QueryDeviceName(DeviceName); | |||||
DeviceTable device = mgsb.QueryDeviceName(DeviceName); | |||||
//ConsoleHelper.WriteSuccessLine(Tools.JsonConvertTools(device)+ " "+Time); | //ConsoleHelper.WriteSuccessLine(Tools.JsonConvertTools(device)+ " "+Time); | ||||
if (device != null) | if (device != null) | ||||
{ | { | ||||
if (!string.IsNullOrEmpty(StartTime) && !string.IsNullOrEmpty(StopTime)) | if (!string.IsNullOrEmpty(StartTime) && !string.IsNullOrEmpty(StopTime)) | ||||
{ | { | ||||
DateTime starttime,stoptime; | |||||
DateTime starttime, stoptime; | |||||
starttime = Tools.ConvertLongToDateTime(long.Parse(StartTime)); | starttime = Tools.ConvertLongToDateTime(long.Parse(StartTime)); | ||||
stoptime = Tools.ConvertLongToDateTime(long.Parse(StopTime)); | stoptime = Tools.ConvertLongToDateTime(long.Parse(StopTime)); | ||||
return JsonMsg<List<AlarmTable>>.OK(mg.QueryAllTime(device.ClientId,starttime,stoptime),st); | |||||
return JsonMsg<List<AlarmTable>>.OK(mg.QueryAllTime(device.ClientId, starttime, stoptime), st); | |||||
} | } | ||||
else return JsonMsg<List<AlarmTable>>.OK(mg.QueryClientId(device.ClientId),st); | |||||
else return JsonMsg<List<AlarmTable>>.OK(mg.QueryClientId(device.ClientId), st); | |||||
} | } | ||||
return JsonMsg<List<AlarmTable>>.OK(null,st); | |||||
return JsonMsg<List<AlarmTable>>.OK(null, st); | |||||
} | } | ||||
catch (System.Exception ex) | |||||
catch (Exception ex) | |||||
{ | { | ||||
return JsonMsg<List<AlarmTable>>.Error(null,st,ex.Message); | |||||
return JsonMsg<List<AlarmTable>>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -171,16 +171,16 @@ namespace 服务API.Controllers | |||||
/// <param name="datastop"></param> | /// <param name="datastop"></param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
[HttpGet] | [HttpGet] | ||||
public JsonMsg<List<AlarmTable>> Query(string clientId,DateTime datesta,DateTime datastop) | |||||
public JsonMsg<List<AlarmTable>> Query(string clientId, DateTime datesta, DateTime datastop) | |||||
{ | { | ||||
st = System.Reflection.MethodBase.GetCurrentMethod().Name; | st = System.Reflection.MethodBase.GetCurrentMethod().Name; | ||||
try | try | ||||
{ | { | ||||
return JsonMsg<List<AlarmTable>>.OK(mg.QueryAllTime(clientId,datesta,datastop),st); | |||||
return JsonMsg<List<AlarmTable>>.OK(mg.QueryAllTime(clientId, datesta, datastop), st); | |||||
} | } | ||||
catch (System.Exception ex) | |||||
catch (Exception ex) | |||||
{ | { | ||||
return JsonMsg<List<AlarmTable>>.Error(null,st,ex.Message); | |||||
return JsonMsg<List<AlarmTable>>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -193,16 +193,16 @@ namespace 服务API.Controllers | |||||
/// <param name="PageSize">大小</param> | /// <param name="PageSize">大小</param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
[HttpGet] | [HttpGet] | ||||
public JsonMsg<PaginationListModel<AlarmTable>> BasePagQuery(string clientId,DateTime datesta,DateTime datastop,int PageNumber=1,int PageSize=100) | |||||
public JsonMsg<PaginationListModel<AlarmTable>> BasePagQuery(string clientId, DateTime datesta, DateTime datastop, int PageNumber = 1, int PageSize = 100) | |||||
{ | { | ||||
st = System.Reflection.MethodBase.GetCurrentMethod().Name; | st = System.Reflection.MethodBase.GetCurrentMethod().Name; | ||||
try | try | ||||
{ | { | ||||
return JsonMsg<PaginationListModel<AlarmTable>>.OK(mg.BasePagQuery(clientId,datesta,datastop,PageNumber,PageSize),st); | |||||
return JsonMsg<PaginationListModel<AlarmTable>>.OK(mg.BasePagQuery(clientId, datesta, datastop, PageNumber, PageSize), st); | |||||
} | } | ||||
catch (System.Exception ex) | |||||
catch (Exception ex) | |||||
{ | { | ||||
return JsonMsg<PaginationListModel<AlarmTable>>.Error(null,st,ex.Message); | |||||
return JsonMsg<PaginationListModel<AlarmTable>>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -218,17 +218,17 @@ namespace 服务API.Controllers | |||||
{ | { | ||||
if (string.IsNullOrEmpty(id)) | if (string.IsNullOrEmpty(id)) | ||||
{ | { | ||||
return JsonMsg<string>.Error(null,st,"设备ID不能为空"); ; | |||||
return JsonMsg<string>.Error(null, st, "设备ID不能为空"); ; | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
mg.Modify(id,"State","n"); | |||||
return JsonMsg<string>.OK("success!",st); | |||||
mg.Modify(id, "State", "n"); | |||||
return JsonMsg<string>.OK("success!", st); | |||||
} | } | ||||
} | } | ||||
catch (System.Exception ex) | |||||
catch (Exception ex) | |||||
{ | { | ||||
return JsonMsg<string>.Error(null,st,ex.Message); | |||||
return JsonMsg<string>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -244,17 +244,17 @@ namespace 服务API.Controllers | |||||
{ | { | ||||
if (string.IsNullOrEmpty(id)) | if (string.IsNullOrEmpty(id)) | ||||
{ | { | ||||
return JsonMsg<string>.Error(null,st,"设备ID不能为空"); ; | |||||
return JsonMsg<string>.Error(null, st, "设备ID不能为空"); ; | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
mg.Delete(id); | mg.Delete(id); | ||||
return JsonMsg<string>.OK("success!",st); | |||||
return JsonMsg<string>.OK("success!", st); | |||||
} | } | ||||
} | } | ||||
catch (System.Exception ex) | |||||
catch (Exception ex) | |||||
{ | { | ||||
return JsonMsg<string>.Error(null,st,ex.Message); | |||||
return JsonMsg<string>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
} | } |
@@ -2,7 +2,7 @@ | |||||
using Microsoft.AspNetCore.Http; | using Microsoft.AspNetCore.Http; | ||||
using Microsoft.AspNetCore.Mvc; | using Microsoft.AspNetCore.Mvc; | ||||
namespace 服务API.Controllers | |||||
namespace DataVAPI.Controllers | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 自定义路由 基类 | /// 自定义路由 基类 |
@@ -1,18 +1,16 @@ | |||||
using Microsoft.AspNetCore.Mvc; | |||||
using DataVAPI.Model; | |||||
using DataVAPI.ServerDB.MongoDB; | |||||
using Microsoft.AspNetCore.Mvc; | |||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using 服务API.AppConfig; | |||||
using 服务API.Model; | |||||
using 服务API.ServerDB.MongoDB; | |||||
namespace 服务API.Controllers | |||||
namespace DataVAPI.Controllers | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// MG数据库:设备信息表 DeviceTable | /// MG数据库:设备信息表 DeviceTable | ||||
/// </summary> | /// </summary> | ||||
public class DeviceController :BaseController | |||||
public class DeviceController : BaseController | |||||
{ | { | ||||
MongoDbHelper<DeviceTable> mg = new MongoDbHelper<DeviceTable>(DataBus.DataBus.connStr,DataBus.DataBus.dbName); | |||||
MongoDbHelper<DeviceTable> mg = new MongoDbHelper<DeviceTable>(DataBus.connStr, DataBus.dbName); | |||||
string st = System.Reflection.MethodBase.GetCurrentMethod().Name; | string st = System.Reflection.MethodBase.GetCurrentMethod().Name; | ||||
@@ -27,14 +25,14 @@ namespace 服务API.Controllers | |||||
{ | { | ||||
if (string.IsNullOrEmpty(auth.ClientId)) | if (string.IsNullOrEmpty(auth.ClientId)) | ||||
{ | { | ||||
return JsonMsg<DeviceTable>.Error(null,st,"设备ID不能为空"); ; | |||||
return JsonMsg<DeviceTable>.Error(null, st, "设备ID不能为空"); ; | |||||
} | } | ||||
mg.Insert(auth); | mg.Insert(auth); | ||||
return JsonMsg<DeviceTable>.OK(auth,st); | |||||
return JsonMsg<DeviceTable>.OK(auth, st); | |||||
} | } | ||||
catch (System.Exception ex) | |||||
catch (Exception ex) | |||||
{ | { | ||||
return JsonMsg<DeviceTable>.Error(null,st,ex.Message); | |||||
return JsonMsg<DeviceTable>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -47,11 +45,11 @@ namespace 服务API.Controllers | |||||
try | try | ||||
{ | { | ||||
mg.Inserts(auth); | mg.Inserts(auth); | ||||
return JsonMsg<List<DeviceTable>>.OK(auth,st); | |||||
return JsonMsg<List<DeviceTable>>.OK(auth, st); | |||||
} | } | ||||
catch (System.Exception ex) | |||||
catch (Exception ex) | |||||
{ | { | ||||
return JsonMsg<List<DeviceTable>>.Error(null,st,ex.Message); | |||||
return JsonMsg<List<DeviceTable>>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -64,11 +62,11 @@ namespace 服务API.Controllers | |||||
try | try | ||||
{ | { | ||||
mg.UpdateID(auth); | mg.UpdateID(auth); | ||||
return JsonMsg<DeviceTable>.OK(auth,st); | |||||
return JsonMsg<DeviceTable>.OK(auth, st); | |||||
} | } | ||||
catch (System.Exception ex) | |||||
catch (Exception ex) | |||||
{ | { | ||||
return JsonMsg<DeviceTable>.Error(null,st,ex.Message); | |||||
return JsonMsg<DeviceTable>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -81,11 +79,11 @@ namespace 服务API.Controllers | |||||
st = System.Reflection.MethodBase.GetCurrentMethod().Name; | st = System.Reflection.MethodBase.GetCurrentMethod().Name; | ||||
try | try | ||||
{ | { | ||||
return JsonMsg<DeviceTable>.OK(mg.QueryOne(id),st); | |||||
return JsonMsg<DeviceTable>.OK(mg.QueryOne(id), st); | |||||
} | } | ||||
catch (System.Exception ex) | |||||
catch (Exception ex) | |||||
{ | { | ||||
return JsonMsg<DeviceTable>.Error(null,st,ex.Message); | |||||
return JsonMsg<DeviceTable>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -96,16 +94,16 @@ namespace 服务API.Controllers | |||||
/// <param name="endtime">结束时间</param> | /// <param name="endtime">结束时间</param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
[HttpGet] | [HttpGet] | ||||
public JsonMsg<List<DeviceTable>> Query(string clientId,DateTime starttime,DateTime endtime) | |||||
public JsonMsg<List<DeviceTable>> Query(string clientId, DateTime starttime, DateTime endtime) | |||||
{ | { | ||||
st = System.Reflection.MethodBase.GetCurrentMethod().Name; | st = System.Reflection.MethodBase.GetCurrentMethod().Name; | ||||
try | try | ||||
{ | { | ||||
return JsonMsg<List<DeviceTable>>.OK(mg.QueryAllTime(clientId,starttime,endtime),st); | |||||
return JsonMsg<List<DeviceTable>>.OK(mg.QueryAllTime(clientId, starttime, endtime), st); | |||||
} | } | ||||
catch (System.Exception ex) | |||||
catch (Exception ex) | |||||
{ | { | ||||
return JsonMsg<List<DeviceTable>>.Error(null,st,ex.Message); | |||||
return JsonMsg<List<DeviceTable>>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -118,16 +116,16 @@ namespace 服务API.Controllers | |||||
/// <param name="PageSize">每页大小</param> | /// <param name="PageSize">每页大小</param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
[HttpGet] | [HttpGet] | ||||
public JsonMsg<PaginationListModel<DeviceTable>> BasePagQuery(string clientId,DateTime starttime,DateTime endtime,int PageNumber = 1,int PageSize = 100) | |||||
public JsonMsg<PaginationListModel<DeviceTable>> BasePagQuery(string clientId, DateTime starttime, DateTime endtime, int PageNumber = 1, int PageSize = 100) | |||||
{ | { | ||||
st = System.Reflection.MethodBase.GetCurrentMethod().Name; | st = System.Reflection.MethodBase.GetCurrentMethod().Name; | ||||
try | try | ||||
{ | { | ||||
return JsonMsg<PaginationListModel<DeviceTable>>.OK(mg.BasePagQuery(clientId,starttime,endtime,PageNumber,PageSize),st); | |||||
return JsonMsg<PaginationListModel<DeviceTable>>.OK(mg.BasePagQuery(clientId, starttime, endtime, PageNumber, PageSize), st); | |||||
} | } | ||||
catch (System.Exception ex) | |||||
catch (Exception ex) | |||||
{ | { | ||||
return JsonMsg<PaginationListModel<DeviceTable>>.Error(null,st,ex.Message); | |||||
return JsonMsg<PaginationListModel<DeviceTable>>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -142,17 +140,17 @@ namespace 服务API.Controllers | |||||
{ | { | ||||
if (string.IsNullOrEmpty(id)) | if (string.IsNullOrEmpty(id)) | ||||
{ | { | ||||
return JsonMsg<string>.Error(null,st,"设备ID不能为空"); ; | |||||
return JsonMsg<string>.Error(null, st, "设备ID不能为空"); ; | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
mg.Modify(id,"State","n"); | |||||
return JsonMsg<string>.OK("success!",st); | |||||
mg.Modify(id, "State", "n"); | |||||
return JsonMsg<string>.OK("success!", st); | |||||
} | } | ||||
} | } | ||||
catch (System.Exception ex) | |||||
catch (Exception ex) | |||||
{ | { | ||||
return JsonMsg<string>.Error(null,st,ex.Message); | |||||
return JsonMsg<string>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -167,17 +165,17 @@ namespace 服务API.Controllers | |||||
{ | { | ||||
if (string.IsNullOrEmpty(id)) | if (string.IsNullOrEmpty(id)) | ||||
{ | { | ||||
return JsonMsg<string>.Error(null,st,"设备ID不能为空"); ; | |||||
return JsonMsg<string>.Error(null, st, "设备ID不能为空"); ; | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
mg.Delete(id); | mg.Delete(id); | ||||
return JsonMsg<string>.OK("success!",st); | |||||
return JsonMsg<string>.OK("success!", st); | |||||
} | } | ||||
} | } | ||||
catch (System.Exception ex) | |||||
catch (Exception ex) | |||||
{ | { | ||||
return JsonMsg<string>.Error(null,st,ex.Message); | |||||
return JsonMsg<string>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
} | } |
@@ -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; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using 服务API.Model; | |||||
using 服务API.ServerDB.MongoDB; | |||||
using 服务API.Tool.IOT; | |||||
namespace 服务API.Controllers | |||||
namespace DataVAPI.Controllers | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// MG数据库:日志表 LogTable | /// MG数据库:日志表 LogTable | ||||
/// </summary> | /// </summary> | ||||
public class LogController :BaseController | |||||
public class LogController : BaseController | |||||
{ | { | ||||
MongoDbHelper<LogTable> mg = new MongoDbHelper<LogTable>(DataBus.DataBus.connStr,DataBus.DataBus.dbName); | |||||
MongoDbHelper<DeviceTable> mgsb = new MongoDbHelper<DeviceTable>(DataBus.DataBus.connStr,DataBus.DataBus.dbName); | |||||
MongoDbHelper<LogTable> mg = new MongoDbHelper<LogTable>(DataBus.connStr, DataBus.dbName); | |||||
MongoDbHelper<DeviceTable> mgsb = new MongoDbHelper<DeviceTable>(DataBus.connStr, DataBus.dbName); | |||||
string st = System.Reflection.MethodBase.GetCurrentMethod().Name; | string st = System.Reflection.MethodBase.GetCurrentMethod().Name; | ||||
@@ -29,14 +29,14 @@ namespace 服务API.Controllers | |||||
{ | { | ||||
if (string.IsNullOrEmpty(auth.ClientId)) | if (string.IsNullOrEmpty(auth.ClientId)) | ||||
{ | { | ||||
return JsonMsg<LogTable>.Error(null,st,"设备ID不能为空"); ; | |||||
return JsonMsg<LogTable>.Error(null, st, "设备ID不能为空"); ; | |||||
} | } | ||||
mg.Insert(auth); | mg.Insert(auth); | ||||
return JsonMsg<LogTable>.OK(auth,st); | |||||
return JsonMsg<LogTable>.OK(auth, st); | |||||
} | } | ||||
catch (System.Exception ex) | |||||
catch (Exception ex) | |||||
{ | { | ||||
return JsonMsg<LogTable>.Error(null,st,ex.Message); | |||||
return JsonMsg<LogTable>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -50,11 +50,11 @@ namespace 服务API.Controllers | |||||
try | try | ||||
{ | { | ||||
mg.Inserts(auth); | mg.Inserts(auth); | ||||
return JsonMsg<List<LogTable>>.OK(auth,st); | |||||
return JsonMsg<List<LogTable>>.OK(auth, st); | |||||
} | } | ||||
catch (System.Exception ex) | |||||
catch (Exception ex) | |||||
{ | { | ||||
return JsonMsg<List<LogTable>>.Error(null,st,ex.Message); | |||||
return JsonMsg<List<LogTable>>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -69,11 +69,11 @@ namespace 服务API.Controllers | |||||
try | try | ||||
{ | { | ||||
mg.Update(auth); | mg.Update(auth); | ||||
return JsonMsg<LogTable>.OK(auth,st); | |||||
return JsonMsg<LogTable>.OK(auth, st); | |||||
} | } | ||||
catch (System.Exception ex) | |||||
catch (Exception ex) | |||||
{ | { | ||||
return JsonMsg<LogTable>.Error(null,st,ex.Message); | |||||
return JsonMsg<LogTable>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -87,11 +87,11 @@ namespace 服务API.Controllers | |||||
st = System.Reflection.MethodBase.GetCurrentMethod().Name; | st = System.Reflection.MethodBase.GetCurrentMethod().Name; | ||||
try | try | ||||
{ | { | ||||
return JsonMsg<LogTable>.OK(mg.QueryOne(id),st); | |||||
return JsonMsg<LogTable>.OK(mg.QueryOne(id), st); | |||||
} | } | ||||
catch (System.Exception ex) | |||||
catch (Exception ex) | |||||
{ | { | ||||
return JsonMsg<LogTable>.Error(null,st,ex.Message); | |||||
return JsonMsg<LogTable>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -105,11 +105,11 @@ namespace 服务API.Controllers | |||||
st = System.Reflection.MethodBase.GetCurrentMethod().Name; | st = System.Reflection.MethodBase.GetCurrentMethod().Name; | ||||
try | try | ||||
{ | { | ||||
return JsonMsg<List<LogTable>>.OK(mg.QueryClientId(clientId),st); | |||||
return JsonMsg<List<LogTable>>.OK(mg.QueryClientId(clientId), st); | |||||
} | } | ||||
catch (System.Exception ex) | |||||
catch (Exception ex) | |||||
{ | { | ||||
return JsonMsg<List<LogTable>>.Error(null,st,ex.Message); | |||||
return JsonMsg<List<LogTable>>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -118,7 +118,7 @@ namespace 服务API.Controllers | |||||
/// <param name="DeviceName"></param> | /// <param name="DeviceName"></param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
[HttpGet] | [HttpGet] | ||||
public JsonMsg<List<LogTable>> QueryDeviceName(string DeviceName,string StartTime,string StopTime) | |||||
public JsonMsg<List<LogTable>> QueryDeviceName(string DeviceName, string StartTime, string StopTime) | |||||
{ | { | ||||
st = System.Reflection.MethodBase.GetCurrentMethod().Name; | st = System.Reflection.MethodBase.GetCurrentMethod().Name; | ||||
try | try | ||||
@@ -131,15 +131,15 @@ namespace 服务API.Controllers | |||||
DateTime starttime, stoptime; | DateTime starttime, stoptime; | ||||
starttime = Tools.ConvertLongToDateTime(long.Parse(StartTime)); | starttime = Tools.ConvertLongToDateTime(long.Parse(StartTime)); | ||||
stoptime = Tools.ConvertLongToDateTime(long.Parse(StopTime)); | stoptime = Tools.ConvertLongToDateTime(long.Parse(StopTime)); | ||||
return JsonMsg<List<LogTable>>.OK(mg.QueryAllTime(device.ClientId,starttime,stoptime),st); | |||||
return JsonMsg<List<LogTable>>.OK(mg.QueryAllTime(device.ClientId, starttime, stoptime), st); | |||||
} | } | ||||
else return JsonMsg<List<LogTable>>.OK(mg.QueryClientId(device.ClientId),st); | |||||
else return JsonMsg<List<LogTable>>.OK(mg.QueryClientId(device.ClientId), st); | |||||
} | } | ||||
return JsonMsg<List<LogTable>>.OK(null,st); | |||||
return JsonMsg<List<LogTable>>.OK(null, st); | |||||
} | } | ||||
catch (System.Exception ex) | |||||
catch (Exception ex) | |||||
{ | { | ||||
return JsonMsg<List<LogTable>>.Error(null,st,ex.Message); | |||||
return JsonMsg<List<LogTable>>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -150,16 +150,16 @@ namespace 服务API.Controllers | |||||
/// <param name="datastop"></param> | /// <param name="datastop"></param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
[HttpGet] | [HttpGet] | ||||
public JsonMsg<List<LogTable>> Query(string clientId,DateTime datesta,DateTime datastop) | |||||
public JsonMsg<List<LogTable>> Query(string clientId, DateTime datesta, DateTime datastop) | |||||
{ | { | ||||
st = System.Reflection.MethodBase.GetCurrentMethod().Name; | st = System.Reflection.MethodBase.GetCurrentMethod().Name; | ||||
try | try | ||||
{ | { | ||||
return JsonMsg<List<LogTable>>.OK(mg.QueryAllTime(clientId,datesta,datastop),st); | |||||
return JsonMsg<List<LogTable>>.OK(mg.QueryAllTime(clientId, datesta, datastop), st); | |||||
} | } | ||||
catch (System.Exception ex) | |||||
catch (Exception ex) | |||||
{ | { | ||||
return JsonMsg<List<LogTable>>.Error(null,st,ex.Message); | |||||
return JsonMsg<List<LogTable>>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -172,16 +172,16 @@ namespace 服务API.Controllers | |||||
/// <param name="PageSize"></param> | /// <param name="PageSize"></param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
[HttpGet] | [HttpGet] | ||||
public JsonMsg<PaginationListModel<LogTable>> BasePagQuery(string clientId,DateTime datesta,DateTime datastop,int PageNumber = 1,int PageSize = 100) | |||||
public JsonMsg<PaginationListModel<LogTable>> BasePagQuery(string clientId, DateTime datesta, DateTime datastop, int PageNumber = 1, int PageSize = 100) | |||||
{ | { | ||||
st = System.Reflection.MethodBase.GetCurrentMethod().Name; | st = System.Reflection.MethodBase.GetCurrentMethod().Name; | ||||
try | try | ||||
{ | { | ||||
return JsonMsg<PaginationListModel<LogTable>>.OK(mg.BasePagQuery(clientId,datesta,datastop,PageNumber,PageSize),st); | |||||
return JsonMsg<PaginationListModel<LogTable>>.OK(mg.BasePagQuery(clientId, datesta, datastop, PageNumber, PageSize), st); | |||||
} | } | ||||
catch (System.Exception ex) | |||||
catch (Exception ex) | |||||
{ | { | ||||
return JsonMsg<PaginationListModel<LogTable>>.Error(null,st,ex.Message); | |||||
return JsonMsg<PaginationListModel<LogTable>>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -197,17 +197,17 @@ namespace 服务API.Controllers | |||||
{ | { | ||||
if (string.IsNullOrEmpty(id)) | if (string.IsNullOrEmpty(id)) | ||||
{ | { | ||||
return JsonMsg<string>.Error(null,st,"设备ID不能为空"); ; | |||||
return JsonMsg<string>.Error(null, st, "设备ID不能为空"); ; | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
mg.Modify(id,"State","n"); | |||||
return JsonMsg<string>.OK("success!",st); | |||||
mg.Modify(id, "State", "n"); | |||||
return JsonMsg<string>.OK("success!", st); | |||||
} | } | ||||
} | } | ||||
catch (System.Exception ex) | |||||
catch (Exception ex) | |||||
{ | { | ||||
return JsonMsg<string>.Error(null,st,ex.Message); | |||||
return JsonMsg<string>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -223,17 +223,17 @@ namespace 服务API.Controllers | |||||
{ | { | ||||
if (string.IsNullOrEmpty(id)) | if (string.IsNullOrEmpty(id)) | ||||
{ | { | ||||
return JsonMsg<string>.Error(null,st,"设备ID不能为空"); ; | |||||
return JsonMsg<string>.Error(null, st, "设备ID不能为空"); ; | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
mg.Delete(id); | mg.Delete(id); | ||||
return JsonMsg<string>.OK("success!",st); | |||||
return JsonMsg<string>.OK("success!", st); | |||||
} | } | ||||
} | } | ||||
catch (System.Exception ex) | |||||
catch (Exception ex) | |||||
{ | { | ||||
return JsonMsg<string>.Error(null,st,ex.Message); | |||||
return JsonMsg<string>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
} | } |
@@ -1,17 +1,17 @@ | |||||
using Microsoft.AspNetCore.Mvc; | |||||
using 服务Api.Order; | |||||
using 服务Api.Order.RequestModel; | |||||
using 服务API.Model; | |||||
using DataVApi.Order; | |||||
using DataVApi.Order.RequestModel; | |||||
using DataVAPI.Model; | |||||
using Microsoft.AspNetCore.Mvc; | |||||
namespace 服务API.Controllers | |||||
namespace DataVAPI.Controllers | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 订单接口:统计订单或者营业额 | /// 订单接口:统计订单或者营业额 | ||||
/// </summary> | /// </summary> | ||||
public class OrderController :BaseController | |||||
public class OrderController : BaseController | |||||
{ | { | ||||
string st = System.Reflection.MethodBase.GetCurrentMethod().Name; | string st = System.Reflection.MethodBase.GetCurrentMethod().Name; | ||||
OrderProvider orderProvider=new OrderProvider(); | |||||
OrderProvider orderProvider = new OrderProvider(); | |||||
/// <summary> | /// <summary> | ||||
/// 全部数据 | /// 全部数据 | ||||
/// </summary> | /// </summary> | ||||
@@ -21,12 +21,12 @@ namespace 服务API.Controllers | |||||
st = System.Reflection.MethodBase.GetCurrentMethod().Name; | st = System.Reflection.MethodBase.GetCurrentMethod().Name; | ||||
try | try | ||||
{ | { | ||||
object retdata= orderProvider.GetAllOrderDataState(auth); | |||||
return JsonMsg<object>.OK(retdata,st); | |||||
object retdata = orderProvider.GetAllOrderDataState(auth); | |||||
return JsonMsg<object>.OK(retdata, st); | |||||
} | } | ||||
catch (System.Exception ex) | catch (System.Exception ex) | ||||
{ | { | ||||
return JsonMsg<object>.Error(null,st,ex.Message); | |||||
return JsonMsg<object>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
@@ -40,11 +40,11 @@ namespace 服务API.Controllers | |||||
try | try | ||||
{ | { | ||||
object retdata = orderProvider.OrderLine(auth); | object retdata = orderProvider.OrderLine(auth); | ||||
return JsonMsg<object>.OK(retdata,st); | |||||
return JsonMsg<object>.OK(retdata, st); | |||||
} | } | ||||
catch (System.Exception ex) | catch (System.Exception ex) | ||||
{ | { | ||||
return JsonMsg<object>.Error(null,st,ex.Message); | |||||
return JsonMsg<object>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
@@ -58,11 +58,11 @@ namespace 服务API.Controllers | |||||
try | try | ||||
{ | { | ||||
object retdata = orderProvider.GetLocSale(); | object retdata = orderProvider.GetLocSale(); | ||||
return JsonMsg<object>.OK(retdata,st); | |||||
return JsonMsg<object>.OK(retdata, st); | |||||
} | } | ||||
catch (System.Exception ex) | catch (System.Exception ex) | ||||
{ | { | ||||
return JsonMsg<object>.Error(null,st,ex.Message); | |||||
return JsonMsg<object>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
@@ -76,11 +76,11 @@ namespace 服务API.Controllers | |||||
try | try | ||||
{ | { | ||||
object retdata = orderProvider.OrderNumber(input); | object retdata = orderProvider.OrderNumber(input); | ||||
return JsonMsg<object>.OK(retdata,st); | |||||
return JsonMsg<object>.OK(retdata, st); | |||||
} | } | ||||
catch (System.Exception ex) | catch (System.Exception ex) | ||||
{ | { | ||||
return JsonMsg<object>.Error(null,st,ex.Message); | |||||
return JsonMsg<object>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
} | } |
@@ -1,17 +1,17 @@ | |||||
using Microsoft.AspNetCore.Mvc; | |||||
using DataVAPI.Model; | |||||
using DataVAPI.ServerDB.MongoDB; | |||||
using Microsoft.AspNetCore.Mvc; | |||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using 服务API.Model; | |||||
using 服务API.ServerDB.MongoDB; | |||||
namespace 服务API.Controllers | |||||
namespace DataVAPI.Controllers | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// MG数据库:大屏信息表 ScreenController | /// MG数据库:大屏信息表 ScreenController | ||||
/// </summary> | /// </summary> | ||||
public class ScreenController :BaseController | |||||
public class ScreenController : BaseController | |||||
{ | { | ||||
MongoDbHelper<LargeScreenTable> mg = new MongoDbHelper<LargeScreenTable>(DataBus.DataBus.connStr,DataBus.DataBus.dbName); | |||||
MongoDbHelper<LargeScreenTable> mg = new MongoDbHelper<LargeScreenTable>(DataBus.connStr, DataBus.dbName); | |||||
string st = System.Reflection.MethodBase.GetCurrentMethod().Name; | string st = System.Reflection.MethodBase.GetCurrentMethod().Name; | ||||
/// <summary> | /// <summary> | ||||
@@ -25,9 +25,9 @@ namespace 服务API.Controllers | |||||
{ | { | ||||
if (string.IsNullOrEmpty(largeScreenTable.devicename)) | if (string.IsNullOrEmpty(largeScreenTable.devicename)) | ||||
{ | { | ||||
return JsonMsg<LargeScreenTable>.Error(null,st,"设备名称不能为空"); ; | |||||
return JsonMsg<LargeScreenTable>.Error(null, st, "设备名称不能为空"); ; | |||||
} | } | ||||
LargeScreenTable largeScreen= mg.QueryDeviceName(largeScreenTable.devicename); | |||||
LargeScreenTable largeScreen = mg.QueryDeviceName(largeScreenTable.devicename); | |||||
if (largeScreen != null) | if (largeScreen != null) | ||||
{ | { | ||||
@@ -39,11 +39,11 @@ namespace 服务API.Controllers | |||||
{ | { | ||||
mg.Insert(largeScreenTable); | mg.Insert(largeScreenTable); | ||||
} | } | ||||
return JsonMsg<LargeScreenTable>.OK(largeScreenTable,st); | |||||
return JsonMsg<LargeScreenTable>.OK(largeScreenTable, st); | |||||
} | } | ||||
catch (System.Exception ex) | |||||
catch (Exception ex) | |||||
{ | { | ||||
return JsonMsg<LargeScreenTable>.Error(null,st,ex.Message); | |||||
return JsonMsg<LargeScreenTable>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -57,14 +57,14 @@ namespace 服务API.Controllers | |||||
{ | { | ||||
if (string.IsNullOrEmpty(auth.ClientId)) | if (string.IsNullOrEmpty(auth.ClientId)) | ||||
{ | { | ||||
return JsonMsg<LargeScreenTable>.Error(null,st,"大屏ID不能为空"); ; | |||||
return JsonMsg<LargeScreenTable>.Error(null, st, "大屏ID不能为空"); ; | |||||
} | } | ||||
mg.Insert(auth); | mg.Insert(auth); | ||||
return JsonMsg<LargeScreenTable>.OK(auth,st); | |||||
return JsonMsg<LargeScreenTable>.OK(auth, st); | |||||
} | } | ||||
catch (System.Exception ex) | |||||
catch (Exception ex) | |||||
{ | { | ||||
return JsonMsg<LargeScreenTable>.Error(null,st,ex.Message); | |||||
return JsonMsg<LargeScreenTable>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -77,11 +77,11 @@ namespace 服务API.Controllers | |||||
try | try | ||||
{ | { | ||||
mg.Inserts(auth); | mg.Inserts(auth); | ||||
return JsonMsg<List<LargeScreenTable>>.OK(auth,st); | |||||
return JsonMsg<List<LargeScreenTable>>.OK(auth, st); | |||||
} | } | ||||
catch (System.Exception ex) | |||||
catch (Exception ex) | |||||
{ | { | ||||
return JsonMsg<List<LargeScreenTable>>.Error(null,st,ex.Message); | |||||
return JsonMsg<List<LargeScreenTable>>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -94,11 +94,11 @@ namespace 服务API.Controllers | |||||
try | try | ||||
{ | { | ||||
mg.UpdateID(auth); | mg.UpdateID(auth); | ||||
return JsonMsg<LargeScreenTable>.OK(auth,st); | |||||
return JsonMsg<LargeScreenTable>.OK(auth, st); | |||||
} | } | ||||
catch (System.Exception ex) | |||||
catch (Exception ex) | |||||
{ | { | ||||
return JsonMsg<LargeScreenTable>.Error(null,st,ex.Message); | |||||
return JsonMsg<LargeScreenTable>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -111,11 +111,11 @@ namespace 服务API.Controllers | |||||
st = System.Reflection.MethodBase.GetCurrentMethod().Name; | st = System.Reflection.MethodBase.GetCurrentMethod().Name; | ||||
try | try | ||||
{ | { | ||||
return JsonMsg<LargeScreenTable>.OK(mg.QueryOne(id),st); | |||||
return JsonMsg<LargeScreenTable>.OK(mg.QueryOne(id), st); | |||||
} | } | ||||
catch (System.Exception ex) | |||||
catch (Exception ex) | |||||
{ | { | ||||
return JsonMsg<LargeScreenTable>.Error(null,st,ex.Message); | |||||
return JsonMsg<LargeScreenTable>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -126,16 +126,16 @@ namespace 服务API.Controllers | |||||
/// <param name="endtime">结束时间</param> | /// <param name="endtime">结束时间</param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
[HttpGet] | [HttpGet] | ||||
public JsonMsg<List<LargeScreenTable>> Query(string clientId,DateTime starttime,DateTime endtime) | |||||
public JsonMsg<List<LargeScreenTable>> Query(string clientId, DateTime starttime, DateTime endtime) | |||||
{ | { | ||||
st = System.Reflection.MethodBase.GetCurrentMethod().Name; | st = System.Reflection.MethodBase.GetCurrentMethod().Name; | ||||
try | try | ||||
{ | { | ||||
return JsonMsg<List<LargeScreenTable>>.OK(mg.QueryAllTime(clientId,starttime,endtime),st); | |||||
return JsonMsg<List<LargeScreenTable>>.OK(mg.QueryAllTime(clientId, starttime, endtime), st); | |||||
} | } | ||||
catch (System.Exception ex) | |||||
catch (Exception ex) | |||||
{ | { | ||||
return JsonMsg<List<LargeScreenTable>>.Error(null,st,ex.Message); | |||||
return JsonMsg<List<LargeScreenTable>>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -148,16 +148,16 @@ namespace 服务API.Controllers | |||||
/// <param name="PageSize">每页大小</param> | /// <param name="PageSize">每页大小</param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
[HttpGet] | [HttpGet] | ||||
public JsonMsg<PaginationListModel<LargeScreenTable>> BasePagQuery(string clientId,DateTime starttime,DateTime endtime,int PageNumber = 1,int PageSize = 100) | |||||
public JsonMsg<PaginationListModel<LargeScreenTable>> BasePagQuery(string clientId, DateTime starttime, DateTime endtime, int PageNumber = 1, int PageSize = 100) | |||||
{ | { | ||||
st = System.Reflection.MethodBase.GetCurrentMethod().Name; | st = System.Reflection.MethodBase.GetCurrentMethod().Name; | ||||
try | try | ||||
{ | { | ||||
return JsonMsg<PaginationListModel<LargeScreenTable>>.OK(mg.BasePagQuery(clientId,starttime,endtime,PageNumber,PageSize),st); | |||||
return JsonMsg<PaginationListModel<LargeScreenTable>>.OK(mg.BasePagQuery(clientId, starttime, endtime, PageNumber, PageSize), st); | |||||
} | } | ||||
catch (System.Exception ex) | |||||
catch (Exception ex) | |||||
{ | { | ||||
return JsonMsg<PaginationListModel<LargeScreenTable>>.Error(null,st,ex.Message); | |||||
return JsonMsg<PaginationListModel<LargeScreenTable>>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -173,13 +173,13 @@ namespace 服务API.Controllers | |||||
{ | { | ||||
if (string.IsNullOrEmpty(DeviceName)) | if (string.IsNullOrEmpty(DeviceName)) | ||||
{ | { | ||||
return JsonMsg<LargeScreenTable>.Error(null,st,"设备名称不能为空"); ; | |||||
return JsonMsg<LargeScreenTable>.Error(null, st, "设备名称不能为空"); ; | |||||
} | } | ||||
return JsonMsg<LargeScreenTable>.OK(mg.QueryDeviceName(DeviceName),st); | |||||
return JsonMsg<LargeScreenTable>.OK(mg.QueryDeviceName(DeviceName), st); | |||||
} | } | ||||
catch (System.Exception ex) | |||||
catch (Exception ex) | |||||
{ | { | ||||
return JsonMsg<LargeScreenTable>.Error(null,st,ex.Message); | |||||
return JsonMsg<LargeScreenTable>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -194,17 +194,17 @@ namespace 服务API.Controllers | |||||
{ | { | ||||
if (string.IsNullOrEmpty(id)) | if (string.IsNullOrEmpty(id)) | ||||
{ | { | ||||
return JsonMsg<string>.Error(null,st,"大屏ID不能为空"); ; | |||||
return JsonMsg<string>.Error(null, st, "大屏ID不能为空"); ; | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
mg.Modify(id,"State","n"); | |||||
return JsonMsg<string>.OK("success!",st); | |||||
mg.Modify(id, "State", "n"); | |||||
return JsonMsg<string>.OK("success!", st); | |||||
} | } | ||||
} | } | ||||
catch (System.Exception ex) | |||||
catch (Exception ex) | |||||
{ | { | ||||
return JsonMsg<string>.Error(null,st,ex.Message); | |||||
return JsonMsg<string>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -219,17 +219,17 @@ namespace 服务API.Controllers | |||||
{ | { | ||||
if (string.IsNullOrEmpty(id)) | if (string.IsNullOrEmpty(id)) | ||||
{ | { | ||||
return JsonMsg<string>.Error(null,st,"大屏ID不能为空"); ; | |||||
return JsonMsg<string>.Error(null, st, "大屏ID不能为空"); ; | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
mg.Delete(id); | mg.Delete(id); | ||||
return JsonMsg<string>.OK("success!",st); | |||||
return JsonMsg<string>.OK("success!", st); | |||||
} | } | ||||
} | } | ||||
catch (System.Exception ex) | |||||
catch (Exception ex) | |||||
{ | { | ||||
return JsonMsg<string>.Error(null,st,ex.Message); | |||||
return JsonMsg<string>.Error(null, st, ex.Message); | |||||
} | } | ||||
} | } | ||||
} | } |
@@ -1,17 +1,17 @@ | |||||
using Microsoft.AspNetCore.Mvc; | |||||
using DataVAPI.Model; | |||||
using DataVAPI.Tool.IOT; | |||||
using DataVAPI.Tool.控制台显示; | |||||
using Microsoft.AspNetCore.Mvc; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Net.Http; | using System.Net.Http; | ||||
using System.Text; | using System.Text; | ||||
using 服务API.Model; | |||||
using 服务API.Tool.IOT; | |||||
using 服务API.Tool.控制台显示; | |||||
namespace 服务API.Controllers | |||||
namespace DataVAPI.Controllers | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 老IOT设备查询API接口 | /// 老IOT设备查询API接口 | ||||
/// </summary> | /// </summary> | ||||
public class IOTDeviceController :BaseController | |||||
public class IOTDeviceController : BaseController | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 根据设备名称查询设备状态 | /// 根据设备名称查询设备状态 | ||||
@@ -25,20 +25,20 @@ namespace 服务API.Controllers | |||||
{ | { | ||||
if (string.IsNullOrEmpty(name)) | if (string.IsNullOrEmpty(name)) | ||||
{ | { | ||||
return JsonMsg<ReceiveModel>.Error(null,st,"设备名称不能为空"); ; | |||||
return JsonMsg<ReceiveModel>.Error(null, st, "设备名称不能为空"); ; | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
//DataVModel dataV = SqlContext<DataVModel>.Base.GetInfo(name); | //DataVModel dataV = SqlContext<DataVModel>.Base.GetInfo(name); | ||||
//return JsonMsg<ReceiveModel>.OK(Tools.JsonToObjectTools<ReceiveModel>(dataV?.json),st); | //return JsonMsg<ReceiveModel>.OK(Tools.JsonToObjectTools<ReceiveModel>(dataV?.json),st); | ||||
return JsonMsg<ReceiveModel>.Error(null,st,"设备名称不能为空"); ; | |||||
return JsonMsg<ReceiveModel>.Error(null, st, "设备名称不能为空"); ; | |||||
} | } | ||||
} | } | ||||
catch (System.Exception ex) | catch (System.Exception ex) | ||||
{ | { | ||||
return JsonMsg<ReceiveModel>.Error(null,ex.Message); | |||||
return JsonMsg<ReceiveModel>.Error(null, ex.Message); | |||||
} | } | ||||
} | } | ||||
@@ -52,25 +52,25 @@ namespace 服务API.Controllers | |||||
try | try | ||||
{ | { | ||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(Tools.JsonConvertTools<CommandModel>(usersModel),Encoding.GetEncoding("UTF-8"),"application/json") }; | |||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(Tools.JsonConvertTools<CommandModel>(usersModel), Encoding.GetEncoding("UTF-8"), "application/json") }; | |||||
if (usersModel == null || string.IsNullOrEmpty(usersModel.deviceName)) | if (usersModel == null || string.IsNullOrEmpty(usersModel.deviceName)) | ||||
{ | { | ||||
return JsonMsg<CommandModel>.Error(null,st,"设备名称不能为空"); ; | |||||
return JsonMsg<CommandModel>.Error(null, st, "设备名称不能为空"); ; | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
string PubTopic = "/broadcast/" + "grgpECHSL7q" + "/" + usersModel.deviceName + "_SetDevice"; | string PubTopic = "/broadcast/" + "grgpECHSL7q" + "/" + usersModel.deviceName + "_SetDevice"; | ||||
ConsoleHelper.WriteWarningLine("发送数据 " + PubTopic + Tools.JsonConvertTools<CommandModel>(usersModel)); | ConsoleHelper.WriteWarningLine("发送数据 " + PubTopic + Tools.JsonConvertTools<CommandModel>(usersModel)); | ||||
IOTDevServer.GetInstance().IOT_Publish(PubTopic,Tools.JsonConvertTools<CommandModel>(usersModel)); | |||||
return JsonMsg<CommandModel>.OK(usersModel,st); | |||||
IOTDevServer.GetInstance().IOT_Publish(PubTopic, Tools.JsonConvertTools<CommandModel>(usersModel)); | |||||
return JsonMsg<CommandModel>.OK(usersModel, st); | |||||
} | } | ||||
} | } | ||||
catch (System.Exception ex) | catch (System.Exception ex) | ||||
{ | { | ||||
return JsonMsg<CommandModel>.Error(null,st,ex.Message); ; | |||||
return JsonMsg<CommandModel>.Error(null, st, ex.Message); ; | |||||
} | } | ||||
} | } | ||||
@@ -83,30 +83,30 @@ namespace 服务API.Controllers | |||||
/// <param name="CommandValue">命令变量:value为值或者消息</param> | /// <param name="CommandValue">命令变量:value为值或者消息</param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
[HttpGet] | [HttpGet] | ||||
public JsonMsg<CommandModel> SetDeviceProperty(string deviceName,int CommandName,string CommandKey,string CommandValue) | |||||
public JsonMsg<CommandModel> SetDeviceProperty(string deviceName, int CommandName, string CommandKey, string CommandValue) | |||||
{ | { | ||||
string st = System.Reflection.MethodBase.GetCurrentMethod().Name; | string st = System.Reflection.MethodBase.GetCurrentMethod().Name; | ||||
try | try | ||||
{ | { | ||||
if (string.IsNullOrEmpty(deviceName)) | if (string.IsNullOrEmpty(deviceName)) | ||||
{ | { | ||||
return JsonMsg<CommandModel>.Error(null,st,"设备名称不能为空"); ; | |||||
return JsonMsg<CommandModel>.Error(null, st, "设备名称不能为空"); ; | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
string PubTopic = "/broadcast/" + "grgpECHSL7q" + "/" + deviceName + "_SetDevice"; | string PubTopic = "/broadcast/" + "grgpECHSL7q" + "/" + deviceName + "_SetDevice"; | ||||
Dictionary<string,string> keyValuePair = new Dictionary<string,string>(); | |||||
keyValuePair.Add(CommandKey,CommandValue); | |||||
CommandModel command = new CommandModel() { CommandName = CommandName,deviceName = deviceName,CommandValue = keyValuePair }; | |||||
Dictionary<string, string> keyValuePair = new Dictionary<string, string>(); | |||||
keyValuePair.Add(CommandKey, CommandValue); | |||||
CommandModel command = new CommandModel() { CommandName = CommandName, deviceName = deviceName, CommandValue = keyValuePair }; | |||||
ConsoleHelper.WriteWarningLine("发送数据 " + PubTopic + Tools.JsonConvertTools<CommandModel>(command)); | ConsoleHelper.WriteWarningLine("发送数据 " + PubTopic + Tools.JsonConvertTools<CommandModel>(command)); | ||||
IOTDevServer.GetInstance().IOT_Publish(PubTopic,Tools.JsonConvertTools<CommandModel>(command)); | |||||
return JsonMsg<CommandModel>.OK(command,st); | |||||
IOTDevServer.GetInstance().IOT_Publish(PubTopic, Tools.JsonConvertTools<CommandModel>(command)); | |||||
return JsonMsg<CommandModel>.OK(command, st); | |||||
} | } | ||||
} | } | ||||
catch (System.Exception ex) | catch (System.Exception ex) | ||||
{ | { | ||||
return JsonMsg<CommandModel>.Error(null,st,ex.Message); ; | |||||
return JsonMsg<CommandModel>.Error(null, st, ex.Message); ; | |||||
} | } | ||||
} | } |
@@ -1,4 +1,4 @@ | |||||
namespace 服务API.DataBus | |||||
namespace DataVAPI | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 数据总线 | /// 数据总线 |
@@ -23,10 +23,10 @@ | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<ProjectReference Include="..\服务API.Model\服务API.Model.csproj" /> | |||||
<ProjectReference Include="..\服务Api.Order\服务Api.Order.csproj" /> | |||||
<ProjectReference Include="..\服务API.ServerDB\服务API.ServerDB.csproj" /> | |||||
<ProjectReference Include="..\服务API.Tools\服务API.Tool.csproj" /> | |||||
<ProjectReference Include="..\DataVAPI.Model\DataVAPI.Model.csproj" /> | |||||
<ProjectReference Include="..\DataVApi.Order\DataVApi.Order.csproj" /> | |||||
<ProjectReference Include="..\DataVAPI.ServerDB\DataVAPI.ServerDB.csproj" /> | |||||
<ProjectReference Include="..\DataVAPI.Tools\DataVAPI.Tool.csproj" /> | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> |
@@ -6,15 +6,14 @@ using Microsoft.Extensions.Configuration; | |||||
using Microsoft.Extensions.Hosting; | using Microsoft.Extensions.Hosting; | ||||
using System; | using System; | ||||
using System.Runtime.InteropServices; | using System.Runtime.InteropServices; | ||||
using 服务API.Tool.控制台显示; | |||||
namespace 服务API | |||||
namespace DataVAPI | |||||
{ | { | ||||
public class Program | public class Program | ||||
{ | { | ||||
public delegate bool ControlCtrlDelegate(int CtrlType); | public delegate bool ControlCtrlDelegate(int CtrlType); | ||||
[DllImport("kernel32.dll")] | [DllImport("kernel32.dll")] | ||||
private static extern bool SetConsoleCtrlHandler(ControlCtrlDelegate HandlerRoutine,bool Add); | |||||
private static extern bool SetConsoleCtrlHandler(ControlCtrlDelegate HandlerRoutine, bool Add); | |||||
private static ControlCtrlDelegate cancelHandler = new ControlCtrlDelegate(HandlerRoutine); | private static ControlCtrlDelegate cancelHandler = new ControlCtrlDelegate(HandlerRoutine); | ||||
public static bool HandlerRoutine(int CtrlType) | public static bool HandlerRoutine(int CtrlType) | ||||
@@ -44,7 +43,8 @@ namespace 服务API | |||||
Host.CreateDefaultBuilder(args).ConfigureWebHostDefaults(webBuilder => | Host.CreateDefaultBuilder(args).ConfigureWebHostDefaults(webBuilder => | ||||
{ | { | ||||
//配置阿波罗 | //配置阿波罗 | ||||
webBuilder.ConfigureAppConfiguration((context,builder) => { | |||||
webBuilder.ConfigureAppConfiguration((context, builder) => | |||||
{ | |||||
builder.AddApolloConfiguration(op => | builder.AddApolloConfiguration(op => | ||||
{ | { | ||||
builder.Build().GetSection(nameof(ApolloOptions)).Bind(op); | builder.Build().GetSection(nameof(ApolloOptions)).Bind(op); |
@@ -1,14 +1,14 @@ | |||||
using DataVApi.Order; | |||||
using DataVAPI.AppConfig; | |||||
using DataVAPI.ConfigureSwagger; | |||||
using DataVAPI.Tool.控制台显示; | |||||
using Microsoft.AspNetCore.Builder; | using Microsoft.AspNetCore.Builder; | ||||
using Microsoft.AspNetCore.Hosting; | using Microsoft.AspNetCore.Hosting; | ||||
using Microsoft.Extensions.Configuration; | using Microsoft.Extensions.Configuration; | ||||
using Microsoft.Extensions.DependencyInjection; | using Microsoft.Extensions.DependencyInjection; | ||||
using Microsoft.Extensions.Hosting; | using Microsoft.Extensions.Hosting; | ||||
using 服务Api.Order; | |||||
using 服务API.AppConfig; | |||||
using 服务API.ConfigureSwagger; | |||||
using 服务API.Tool.控制台显示; | |||||
namespace 服务API | |||||
namespace DataVAPI | |||||
{ | { | ||||
public class Startup | public class Startup | ||||
{ | { | ||||
@@ -45,7 +45,7 @@ namespace 服务API | |||||
app.UseSwagger(); | app.UseSwagger(); | ||||
//配置Cors | //配置Cors | ||||
app.UseCors("any"); | app.UseCors("any"); | ||||
app.UseSwaggerUI(c => | app.UseSwaggerUI(c => | ||||
{ | { | ||||
c.InjectJavascript($"/swagger/ui/zh_CN.js"); // 加载中文包 | c.InjectJavascript($"/swagger/ui/zh_CN.js"); // 加载中文包 |
@@ -4,7 +4,7 @@ using System.Linq; | |||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
namespace 服务Api.Order.Dto | |||||
namespace DataVApi.Order.Dto | |||||
{ | { | ||||
public class LocSaleDto | public class LocSaleDto | ||||
{ | { |
@@ -4,7 +4,7 @@ using System.Linq; | |||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
namespace 服务Api.Order.Dto | |||||
namespace DataVApi.Order.Dto | |||||
{ | { | ||||
public class OrderDataStateDto | public class OrderDataStateDto | ||||
{ | { |
@@ -4,7 +4,7 @@ using System.Linq; | |||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
namespace 服务Api.Order.Dto | |||||
namespace DataVApi.Order.Dto | |||||
{ | { | ||||
public class OrderLineDto | public class OrderLineDto | ||||
{ | { |
@@ -4,7 +4,7 @@ using System.Linq; | |||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
namespace 服务Api.Order.Dto | |||||
namespace DataVApi.Order.Dto | |||||
{ | { | ||||
public class OrderNumberDto | public class OrderNumberDto | ||||
{ | { |
@@ -1,14 +1,14 @@ | |||||
using System; | |||||
using DataVApi.Order.Dto; | |||||
using DataVApi.Order.RequestModel; | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Linq; | using System.Linq; | ||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using System.Xml; | using System.Xml; | ||||
using XExten.Advance.HttpFramework.MultiFactory; | using XExten.Advance.HttpFramework.MultiFactory; | ||||
using 服务Api.Order.Dto; | |||||
using 服务Api.Order.RequestModel; | |||||
namespace 服务Api.Order | |||||
namespace DataVApi.Order | |||||
{ | { | ||||
public class OrderProvider : SugarDb | public class OrderProvider : SugarDb | ||||
{ | { | ||||
@@ -113,7 +113,8 @@ WHERE | |||||
/// 区域销售 | /// 区域销售 | ||||
/// </summary> | /// </summary> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
public object GetLocSale() { | |||||
public object GetLocSale() | |||||
{ | |||||
var db = DbContext(); | var db = DbContext(); | ||||
var baiduMap = "http://api.map.baidu.com/geocoder/v2/?ak=3ce7ddfda60046708248ea55e10b1435&callback=renderReverse&location={0}&output=xml"; | var baiduMap = "http://api.map.baidu.com/geocoder/v2/?ak=3ce7ddfda60046708248ea55e10b1435&callback=renderReverse&location={0}&output=xml"; | ||||
@@ -135,12 +136,12 @@ WHERE | |||||
if (http == null) | if (http == null) | ||||
http = IHttpMultiClient.HttpMulti.AddNode(opt => | http = IHttpMultiClient.HttpMulti.AddNode(opt => | ||||
{ | { | ||||
opt.NodePath = String.Format(baiduMap, item.Loc); | |||||
opt.NodePath = string.Format(baiduMap, item.Loc); | |||||
}); | }); | ||||
else | else | ||||
http = http.AddNode(opt => | http = http.AddNode(opt => | ||||
{ | { | ||||
opt.NodePath = String.Format(baiduMap, item.Loc); | |||||
opt.NodePath = string.Format(baiduMap, item.Loc); | |||||
}); | }); | ||||
}); | }); | ||||
XmlDocument doc = new XmlDocument(); | XmlDocument doc = new XmlDocument(); | ||||
@@ -170,7 +171,7 @@ WHERE | |||||
/// 下单数量 | /// 下单数量 | ||||
/// </summary> | /// </summary> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
public object OrderNumber(FullScreenBasic input) | |||||
public object OrderNumber(FullScreenBasic input) | |||||
{ | { | ||||
var db = DbContext(); | var db = DbContext(); | ||||
@@ -4,7 +4,7 @@ using System.Linq; | |||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
namespace 服务Api.Order.RequestModel | |||||
namespace DataVApi.Order.RequestModel | |||||
{ | { | ||||
public class FullScreenBasic | public class FullScreenBasic | ||||
{ | { |
@@ -4,9 +4,9 @@ using System.Linq; | |||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
namespace 服务Api.Order.RequestModel | |||||
namespace DataVApi.Order.RequestModel | |||||
{ | { | ||||
public class FullScreenInput: FullScreenBasic | |||||
public class FullScreenInput : FullScreenBasic | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 开始时间 | /// 开始时间 |
@@ -2,7 +2,7 @@ | |||||
using System; | using System; | ||||
using System.Linq; | using System.Linq; | ||||
namespace 服务Api.Order | |||||
namespace DataVApi.Order | |||||
{ | { | ||||
public class SugarDb | public class SugarDb | ||||
{ | { |
@@ -7,16 +7,16 @@ EXPOSE 80 | |||||
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build | FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build | ||||
WORKDIR /src | WORKDIR /src | ||||
COPY ["NuGet.config", "."] | COPY ["NuGet.config", "."] | ||||
COPY ["服务API/服务API.csproj", "服务API/"] | |||||
RUN dotnet restore "服务API/服务API.csproj" --configfile "NuGet.config" | |||||
COPY ["DataVAPI/DataVAPI.csproj", "DataVAPI/"] | |||||
RUN dotnet restore "DataVAPI/DataVAPI.csproj" --configfile "NuGet.config" | |||||
COPY . . | COPY . . | ||||
WORKDIR "/src/DataV" | WORKDIR "/src/DataV" | ||||
RUN dotnet build "服务API.csproj" -c Release -o /app/build | |||||
RUN dotnet build "DataVAPI.csproj" -c Release -o /app/build | |||||
FROM build AS publish | FROM build AS publish | ||||
RUN dotnet publish "服务API.csproj" -c Release -o /app/publish | |||||
RUN dotnet publish "DataVAPI.csproj" -c Release -o /app/publish | |||||
FROM base AS final | FROM base AS final | ||||
WORKDIR /app | WORKDIR /app | ||||
COPY --from=publish /app/publish . | COPY --from=publish /app/publish . | ||||
ENTRYPOINT ["dotnet", "服务API.dll"] | |||||
ENTRYPOINT ["dotnet", "DataVAPI.dll"] |
@@ -18,7 +18,7 @@ | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<ProjectReference Include="..\服务API.Tools\服务API.Tool.csproj" /> | |||||
<ProjectReference Include="..\DataVAPI.Tools\DataVAPI.Tool.csproj" /> | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> |
@@ -1,6 +1,8 @@ | |||||
using AduSkin.Controls.Metro; | using AduSkin.Controls.Metro; | ||||
using IOT.Help.Model; | |||||
using IOT.Help.ViewModel; | |||||
using DataVAPI.Tool.API请求; | |||||
using DataVAPI.Tool.IOT; | |||||
using DataVIOT.Help.Model; | |||||
using DataVIOT.Help.ViewModel; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Collections.ObjectModel; | using System.Collections.ObjectModel; | ||||
using System.IO; | using System.IO; | ||||
@@ -8,8 +10,6 @@ using System.Linq; | |||||
using System.Windows; | using System.Windows; | ||||
using System.Windows.Controls; | using System.Windows.Controls; | ||||
using System.Windows.Input; | using System.Windows.Input; | ||||
using 服务API.Tool.API请求; | |||||
using 服务API.Tool.IOT; | |||||
namespace IOT.Help | namespace IOT.Help | ||||
{ | { | ||||
@@ -4,7 +4,7 @@ using System.Linq; | |||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
namespace IOT.Help.Model | |||||
namespace DataVIOT.Help.Model | |||||
{ | { | ||||
public class Carouselname | public class Carouselname | ||||
{ | { | ||||
@@ -1,14 +1,14 @@ | |||||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||||
using DataVAPI.Tool.API请求; | |||||
using DataVAPI.Tool.IOT; | |||||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Collections.ObjectModel; | using System.Collections.ObjectModel; | ||||
using System.Linq; | using System.Linq; | ||||
using 服务API.Tool.API请求; | |||||
using 服务API.Tool.IOT; | |||||
namespace IOT.Help.ViewModel | |||||
namespace DataVIOT.Help.ViewModel | |||||
{ | { | ||||
public class MainViewModel :ObservableObject | |||||
public class MainViewModel : ObservableObject | |||||
{ | { | ||||
#region 公有变量 | #region 公有变量 | ||||
/// <summary> | /// <summary> | ||||
@@ -67,7 +67,7 @@ namespace IOT.Help.ViewModel | |||||
public MainViewModel() | public MainViewModel() | ||||
{ | { | ||||
deviceTable = new ObservableCollection<DeviceTable>(); | deviceTable = new ObservableCollection<DeviceTable>(); | ||||
device=new DeviceTable(); | |||||
device = new DeviceTable(); | |||||
deviceTableSelectedItem = new DeviceTable(); | deviceTableSelectedItem = new DeviceTable(); | ||||
//Refresh(); | //Refresh(); | ||||
} | } | ||||
@@ -82,7 +82,8 @@ namespace IOT.Help.ViewModel | |||||
public void Refresh() | public void Refresh() | ||||
{ | { | ||||
deviceTable.Clear(); | deviceTable.Clear(); | ||||
Inquire()?.OrderBy(o=>int.Parse(o.ClientId)).ToList().ForEach(d => { | |||||
Inquire()?.OrderBy(o => int.Parse(o.ClientId)).ToList().ForEach(d => | |||||
{ | |||||
deviceTable.Add(d); | deviceTable.Add(d); | ||||
}); | }); | ||||
} | } | ||||
@@ -91,12 +92,12 @@ namespace IOT.Help.ViewModel | |||||
/// 根据客户端iD查询 | /// 根据客户端iD查询 | ||||
/// </summary> | /// </summary> | ||||
/// <param name="clientId"></param> | /// <param name="clientId"></param> | ||||
public List<DeviceTable> Inquire(string clientId="") | |||||
public List<DeviceTable> Inquire(string clientId = "") | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
string url = ApiURL + "/api/Device/Query"; | string url = ApiURL + "/api/Device/Query"; | ||||
if (!string.IsNullOrEmpty(clientId)) url = ApiURL + "/api/Device/Query?clientId="+clientId; | |||||
if (!string.IsNullOrEmpty(clientId)) url = ApiURL + "/api/Device/Query?clientId=" + clientId; | |||||
string json = HttpRequestHelper.HttpGetRequest(url); | string json = HttpRequestHelper.HttpGetRequest(url); | ||||
JsonMsg<List<DeviceTable>> jsonMsg = Tools.JsonToObjectTools<JsonMsg<List<DeviceTable>>>(json); | JsonMsg<List<DeviceTable>> jsonMsg = Tools.JsonToObjectTools<JsonMsg<List<DeviceTable>>>(json); | ||||
return jsonMsg.obj; | return jsonMsg.obj; | ||||
@@ -117,7 +118,7 @@ namespace IOT.Help.ViewModel | |||||
try | try | ||||
{ | { | ||||
string url = ApiURL + "/api/Device/Modify"; | string url = ApiURL + "/api/Device/Modify"; | ||||
string json = HttpRequestHelper.HttpPostRequest(url,Tools.JsonConvertTools(device)); | |||||
string json = HttpRequestHelper.HttpPostRequest(url, Tools.JsonConvertTools(device)); | |||||
Refresh(); | Refresh(); | ||||
return true; | return true; | ||||
} | } | ||||
@@ -137,7 +138,7 @@ namespace IOT.Help.ViewModel | |||||
try | try | ||||
{ | { | ||||
string url = ApiURL + "/api/Device/Create"; | string url = ApiURL + "/api/Device/Create"; | ||||
string json = HttpRequestHelper.HttpPostRequest(url,Tools.JsonConvertTools(device)); | |||||
string json = HttpRequestHelper.HttpPostRequest(url, Tools.JsonConvertTools(device)); | |||||
Refresh(); | Refresh(); | ||||
return true; | return true; | ||||
} | } | ||||
@@ -153,7 +154,7 @@ namespace IOT.Help.ViewModel | |||||
try | try | ||||
{ | { | ||||
string url = ApiURL + "/api/Device/Create"; | string url = ApiURL + "/api/Device/Create"; | ||||
string json = HttpRequestHelper.HttpPostRequest(url,Tools.JsonConvertTools(deviceTable)); | |||||
string json = HttpRequestHelper.HttpPostRequest(url, Tools.JsonConvertTools(deviceTable)); | |||||
Refresh(); | Refresh(); | ||||
return true; | return true; | ||||
} | } | ||||
@@ -172,7 +173,7 @@ namespace IOT.Help.ViewModel | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
string url = ApiURL + "/api/Device/DeleteDate?id="+ device.IdStr; | |||||
string url = ApiURL + "/api/Device/DeleteDate?id=" + device.IdStr; | |||||
string json = HttpRequestHelper.HttpGetRequest(url); | string json = HttpRequestHelper.HttpGetRequest(url); | ||||
Refresh(); | Refresh(); | ||||
return true; | return true; | ||||
@@ -1,61 +0,0 @@ | |||||
| |||||
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}") = "服务API", "服务API\服务API.csproj", "{0F350854-541C-41B9-8B5C-788384E293E5}" | |||||
EndProject | |||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "服务API.Model", "服务API.Model\服务API.Model.csproj", "{6338B18D-A3B2-4458-AB7C-756CBE23A574}" | |||||
EndProject | |||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "服务API.ProcessServices", "服务API.ProcessServices\服务API.ProcessServices.csproj", "{C7F090EE-AA2D-4ABB-B301-00443C2D062B}" | |||||
EndProject | |||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "服务API.Tool", "服务API.Tools\服务API.Tool.csproj", "{9A7B217F-7038-4CD1-ABC3-D0F3B92D9297}" | |||||
EndProject | |||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "服务API.ServerDB", "服务API.ServerDB\服务API.ServerDB.csproj", "{B32B6FE9-E40F-4461-8AD0-364B63C12E4B}" | |||||
EndProject | |||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "服务Api.Order", "服务Api.Order\服务Api.Order.csproj", "{76E3E5FA-F2B6-48E8-81DA-397E84A2C76B}" | |||||
EndProject | |||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IOT.Help", "IOT.Help\IOT.Help.csproj", "{302A05E0-4AA1-4655-AE4B-0826B2C55EB9}" | |||||
EndProject | |||||
Global | |||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | |||||
Debug|Any CPU = Debug|Any CPU | |||||
Release|Any CPU = Release|Any CPU | |||||
EndGlobalSection | |||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | |||||
{0F350854-541C-41B9-8B5C-788384E293E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||||
{0F350854-541C-41B9-8B5C-788384E293E5}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||||
{0F350854-541C-41B9-8B5C-788384E293E5}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||||
{0F350854-541C-41B9-8B5C-788384E293E5}.Release|Any CPU.Build.0 = Release|Any CPU | |||||
{6338B18D-A3B2-4458-AB7C-756CBE23A574}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||||
{6338B18D-A3B2-4458-AB7C-756CBE23A574}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||||
{6338B18D-A3B2-4458-AB7C-756CBE23A574}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||||
{6338B18D-A3B2-4458-AB7C-756CBE23A574}.Release|Any CPU.Build.0 = Release|Any CPU | |||||
{C7F090EE-AA2D-4ABB-B301-00443C2D062B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||||
{C7F090EE-AA2D-4ABB-B301-00443C2D062B}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||||
{C7F090EE-AA2D-4ABB-B301-00443C2D062B}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||||
{C7F090EE-AA2D-4ABB-B301-00443C2D062B}.Release|Any CPU.Build.0 = Release|Any CPU | |||||
{9A7B217F-7038-4CD1-ABC3-D0F3B92D9297}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||||
{9A7B217F-7038-4CD1-ABC3-D0F3B92D9297}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||||
{9A7B217F-7038-4CD1-ABC3-D0F3B92D9297}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||||
{9A7B217F-7038-4CD1-ABC3-D0F3B92D9297}.Release|Any CPU.Build.0 = Release|Any CPU | |||||
{B32B6FE9-E40F-4461-8AD0-364B63C12E4B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||||
{B32B6FE9-E40F-4461-8AD0-364B63C12E4B}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||||
{B32B6FE9-E40F-4461-8AD0-364B63C12E4B}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||||
{B32B6FE9-E40F-4461-8AD0-364B63C12E4B}.Release|Any CPU.Build.0 = Release|Any CPU | |||||
{76E3E5FA-F2B6-48E8-81DA-397E84A2C76B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||||
{76E3E5FA-F2B6-48E8-81DA-397E84A2C76B}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||||
{76E3E5FA-F2B6-48E8-81DA-397E84A2C76B}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||||
{76E3E5FA-F2B6-48E8-81DA-397E84A2C76B}.Release|Any CPU.Build.0 = Release|Any CPU | |||||
{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 | |||||
EndGlobalSection | |||||
GlobalSection(SolutionProperties) = preSolution | |||||
HideSolutionNode = FALSE | |||||
EndGlobalSection | |||||
GlobalSection(ExtensibilityGlobals) = postSolution | |||||
SolutionGuid = {5E3567E1-6440-428F-A2E2-A7CF6A1EF45A} | |||||
EndGlobalSection | |||||
EndGlobal |