Skip to content

Commit 8470fbe

Browse files
committed
v1.5 版本发布 http://pan.baidu.com/s/1c0B01Eg 。(框架结构调整预制版)
1 parent ee6d6ba commit 8470fbe

File tree

607 files changed

+24822
-18372
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

607 files changed

+24822
-18372
lines changed

src/RoadFlow/Business.Platform/Business.Platform.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@
3131
<WarningLevel>4</WarningLevel>
3232
</PropertyGroup>
3333
<ItemGroup>
34-
<Reference Include="LitJSON, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
35-
<SpecificVersion>False</SpecificVersion>
36-
<HintPath>..\Source\Web\bin\LitJSON.dll</HintPath>
37-
</Reference>
3834
<Reference Include="System" />
3935
<Reference Include="System.Core" />
4036
<Reference Include="System.Drawing" />
@@ -73,6 +69,10 @@
7369
<Compile Include="WorkGroup.cs" />
7470
</ItemGroup>
7571
<ItemGroup>
72+
<ProjectReference Include="..\LitJSON\LitJSON.csproj">
73+
<Project>{28d9f7ba-2923-4364-9bea-9e1ccd70dd22}</Project>
74+
<Name>LitJSON</Name>
75+
</ProjectReference>
7676
<ProjectReference Include="..\MyCache.Factory\MyCache.Factory.csproj">
7777
<Project>{1E605362-7767-45F9-9BC1-F8E495FA3F4E}</Project>
7878
<Name>MyCache.Factory</Name>

src/RoadFlow/Business.Platform/Log.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public Log()
1313
{
1414
this.dataLog = Data.Factory.Platform.GetLogInstance();
1515
}
16-
16+
1717
/// <summary>
1818
/// 更新
1919
/// </summary>
@@ -51,7 +51,7 @@ public long GetCount()
5151
}
5252

