BLL layer We use WCF to provide services, this layer we only publish only one service, in order to make our code more maintainable, we introduce the abstract factory model.
In this case, we will first create three interfaces:
1) iinfo
Inforesult ADD (info info);
Inforesult Update (info info);
Inforesult Delete (int infoid);
Infolist getinfolist (SearchInfo searchinfo);
Infolist Getinfobyid (int infoid);
2) Iinfotype
The same as above, no longer repeat.
3) Iuserinfo
The same as above, no longer repeat.
Then implement these three interfaces, we also use INFOBLL for example as follows:
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Using Infopub.dal;
Using Infopub.modal;
Namespace Infopub.bllservice
{
public class Infobll:iinfo
{
Private Infodal infodal=new infodal ();
Public Inforesult ADD (Info model)
{
return Infodal.add (model);
}
Public Inforesult Update (Info model)
{
return infodal.update (model);
}
Public Inforesult Delete (int infoid)
{
Return Infodal.delete (infoid);
}
Public infolist getinfolist (SearchInfo searchinfo)
{
Return Infodal.getinfolist (SearchInfo);
}
Public infolist Getinfobyid (int infoid)
{
Return Infodal.getinfobyid (infoid);
}
}
}
Then we create a factory interface:
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Namespace InfoPub.BLLService.Interface
{
public interface Inbllfactory
{
Iinfo Createinfo ();
Iinfotype Createinfotype ();
Iuserinfo Createuserinfo ();
}
}
Then implement the factory class:
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Using InfoPub.BLLService.Interface;
Namespace Infopub.bllservice
{
public class Bllfactory:inbllfactory
{
Public Iinfo Createinfo ()
{
return new INFOBLL ();
}
Public Iinfotype Createinfotype ()
{
return new INFOTYPEBLL ();
}
Public Iuserinfo Createuserinfo ()
{
return new USERINFOBLL ();
}
}
}
To access the factory class we define a factory-provided class:
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Namespace Infopub.bllservice
{
public class Common
{
public static bllfactory bllfactory=new bllfactory ();
}
}
So that we can access our factory class, and in order to provide the factory class method to WCF, we add a Commondata class, which resembles our façade:
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Namespace Infopub.bllservice
{
public class Commondata
{
#region Global Variables
public static Iinfo info = Common.bllFactory.CreateInfo ();
public static Iinfotype InfoType = Common.bllFactory.CreateInfoType ();
public static Iuserinfo UserInfo = Common.bllFactory.CreateUserInfo ();
#endregion
}
}
Then define our WCF contract:
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Runtime.Serialization;
Using System.ServiceModel;
Using System.Text;
Using Infopub.modal;
Namespace Infopub.bllservice
{
[ServiceContract]
public interface Iinfopubservice
{
[OperationContract]
Inforesult Addinfo (info info);
[OperationContract]
Inforesult Updateinfo (info info);
[OperationContract]
Inforesult deleteinfo (int infoid);
[OperationContract]
Infolist getinfolist (SearchInfo searchinfo);
[OperationContract]
Infolist Getinfobyid (int infoid);
[OperationContract]
Inforesult Addinfotype (InfoType infotype);
[OperationContract]
Inforesult Updateinfotype (InfoType infotype);
[OperationContract]
Inforesult deleteinfotype (int infotypeid);
[OperationContract]
Infotypelist getinfotypelist (Searchinfotype searchinfotype);
[OperationContract]
Infotypelist Getinfotypebyid (int infoid);
[OperationContract]
Inforesult Adduserinfo (UserInfo UserInfo);
[OperationContract]
Inforesult Updateuserinfo (UserInfo UserInfo);
[OperationContract]
Inforesult deleteuserinfo (int userinfoid);
[OperationContract]
Infolist getuserinfolist (Searchuserinfo searchuserinfo);
[OperationContract]
Infolist Getuserinfobyid (int userinfoid);
}
}
It is implemented as follows:
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Runtime.Serialization;
Using System.ServiceModel;
Using System.Text;
Using Infopub.modal;
Namespace Infopub.bllservice
{
public class Infopubservice:iinfopubservice
{
Public Inforesult Addinfo (info info)
{
return CommonData.info.Add (info);
}
Public Inforesult Updateinfo (info info)
{
return CommonData.info.Update (info);
}
Public Inforesult deleteinfo (int infoid)
{
Return CommonData.info.Delete (infoid);
}
Public infolist getinfolist (SearchInfo searchinfo)
{
Return CommonData.info.GetInfoList (SearchInfo);
}
Public infolist Getinfobyid (int infoid)
{
Return CommonData.info.GetInfoById (infoid);
}
Public Inforesult Addinfotype (InfoType infotype)
{
Return CommonData.infoType.Add (InfoType);
}
Public Inforesult Updateinfotype (InfoType infotype)
{
Return CommonData.infoType.Update (InfoType);
}
Public Inforesult deleteinfotype (int infotypeid)
{
Return CommonData.infoType.Delete (Infotypeid);
}
Public infotypelist getinfotypelist (Searchinfotype searchinfotype)
{
Return CommonData.infoType.GetInfoTypeList (Searchinfotype);
}
Public infotypelist Getinfotypebyid (int infoid)
{
Return CommonData.infoType.GetInfoTypeById (infoid);
}
Public Inforesult Adduserinfo (UserInfo UserInfo)
{
Return CommonData.userInfo.Add (UserInfo);
}
Public Inforesult Updateuserinfo (UserInfo UserInfo)
{
Return CommonData.userInfo.Update (UserInfo);
}
Public Inforesult deleteuserinfo (int userinfoid)
{
Return CommonData.userInfo.Delete (userinfoid);
}
Public infolist getuserinfolist (Searchuserinfo searchuserinfo)
{
Return CommonData.userInfo.GetUserInfoList (Searchuserinfo);
}
Public infolist Getuserinfobyid (int userinfoid)
{
Return CommonData.userInfo.GetUserInfoById (userinfoid);
}
}
}
Here is our class diagram relationship:
What I need to explain is that this is a class diagram that was generated in reverse with EA and then manually modified.