From f248541655abd38acf109af0320ec2298cfb0c02 Mon Sep 17 00:00:00 2001 From: "wanling040@gmail.com" Date: Wed, 13 Jul 2022 18:40:36 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=A0=81=E9=9D=A2:=20?= =?UTF-8?q?=E8=A3=9D=E7=BD=AE=E7=AE=A1=E7=90=86=20(=E7=B3=BB=E7=B5=B1?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=BA=95=E4=B8=8B)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/SensorTypeController.cs | 132 ++++++++++ SolarPower/Models/SensorType.cs | 31 +++ .../Implement/SensorTypeRepository.cs | 142 ++++++++++ .../Interface/ISensorTypeRepository.cs | 40 +++ SolarPower/Startup.cs | 1 + SolarPower/Views/SensorType/Index.cshtml | 249 ++++++++++++++++++ SolarPower/Views/Shared/_Layout.cshtml | 40 +-- 7 files changed, 619 insertions(+), 16 deletions(-) create mode 100644 SolarPower/Controllers/SensorTypeController.cs create mode 100644 SolarPower/Models/SensorType.cs create mode 100644 SolarPower/Repository/Implement/SensorTypeRepository.cs create mode 100644 SolarPower/Repository/Interface/ISensorTypeRepository.cs create mode 100644 SolarPower/Views/SensorType/Index.cshtml diff --git a/SolarPower/Controllers/SensorTypeController.cs b/SolarPower/Controllers/SensorTypeController.cs new file mode 100644 index 0000000..fb7d95e --- /dev/null +++ b/SolarPower/Controllers/SensorTypeController.cs @@ -0,0 +1,132 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using SolarPower.Repository.Interface; +using SolarPower.Services.Interface; +using System.IO; +using SolarPower.Models; +using SolarPower.Models.SensorType; + +namespace SolarPower.Controllers +{ + public class SensorTypeController : MyBaseController + { + private readonly ISensorTypeRepository sensorRepository; + private string boeFilePath = "/upload/power_station/boe_file/"; + private string stationImageFilePath = "/upload/power_station/"; + private string powerSationSaveAsPath = ""; + + public SensorTypeController(ISensorTypeRepository sensorRepository) : base() + { + this.sensorRepository = sensorRepository; + + powerSationSaveAsPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "upload", "power_station"); + } + + public IActionResult Index() + { + sensorRepository.GetAllSensorAsync(); + return View(); + } + + + /// + /// 新增 / 修改 設備資料 + /// + /// + /// + [HttpPost] + public async Task> SaveSensorType(SensorTypeInfo post) + { + ApiResult apiResult = new ApiResult(); + + SensorType sensor = null; + + try + { + sensor = await sensorRepository.GetOneAsync(post.Id); + + if (sensor == null) + { + + if (post.Id != 0) + { + apiResult.Code = "9998";//待定 + apiResult.Msg = errorCode.GetString(apiResult.Code); + return apiResult; + } + + #region 新增設備 + sensor = new SensorType() + { + UId = post.UId, + Enabled = post.Enabled, + SensorName = post.SensorName, + SensorNameEn = post.SensorNameEn, + CreatedBy = myUser.Id, + }; + + List properties = new List() + { + "UId", + "Enabled", + "SensorName", + "SensorNameEn", + "CreatedBy", + }; + + var id = await sensorRepository.AddOneAsync(sensor, properties); + + + //var website_url = await powerStationRepository.GetOneVariableByName("WebSiteUrl"); + + + //var sendSubject = "新增設備成功"; + apiResult.Code = "0000"; + apiResult.Msg = "儲存成功"; + #endregion + } + else + { + #region 修改設備 + SensorType update = new SensorType() + { + Id = sensor.Id, + Enabled = post.Enabled, + SensorName = post.SensorName, + SensorNameEn = post.SensorNameEn, + UpdatedBy = myUser.Id + }; + + + List properties = new List() + { + "Id", + "Enabled", + "SensorName", + "SensorNameEn", + "UpdatedBy", + }; + + await sensorRepository.UpdateSensorInfo(update, properties); + apiResult.Code = "0000"; + apiResult.Msg = "儲存成功"; + #endregion + } + } + catch (Exception exception) + { + apiResult.Code = "9999"; + apiResult.Msg = errorCode.GetString(apiResult.Code); + string json = System.Text.Json.JsonSerializer.Serialize(post); + Logger.LogError("【" + controllerName + "/" + actionName + "】" + json); + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + } + return apiResult; + } + + } +} diff --git a/SolarPower/Models/SensorType.cs b/SolarPower/Models/SensorType.cs new file mode 100644 index 0000000..3508bc3 --- /dev/null +++ b/SolarPower/Models/SensorType.cs @@ -0,0 +1,31 @@ +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace SolarPower.Models.SensorType +{ + //Base Class。如由其餘需求,使用繼承 + public class SensorType : SensorTypeInfo + { + //public int Id { get; set; } //編號 + public byte Deleted { get; set; } //是否刪除 + //public int UId { get; set; } //設備編號 + //public int Enabled { get; set; } //啟用 + //public string SensorName { get; set; } //sensor名稱 + //public string SensorNameEn { get; set; } //sensor英文名稱 + } + + /// + /// 設備 + /// + public class SensorTypeInfo : UserInfo + { + public int UId { get; set; }//設備編號 + public string SensorName { get; set; }//傳感器名稱 + public string SensorNameEn { get; set; }//傳感器英文名稱 + public int Enabled { get; set; }//啟用 + } + +} diff --git a/SolarPower/Repository/Implement/SensorTypeRepository.cs b/SolarPower/Repository/Implement/SensorTypeRepository.cs new file mode 100644 index 0000000..0a616c6 --- /dev/null +++ b/SolarPower/Repository/Implement/SensorTypeRepository.cs @@ -0,0 +1,142 @@ +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using SolarPower.Models; +using SolarPower.Models.SensorType; +using SolarPower.Repository.Interface; +using Dapper; +using SolarPower.Helper; +using System.Data; + +namespace SolarPower.Repository.Implement +{ + public class SensorTypeRepository : RepositoryBase, ISensorTypeRepository + { + public SensorTypeRepository(IDatabaseHelper databaseHelper) : base(databaseHelper) + { + tableName = "sensor_type"; + } + public async Task> GetAllSensorAsync() + { + List result; + using (IDbConnection conn = this._databaseHelper.GetConnection()) + { + try + { + var sql = $"SELECT Id, Deleted, Enabled, UID, SensorName, SensorNameEn FROM solar_master.sensor_type WHERE deleted = 0"; + + result = (await conn.QueryAsync(sql)).ToList(); + } + catch (Exception exception) + { + throw exception; + } + return result; + } + } + + /// + /// 新增裝置資料 + /// + /// + /// + /// + public async Task AddSensor(SensorType sensorInfo, List properties) + { + using (IDbConnection conn = _databaseHelper.GetConnection()) + { + conn.Open(); + //var trans = conn.BeginTransaction(); + using (var trans = conn.BeginTransaction()) + { + try + { + //string sql = GenerateInsertQueryWithCustomDBNameAndTable(properties, db_name, "device"); + //await conn.ExecuteAsync(sql, DeviceInfo); + //trans.Commit(); + + //var sql2 = GenerateUpdateQuery(properties); + var sql = GenerateInsertQueryWithCustomTable(properties, "sensor_type"); + await conn.ExecuteAsync(sql, sensorInfo, trans); + trans.Commit(); + + //string sql = $"INSERT INTO company_auth_page (CompanyId, AuthCode, CreatedBy) VALUES (@CompanyId, @AuthCode, @CreatedBy)"; + //await conn.ExecuteAsync(sql, trans); + //trans.Commit(); + } + catch (Exception exception) + { + trans.Rollback(); + throw exception; + } + finally + { + conn.Close(); + } + } + } + + } + + /// + /// 透過sensorNameEn,取得單一筆資料 + /// + /// + /// + public async Task GetOneByEnglishNameAsync(string sensorNameEn) + { + SensorType result; + using (IDbConnection conn = _databaseHelper.GetConnection()) + { + try + { + var sql = $"SELECT * FROM solar_master.sensor_type WHERE deleted = 0 AND sensorNameEn = @SensorNameEn"; + + result = await conn.QueryFirstOrDefaultAsync(sql, new { SensorName_En = sensorNameEn }); + } + catch (Exception exception) + { + throw exception; + } + return result; + } + } + + /// + /// 修改設備資料 + /// + /// + /// + public async Task UpdateSensorInfo(SensorType entity, List properties) + { + GetProperties = typeof(SensorType).GetProperties(); + using (IDbConnection conn = _databaseHelper.GetConnection()) + { + conn.Open(); + using (var trans = conn.BeginTransaction()) + { + try + { + var sql = GenerateUpdateQuery(properties); + + await conn.ExecuteAsync(sql, entity, trans); + + trans.Commit(); + } + catch (Exception exception) + { + trans.Rollback(); + throw exception; + } + finally + { + conn.Close(); + } + } + } + } + + } +} diff --git a/SolarPower/Repository/Interface/ISensorTypeRepository.cs b/SolarPower/Repository/Interface/ISensorTypeRepository.cs new file mode 100644 index 0000000..2f6ec21 --- /dev/null +++ b/SolarPower/Repository/Interface/ISensorTypeRepository.cs @@ -0,0 +1,40 @@ +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using SolarPower.Models; +using SolarPower.Models.SensorType; +using SolarPower.Repository.Interface; + +namespace SolarPower.Repository.Interface +{ + public interface ISensorTypeRepository : IRepositoryBase + { + Task> GetAllSensorAsync(); + + /// + /// 新增 設備 + /// + /// + /// + Task AddSensor(SensorType SensorInfo, List properties); + + /// + /// 透過sensorNameEn,取得單一筆資料 + /// + /// + /// + Task GetOneByEnglishNameAsync(string sensorNameEn); + + /// + /// 修改設備資料 + /// + /// + /// + /// + Task UpdateSensorInfo(SensorType entity, List properties); + + + } +} diff --git a/SolarPower/Startup.cs b/SolarPower/Startup.cs index 1dd5028..7706b29 100644 --- a/SolarPower/Startup.cs +++ b/SolarPower/Startup.cs @@ -82,6 +82,7 @@ namespace SolarPower services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); #endregion double loginExpireMinute = this.Configuration.GetValue("LoginExpireMinute"); diff --git a/SolarPower/Views/SensorType/Index.cshtml b/SolarPower/Views/SensorType/Index.cshtml new file mode 100644 index 0000000..8def1b3 --- /dev/null +++ b/SolarPower/Views/SensorType/Index.cshtml @@ -0,0 +1,249 @@ +@{ + ViewData["MainNum"] = "7"; + ViewData["SubNum"] = "3"; + ViewData["Title"] = "裝置管理"; +} +@using SolarPower.Models.Role +@model RoleLayerEnum + + + +
+

+ @ViewData["Title"] +

+
+ +
+
+
+
+
+ @*只有平台人員可以新增公司*@ + @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformUser) + { + + } +
+
+ + + + + + + + + + + + + +
設備編號啟用Sensor名稱Sensor英文名稱建立時間功能
+
+
+
+
+
+
+
+ + + +@section Scripts { + +} \ No newline at end of file diff --git a/SolarPower/Views/Shared/_Layout.cshtml b/SolarPower/Views/Shared/_Layout.cshtml index 3f3945f..b769f2d 100644 --- a/SolarPower/Views/Shared/_Layout.cshtml +++ b/SolarPower/Views/Shared/_Layout.cshtml @@ -394,7 +394,7 @@ } - @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("Company") || ViewBag.auths.Contains("User") || ViewBag.auths.Contains("Role") || ViewBag.auths.Contains("User"))@*TODO修改定時任務權限*@ + @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("Company") || ViewBag.auths.Contains("User") || ViewBag.auths.Contains("Role") || ViewBag.auths.Contains("User") || ViewBag.auths.Contains("SensorType"))@*TODO修改定時任務權限*@ {
  • @@ -418,22 +418,30 @@
  • } + @*@if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("SensorType")) + { +
  • + + 裝置管理 + +
  • + }*@ @*@if (ViewBag.auths.Contains("User")) - { -
  • - - 功能清單 - -
  • - } - @if (ViewBag.auths.Contains("User")) - { -
  • - - 定時任務設定 - -
  • - }*@ + { +
  • + + 功能清單 + +
  • + } + @if (ViewBag.auths.Contains("User")) + { +
  • + + 定時任務設定 + +
  • + }*@ } From aa7dbfba8dcd9c2fbe2c6674e3f0614bc0a510e9 Mon Sep 17 00:00:00 2001 From: "wanling040@gmail.com" Date: Thu, 14 Jul 2022 12:34:25 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=BB=B6=E9=95=B7=E8=AE=80=E5=8F=96=20DB?= =?UTF-8?q?=20=E7=9A=84=E6=99=82=E9=96=93=20(=E6=AF=8F=E5=B0=8F=E6=99=82?= =?UTF-8?q?=E7=9A=84=E6=9B=B4=E6=96=B0)=EF=BC=8C=E6=94=B9=E6=88=9010?= =?UTF-8?q?=E5=88=86=E9=90=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Implement/PowerStationRepository.cs | 42 +++++++++---------- .../Repository/Implement/RepositoryBase.cs | 2 +- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/SolarPower/Repository/Implement/PowerStationRepository.cs b/SolarPower/Repository/Implement/PowerStationRepository.cs index d762167..d42fbb6 100644 --- a/SolarPower/Repository/Implement/PowerStationRepository.cs +++ b/SolarPower/Repository/Implement/PowerStationRepository.cs @@ -679,7 +679,7 @@ namespace SolarPower.Repository.Implement LEFT JOIN user u ON lb.CreatedBy = u.Id WHERE lb.Deleted = 0 AND PowerStationId = @PowerStationId"; - result = (await conn.QueryAsync(sql, new { PowerStationId = id })).ToList(); + result = (await conn.QueryAsync(sql, new { PowerStationId = id }, commandTimeout: 600)).ToList(); } catch (Exception exception) { @@ -1900,7 +1900,7 @@ namespace SolarPower.Repository.Implement try { string sql = $"SELECT id FROM {db_name}.controller WHERE PowerStationId = {stationId}"; - count = (await conn.QueryAsync(sql)).ToList(); + count = (await conn.QueryAsync(sql, commandTimeout: 600)).ToList(); } catch (Exception exception) { @@ -1965,7 +1965,7 @@ namespace SolarPower.Repository.Implement LEFT JOIN user ON inv.CreatedBy = user.id LEFT JOIN {db_name}.device de ON inv.Pyrheliometer = de.id WHERE inv.Deleted = 0 AND inv.ControllerId IN @Controllerid"; - inverterTable = (await conn.QueryAsync(sql, new { Controllerid = controllerid })).ToList(); + inverterTable = (await conn.QueryAsync(sql, new { Controllerid = controllerid }, commandTimeout: 600)).ToList(); } catch (Exception exception) @@ -2158,7 +2158,7 @@ namespace SolarPower.Repository.Implement FROM {table_name} WHERE DATE_FORMAT(FROM_UNIXTIME(timestamp / 1000), '%Y-%m-%d %H') = @DateTime "; - result = await conn.QueryFirstOrDefaultAsync(sql, new { DateTime = dateTime }); + result = await conn.QueryFirstOrDefaultAsync(sql, new { DateTime = dateTime }, commandTimeout: 600);//加上時間 } catch (Exception exception) { @@ -2207,7 +2207,7 @@ namespace SolarPower.Repository.Implement { string sql = GenerateInsertQueryWithCustomTable(properties, "power_station_history_hour"); - count = await conn.ExecuteAsync(sql, entity, trans); + count = await conn.ExecuteAsync(sql, entity, trans, commandTimeout: 600); trans.Commit(); } @@ -2238,7 +2238,7 @@ namespace SolarPower.Repository.Implement { string sql = GenerateUpdateQuery(properties); - count = await conn.ExecuteAsync(sql, entity, trans); + count = await conn.ExecuteAsync(sql, entity, trans, commandTimeout: 600); trans.Commit(); } @@ -2522,7 +2522,7 @@ namespace SolarPower.Repository.Implement ORDER BY temp.ColName "; - result = (await conn.QueryAsync(sql, new { PowerStationId = powerStationId })).ToList(); + result = (await conn.QueryAsync(sql, new { PowerStationId = powerStationId }, commandTimeout: 600)).ToList(); } catch (Exception exception) { @@ -2580,7 +2580,7 @@ namespace SolarPower.Repository.Implement ) temp ORDER BY temp.ColName"; - result = (await conn.QueryAsync(sql, new { PowerStationId = powerStationId })).ToList(); + result = (await conn.QueryAsync(sql, new { PowerStationId = powerStationId }, commandTimeout: 600)).ToList(); } catch (Exception exception) { @@ -2651,7 +2651,7 @@ namespace SolarPower.Repository.Implement var sql = @$"SELECT a.TIMESTAMP, {calc}(a.SENSOR) AS {typename} FROM(" + string.Join(" UNION ", sql_per_device) + @") a GROUP BY `TIMESTAMP`"; - result = await conn.QueryFirstOrDefaultAsync(sql, new { DateTime = dateTime }); + result = await conn.QueryFirstOrDefaultAsync(sql, new { DateTime = dateTime }, commandTimeout: 600); } catch (Exception exception) { @@ -2677,7 +2677,7 @@ namespace SolarPower.Repository.Implement { string sql = GenerateInsertQueryWithCustomTable(properties, "sensor_history_hour"); - count = await conn.ExecuteAsync(sql, entity, trans); + count = await conn.ExecuteAsync(sql, entity, trans, commandTimeout: 600); trans.Commit(); } @@ -3130,7 +3130,7 @@ namespace SolarPower.Repository.Implement GROUP BY left(s.CrdTime, 13), s.INVERTERID "; - result = (await conn.QueryAsync(sql, new { DateTime = dateTime, InverterIds = inverterIds }, commandTimeout: 300)).ToList(); + result = (await conn.QueryAsync(sql, new { DateTime = dateTime, InverterIds = inverterIds }, commandTimeout: 600)).ToList(); } catch (Exception exception) { @@ -3158,7 +3158,7 @@ namespace SolarPower.Repository.Implement AND d.PowerStationId = @PowerStationId ORDER BY d.ColName"; - result = await conn.QueryFirstAsync(sql, new { PowerStationId = powerStationId }); + result = await conn.QueryFirstAsync(sql, new { PowerStationId = powerStationId }, commandTimeout: 600); } catch (Exception exception) { @@ -3186,7 +3186,7 @@ namespace SolarPower.Repository.Implement WHERE {col_name} != 0 AND FROM_UNIXTIME(TIMESTAMP/1000, '%Y-%m-%d %H') = @DateTime"; - result = await conn.QueryFirstOrDefaultAsync(sql, new { DateTime = dateTime }); + result = await conn.QueryFirstOrDefaultAsync(sql, new { DateTime = dateTime }, commandTimeout: 600); } catch (Exception exception) { @@ -3438,7 +3438,7 @@ namespace SolarPower.Repository.Implement { string sql = GenerateInsertQueryWithCustomTable(properties, "inverter_history_hour"); - count = await conn.ExecuteAsync(sql, entity, trans); + count = await conn.ExecuteAsync(sql, entity, trans, commandTimeout: 600); trans.Commit(); } @@ -3573,7 +3573,7 @@ namespace SolarPower.Repository.Implement { string sql = GenerateInsertQueryWithCustomTable(properties, "weather_observation"); - count = await conn.ExecuteAsync(sql, entity, trans); + count = await conn.ExecuteAsync(sql, entity, trans, commandTimeout: 600); trans.Commit(); } @@ -3632,7 +3632,7 @@ namespace SolarPower.Repository.Implement LEFT JOIN weather_description wd ON wd.WeatherName = wf.Wx WHERE c.Id = {CityId} AND '{now}' BETWEEN wf.StartTime AND wf.EndTime ORDER BY wf.CreatedAt desc"; - result = await conn.QueryFirstOrDefaultAsync(sql); + result = await conn.QueryFirstOrDefaultAsync(sql, commandTimeout: 600); } catch (Exception exception) { @@ -3739,7 +3739,7 @@ namespace SolarPower.Repository.Implement { var sql = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA = @DBName AND TABLE_NAME = @TableName;"; - result = await conn.QueryFirstOrDefaultAsync(sql, new { DBName = db_name, TableName = table_name }); + result = await conn.QueryFirstOrDefaultAsync(sql, new { DBName = db_name, TableName = table_name }, commandTimeout: 600); } catch (Exception exception) { @@ -3783,7 +3783,7 @@ namespace SolarPower.Repository.Implement GROUP BY FROM_UNIXTIME(timestamp / 1000, '%Y-%m-%d %H')"; - result = await conn.QueryFirstOrDefaultAsync(sql, new { DateTime = dateTime }); + result = await conn.QueryFirstOrDefaultAsync(sql, new { DateTime = dateTime }, commandTimeout: 600); } catch (Exception exception) { @@ -3809,7 +3809,7 @@ namespace SolarPower.Repository.Implement { string sql = GenerateInsertQueryWithCustomTable(properties, "sensoravg_history_hour"); - count = await conn.ExecuteAsync(sql, entity, trans); + count = await conn.ExecuteAsync(sql, entity, trans, commandTimeout: 600); trans.Commit(); } @@ -4099,7 +4099,7 @@ namespace SolarPower.Repository.Implement WHERE LEFT(FROM_UNIXTIME(m.timestamp / 1000, '%Y-%m-%d %H'), 10) = @DateTime AND RIGHT(FROM_UNIXTIME(m.timestamp / 1000, '%Y-%m-%d %H'), 2) = '55' ) m2 ON m1.timestamp = m2.timestamp AND m1.METERID = m2.METERID"; - result = await conn.QueryFirstOrDefaultAsync(sql, new { DateTime = dateTime }); + result = await conn.QueryFirstOrDefaultAsync(sql, new { DateTime = dateTime }, commandTimeout: 600); } catch (Exception exception) { @@ -4125,7 +4125,7 @@ namespace SolarPower.Repository.Implement { string sql = GenerateInsertQueryWithCustomTable(properties, "meter_history_hour"); - count = await conn.ExecuteAsync(sql, entity, trans); + count = await conn.ExecuteAsync(sql, entity, trans, commandTimeout: 600); trans.Commit(); } diff --git a/SolarPower/Repository/Implement/RepositoryBase.cs b/SolarPower/Repository/Implement/RepositoryBase.cs index 07cdd16..b0a25f8 100644 --- a/SolarPower/Repository/Implement/RepositoryBase.cs +++ b/SolarPower/Repository/Implement/RepositoryBase.cs @@ -419,7 +419,7 @@ namespace SolarPower.Repository.Implement { var sql = $"SELECT Value FROM variable WHERE Name = @Name"; - result = await conn.QueryFirstOrDefaultAsync(sql, new { Name = name }); + result = await conn.QueryFirstOrDefaultAsync(sql, new { Name = name }, commandTimeout: 600); } catch (Exception exception) {