逻辑分层设计及开发架构设计

数据仓储层 1 using System; 2 using System Collections Generic; 3 using System Li

 

 

 

 数据仓储层

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 namespace ZhiYuan.Repository.Member
 5 {
 6     public  class LoginRepository:ZhiYuan.IRepository.Member.ILoginRepository
 7     {           
 8          public ZhiYuan.DataContract.Member.LoginResponse UserLogin(ZhiYuan.DataContract.Member.LoginRequest login)
 9          {
10              var res = new ZhiYuan.DataContract.Member.LoginResponse
11              {
12                LoginId = login.LoginId
13              };
14              using (MemberData context = new MemberData())
15              {
16                  var user = context.MemberUser.SingleOrDefault(u => u.UserCode == login.UserCode);
17                  if (user != null)
18                  {
19                      i。。。。。。
20                 }
21               }
22              return res;
23          }
24          public IList<ZhiYuan.DataContract.Member.MenuInfo> GetMenuByUser(Guid userId,string langStr)
25          {
26              using (MemberData context = new MemberData())
27              {
28                  var query = from m in context.FGetUserMenuByLanguage(userId,langStr)
29                                   select new ZhiYuan.DataContract.Member.MenuInfo()
30                                   {
31                                         MenuId = m.MenuId ?? System.Guid.Empty,
32                                         ParMenuId = m.ParMenuId,
33                                         Lvl = m.Lvl,
34                                         Title =m.Title,
35                                         AssemblyFile = m.AssemblyFile,
36                                         Icon =m.Icon,
37                                         URL = m.URL,
38                                         ToolBar = m.ToolBar,
39                                         ToolGroup = m.ToolGroup,
40                                         ToolPageGroup = m.ToolPageGroup,
41                                         ToolBarDisplayOrder =m.ToolBarDisplayOrder,
42                                         DisplayOrder = m.DisplayOrder,
43                                         ModuleId =m.ModuleId,
44                                         Attribute =m.Attribute,
45                                         HelpId = m.MenuId,
46                                   };
47                  return query.ToList < ZhiYuan.DataContract.Member.MenuInfo>();
48              }
49          }    
50 }

 业务领域层

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using ZhiYuan.IRepository.Member;
 6 using StructureMap;
 7 
 8 namespace ZhiYuan.Domain.Member
 9 {
10     public class LoginDomain:BaseDomain
11     {
12          private ILoginRepository loginRepository;
13 
14          public LoginDomain() : base()
15         {
16            
17             loginRepository = ObjectFactory.GetInstance<ILoginRepository>();
18         }
19         public ZhiYuan.DataContract.Member.LoginResponse Login(ZhiYuan.DataContract.Member.LoginRequest loginRequest)
20         {
21             var responseModel = loginRepository.UserLogin(loginRequest);           
22             return responseModel;
23         }
24 
25         public IList<ZhiYuan.DataContract.Member.MenuInfo> GetMenuByUser(Guid userId, string langStr)
26         {
27             var result = loginRepository.GetMenuByUser(userId, langStr);
28             return result;
29         }
30        
31     }
32 }

 服务层

 1 using System;
 2 using System.Collections.Generic;
 3 using System.ServiceModel.Activation;
 4 using ZhiYuan.ServiceContract.Member;
 5 using ZhiYuan.Domain.Member;
 6 
 7 namespace ZhiYuan.Services.Member
 8 {
 9     [AspNetCompatibilityRequirements(RequirementsMode =
10            AspNetCompatibilityRequirementsMode.Allowed)]
11     public class LoginService : ILoginService
12     {
13         private LoginDomain loginDomain;
14         public LoginService()
15         {
16             loginDomain = new LoginDomain();
17         }
18         public ZhiYuan.DataContract.Member.LoginResponse Login(ZhiYuan.DataContract.Member.LoginRequest loginRequest)
19         {
20             var responseModel = loginDomain.Login(loginRequest);           
21             return responseModel;
22         }
23 
24         public IList<ZhiYuan.DataContract.Member.MenuInfo> GetMenuByUser(Guid userId, string langStr)
25         {
26             var result = loginDomain.GetMenuByUser(userId, langStr);
27             return result;
28         }
29        
30     }
31 }

服务代理层

 1 using System;
 2 using System.Collections.Generic;
 3 using ZhiYuan.ServiceContract.Member;
 4 
 5 namespace ZhiYuan.ServiceProxy.Member
 6 {
 7     public class LoginServiceFacade
 8     {
 9         private ILoginService loginService;
10         public LoginServiceFacade()
11         {
12             this.loginService = WCFClient<ILoginService>.CreateService("http://localhost:1785/Member/LoginService.svc");
13         }
14 
15         public ZhiYuan.DataContract.Member.LoginResponse LoginFor(ZhiYuan.DataContract.Member.LoginRequest loginRequest)
16         {
17             var response = new ZhiYuan.DataContract.Member.LoginResponse();
18             try
19             {
20                 response = this.loginService.Login(loginRequest);
21                 response.ObjectCreateDateTime = System.DateTime.Now;   
22             }
23             catch(Exception ex)
24             {
25                 response.LoginStatus = 0;
26                 response.LoginMessage = ex.Message;
27                 response.ObjectCreateDateTime = System.DateTime.Now;            
28             }
29             return response;
30         }
31         public IList<ZhiYuan.DataContract.Member.MenuInfo> GetUserMenu(Guid userId, string langStr)
32         {
33             return this.loginService.GetMenuByUser(userId, langStr);
34         
35         }
36     }
37 }

 

 时序图模版

 

 

 
 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 namespace ZhiYuan.Repository.Member
 5 {
 6     public  class LoginRepository:ZhiYuan.IRepository.Member.ILoginRepository
 7     {           
 8          public ZhiYuan.DataContract.Member.LoginResponse UserLogin(ZhiYuan.DataContract.Member.LoginRequest login)
 9          {
10              var res = new ZhiYuan.DataContract.Member.LoginResponse
11              {
12                LoginId = login.LoginId
13              };
14              using (MemberData context = new MemberData())
15              {
16                  var user = context.MemberUser.SingleOrDefault(u => u.UserCode == login.UserCode);
17                  if (user != null)
18                  {
19                      i。。。。。。
20                 }
21               }
22              return res;
23          }
24          public IList<ZhiYuan.DataContract.Member.MenuInfo> GetMenuByUser(Guid userId,string langStr)
25          {
26              using (MemberData context = new MemberData())
27              {
28                  var query = from m in context.FGetUserMenuByLanguage(userId,langStr)
29                                   select new ZhiYuan.DataContract.Member.MenuInfo()
30                                   {
31                                         MenuId = m.MenuId ?? System.Guid.Empty,
32                                         ParMenuId = m.ParMenuId,
33                                         Lvl = m.Lvl,
34                                         Title =m.Title,
35                                         AssemblyFile = m.AssemblyFile,
36                                         Icon =m.Icon,
37                                         URL = m.URL,
38                                         ToolBar = m.ToolBar,
39                                         ToolGroup = m.ToolGroup,
40                                         ToolPageGroup = m.ToolPageGroup,
41                                         ToolBarDisplayOrder =m.ToolBarDisplayOrder,
42                                         DisplayOrder = m.DisplayOrder,
43                                         ModuleId =m.ModuleId,
44                                         Attribute =m.Attribute,
45                                         HelpId = m.MenuId,
46                                   };
47                  return query.ToList < ZhiYuan.DataContract.Member.MenuInfo>();
48              }
49          }    
50