5353
public enum Types
54-
{
54+
{
5555
组织机构,
5656
用户登录,
5757
角色应用,
@@ -61,7 +61,7 @@ public enum Types
6161
其它分类
6262
}
6363

64-
64+
6565
/// <summary>
6666
/// 新增
6767
/// </summary>
@@ -78,11 +78,12 @@ public static void Add(Data.Model.Log model)
7878
dgWriteLog wl = new dgWriteLog(add);
7979
wl.BeginInvoke(model, null, null);
8080
}
81+
8182
/// <summary>
8283
/// 记录日志
8384
/// </summary>
8485
/// <param name="err"></param>
85-
public static void Add(string title, string contents, Types type = Types.其它分类, Data.Model.Users user = null)
86+
public static void Add(string title, string contents, Types type = Types.其它分类, string oldXML = "", string newXML = "", Data.Model.Users user = null)
8687
{
8788
if (user == null)
8889
{
@@ -94,6 +95,8 @@ public static void Add(string title, string contents, Types type = Types.其它
9495
log.IPAddress = Utility.Tools.GetIPAddress();
9596
log.Others = string.Format("操作系统:{0} 浏览器:{1}", Utility.Tools.GetOSName(), Utility.Tools.GetBrowse());
9697
log.Title = title;
98+
log.OldXml = oldXML.IsNullOrEmpty() ? null : oldXML;
99+
log.NewXml = newXML.IsNullOrEmpty() ? null : newXML;
97100
log.Type = type.ToString();
98101
log.URL = System.Web.HttpContext.Current.Request.Url.ToString();
99102
if (user != null)
@@ -114,7 +117,7 @@ public static void Add(Exception err)
114117
/// 得到类别下接选择
115118
/// </summary>
116119
/// <returns></returns>
117-
public string GetTypeOptions(string value="")
120+
public string GetTypeOptions(string value = "")
118121
{
119122
StringBuilder options = new StringBuilder();
120123
var array = Enum.GetValues(typeof(Types));

src/RoadFlow/Business.Platform/Organize.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,8 @@ public string GetName(string id)
394394
return GetName(id.ToGuid());
395395
}
396396
else if (id.StartsWith(Users.PREFIX))//用户
397-
{
398-
string uid=Users.RemovePrefix(id);
397+
{
398+
string uid = Users.RemovePrefix(id);
399399
Guid userID;
400400
if(!uid.IsGuid(out userID))
401401
{
@@ -474,23 +474,20 @@ public int DeleteAndAllChilds(Guid orgID)
474474
{
475475
bur.Delete(ur.UserID, ur.OrganizeID);
476476
user.Delete(ur.UserID);
477-
userInfo.Delete(ur.UserID);
478-
i++;
477+
i += userInfo.Delete(ur.UserID);
478+
479479
}
480-
Delete(child.ID);
481-
i++;
480+
i += Delete(child.ID);
482481
}
483482
//删除人员及关系
484483
var urs1 = bur.GetAllByOrganizeID(orgID);
485484
foreach (var ur in urs1)
486485
{
487486
bur.Delete(ur.UserID, ur.OrganizeID);
488487
user.Delete(ur.UserID);
489-
userInfo.Delete(ur.UserID);
490-
i++;
488+
i += userInfo.Delete(ur.UserID);
491489
}
492-
Delete(orgID);
493-
i++;
490+
i += Delete(orgID);
494491
scope.Complete();
495492
}
496493
return i;

src/RoadFlow/Business.Platform/RoleApp.cs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,16 @@ public System.Data.DataTable GetAllDataTable()
7979
return dataRoleApp.GetAllDataTable();
8080
}
8181

82+
/// <summary>
83+
/// 查询单条记录
84+
/// </summary>
85+
public System.Data.DataRow GetFromCache(string id)
86+
{
87+
var dt = GetAllDataTableFromCache();
88+
var rows = dt.Select("ID='" + id.ToString() + "'");
89+
return rows.Length > 0 ? rows[0] : null;
90+
}
91+
8292
/// <summary>
8393
/// 查询所有记录(缓存)
8494
/// </summary>
@@ -213,7 +223,7 @@ public DataTable CloneDataTable(DataTable dt)
213223
/// </summary>
214224
/// <param name="roleID"></param>
215225
/// <returns></returns>
216-
public string GetRoleAppJsonString(Guid roleID, Guid userID)
226+
public string GetRoleAppJsonString(Guid roleID, Guid userID, string rootDir="")
217227
{
218228
Business.Platform.RoleApp RoleApp = new Business.Platform.RoleApp();
219229
Business.Platform.UsersApp UsersApp = new Platform.UsersApp();
@@ -237,7 +247,7 @@ public string GetRoleAppJsonString(Guid roleID, Guid userID)
237247
json.Append("{");
238248
json.AppendFormat("\"id\":\"{0}\",", rootDr["ID"]);
239249
json.AppendFormat("\"title\":\"{0}\",", rootDr["Title"].ToString().Trim());
240-
json.AppendFormat("\"ico\":\"{0}\",", rootDr["Ico"]);
250+
json.AppendFormat("\"ico\":\"{0}\",", rootDr["Ico"].ToString().IsNullOrEmpty() ? "" : rootDir + rootDr["Ico"]);
241251
json.AppendFormat("\"link\":\"{0}\",", getAddress(rootDr));
242252
json.AppendFormat("\"model\":\"{0}\",", rootDr["OpenMode"]);
243253
json.AppendFormat("\"width\":\"{0}\",", rootDr["Width"]);
@@ -252,7 +262,7 @@ public string GetRoleAppJsonString(Guid roleID, Guid userID)
252262
json.Append("{");
253263
json.AppendFormat("\"id\":\"{0}\",", dr["ID"]);
254264
json.AppendFormat("\"title\":\"{0}\",", dr["Title"]);
255-
json.AppendFormat("\"ico\":\"{0}\",", dr["Ico"]);
265+
json.AppendFormat("\"ico\":\"{0}\",", dr["Ico"].ToString().IsNullOrEmpty() ? "" : rootDir + dr["Ico"]);
256266
json.AppendFormat("\"link\":\"{0}\",", getAddress(dr));
257267
json.AppendFormat("\"model\":\"{0}\",", dr["OpenMode"]);
258268
json.AppendFormat("\"width\":\"{0}\",", dr["Width"]);
@@ -268,7 +278,7 @@ public string GetRoleAppJsonString(Guid roleID, Guid userID)
268278
json.Append("{");
269279
json.AppendFormat("\"id\":\"{0}\",", dr1["ID"]);
270280
json.AppendFormat("\"title\":\"{0}\",", dr1["Title"]);
271-
json.AppendFormat("\"ico\":\"{0}\",", dr1["Ico"]);
281+
json.AppendFormat("\"ico\":\"{0}\",", dr1["Ico"].ToString().IsNullOrEmpty() ? "" : rootDir + dr1["Ico"]);
272282
json.AppendFormat("\"link\":\"{0}\",", getAddress(dr1));
273283
json.AppendFormat("\"model\":\"{0}\",", dr1["OpenMode"]);
274284
json.AppendFormat("\"width\":\"{0}\",", dr1["Width"]);
@@ -300,7 +310,7 @@ public string GetRoleAppJsonString(Guid roleID, Guid userID)
300310
/// 得到角色应用刷新JSON
301311
/// </summary>
302312
/// <returns></returns>
303-
public string GetRoleAppRefreshJsonString(Guid roleID, Guid userID, Guid refreshID)
313+
public string GetRoleAppRefreshJsonString(Guid roleID, Guid userID, Guid refreshID, string rootDir = "")
304314
{
305315
Business.Platform.RoleApp roleApp = new Business.Platform.RoleApp();
306316
Business.Platform.UsersApp UsersApp = new Platform.UsersApp();
@@ -323,7 +333,7 @@ public string GetRoleAppRefreshJsonString(Guid roleID, Guid userID, Guid refresh
323333
json.Append("{");
324334
json.AppendFormat("\"id\":\"{0}\",", dr["ID"]);
325335
json.AppendFormat("\"title\":\"{0}\",", dr["Title"].ToString().Trim());
326-
json.AppendFormat("\"ico\":\"{0}\",", dr["Ico"]);
336+
json.AppendFormat("\"ico\":\"{0}\",", dr["Ico"].ToString().IsNullOrEmpty() ? "" : rootDir + dr["Ico"]);
327337
json.AppendFormat("\"link\":\"{0}\",", getAddress(dr));
328338
json.AppendFormat("\"model\":\"{0}\",", dr["OpenMode"]);
329339
json.AppendFormat("\"width\":\"{0}\",", dr["Width"]);

src/RoadFlow/Business.Platform/Users.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,28 @@ public static string CurrentUserName
294294
}
295295
}
296296

297+
/// <summary>
298+
/// 当前用户的所有角色
299+
/// </summary>
300+
public static List<Guid> CurrentUserRoles
301+
{
302+
get
303+
{
304+
Guid userID = CurrentUserID;
305+
if (userID.IsEmptyGuid())
306+
{
307+
return new List<Guid>();
308+
}
309+
List<Guid> list = new List<Guid>();
310+
var userRoles = new UsersRole().GetByUserIDFromCache(userID);
311+
foreach (var userRole in userRoles)
312+
{
313+
list.Add(userRole.RoleID);
314+
}
315+
return list;
316+
}
317+
}
318+
297319
/// <summary>
298320
/// 得到一个不重复的帐号
299321
/// </summary>

src/RoadFlow/Business.Platform/UsersRole.cs

Lines changed: 58 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Text;
4+
using System.Linq;
45

56
namespace Business.Platform
67
{
78
public class UsersRole
89
{
10+
private static string cacheKey = Utility.Keys.CacheKeys.UserRoles.ToString();
911
private Data.Interface.IUsersRole dataUsersRole;
1012
public UsersRole()
1113
{
@@ -16,14 +18,18 @@ public UsersRole()
1618
/// </summary>
1719
public int Add(Data.Model.UsersRole model)
1820
{
19-
return dataUsersRole.Add(model);
21+
int i = dataUsersRole.Add(model);
22+
ClearCache();
23+
return i;
2024
}
2125
/// <summary>
2226
/// 更新
2327
/// </summary>
2428
public int Update(Data.Model.UsersRole model)
2529
{
26-
return dataUsersRole.Update(model);
30+
int i = dataUsersRole.Update(model);
31+
ClearCache();
32+
return i;
2733
}
2834
/// <summary>
2935
/// 查询所有记录
@@ -44,7 +50,9 @@ public Data.Model.UsersRole Get(Guid userid, Guid roleid)
4450
/// </summary>
4551
public int Delete(Guid userid, Guid roleid)
4652
{
47-
return dataUsersRole.Delete(userid, roleid);
53+
int i = dataUsersRole.Delete(userid, roleid);
54+
ClearCache();
55+
return i;
4856
}
4957
/// <summary>
5058
/// 查询记录条数
@@ -59,33 +67,48 @@ public long GetCount()
5967
/// </summary>
6068
public int DeleteByUserID(Guid memberID)
6169
{
62-
return dataUsersRole.DeleteByUserID(memberID);
70+
int i = dataUsersRole.DeleteByUserID(memberID);
71+
ClearCache();
72+
return i;
6373
}
6474

6575
/// <summary>
6676
/// 删除一个角色所有记录
6777
/// </summary>
6878
public int DeleteByRoleID(Guid roleid)
6979
{
70-
return dataUsersRole.DeleteByRoleID(roleid);
80+
int i = dataUsersRole.DeleteByRoleID(roleid);
81+
ClearCache();
82+
return i;
7183
}
7284

7385
/// <summary>
74-
/// 根据一组机构ID查询记录
86+
/// 根据一组用户ID查询记录
7587
/// </summary>
7688
public List<Data.Model.UsersRole> GetByUserIDArray(Guid[] memberIDArray)
7789
{
7890
return dataUsersRole.GetByUserIDArray(memberIDArray);
7991
}
8092

8193
/// <summary>
82-
/// 根据机构ID查询记录
94+
/// 根据用户ID查询记录
8395
/// </summary>
8496
public List<Data.Model.UsersRole> GetByUserID(Guid memberID)
8597
{
8698
return dataUsersRole.GetByUserID(memberID);
8799
}
88100

101+
/// <summary>
102+
/// 得到一个用户的所有角色
103+
/// </summary>
104+
/// <param name="userID"></param>
105+
/// <returns></returns>
106+
public List<Data.Model.UsersRole> GetByUserIDFromCache(Guid userID)
107+
{
108+
var list = GetAllFromCache();
109+
return list.FindAll(p => p.MemberID == userID);
110+
}
111+
89112
/// <summary>
90113
/// 更新一个人员的所属角色
91114
/// </summary>
@@ -114,7 +137,34 @@ public void UpdateByUserID(Guid userID)
114137
});
115138
}
116139
}
117-
140+
ClearCache();
141+
}
142+
143+
/// <summary>
144+
/// 从缓存得到所有记录
145+
/// </summary>
146+
/// <returns></returns>
147+
public List<Data.Model.UsersRole> GetAllFromCache()
148+
{
149+
var obj = MyCache.IO.Opation.Get(cacheKey);
150+
if (obj == null || !(obj is List<Data.Model.UsersRole>))
151+
{
152+
var list = GetAll();
153+
MyCache.IO.Opation.Set(cacheKey, list);
154+
return list;
155+
}
156+
else
157+
{
158+
return obj as List<Data.Model.UsersRole>;
159+
}
160+
}
161+
162+
/// <summary>
163+
/// 清除缓存记录
164+
/// </summary>
165+
public void ClearCache()
166+
{
167+
MyCache.IO.Opation.Remove(cacheKey);
118168
}
119169
}
120170
}

0 commit comments

Comments
 (0)