BaseBll.cs
9.88 KB
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
using HHECS.Model;
using HHECS.Model.BLLModel;
using HHECS.Model.Entities;
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
namespace HHECS.Bll
{
/// <summary>
/// 基础数据和访问数据库相关的抽象类
/// </summary>
public abstract class BaseBll
{
public string ConnectStr { get; set; }
public IDbConnection GetConnection()
{
return new MySqlConnection(ConnectStr);
}
#region 实例方法
/// <summary>
/// 检查按钮权限
/// </summary>
/// <param name="menuOperations"></param>
/// <param name="controls"></param>
public void CheckPermission(List<MenuOperation> menuOperations, UIElementCollection controls)
{
foreach (var item in controls)
{
if (item is Button)
{
Button temp = item as Button;
if (temp.Tag is String)
{
string perms = (string)temp.Tag;
if (menuOperations.Count(t => t.Perms == perms) > 0)
{
temp.Visibility = Visibility.Visible;
}
else
{
temp.Visibility = Visibility.Collapsed;
}
}
else
{
temp.Visibility = Visibility.Collapsed;
}
}
}
}
/// <summary>
/// 检查按钮权限
/// </summary>
/// <param name="menuOperations"></param>
/// <param name="controls"></param>
public void CheckPermission(List<MenuOperation> menuOperations, List<UIElement> controls)
{
foreach (var item in controls)
{
if (item is Button)
{
Button temp = item as Button;
if (temp.Tag is String)
{
string perms = (string)temp.Tag;
if (menuOperations.Count(t => t.Perms == perms) > 0)
{
temp.Visibility = Visibility.Visible;
}
else
{
temp.Visibility = Visibility.Collapsed;
}
}
else
{
temp.Visibility = Visibility.Collapsed;
}
}
}
}
/// <summary>
/// 组合一组权限和他的子权限
/// </summary>
/// <param name="menuOperations"></param>
/// <param name="all"></param>
public void Combine(List<MenuOperation> menuOperations, List<MenuOperation> all)
{
foreach (var item in menuOperations)
{
item.Children.AddRange(all.FindAll(t => t.ParentId == item.Id));
if (item.Children.Count > 0)
{
Combine(item.Children, all);
}
}
}
#endregion
#region 基础数据
public abstract BllResult<User> GetUserWithRoles(string userName, string password);
public abstract BllResult<List<MenuOperation>> FindMenuOperation(List<Role> roles);
public abstract BllResult<List<MenuOperation>> GetAllMenuOperation();
public abstract BllResult<MenuOperation> SaveMenuOperation(MenuOperation currentMenuOperation);
public abstract BllResult UpdateMenuOperation(MenuOperation currentMenuOperation);
public abstract BllResult DeleteMenuOperationByIds(List<int> ids);
public abstract BllResult<List<Role>> GetAllRole();
public abstract BllResult<Role> GetRoleById(int value);
public abstract void GetMenuOperationIds(List<MenuOperation> list, List<MenuOperation> menuOperations, List<int> ids);
public abstract BllResult<List<Config>> GetAllConfig();
public abstract BllResult<List<Material>> GetAllMaterial();
public abstract BllResult<Role> InsertRoleAndMenuOperations(Role currentRole, List<MenuOperation> list);
public abstract BllResult<Role> UpdateRoleAndMenuOperations(Role currentRole, List<MenuOperation> list);
public abstract BllResult<List<User>> GetUserByCondition(string sql);
public abstract BllResult SetUserDisable(List<int?> list, int enable);
public abstract BllResult<User> SaveUserWithRoles(User currentUser, List<int> RoleIds);
public abstract BllResult<User> UpdateUserWithRoles(User currentUser, List<int> RoleIds);
public abstract BllResult<Dict> GetDictWithDetails(string v);
public abstract BllResult DeleteConfigByIds(List<int> list);
public abstract BllResult DeleteMaterialByIds(List<int> list);
public abstract BllResult DeleteRoleByIds(List<int> list);
public abstract BllResult DeleteDictByIds(List<int> list);
public abstract BllResult DeleteEuipmentTypeByIds(List<int> list);
public abstract BllResult DeleteEquipmentTypePropTemplateByIds(List<int> list);
public abstract BllResult DeleteEuipmentByIds(List<int> ids);
public abstract BllResult SyncEquipmentProp(int? id);
public abstract BllResult CopyEquipment(EquipmentType equipment);
#endregion
#region Job
/// <summary>
/// 执行一次指定的job
/// </summary>
/// <param name="value"></param>
/// <param name="client"></param>
/// <returns></returns>
public abstract Task<BllResult> ExcuteJobAsync(int value, HttpClient client);
#endregion
#region Data
public abstract BllResult<List<T>> GetCommonModelByCondition<T>(string v);
public abstract Task<BllResult<List<T>>> GetCommonModelByConditionAsync<T>(string v);
public abstract BllResult<List<T>> GetCommonModelByCondition<T>(string v, IDbConnection connection, IDbTransaction tran);
public abstract Task<BllResult<List<T>>> GetCommonModelByConditionAsync<T>(string v, IDbConnection connection, IDbTransaction tran);
public abstract BllResult<int> GetCommonModelCount<T>(string sql);
public abstract BllResult<int> GetCommonModelCount<T>(string sql, IDbConnection connection, IDbTransaction tran);
public abstract BllResult<int?> SaveCommonModel<T>(T model);
public abstract Task<BllResult<int?>> SaveCommonModelAsync<T>(T model);
public abstract BllResult<int?> SaveCommonModel<T>(T model, IDbConnection connection, IDbTransaction tran);
public abstract Task<BllResult<int?>> SaveCommonModelAsync<T>(T model, IDbConnection connection, IDbTransaction tran);
public abstract BllResult UpdateCommonModel<T>(T model);
public abstract Task<BllResult> UpdateCommonModelAsync<T>(T model);
public abstract BllResult UpdateCommonModel<T>(T model, IDbConnection connection, IDbTransaction tran);
public abstract Task<BllResult> UpdateCommonModelAsync<T>(T model, IDbConnection connection, IDbTransaction tran);
public abstract BllResult DeleteCommonModelByIds<T>(List<int> list);
public abstract Task<BllResult> DeleteCommonModelByIdsAsync<T>(List<int> list);
public abstract BllResult DeleteCommonModelByIds<T>(List<int> list, IDbConnection connection, IDbTransaction tran);
public abstract Task<BllResult> DeleteCommonModelByIdsAsync<T>(List<int> list, IDbConnection connection, IDbTransaction tran);
public abstract BllResult<List<T>> GetCommonModeByPageCondition<T>(int pageNumber, int pageSize, string condition, string orderBy);
public abstract Task<BllResult<List<T>>> GetCommonModeByPageConditionAsync<T>(int pageNumber, int pageSize, string condition, string orderBy);
public abstract BllResult<List<T>> GetCommonModeByPageCondition<T>(IDbConnection connection, IDbTransaction tran, int pageNumber, int pageSize, string condition, string orderBy);
public abstract Task<BllResult<List<T>>> GetCommonModeByPageConditionAsync<T>(IDbConnection connection, IDbTransaction tran, int pageNumber, int pageSize, string condition, string orderBy);
public abstract BllResult<int> ExcuteCommonSqlForInsertOrUpdate(string sql);
public abstract Task<BllResult<int>> ExcuteCommonSqlForInsertOrUpdateAsync(string sql);
public abstract BllResult<int> ExcuteCommonSqlForInsertOrUpdate(string sql, IDbConnection connection, IDbTransaction tran);
public abstract Task<BllResult<int>> ExcuteCommonSqlForInsertOrUpdateAsync(string sql, IDbConnection connection, IDbTransaction tran);
public abstract BllResult<int> ExcuteCommonSqlForInsertOrUpdate(string sql, object param);
public abstract Task<BllResult<int>> ExcuteCommonSqlForInsertOrUpdateAsync(string sql, object param);
public abstract BllResult<int> ExcuteCommonSqlForInsertOrUpdate(string sql, object param, IDbConnection connection, IDbTransaction tran);
public abstract Task<BllResult<int>> ExcuteCommonSqlForInsertOrUpdateAsync(string sql, object param, IDbConnection connection, IDbTransaction tran);
public abstract BllResult<List<T>> GetCommonModelByConditionWithZero<T>(string v);
public abstract Task<BllResult<List<T>>> GetCommonModelByConditionWithZeroAsync<T>(string v);
public abstract BllResult<List<T>> GetCommonModelByConditionWithZero<T>(string v, IDbConnection connection, IDbTransaction tran);
public abstract Task<BllResult<List<T>>> GetCommonModelByConditionWithZeroAsync<T>(string v, IDbConnection connection, IDbTransaction tran);
#endregion
}
}