tangxu
2024-04-30 26d8996e55c33186800031f7c305688035bb3182
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
using AStation.HttpClient;
using SqlSugar;
 
namespace AStation.DAL
{
    public class SoftSetting : BaseDAL<Entity.SoftSetting>
    {
        public override ConnectionConfig ConnectionConfig
        {
            get { return ConnectionFactory.BuildConnection(); }
        }
 
        /// <summary>
        /// 通过 SetName 获取
        /// </summary>
        public Entity.SoftSetting GetBySetName(string Type, string SetName)
        {
            using (ISqlSugarClient db = Connection)
            {
                return db.Queryable<Entity.SoftSetting>().Single(x => x.Name == SetName && x.Type == Type);
            }
        }
 
        /// <summary>
        /// 更新 SetValue
        /// </summary>
        public bool UpdateSetValue(string Type, string Name, string SetValue)
        {
            using (ISqlSugarClient db = Connection)
            {
                var result = db.Updateable<Entity.SoftSetting>()
                    .SetColumns("Value", SetValue)
                    .Where(x => x.Type == Type && x.Name == Name).ExecuteCommandHasChange();
 
                if (result && AStation.CorpConfig.Instance.RealTimeRemoteService.IsSynMainData)
                {
                    var dtos = db.Queryable<Entity.SoftSetting>().Where(x => x.Type == Type && x.Name == Name);
                    HttpClientHelper.Build(this.TableName, "Updates@V1.0").Put<bool>(dtos);
                }
                return result;
            }
        }
    }
}