Merge branch 'master' of https://gitea.mjm-staging.developers-homelab.net/BIMS/BIMS
This commit is contained in:
commit
18426a3624
@ -755,6 +755,7 @@ namespace Backend.Controllers
|
||||
public async Task<ApiResult<string>> ImportDevForCor([FromBody] List<ImportDevForCoo> post)
|
||||
{
|
||||
ApiResult<string> apiResult = new ApiResult<string>();
|
||||
var device_guid_record = "";
|
||||
try
|
||||
{
|
||||
if (post != null)
|
||||
@ -762,38 +763,43 @@ namespace Backend.Controllers
|
||||
if (post.Count > 0)
|
||||
{
|
||||
//清空device_node資料表
|
||||
//await backendRepository.TruncateTable("device_node");
|
||||
await backendRepository.TruncateTable("device_node");
|
||||
|
||||
//int node_priority = 1;
|
||||
int node_priority = 1;
|
||||
foreach(var idfc in post)
|
||||
{
|
||||
//if(idfc.device_number.IndexOf("_LT_L1") > -1)
|
||||
//{
|
||||
// //取得device_guid
|
||||
// var sWhere = $@"where deleted = 0 and device_number = " + idfc.device_number;
|
||||
// var device_guid = await backendRepository.GetOneAsync<string>("device_node", sWhere, "device_guid");
|
||||
if (idfc.device_number.IndexOf("_LT_L1") > -1)
|
||||
{
|
||||
//取得device_guid
|
||||
var sWhere = $@" deleted = 0 and device_number = '" + idfc.device_number + "'";
|
||||
var device_guid = await backendRepository.GetOneColAsync("device", sWhere, "device_guid");
|
||||
if(device_guid.ToString() != device_guid_record)
|
||||
{
|
||||
device_guid_record = device_guid.ToString();
|
||||
node_priority = 1;
|
||||
}
|
||||
|
||||
// //燈具
|
||||
// Dictionary<string, object> device = new Dictionary<string, object>();
|
||||
// device.Add("@device_node_guid", Guid.NewGuid());
|
||||
// device.Add("@deleted", 0);
|
||||
// device.Add("@device_guid", device_guid);
|
||||
// device.Add("@device_node_coordinate_3d", idfc.device_coordinate_3d);
|
||||
// device.Add("@forge_dbid", idfc.forge_dbid);
|
||||
// device.Add("@priority", node_priority);
|
||||
// device.Add("@created_by", myUserInfo.Userinfo_guid);
|
||||
// device.Add("@created_at", DateTime.Now);
|
||||
//燈具
|
||||
Dictionary<string, object> device = new Dictionary<string, object>();
|
||||
device.Add("@device_node_guid", Guid.NewGuid());
|
||||
device.Add("@deleted", 0);
|
||||
device.Add("@device_guid", device_guid);
|
||||
device.Add("@device_node_coordinate_3d", idfc.device_coordinate_3d);
|
||||
device.Add("@forge_dbid", idfc.forge_dbid);
|
||||
device.Add("@priority", node_priority);
|
||||
device.Add("@created_by", myUserInfo.Userinfo_guid);
|
||||
device.Add("@created_at", DateTime.Now);
|
||||
|
||||
// node_priority++;
|
||||
// await backendRepository.AddOneByCustomTableReturnId(device, "device_node", false);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
node_priority++;
|
||||
await backendRepository.AddOneByCustomTableReturnId(device, "device_node", false);
|
||||
}
|
||||
else
|
||||
{
|
||||
Dictionary<string, object> device = new Dictionary<string, object>();
|
||||
device.Add("@device_coordinate_3d", idfc.device_coordinate_3d);
|
||||
device.Add("@forge_dbid", idfc.forge_dbid);
|
||||
await backendRepository.UpdateOneByCustomTable(device, "device", $@" device_number = '{idfc.device_number}'");
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -184,7 +184,6 @@
|
||||
|
||||
<script>
|
||||
var curLightIsOpen = true;
|
||||
var objSendData = { Data: null };
|
||||
|
||||
$(document).ready(function () {
|
||||
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwJUU1JThGJUIwJUU1JThDJTk3JUU0JUI4JUFEJUU4JThGJUIxJUU1JUE0JUE3JUU2JUE4JTkzJUUzJTgwJTkxQVJDLm53ZA');
|
||||
@ -238,8 +237,10 @@
|
||||
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwJUU1JThGJUIwJUU1JThDJTk3JUU0JUI4JUFEJUU4JThGJUIxJUU1JUE0JUE3JUU2JUE4JTkzJUUzJTgwJTkxQVJDK01FUCVFNiU4QiU4NiVFNyVCMyVCQiVFNyVCNSVCMV8lRTUlOEQlOEElRTklODAlOEYlRTYlOTglOEUlRTUlQkIlQkElRTclQUYlODlfMTJfMzAubndk');
|
||||
|
||||
//12.31 整棟樓
|
||||
launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dGEzaHFzZmZ6cWJub3V4a3BsZGt1a3NldzRzajIxdzUtYmltc19tb2RlbHMvJUUzJTgwJTkwJUU1JThGJUIwJUU1JThDJTk3JUU0JUI4JUFEJUU4JThGJUIxJUU1JUE0JUE3JUU2JUE4JTkzJUUzJTgwJTkxQVJDJUU5JTlCJTk5JUU2JUE4JUExJUU1JUJDJThGK01FUCVFNiU4QiU4NiVFNyVCMyVCQiVFNyVCNSVCMV8yMDIyXzEyXzMxLm53ZA');
|
||||
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dGEzaHFzZmZ6cWJub3V4a3BsZGt1a3NldzRzajIxdzUtYmltc19tb2RlbHMvJUUzJTgwJTkwJUU1JThGJUIwJUU1JThDJTk3JUU0JUI4JUFEJUU4JThGJUIxJUU1JUE0JUE3JUU2JUE4JTkzJUUzJTgwJTkxQVJDJUU5JTlCJTk5JUU2JUE4JUExJUU1JUJDJThGK01FUCVFNiU4QiU4NiVFNyVCMyVCQiVFNyVCNSVCMV8yMDIyXzEyXzMxLm53ZA');
|
||||
|
||||
//雙模式
|
||||
launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dGEzaHFzZmZ6cWJub3V4a3BsZGt1a3NldzRzajIxdzUtYmltc19tb2RlbHMvJUUzJTgwJTkwJUU1JThGJUIwJUU1JThDJTk3JUU0JUI4JUFEJUU4JThGJUIxJUU1JUE0JUE3JUU2JUE4JTkzJUUzJTgwJTkxQVJDJUU5JTlCJTk5JUU2JUE4JUExJUU1JUJDJThGK01FUCVFNiU4QiU4NiVFNyVCMyVCQiVFNyVCNSVCMV8yMDIyXzEyXzMxLm53ZA==');
|
||||
|
||||
|
||||
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwQVJDJUUzJTgwJTkxXzIwMjJfMTJfMTMubndk');//new ARC
|
||||
@ -384,75 +385,6 @@
|
||||
|
||||
function ImportDevForCor() {//callback = null
|
||||
var url = "/DeviceImport/ImportDevForCor";
|
||||
//let sendData = {
|
||||
// "device_number": pageAct.AreaTag,
|
||||
// "device_coordinate_3d": "",
|
||||
// "device_dbid": "",
|
||||
//};
|
||||
objSendData.Data = tagIdDevList;
|
||||
//ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
|
||||
// if (!res || res.code != "0000" || !res.data) {
|
||||
// console.log(rel.msg);
|
||||
// } else {
|
||||
// console.log(rel.msg);
|
||||
// }
|
||||
//}, null, "POST").send();
|
||||
|
||||
//$.post(url, objSendData.Data, function (rel) {
|
||||
// if (rel.code != "0000") {
|
||||
// if (rel.code == "9999") {
|
||||
// //toast_error(rel.msg);
|
||||
// console.log(rel.msg);
|
||||
// }
|
||||
// else {
|
||||
// //toast_warning(rel.msg);
|
||||
// console.log(rel.msg);
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
// else {
|
||||
// //toast_ok(rel.msg);
|
||||
// console.log(rel.msg);
|
||||
// //ReloadRawDataCheckTable();
|
||||
// }
|
||||
|
||||
//}, 'json');
|
||||
|
||||
//headers={'content-type': 'application/json'}
|
||||
|
||||
//$.ajax({
|
||||
// type: "POST",
|
||||
// url: url,
|
||||
// data: objSendData.Data,
|
||||
// cache: false,
|
||||
// contentType: 'application/json',
|
||||
// processData: false,
|
||||
// success: function (rel) {
|
||||
// //$("#save-building-btn").html('確定').attr("disabled", false);
|
||||
// if (rel.code != "0000") {
|
||||
// if (rel.code == "9999") {
|
||||
// //toast_error(rel.msg);
|
||||
// console.log(rel.msg);
|
||||
// }
|
||||
// else {
|
||||
// //toast_warning(rel.msg);
|
||||
// console.log(rel.msg);
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
// else {
|
||||
// //toast_ok(rel.msg);
|
||||
// console.log(rel.msg);
|
||||
// //buildInfoTable.ajax.reload(null, false);
|
||||
// //$('#build-modal').modal('hide');
|
||||
// return;
|
||||
// }
|
||||
// },
|
||||
// fail: function (xhr, status, error) {
|
||||
// //$("#save-building-btn").html('確定').attr("disabled", false);
|
||||
// //toast_error(rel.msg);
|
||||
// }
|
||||
//});
|
||||
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
@ -463,29 +395,21 @@
|
||||
contentType: "application/json; charset=UTF-8",
|
||||
dataType: 'json',
|
||||
success: function (rel) {
|
||||
//$("#save-building-btn").html('確定').attr("disabled", false);
|
||||
if (rel.code != "0000") {
|
||||
if (rel.code == "9999") {
|
||||
//toast_error(rel.msg);
|
||||
console.log(rel.msg);
|
||||
}
|
||||
else {
|
||||
//toast_warning(rel.msg);
|
||||
console.log(rel.msg);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else {
|
||||
//toast_ok(rel.msg);
|
||||
console.log(rel.msg);
|
||||
//buildInfoTable.ajax.reload(null, false);
|
||||
//$('#build-modal').modal('hide');
|
||||
return;
|
||||
}
|
||||
},
|
||||
fail: function (xhr, status, error) {
|
||||
//$("#save-building-btn").html('確定').attr("disabled", false);
|
||||
//toast_error(rel.msg);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -45,7 +45,9 @@
|
||||
setLightColor();
|
||||
}
|
||||
if (arr.indexOf(3) != -1) {
|
||||
|
||||
getHotspotPoint(() => {
|
||||
getLightDevice();
|
||||
show3DModel(data.urn_3D);
|
||||
});
|
||||
|
||||
@ -335,11 +337,50 @@
|
||||
|
||||
}
|
||||
|
||||
async function getLightDevice() {//callback = null
|
||||
getLightData(null);
|
||||
let url = baseApiUrl + "/api/GetDevNodeForCor";
|
||||
let sendData = {
|
||||
"device_area_tag": pageAct.AreaTag,
|
||||
"device_building_tag": pageAct.buiTag,
|
||||
"device_system_tag": pageAct.sysMainTag,
|
||||
"device_name_tag": pageAct.sysSubTag,
|
||||
};
|
||||
objSendData.Data = sendData;
|
||||
ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
|
||||
if (!res || res.code != "0000" || !res.data) {
|
||||
|
||||
} else {
|
||||
|
||||
let myLightList = [];
|
||||
$.each(res.data, (idx, data) => {
|
||||
let item = {};
|
||||
item.position = {};
|
||||
if (data.device_node_coordinate_3d != null && isJSON(data.device_node_coordinate_3d)) {
|
||||
item.position = JSON.parse(data.device_node_coordinate_3d);
|
||||
}
|
||||
$.extend(item, data);
|
||||
myLightList.push(item);
|
||||
})
|
||||
|
||||
console.log("2", myLightList);
|
||||
setLightList(myLightList);
|
||||
//callback ? callback() : "";
|
||||
}
|
||||
}, null, "POST").send();
|
||||
|
||||
}
|
||||
|
||||
function setHotspotPoint(myDataList = []) {
|
||||
console.log(myDataList)
|
||||
getHopspotPoint(myDataList);
|
||||
}
|
||||
|
||||
async function setLightList(myDataList = []) {
|
||||
console.log(myDataList);
|
||||
getLightData(myDataList);
|
||||
}
|
||||
|
||||
var parentEle = "";
|
||||
onEvent("autodesk:click:sprite", "[name=forgeViewer]", function (e, obj) {
|
||||
forgeUnFocusAll();
|
||||
|
@ -5,6 +5,7 @@ var targetFloorZ;
|
||||
var elevatorSpeed;
|
||||
var selector = "#forgeViewer";
|
||||
var myDataList;
|
||||
var lightDataList;
|
||||
var lightList = [];//燈光清單
|
||||
var levels;//剖面用
|
||||
var lowerIdx;//剖面的下方樓層
|
||||
@ -304,6 +305,16 @@ class elevator3D {
|
||||
}
|
||||
|
||||
function onDocumentLoadSuccess(doc, eleOption) {
|
||||
//取得燈光清單
|
||||
if (lightDataList != undefined && lightDataList != null && lightDataList.length > 0) {
|
||||
lightDataList.forEach((myData, index) => {
|
||||
//if (myData.priority == 5) {
|
||||
const position = JSON.parse(myData.device_node_coordinate_3d);
|
||||
lightList.push({ dbid: myData.forge_dbid, spotLight: newLight(position) });
|
||||
//}
|
||||
});
|
||||
}
|
||||
|
||||
var viewables = doc.getRoot().getDefaultGeometry();
|
||||
viewer.loadDocumentNode(doc, viewables).then(i => {
|
||||
// documented loaded, any action?
|
||||
@ -323,6 +334,7 @@ function onDocumentLoadSuccess(doc, eleOption) {
|
||||
$(selector).trigger("autodesk:loaded", nodeIds);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
@ -607,35 +619,18 @@ class ADHeatMaps {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function setTransparentBuilding() {
|
||||
//allDbIdsStr.forEach((dbId) => {
|
||||
// setTransparency(dbId, 0.2);
|
||||
//})
|
||||
|
||||
//全部物件 透明度: 輸入0:透明;輸入1:不透明
|
||||
function setTransparentBuilding(transparent) {
|
||||
for (var i = 0; i < allDbIdsStr.length; i++) {
|
||||
setTransparency(parseInt(allDbIdsStr[i]), 0.2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function recoverTransparentBuilding() {
|
||||
//allDbIdsStr.forEach((dbId) => {
|
||||
// setTransparency(dbId, 1);
|
||||
//})
|
||||
|
||||
for (var i = 0; i < allDbIdsStr.length; i++) {
|
||||
setTransparency(parseInt(allDbIdsStr[i]), 1);
|
||||
setTransparency(parseInt(allDbIdsStr[i]), transparent);
|
||||
}
|
||||
}
|
||||
|
||||
//設定模型 透明度
|
||||
function setTransparency(nodeId, opacity) {
|
||||
var model = viewer.model;
|
||||
//var nodeId = 1633;
|
||||
|
||||
var fragList = viewer.model.getFragmentList();
|
||||
|
||||
var fragIds = []
|
||||
var fragIds = [];
|
||||
|
||||
model.getData().instanceTree.enumNodeFragments(
|
||||
nodeId, (fragId) => {
|
||||
@ -694,6 +689,14 @@ async function addHotPoint(data) {
|
||||
|
||||
const style = new DataVizCore.ViewableStyle(viewableType, spriteColor, spriteIcon);
|
||||
|
||||
//取得燈光清單
|
||||
//if (lightDataList != undefined && lightDataList != null && lightDataList.length > 0) {
|
||||
// lightDataList.forEach((myData, index) => {
|
||||
// const position = JSON.parse(myData.device_node_coordinate_3d);
|
||||
// lightList.push({ dbid: myData.forge_dbid, spotLight: newLight(position) });
|
||||
// });
|
||||
//}
|
||||
|
||||
//熱點 點擊事件註冊
|
||||
viewer.addEventListener(DataVizCore.MOUSE_CLICK, onSpriteClicked);// SPRITE_SELECTED
|
||||
|
||||
@ -711,9 +714,6 @@ async function addHotPoint(data) {
|
||||
const viewable = new DataVizCore.SpriteViewable(myPosition, style, dbId);
|
||||
myData._dbId = dbId;
|
||||
viewableData.addViewable(viewable);
|
||||
if (myData.device_number.indexOf("_LT_L1_") > -1) {
|
||||
lightList.push({ dbid: myData.forge_dbid, name: myData.device_number, spotLight: newLight(myPosition) });
|
||||
}
|
||||
});
|
||||
|
||||
await viewableData.finish();
|
||||
@ -913,7 +913,7 @@ function profile() {
|
||||
//新增燈光
|
||||
async function newLight(lightPosition) {
|
||||
//聚光燈
|
||||
spotLight = new THREE.SpotLight(0xff0000, 200, 20, 0.6, 0.5, 10);
|
||||
var spotLight = new THREE.SpotLight(0xffffff, 200, 20, 0.6, 0.5, 10);
|
||||
spotLight.position.set(lightPosition.x, lightPosition.y, lightPosition.z);
|
||||
spotLight.castShadow = false;
|
||||
spotLight.visible = true;
|
||||
@ -925,15 +925,11 @@ async function newLight(lightPosition) {
|
||||
return spotLight;
|
||||
}
|
||||
|
||||
//調整燈光參數 setLightValues(13593, 10, 10, 0.1, 0.3, 1, 0xffff00);
|
||||
async function setLightValues(dbid, intensity, distance, angle, penumbra, decay, color) {
|
||||
//調整燈光 強度、顏色
|
||||
async function setLightValues(dbid, intensity, color) {
|
||||
for (var i = 0; i < lightList.length; i++) {
|
||||
if (lightList[i].dbid == dbid) {
|
||||
lightList[i].spotLight.intensity = intensity;
|
||||
lightList[i].spotLight.distance = distance;
|
||||
lightList[i].spotLight.angle = angle;
|
||||
lightList[i].spotLight.penumbra = penumbra;
|
||||
lightList[i].spotLight.decay = decay;
|
||||
|
||||
var tempcolor = new THREE.Color().setHex(color);
|
||||
lightList[i].spotLight.color = tempcolor;
|
||||
@ -942,6 +938,23 @@ async function setLightValues(dbid, intensity, distance, angle, penumbra, decay,
|
||||
}
|
||||
}
|
||||
|
||||
//燈光開關
|
||||
function setLightOpenOrClose(value, light) {
|
||||
if (value) {
|
||||
light.visible = true;
|
||||
}
|
||||
else {
|
||||
light.visible = false;
|
||||
}
|
||||
viewer.impl.sceneUpdated(true);
|
||||
}
|
||||
|
||||
//透過nodeId,更改物件顏色或顯示與否;color請填寫THREE.Vector4
|
||||
function changeColorTransparency(nodeId, color) {//變綠色
|
||||
//var color = new THREE.Vector4(0, 1, 0, 1);//綠色;前三個代表r、g、b; 亦可填入255/255
|
||||
//var color = new THREE.Vector4(0, 1, 0, 0);//不顯示顏色;最後的參數為透明度
|
||||
viewer.setThemingColor(nodeId, color);
|
||||
}
|
||||
|
||||
//======================== 外部呼叫function ===========================
|
||||
//紀錄熱點座標
|
||||
@ -949,6 +962,11 @@ function getHopspotPoint(data) {
|
||||
myDataList = data;
|
||||
}
|
||||
|
||||
//紀錄燈具座標
|
||||
async function getLightData(data) {
|
||||
lightDataList = data;
|
||||
}
|
||||
|
||||
//呼叫載入熱圖
|
||||
async function toLoadHeatmap(roomArr) {
|
||||
const model = viewer.model;
|
||||
|
@ -711,6 +711,37 @@ namespace FrontendWebApi.ApiControllers
|
||||
return Ok(apiResult);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("api/GetDevNodeForCor")]
|
||||
public async Task<ActionResult<List<DevNodeForCor>>> GetDevNodeForCor([FromBody] Device p)
|
||||
{
|
||||
ApiResult<List<DevNodeForCor>> apiResult = new ApiResult<List<DevNodeForCor>>();
|
||||
List<DevNodeForCor> device = new List<DevNodeForCor>();
|
||||
|
||||
try
|
||||
{
|
||||
apiResult.Code = "0001";
|
||||
if (p != null )
|
||||
{
|
||||
if (p.device_system_tag == "LT" && p.device_name_tag == "L1")
|
||||
{
|
||||
var d = await backendRepository.GetAllAsync<DevNodeForCor>($@"select device_guid,priority,device_node_coordinate_3d,forge_dbid from device_node where deleted = 0");
|
||||
|
||||
apiResult.Data = d;
|
||||
apiResult.Code = "0000";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
return Ok(apiResult);
|
||||
}
|
||||
return Ok(apiResult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 燈控排程列表
|
||||
/// </summary>
|
||||
|
@ -793,6 +793,17 @@ namespace FrontendWebApi.ApiControllers
|
||||
});
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("api/getUserFull")]
|
||||
public ActionResult GetUserFull()
|
||||
{
|
||||
return Json(new
|
||||
{
|
||||
code = "0000",
|
||||
data = myUser
|
||||
});
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ApiResult<string>> GetUsrRolId([FromBody] User post)
|
||||
{
|
||||
|
@ -133,4 +133,12 @@ namespace FrontendWebApi.Models
|
||||
public string device_coordinate_3d { get; set; }
|
||||
public int? forge_dbid { get; set; }
|
||||
}
|
||||
|
||||
public class DevNodeForCor
|
||||
{
|
||||
public string device_guid { get; set; }
|
||||
public int priority { get; set; }
|
||||
public string device_node_coordinate_3d { get; set; }
|
||||
public int? forge_dbid { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -270,6 +270,41 @@ namespace Repository.BaseRepository.Implement
|
||||
return result;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 取得單一筆資料某一欄位(排序)
|
||||
/// </summary>
|
||||
/// <param name="tableName"></param>
|
||||
/// <param name="sWhere"></param>
|
||||
/// <param name="selCol">填放欄位</param>
|
||||
/// <param name="param">參數值</param>
|
||||
/// <param name="sOrderBy"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<string> GetOneColAsync(string tableName, string sWhere, string selCol, object param = null, string sOrderBy = "")
|
||||
{
|
||||
string result;
|
||||
using (IDbConnection conn = GetDbConnection())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = $"SELECT {selCol} FROM {tableName}";
|
||||
if (!string.IsNullOrEmpty(sWhere))
|
||||
{
|
||||
sql += $" WHERE {sWhere}";
|
||||
}
|
||||
if (!string.IsNullOrEmpty(sOrderBy))
|
||||
{
|
||||
sql += $" ORDER BY {sOrderBy}";
|
||||
}
|
||||
|
||||
result = await conn.QueryFirstOrDefaultAsync<string>(sql, param);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得單一筆資料(根據自訂SQL, 自訂參數)
|
||||
|
@ -95,6 +95,18 @@ namespace Repository.BaseRepository.Interface
|
||||
/// <returns></returns>
|
||||
Task<object> GetOneAsync(string tableName, string sWhere, string selCol, object param = null, string sOrderBy = "");
|
||||
/// <summary>
|
||||
/// 取得單一筆資料某一欄位(排序),不需sWhere及sOrderBy填""
|
||||
/// <para>
|
||||
/// SELECT {selCol} FROM {tableName} WHERE {sWhere} ORDER BY {sOrderBy}
|
||||
/// </para>
|
||||
/// </summary>
|
||||
/// <param name="tableName"></param>
|
||||
/// <param name="sWhere"></param>
|
||||
/// <param name="sOrderBy"></param>
|
||||
/// <param name="selCol">填放欄位</param>
|
||||
/// <returns></returns>
|
||||
Task<string> GetOneColAsync(string tableName, string sWhere, string selCol, object param = null, string sOrderBy = "");
|
||||
/// <summary>
|
||||
/// 取得單一筆資料(根據自訂SQL, 自訂參數)
|
||||
/// </summary>
|
||||
/// <param name="sqlString"></param>
|
||||
|
Loading…
Reference in New Issue
Block a user