duheng
2024-08-07 c1c74bdc430bd1f4ff0849c6240bcba892c4a189
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
using Yw.DAL.PostgreSql;
 
namespace HStation.DAL.PostgreSql
{
    /// <summary>
    ///
    /// </summary>:
    public partial class EmployeeMain : BaseDAL_Paras_Flags_TagName_Sorter<Entity.EmployeeMain>, IEmployeeMain
    {
        /// <summary>
        ///
        /// </summary>
        public override ConnectionConfig ConnectionConfig
        {
            get { return Organize.ConfigHelper.PostgreSqlConnectionConfig; }
        }
 
        //插入拓展
        public long InsertEx(Entity.EmployeeMain employeeMain, Entity.UserLoginAccount userLogin, Entity.UserLoginMap loginmap)
        {
            if (employeeMain == null)
            {
                return default;
            }
            using (var db = new SqlSugarClient(ConnectionConfig))
            {
                try
                {
                    db.BeginTran();
                    employeeMain.AddTime = DateTime.Now.ToString();
                    var result = db.Insertable(employeeMain).ExecuteReturnSnowflakeId();
                    if (result < 0)
                    {
                        db.RollbackTran();
                        return default;
                    }
                    else
                    {
                        if (userLogin != null)
                        {
                            userLogin.CreateTime = DateTime.Now.ToString();
                            var logjinresult = db.Insertable(userLogin).ExecuteReturnSnowflakeId();
                            if (logjinresult < 0)
                            {
                                db.RollbackTran();
                                return default;
                            }
                            else
                            {
                                loginmap.LoginID = logjinresult;
                                loginmap.ObjectID = result;
                                loginmap.ObjectType = 0;
                                var mapresult = db.Insertable(loginmap).ExecuteReturnSnowflakeId();
                                if (mapresult < 0)
                                {
                                    db.RollbackTran();
                                    return default;
                                }
                            }
                        }
                    }
                    db.CommitTran();
                    return result;
                }
                catch (Exception ex)
                {
                    db.RollbackTran();
                    throw;
                }
            }
        }
    }
}