lixiaojun
2024-03-30 e9c15d84b7f5edc9fee0c1998e21877d24290d71
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
namespace Yw.DAL.SQLite
{
    /// <summary>
    /// 
    /// </summary>
    public partial class BimfaceFile : BaseTraceDAL_Paras_Flags_TagName_Sorter<Entity.BimfaceFile>, IBimfaceFile
    {
        /// <summary>
        /// 
        /// </summary>
        public override ConnectionConfig ConnectionConfig
        {
            get { return ConfigHelper.SQLiteConnectionConfig; }
 
        }
 
        /// <summary>
        /// 更新 FileStatus
        /// </summary>
        public bool UpdateFileStatus(long ID, int FileStatus)
        {
            using (SqlSugarClient db = new(ConnectionConfig))
            {
                return db.Updateable<Entity.BimfaceFile>()
                    .SetColumns(x => x.FileStatus == FileStatus)
                    .SetColumns(x => x.UpdateUserID == UserRegister.UserID)
                    .SetColumns(x => x.UpdateTime == DateTime.Now)
                    .SetColumns(x => x.UpdateUserName == UserRegister.UserName)
                    .Where(x => x.ID == ID)
                    .ExecuteCommandHasChange();
            }
        }
 
        /// <summary>
        /// 更新 Content 
        /// </summary>
        public bool UpdateContent(long ID, string Content)
        {
            using (SqlSugarClient db = new(ConnectionConfig))
            {
                return db.Updateable<Entity.BimfaceFile>()
                    .SetColumns(x => x.Content == Content)
                    .SetColumns(x => x.UpdateUserID == UserRegister.UserID)
                    .SetColumns(x => x.UpdateTime == DateTime.Now)
                    .SetColumns(x => x.UpdateUserName == UserRegister.UserName)
                    .Where(x => x.ID == ID)
                    .ExecuteCommandHasChange();
            }
        }
 
 
        /// <summary>
        /// 通过 ID 删除(同时删除标签)
        /// </summary>
        public bool DeleteExByID(long ID)
        {
            using (var db = new SqlSugarClient(ConnectionConfig))
            {
                try
                {
                    db.BeginTran();
                    var bol = db.Deleteable<Entity.BimfaceFile>().Where(x => x.ID == ID).ExecuteCommandHasChange();
                    if (!bol)
                    {
                        db.RollbackTran();
                        return false;
                    }
                    db.Deleteable<Entity.BimfaceFileLabel>().Where(x => x.BimfaceFileID == ID).ExecuteCommandHasChange();
                    db.CommitTran();
                    return true;
                }
                catch
                {
                    db.RollbackTran();
                    throw;
                }
            }
        }
 
 
 
 
    }
}