duan
2024-08-21 22bd5bc1ce2b49284cc2f042c7f4f48619fcf85b
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
using DIXWeb.DAL;
using DIXWeb.Entity.Workflow;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace DIXWeb.Business.GlobalM
{
    public class WorkflowNodeDetailBusiness
    {
        public List<WorkflowOrgType> GetWorkflowOrgType()
        {
            List<WorkflowOrgType> list = null;
            using (DBContext db =new DBContext())
            {
                list = db.WorkflowOrgType.ToList();
            }
            return list;
        }
 
        public List<WorkflowRoleType> GetWorkflowRoleType()
        {
            List<WorkflowRoleType> list = null;
            using (DBContext db = new DBContext())
            {
                list = db.WorkflowRoleType.ToList();
            }
            return list;
        }
 
        public Receive GetWorkflowNDetail(int NodeId, int pageIndex, int pageSize)
        {
            Receive receive = new Receive();
            try
            {
                using (DBContext db = new DBContext())
                {
                    System.Data.SqlClient.SqlParameter[] paramList = new System.Data.SqlClient.SqlParameter[] {
                        new System.Data.SqlClient.SqlParameter("@NodeId", NodeId),
                        new System.Data.SqlClient.SqlParameter("@pageIndex", pageIndex),
                        new System.Data.SqlClient.SqlParameter("@pageSize", pageSize),
                        new System.Data.SqlClient.SqlParameter("@Total", 0),
                    };
                    int index = paramList.Length - 1;
                    paramList[index].Direction = ParameterDirection.Output;
                    receive.rows = db.Database.SqlQuery<ReceiveNodeDetail>("exec meta.p_getWorkflowNDetailByNodeId @NodeId,@pageIndex,@pageSize,@Total output ", paramList).ToList();
                    receive.total = int.Parse(paramList[index].Value.ToString());
                    receive.Code = 200;
                    receive.Message = "SUCCESS";
                }
            }
            catch (Exception ex)
            {
                receive.Code = 500;
                receive.Message = ex.Message;
            }
            return receive;
        }
 
        public void Insert(WorkflowNodeDetail record)
        {
            using (DBContext db = new DBContext())
            {
                db.WorkflowNodeDetail.Add(record);
                db.SaveChanges();
            }
        }
 
        public void Update(WorkflowNodeDetail record)
        {
            using (DBContext db = new DBContext())
            {
                WorkflowNodeDetail tempRecord = db.WorkflowNodeDetail.Find(record.Id);
                //tempRecord.WorkflowId = record.WorkflowId;
                //tempRecord.NodeId = record.NodeId;
                tempRecord.OrgTypeId = record.OrgTypeId;
                tempRecord.OrgId = record.OrgId;
                tempRecord.RoleTypeId = record.RoleTypeId;
                tempRecord.RoleId = record.RoleId;
                tempRecord.DetailLevel = record.DetailLevel;
                tempRecord.ActiveType = record.ActiveType;
                tempRecord.ChTime = record.ChTime;
                tempRecord.ChUserId = record.ChUserId;
                db.SaveChanges();
            }
        }
 
        public ReceiveNodeDetail SelectById(int Id)
        {
            ReceiveNodeDetail record = null;
            using (DBContext db = new DBContext())
            {
                System.Data.SqlClient.SqlParameter[] paramList = new System.Data.SqlClient.SqlParameter[] {
                    new System.Data.SqlClient.SqlParameter("@Id", Id),
                };
                record = db.Database.SqlQuery<ReceiveNodeDetail>("EXEC meta.p_getWorkflowNDetailById @Id ", paramList).FirstOrDefault();
            }
            return record;
        }
    }
}