.NET學習生活感想...万事成蹉跎.....贵在坚持及时整理自己做过和学过的东西
XCRM:MarketingCampaignsandCustomersupport(市场营销和客户支持)
MarketingCampaigns(市场营销)
[Test]
publicvoidCampaignRelationships(){
RegisterDC
RegisterDC
RegisterDC
RegisterDC
RegisterDC
Generate();
ICampaigncampaign=ObjectSpace.CreateObject
campaign.Name="Playboybackcover";
ILeadlead=ObjectSpace.CreateObject
IOpportunityopportunity=ObjectSpace.CreateObject
lead.Campaign=campaign;
opportunity.Campaign=campaign;
}
[DomainComponent]
publicinterfaceICampaign{
stringName{get;set;}
publicinterfaceILead{
…
ICampaignCampaign{get;set;}
publicinterfaceIOpportunity{
InsteadofaddingtheCampaignreferencepropertytoboththeILeadandIOpportunitycomponents,IcouldaddtheICampaignResultinterfaceandinherittheILeadandIOpportunityfromit.ButIthink,thisisoverkill.However,ifonemoreclassreferencestheCampaign,andbusinesslogicissuppliedforthisreference,I'llchoosethisapproach.Ilead和Iopportunity组件代替添加活动引用属性,我添加IcampaignResult接口,从它继承Ilead和Iopportunity.但是,我认为这是过度了。然而,如果多个类引用Campaign,业务逻辑支持引用,我将选择这种方法。
Cases(customersupportincidents)(例(客户支持事件))
ACaseisarecordaboutauser'sinquiryorproblem.ItislinkedtoanAccountand/oraContact.IftheContactisset,theAccountisinitializedfromtheContact’sAccount,ifany:一种情况是:一个关于一个用户的调查或问题记录。它链接一个客户,或者一个联系人。如果设置联系人,客户从联系人的客户初始化,如果有的话:
publicvoidCaseRelationships(){
RegisterDC
IContactroman=ObjectSpace.CreateObject
roman.FirstName="Roman";
roman.LastName="Eremin";
IAccountdx=ObjectSpace.CreateObject
dx.Name="DevExpress";
ICasecase1=ObjectSpace.CreateObject
case1.Subject="1";
case1.Contact=roman;
Assert.IsNull(case1.Account);
ICasecase2=ObjectSpace.CreateObject
case2.Subject="2";
case2.Account=dx;
Assert.IsNull(case2.Contact);
roman.Account=dx;
ICasecase3=ObjectSpace.CreateObject
case3.Subject="3";
case3.Contact=roman;
Assert.AreEqual(dx,case3.Account);
publicinterfaceICase{
stringSubject{get;set;}
IAccountAccount{get;set;}
IContactContact{get;set;}
Tomakethistestpassweneedanextracode,inadditiontotheinterface.WeneeddomainlogicfortheICasetoinitializetheICase.AccountpropertybytheICase.Contact'sAccount:要使这个测试通过我们需要一个扩展代码,附件到这个接口。我们需要领域逻辑通过Icase.Contacts的客户为Icase初始化ICase.Account属性:
[DomainLogic(typeof(ICase))]
publicclassCaseLogic{
publicstaticvoidAfterChange_Contact(ICaseself){
if(self.Contact!=null&&self.Account==null){
self.Account=self.Contact.Account;
HereishowweareplanningtoadddomainlogictotheclassesthataregeneratedbytheXpoBuilder.Wearegoingtousenamingconventions.IftheXpoBuilderfindsamethodnamed“AfterChange_XXX”,ittriestocallthismethodinthegeneratedsetterofaXXXproperty.We'llprobablyaddtheattribute-basedbindinginthefuture.这是如何用计划给这个类添加领域逻辑用XpoBuilder生成的类。我们打算使用明明约定。如果XpoBuilder发现命名为“AfterChange_XXX”的方法,它试着在生成的一个XXX属性的Setter内调用方法。我们将来可能添加基于特性的绑定。
ACaseshouldhaveahuman-readableIDthatcanbeusedincommunicationstoquicklyreferencetheCase.ThisIDshouldbegeneratedonlyonce,whenanewobjectisbeeingcreated.Inaddtion,theIDpropertyshouldberead-only,butpersistent.一种情况应当有一个人可读ID,它可用于沟通,快速引用Case.当新建一个对象时,这个ID应当只生成一次,另外,这个ID属性也应当只读,但可以持久化。
[PersistentDc]
stringID{get;}
publicstaticstringInit_ID(ICaseself){
//ToDo:Changeto"selectcount(*)+1fromcase"analog
returnGuid.NewGuid().ToString();
Thisisaverysimplisticimplementation.Iwillreturnwithamorerealisticcode,assoonwehaveaproperinfrastructure.这是一个非常简单的实现。我要回到一个更现实的代码,不久,我们将有一个适当的基础架构。