123 lines
3.2 KiB
C#
123 lines
3.2 KiB
C#
using Newtonsoft.Json.Bson;
|
|
using Sinvo.EplanHpD.Plugin.Service;
|
|
using Sinvo.EplanHpD.Plugin.Service.Model;
|
|
using Sinvo.EplanHpD.Plugin.WPFUI.Models.MultiCoreWire;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Shapes;
|
|
|
|
namespace Sinvo.EplanHpD.Plugin.WPFUI.Service
|
|
{
|
|
public class MultiCoreWireService
|
|
{
|
|
public IEnumerable<MultiCoreWireLecDBModel> GetByUniqueKey(string uniqueKey)
|
|
{
|
|
|
|
if (string.IsNullOrEmpty(uniqueKey))
|
|
{
|
|
return [];
|
|
}
|
|
var db = DBHelper.DB;
|
|
try
|
|
{
|
|
var result = db.Queryable<MultiCoreWireLecDBModel>()
|
|
.Where(it => it.UniqueKey == uniqueKey)
|
|
.ToList();
|
|
return result;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
// 保存
|
|
public void SaveData(MultiCoreWireLecDBModel line)
|
|
{
|
|
if (string.IsNullOrEmpty(line.UniqueKey)
|
|
|| string.IsNullOrEmpty(line.UserId)
|
|
|| string.IsNullOrEmpty(line.ProjectName))
|
|
{
|
|
return;
|
|
}
|
|
var db = DBHelper.DB;
|
|
try
|
|
{
|
|
db.BeginTran();
|
|
db.Insertable(line).ExecuteCommand();
|
|
db.CommitTran();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
db.RollbackTran();
|
|
throw;
|
|
}
|
|
}
|
|
|
|
internal void ClearSelf(string uniqueKey)
|
|
{
|
|
if (string.IsNullOrEmpty(uniqueKey))
|
|
{
|
|
return;
|
|
}
|
|
var db = DBHelper.DB;
|
|
try
|
|
{
|
|
db.BeginTran();
|
|
db.Deleteable<MultiCoreWireLecDBModel>().Where(it => it.UniqueKey == uniqueKey).ExecuteCommand();
|
|
db.CommitTran();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
db.RollbackTran();
|
|
throw;
|
|
}
|
|
}
|
|
|
|
internal void DeleteById(string id)
|
|
{
|
|
if (string.IsNullOrEmpty(id))
|
|
{
|
|
return;
|
|
}
|
|
var db = DBHelper.DB;
|
|
try
|
|
{
|
|
db.BeginTran();
|
|
db.Deleteable<MultiCoreWireLecDBModel>().Where(it => it.Id == id).ExecuteCommand();
|
|
db.CommitTran();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
db.RollbackTran();
|
|
throw;
|
|
}
|
|
}
|
|
internal void UpdateWireIsLayout(string id)
|
|
{
|
|
if (string.IsNullOrEmpty(id))
|
|
{
|
|
return;
|
|
}
|
|
var db = DBHelper.DB;
|
|
try
|
|
{
|
|
db.BeginTran();
|
|
db.Updateable<MultiCoreWireLecDBModel>()
|
|
.Where(it => it.Id == id)
|
|
.SetColumns(it => it.Layouted == true)
|
|
.ExecuteCommand();
|
|
db.CommitTran();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
db.RollbackTran();
|
|
throw;
|
|
}
|
|
}
|
|
}
|
|
}
|