提交项目
This commit is contained in:
parent
970af5ef29
commit
8c9db76823
|
@ -0,0 +1,25 @@
|
||||||
|
**/.classpath
|
||||||
|
**/.dockerignore
|
||||||
|
**/.env
|
||||||
|
**/.git
|
||||||
|
**/.gitignore
|
||||||
|
**/.project
|
||||||
|
**/.settings
|
||||||
|
**/.toolstarget
|
||||||
|
**/.vs
|
||||||
|
**/.vscode
|
||||||
|
**/*.*proj.user
|
||||||
|
**/*.dbmdl
|
||||||
|
**/*.jfm
|
||||||
|
**/azds.yaml
|
||||||
|
**/bin
|
||||||
|
**/charts
|
||||||
|
**/docker-compose*
|
||||||
|
**/Dockerfile*
|
||||||
|
**/node_modules
|
||||||
|
**/npm-debug.log
|
||||||
|
**/obj
|
||||||
|
**/secrets.dev.yaml
|
||||||
|
**/values.dev.yaml
|
||||||
|
LICENSE
|
||||||
|
README.md
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<configSections>
|
||||||
|
|
||||||
|
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
|
||||||
|
|
||||||
|
</configSections>
|
||||||
|
<log4net>
|
||||||
|
<root>
|
||||||
|
<level value="ALL" />
|
||||||
|
<appender-ref ref="SysAppender" />
|
||||||
|
</root>
|
||||||
|
<logger name="WebLogger">
|
||||||
|
<level value="DEBUG" />
|
||||||
|
</logger>
|
||||||
|
<appender name="SysAppender" type="log4net.Appender.RollingFileAppender,log4net">
|
||||||
|
<param name="File" value="App_Data/" />
|
||||||
|
<param name="AppendToFile" value="true" />
|
||||||
|
<param name="RollingStyle" value="Date" />
|
||||||
|
<param name="DatePattern" value=""Logs_"yyyyMMdd".txt"" />
|
||||||
|
<param name="StaticLogFileName" value="false" />
|
||||||
|
<layout type="log4net.Layout.PatternLayout,log4net">
|
||||||
|
<param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n" />
|
||||||
|
<param name="Header" value=" ------------------------------------------------
" />
|
||||||
|
<param name="Footer" value=" ------------------------------------------------
" />
|
||||||
|
</layout>
|
||||||
|
</appender>
|
||||||
|
<appender name="consoleApp" type="log4net.Appender.ConsoleAppender,log4net">
|
||||||
|
<layout type="log4net.Layout.PatternLayout,log4net">
|
||||||
|
<param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n" />
|
||||||
|
</layout>
|
||||||
|
</appender>
|
||||||
|
</log4net>
|
||||||
|
</configuration>
|
|
@ -0,0 +1,29 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="HslCommunication" Version="12.3.0" />
|
||||||
|
<PackageReference Include="log4net" Version="2.0.15" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
|
||||||
|
<PackageReference Include="System.Text.Encoding.CodePages" Version="9.0.5" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Gather.Mysql\Gather.Mysql.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Update="App.config">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Update="appsettings.json">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<_LastSelectedProfileId>F:\项目\苏州站房\项目\suzhou-iot-service\DataAcquisition\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,23 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DataAcquisition.Model
|
||||||
|
{
|
||||||
|
public class DeviceInfo
|
||||||
|
{
|
||||||
|
public long Id { get; set; }
|
||||||
|
public string DeviceNoHost { get; set; }
|
||||||
|
public string DeviceNoFollow { get; set; }
|
||||||
|
public string DeviceName { get; set; }
|
||||||
|
public string IpAddress { get; set; }
|
||||||
|
public int Port { get; set; } = 502;
|
||||||
|
public byte Station { get; set; } = 1;
|
||||||
|
public int AcquisitionFrequency { get; set; } = 1000;
|
||||||
|
public List<ModbusPoint> Points { get; set; } = new List<ModbusPoint>();
|
||||||
|
|
||||||
|
public int MaxConnections = 1;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DataAcquisition.Model
|
||||||
|
{
|
||||||
|
public class ModbusPoint
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string EnglishName { get; set; }
|
||||||
|
public string Address { get; set; } = "0";
|
||||||
|
public string FunctionCode { get; set; } = "03";
|
||||||
|
public string Pattern { get; set; } = "R";
|
||||||
|
public string DataType { get; set; } = "ushort";
|
||||||
|
public string ByteOrder { get; set; } = "ABCD";
|
||||||
|
public float Magnification { get; set; } = 1.0f;
|
||||||
|
|
||||||
|
// 是否按位读取
|
||||||
|
public string IsBitRead { get; set; } = "0";
|
||||||
|
// 位索引(0 - 7)
|
||||||
|
public int BitIndex { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否是故障点 1是 0否
|
||||||
|
/// </summary>
|
||||||
|
public string FaultPoint { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否是报警点 1是 0否
|
||||||
|
/// </summary>
|
||||||
|
public string AlarmPoint { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 最大值
|
||||||
|
/// </summary>
|
||||||
|
public string MaxValue { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 最小值
|
||||||
|
/// </summary>
|
||||||
|
public string MinValue { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 范围 0:范围内 1:范围外
|
||||||
|
/// </summary>
|
||||||
|
public string Range { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 首地址是否从0开始,1:是 0:否
|
||||||
|
/// </summary>
|
||||||
|
public string StartAddressFromZero { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
using log4net.Config;
|
||||||
|
using log4net;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using System.Text;
|
||||||
|
using log4net.Repository;
|
||||||
|
|
||||||
|
namespace DataAcquisition
|
||||||
|
{
|
||||||
|
internal class Program
|
||||||
|
{
|
||||||
|
static ILoggerRepository LoggerRepository;
|
||||||
|
|
||||||
|
static ILog log;
|
||||||
|
|
||||||
|
static IConfigurationRoot configuration;
|
||||||
|
|
||||||
|
static async Task Main(string[] args)
|
||||||
|
{
|
||||||
|
LoggerRepository = LogManager.CreateRepository("DataAcquisition");
|
||||||
|
XmlConfigurator.ConfigureAndWatch(LoggerRepository, new FileInfo("App.config"));
|
||||||
|
log = LogManager.GetLogger(LoggerRepository.Name, typeof(Program));
|
||||||
|
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||||
|
|
||||||
|
// 授权示例 调用一次即可 call only once
|
||||||
|
if (!HslCommunication.Authorization.SetAuthorizationCode("d8868ab9-4494-4056-98c6-b669e2434e25"))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
configuration = new ConfigurationBuilder()
|
||||||
|
.SetBasePath(Directory.GetCurrentDirectory())
|
||||||
|
.AddJsonFile(path: "appsettings.json", optional: true, reloadOnChange: true)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var connectionString = configuration.GetConnectionString("ConnectionString");
|
||||||
|
using (var collector = new ModbusDataCollector(connectionString))
|
||||||
|
{
|
||||||
|
// 订阅日志事件
|
||||||
|
collector.LogMessage += (sender, message) => { Console.WriteLine(message); log.Info(message); };
|
||||||
|
|
||||||
|
// 初始化并启动采集
|
||||||
|
await collector.InitializeAsync();
|
||||||
|
|
||||||
|
// 模拟运行一段时间后刷新配置
|
||||||
|
await Task.Delay(TimeSpan.FromMinutes(30));
|
||||||
|
Console.WriteLine("正在刷新设备配置...");
|
||||||
|
await collector.RefreshDevicesAsync();
|
||||||
|
|
||||||
|
Console.WriteLine("按任意键退出...");
|
||||||
|
Console.ReadKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Console.WriteLine("启动服务");
|
||||||
|
//log.Info("启动服务");
|
||||||
|
|
||||||
|
//Console.ReadKey();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- https://go.microsoft.com/fwlink/?LinkID=208121. -->
|
||||||
|
<Project>
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Any CPU</Platform>
|
||||||
|
<PublishDir>bin\Release\net6.0\publish\</PublishDir>
|
||||||
|
<PublishProtocol>FileSystem</PublishProtocol>
|
||||||
|
<_TargetId>Folder</_TargetId>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- https://go.microsoft.com/fwlink/?LinkID=208121. -->
|
||||||
|
<Project>
|
||||||
|
<PropertyGroup>
|
||||||
|
<History>True|2025-06-09T02:27:00.8967484Z||;</History>
|
||||||
|
<LastFailureDetails />
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"ConnectionStrings": {
|
||||||
|
"ConStringEncrypt": "false",
|
||||||
|
"ConnectionString": "server=127.0.0.1;port=3306;userid=root;password=Unity3du#d112233;database=suzhou_iot_db;"
|
||||||
|
//"ConnectionString": "server=172.16.1.162;port=33061;userid=root;password=p@ssw0rd;database=suzhou_iot_db;"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,69 @@
|
||||||
|
using Gather.IBLL;
|
||||||
|
using Gather.IDAL;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Gather.BLL
|
||||||
|
{
|
||||||
|
public class BaseService<T, TKey> : IBaseService<T, TKey> where T : class
|
||||||
|
{
|
||||||
|
private readonly IBaseRepository<T, TKey> _repository;
|
||||||
|
public BaseService(IBaseRepository<T, TKey> repository)
|
||||||
|
{
|
||||||
|
_repository = repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public T Find(TKey id)
|
||||||
|
{
|
||||||
|
return _repository.Find(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public T Find(Expression<Func<T, bool>> wherelamb)
|
||||||
|
{
|
||||||
|
return _repository.Find(wherelamb);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IQueryable<T> LoadEntities(Expression<Func<T, bool>> whereLambda)
|
||||||
|
{
|
||||||
|
return _repository.LoadEntities(whereLambda);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IQueryable<T> LoadPageEntities<S>(int pageSize, int pageIndex, out int total, Expression<Func<T, bool>> whereLambda, Expression<Func<T, S>> orderbyLambda, bool isAsc)
|
||||||
|
{
|
||||||
|
return _repository.LoadPageEntities(pageSize, pageIndex, out total, whereLambda, orderbyLambda, isAsc);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int SaveChange()
|
||||||
|
{
|
||||||
|
return _repository.SaveChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Update(T entity, bool isSaveChage = true)
|
||||||
|
{
|
||||||
|
return _repository.Update(entity, isSaveChage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Add(T entity, bool isSaveChage = true)
|
||||||
|
{
|
||||||
|
return _repository.Add(entity, isSaveChage = true);
|
||||||
|
}
|
||||||
|
public int Delete(T entity, bool isSaveChage = true)
|
||||||
|
{
|
||||||
|
return _repository.Delete(entity, isSaveChage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Delete(params int[] ids)
|
||||||
|
{
|
||||||
|
return _repository.Delete(ids);
|
||||||
|
}
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
_repository.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="SYSTEM\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Gather.IBLL\Gather.IBLL.csproj" />
|
||||||
|
<ProjectReference Include="..\Gather.IDAL\Gather.IDAL.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
|
@ -0,0 +1,20 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||||
|
<PackageReference Include="Portable.BouncyCastle" Version="1.9.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="zKeyAccess">
|
||||||
|
<HintPath>..\packages\zKeyAccess.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
|
@ -0,0 +1,26 @@
|
||||||
|
namespace Gather.Common
|
||||||
|
{
|
||||||
|
public class GridPager
|
||||||
|
{
|
||||||
|
public int rows { get; set; }//每页行数
|
||||||
|
public int page { get; set; }//当前页是第几页
|
||||||
|
public string order { get; set; }//排序方式
|
||||||
|
public string sort { get; set; }//排序列
|
||||||
|
public int totalRows { get; set; }//总行数
|
||||||
|
public int totalPages //总页数
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return (int)Math.Ceiling((float)totalRows / (float)rows);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public string filterRules { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class GridRows<T>
|
||||||
|
{
|
||||||
|
public List<T> rows { get; set; }
|
||||||
|
public int total { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,85 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Reflection.Emit;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Gather.Common.Util
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 接口状态码
|
||||||
|
/// </summary>
|
||||||
|
public enum APICode
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 成功
|
||||||
|
/// </summary>
|
||||||
|
Success = 200,
|
||||||
|
/// <summary>
|
||||||
|
/// 失败
|
||||||
|
/// </summary>
|
||||||
|
Fail = 500,
|
||||||
|
/// <summary>
|
||||||
|
/// token失效
|
||||||
|
/// </summary>
|
||||||
|
TokenFail
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 工具类
|
||||||
|
/// </summary>
|
||||||
|
public class Tool
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取带状态码的JSON字符串
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="code"></param>
|
||||||
|
/// <param name="dataObj"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static object GetJsonWithCode(APICode code, object dataObj)
|
||||||
|
{
|
||||||
|
return new { code = (int)code, msg = code.ToString(), data = dataObj };
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get请求
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="post_url">请求地址</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string get_page(string post_url)
|
||||||
|
{
|
||||||
|
Stream instream = null;
|
||||||
|
StreamReader sr = null;
|
||||||
|
HttpWebResponse response = null;
|
||||||
|
HttpWebRequest request = null;
|
||||||
|
Encoding encoding = Encoding.UTF8;
|
||||||
|
// 准备请求...
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 设置参数
|
||||||
|
request = WebRequest.Create(post_url) as HttpWebRequest;
|
||||||
|
CookieContainer cookieContainer = new CookieContainer();
|
||||||
|
request.CookieContainer = cookieContainer;
|
||||||
|
request.AllowAutoRedirect = true;
|
||||||
|
request.Timeout = 10000;
|
||||||
|
//默认值TimeOut:100 秒
|
||||||
|
//发送请求并获取相应回应数据
|
||||||
|
response = request.GetResponse() as HttpWebResponse;
|
||||||
|
//直到request.GetResponse()程序才开始向目标网页发送Post请求
|
||||||
|
instream = response.GetResponseStream();
|
||||||
|
sr = new StreamReader(instream, encoding);
|
||||||
|
//返回结果网页(html)代码
|
||||||
|
string content = sr.ReadToEnd();
|
||||||
|
string err = string.Empty;
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return ex.Message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,127 @@
|
||||||
|
using Gather.IDAL;
|
||||||
|
using Gather.Model;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
|
||||||
|
namespace Gather.DAL
|
||||||
|
{
|
||||||
|
public class BaseRepository<T, TKey> : IBaseRepository<T, TKey> where T : class
|
||||||
|
{
|
||||||
|
private Gather_dbContext _context;
|
||||||
|
|
||||||
|
protected bool disposedValue;
|
||||||
|
|
||||||
|
public BaseRepository(Gather_dbContext context)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
|
||||||
|
}
|
||||||
|
public T Find(TKey id)
|
||||||
|
{
|
||||||
|
return _context.Set<T>().Find(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public T Find(Expression<Func<T, bool>> wherelamb)
|
||||||
|
{
|
||||||
|
return _context.Set<T>().Where(wherelamb).AsNoTracking().FirstOrDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual bool Update(T entity, bool isSaveChage = true)
|
||||||
|
{
|
||||||
|
_context.Entry(entity).State = EntityState.Modified;
|
||||||
|
if (isSaveChage)
|
||||||
|
{
|
||||||
|
SaveChange();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual int Delete(T entity, bool isSaveChage = true)
|
||||||
|
{
|
||||||
|
int row = 0;
|
||||||
|
_context.Entry(entity).State = EntityState.Deleted;
|
||||||
|
if (isSaveChage)
|
||||||
|
{
|
||||||
|
row = SaveChange();
|
||||||
|
}
|
||||||
|
return row;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual int Delete(params int[] ids)
|
||||||
|
{
|
||||||
|
foreach (var item in ids)
|
||||||
|
{
|
||||||
|
var entity = _context.Set<T>().Find(item);
|
||||||
|
_context.Set<T>().Remove(entity);
|
||||||
|
}
|
||||||
|
SaveChange();
|
||||||
|
return ids.Count();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IQueryable<T> LoadEntities(Expression<Func<T, bool>> whereLambda)
|
||||||
|
{
|
||||||
|
return _context.Set<T>().Where(whereLambda).AsQueryable();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IQueryable<T> LoadPageEntities<S>(int pageSize, int pageIndex, out int total, Expression<Func<T, bool>> whereLambda, Expression<Func<T, S>> orderbyLambda, bool isAsc)
|
||||||
|
{
|
||||||
|
total = _context.Set<T>().Where(whereLambda).Count();
|
||||||
|
if (isAsc)
|
||||||
|
{
|
||||||
|
return
|
||||||
|
_context.Set<T>()
|
||||||
|
.Where(whereLambda)
|
||||||
|
.OrderBy(orderbyLambda)
|
||||||
|
.Skip(pageSize * (pageIndex - 1))
|
||||||
|
.Take(pageSize)
|
||||||
|
.AsQueryable();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return
|
||||||
|
_context.Set<T>()
|
||||||
|
.Where(whereLambda)
|
||||||
|
.OrderByDescending(orderbyLambda)
|
||||||
|
.Skip(pageSize * (pageIndex - 1))
|
||||||
|
.Take(pageSize)
|
||||||
|
.AsQueryable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (!disposedValue)
|
||||||
|
{
|
||||||
|
if (disposing)
|
||||||
|
{
|
||||||
|
_context?.Dispose();
|
||||||
|
}
|
||||||
|
disposedValue = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Dispose(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Add(T entity, bool isSaveChage = true)
|
||||||
|
{
|
||||||
|
int row = 0;
|
||||||
|
_context.Set<T>().Add(entity);
|
||||||
|
if (isSaveChage)
|
||||||
|
{
|
||||||
|
row = SaveChange();
|
||||||
|
}
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int SaveChange()
|
||||||
|
{
|
||||||
|
return _context.SaveChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="SYSTEM\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.22" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Gather.IDAL\Gather.IDAL.csproj" />
|
||||||
|
<ProjectReference Include="..\Gather.Model\Gather.Model.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
|
@ -0,0 +1,17 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="SYSTEM\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Gather.IDAL\Gather.IDAL.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
|
@ -0,0 +1,9 @@
|
||||||
|
using Gather.IDAL;
|
||||||
|
|
||||||
|
namespace Gather.IBLL
|
||||||
|
{
|
||||||
|
public interface IBaseService<T, TKey> : IBaseRepository<T, TKey> where T : class
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="SYSTEM\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
|
@ -0,0 +1,18 @@
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
|
||||||
|
namespace Gather.IDAL
|
||||||
|
{
|
||||||
|
public interface IBaseRepository<T, TKey> : IDisposable where T : class
|
||||||
|
{
|
||||||
|
T Find(TKey id);
|
||||||
|
T Find(Expression<Func<T, bool>> wherelamb);
|
||||||
|
int Add(T entity, bool isSaveChage = true);
|
||||||
|
bool Update(T entity, bool isSaveChage = true);
|
||||||
|
int Delete(T entity, bool isSaveChage = true);
|
||||||
|
int Delete(params int[] ids);
|
||||||
|
IQueryable<T> LoadEntities(Expression<Func<T, bool>> whereLambda);
|
||||||
|
IQueryable<T> LoadPageEntities<S>(int pageSize, int pageIndex, out int total, Expression<Func<T, bool>> whereLambda, Expression<Func<T, S>> orderbyLambda, bool isAsc);
|
||||||
|
int SaveChange();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.22" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
|
@ -0,0 +1,25 @@
|
||||||
|
using System;
|
||||||
|
using Gather.Model;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Gather.Model
|
||||||
|
{
|
||||||
|
public partial class Gather_dbContext : DbContext
|
||||||
|
{
|
||||||
|
public Gather_dbContext()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public Gather_dbContext(DbContextOptions<Gather_dbContext> options)
|
||||||
|
: base(options)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
///// <summary>
|
||||||
|
///// 全局配置
|
||||||
|
///// </summary>
|
||||||
|
//public virtual DbSet<b_quanjsz> b_quanjsz { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,179 @@
|
||||||
|
/** 版本信息模板在安装目录下,可自行修改。
|
||||||
|
* iot_device.cs
|
||||||
|
*
|
||||||
|
* 功 能: N/A
|
||||||
|
* 类 名: iot_device
|
||||||
|
*
|
||||||
|
* Ver 变更日期 负责人 变更内容
|
||||||
|
* ───────────────────────────────────
|
||||||
|
* V0.01 2025/6/6 9:48:17 N/A 初版
|
||||||
|
*
|
||||||
|
* Copyright (c) 2012 Maticsoft Corporation. All rights reserved.
|
||||||
|
*┌──────────────────────────────────┐
|
||||||
|
*│ 此技术信息为本公司机密信息,未经本公司书面同意禁止向第三方披露. │
|
||||||
|
*│ 版权所有:动软卓越(北京)科技有限公司 │
|
||||||
|
*└──────────────────────────────────┘
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.Data;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Maticsoft.Common;
|
||||||
|
using Gather.Mysql.Model;
|
||||||
|
namespace Gather.Mysql.BLL
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// iot_device
|
||||||
|
/// </summary>
|
||||||
|
public partial class iot_device
|
||||||
|
{
|
||||||
|
private readonly Gather.Mysql.DAL.iot_device dal=new Gather.Mysql.DAL.iot_device();
|
||||||
|
public iot_device()
|
||||||
|
{}
|
||||||
|
#region BasicMethod
|
||||||
|
/// <summary>
|
||||||
|
/// 是否存在该记录
|
||||||
|
/// </summary>
|
||||||
|
public bool Exists(long id)
|
||||||
|
{
|
||||||
|
return dal.Exists(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 增加一条数据
|
||||||
|
/// </summary>
|
||||||
|
public bool Add(Gather.Mysql.Model.iot_device model)
|
||||||
|
{
|
||||||
|
return dal.Add(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新一条数据
|
||||||
|
/// </summary>
|
||||||
|
public bool Update(Gather.Mysql.Model.iot_device model)
|
||||||
|
{
|
||||||
|
return dal.Update(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除一条数据
|
||||||
|
/// </summary>
|
||||||
|
public bool Delete(long id)
|
||||||
|
{
|
||||||
|
|
||||||
|
return dal.Delete(id);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 删除一条数据
|
||||||
|
/// </summary>
|
||||||
|
public bool DeleteList(string idlist )
|
||||||
|
{
|
||||||
|
return dal.DeleteList(idlist );
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 得到一个对象实体
|
||||||
|
/// </summary>
|
||||||
|
public Gather.Mysql.Model.iot_device GetModel(long id)
|
||||||
|
{
|
||||||
|
|
||||||
|
return dal.GetModel(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 得到一个对象实体,从缓存中
|
||||||
|
/// </summary>
|
||||||
|
public Gather.Mysql.Model.iot_device GetModelByCache(long id)
|
||||||
|
{
|
||||||
|
|
||||||
|
string CacheKey = "iot_deviceModel-" + id;
|
||||||
|
object objModel = Maticsoft.Common.DataCache.GetCache(CacheKey);
|
||||||
|
if (objModel == null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
objModel = dal.GetModel(id);
|
||||||
|
if (objModel != null)
|
||||||
|
{
|
||||||
|
int ModelCache = Maticsoft.Common.ConfigHelper.GetConfigInt("ModelCache");
|
||||||
|
Maticsoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch{}
|
||||||
|
}
|
||||||
|
return (Gather.Mysql.Model.iot_device)objModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获得数据列表
|
||||||
|
/// </summary>
|
||||||
|
public DataSet GetList(string strWhere)
|
||||||
|
{
|
||||||
|
return dal.GetList(strWhere);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 获得数据列表
|
||||||
|
/// </summary>
|
||||||
|
public List<Gather.Mysql.Model.iot_device> GetModelList(string strWhere)
|
||||||
|
{
|
||||||
|
DataSet ds = dal.GetList(strWhere);
|
||||||
|
return DataTableToList(ds.Tables[0]);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 获得数据列表
|
||||||
|
/// </summary>
|
||||||
|
public List<Gather.Mysql.Model.iot_device> DataTableToList(DataTable dt)
|
||||||
|
{
|
||||||
|
List<Gather.Mysql.Model.iot_device> modelList = new List<Gather.Mysql.Model.iot_device>();
|
||||||
|
int rowsCount = dt.Rows.Count;
|
||||||
|
if (rowsCount > 0)
|
||||||
|
{
|
||||||
|
Gather.Mysql.Model.iot_device model;
|
||||||
|
for (int n = 0; n < rowsCount; n++)
|
||||||
|
{
|
||||||
|
model = dal.DataRowToModel(dt.Rows[n]);
|
||||||
|
if (model != null)
|
||||||
|
{
|
||||||
|
modelList.Add(model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return modelList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获得数据列表
|
||||||
|
/// </summary>
|
||||||
|
public DataSet GetAllList()
|
||||||
|
{
|
||||||
|
return GetList("");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 分页获取数据列表
|
||||||
|
/// </summary>
|
||||||
|
public int GetRecordCount(string strWhere)
|
||||||
|
{
|
||||||
|
return dal.GetRecordCount(strWhere);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 分页获取数据列表
|
||||||
|
/// </summary>
|
||||||
|
public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
|
||||||
|
{
|
||||||
|
return dal.GetListByPage( strWhere, orderby, startIndex, endIndex);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 分页获取数据列表
|
||||||
|
/// </summary>
|
||||||
|
//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
|
||||||
|
//{
|
||||||
|
//return dal.GetList(PageSize,PageIndex,strWhere);
|
||||||
|
//}
|
||||||
|
|
||||||
|
#endregion BasicMethod
|
||||||
|
#region ExtensionMethod
|
||||||
|
|
||||||
|
#endregion ExtensionMethod
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,179 @@
|
||||||
|
/** 版本信息模板在安装目录下,可自行修改。
|
||||||
|
* iot_function_code_config.cs
|
||||||
|
*
|
||||||
|
* 功 能: N/A
|
||||||
|
* 类 名: iot_function_code_config
|
||||||
|
*
|
||||||
|
* Ver 变更日期 负责人 变更内容
|
||||||
|
* ───────────────────────────────────
|
||||||
|
* V0.01 2025/6/6 13:58:11 N/A 初版
|
||||||
|
*
|
||||||
|
* Copyright (c) 2012 Maticsoft Corporation. All rights reserved.
|
||||||
|
*┌──────────────────────────────────┐
|
||||||
|
*│ 此技术信息为本公司机密信息,未经本公司书面同意禁止向第三方披露. │
|
||||||
|
*│ 版权所有:动软卓越(北京)科技有限公司 │
|
||||||
|
*└──────────────────────────────────┘
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.Data;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Maticsoft.Common;
|
||||||
|
using Gather.Mysql.Model;
|
||||||
|
namespace Gather.Mysql.BLL
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// iot_function_code_config
|
||||||
|
/// </summary>
|
||||||
|
public partial class iot_function_code_config
|
||||||
|
{
|
||||||
|
private readonly Gather.Mysql.DAL.iot_function_code_config dal=new Gather.Mysql.DAL.iot_function_code_config();
|
||||||
|
public iot_function_code_config()
|
||||||
|
{}
|
||||||
|
#region BasicMethod
|
||||||
|
/// <summary>
|
||||||
|
/// 是否存在该记录
|
||||||
|
/// </summary>
|
||||||
|
public bool Exists(long id)
|
||||||
|
{
|
||||||
|
return dal.Exists(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 增加一条数据
|
||||||
|
/// </summary>
|
||||||
|
public bool Add(Gather.Mysql.Model.iot_function_code_config model)
|
||||||
|
{
|
||||||
|
return dal.Add(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新一条数据
|
||||||
|
/// </summary>
|
||||||
|
public bool Update(Gather.Mysql.Model.iot_function_code_config model)
|
||||||
|
{
|
||||||
|
return dal.Update(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除一条数据
|
||||||
|
/// </summary>
|
||||||
|
public bool Delete(long id)
|
||||||
|
{
|
||||||
|
|
||||||
|
return dal.Delete(id);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 删除一条数据
|
||||||
|
/// </summary>
|
||||||
|
public bool DeleteList(string idlist )
|
||||||
|
{
|
||||||
|
return dal.DeleteList(idlist );
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 得到一个对象实体
|
||||||
|
/// </summary>
|
||||||
|
public Gather.Mysql.Model.iot_function_code_config GetModel(long id)
|
||||||
|
{
|
||||||
|
|
||||||
|
return dal.GetModel(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 得到一个对象实体,从缓存中
|
||||||
|
/// </summary>
|
||||||
|
public Gather.Mysql.Model.iot_function_code_config GetModelByCache(long id)
|
||||||
|
{
|
||||||
|
|
||||||
|
string CacheKey = "iot_function_code_configModel-" + id;
|
||||||
|
object objModel = Maticsoft.Common.DataCache.GetCache(CacheKey);
|
||||||
|
if (objModel == null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
objModel = dal.GetModel(id);
|
||||||
|
if (objModel != null)
|
||||||
|
{
|
||||||
|
int ModelCache = Maticsoft.Common.ConfigHelper.GetConfigInt("ModelCache");
|
||||||
|
Maticsoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch{}
|
||||||
|
}
|
||||||
|
return (Gather.Mysql.Model.iot_function_code_config)objModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获得数据列表
|
||||||
|
/// </summary>
|
||||||
|
public DataSet GetList(string strWhere)
|
||||||
|
{
|
||||||
|
return dal.GetList(strWhere);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 获得数据列表
|
||||||
|
/// </summary>
|
||||||
|
public List<Gather.Mysql.Model.iot_function_code_config> GetModelList(string strWhere)
|
||||||
|
{
|
||||||
|
DataSet ds = dal.GetList(strWhere);
|
||||||
|
return DataTableToList(ds.Tables[0]);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 获得数据列表
|
||||||
|
/// </summary>
|
||||||
|
public List<Gather.Mysql.Model.iot_function_code_config> DataTableToList(DataTable dt)
|
||||||
|
{
|
||||||
|
List<Gather.Mysql.Model.iot_function_code_config> modelList = new List<Gather.Mysql.Model.iot_function_code_config>();
|
||||||
|
int rowsCount = dt.Rows.Count;
|
||||||
|
if (rowsCount > 0)
|
||||||
|
{
|
||||||
|
Gather.Mysql.Model.iot_function_code_config model;
|
||||||
|
for (int n = 0; n < rowsCount; n++)
|
||||||
|
{
|
||||||
|
model = dal.DataRowToModel(dt.Rows[n]);
|
||||||
|
if (model != null)
|
||||||
|
{
|
||||||
|
modelList.Add(model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return modelList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获得数据列表
|
||||||
|
/// </summary>
|
||||||
|
public DataSet GetAllList()
|
||||||
|
{
|
||||||
|
return GetList("");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 分页获取数据列表
|
||||||
|
/// </summary>
|
||||||
|
public int GetRecordCount(string strWhere)
|
||||||
|
{
|
||||||
|
return dal.GetRecordCount(strWhere);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 分页获取数据列表
|
||||||
|
/// </summary>
|
||||||
|
public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
|
||||||
|
{
|
||||||
|
return dal.GetListByPage( strWhere, orderby, startIndex, endIndex);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 分页获取数据列表
|
||||||
|
/// </summary>
|
||||||
|
//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
|
||||||
|
//{
|
||||||
|
//return dal.GetList(PageSize,PageIndex,strWhere);
|
||||||
|
//}
|
||||||
|
|
||||||
|
#endregion BasicMethod
|
||||||
|
#region ExtensionMethod
|
||||||
|
|
||||||
|
#endregion ExtensionMethod
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,188 @@
|
||||||
|
/** 版本信息模板在安装目录下,可自行修改。
|
||||||
|
* iot_plc_pt.cs
|
||||||
|
*
|
||||||
|
* 功 能: N/A
|
||||||
|
* 类 名: iot_plc_pt
|
||||||
|
*
|
||||||
|
* Ver 变更日期 负责人 变更内容
|
||||||
|
* ───────────────────────────────────
|
||||||
|
* V0.01 2025/6/14 9:40:01 N/A 初版
|
||||||
|
*
|
||||||
|
* Copyright (c) 2012 Maticsoft Corporation. All rights reserved.
|
||||||
|
*┌──────────────────────────────────┐
|
||||||
|
*│ 此技术信息为本公司机密信息,未经本公司书面同意禁止向第三方披露. │
|
||||||
|
*│ 版权所有:动软卓越(北京)科技有限公司 │
|
||||||
|
*└──────────────────────────────────┘
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.Data;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Maticsoft.Common;
|
||||||
|
using Gather.Mysql.Model;
|
||||||
|
namespace Gather.Mysql.BLL
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// iot_plc_pt
|
||||||
|
/// </summary>
|
||||||
|
public partial class iot_plc_pt
|
||||||
|
{
|
||||||
|
private readonly Gather.Mysql.DAL.iot_plc_pt dal=new Gather.Mysql.DAL.iot_plc_pt();
|
||||||
|
public iot_plc_pt()
|
||||||
|
{}
|
||||||
|
#region BasicMethod
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 得到最大ID
|
||||||
|
/// </summary>
|
||||||
|
public int GetMaxId()
|
||||||
|
{
|
||||||
|
return dal.GetMaxId();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否存在该记录
|
||||||
|
/// </summary>
|
||||||
|
public bool Exists(int id)
|
||||||
|
{
|
||||||
|
return dal.Exists(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 增加一条数据
|
||||||
|
/// </summary>
|
||||||
|
public bool Add(Gather.Mysql.Model.iot_plc_pt model)
|
||||||
|
{
|
||||||
|
return dal.Add(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新一条数据
|
||||||
|
/// </summary>
|
||||||
|
public bool Update(Gather.Mysql.Model.iot_plc_pt model)
|
||||||
|
{
|
||||||
|
return dal.Update(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除一条数据
|
||||||
|
/// </summary>
|
||||||
|
public bool Delete(int id)
|
||||||
|
{
|
||||||
|
|
||||||
|
return dal.Delete(id);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 删除一条数据
|
||||||
|
/// </summary>
|
||||||
|
public bool DeleteList(string idlist )
|
||||||
|
{
|
||||||
|
return dal.DeleteList(idlist );
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 得到一个对象实体
|
||||||
|
/// </summary>
|
||||||
|
public Gather.Mysql.Model.iot_plc_pt GetModel(int id)
|
||||||
|
{
|
||||||
|
|
||||||
|
return dal.GetModel(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 得到一个对象实体,从缓存中
|
||||||
|
/// </summary>
|
||||||
|
public Gather.Mysql.Model.iot_plc_pt GetModelByCache(int id)
|
||||||
|
{
|
||||||
|
|
||||||
|
string CacheKey = "iot_plc_ptModel-" + id;
|
||||||
|
object objModel = Maticsoft.Common.DataCache.GetCache(CacheKey);
|
||||||
|
if (objModel == null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
objModel = dal.GetModel(id);
|
||||||
|
if (objModel != null)
|
||||||
|
{
|
||||||
|
int ModelCache = Maticsoft.Common.ConfigHelper.GetConfigInt("ModelCache");
|
||||||
|
Maticsoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch{}
|
||||||
|
}
|
||||||
|
return (Gather.Mysql.Model.iot_plc_pt)objModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获得数据列表
|
||||||
|
/// </summary>
|
||||||
|
public DataSet GetList(string strWhere)
|
||||||
|
{
|
||||||
|
return dal.GetList(strWhere);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 获得数据列表
|
||||||
|
/// </summary>
|
||||||
|
public List<Gather.Mysql.Model.iot_plc_pt> GetModelList(string strWhere)
|
||||||
|
{
|
||||||
|
DataSet ds = dal.GetList(strWhere);
|
||||||
|
return DataTableToList(ds.Tables[0]);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 获得数据列表
|
||||||
|
/// </summary>
|
||||||
|
public List<Gather.Mysql.Model.iot_plc_pt> DataTableToList(DataTable dt)
|
||||||
|
{
|
||||||
|
List<Gather.Mysql.Model.iot_plc_pt> modelList = new List<Gather.Mysql.Model.iot_plc_pt>();
|
||||||
|
int rowsCount = dt.Rows.Count;
|
||||||
|
if (rowsCount > 0)
|
||||||
|
{
|
||||||
|
Gather.Mysql.Model.iot_plc_pt model;
|
||||||
|
for (int n = 0; n < rowsCount; n++)
|
||||||
|
{
|
||||||
|
model = dal.DataRowToModel(dt.Rows[n]);
|
||||||
|
if (model != null)
|
||||||
|
{
|
||||||
|
modelList.Add(model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return modelList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获得数据列表
|
||||||
|
/// </summary>
|
||||||
|
public DataSet GetAllList()
|
||||||
|
{
|
||||||
|
return GetList("");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 分页获取数据列表
|
||||||
|
/// </summary>
|
||||||
|
public int GetRecordCount(string strWhere)
|
||||||
|
{
|
||||||
|
return dal.GetRecordCount(strWhere);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 分页获取数据列表
|
||||||
|
/// </summary>
|
||||||
|
public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
|
||||||
|
{
|
||||||
|
return dal.GetListByPage( strWhere, orderby, startIndex, endIndex);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 分页获取数据列表
|
||||||
|
/// </summary>
|
||||||
|
//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
|
||||||
|
//{
|
||||||
|
//return dal.GetList(PageSize,PageIndex,strWhere);
|
||||||
|
//}
|
||||||
|
|
||||||
|
#endregion BasicMethod
|
||||||
|
#region ExtensionMethod
|
||||||
|
|
||||||
|
#endregion ExtensionMethod
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,473 @@
|
||||||
|
/** 版本信息模板在安装目录下,可自行修改。
|
||||||
|
* iot_device.cs
|
||||||
|
*
|
||||||
|
* 功 能: N/A
|
||||||
|
* 类 名: iot_device
|
||||||
|
*
|
||||||
|
* Ver 变更日期 负责人 变更内容
|
||||||
|
* ───────────────────────────────────
|
||||||
|
* V0.01 2025/6/6 9:48:17 N/A 初版
|
||||||
|
*
|
||||||
|
* Copyright (c) 2012 Maticsoft Corporation. All rights reserved.
|
||||||
|
*┌──────────────────────────────────┐
|
||||||
|
*│ 此技术信息为本公司机密信息,未经本公司书面同意禁止向第三方披露. │
|
||||||
|
*│ 版权所有:动软卓越(北京)科技有限公司 │
|
||||||
|
*└──────────────────────────────────┘
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.Data;
|
||||||
|
using System.Text;
|
||||||
|
using MySql.Data.MySqlClient;
|
||||||
|
using Maticsoft.DBUtility;//Please add references
|
||||||
|
namespace Gather.Mysql.DAL
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 数据访问类:iot_device
|
||||||
|
/// </summary>
|
||||||
|
public partial class iot_device
|
||||||
|
{
|
||||||
|
public iot_device()
|
||||||
|
{}
|
||||||
|
#region BasicMethod
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否存在该记录
|
||||||
|
/// </summary>
|
||||||
|
public bool Exists(long id)
|
||||||
|
{
|
||||||
|
StringBuilder strSql=new StringBuilder();
|
||||||
|
strSql.Append("select count(1) from iot_device");
|
||||||
|
strSql.Append(" where id=@id");
|
||||||
|
MySqlParameter[] parameters = {
|
||||||
|
new MySqlParameter("@id", MySqlDbType.Int32)
|
||||||
|
};
|
||||||
|
parameters[0].Value = id;
|
||||||
|
|
||||||
|
return DbHelperMySQL.Exists(strSql.ToString(),parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 增加一条数据
|
||||||
|
/// </summary>
|
||||||
|
public bool Add(Gather.Mysql.Model.iot_device model)
|
||||||
|
{
|
||||||
|
StringBuilder strSql=new StringBuilder();
|
||||||
|
strSql.Append("insert into iot_device(");
|
||||||
|
strSql.Append("device_no_host,device_no_follow,device_name,device_type_id,region_id,server_model,service_ip,service_port,station,remark,coordinate_x,coordinate_y,coordinate_z,is_del,creat_by,creat_time,update_by,update_time,panel_type,manual_control_time,acquisition_frequency,sort)");
|
||||||
|
strSql.Append(" values (");
|
||||||
|
strSql.Append("@device_no_host,@device_no_follow,@device_name,@device_type_id,@region_id,@server_model,@service_ip,@service_port,@station,@remark,@coordinate_x,@coordinate_y,@coordinate_z,@is_del,@creat_by,@creat_time,@update_by,@update_time,@panel_type,@manual_control_time,@acquisition_frequency,@sort)");
|
||||||
|
MySqlParameter[] parameters = {
|
||||||
|
new MySqlParameter("@device_no_host", MySqlDbType.VarChar,64),
|
||||||
|
new MySqlParameter("@device_no_follow", MySqlDbType.VarChar,64),
|
||||||
|
new MySqlParameter("@device_name", MySqlDbType.VarChar,64),
|
||||||
|
new MySqlParameter("@device_type_id", MySqlDbType.Int32),
|
||||||
|
new MySqlParameter("@region_id", MySqlDbType.Int32),
|
||||||
|
new MySqlParameter("@server_model", MySqlDbType.VarChar,2),
|
||||||
|
new MySqlParameter("@service_ip", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@service_port", MySqlDbType.VarChar,8),
|
||||||
|
new MySqlParameter("@station", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@remark", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@coordinate_x", MySqlDbType.Double),
|
||||||
|
new MySqlParameter("@coordinate_y", MySqlDbType.Double),
|
||||||
|
new MySqlParameter("@coordinate_z", MySqlDbType.Double),
|
||||||
|
new MySqlParameter("@is_del", MySqlDbType.VarChar,2),
|
||||||
|
new MySqlParameter("@creat_by", MySqlDbType.VarChar,64),
|
||||||
|
new MySqlParameter("@creat_time", MySqlDbType.DateTime),
|
||||||
|
new MySqlParameter("@update_by", MySqlDbType.VarChar,64),
|
||||||
|
new MySqlParameter("@update_time", MySqlDbType.DateTime),
|
||||||
|
new MySqlParameter("@panel_type", MySqlDbType.Int32),
|
||||||
|
new MySqlParameter("@manual_control_time", MySqlDbType.DateTime),
|
||||||
|
new MySqlParameter("@acquisition_frequency", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@sort", MySqlDbType.Int32)};
|
||||||
|
parameters[0].Value = model.device_no_host;
|
||||||
|
parameters[1].Value = model.device_no_follow;
|
||||||
|
parameters[2].Value = model.device_name;
|
||||||
|
parameters[3].Value = model.device_type_id;
|
||||||
|
parameters[4].Value = model.region_id;
|
||||||
|
parameters[5].Value = model.server_model;
|
||||||
|
parameters[6].Value = model.service_ip;
|
||||||
|
parameters[7].Value = model.service_port;
|
||||||
|
parameters[8].Value = model.station;
|
||||||
|
parameters[9].Value = model.remark;
|
||||||
|
parameters[10].Value = model.coordinate_x;
|
||||||
|
parameters[11].Value = model.coordinate_y;
|
||||||
|
parameters[12].Value = model.coordinate_z;
|
||||||
|
parameters[13].Value = model.is_del;
|
||||||
|
parameters[14].Value = model.creat_by;
|
||||||
|
parameters[15].Value = model.creat_time;
|
||||||
|
parameters[16].Value = model.update_by;
|
||||||
|
parameters[17].Value = model.update_time;
|
||||||
|
parameters[18].Value = model.panel_type;
|
||||||
|
parameters[19].Value = model.manual_control_time;
|
||||||
|
parameters[20].Value = model.acquisition_frequency;
|
||||||
|
parameters[21].Value = model.sort;
|
||||||
|
|
||||||
|
int rows=DbHelperMySQL.ExecuteSql(strSql.ToString(),parameters);
|
||||||
|
if (rows > 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 更新一条数据
|
||||||
|
/// </summary>
|
||||||
|
public bool Update(Gather.Mysql.Model.iot_device model)
|
||||||
|
{
|
||||||
|
StringBuilder strSql=new StringBuilder();
|
||||||
|
strSql.Append("update iot_device set ");
|
||||||
|
strSql.Append("device_no_host=@device_no_host,");
|
||||||
|
strSql.Append("device_no_follow=@device_no_follow,");
|
||||||
|
strSql.Append("device_name=@device_name,");
|
||||||
|
strSql.Append("device_type_id=@device_type_id,");
|
||||||
|
strSql.Append("region_id=@region_id,");
|
||||||
|
strSql.Append("server_model=@server_model,");
|
||||||
|
strSql.Append("service_ip=@service_ip,");
|
||||||
|
strSql.Append("service_port=@service_port,");
|
||||||
|
strSql.Append("station=@station,");
|
||||||
|
strSql.Append("remark=@remark,");
|
||||||
|
strSql.Append("coordinate_x=@coordinate_x,");
|
||||||
|
strSql.Append("coordinate_y=@coordinate_y,");
|
||||||
|
strSql.Append("coordinate_z=@coordinate_z,");
|
||||||
|
strSql.Append("is_del=@is_del,");
|
||||||
|
strSql.Append("creat_by=@creat_by,");
|
||||||
|
strSql.Append("creat_time=@creat_time,");
|
||||||
|
strSql.Append("update_by=@update_by,");
|
||||||
|
strSql.Append("update_time=@update_time,");
|
||||||
|
strSql.Append("panel_type=@panel_type,");
|
||||||
|
strSql.Append("manual_control_time=@manual_control_time,");
|
||||||
|
strSql.Append("acquisition_frequency=@acquisition_frequency,");
|
||||||
|
strSql.Append("sort=@sort");
|
||||||
|
strSql.Append(" where id=@id");
|
||||||
|
MySqlParameter[] parameters = {
|
||||||
|
new MySqlParameter("@device_no_host", MySqlDbType.VarChar,64),
|
||||||
|
new MySqlParameter("@device_no_follow", MySqlDbType.VarChar,64),
|
||||||
|
new MySqlParameter("@device_name", MySqlDbType.VarChar,64),
|
||||||
|
new MySqlParameter("@device_type_id", MySqlDbType.Int32),
|
||||||
|
new MySqlParameter("@region_id", MySqlDbType.Int32),
|
||||||
|
new MySqlParameter("@server_model", MySqlDbType.VarChar,2),
|
||||||
|
new MySqlParameter("@service_ip", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@service_port", MySqlDbType.VarChar,8),
|
||||||
|
new MySqlParameter("@station", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@remark", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@coordinate_x", MySqlDbType.Double),
|
||||||
|
new MySqlParameter("@coordinate_y", MySqlDbType.Double),
|
||||||
|
new MySqlParameter("@coordinate_z", MySqlDbType.Double),
|
||||||
|
new MySqlParameter("@is_del", MySqlDbType.VarChar,2),
|
||||||
|
new MySqlParameter("@creat_by", MySqlDbType.VarChar,64),
|
||||||
|
new MySqlParameter("@creat_time", MySqlDbType.DateTime),
|
||||||
|
new MySqlParameter("@update_by", MySqlDbType.VarChar,64),
|
||||||
|
new MySqlParameter("@update_time", MySqlDbType.DateTime),
|
||||||
|
new MySqlParameter("@panel_type", MySqlDbType.Int32),
|
||||||
|
new MySqlParameter("@manual_control_time", MySqlDbType.DateTime),
|
||||||
|
new MySqlParameter("@acquisition_frequency", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@sort", MySqlDbType.Int32),
|
||||||
|
new MySqlParameter("@id", MySqlDbType.Int32)};
|
||||||
|
parameters[0].Value = model.device_no_host;
|
||||||
|
parameters[1].Value = model.device_no_follow;
|
||||||
|
parameters[2].Value = model.device_name;
|
||||||
|
parameters[3].Value = model.device_type_id;
|
||||||
|
parameters[4].Value = model.region_id;
|
||||||
|
parameters[5].Value = model.server_model;
|
||||||
|
parameters[6].Value = model.service_ip;
|
||||||
|
parameters[7].Value = model.service_port;
|
||||||
|
parameters[8].Value = model.station;
|
||||||
|
parameters[9].Value = model.remark;
|
||||||
|
parameters[10].Value = model.coordinate_x;
|
||||||
|
parameters[11].Value = model.coordinate_y;
|
||||||
|
parameters[12].Value = model.coordinate_z;
|
||||||
|
parameters[13].Value = model.is_del;
|
||||||
|
parameters[14].Value = model.creat_by;
|
||||||
|
parameters[15].Value = model.creat_time;
|
||||||
|
parameters[16].Value = model.update_by;
|
||||||
|
parameters[17].Value = model.update_time;
|
||||||
|
parameters[18].Value = model.panel_type;
|
||||||
|
parameters[19].Value = model.manual_control_time;
|
||||||
|
parameters[20].Value = model.acquisition_frequency;
|
||||||
|
parameters[21].Value = model.sort;
|
||||||
|
parameters[22].Value = model.id;
|
||||||
|
|
||||||
|
int rows=DbHelperMySQL.ExecuteSql(strSql.ToString(),parameters);
|
||||||
|
if (rows > 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除一条数据
|
||||||
|
/// </summary>
|
||||||
|
public bool Delete(long id)
|
||||||
|
{
|
||||||
|
|
||||||
|
StringBuilder strSql=new StringBuilder();
|
||||||
|
strSql.Append("delete from iot_device ");
|
||||||
|
strSql.Append(" where id=@id");
|
||||||
|
MySqlParameter[] parameters = {
|
||||||
|
new MySqlParameter("@id", MySqlDbType.Int32)
|
||||||
|
};
|
||||||
|
parameters[0].Value = id;
|
||||||
|
|
||||||
|
int rows=DbHelperMySQL.ExecuteSql(strSql.ToString(),parameters);
|
||||||
|
if (rows > 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 批量删除数据
|
||||||
|
/// </summary>
|
||||||
|
public bool DeleteList(string idlist )
|
||||||
|
{
|
||||||
|
StringBuilder strSql=new StringBuilder();
|
||||||
|
strSql.Append("delete from iot_device ");
|
||||||
|
strSql.Append(" where id in ("+idlist + ") ");
|
||||||
|
int rows=DbHelperMySQL.ExecuteSql(strSql.ToString());
|
||||||
|
if (rows > 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 得到一个对象实体
|
||||||
|
/// </summary>
|
||||||
|
public Gather.Mysql.Model.iot_device GetModel(long id)
|
||||||
|
{
|
||||||
|
|
||||||
|
StringBuilder strSql=new StringBuilder();
|
||||||
|
strSql.Append("select id,device_no_host,device_no_follow,device_name,device_type_id,region_id,server_model,service_ip,service_port,station,remark,coordinate_x,coordinate_y,coordinate_z,is_del,creat_by,creat_time,update_by,update_time,panel_type,manual_control_time,acquisition_frequency,sort from iot_device ");
|
||||||
|
strSql.Append(" where id=@id");
|
||||||
|
MySqlParameter[] parameters = {
|
||||||
|
new MySqlParameter("@id", MySqlDbType.Int32)
|
||||||
|
};
|
||||||
|
parameters[0].Value = id;
|
||||||
|
|
||||||
|
Gather.Mysql.Model.iot_device model=new Gather.Mysql.Model.iot_device();
|
||||||
|
DataSet ds=DbHelperMySQL.Query(strSql.ToString(),parameters);
|
||||||
|
if(ds.Tables[0].Rows.Count>0)
|
||||||
|
{
|
||||||
|
return DataRowToModel(ds.Tables[0].Rows[0]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 得到一个对象实体
|
||||||
|
/// </summary>
|
||||||
|
public Gather.Mysql.Model.iot_device DataRowToModel(DataRow row)
|
||||||
|
{
|
||||||
|
Gather.Mysql.Model.iot_device model=new Gather.Mysql.Model.iot_device();
|
||||||
|
if (row != null)
|
||||||
|
{
|
||||||
|
if(row["id"]!=null && row["id"].ToString()!="")
|
||||||
|
{
|
||||||
|
model.id=long.Parse(row["id"].ToString());
|
||||||
|
}
|
||||||
|
if(row["device_no_host"]!=null)
|
||||||
|
{
|
||||||
|
model.device_no_host=row["device_no_host"].ToString();
|
||||||
|
}
|
||||||
|
if(row["device_no_follow"]!=null)
|
||||||
|
{
|
||||||
|
model.device_no_follow=row["device_no_follow"].ToString();
|
||||||
|
}
|
||||||
|
if(row["device_name"]!=null)
|
||||||
|
{
|
||||||
|
model.device_name=row["device_name"].ToString();
|
||||||
|
}
|
||||||
|
if(row["device_type_id"]!=null && row["device_type_id"].ToString()!="")
|
||||||
|
{
|
||||||
|
model.device_type_id=long.Parse(row["device_type_id"].ToString());
|
||||||
|
}
|
||||||
|
if(row["region_id"]!=null && row["region_id"].ToString()!="")
|
||||||
|
{
|
||||||
|
model.region_id=long.Parse(row["region_id"].ToString());
|
||||||
|
}
|
||||||
|
if(row["server_model"]!=null)
|
||||||
|
{
|
||||||
|
model.server_model=row["server_model"].ToString();
|
||||||
|
}
|
||||||
|
if(row["service_ip"]!=null)
|
||||||
|
{
|
||||||
|
model.service_ip=row["service_ip"].ToString();
|
||||||
|
}
|
||||||
|
if(row["service_port"]!=null)
|
||||||
|
{
|
||||||
|
model.service_port=row["service_port"].ToString();
|
||||||
|
}
|
||||||
|
if(row["station"]!=null)
|
||||||
|
{
|
||||||
|
model.station=row["station"].ToString();
|
||||||
|
}
|
||||||
|
if(row["remark"]!=null)
|
||||||
|
{
|
||||||
|
model.remark=row["remark"].ToString();
|
||||||
|
}
|
||||||
|
if (row["coordinate_x"] != null && row["coordinate_x"].ToString() != "")
|
||||||
|
{
|
||||||
|
model.coordinate_x = double.Parse(row["coordinate_x"].ToString());
|
||||||
|
}
|
||||||
|
if (row["coordinate_y"] != null && row["coordinate_y"].ToString() != "")
|
||||||
|
{
|
||||||
|
model.coordinate_y = double.Parse(row["coordinate_y"].ToString());
|
||||||
|
}
|
||||||
|
if (row["coordinate_z"] != null && row["coordinate_z"].ToString() != "")
|
||||||
|
{
|
||||||
|
model.coordinate_z = double.Parse(row["coordinate_z"].ToString());
|
||||||
|
}
|
||||||
|
if (row["is_del"]!=null)
|
||||||
|
{
|
||||||
|
model.is_del=row["is_del"].ToString();
|
||||||
|
}
|
||||||
|
if(row["creat_by"]!=null)
|
||||||
|
{
|
||||||
|
model.creat_by=row["creat_by"].ToString();
|
||||||
|
}
|
||||||
|
if(row["creat_time"]!=null && row["creat_time"].ToString()!="")
|
||||||
|
{
|
||||||
|
model.creat_time=DateTime.Parse(row["creat_time"].ToString());
|
||||||
|
}
|
||||||
|
if(row["update_by"]!=null)
|
||||||
|
{
|
||||||
|
model.update_by=row["update_by"].ToString();
|
||||||
|
}
|
||||||
|
if(row["update_time"]!=null && row["update_time"].ToString()!="")
|
||||||
|
{
|
||||||
|
model.update_time=DateTime.Parse(row["update_time"].ToString());
|
||||||
|
}
|
||||||
|
if(row["panel_type"]!=null && row["panel_type"].ToString()!="")
|
||||||
|
{
|
||||||
|
model.panel_type=int.Parse(row["panel_type"].ToString());
|
||||||
|
}
|
||||||
|
if(row["manual_control_time"]!=null && row["manual_control_time"].ToString()!="")
|
||||||
|
{
|
||||||
|
model.manual_control_time=DateTime.Parse(row["manual_control_time"].ToString());
|
||||||
|
}
|
||||||
|
if(row["acquisition_frequency"]!=null)
|
||||||
|
{
|
||||||
|
model.acquisition_frequency=row["acquisition_frequency"].ToString();
|
||||||
|
}
|
||||||
|
if(row["sort"]!=null && row["sort"].ToString()!="")
|
||||||
|
{
|
||||||
|
model.sort=int.Parse(row["sort"].ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获得数据列表
|
||||||
|
/// </summary>
|
||||||
|
public DataSet GetList(string strWhere)
|
||||||
|
{
|
||||||
|
StringBuilder strSql=new StringBuilder();
|
||||||
|
strSql.Append("select id,device_no_host,device_no_follow,device_name,device_type_id,region_id,server_model,service_ip,service_port,station,remark,coordinate_x,coordinate_y,coordinate_z,is_del,creat_by,creat_time,update_by,update_time,panel_type,manual_control_time,acquisition_frequency,sort ");
|
||||||
|
strSql.Append(" FROM iot_device ");
|
||||||
|
if(strWhere.Trim()!="")
|
||||||
|
{
|
||||||
|
strSql.Append(" where "+strWhere);
|
||||||
|
}
|
||||||
|
return DbHelperMySQL.Query(strSql.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取记录总数
|
||||||
|
/// </summary>
|
||||||
|
public int GetRecordCount(string strWhere)
|
||||||
|
{
|
||||||
|
StringBuilder strSql=new StringBuilder();
|
||||||
|
strSql.Append("select count(1) FROM iot_device ");
|
||||||
|
if(strWhere.Trim()!="")
|
||||||
|
{
|
||||||
|
strSql.Append(" where "+strWhere);
|
||||||
|
}
|
||||||
|
object obj = DbHelperMySQL.GetSingle(strSql.ToString());
|
||||||
|
if (obj == null)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Convert.ToInt32(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 分页获取数据列表
|
||||||
|
/// </summary>
|
||||||
|
public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
|
||||||
|
{
|
||||||
|
StringBuilder strSql=new StringBuilder();
|
||||||
|
strSql.Append("SELECT * FROM ( ");
|
||||||
|
strSql.Append(" SELECT ROW_NUMBER() OVER (");
|
||||||
|
if (!string.IsNullOrEmpty(orderby.Trim()))
|
||||||
|
{
|
||||||
|
strSql.Append("order by T." + orderby );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strSql.Append("order by T.id desc");
|
||||||
|
}
|
||||||
|
strSql.Append(")AS Row, T.* from iot_device T ");
|
||||||
|
if (!string.IsNullOrEmpty(strWhere.Trim()))
|
||||||
|
{
|
||||||
|
strSql.Append(" WHERE " + strWhere);
|
||||||
|
}
|
||||||
|
strSql.Append(" ) TT");
|
||||||
|
strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
|
||||||
|
return DbHelperMySQL.Query(strSql.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
/// <summary>
|
||||||
|
/// 分页获取数据列表
|
||||||
|
/// </summary>
|
||||||
|
public DataSet GetList(int PageSize,int PageIndex,string strWhere)
|
||||||
|
{
|
||||||
|
MySqlParameter[] parameters = {
|
||||||
|
new MySqlParameter("@tblName", MySqlDbType.VarChar, 255),
|
||||||
|
new MySqlParameter("@fldName", MySqlDbType.VarChar, 255),
|
||||||
|
new MySqlParameter("@PageSize", MySqlDbType.Int32),
|
||||||
|
new MySqlParameter("@PageIndex", MySqlDbType.Int32),
|
||||||
|
new MySqlParameter("@IsReCount", MySqlDbType.Bit),
|
||||||
|
new MySqlParameter("@OrderType", MySqlDbType.Bit),
|
||||||
|
new MySqlParameter("@strWhere", MySqlDbType.VarChar,1000),
|
||||||
|
};
|
||||||
|
parameters[0].Value = "iot_device";
|
||||||
|
parameters[1].Value = "id";
|
||||||
|
parameters[2].Value = PageSize;
|
||||||
|
parameters[3].Value = PageIndex;
|
||||||
|
parameters[4].Value = 0;
|
||||||
|
parameters[5].Value = 0;
|
||||||
|
parameters[6].Value = strWhere;
|
||||||
|
return DbHelperMySQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
|
||||||
|
}*/
|
||||||
|
|
||||||
|
#endregion BasicMethod
|
||||||
|
#region ExtensionMethod
|
||||||
|
|
||||||
|
#endregion ExtensionMethod
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,338 @@
|
||||||
|
/** 版本信息模板在安装目录下,可自行修改。
|
||||||
|
* iot_function_code_config.cs
|
||||||
|
*
|
||||||
|
* 功 能: N/A
|
||||||
|
* 类 名: iot_function_code_config
|
||||||
|
*
|
||||||
|
* Ver 变更日期 负责人 变更内容
|
||||||
|
* ───────────────────────────────────
|
||||||
|
* V0.01 2025/6/6 13:58:11 N/A 初版
|
||||||
|
*
|
||||||
|
* Copyright (c) 2012 Maticsoft Corporation. All rights reserved.
|
||||||
|
*┌──────────────────────────────────┐
|
||||||
|
*│ 此技术信息为本公司机密信息,未经本公司书面同意禁止向第三方披露. │
|
||||||
|
*│ 版权所有:动软卓越(北京)科技有限公司 │
|
||||||
|
*└──────────────────────────────────┘
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.Data;
|
||||||
|
using System.Text;
|
||||||
|
using MySql.Data.MySqlClient;
|
||||||
|
using Maticsoft.DBUtility;//Please add references
|
||||||
|
namespace Gather.Mysql.DAL
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 数据访问类:iot_function_code_config
|
||||||
|
/// </summary>
|
||||||
|
public partial class iot_function_code_config
|
||||||
|
{
|
||||||
|
public iot_function_code_config()
|
||||||
|
{}
|
||||||
|
#region BasicMethod
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否存在该记录
|
||||||
|
/// </summary>
|
||||||
|
public bool Exists(long id)
|
||||||
|
{
|
||||||
|
StringBuilder strSql=new StringBuilder();
|
||||||
|
strSql.Append("select count(1) from iot_function_code_config");
|
||||||
|
strSql.Append(" where id=@id");
|
||||||
|
MySqlParameter[] parameters = {
|
||||||
|
new MySqlParameter("@id", MySqlDbType.Int64)
|
||||||
|
};
|
||||||
|
parameters[0].Value = id;
|
||||||
|
|
||||||
|
return DbHelperMySQL.Exists(strSql.ToString(),parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 增加一条数据
|
||||||
|
/// </summary>
|
||||||
|
public bool Add(Gather.Mysql.Model.iot_function_code_config model)
|
||||||
|
{
|
||||||
|
StringBuilder strSql=new StringBuilder();
|
||||||
|
strSql.Append("insert into iot_function_code_config(");
|
||||||
|
strSql.Append("function_code,start_address_from_zero,is_del,creat_by,creat_time,update_by,update_time)");
|
||||||
|
strSql.Append(" values (");
|
||||||
|
strSql.Append("@function_code,@start_address_from_zero,@is_del,@creat_by,@creat_time,@update_by,@update_time)");
|
||||||
|
MySqlParameter[] parameters = {
|
||||||
|
new MySqlParameter("@function_code", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@start_address_from_zero", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@is_del", MySqlDbType.VarChar,2),
|
||||||
|
new MySqlParameter("@creat_by", MySqlDbType.VarChar,64),
|
||||||
|
new MySqlParameter("@creat_time", MySqlDbType.DateTime),
|
||||||
|
new MySqlParameter("@update_by", MySqlDbType.VarChar,64),
|
||||||
|
new MySqlParameter("@update_time", MySqlDbType.DateTime)};
|
||||||
|
parameters[0].Value = model.function_code;
|
||||||
|
parameters[1].Value = model.start_address_from_zero;
|
||||||
|
parameters[2].Value = model.is_del;
|
||||||
|
parameters[3].Value = model.creat_by;
|
||||||
|
parameters[4].Value = model.creat_time;
|
||||||
|
parameters[5].Value = model.update_by;
|
||||||
|
parameters[6].Value = model.update_time;
|
||||||
|
|
||||||
|
int rows=DbHelperMySQL.ExecuteSql(strSql.ToString(),parameters);
|
||||||
|
if (rows > 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 更新一条数据
|
||||||
|
/// </summary>
|
||||||
|
public bool Update(Gather.Mysql.Model.iot_function_code_config model)
|
||||||
|
{
|
||||||
|
StringBuilder strSql=new StringBuilder();
|
||||||
|
strSql.Append("update iot_function_code_config set ");
|
||||||
|
strSql.Append("function_code=@function_code,");
|
||||||
|
strSql.Append("start_address_from_zero=@start_address_from_zero,");
|
||||||
|
strSql.Append("is_del=@is_del,");
|
||||||
|
strSql.Append("creat_by=@creat_by,");
|
||||||
|
strSql.Append("creat_time=@creat_time,");
|
||||||
|
strSql.Append("update_by=@update_by,");
|
||||||
|
strSql.Append("update_time=@update_time");
|
||||||
|
strSql.Append(" where id=@id");
|
||||||
|
MySqlParameter[] parameters = {
|
||||||
|
new MySqlParameter("@function_code", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@start_address_from_zero", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@is_del", MySqlDbType.VarChar,2),
|
||||||
|
new MySqlParameter("@creat_by", MySqlDbType.VarChar,64),
|
||||||
|
new MySqlParameter("@creat_time", MySqlDbType.DateTime),
|
||||||
|
new MySqlParameter("@update_by", MySqlDbType.VarChar,64),
|
||||||
|
new MySqlParameter("@update_time", MySqlDbType.DateTime),
|
||||||
|
new MySqlParameter("@id", MySqlDbType.Int64)};
|
||||||
|
parameters[0].Value = model.function_code;
|
||||||
|
parameters[1].Value = model.start_address_from_zero;
|
||||||
|
parameters[2].Value = model.is_del;
|
||||||
|
parameters[3].Value = model.creat_by;
|
||||||
|
parameters[4].Value = model.creat_time;
|
||||||
|
parameters[5].Value = model.update_by;
|
||||||
|
parameters[6].Value = model.update_time;
|
||||||
|
parameters[7].Value = model.id;
|
||||||
|
|
||||||
|
int rows=DbHelperMySQL.ExecuteSql(strSql.ToString(),parameters);
|
||||||
|
if (rows > 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除一条数据
|
||||||
|
/// </summary>
|
||||||
|
public bool Delete(long id)
|
||||||
|
{
|
||||||
|
|
||||||
|
StringBuilder strSql=new StringBuilder();
|
||||||
|
strSql.Append("delete from iot_function_code_config ");
|
||||||
|
strSql.Append(" where id=@id");
|
||||||
|
MySqlParameter[] parameters = {
|
||||||
|
new MySqlParameter("@id", MySqlDbType.Int64)
|
||||||
|
};
|
||||||
|
parameters[0].Value = id;
|
||||||
|
|
||||||
|
int rows=DbHelperMySQL.ExecuteSql(strSql.ToString(),parameters);
|
||||||
|
if (rows > 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 批量删除数据
|
||||||
|
/// </summary>
|
||||||
|
public bool DeleteList(string idlist )
|
||||||
|
{
|
||||||
|
StringBuilder strSql=new StringBuilder();
|
||||||
|
strSql.Append("delete from iot_function_code_config ");
|
||||||
|
strSql.Append(" where id in ("+idlist + ") ");
|
||||||
|
int rows=DbHelperMySQL.ExecuteSql(strSql.ToString());
|
||||||
|
if (rows > 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 得到一个对象实体
|
||||||
|
/// </summary>
|
||||||
|
public Gather.Mysql.Model.iot_function_code_config GetModel(long id)
|
||||||
|
{
|
||||||
|
|
||||||
|
StringBuilder strSql=new StringBuilder();
|
||||||
|
strSql.Append("select id,function_code,start_address_from_zero,is_del,creat_by,creat_time,update_by,update_time from iot_function_code_config ");
|
||||||
|
strSql.Append(" where id=@id");
|
||||||
|
MySqlParameter[] parameters = {
|
||||||
|
new MySqlParameter("@id", MySqlDbType.Int64)
|
||||||
|
};
|
||||||
|
parameters[0].Value = id;
|
||||||
|
|
||||||
|
Gather.Mysql.Model.iot_function_code_config model=new Gather.Mysql.Model.iot_function_code_config();
|
||||||
|
DataSet ds=DbHelperMySQL.Query(strSql.ToString(),parameters);
|
||||||
|
if(ds.Tables[0].Rows.Count>0)
|
||||||
|
{
|
||||||
|
return DataRowToModel(ds.Tables[0].Rows[0]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 得到一个对象实体
|
||||||
|
/// </summary>
|
||||||
|
public Gather.Mysql.Model.iot_function_code_config DataRowToModel(DataRow row)
|
||||||
|
{
|
||||||
|
Gather.Mysql.Model.iot_function_code_config model=new Gather.Mysql.Model.iot_function_code_config();
|
||||||
|
if (row != null)
|
||||||
|
{
|
||||||
|
if(row["id"]!=null && row["id"].ToString()!="")
|
||||||
|
{
|
||||||
|
model.id=long.Parse(row["id"].ToString());
|
||||||
|
}
|
||||||
|
if(row["function_code"]!=null)
|
||||||
|
{
|
||||||
|
model.function_code=row["function_code"].ToString();
|
||||||
|
}
|
||||||
|
if(row["start_address_from_zero"]!=null)
|
||||||
|
{
|
||||||
|
model.start_address_from_zero=row["start_address_from_zero"].ToString();
|
||||||
|
}
|
||||||
|
if(row["is_del"]!=null)
|
||||||
|
{
|
||||||
|
model.is_del=row["is_del"].ToString();
|
||||||
|
}
|
||||||
|
if(row["creat_by"]!=null)
|
||||||
|
{
|
||||||
|
model.creat_by=row["creat_by"].ToString();
|
||||||
|
}
|
||||||
|
if(row["creat_time"]!=null && row["creat_time"].ToString()!="")
|
||||||
|
{
|
||||||
|
model.creat_time=DateTime.Parse(row["creat_time"].ToString());
|
||||||
|
}
|
||||||
|
if(row["update_by"]!=null)
|
||||||
|
{
|
||||||
|
model.update_by=row["update_by"].ToString();
|
||||||
|
}
|
||||||
|
if(row["update_time"]!=null && row["update_time"].ToString()!="")
|
||||||
|
{
|
||||||
|
model.update_time=DateTime.Parse(row["update_time"].ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获得数据列表
|
||||||
|
/// </summary>
|
||||||
|
public DataSet GetList(string strWhere)
|
||||||
|
{
|
||||||
|
StringBuilder strSql=new StringBuilder();
|
||||||
|
strSql.Append("select id,function_code,start_address_from_zero,is_del,creat_by,creat_time,update_by,update_time ");
|
||||||
|
strSql.Append(" FROM iot_function_code_config ");
|
||||||
|
if(strWhere.Trim()!="")
|
||||||
|
{
|
||||||
|
strSql.Append(" where "+strWhere);
|
||||||
|
}
|
||||||
|
return DbHelperMySQL.Query(strSql.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取记录总数
|
||||||
|
/// </summary>
|
||||||
|
public int GetRecordCount(string strWhere)
|
||||||
|
{
|
||||||
|
StringBuilder strSql=new StringBuilder();
|
||||||
|
strSql.Append("select count(1) FROM iot_function_code_config ");
|
||||||
|
if(strWhere.Trim()!="")
|
||||||
|
{
|
||||||
|
strSql.Append(" where "+strWhere);
|
||||||
|
}
|
||||||
|
object obj = DbHelperMySQL.GetSingle(strSql.ToString());
|
||||||
|
if (obj == null)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Convert.ToInt32(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 分页获取数据列表
|
||||||
|
/// </summary>
|
||||||
|
public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
|
||||||
|
{
|
||||||
|
StringBuilder strSql=new StringBuilder();
|
||||||
|
strSql.Append("SELECT * FROM ( ");
|
||||||
|
strSql.Append(" SELECT ROW_NUMBER() OVER (");
|
||||||
|
if (!string.IsNullOrEmpty(orderby.Trim()))
|
||||||
|
{
|
||||||
|
strSql.Append("order by T." + orderby );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strSql.Append("order by T.id desc");
|
||||||
|
}
|
||||||
|
strSql.Append(")AS Row, T.* from iot_function_code_config T ");
|
||||||
|
if (!string.IsNullOrEmpty(strWhere.Trim()))
|
||||||
|
{
|
||||||
|
strSql.Append(" WHERE " + strWhere);
|
||||||
|
}
|
||||||
|
strSql.Append(" ) TT");
|
||||||
|
strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
|
||||||
|
return DbHelperMySQL.Query(strSql.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
/// <summary>
|
||||||
|
/// 分页获取数据列表
|
||||||
|
/// </summary>
|
||||||
|
public DataSet GetList(int PageSize,int PageIndex,string strWhere)
|
||||||
|
{
|
||||||
|
MySqlParameter[] parameters = {
|
||||||
|
new MySqlParameter("@tblName", MySqlDbType.VarChar, 255),
|
||||||
|
new MySqlParameter("@fldName", MySqlDbType.VarChar, 255),
|
||||||
|
new MySqlParameter("@PageSize", MySqlDbType.Int32),
|
||||||
|
new MySqlParameter("@PageIndex", MySqlDbType.Int32),
|
||||||
|
new MySqlParameter("@IsReCount", MySqlDbType.Bit),
|
||||||
|
new MySqlParameter("@OrderType", MySqlDbType.Bit),
|
||||||
|
new MySqlParameter("@strWhere", MySqlDbType.VarChar,1000),
|
||||||
|
};
|
||||||
|
parameters[0].Value = "iot_function_code_config";
|
||||||
|
parameters[1].Value = "id";
|
||||||
|
parameters[2].Value = PageSize;
|
||||||
|
parameters[3].Value = PageIndex;
|
||||||
|
parameters[4].Value = 0;
|
||||||
|
parameters[5].Value = 0;
|
||||||
|
parameters[6].Value = strWhere;
|
||||||
|
return DbHelperMySQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
|
||||||
|
}*/
|
||||||
|
|
||||||
|
#endregion BasicMethod
|
||||||
|
#region ExtensionMethod
|
||||||
|
|
||||||
|
#endregion ExtensionMethod
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,499 @@
|
||||||
|
/** 版本信息模板在安装目录下,可自行修改。
|
||||||
|
* iot_plc_pt.cs
|
||||||
|
*
|
||||||
|
* 功 能: N/A
|
||||||
|
* 类 名: iot_plc_pt
|
||||||
|
*
|
||||||
|
* Ver 变更日期 负责人 变更内容
|
||||||
|
* ───────────────────────────────────
|
||||||
|
* V0.01 2025/6/14 9:40:01 N/A 初版
|
||||||
|
*
|
||||||
|
* Copyright (c) 2012 Maticsoft Corporation. All rights reserved.
|
||||||
|
*┌──────────────────────────────────┐
|
||||||
|
*│ 此技术信息为本公司机密信息,未经本公司书面同意禁止向第三方披露. │
|
||||||
|
*│ 版权所有:动软卓越(北京)科技有限公司 │
|
||||||
|
*└──────────────────────────────────┘
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.Data;
|
||||||
|
using System.Text;
|
||||||
|
using MySql.Data.MySqlClient;
|
||||||
|
using Maticsoft.DBUtility;//Please add references
|
||||||
|
namespace Gather.Mysql.DAL
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 数据访问类:iot_plc_pt
|
||||||
|
/// </summary>
|
||||||
|
public partial class iot_plc_pt
|
||||||
|
{
|
||||||
|
public iot_plc_pt()
|
||||||
|
{}
|
||||||
|
#region BasicMethod
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 得到最大ID
|
||||||
|
/// </summary>
|
||||||
|
public int GetMaxId()
|
||||||
|
{
|
||||||
|
return DbHelperMySQL.GetMaxID("id", "iot_plc_pt");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否存在该记录
|
||||||
|
/// </summary>
|
||||||
|
public bool Exists(int id)
|
||||||
|
{
|
||||||
|
StringBuilder strSql=new StringBuilder();
|
||||||
|
strSql.Append("select count(1) from iot_plc_pt");
|
||||||
|
strSql.Append(" where id=@id");
|
||||||
|
MySqlParameter[] parameters = {
|
||||||
|
new MySqlParameter("@id", MySqlDbType.Int32)
|
||||||
|
};
|
||||||
|
parameters[0].Value = id;
|
||||||
|
|
||||||
|
return DbHelperMySQL.Exists(strSql.ToString(),parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 增加一条数据
|
||||||
|
/// </summary>
|
||||||
|
public bool Add(Gather.Mysql.Model.iot_plc_pt model)
|
||||||
|
{
|
||||||
|
StringBuilder strSql=new StringBuilder();
|
||||||
|
strSql.Append("insert into iot_plc_pt(");
|
||||||
|
strSql.Append("pt_device_id,pt_name,pt_english,pt_relate_english,pt_value,pt_function,pt_pattern,pt_unit,pt_sort,pt_is_bit_read,pt_bit_index,pt_fault_point,pt_alarm_point,pt_max_value,pt_min_value,pt_range,pt_data_type,pt_byte_order,pt_magnification_ratio,is_del,creat_by,creat_time,update_by,update_time)");
|
||||||
|
strSql.Append(" values (");
|
||||||
|
strSql.Append("@pt_device_id,@pt_name,@pt_english,@pt_relate_english,@pt_value,@pt_function,@pt_pattern,@pt_unit,@pt_sort,@pt_is_bit_read,@pt_bit_index,@pt_fault_point,@pt_alarm_point,@pt_max_value,@pt_min_value,@pt_range,@pt_data_type,@pt_byte_order,@pt_magnification_ratio,@is_del,@creat_by,@creat_time,@update_by,@update_time)");
|
||||||
|
MySqlParameter[] parameters = {
|
||||||
|
new MySqlParameter("@pt_device_id", MySqlDbType.Int64),
|
||||||
|
new MySqlParameter("@pt_name", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@pt_english", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@pt_relate_english", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@pt_value", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@pt_function", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@pt_pattern", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@pt_unit", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@pt_sort", MySqlDbType.Int32),
|
||||||
|
new MySqlParameter("@pt_is_bit_read", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@pt_bit_index", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@pt_fault_point", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@pt_alarm_point", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@pt_max_value", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@pt_min_value", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@pt_range", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@pt_data_type", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@pt_byte_order", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@pt_magnification_ratio", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@is_del", MySqlDbType.VarChar,2),
|
||||||
|
new MySqlParameter("@creat_by", MySqlDbType.VarChar,64),
|
||||||
|
new MySqlParameter("@creat_time", MySqlDbType.DateTime),
|
||||||
|
new MySqlParameter("@update_by", MySqlDbType.VarChar,64),
|
||||||
|
new MySqlParameter("@update_time", MySqlDbType.DateTime)};
|
||||||
|
parameters[0].Value = model.pt_device_id;
|
||||||
|
parameters[1].Value = model.pt_name;
|
||||||
|
parameters[2].Value = model.pt_english;
|
||||||
|
parameters[3].Value = model.pt_relate_english;
|
||||||
|
parameters[4].Value = model.pt_value;
|
||||||
|
parameters[5].Value = model.pt_function;
|
||||||
|
parameters[6].Value = model.pt_pattern;
|
||||||
|
parameters[7].Value = model.pt_unit;
|
||||||
|
parameters[8].Value = model.pt_sort;
|
||||||
|
parameters[9].Value = model.pt_is_bit_read;
|
||||||
|
parameters[10].Value = model.pt_bit_index;
|
||||||
|
parameters[11].Value = model.pt_fault_point;
|
||||||
|
parameters[12].Value = model.pt_alarm_point;
|
||||||
|
parameters[13].Value = model.pt_max_value;
|
||||||
|
parameters[14].Value = model.pt_min_value;
|
||||||
|
parameters[15].Value = model.pt_range;
|
||||||
|
parameters[16].Value = model.pt_data_type;
|
||||||
|
parameters[17].Value = model.pt_byte_order;
|
||||||
|
parameters[18].Value = model.pt_magnification_ratio;
|
||||||
|
parameters[19].Value = model.is_del;
|
||||||
|
parameters[20].Value = model.creat_by;
|
||||||
|
parameters[21].Value = model.creat_time;
|
||||||
|
parameters[22].Value = model.update_by;
|
||||||
|
parameters[23].Value = model.update_time;
|
||||||
|
|
||||||
|
int rows=DbHelperMySQL.ExecuteSql(strSql.ToString(),parameters);
|
||||||
|
if (rows > 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 更新一条数据
|
||||||
|
/// </summary>
|
||||||
|
public bool Update(Gather.Mysql.Model.iot_plc_pt model)
|
||||||
|
{
|
||||||
|
StringBuilder strSql=new StringBuilder();
|
||||||
|
strSql.Append("update iot_plc_pt set ");
|
||||||
|
strSql.Append("pt_device_id=@pt_device_id,");
|
||||||
|
strSql.Append("pt_name=@pt_name,");
|
||||||
|
strSql.Append("pt_english=@pt_english,");
|
||||||
|
strSql.Append("pt_relate_english=@pt_relate_english,");
|
||||||
|
strSql.Append("pt_value=@pt_value,");
|
||||||
|
strSql.Append("pt_function=@pt_function,");
|
||||||
|
strSql.Append("pt_pattern=@pt_pattern,");
|
||||||
|
strSql.Append("pt_unit=@pt_unit,");
|
||||||
|
strSql.Append("pt_sort=@pt_sort,");
|
||||||
|
strSql.Append("pt_is_bit_read=@pt_is_bit_read,");
|
||||||
|
strSql.Append("pt_bit_index=@pt_bit_index,");
|
||||||
|
strSql.Append("pt_fault_point=@pt_fault_point,");
|
||||||
|
strSql.Append("pt_alarm_point=@pt_alarm_point,");
|
||||||
|
strSql.Append("pt_max_value=@pt_max_value,");
|
||||||
|
strSql.Append("pt_min_value=@pt_min_value,");
|
||||||
|
strSql.Append("pt_range=@pt_range,");
|
||||||
|
strSql.Append("pt_data_type=@pt_data_type,");
|
||||||
|
strSql.Append("pt_byte_order=@pt_byte_order,");
|
||||||
|
strSql.Append("pt_magnification_ratio=@pt_magnification_ratio,");
|
||||||
|
strSql.Append("is_del=@is_del,");
|
||||||
|
strSql.Append("creat_by=@creat_by,");
|
||||||
|
strSql.Append("creat_time=@creat_time,");
|
||||||
|
strSql.Append("update_by=@update_by,");
|
||||||
|
strSql.Append("update_time=@update_time");
|
||||||
|
strSql.Append(" where id=@id");
|
||||||
|
MySqlParameter[] parameters = {
|
||||||
|
new MySqlParameter("@pt_device_id", MySqlDbType.Int64),
|
||||||
|
new MySqlParameter("@pt_name", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@pt_english", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@pt_relate_english", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@pt_value", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@pt_function", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@pt_pattern", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@pt_unit", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@pt_sort", MySqlDbType.Int32),
|
||||||
|
new MySqlParameter("@pt_is_bit_read", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@pt_bit_index", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@pt_fault_point", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@pt_alarm_point", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@pt_max_value", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@pt_min_value", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@pt_range", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@pt_data_type", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@pt_byte_order", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@pt_magnification_ratio", MySqlDbType.VarChar,255),
|
||||||
|
new MySqlParameter("@is_del", MySqlDbType.VarChar,2),
|
||||||
|
new MySqlParameter("@creat_by", MySqlDbType.VarChar,64),
|
||||||
|
new MySqlParameter("@creat_time", MySqlDbType.DateTime),
|
||||||
|
new MySqlParameter("@update_by", MySqlDbType.VarChar,64),
|
||||||
|
new MySqlParameter("@update_time", MySqlDbType.DateTime),
|
||||||
|
new MySqlParameter("@id", MySqlDbType.Int32)};
|
||||||
|
parameters[0].Value = model.pt_device_id;
|
||||||
|
parameters[1].Value = model.pt_name;
|
||||||
|
parameters[2].Value = model.pt_english;
|
||||||
|
parameters[3].Value = model.pt_relate_english;
|
||||||
|
parameters[4].Value = model.pt_value;
|
||||||
|
parameters[5].Value = model.pt_function;
|
||||||
|
parameters[6].Value = model.pt_pattern;
|
||||||
|
parameters[7].Value = model.pt_unit;
|
||||||
|
parameters[8].Value = model.pt_sort;
|
||||||
|
parameters[9].Value = model.pt_is_bit_read;
|
||||||
|
parameters[10].Value = model.pt_bit_index;
|
||||||
|
parameters[11].Value = model.pt_fault_point;
|
||||||
|
parameters[12].Value = model.pt_alarm_point;
|
||||||
|
parameters[13].Value = model.pt_max_value;
|
||||||
|
parameters[14].Value = model.pt_min_value;
|
||||||
|
parameters[15].Value = model.pt_range;
|
||||||
|
parameters[16].Value = model.pt_data_type;
|
||||||
|
parameters[17].Value = model.pt_byte_order;
|
||||||
|
parameters[18].Value = model.pt_magnification_ratio;
|
||||||
|
parameters[19].Value = model.is_del;
|
||||||
|
parameters[20].Value = model.creat_by;
|
||||||
|
parameters[21].Value = model.creat_time;
|
||||||
|
parameters[22].Value = model.update_by;
|
||||||
|
parameters[23].Value = model.update_time;
|
||||||
|
parameters[24].Value = model.id;
|
||||||
|
|
||||||
|
int rows=DbHelperMySQL.ExecuteSql(strSql.ToString(),parameters);
|
||||||
|
if (rows > 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除一条数据
|
||||||
|
/// </summary>
|
||||||
|
public bool Delete(int id)
|
||||||
|
{
|
||||||
|
|
||||||
|
StringBuilder strSql=new StringBuilder();
|
||||||
|
strSql.Append("delete from iot_plc_pt ");
|
||||||
|
strSql.Append(" where id=@id");
|
||||||
|
MySqlParameter[] parameters = {
|
||||||
|
new MySqlParameter("@id", MySqlDbType.Int32)
|
||||||
|
};
|
||||||
|
parameters[0].Value = id;
|
||||||
|
|
||||||
|
int rows=DbHelperMySQL.ExecuteSql(strSql.ToString(),parameters);
|
||||||
|
if (rows > 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 批量删除数据
|
||||||
|
/// </summary>
|
||||||
|
public bool DeleteList(string idlist )
|
||||||
|
{
|
||||||
|
StringBuilder strSql=new StringBuilder();
|
||||||
|
strSql.Append("delete from iot_plc_pt ");
|
||||||
|
strSql.Append(" where id in ("+idlist + ") ");
|
||||||
|
int rows=DbHelperMySQL.ExecuteSql(strSql.ToString());
|
||||||
|
if (rows > 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 得到一个对象实体
|
||||||
|
/// </summary>
|
||||||
|
public Gather.Mysql.Model.iot_plc_pt GetModel(int id)
|
||||||
|
{
|
||||||
|
|
||||||
|
StringBuilder strSql=new StringBuilder();
|
||||||
|
strSql.Append("select id,pt_device_id,pt_name,pt_english,pt_relate_english,pt_value,pt_function,pt_pattern,pt_unit,pt_sort,pt_is_bit_read,pt_bit_index,pt_fault_point,pt_alarm_point,pt_max_value,pt_min_value,pt_range,pt_data_type,pt_byte_order,pt_magnification_ratio,is_del,creat_by,creat_time,update_by,update_time from iot_plc_pt ");
|
||||||
|
strSql.Append(" where id=@id");
|
||||||
|
MySqlParameter[] parameters = {
|
||||||
|
new MySqlParameter("@id", MySqlDbType.Int32)
|
||||||
|
};
|
||||||
|
parameters[0].Value = id;
|
||||||
|
|
||||||
|
Gather.Mysql.Model.iot_plc_pt model=new Gather.Mysql.Model.iot_plc_pt();
|
||||||
|
DataSet ds=DbHelperMySQL.Query(strSql.ToString(),parameters);
|
||||||
|
if(ds.Tables[0].Rows.Count>0)
|
||||||
|
{
|
||||||
|
return DataRowToModel(ds.Tables[0].Rows[0]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 得到一个对象实体
|
||||||
|
/// </summary>
|
||||||
|
public Gather.Mysql.Model.iot_plc_pt DataRowToModel(DataRow row)
|
||||||
|
{
|
||||||
|
Gather.Mysql.Model.iot_plc_pt model=new Gather.Mysql.Model.iot_plc_pt();
|
||||||
|
if (row != null)
|
||||||
|
{
|
||||||
|
if(row["id"]!=null && row["id"].ToString()!="")
|
||||||
|
{
|
||||||
|
model.id=int.Parse(row["id"].ToString());
|
||||||
|
}
|
||||||
|
if(row["pt_device_id"]!=null && row["pt_device_id"].ToString()!="")
|
||||||
|
{
|
||||||
|
model.pt_device_id=long.Parse(row["pt_device_id"].ToString());
|
||||||
|
}
|
||||||
|
if(row["pt_name"]!=null)
|
||||||
|
{
|
||||||
|
model.pt_name=row["pt_name"].ToString();
|
||||||
|
}
|
||||||
|
if(row["pt_english"]!=null)
|
||||||
|
{
|
||||||
|
model.pt_english=row["pt_english"].ToString();
|
||||||
|
}
|
||||||
|
if(row["pt_relate_english"]!=null)
|
||||||
|
{
|
||||||
|
model.pt_relate_english=row["pt_relate_english"].ToString();
|
||||||
|
}
|
||||||
|
if(row["pt_value"]!=null)
|
||||||
|
{
|
||||||
|
model.pt_value=row["pt_value"].ToString();
|
||||||
|
}
|
||||||
|
if(row["pt_function"]!=null)
|
||||||
|
{
|
||||||
|
model.pt_function=row["pt_function"].ToString();
|
||||||
|
}
|
||||||
|
if(row["pt_pattern"]!=null)
|
||||||
|
{
|
||||||
|
model.pt_pattern=row["pt_pattern"].ToString();
|
||||||
|
}
|
||||||
|
if(row["pt_unit"]!=null)
|
||||||
|
{
|
||||||
|
model.pt_unit=row["pt_unit"].ToString();
|
||||||
|
}
|
||||||
|
if(row["pt_sort"]!=null && row["pt_sort"].ToString()!="")
|
||||||
|
{
|
||||||
|
model.pt_sort=int.Parse(row["pt_sort"].ToString());
|
||||||
|
}
|
||||||
|
if(row["pt_is_bit_read"]!=null)
|
||||||
|
{
|
||||||
|
model.pt_is_bit_read=row["pt_is_bit_read"].ToString();
|
||||||
|
}
|
||||||
|
if(row["pt_bit_index"]!=null)
|
||||||
|
{
|
||||||
|
model.pt_bit_index=row["pt_bit_index"].ToString();
|
||||||
|
}
|
||||||
|
if(row["pt_fault_point"]!=null)
|
||||||
|
{
|
||||||
|
model.pt_fault_point=row["pt_fault_point"].ToString();
|
||||||
|
}
|
||||||
|
if(row["pt_alarm_point"]!=null)
|
||||||
|
{
|
||||||
|
model.pt_alarm_point=row["pt_alarm_point"].ToString();
|
||||||
|
}
|
||||||
|
if(row["pt_max_value"]!=null)
|
||||||
|
{
|
||||||
|
model.pt_max_value=row["pt_max_value"].ToString();
|
||||||
|
}
|
||||||
|
if(row["pt_min_value"]!=null)
|
||||||
|
{
|
||||||
|
model.pt_min_value=row["pt_min_value"].ToString();
|
||||||
|
}
|
||||||
|
if(row["pt_range"]!=null)
|
||||||
|
{
|
||||||
|
model.pt_range=row["pt_range"].ToString();
|
||||||
|
}
|
||||||
|
if(row["pt_data_type"]!=null)
|
||||||
|
{
|
||||||
|
model.pt_data_type=row["pt_data_type"].ToString();
|
||||||
|
}
|
||||||
|
if(row["pt_byte_order"]!=null)
|
||||||
|
{
|
||||||
|
model.pt_byte_order=row["pt_byte_order"].ToString();
|
||||||
|
}
|
||||||
|
if(row["pt_magnification_ratio"]!=null)
|
||||||
|
{
|
||||||
|
model.pt_magnification_ratio=row["pt_magnification_ratio"].ToString();
|
||||||
|
}
|
||||||
|
if(row["is_del"]!=null)
|
||||||
|
{
|
||||||
|
model.is_del=row["is_del"].ToString();
|
||||||
|
}
|
||||||
|
if(row["creat_by"]!=null)
|
||||||
|
{
|
||||||
|
model.creat_by=row["creat_by"].ToString();
|
||||||
|
}
|
||||||
|
if(row["creat_time"]!=null && row["creat_time"].ToString()!="")
|
||||||
|
{
|
||||||
|
model.creat_time=DateTime.Parse(row["creat_time"].ToString());
|
||||||
|
}
|
||||||
|
if(row["update_by"]!=null)
|
||||||
|
{
|
||||||
|
model.update_by=row["update_by"].ToString();
|
||||||
|
}
|
||||||
|
if(row["update_time"]!=null && row["update_time"].ToString()!="")
|
||||||
|
{
|
||||||
|
model.update_time=DateTime.Parse(row["update_time"].ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获得数据列表
|
||||||
|
/// </summary>
|
||||||
|
public DataSet GetList(string strWhere)
|
||||||
|
{
|
||||||
|
StringBuilder strSql=new StringBuilder();
|
||||||
|
strSql.Append("select id,pt_device_id,pt_name,pt_english,pt_relate_english,pt_value,pt_function,pt_pattern,pt_unit,pt_sort,pt_is_bit_read,pt_bit_index,pt_fault_point,pt_alarm_point,pt_max_value,pt_min_value,pt_range,pt_data_type,pt_byte_order,pt_magnification_ratio,is_del,creat_by,creat_time,update_by,update_time ");
|
||||||
|
strSql.Append(" FROM iot_plc_pt ");
|
||||||
|
if(strWhere.Trim()!="")
|
||||||
|
{
|
||||||
|
strSql.Append(" where "+strWhere);
|
||||||
|
}
|
||||||
|
return DbHelperMySQL.Query(strSql.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取记录总数
|
||||||
|
/// </summary>
|
||||||
|
public int GetRecordCount(string strWhere)
|
||||||
|
{
|
||||||
|
StringBuilder strSql=new StringBuilder();
|
||||||
|
strSql.Append("select count(1) FROM iot_plc_pt ");
|
||||||
|
if(strWhere.Trim()!="")
|
||||||
|
{
|
||||||
|
strSql.Append(" where "+strWhere);
|
||||||
|
}
|
||||||
|
object obj = DbHelperMySQL.GetSingle(strSql.ToString());
|
||||||
|
if (obj == null)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Convert.ToInt32(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 分页获取数据列表
|
||||||
|
/// </summary>
|
||||||
|
public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
|
||||||
|
{
|
||||||
|
StringBuilder strSql=new StringBuilder();
|
||||||
|
strSql.Append("SELECT * FROM ( ");
|
||||||
|
strSql.Append(" SELECT ROW_NUMBER() OVER (");
|
||||||
|
if (!string.IsNullOrEmpty(orderby.Trim()))
|
||||||
|
{
|
||||||
|
strSql.Append("order by T." + orderby );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strSql.Append("order by T.id desc");
|
||||||
|
}
|
||||||
|
strSql.Append(")AS Row, T.* from iot_plc_pt T ");
|
||||||
|
if (!string.IsNullOrEmpty(strWhere.Trim()))
|
||||||
|
{
|
||||||
|
strSql.Append(" WHERE " + strWhere);
|
||||||
|
}
|
||||||
|
strSql.Append(" ) TT");
|
||||||
|
strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
|
||||||
|
return DbHelperMySQL.Query(strSql.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
/// <summary>
|
||||||
|
/// 分页获取数据列表
|
||||||
|
/// </summary>
|
||||||
|
public DataSet GetList(int PageSize,int PageIndex,string strWhere)
|
||||||
|
{
|
||||||
|
MySqlParameter[] parameters = {
|
||||||
|
new MySqlParameter("@tblName", MySqlDbType.VarChar, 255),
|
||||||
|
new MySqlParameter("@fldName", MySqlDbType.VarChar, 255),
|
||||||
|
new MySqlParameter("@PageSize", MySqlDbType.Int32),
|
||||||
|
new MySqlParameter("@PageIndex", MySqlDbType.Int32),
|
||||||
|
new MySqlParameter("@IsReCount", MySqlDbType.Bit),
|
||||||
|
new MySqlParameter("@OrderType", MySqlDbType.Bit),
|
||||||
|
new MySqlParameter("@strWhere", MySqlDbType.VarChar,1000),
|
||||||
|
};
|
||||||
|
parameters[0].Value = "iot_plc_pt";
|
||||||
|
parameters[1].Value = "id";
|
||||||
|
parameters[2].Value = PageSize;
|
||||||
|
parameters[3].Value = PageIndex;
|
||||||
|
parameters[4].Value = 0;
|
||||||
|
parameters[5].Value = 0;
|
||||||
|
parameters[6].Value = strWhere;
|
||||||
|
return DbHelperMySQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
|
||||||
|
}*/
|
||||||
|
|
||||||
|
#endregion BasicMethod
|
||||||
|
#region ExtensionMethod
|
||||||
|
|
||||||
|
#endregion ExtensionMethod
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
|
||||||
|
<PackageReference Include="MySqlConnector" Version="0.69.1" />
|
||||||
|
<PackageReference Include="Pomelo.Data.MySql.Unofficial" Version="1.0.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Gather.Common\Gather.Common.csproj" />
|
||||||
|
<ProjectReference Include="..\Gather.Model\Gather.Model.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Maticsoft.Common">
|
||||||
|
<HintPath>..\packages\Maticsoft.Common.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Maticsoft.DBUtility">
|
||||||
|
<HintPath>..\packages\Maticsoft.DBUtility.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Other\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
|
@ -0,0 +1,240 @@
|
||||||
|
/** 版本信息模板在安装目录下,可自行修改。
|
||||||
|
* iot_device.cs
|
||||||
|
*
|
||||||
|
* 功 能: N/A
|
||||||
|
* 类 名: iot_device
|
||||||
|
*
|
||||||
|
* Ver 变更日期 负责人 变更内容
|
||||||
|
* ───────────────────────────────────
|
||||||
|
* V0.01 2025/6/6 9:48:17 N/A 初版
|
||||||
|
*
|
||||||
|
* Copyright (c) 2012 Maticsoft Corporation. All rights reserved.
|
||||||
|
*┌──────────────────────────────────┐
|
||||||
|
*│ 此技术信息为本公司机密信息,未经本公司书面同意禁止向第三方披露. │
|
||||||
|
*│ 版权所有:动软卓越(北京)科技有限公司 │
|
||||||
|
*└──────────────────────────────────┘
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
namespace Gather.Mysql.Model
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// iot_device:实体类(属性说明自动提取数据库字段的描述信息)
|
||||||
|
/// </summary>
|
||||||
|
[Serializable]
|
||||||
|
public partial class iot_device
|
||||||
|
{
|
||||||
|
public iot_device()
|
||||||
|
{}
|
||||||
|
#region Model
|
||||||
|
private long _id;
|
||||||
|
private string _device_no_host;
|
||||||
|
private string _device_no_follow;
|
||||||
|
private string _device_name;
|
||||||
|
private long? _device_type_id;
|
||||||
|
private long _region_id;
|
||||||
|
private string _server_model;
|
||||||
|
private string _service_ip;
|
||||||
|
private string _service_port;
|
||||||
|
private string _station;
|
||||||
|
private string _remark= "0";
|
||||||
|
private double? _coordinate_x=0;
|
||||||
|
private double? _coordinate_y=0;
|
||||||
|
private double? _coordinate_z=0;
|
||||||
|
private string _is_del= "0";
|
||||||
|
private string _creat_by;
|
||||||
|
private DateTime? _creat_time;
|
||||||
|
private string _update_by;
|
||||||
|
private DateTime? _update_time;
|
||||||
|
private int _panel_type;
|
||||||
|
private DateTime? _manual_control_time;
|
||||||
|
private string _acquisition_frequency;
|
||||||
|
private int? _sort;
|
||||||
|
/// <summary>
|
||||||
|
/// auto_increment
|
||||||
|
/// </summary>
|
||||||
|
public long id
|
||||||
|
{
|
||||||
|
set{ _id=value;}
|
||||||
|
get{return _id;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string device_no_host
|
||||||
|
{
|
||||||
|
set{ _device_no_host=value;}
|
||||||
|
get{return _device_no_host;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string device_no_follow
|
||||||
|
{
|
||||||
|
set{ _device_no_follow=value;}
|
||||||
|
get{return _device_no_follow;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string device_name
|
||||||
|
{
|
||||||
|
set{ _device_name=value;}
|
||||||
|
get{return _device_name;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public long? device_type_id
|
||||||
|
{
|
||||||
|
set{ _device_type_id=value;}
|
||||||
|
get{return _device_type_id;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public long region_id
|
||||||
|
{
|
||||||
|
set{ _region_id=value;}
|
||||||
|
get{return _region_id;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string server_model
|
||||||
|
{
|
||||||
|
set{ _server_model=value;}
|
||||||
|
get{return _server_model;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string service_ip
|
||||||
|
{
|
||||||
|
set{ _service_ip=value;}
|
||||||
|
get{return _service_ip;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string service_port
|
||||||
|
{
|
||||||
|
set{ _service_port=value;}
|
||||||
|
get{return _service_port;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string station
|
||||||
|
{
|
||||||
|
set{ _station=value;}
|
||||||
|
get{return _station;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string remark
|
||||||
|
{
|
||||||
|
set{ _remark=value;}
|
||||||
|
get{return _remark;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public double? coordinate_x
|
||||||
|
{
|
||||||
|
set{ _coordinate_x=value;}
|
||||||
|
get{return _coordinate_x;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public double? coordinate_y
|
||||||
|
{
|
||||||
|
set{ _coordinate_y=value;}
|
||||||
|
get{return _coordinate_y;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public double? coordinate_z
|
||||||
|
{
|
||||||
|
set{ _coordinate_z=value;}
|
||||||
|
get{return _coordinate_z;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string is_del
|
||||||
|
{
|
||||||
|
set{ _is_del=value;}
|
||||||
|
get{return _is_del;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string creat_by
|
||||||
|
{
|
||||||
|
set{ _creat_by=value;}
|
||||||
|
get{return _creat_by;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? creat_time
|
||||||
|
{
|
||||||
|
set{ _creat_time=value;}
|
||||||
|
get{return _creat_time;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string update_by
|
||||||
|
{
|
||||||
|
set{ _update_by=value;}
|
||||||
|
get{return _update_by;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? update_time
|
||||||
|
{
|
||||||
|
set{ _update_time=value;}
|
||||||
|
get{return _update_time;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int panel_type
|
||||||
|
{
|
||||||
|
set{ _panel_type=value;}
|
||||||
|
get{return _panel_type;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? manual_control_time
|
||||||
|
{
|
||||||
|
set{ _manual_control_time=value;}
|
||||||
|
get{return _manual_control_time;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string acquisition_frequency
|
||||||
|
{
|
||||||
|
set{ _acquisition_frequency=value;}
|
||||||
|
get{return _acquisition_frequency;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int? sort
|
||||||
|
{
|
||||||
|
set{ _sort=value;}
|
||||||
|
get{return _sort;}
|
||||||
|
}
|
||||||
|
#endregion Model
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,105 @@
|
||||||
|
/** 版本信息模板在安装目录下,可自行修改。
|
||||||
|
* iot_function_code_config.cs
|
||||||
|
*
|
||||||
|
* 功 能: N/A
|
||||||
|
* 类 名: iot_function_code_config
|
||||||
|
*
|
||||||
|
* Ver 变更日期 负责人 变更内容
|
||||||
|
* ───────────────────────────────────
|
||||||
|
* V0.01 2025/6/6 13:58:11 N/A 初版
|
||||||
|
*
|
||||||
|
* Copyright (c) 2012 Maticsoft Corporation. All rights reserved.
|
||||||
|
*┌──────────────────────────────────┐
|
||||||
|
*│ 此技术信息为本公司机密信息,未经本公司书面同意禁止向第三方披露. │
|
||||||
|
*│ 版权所有:动软卓越(北京)科技有限公司 │
|
||||||
|
*└──────────────────────────────────┘
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
namespace Gather.Mysql.Model
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// iot_function_code_config:实体类(属性说明自动提取数据库字段的描述信息)
|
||||||
|
/// </summary>
|
||||||
|
[Serializable]
|
||||||
|
public partial class iot_function_code_config
|
||||||
|
{
|
||||||
|
public iot_function_code_config()
|
||||||
|
{}
|
||||||
|
#region Model
|
||||||
|
private long _id;
|
||||||
|
private string _function_code;
|
||||||
|
private string _start_address_from_zero;
|
||||||
|
private string _is_del;
|
||||||
|
private string _creat_by;
|
||||||
|
private DateTime? _creat_time;
|
||||||
|
private string _update_by;
|
||||||
|
private DateTime? _update_time;
|
||||||
|
/// <summary>
|
||||||
|
/// auto_increment
|
||||||
|
/// </summary>
|
||||||
|
public long id
|
||||||
|
{
|
||||||
|
set{ _id=value;}
|
||||||
|
get{return _id;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string function_code
|
||||||
|
{
|
||||||
|
set{ _function_code=value;}
|
||||||
|
get{return _function_code;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string start_address_from_zero
|
||||||
|
{
|
||||||
|
set{ _start_address_from_zero=value;}
|
||||||
|
get{return _start_address_from_zero;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string is_del
|
||||||
|
{
|
||||||
|
set{ _is_del=value;}
|
||||||
|
get{return _is_del;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string creat_by
|
||||||
|
{
|
||||||
|
set{ _creat_by=value;}
|
||||||
|
get{return _creat_by;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? creat_time
|
||||||
|
{
|
||||||
|
set{ _creat_time=value;}
|
||||||
|
get{return _creat_time;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string update_by
|
||||||
|
{
|
||||||
|
set{ _update_by=value;}
|
||||||
|
get{return _update_by;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? update_time
|
||||||
|
{
|
||||||
|
set{ _update_time=value;}
|
||||||
|
get{return _update_time;}
|
||||||
|
}
|
||||||
|
#endregion Model
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,258 @@
|
||||||
|
/** 版本信息模板在安装目录下,可自行修改。
|
||||||
|
* iot_plc_pt.cs
|
||||||
|
*
|
||||||
|
* 功 能: N/A
|
||||||
|
* 类 名: iot_plc_pt
|
||||||
|
*
|
||||||
|
* Ver 变更日期 负责人 变更内容
|
||||||
|
* ───────────────────────────────────
|
||||||
|
* V0.01 2025/6/14 9:40:01 N/A 初版
|
||||||
|
*
|
||||||
|
* Copyright (c) 2012 Maticsoft Corporation. All rights reserved.
|
||||||
|
*┌──────────────────────────────────┐
|
||||||
|
*│ 此技术信息为本公司机密信息,未经本公司书面同意禁止向第三方披露. │
|
||||||
|
*│ 版权所有:动软卓越(北京)科技有限公司 │
|
||||||
|
*└──────────────────────────────────┘
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
namespace Gather.Mysql.Model
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// iot_plc_pt:实体类(属性说明自动提取数据库字段的描述信息)
|
||||||
|
/// </summary>
|
||||||
|
[Serializable]
|
||||||
|
public partial class iot_plc_pt
|
||||||
|
{
|
||||||
|
public iot_plc_pt()
|
||||||
|
{}
|
||||||
|
#region Model
|
||||||
|
private int _id;
|
||||||
|
private long? _pt_device_id;
|
||||||
|
private string _pt_name;
|
||||||
|
private string _pt_english;
|
||||||
|
private string _pt_relate_english;
|
||||||
|
private string _pt_value;
|
||||||
|
private string _pt_function;
|
||||||
|
private string _pt_pattern;
|
||||||
|
private string _pt_unit;
|
||||||
|
private int? _pt_sort;
|
||||||
|
private string _pt_is_bit_read;
|
||||||
|
private string _pt_bit_index;
|
||||||
|
private string _pt_fault_point;
|
||||||
|
private string _pt_alarm_point;
|
||||||
|
private string _pt_max_value;
|
||||||
|
private string _pt_min_value;
|
||||||
|
private string _pt_range;
|
||||||
|
private string _pt_data_type;
|
||||||
|
private string _pt_byte_order;
|
||||||
|
private string _pt_magnification_ratio;
|
||||||
|
private string _is_del= "0";
|
||||||
|
private string _creat_by;
|
||||||
|
private DateTime? _creat_time;
|
||||||
|
private string _update_by;
|
||||||
|
private DateTime? _update_time;
|
||||||
|
/// <summary>
|
||||||
|
/// auto_increment
|
||||||
|
/// </summary>
|
||||||
|
public int id
|
||||||
|
{
|
||||||
|
set{ _id=value;}
|
||||||
|
get{return _id;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public long? pt_device_id
|
||||||
|
{
|
||||||
|
set{ _pt_device_id=value;}
|
||||||
|
get{return _pt_device_id;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string pt_name
|
||||||
|
{
|
||||||
|
set{ _pt_name=value;}
|
||||||
|
get{return _pt_name;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string pt_english
|
||||||
|
{
|
||||||
|
set{ _pt_english=value;}
|
||||||
|
get{return _pt_english;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string pt_relate_english
|
||||||
|
{
|
||||||
|
set{ _pt_relate_english=value;}
|
||||||
|
get{return _pt_relate_english;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string pt_value
|
||||||
|
{
|
||||||
|
set{ _pt_value=value;}
|
||||||
|
get{return _pt_value;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string pt_function
|
||||||
|
{
|
||||||
|
set{ _pt_function=value;}
|
||||||
|
get{return _pt_function;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string pt_pattern
|
||||||
|
{
|
||||||
|
set{ _pt_pattern=value;}
|
||||||
|
get{return _pt_pattern;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string pt_unit
|
||||||
|
{
|
||||||
|
set{ _pt_unit=value;}
|
||||||
|
get{return _pt_unit;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int? pt_sort
|
||||||
|
{
|
||||||
|
set{ _pt_sort=value;}
|
||||||
|
get{return _pt_sort;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string pt_is_bit_read
|
||||||
|
{
|
||||||
|
set{ _pt_is_bit_read=value;}
|
||||||
|
get{return _pt_is_bit_read;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string pt_bit_index
|
||||||
|
{
|
||||||
|
set{ _pt_bit_index=value;}
|
||||||
|
get{return _pt_bit_index;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string pt_fault_point
|
||||||
|
{
|
||||||
|
set{ _pt_fault_point=value;}
|
||||||
|
get{return _pt_fault_point;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string pt_alarm_point
|
||||||
|
{
|
||||||
|
set{ _pt_alarm_point=value;}
|
||||||
|
get{return _pt_alarm_point;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string pt_max_value
|
||||||
|
{
|
||||||
|
set{ _pt_max_value=value;}
|
||||||
|
get{return _pt_max_value;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string pt_min_value
|
||||||
|
{
|
||||||
|
set{ _pt_min_value=value;}
|
||||||
|
get{return _pt_min_value;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string pt_range
|
||||||
|
{
|
||||||
|
set{ _pt_range=value;}
|
||||||
|
get{return _pt_range;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string pt_data_type
|
||||||
|
{
|
||||||
|
set{ _pt_data_type=value;}
|
||||||
|
get{return _pt_data_type;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string pt_byte_order
|
||||||
|
{
|
||||||
|
set{ _pt_byte_order=value;}
|
||||||
|
get{return _pt_byte_order;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string pt_magnification_ratio
|
||||||
|
{
|
||||||
|
set{ _pt_magnification_ratio=value;}
|
||||||
|
get{return _pt_magnification_ratio;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string is_del
|
||||||
|
{
|
||||||
|
set{ _is_del=value;}
|
||||||
|
get{return _is_del;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string creat_by
|
||||||
|
{
|
||||||
|
set{ _creat_by=value;}
|
||||||
|
get{return _creat_by;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? creat_time
|
||||||
|
{
|
||||||
|
set{ _creat_time=value;}
|
||||||
|
get{return _creat_time;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string update_by
|
||||||
|
{
|
||||||
|
set{ _update_by=value;}
|
||||||
|
get{return _update_by;}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? update_time
|
||||||
|
{
|
||||||
|
set{ _update_time=value;}
|
||||||
|
get{return _update_time;}
|
||||||
|
}
|
||||||
|
#endregion Model
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,84 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.4.33122.133
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GatherAPI", "GatherAPI\GatherAPI.csproj", "{282944FE-EBE1-43DE-8A19-AC2227EB0B49}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Gather.Mysql", "Gather.Mysql\Gather.Mysql.csproj", "{D5B7A73B-974B-4BD2-8C7E-E0EF162F75B9}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Gather.Model", "Gather.Model\Gather.Model.csproj", "{E96226DB-B062-4D2B-9D86-FF88DC75125D}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Gather.Common", "Gather.Common\Gather.Common.csproj", "{6943AED8-E694-4D14-9DDE-4E35CEE84C6F}"
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Gather_Base", "Gather_Base", "{9AF09A3C-A61B-4BD4-A95B-3A261FE5705F}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Gather.BLL", "Gather.BLL\Gather.BLL.csproj", "{B685DE8B-B9F8-440C-9F4C-B77F202300A2}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Gather.DAL", "Gather.DAL\Gather.DAL.csproj", "{DF8868E6-6C2A-4F6E-891D-790951989DCC}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Gather.IBLL", "Gather.IBLL\Gather.IBLL.csproj", "{D7C6316C-0018-4169-B55B-4FD9642E2E5D}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Gather.IDAL", "Gather.IDAL\Gather.IDAL.csproj", "{CB464FEC-4D12-4C2E-AEC5-6E19559ABC7A}"
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "服务", "服务", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataAcquisition", "DataAcquisition\DataAcquisition.csproj", "{D7543659-CA38-45A9-917B-D938CDCAC769}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{282944FE-EBE1-43DE-8A19-AC2227EB0B49}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{282944FE-EBE1-43DE-8A19-AC2227EB0B49}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{282944FE-EBE1-43DE-8A19-AC2227EB0B49}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{282944FE-EBE1-43DE-8A19-AC2227EB0B49}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{D5B7A73B-974B-4BD2-8C7E-E0EF162F75B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{D5B7A73B-974B-4BD2-8C7E-E0EF162F75B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{D5B7A73B-974B-4BD2-8C7E-E0EF162F75B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{D5B7A73B-974B-4BD2-8C7E-E0EF162F75B9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{E96226DB-B062-4D2B-9D86-FF88DC75125D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{E96226DB-B062-4D2B-9D86-FF88DC75125D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{E96226DB-B062-4D2B-9D86-FF88DC75125D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{E96226DB-B062-4D2B-9D86-FF88DC75125D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{6943AED8-E694-4D14-9DDE-4E35CEE84C6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{6943AED8-E694-4D14-9DDE-4E35CEE84C6F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{6943AED8-E694-4D14-9DDE-4E35CEE84C6F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{6943AED8-E694-4D14-9DDE-4E35CEE84C6F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{B685DE8B-B9F8-440C-9F4C-B77F202300A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{B685DE8B-B9F8-440C-9F4C-B77F202300A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{B685DE8B-B9F8-440C-9F4C-B77F202300A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{B685DE8B-B9F8-440C-9F4C-B77F202300A2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{DF8868E6-6C2A-4F6E-891D-790951989DCC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{DF8868E6-6C2A-4F6E-891D-790951989DCC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{DF8868E6-6C2A-4F6E-891D-790951989DCC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{DF8868E6-6C2A-4F6E-891D-790951989DCC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{D7C6316C-0018-4169-B55B-4FD9642E2E5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{D7C6316C-0018-4169-B55B-4FD9642E2E5D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{D7C6316C-0018-4169-B55B-4FD9642E2E5D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{D7C6316C-0018-4169-B55B-4FD9642E2E5D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{CB464FEC-4D12-4C2E-AEC5-6E19559ABC7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{CB464FEC-4D12-4C2E-AEC5-6E19559ABC7A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{CB464FEC-4D12-4C2E-AEC5-6E19559ABC7A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{CB464FEC-4D12-4C2E-AEC5-6E19559ABC7A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{D7543659-CA38-45A9-917B-D938CDCAC769}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{D7543659-CA38-45A9-917B-D938CDCAC769}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{D7543659-CA38-45A9-917B-D938CDCAC769}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{D7543659-CA38-45A9-917B-D938CDCAC769}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(NestedProjects) = preSolution
|
||||||
|
{B685DE8B-B9F8-440C-9F4C-B77F202300A2} = {9AF09A3C-A61B-4BD4-A95B-3A261FE5705F}
|
||||||
|
{DF8868E6-6C2A-4F6E-891D-790951989DCC} = {9AF09A3C-A61B-4BD4-A95B-3A261FE5705F}
|
||||||
|
{D7C6316C-0018-4169-B55B-4FD9642E2E5D} = {9AF09A3C-A61B-4BD4-A95B-3A261FE5705F}
|
||||||
|
{CB464FEC-4D12-4C2E-AEC5-6E19559ABC7A} = {9AF09A3C-A61B-4BD4-A95B-3A261FE5705F}
|
||||||
|
{D7543659-CA38-45A9-917B-D938CDCAC769} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {3A7FB099-8B53-4CD2-BBC4-D963B54CEABB}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"version": 1,
|
||||||
|
"isRoot": true,
|
||||||
|
"tools": {
|
||||||
|
"dotnet-ef": {
|
||||||
|
"version": "9.0.4",
|
||||||
|
"commands": [
|
||||||
|
"dotnet-ef"
|
||||||
|
],
|
||||||
|
"rollForward": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,277 @@
|
||||||
|
using Gather.Common.Util;
|
||||||
|
using GatherAPI.api;
|
||||||
|
using HslCommunication.Core;
|
||||||
|
using HslCommunication.ModBus;
|
||||||
|
using log4net;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using Pomelo.Data.MySql.Memcached;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace GatherAPI.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
public class ControlDeviceController : Controller
|
||||||
|
{
|
||||||
|
public ControlDeviceController()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 控制设备接口
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
public JsonResult Index([FromBody] ControlDeviceRequest req)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(req.ip))
|
||||||
|
{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "IP不能为空"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(req.port))
|
||||||
|
{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "端口号不能为空"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(req.station))
|
||||||
|
{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "站号不能为空"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(req.function_code))
|
||||||
|
{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "功能码不能为空"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(req.data_type))
|
||||||
|
{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "数据类型不能为空"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(req.byte_order))
|
||||||
|
{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "字节顺序不能为空"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(req.is_bit_read))
|
||||||
|
{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "是否按二进制位读取不能为空"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.is_bit_read == "1")
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(req.bit_index))
|
||||||
|
{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "位索引(0-7)不能为空"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(req.attr_value))
|
||||||
|
{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "点位不能为空"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(req.value))
|
||||||
|
{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "值不能为空"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(req.start_address_from_zero))
|
||||||
|
{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "是否从0开始不能为空"));
|
||||||
|
}
|
||||||
|
|
||||||
|
var modbusTcp = new ModbusTcpNet(req.ip, int.Parse(req.port), byte.Parse(req.station));
|
||||||
|
if (req.start_address_from_zero == "1")
|
||||||
|
{
|
||||||
|
modbusTcp.AddressStartWithZero = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
modbusTcp.AddressStartWithZero = false;
|
||||||
|
}
|
||||||
|
if (req.function_code == "01")
|
||||||
|
{
|
||||||
|
modbusTcp.ByteTransform.DataFormat = GetDataFormat(req.byte_order);
|
||||||
|
var value = bool.Parse(req.value);
|
||||||
|
var result1 = modbusTcp.Write(req.attr_value, value);
|
||||||
|
if (result1.IsSuccess)
|
||||||
|
{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Success, "控制成功"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "控制失败"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (req.function_code == "03")
|
||||||
|
{
|
||||||
|
modbusTcp.ByteTransform.DataFormat = GetDataFormat(req.byte_order);
|
||||||
|
if (req.is_bit_read == "1")
|
||||||
|
{
|
||||||
|
req.attr_value = req.attr_value + "." + req.bit_index;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.data_type == "short")
|
||||||
|
{
|
||||||
|
var value = short.Parse(req.value);
|
||||||
|
var result = modbusTcp.Write(req.attr_value, value);
|
||||||
|
if (result.IsSuccess)
|
||||||
|
{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Success, "控制成功"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "控制失败"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (req.data_type == "ushort")
|
||||||
|
{
|
||||||
|
var value = ushort.Parse(req.value);
|
||||||
|
var result = modbusTcp.Write(req.attr_value, value);
|
||||||
|
if (result.IsSuccess)
|
||||||
|
{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Success, "控制成功"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "控制失败"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (req.data_type == "int")
|
||||||
|
{
|
||||||
|
if (req.is_bit_read == "1")
|
||||||
|
{
|
||||||
|
bool value = req.value == "1";
|
||||||
|
var result = modbusTcp.Write(req.attr_value, value);
|
||||||
|
if (result.IsSuccess)
|
||||||
|
{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Success, "控制成功"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "控制失败"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var value = int.Parse(req.value);
|
||||||
|
var result = modbusTcp.Write(req.attr_value, value);
|
||||||
|
if (result.IsSuccess)
|
||||||
|
{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Success, "控制成功"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "控制失败"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (req.data_type == "uint")
|
||||||
|
{
|
||||||
|
var value = uint.Parse(req.value);
|
||||||
|
var result = modbusTcp.Write(req.attr_value, value);
|
||||||
|
if (result.IsSuccess)
|
||||||
|
{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Success, "控制成功"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "控制失败"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (req.data_type == "long")
|
||||||
|
{
|
||||||
|
var value = long.Parse(req.value);
|
||||||
|
var result = modbusTcp.Write(req.attr_value, value);
|
||||||
|
if (result.IsSuccess)
|
||||||
|
{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Success, "控制成功"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "控制失败"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (req.data_type == "ulong")
|
||||||
|
{
|
||||||
|
var value = ulong.Parse(req.value);
|
||||||
|
var result = modbusTcp.Write(req.attr_value, value);
|
||||||
|
if (result.IsSuccess)
|
||||||
|
{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Success, "控制成功"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "控制失败"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (req.data_type == "float")
|
||||||
|
{
|
||||||
|
var value = float.Parse(req.value);
|
||||||
|
var result = modbusTcp.Write(req.attr_value, value);
|
||||||
|
if (result.IsSuccess)
|
||||||
|
{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Success, "控制成功"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "控制失败"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (req.data_type == "double")
|
||||||
|
{
|
||||||
|
var value = double.Parse(req.value);
|
||||||
|
var result = modbusTcp.Write(req.attr_value, value);
|
||||||
|
if (result.IsSuccess)
|
||||||
|
{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Success, "控制成功"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "控制失败"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "数据类型不支持"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "功能码不支持"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Util.LogHelper.WriteLog(ex.Message + ",行号:" + ex.StackTrace);
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "发生错误,请联系管理员。"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private DataFormat GetDataFormat(string byteOrder)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(byteOrder))
|
||||||
|
{
|
||||||
|
return DataFormat.ABCD;
|
||||||
|
}
|
||||||
|
switch (byteOrder?.ToUpper())
|
||||||
|
{
|
||||||
|
case "ABCD": return DataFormat.ABCD;
|
||||||
|
case "BADC": return DataFormat.BADC;
|
||||||
|
case "CDAB": return DataFormat.CDAB;
|
||||||
|
case "DCBA": return DataFormat.DCBA;
|
||||||
|
default: return DataFormat.ABCD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
using Gather.Common.Util;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace GatherAPI.Controllers.back
|
||||||
|
{
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
public class DeleteFileController : Controller
|
||||||
|
{
|
||||||
|
private readonly IWebHostEnvironment _webHostEnvironment;
|
||||||
|
|
||||||
|
public DeleteFileController(IWebHostEnvironment webHostEnvironment)
|
||||||
|
{
|
||||||
|
_webHostEnvironment = webHostEnvironment;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除文件接口
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Path">文件路径</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[Authorize]
|
||||||
|
[HttpGet]
|
||||||
|
public JsonResult Index(string Path)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//var webRootPath = _webHostEnvironment.WebRootPath;
|
||||||
|
//if (System.IO.File.Exists(webRootPath + "/" + Path))
|
||||||
|
//{
|
||||||
|
// var array = Path.Split('/');
|
||||||
|
// if (array.Length > 0)
|
||||||
|
// {
|
||||||
|
// Array.Resize(ref array, array.Length - 1);
|
||||||
|
// }
|
||||||
|
// var new_path = string.Join("/", array);
|
||||||
|
// Tool.DeleteDir(webRootPath + new_path);
|
||||||
|
//}
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Success, "删除成功"));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Util.LogHelper.WriteLog(ex.Message + ",行号:" + ex.StackTrace);
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "发生错误,请联系管理员。"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
using Gather.Common.Util;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace GatherAPI.Controllers.back
|
||||||
|
{
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
public class DownloadFileController : Controller
|
||||||
|
{
|
||||||
|
private readonly IWebHostEnvironment _webHostEnvironment;
|
||||||
|
|
||||||
|
public DownloadFileController(IWebHostEnvironment webHostEnvironment)
|
||||||
|
{
|
||||||
|
_webHostEnvironment = webHostEnvironment;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 下载文件接口
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Path">文件路径</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[Authorize]
|
||||||
|
[HttpGet]
|
||||||
|
public ActionResult Index(string Path)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(Path))
|
||||||
|
{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "路径不能为空"));
|
||||||
|
}
|
||||||
|
string web_path = _webHostEnvironment.WebRootPath;
|
||||||
|
var filePath = web_path + "/" + Path;
|
||||||
|
//以字符流的形式下载文件
|
||||||
|
FileStream fs = new FileStream(filePath, System.IO.FileMode.Open);
|
||||||
|
byte[] bytes = new byte[(int)fs.Length];
|
||||||
|
fs.Read(bytes, 0, bytes.Length);
|
||||||
|
fs.Close();
|
||||||
|
string displayName = System.IO.Path.GetFileName(filePath);
|
||||||
|
return File(bytes, "application/octet-stream", displayName);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Util.LogHelper.WriteLog(ex.Message + ",行号:" + ex.StackTrace);
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "发生错误,请联系管理员。"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,123 @@
|
||||||
|
using Gather.Common.Util;
|
||||||
|
using GatherAPI.api.back;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Polly;
|
||||||
|
|
||||||
|
namespace GatherAPI.Controllers.back
|
||||||
|
{
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
public class UploadController : Controller
|
||||||
|
{
|
||||||
|
private readonly IWebHostEnvironment _webHostEnvironment;
|
||||||
|
|
||||||
|
public IConfiguration Configuration { get; }
|
||||||
|
|
||||||
|
public UploadController(IWebHostEnvironment webHostEnvironment, IConfiguration configuration)
|
||||||
|
{
|
||||||
|
_webHostEnvironment = webHostEnvironment;
|
||||||
|
Configuration = configuration;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 分片上传文件接口
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="file">请求参数</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[Authorize]
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<JsonResult> RuleUploadFile([FromQuery] SliceFileInfo file)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string path = System.IO.Path.Combine(_webHostEnvironment.WebRootPath, "Upload", file.FolderName);
|
||||||
|
|
||||||
|
var files = Request.Form.Files;
|
||||||
|
var buffer = new byte[file.Size];
|
||||||
|
var fileName = file.Name.Replace("(", "").Replace(")", "").Replace("(", "").Replace(")", "");
|
||||||
|
path = path + "//" + fileName + "//";
|
||||||
|
if (!System.IO.Directory.Exists(path))
|
||||||
|
{
|
||||||
|
System.IO.Directory.CreateDirectory(path);
|
||||||
|
}
|
||||||
|
string filepath = path + "//" + file.Name.Replace("(", "").Replace(")", "").Replace("(", "").Replace(")", "") + "^" + file.Number;
|
||||||
|
using (var stream = new FileStream(filepath, FileMode.Append))
|
||||||
|
{
|
||||||
|
await files[0].CopyToAsync(stream);
|
||||||
|
}
|
||||||
|
var filesList = Directory.GetFiles(Path.GetDirectoryName(path));
|
||||||
|
|
||||||
|
//当顺序号等于分片总数量 合并文件
|
||||||
|
if ((file.Number + 1) == file.Count || filesList.Length == file.Count)
|
||||||
|
{
|
||||||
|
await MergeFile(file);
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Success, "/Upload/" + file.FolderName + "/" + file.Name.Replace("(", "").Replace(")", "").Replace("(", "").Replace(")", "") + "/" + fileName.Split("~")[0].ToString()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Success, "成功"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Util.LogHelper.WriteLog(ex.Message + ",行号:" + ex.StackTrace);
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "发生错误,请联系管理员。"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 合并文件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="file"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private async Task MergeFile(SliceFileInfo file)
|
||||||
|
{
|
||||||
|
string path = System.IO.Path.Combine(_webHostEnvironment.WebRootPath, "Upload", file.FolderName);
|
||||||
|
var fileName = file.Name.Replace("(", "").Replace(")", "").Replace("(", "").Replace(")", "");
|
||||||
|
path = path + "//" + fileName + "//";
|
||||||
|
string baseFileName = path + fileName.Split("~")[0].ToString();
|
||||||
|
if (!System.IO.Directory.Exists(path))
|
||||||
|
{
|
||||||
|
System.IO.Directory.CreateDirectory(path);
|
||||||
|
}
|
||||||
|
var filesList = Directory.GetFiles(Path.GetDirectoryName(path));
|
||||||
|
if (filesList.Length != file.Count)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<FileSort> lstFile = new List<FileSort>();
|
||||||
|
foreach (var item in filesList)
|
||||||
|
{
|
||||||
|
lstFile.Add(new FileSort()
|
||||||
|
{
|
||||||
|
Name = item,
|
||||||
|
NumBer = Convert.ToInt32(item.Substring(item.IndexOf('^') + 1))
|
||||||
|
});
|
||||||
|
}
|
||||||
|
lstFile = lstFile.OrderBy(x => x.NumBer).ToList();
|
||||||
|
using (var fileStream = new FileStream(baseFileName, FileMode.Create))
|
||||||
|
{
|
||||||
|
await Policy.Handle<IOException>()
|
||||||
|
.RetryForeverAsync()
|
||||||
|
.ExecuteAsync(async () =>
|
||||||
|
{
|
||||||
|
foreach (var fileSort in lstFile)
|
||||||
|
{
|
||||||
|
using (FileStream fileChunk = new FileStream(fileSort.Name, FileMode.Open))
|
||||||
|
{
|
||||||
|
await fileChunk.CopyToAsync(fileStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//删除分片文件
|
||||||
|
foreach (var dirfile in filesList)
|
||||||
|
{
|
||||||
|
System.IO.File.Delete(dirfile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,103 @@
|
||||||
|
using Gather.Common.Util;
|
||||||
|
using GatherAPI.api.back;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace GatherAPI.Controllers.back
|
||||||
|
{
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
public class UploadFileController : Controller
|
||||||
|
{
|
||||||
|
private readonly IWebHostEnvironment _webHostEnvironment;
|
||||||
|
|
||||||
|
public UploadFileController(IWebHostEnvironment webHostEnvironment)
|
||||||
|
{
|
||||||
|
_webHostEnvironment = webHostEnvironment;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 不分片上传文件接口
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Files">文件</param>
|
||||||
|
/// <param name="req">非文件其它的业务参数</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[Authorize]
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<JsonResult> Index([FromForm] IFormFile Files, [FromForm] UploadFileRequest req)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(req.ExamId))
|
||||||
|
{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "考试id不能为空"));
|
||||||
|
}
|
||||||
|
if (string.IsNullOrWhiteSpace(req.UserId))
|
||||||
|
{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "用户id不能为空"));
|
||||||
|
}
|
||||||
|
if (string.IsNullOrWhiteSpace(req.FileDesc))
|
||||||
|
{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "文件描述不能为空"));
|
||||||
|
}
|
||||||
|
|
||||||
|
//var model = achievement_bll.GetModelList(" ExamId='" + req.ExamId + "' and UserId='" + req.UserId + "'").FirstOrDefault();
|
||||||
|
//if (model == null)
|
||||||
|
//{
|
||||||
|
// return Json(Tool.GetJsonWithCode(APICode.Fail, "找不到考生考试记录"));
|
||||||
|
//}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (Files.Length <= 0)
|
||||||
|
{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "文件不能为空"));
|
||||||
|
}
|
||||||
|
// Handle file upload
|
||||||
|
var fileName = Guid.NewGuid().ToString() + Path.GetExtension(Files.FileName);
|
||||||
|
var folderPath = "/Upload/PlayBack/";
|
||||||
|
if (!Directory.Exists(_webHostEnvironment.WebRootPath + folderPath))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(_webHostEnvironment.WebRootPath + folderPath);
|
||||||
|
}
|
||||||
|
var filePath = folderPath + fileName;
|
||||||
|
var serverPath = _webHostEnvironment.WebRootPath + filePath;
|
||||||
|
using (var stream = new FileStream(serverPath, FileMode.Create))
|
||||||
|
{
|
||||||
|
await Files.CopyToAsync(stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
//var video_model = new Gather.Mysql.Model.pow_video();
|
||||||
|
//video_model.VideoId = Guid.NewGuid().ToString("N");
|
||||||
|
//video_model.AchievementId = model.AchievementId;
|
||||||
|
//video_model.VideoPath = filePath;
|
||||||
|
//video_model.VideoDesc = req.FileDesc;
|
||||||
|
//video_model.CreateTime = DateTime.Now;
|
||||||
|
|
||||||
|
//if (video_bll.Add(video_model))
|
||||||
|
//{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Success, "文件上传成功"));
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
// if (System.IO.File.Exists(serverPath))
|
||||||
|
// {
|
||||||
|
// System.IO.File.Delete(serverPath);
|
||||||
|
// }
|
||||||
|
// return Json(Tool.GetJsonWithCode(APICode.Fail, "文件上传失败"));
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Fail, e.Message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Util.LogHelper.WriteLog(ex.Message + ",行号:" + ex.StackTrace);
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "发生错误,请联系管理员。"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
|
||||||
|
WORKDIR /app
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
|
||||||
|
WORKDIR /src
|
||||||
|
COPY ["GatherAPI/GatherAPI.csproj", "GatherAPI/"]
|
||||||
|
RUN dotnet restore "GatherAPI/GatherAPI.csproj"
|
||||||
|
COPY . .
|
||||||
|
WORKDIR "/src/GatherAPI"
|
||||||
|
RUN dotnet build "GatherAPI.csproj" -c Release -o /app/build
|
||||||
|
|
||||||
|
FROM build AS publish
|
||||||
|
RUN dotnet publish "GatherAPI.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
||||||
|
|
||||||
|
FROM base AS final
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=publish /app/publish .
|
||||||
|
ENTRYPOINT ["dotnet", "GatherAPI.dll"]
|
|
@ -0,0 +1,49 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="9.0.0" />
|
||||||
|
<PackageReference Include="HslCommunication" Version="12.3.0" />
|
||||||
|
<PackageReference Include="log4net" Version="2.0.15" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.28" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.13" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.22" />
|
||||||
|
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.0" />
|
||||||
|
<PackageReference Include="MQTTnet" Version="4.1.4.563" />
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
|
||||||
|
<PackageReference Include="Polly" Version="8.4.1" />
|
||||||
|
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.2.7" />
|
||||||
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
||||||
|
<PackageReference Include="System.Text.Encoding.CodePages" Version="9.0.4" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Update="GatherAPI.xml">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Gather.BLL\Gather.BLL.csproj" />
|
||||||
|
<ProjectReference Include="..\Gather.Common\Gather.Common.csproj" />
|
||||||
|
<ProjectReference Include="..\Gather.DAL\Gather.DAL.csproj" />
|
||||||
|
<ProjectReference Include="..\Gather.Model\Gather.Model.csproj" />
|
||||||
|
<ProjectReference Include="..\Gather.Mysql\Gather.Mysql.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Update="appsettings.json">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Update="Log4net.config">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<ActiveDebugProfile>CompetitionAPI</ActiveDebugProfile>
|
||||||
|
<Controller_SelectedScaffolderID>ApiControllerEmptyScaffolder</Controller_SelectedScaffolderID>
|
||||||
|
<Controller_SelectedScaffolderCategoryPath>root/Common/Api</Controller_SelectedScaffolderCategoryPath>
|
||||||
|
<NameOfLastUsedPublishProfile>F:\项目\河北高速\web\xinjiang-iot-service\GatherAPI\Properties\PublishProfiles\FolderProfile1.pubxml</NameOfLastUsedPublishProfile>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
|
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
|
@ -0,0 +1,3 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<doc>
|
||||||
|
</doc>
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<configSections>
|
||||||
|
|
||||||
|
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
|
||||||
|
|
||||||
|
</configSections>
|
||||||
|
<log4net>
|
||||||
|
<root>
|
||||||
|
<level value="ALL" />
|
||||||
|
<appender-ref ref="SysAppender" />
|
||||||
|
</root>
|
||||||
|
<logger name="WebLogger">
|
||||||
|
<level value="DEBUG" />
|
||||||
|
</logger>
|
||||||
|
<appender name="SysAppender" type="log4net.Appender.RollingFileAppender,log4net">
|
||||||
|
<param name="File" value="App_Data/" />
|
||||||
|
<param name="AppendToFile" value="true" />
|
||||||
|
<param name="RollingStyle" value="Date" />
|
||||||
|
<param name="DatePattern" value=""Logs_"yyyyMMdd".txt"" />
|
||||||
|
<param name="StaticLogFileName" value="false" />
|
||||||
|
<layout type="log4net.Layout.PatternLayout,log4net">
|
||||||
|
<param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n" />
|
||||||
|
<param name="Header" value=" ------------------------------------------------
" />
|
||||||
|
<param name="Footer" value=" ------------------------------------------------
" />
|
||||||
|
</layout>
|
||||||
|
</appender>
|
||||||
|
<appender name="consoleApp" type="log4net.Appender.ConsoleAppender,log4net">
|
||||||
|
<layout type="log4net.Layout.PatternLayout,log4net">
|
||||||
|
<param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n" />
|
||||||
|
</layout>
|
||||||
|
</appender>
|
||||||
|
</log4net>
|
||||||
|
</configuration>
|
|
@ -0,0 +1,23 @@
|
||||||
|
using Autofac.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
|
||||||
|
namespace GatherAPI
|
||||||
|
{
|
||||||
|
public class Program
|
||||||
|
{
|
||||||
|
public static void Main(string[] args)
|
||||||
|
{
|
||||||
|
//log4net.Config.XmlConfigurator.Configure();
|
||||||
|
CreateHostBuilder(args).Build().Run();
|
||||||
|
HslCommunication.Authorization.SetAuthorizationCode("d8868ab9-4494-4056-98c6-b669e2434e25");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||||
|
Host.CreateDefaultBuilder(args).UseServiceProviderFactory(new AutofacServiceProviderFactory())
|
||||||
|
.ConfigureWebHostDefaults(webBuilder =>
|
||||||
|
{
|
||||||
|
webBuilder.UseUrls("http://*:5005");
|
||||||
|
webBuilder.UseStartup<Startup>();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- https://go.microsoft.com/fwlink/?LinkID=208121. -->
|
||||||
|
<Project>
|
||||||
|
<PropertyGroup>
|
||||||
|
<DeleteExistingFiles>true</DeleteExistingFiles>
|
||||||
|
<ExcludeApp_Data>false</ExcludeApp_Data>
|
||||||
|
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
|
||||||
|
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
|
||||||
|
<LastUsedPlatform>Any CPU</LastUsedPlatform>
|
||||||
|
<PublishProvider>FileSystem</PublishProvider>
|
||||||
|
<PublishUrl>bin\Release\net6.0\publish\</PublishUrl>
|
||||||
|
<WebPublishMethod>FileSystem</WebPublishMethod>
|
||||||
|
<_TargetId>Folder</_TargetId>
|
||||||
|
<SiteUrlToLaunchAfterPublish />
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ProjectGuid>282944fe-ebe1-43de-8a19-ac2227eb0b49</ProjectGuid>
|
||||||
|
<SelfContained>false</SelfContained>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- https://go.microsoft.com/fwlink/?LinkID=208121. -->
|
||||||
|
<Project>
|
||||||
|
<PropertyGroup>
|
||||||
|
<_PublishTargetUrl>F:\项目\河北高速\项目\CentralizedProcurement\GatherAPI\bin\Release\net6.0\publish\</_PublishTargetUrl>
|
||||||
|
<History>True|2025-04-25T06:42:06.2820132Z||;True|2025-04-25T14:06:53.3449943+08:00||;</History>
|
||||||
|
<LastFailureDetails />
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- https://go.microsoft.com/fwlink/?LinkID=208121. -->
|
||||||
|
<Project>
|
||||||
|
<PropertyGroup>
|
||||||
|
<DeleteExistingFiles>true</DeleteExistingFiles>
|
||||||
|
<ExcludeApp_Data>false</ExcludeApp_Data>
|
||||||
|
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
|
||||||
|
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
|
||||||
|
<LastUsedPlatform>Any CPU</LastUsedPlatform>
|
||||||
|
<PublishProvider>FileSystem</PublishProvider>
|
||||||
|
<PublishUrl>bin\Release\net6.0\publish\</PublishUrl>
|
||||||
|
<WebPublishMethod>FileSystem</WebPublishMethod>
|
||||||
|
<_TargetId>Folder</_TargetId>
|
||||||
|
<SiteUrlToLaunchAfterPublish />
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ProjectGuid>282944fe-ebe1-43de-8a19-ac2227eb0b49</ProjectGuid>
|
||||||
|
<SelfContained>false</SelfContained>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- https://go.microsoft.com/fwlink/?LinkID=208121. -->
|
||||||
|
<Project>
|
||||||
|
<PropertyGroup>
|
||||||
|
<_PublishTargetUrl>F:\项目\河北高速\web\xinjiang-iot-service\GatherAPI\bin\Release\net6.0\publish\</_PublishTargetUrl>
|
||||||
|
<History>True|2025-05-20T02:35:58.9664949Z||;True|2025-05-14T16:06:40.5067158+08:00||;True|2025-05-14T16:05:19.2504310+08:00||;True|2025-05-12T13:49:24.1605189+08:00||;True|2025-05-12T13:31:02.6790977+08:00||;True|2025-05-09T10:23:50.7552419+08:00||;True|2025-05-09T10:23:41.2624961+08:00||;True|2025-05-09T09:36:31.7732227+08:00||;</History>
|
||||||
|
<LastFailureDetails />
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
|
@ -0,0 +1,37 @@
|
||||||
|
{
|
||||||
|
"profiles": {
|
||||||
|
"GatherAPI": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
},
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"applicationUrl": "http://localhost:5005"
|
||||||
|
},
|
||||||
|
"IIS Express": {
|
||||||
|
"commandName": "IISExpress",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Docker": {
|
||||||
|
"commandName": "Docker",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
|
||||||
|
"publishAllPorts": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||||
|
"iisSettings": {
|
||||||
|
"windowsAuthentication": false,
|
||||||
|
"anonymousAuthentication": true,
|
||||||
|
"iisExpress": {
|
||||||
|
"applicationUrl": "http://localhost:17785",
|
||||||
|
"sslPort": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,242 @@
|
||||||
|
using Autofac;
|
||||||
|
using log4net;
|
||||||
|
using log4net.Config;
|
||||||
|
using Microsoft.AspNetCore.Http.Features;
|
||||||
|
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
||||||
|
using Microsoft.OpenApi.Models;
|
||||||
|
using System.Text.Encodings.Web;
|
||||||
|
using System.Text.Unicode;
|
||||||
|
using Gather.BLL;
|
||||||
|
using Gather.DAL;
|
||||||
|
using Gather.Model;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using System.Linq;
|
||||||
|
using System.IO;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Newtonsoft.Json.Serialization;
|
||||||
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
|
using Microsoft.IdentityModel.Tokens;
|
||||||
|
using System.Text;
|
||||||
|
using System.Security.Claims;
|
||||||
|
using Gather.Common.Util;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace GatherAPI
|
||||||
|
{
|
||||||
|
public class Startup
|
||||||
|
{
|
||||||
|
public static log4net.Repository.ILoggerRepository repository;
|
||||||
|
|
||||||
|
public Startup(IConfiguration configuration)
|
||||||
|
{
|
||||||
|
Configuration = configuration;
|
||||||
|
repository = LogManager.CreateRepository("NETCoreRepository");
|
||||||
|
XmlConfigurator.Configure(repository, new FileInfo("Log4net.config"));
|
||||||
|
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IConfiguration Configuration { get; }
|
||||||
|
|
||||||
|
// This method gets called by the runtime. Use this method to add services to the container.
|
||||||
|
public void ConfigureServices(IServiceCollection services)
|
||||||
|
{
|
||||||
|
//配置跨域访问问题
|
||||||
|
services.AddCors(
|
||||||
|
options => options.AddPolicy("CorsTest",
|
||||||
|
p => p.AllowAnyOrigin()
|
||||||
|
.AllowAnyHeader()
|
||||||
|
.AllowAnyMethod()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
services.Configure<FormOptions>(options =>
|
||||||
|
{
|
||||||
|
options.KeyLengthLimit = int.MaxValue;
|
||||||
|
options.ValueLengthLimit = int.MaxValue;
|
||||||
|
options.MultipartBodyLengthLimit = int.MaxValue;
|
||||||
|
options.MultipartHeadersLengthLimit = int.MaxValue;
|
||||||
|
});
|
||||||
|
services.Configure<KestrelServerOptions>(options =>
|
||||||
|
{
|
||||||
|
options.Limits.MaxRequestBodySize = int.MaxValue;
|
||||||
|
options.Limits.MaxRequestBufferSize = int.MaxValue;
|
||||||
|
});
|
||||||
|
//禁用自动模型验证
|
||||||
|
services.Configure<ApiBehaviorOptions>(options =>
|
||||||
|
{
|
||||||
|
options.SuppressModelStateInvalidFilter = true;
|
||||||
|
});
|
||||||
|
services.AddDbContext<Gather_dbContext>(options => options.UseMySql(Configuration.GetConnectionString("MySQL")));
|
||||||
|
services.AddControllers().AddJsonOptions(options =>
|
||||||
|
{
|
||||||
|
options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All);
|
||||||
|
});
|
||||||
|
////注册Swagger生成器,定义一个和多个Swagger 文档
|
||||||
|
//services.AddSwaggerGen(c =>
|
||||||
|
//{
|
||||||
|
// c.SwaggerDoc("v1", new OpenApiInfo { Title = "GatherAPI" });
|
||||||
|
// // 为 Swagger JSON and UI设置xml文档注释路径
|
||||||
|
// var basePath = Path.GetDirectoryName(typeof(Program).Assembly.Location);//获取应用程序所在目录(绝对,不受工作目录影响,建议采用此方法获取路径)
|
||||||
|
// var xmlPath = Path.Combine(basePath, "GatherAPI.xml");
|
||||||
|
// c.IncludeXmlComments(xmlPath);
|
||||||
|
//});
|
||||||
|
|
||||||
|
services.AddControllers().AddNewtonsoftJson(options =>
|
||||||
|
{
|
||||||
|
//配置返回Json大小写格式与Model一致
|
||||||
|
options.SerializerSettings.ContractResolver = new DefaultContractResolver();
|
||||||
|
});
|
||||||
|
|
||||||
|
//添加MVC组件
|
||||||
|
services.AddMvc().AddNewtonsoftJson(options =>
|
||||||
|
{
|
||||||
|
options.SerializerSettings.Converters.Add(new Newtonsoft.Json.Converters.IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" });
|
||||||
|
});
|
||||||
|
|
||||||
|
//注入Http
|
||||||
|
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
||||||
|
|
||||||
|
// 确保 TokenService 类被正确注册
|
||||||
|
//services.AddSingleton<TokenService>(new TokenService(Configuration["Jwt:SecretKey"], Configuration["Jwt:Issuer"]));
|
||||||
|
|
||||||
|
// 添加身份验证服务
|
||||||
|
//services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
||||||
|
// .AddJwtBearer(options =>
|
||||||
|
// {
|
||||||
|
// options.TokenValidationParameters = new TokenValidationParameters
|
||||||
|
// {
|
||||||
|
// ValidateIssuer = true,
|
||||||
|
// ValidIssuer = Configuration["Jwt:Issuer"],
|
||||||
|
// ValidateIssuerSigningKey = true,
|
||||||
|
// IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration["Jwt:SecretKey"])),
|
||||||
|
// ValidateAudience = false,
|
||||||
|
// ValidateLifetime = true,
|
||||||
|
// ClockSkew = TimeSpan.Zero
|
||||||
|
// };
|
||||||
|
// options.Events = new JwtBearerEvents
|
||||||
|
// {
|
||||||
|
// // 添加自定义的Token验证后的处理逻辑
|
||||||
|
// OnTokenValidated = async context =>
|
||||||
|
// {
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// // 获取请求头中的Authorization值
|
||||||
|
// string authorizationHeader = context.HttpContext.Request.Headers["Authorization"];
|
||||||
|
|
||||||
|
// // 确保Authorization头存在且以Bearer开头
|
||||||
|
// if (!string.IsNullOrEmpty(authorizationHeader) && authorizationHeader.StartsWith("Bearer "))
|
||||||
|
// {
|
||||||
|
// // 提取Token值
|
||||||
|
// var token = authorizationHeader.Substring("Bearer ".Length).Trim();
|
||||||
|
|
||||||
|
// // 在这里可以访问验证后的Principal(包含用户信息)
|
||||||
|
// var claimsPrincipal = context.Principal.Claims;
|
||||||
|
// var userId = claimsPrincipal.First(claim => claim.Type == ClaimTypes.NameIdentifier).Value;
|
||||||
|
// var roleId = claimsPrincipal.First(claim => claim.Type == ClaimTypes.Role).Value;
|
||||||
|
// if (roleId == "2")
|
||||||
|
// {
|
||||||
|
// Gather.Mysql.BLL.admin_user bll = new Gather.Mysql.BLL.admin_user();
|
||||||
|
// var user_model = bll.GetModel(userId);
|
||||||
|
// if (user_model != null)
|
||||||
|
// {
|
||||||
|
// if (user_model.r4 != token)
|
||||||
|
// {
|
||||||
|
// context.Fail("");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// context.Fail("");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// context.Fail("");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// catch (Exception ex)
|
||||||
|
// {
|
||||||
|
// // 记录日志或处理异常
|
||||||
|
// context.Fail(ex);
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// //此处为权限验证失败后触发的事件
|
||||||
|
// OnChallenge = context =>
|
||||||
|
// {
|
||||||
|
// //此处代码为终止.Net Core默认的返回类型和数据结果,这个很重要哦,必须
|
||||||
|
// context.HandleResponse();
|
||||||
|
// var response = Tool.GetJsonWithCode(APICode.TokenFail, "Authentication failed");
|
||||||
|
// //自定义自己想要返回的数据结果,我这里要返回的是Json对象,通过引用Newtonsoft.Json库进行转换
|
||||||
|
// var payload = JsonConvert.SerializeObject(response);
|
||||||
|
// //自定义返回的数据类型
|
||||||
|
// context.Response.ContentType = "application/json";
|
||||||
|
// //自定义返回状态码,默认为401 我这里改成 200
|
||||||
|
// context.Response.StatusCode = StatusCodes.Status401Unauthorized;
|
||||||
|
// //输出Json数据结果
|
||||||
|
// context.Response.WriteAsync(payload);
|
||||||
|
// return Task.FromResult(0);
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ConfigureContainer(ContainerBuilder builder)
|
||||||
|
{
|
||||||
|
//AUTOFAC注入
|
||||||
|
builder.RegisterAssemblyTypes(typeof(BaseRepository<,>).Assembly)
|
||||||
|
.Where(t => t.Name.EndsWith("Repository"))
|
||||||
|
.AsImplementedInterfaces();
|
||||||
|
builder.RegisterAssemblyTypes(typeof(BaseService<,>).Assembly)
|
||||||
|
.Where(t => t.Name.EndsWith("Service"))
|
||||||
|
.AsImplementedInterfaces();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||||
|
{
|
||||||
|
//DefaultFilesOptions defaultFilesOptions = new DefaultFilesOptions();
|
||||||
|
//defaultFilesOptions.DefaultFileNames.Clear();
|
||||||
|
//defaultFilesOptions.DefaultFileNames.Add("index.html");
|
||||||
|
//app.UseDefaultFiles(defaultFilesOptions);
|
||||||
|
|
||||||
|
|
||||||
|
//app.UseStaticFiles(new StaticFileOptions { ServeUnknownFileTypes = true });
|
||||||
|
|
||||||
|
app.UseDefaultFiles();
|
||||||
|
app.UseStaticFiles();
|
||||||
|
|
||||||
|
if (env.IsDevelopment())
|
||||||
|
{
|
||||||
|
app.UseDeveloperExceptionPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 启用身份验证中间件
|
||||||
|
app.UseAuthentication();
|
||||||
|
|
||||||
|
|
||||||
|
app.UseRouting();
|
||||||
|
app.UseCors("CorsTest");//其中app.UseCors()必须放在app.UseRouting()和app.UseEndpoints之间,不然还是解决不了问题。
|
||||||
|
app.UseAuthorization();
|
||||||
|
|
||||||
|
app.UseEndpoints(endpoints =>
|
||||||
|
{
|
||||||
|
endpoints.MapControllers();
|
||||||
|
});
|
||||||
|
|
||||||
|
////启用中间件服务生成Swagger作为JSON终结点
|
||||||
|
//app.UseSwagger();
|
||||||
|
////启用中间件服务对swagger-ui,指定Swagger JSON终结点
|
||||||
|
//app.UseSwaggerUI(c =>
|
||||||
|
//{
|
||||||
|
// c.SwaggerEndpoint("/swagger/v1/swagger.json", "GatherAPI");
|
||||||
|
//});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,100 @@
|
||||||
|
using Microsoft.IdentityModel.Tokens;
|
||||||
|
using System.IdentityModel.Tokens.Jwt;
|
||||||
|
using System.Security.Claims;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace GatherAPI
|
||||||
|
{
|
||||||
|
public class TokenService
|
||||||
|
{
|
||||||
|
private readonly string _secretKey;
|
||||||
|
private readonly string _issuer;
|
||||||
|
|
||||||
|
public TokenService(string secretKey, string issuer)
|
||||||
|
{
|
||||||
|
_secretKey = secretKey;
|
||||||
|
_issuer = issuer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GenerateToken(string userId, string roleId, int hour)
|
||||||
|
{
|
||||||
|
var tokenHandler = new JwtSecurityTokenHandler();
|
||||||
|
var key = Encoding.ASCII.GetBytes(_secretKey);
|
||||||
|
var tokenDescriptor = new SecurityTokenDescriptor
|
||||||
|
{
|
||||||
|
Subject = new ClaimsIdentity(new[] { new Claim(ClaimTypes.NameIdentifier, userId), new Claim(ClaimTypes.Role, roleId) }),
|
||||||
|
Expires = DateTime.UtcNow.AddHours(hour), // Token 过期时间
|
||||||
|
Issuer = _issuer,
|
||||||
|
SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature)
|
||||||
|
};
|
||||||
|
//注意:使用高版本下面这行代码会报错
|
||||||
|
var token = tokenHandler.CreateToken(tokenDescriptor);
|
||||||
|
var tokenString = tokenHandler.WriteToken(token);
|
||||||
|
return tokenString;
|
||||||
|
}
|
||||||
|
|
||||||
|
//public bool GenerateRefreshToken(string token, out string newToken, out string user_id)
|
||||||
|
//{
|
||||||
|
// var tokenHandler = new JwtSecurityTokenHandler();
|
||||||
|
// var key = Encoding.ASCII.GetBytes(_secretKey);
|
||||||
|
// newToken = "";
|
||||||
|
// user_id = "";
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// tokenHandler.ValidateToken(token, new TokenValidationParameters
|
||||||
|
// {
|
||||||
|
// ValidateIssuer = true,
|
||||||
|
// ValidIssuer = _issuer,
|
||||||
|
// ValidateIssuerSigningKey = true,
|
||||||
|
// IssuerSigningKey = new SymmetricSecurityKey(key),
|
||||||
|
// ValidateAudience = false, // 可选:是否验证 Audience
|
||||||
|
// ValidateLifetime = true, // 是否验证 Token 是否过期
|
||||||
|
// ClockSkew = TimeSpan.Zero // 设置时间偏差
|
||||||
|
// }, out var validatedToken);
|
||||||
|
|
||||||
|
// if (validatedToken != null)
|
||||||
|
// {
|
||||||
|
// var model = ((System.IdentityModel.Tokens.Jwt.JwtSecurityToken)validatedToken).Claims;
|
||||||
|
// // 从旧token中提取用户信息
|
||||||
|
// var userId = model.First(claim => claim.Type == "nameid").Value;
|
||||||
|
// var roleId = model.First(claim => claim.Type == "role").Value;
|
||||||
|
// var result = false;
|
||||||
|
// if (roleId == "2")
|
||||||
|
// {
|
||||||
|
// Gather.Mysql.BLL.admin_user bll = new Gather.Mysql.BLL.admin_user();
|
||||||
|
// var user_model = bll.GetModel(userId);
|
||||||
|
// if (user_model != null)
|
||||||
|
// {
|
||||||
|
// if (user_model.r4 == token)
|
||||||
|
// {
|
||||||
|
// result = true;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// result = true;
|
||||||
|
// }
|
||||||
|
// if (result)
|
||||||
|
// {
|
||||||
|
// user_id = userId;
|
||||||
|
// newToken = GenerateToken(userId, roleId, 3);
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// catch (Exception)
|
||||||
|
// {
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,80 @@
|
||||||
|
using Microsoft.IdentityModel.Tokens;
|
||||||
|
using System.IdentityModel.Tokens.Jwt;
|
||||||
|
using System.Security.Claims;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace GatherAPI
|
||||||
|
{
|
||||||
|
public class TokenValidationService
|
||||||
|
{
|
||||||
|
private readonly string _secretKey;
|
||||||
|
private readonly string _issuer;
|
||||||
|
|
||||||
|
public TokenValidationService(string secretKey, string issuer)
|
||||||
|
{
|
||||||
|
_secretKey = secretKey;
|
||||||
|
_issuer = issuer;
|
||||||
|
}
|
||||||
|
|
||||||
|
//public bool ValidateToken(string token)
|
||||||
|
//{
|
||||||
|
// var tokenHandler = new JwtSecurityTokenHandler();
|
||||||
|
// var key = Encoding.ASCII.GetBytes(_secretKey);
|
||||||
|
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// tokenHandler.ValidateToken(token, new TokenValidationParameters
|
||||||
|
// {
|
||||||
|
// ValidateIssuer = true,
|
||||||
|
// ValidIssuer = _issuer,
|
||||||
|
// ValidateIssuerSigningKey = true,
|
||||||
|
// IssuerSigningKey = new SymmetricSecurityKey(key),
|
||||||
|
// ValidateAudience = false, // 可选:是否验证 Audience
|
||||||
|
// ValidateLifetime = true, // 是否验证 Token 是否过期
|
||||||
|
// ClockSkew = TimeSpan.Zero // 设置时间偏差
|
||||||
|
// }, out var validatedToken);
|
||||||
|
|
||||||
|
// if (validatedToken != null)
|
||||||
|
// {
|
||||||
|
// var model = ((System.IdentityModel.Tokens.Jwt.JwtSecurityToken)validatedToken).Claims;
|
||||||
|
// // 从旧token中提取用户信息
|
||||||
|
// var userId = model.First(claim => claim.Type == ClaimTypes.NameIdentifier).Value;
|
||||||
|
// var roleId = model.First(claim => claim.Type == ClaimTypes.Role).Value;
|
||||||
|
// if (roleId == "2")
|
||||||
|
// {
|
||||||
|
// Gather.Mysql.BLL.admin_user bll = new Gather.Mysql.BLL.admin_user();
|
||||||
|
// var user_model = bll.GetModel(userId);
|
||||||
|
// if (user_model != null)
|
||||||
|
// {
|
||||||
|
// if (user_model.r4 == token)
|
||||||
|
// {
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// catch (Exception)
|
||||||
|
// {
|
||||||
|
// // Token 验证失败
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
using log4net;
|
||||||
|
|
||||||
|
namespace GatherAPI.Util
|
||||||
|
{
|
||||||
|
public class LogHelper
|
||||||
|
{
|
||||||
|
private static readonly ILog log = LogManager.GetLogger(Startup.repository.Name, typeof(LogHelper));
|
||||||
|
|
||||||
|
public static void WriteLog(string msg)
|
||||||
|
{
|
||||||
|
log.Info(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,128 @@
|
||||||
|
using MQTTnet.Client;
|
||||||
|
using MQTTnet.Protocol;
|
||||||
|
using MQTTnet;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace GatherAPI.Util
|
||||||
|
{
|
||||||
|
public class MqttClientService
|
||||||
|
{
|
||||||
|
private static string clientid;
|
||||||
|
public static IMqttClient _mqttClient;
|
||||||
|
|
||||||
|
static log4net.ILog log;
|
||||||
|
public void MqttClientStart()
|
||||||
|
{
|
||||||
|
log4net.Config.XmlConfigurator.Configure();
|
||||||
|
log = log4net.LogManager.GetLogger("loginfo");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (_mqttClient == null)
|
||||||
|
{
|
||||||
|
clientid = "API-" + Guid.NewGuid().ToString("N");
|
||||||
|
|
||||||
|
var optionsBuilder = new MqttClientOptionsBuilder()
|
||||||
|
.WithTcpServer("127.0.0.1", 1883) // 要访问的mqtt服务端的 ip 和 端口号 1.117.96.199
|
||||||
|
.WithCredentials("dev", "!11@22#33") // 要访问的mqtt服务端的用户名和密码
|
||||||
|
.WithClientId(clientid) // 设置客户端id
|
||||||
|
.WithCleanSession()
|
||||||
|
.WithTls(new MqttClientOptionsBuilderTlsParameters
|
||||||
|
{
|
||||||
|
UseTls = false // 是否使用 tls加密
|
||||||
|
});
|
||||||
|
|
||||||
|
var clientOptions = optionsBuilder.Build();
|
||||||
|
_mqttClient = new MqttFactory().CreateMqttClient();
|
||||||
|
|
||||||
|
_mqttClient.ConnectedAsync += _mqttClient_ConnectedAsync; // 客户端连接成功事件
|
||||||
|
_mqttClient.DisconnectedAsync += _mqttClient_DisconnectedAsync; // 客户端连接关闭事件
|
||||||
|
|
||||||
|
_mqttClient.ConnectAsync(clientOptions).Wait();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!_mqttClient.IsConnected)
|
||||||
|
{
|
||||||
|
clientid = "API-" + Guid.NewGuid().ToString("N");
|
||||||
|
|
||||||
|
var optionsBuilder = new MqttClientOptionsBuilder()
|
||||||
|
.WithTcpServer("127.0.0.1", 1883) // 要访问的mqtt服务端的 ip 和 端口号
|
||||||
|
.WithCredentials("dev", "!11@22#33") // 要访问的mqtt服务端的用户名和密码
|
||||||
|
.WithClientId(clientid) // 设置客户端id
|
||||||
|
.WithCleanSession()
|
||||||
|
.WithTls(new MqttClientOptionsBuilderTlsParameters
|
||||||
|
{
|
||||||
|
UseTls = false // 是否使用 tls加密
|
||||||
|
});
|
||||||
|
|
||||||
|
var clientOptions = optionsBuilder.Build();
|
||||||
|
_mqttClient = new MqttFactory().CreateMqttClient();
|
||||||
|
|
||||||
|
_mqttClient.ConnectedAsync += _mqttClient_ConnectedAsync; // 客户端连接成功事件
|
||||||
|
_mqttClient.DisconnectedAsync += _mqttClient_DisconnectedAsync; // 客户端连接关闭事件
|
||||||
|
|
||||||
|
_mqttClient.ConnectAsync(clientOptions).Wait();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.Info("接口端连接服务端失败,失败原因:" + ex.Message);
|
||||||
|
//LogHelper.WriteLog("接口端连接服务端失败,失败原因:" + ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 客户端连接关闭事件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="arg"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private Task _mqttClient_DisconnectedAsync(MqttClientDisconnectedEventArgs arg)
|
||||||
|
{
|
||||||
|
log.Info("接口端已断开MQTT服务端的连接");
|
||||||
|
//LogHelper.WriteLog("接口端已断开MQTT服务端的连接");
|
||||||
|
//Console.WriteLine($"客户端已断开与服务端的连接……");
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 客户端连接成功事件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="arg"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private Task _mqttClient_ConnectedAsync(MqttClientConnectedEventArgs arg)
|
||||||
|
{
|
||||||
|
//Console.WriteLine($"客户端已连接服务端……");
|
||||||
|
//LogHelper.WriteLog("接口端已连接MQTT服务端");
|
||||||
|
log.Info("接口端已连接MQTT服务端");
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Publish(string pub, string data)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (_mqttClient.IsConnected)
|
||||||
|
{
|
||||||
|
var message = new MqttApplicationMessage
|
||||||
|
{
|
||||||
|
Topic = pub,
|
||||||
|
Payload = Encoding.UTF8.GetBytes(data),
|
||||||
|
QualityOfServiceLevel = MqttQualityOfServiceLevel.AtMostOnce,
|
||||||
|
Retain = false // 服务端是否保留消息。true为保留,如果有新的订阅者连接,就会立马收到该消息。
|
||||||
|
};
|
||||||
|
_mqttClient.PublishAsync(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.Info("接口端发布消息失败,失败原因:" + ex.Message);
|
||||||
|
//LogHelper.WriteLog("接口端发布消息失败,失败原因:" + ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
namespace GatherAPI.api
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 设备控制请求实体
|
||||||
|
/// </summary>
|
||||||
|
public class ControlDeviceRequest
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// IP
|
||||||
|
/// </summary>
|
||||||
|
public string ip { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 端口
|
||||||
|
/// </summary>
|
||||||
|
public string port { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 站号
|
||||||
|
/// </summary>
|
||||||
|
public string station { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 功能码
|
||||||
|
/// </summary>
|
||||||
|
public string function_code { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 数据类型 bool、byte、short、ushort、int、uint、long、ulong、float、double
|
||||||
|
/// </summary>
|
||||||
|
public string data_type { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 字节顺序 ABCD、BADC、CDAB、DCBA
|
||||||
|
/// </summary>
|
||||||
|
public string byte_order { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否按二进制位读取
|
||||||
|
/// </summary>
|
||||||
|
public string is_bit_read { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 位索引(0-7)
|
||||||
|
/// </summary>
|
||||||
|
public string bit_index { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 点位
|
||||||
|
/// </summary>
|
||||||
|
public string attr_value { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 值
|
||||||
|
/// </summary>
|
||||||
|
public string value { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 首地址是否从0开始,1:是,0:否
|
||||||
|
/// </summary>
|
||||||
|
public string start_address_from_zero { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
namespace GatherAPI.api.back
|
||||||
|
{
|
||||||
|
public class FileSort
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 名称
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 序号
|
||||||
|
/// </summary>
|
||||||
|
public int NumBer { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
namespace GatherAPI.api.back
|
||||||
|
{
|
||||||
|
public class SliceFileInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 文件名称
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 编号
|
||||||
|
/// </summary>
|
||||||
|
public int Number { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 分片大小
|
||||||
|
/// </summary>
|
||||||
|
public int BufferSize { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 分片总数
|
||||||
|
/// </summary>
|
||||||
|
public int Count { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 文件开始位置
|
||||||
|
/// </summary>
|
||||||
|
public int Start { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 文件结束位置
|
||||||
|
/// </summary>
|
||||||
|
public int End { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 文件总大小
|
||||||
|
/// </summary>
|
||||||
|
public int Size { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文件夹名称
|
||||||
|
/// </summary>
|
||||||
|
public string FolderName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
namespace GatherAPI.api.back
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 上传文件接口请求实体
|
||||||
|
/// </summary>
|
||||||
|
public class UploadFileRequest
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 考试id
|
||||||
|
/// </summary>
|
||||||
|
public string ExamId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户id
|
||||||
|
/// </summary>
|
||||||
|
public string UserId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文件描述
|
||||||
|
/// </summary>
|
||||||
|
public string FileDesc { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft": "Warning",
|
||||||
|
"Microsoft.Hosting.Lifetime": "Information"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Jwt": {
|
||||||
|
"Issuer": "",
|
||||||
|
"SecretKey": ""
|
||||||
|
},
|
||||||
|
"ConnectionStrings": {
|
||||||
|
"ConStringEncrypt": "false",
|
||||||
|
//"ConnectionString": "server=172.16.1.162;port=33061;userid=root;password=p@ssw0rd;database=suzhou_iot_db;"
|
||||||
|
"ConnectionString": "server=127.0.0.1;port=3306;userid=root;password=Unity3du#d112233;database=suzhou_iot_db;"
|
||||||
|
},
|
||||||
|
"AllowedHosts": "*"
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
路侧泊位停车收费员的职业道德
|
||||||
|
|
||||||
|
路侧泊位停车收费员作为城市交通管理的重要一环,其职业道德的高低直接关系到市民的出行体验和城市的文明形象。除了具备基本的业务能力和服务意识外,路侧泊位停车收费员还应注重培养相应的职业道德。
|
||||||
|
|
||||||
|
|
||||||
|
1.守法
|
||||||
|
收费员在日常工作生活中知法、懂法、守法,并运用自己掌握的法律知识,维护公司的利益、车主的利益、自己的利益。在对外交往、对车主服务中,不能出现法律漏洞,以免使自己和公司受到不应有的损失。
|
||||||
|
|
||||||
|
2.诚信
|
||||||
|
这是路侧泊位停车收费员职业道德的核心。
|
||||||
|
在工作中,收费员应严格遵守收费标准和规定,不得私自收费或违规操作。同时,对于车主的咨询和投诉,收费员应耐心解答、积极处理,确保信息的准确性和公正性。
|
||||||
|
|
||||||
|
3.尊重
|
||||||
|
这是收费员必备的职业素养。在收费过程中,收费员应尊重每一位市民的权益和隐私,不得随意泄露个人信息或进行歧视行为。此外,收费员还应注重与市民的沟通3.用礼貌、友好的态度为他们提供优质的服务。
|
||||||
|
|
||||||
|
4.责任
|
||||||
|
责任担当也是路收费员职业道德的重要组成部分。在面对突发事件或紧急情况时,收费员应迅速反应、妥善处理,确保市民的安全和权益不受损害。
|
||||||
|
|
||||||
|
5.服从
|
||||||
|
收费员和巡查员必须以服务为天职,以工作指令为行动准绳。服从观念的树立是做好对车主服务工作以及合格员工应具备的首要条件。
|
||||||
|
|
||||||
|
6.纪律
|
||||||
|
收费员和巡查员要有严谨踏实的工作作风,同时更需要树立严格且严肃的组织纪律观念。要树立强烈的遵章守纪观念,以严格的劳动纪律、规章制度、奖罚条例来约束行为。
|
||||||
|
|
||||||
|
7.自律
|
||||||
|
收费员应具备高度的自律观念,在日常服务工作中,做到自觉、自愿、自律地做好服务工作、守纪工作。做到巡查员和管理人员在场和不在场一个样;服务质量、工作质量督导和不督导一个样,检查与不检查一个样。自律行为主要表现在以下方面:廉洁收费教育的自律、行为规范的自律,仪容仪表的自律、言谈举止的自律、劳动纪律的自律、工作及生活小节的自律,工作质量。
|
||||||
|
|
||||||
|
8.服务
|
||||||
|
"干一行,爱一行"是中国人的古训。停车收费无大事,但服务工作件件是大事,要做好每一次对车主服务工作,必须全身心投入,把做好服务、车主满意贯穿于年复一年、日复一日的服务工作之中。
|
||||||
|
|
||||||
|
9.礼貌
|
||||||
|
收费员和巡查员见到车主微笑、问好、谦让、彬彬有礼,车主会感到有回家的温馨感。否则其他工作做得再好,也将是失败的。礼貌观念的树立与强化,并贯穿于日常服务工作的始终,是一个员工是否合格和职业水准高低的体现。
|
||||||
|
|
||||||
|
10.技能
|
||||||
|
停车收费看似简单,但要做好还必须练就一身过硬的本领,熟悉自己的工作职责、工作程序、优质服务标准。良好的职业技能是给车主提供优质服务、高效服务、周到服务的基础。
|
||||||
|
|
||||||
|
11.团队
|
||||||
|
公司的任务和目标要全体员工从上到下、从内到外齐心协力才能够完成。一是营造100%的车主满意率和优质服务;二是创造良好的经济效益和社会效应。所以,每个员工树立高度的团队观念、集体观念、协作配合观念是十分重要和必要的一项工作。
|
||||||
|
|
||||||
|
12.吃苦
|
||||||
|
每一位收费员和巡查员会经历日晒雨淋,酷暑严寒,更要树立吃苦的观念。
|
||||||
|
|
||||||
|
13.学习
|
||||||
|
每位路收费员必须树立强烈的学习观念,惟有"学习、学习、再学习,提高、提高、再提高"才能做好本职工作,提高业务技能,提高服务水准,提高个人综合文化素质的根本。同时,还应积极关注城市交通管理的最新动态和政策,不断提升自己的业务水平和综合素质。
|
||||||
|
|
||||||
|
14.竞争
|
||||||
|
市场经济就是竞争淘汰经济。所有收费员要珍惜自己的工作岗位,岗位来之不易。懂得入职竞争、岗位竞争、服务竞争以及市场竞争。生存竞争是无处不在,无处不有。
|
||||||
|
|
||||||
|
15.节约
|
||||||
|
每位收费员一定要注意节约一滴水、一度电、一方气、一张纸,懂得环保、节能、节约,设备设施维护保养。"节约一分钱就是百分之百的利润"。
|
||||||
|
|
||||||
|
|
||||||
|
所有收费员要明确树立以上15个观念,才能真正成为一名合格优秀的路侧泊位停车收费员,高度树立了以上从业观念,那么公司的综合服务竞争力就一定会十分强大,管理的核心竞争力就一定会得到提升,一定能够给车主提供一流的服务,成为南京市路侧泊位停车收费队伍中的标杆队伍和旗帜队伍。
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,177 @@
|
||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction, and
|
||||||
|
distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by the copyright
|
||||||
|
owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all other entities
|
||||||
|
that control, are controlled by, or are under common control with that entity.
|
||||||
|
For the purposes of this definition, "control" means (i) the power, direct or
|
||||||
|
indirect, to cause the direction or management of such entity, whether by
|
||||||
|
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
||||||
|
permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications, including
|
||||||
|
but not limited to software source code, documentation source, and configuration
|
||||||
|
files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical transformation or
|
||||||
|
translation of a Source form, including but not limited to compiled object code,
|
||||||
|
generated documentation, and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or Object form, made
|
||||||
|
available under the License, as indicated by a copyright notice that is included
|
||||||
|
in or attached to the work (an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object form, that
|
||||||
|
is based on (or derived from) the Work and for which the editorial revisions,
|
||||||
|
annotations, elaborations, or other modifications represent, as a whole, an
|
||||||
|
original work of authorship. For the purposes of this License, Derivative Works
|
||||||
|
shall not include works that remain separable from, or merely link (or bind by
|
||||||
|
name) to the interfaces of, the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including the original version
|
||||||
|
of the Work and any modifications or additions to that Work or Derivative Works
|
||||||
|
thereof, that is intentionally submitted to Licensor for inclusion in the Work
|
||||||
|
by the copyright owner or by an individual or Legal Entity authorized to submit
|
||||||
|
on behalf of the copyright owner. For the purposes of this definition,
|
||||||
|
"submitted" means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems, and
|
||||||
|
issue tracking systems that are managed by, or on behalf of, the Licensor for
|
||||||
|
the purpose of discussing and improving the Work, but excluding communication
|
||||||
|
that is conspicuously marked or otherwise designated in writing by the copyright
|
||||||
|
owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
|
||||||
|
of whom a Contribution has been received by Licensor and subsequently
|
||||||
|
incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License.
|
||||||
|
|
||||||
|
Subject to the terms and conditions of this License, each Contributor hereby
|
||||||
|
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
||||||
|
irrevocable copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the Work and such
|
||||||
|
Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License.
|
||||||
|
|
||||||
|
Subject to the terms and conditions of this License, each Contributor hereby
|
||||||
|
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
||||||
|
irrevocable (except as stated in this section) patent license to make, have
|
||||||
|
made, use, offer to sell, sell, import, and otherwise transfer the Work, where
|
||||||
|
such license applies only to those patent claims licensable by such Contributor
|
||||||
|
that are necessarily infringed by their Contribution(s) alone or by combination
|
||||||
|
of their Contribution(s) with the Work to which such Contribution(s) was
|
||||||
|
submitted. If You institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work or a
|
||||||
|
Contribution incorporated within the Work constitutes direct or contributory
|
||||||
|
patent infringement, then any patent licenses granted to You under this License
|
||||||
|
for that Work shall terminate as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution.
|
||||||
|
|
||||||
|
You may reproduce and distribute copies of the Work or Derivative Works thereof
|
||||||
|
in any medium, with or without modifications, and in Source or Object form,
|
||||||
|
provided that You meet the following conditions:
|
||||||
|
|
||||||
|
You must give any other recipients of the Work or Derivative Works a copy of
|
||||||
|
this License; and
|
||||||
|
You must cause any modified files to carry prominent notices stating that You
|
||||||
|
changed the files; and
|
||||||
|
You must retain, in the Source form of any Derivative Works that You distribute,
|
||||||
|
all copyright, patent, trademark, and attribution notices from the Source form
|
||||||
|
of the Work, excluding those notices that do not pertain to any part of the
|
||||||
|
Derivative Works; and
|
||||||
|
If the Work includes a "NOTICE" text file as part of its distribution, then any
|
||||||
|
Derivative Works that You distribute must include a readable copy of the
|
||||||
|
attribution notices contained within such NOTICE file, excluding those notices
|
||||||
|
that do not pertain to any part of the Derivative Works, in at least one of the
|
||||||
|
following places: within a NOTICE text file distributed as part of the
|
||||||
|
Derivative Works; within the Source form or documentation, if provided along
|
||||||
|
with the Derivative Works; or, within a display generated by the Derivative
|
||||||
|
Works, if and wherever such third-party notices normally appear. The contents of
|
||||||
|
the NOTICE file are for informational purposes only and do not modify the
|
||||||
|
License. You may add Your own attribution notices within Derivative Works that
|
||||||
|
You distribute, alongside or as an addendum to the NOTICE text from the Work,
|
||||||
|
provided that such additional attribution notices cannot be construed as
|
||||||
|
modifying the License.
|
||||||
|
You may add Your own copyright statement to Your modifications and may provide
|
||||||
|
additional or different license terms and conditions for use, reproduction, or
|
||||||
|
distribution of Your modifications, or for any such Derivative Works as a whole,
|
||||||
|
provided Your use, reproduction, and distribution of the Work otherwise complies
|
||||||
|
with the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions.
|
||||||
|
|
||||||
|
Unless You explicitly state otherwise, any Contribution intentionally submitted
|
||||||
|
for inclusion in the Work by You to the Licensor shall be under the terms and
|
||||||
|
conditions of this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify the terms of
|
||||||
|
any separate license agreement you may have executed with Licensor regarding
|
||||||
|
such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks.
|
||||||
|
|
||||||
|
This License does not grant permission to use the trade names, trademarks,
|
||||||
|
service marks, or product names of the Licensor, except as required for
|
||||||
|
reasonable and customary use in describing the origin of the Work and
|
||||||
|
reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, Licensor provides the
|
||||||
|
Work (and each Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
|
||||||
|
including, without limitation, any warranties or conditions of TITLE,
|
||||||
|
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
|
||||||
|
solely responsible for determining the appropriateness of using or
|
||||||
|
redistributing the Work and assume any risks associated with Your exercise of
|
||||||
|
permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability.
|
||||||
|
|
||||||
|
In no event and under no legal theory, whether in tort (including negligence),
|
||||||
|
contract, or otherwise, unless required by applicable law (such as deliberate
|
||||||
|
and grossly negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special, incidental,
|
||||||
|
or consequential damages of any character arising as a result of this License or
|
||||||
|
out of the use or inability to use the Work (including but not limited to
|
||||||
|
damages for loss of goodwill, work stoppage, computer failure or malfunction, or
|
||||||
|
any and all other commercial damages or losses), even if such Contributor has
|
||||||
|
been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability.
|
||||||
|
|
||||||
|
While redistributing the Work or Derivative Works thereof, You may choose to
|
||||||
|
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
|
||||||
|
other liability obligations and/or rights consistent with this License. However,
|
||||||
|
in accepting such obligations, You may act only on Your own behalf and on Your
|
||||||
|
sole responsibility, not on behalf of any other Contributor, and only if You
|
||||||
|
agree to indemnify, defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason of your
|
||||||
|
accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following boilerplate
|
||||||
|
notice, with the fields enclosed by brackets "{}" replaced with your own
|
||||||
|
identifying information. (Don't include the brackets!) The text should be
|
||||||
|
enclosed in the appropriate comment syntax for the file format. We also
|
||||||
|
recommend that a file or class name and description of purpose be included on
|
||||||
|
the same "printed page" as the copyright notice for easier identification within
|
||||||
|
third-party archives.
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
suzhou-iot-service/packages/NPOI.2.5.1/lib/netstandard2.0/NPOI.OpenXml4Net.dll
vendored
Normal file
BIN
suzhou-iot-service/packages/NPOI.2.5.1/lib/netstandard2.0/NPOI.OpenXml4Net.dll
vendored
Normal file
Binary file not shown.
BIN
suzhou-iot-service/packages/NPOI.2.5.1/lib/netstandard2.0/NPOI.OpenXmlFormats.dll
vendored
Normal file
BIN
suzhou-iot-service/packages/NPOI.2.5.1/lib/netstandard2.0/NPOI.OpenXmlFormats.dll
vendored
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 8.0 KiB |
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
Binary file not shown.
After Width: | Height: | Size: 4.1 KiB |
Binary file not shown.
|
@ -0,0 +1,20 @@
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2007 James Newton-King
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
BIN
suzhou-iot-service/packages/Newtonsoft.Json.12.0.3/Newtonsoft.Json.12.0.3.nupkg
vendored
Normal file
BIN
suzhou-iot-service/packages/Newtonsoft.Json.12.0.3/Newtonsoft.Json.12.0.3.nupkg
vendored
Normal file
Binary file not shown.
BIN
suzhou-iot-service/packages/Newtonsoft.Json.12.0.3/lib/net20/Newtonsoft.Json.dll
vendored
Normal file
BIN
suzhou-iot-service/packages/Newtonsoft.Json.12.0.3/lib/net20/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
10298
suzhou-iot-service/packages/Newtonsoft.Json.12.0.3/lib/net20/Newtonsoft.Json.xml
vendored
Normal file
10298
suzhou-iot-service/packages/Newtonsoft.Json.12.0.3/lib/net20/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
suzhou-iot-service/packages/Newtonsoft.Json.12.0.3/lib/net35/Newtonsoft.Json.dll
vendored
Normal file
BIN
suzhou-iot-service/packages/Newtonsoft.Json.12.0.3/lib/net35/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
9446
suzhou-iot-service/packages/Newtonsoft.Json.12.0.3/lib/net35/Newtonsoft.Json.xml
vendored
Normal file
9446
suzhou-iot-service/packages/Newtonsoft.Json.12.0.3/lib/net35/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
suzhou-iot-service/packages/Newtonsoft.Json.12.0.3/lib/net40/Newtonsoft.Json.dll
vendored
Normal file
BIN
suzhou-iot-service/packages/Newtonsoft.Json.12.0.3/lib/net40/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
9646
suzhou-iot-service/packages/Newtonsoft.Json.12.0.3/lib/net40/Newtonsoft.Json.xml
vendored
Normal file
9646
suzhou-iot-service/packages/Newtonsoft.Json.12.0.3/lib/net40/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
suzhou-iot-service/packages/Newtonsoft.Json.12.0.3/lib/net45/Newtonsoft.Json.dll
vendored
Normal file
BIN
suzhou-iot-service/packages/Newtonsoft.Json.12.0.3/lib/net45/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
11262
suzhou-iot-service/packages/Newtonsoft.Json.12.0.3/lib/net45/Newtonsoft.Json.xml
vendored
Normal file
11262
suzhou-iot-service/packages/Newtonsoft.Json.12.0.3/lib/net45/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
suzhou-iot-service/packages/Newtonsoft.Json.12.0.3/lib/netstandard1.0/Newtonsoft.Json.dll
vendored
Normal file
BIN
suzhou-iot-service/packages/Newtonsoft.Json.12.0.3/lib/netstandard1.0/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue