using SqlSugar;
|
using IStation.Entity;
|
using System;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Linq;
|
|
namespace IStation.DAL
|
{
|
/// <summary>
|
/// Bimface文件类型
|
/// </summary>
|
public partial class BimfaceFileType : CorpTraceDAL_Sorter_UseStatus_TagName<Entity.BimfaceFileType>
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public override ConnectionConfig ConnectionConfig
|
{
|
get { return ConfigHelper.DefaultConnectionConfig; }
|
}
|
|
/// <summary>
|
/// 通过 ObjectType 获取
|
/// </summary>
|
public List<Entity.BimfaceFileType> GetByObjectType(long CorpID, string ObjectType)
|
{
|
using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
|
{
|
return db.Queryable<Entity.BimfaceFileType>()
|
.Where(x=>x.CorpID==CorpID&&x.ObjectType==ObjectType).ToList();
|
}
|
}
|
|
/// <summary>
|
/// 更新 IsDefault
|
/// </summary>
|
public bool UpdateIsDefault(long CorpID, long ID, bool IsDefault,long UpdateUserID,DateTime UpdateTime)
|
{
|
using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
|
{
|
return db.Updateable<Entity.BimfaceFileType>()
|
.SetColumns(x => x.IsDefault == IsDefault)
|
.SetColumns(x => x.UpdateUserID == UpdateUserID)
|
.SetColumns(x => x.UpdateTime == UpdateTime)
|
.Where(x => x.CorpID == CorpID && x.ID == ID)
|
.ExecuteCommand() > 0;
|
}
|
}
|
|
/// <summary>
|
/// 设置默认
|
/// </summary>
|
public bool SetDefault(long CorpID, string ObjectType, long ID,long UpdateUserID, DateTime UpdateTime)
|
{
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
try
|
{
|
db.BeginTran();
|
var bol = db.Updateable<Entity.BimfaceFileType>()
|
.SetColumns(x => x.IsDefault == true)
|
.SetColumns(x=>x.UpdateUserID==UpdateUserID)
|
.SetColumns(x=>x.UpdateTime==UpdateTime)
|
.Where(x => x.CorpID == CorpID && x.ID == ID)
|
.ExecuteCommand() > 0;
|
if (!bol)
|
{
|
db.RollbackTran();
|
return false;
|
}
|
db.Updateable<Entity.BimfaceFileType>()
|
.SetColumns(x => x.IsDefault == false)
|
.SetColumns(x => x.UpdateUserID == UpdateUserID)
|
.SetColumns(x => x.UpdateTime == UpdateTime)
|
.Where(x => x.CorpID == CorpID && x.ObjectType == ObjectType && x.ID != ID)
|
.ExecuteCommand();
|
db.CommitTran();
|
return true;
|
}
|
catch
|
{
|
db.RollbackTran();
|
throw;
|
}
|
}
|
}
|
|
|
|
}
|
}
|