57 lines
1.8 KiB
C#
57 lines
1.8 KiB
C#
using System;
|
|
using System.Linq;
|
|
|
|
namespace BLL
|
|
{
|
|
/// <summary>
|
|
/// 图纸标注信息服务。
|
|
/// </summary>
|
|
public static class DrawingInfoService
|
|
{
|
|
/// <summary>
|
|
/// 根据附件文件标识获取图纸 JSON。
|
|
/// </summary>
|
|
public static string GetDrawingJson(string attachFileId)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(attachFileId))
|
|
{
|
|
return null;
|
|
}
|
|
|
|
return Funs.DB.HJGL_DrawingInfo
|
|
.Where(x => x.AttachFileId == attachFileId)
|
|
.Select(x => x.DrawingJson)
|
|
.FirstOrDefault();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 新增或更新图纸标注信息,同一 AttachFileId 只保留一条记录。
|
|
/// </summary>
|
|
public static void SaveDrawingInfo(string attachFileId, string drawingName, string drawingJson)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(attachFileId))
|
|
{
|
|
throw new ArgumentException("附件文件标识不能为空。", "attachFileId");
|
|
}
|
|
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.HJGL_DrawingInfo drawingInfo = db.HJGL_DrawingInfo
|
|
.FirstOrDefault(x => x.AttachFileId == attachFileId);
|
|
|
|
if (drawingInfo == null)
|
|
{
|
|
drawingInfo = new Model.HJGL_DrawingInfo
|
|
{
|
|
DrawingInfoId = SQLHelper.GetNewID(),
|
|
AttachFileId = attachFileId
|
|
};
|
|
db.HJGL_DrawingInfo.InsertOnSubmit(drawingInfo);
|
|
}
|
|
|
|
drawingInfo.DrawingName = string.IsNullOrWhiteSpace(drawingName) ? null : drawingName;
|
|
drawingInfo.DrawingJson = string.IsNullOrWhiteSpace(drawingJson) ? "{}" : drawingJson;
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
}
|