226. Araxis Merge File Comparison Report

Produced by Araxis Merge on 2/1/2017 2:56:25 PM Eastern Standard Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

226.1 Files compared

# Location File Last Modified
1 C:\Araxis_Merge_Comprasion\Pub_un\BTSSS_CIF_122016.zip\BTSSS_CIF_12_20_16\clean\CRM\trunk\SDK\SampleCode\CS\BusinessDataModel\Marketing MarketingAutomation.cs Tue Dec 20 19:51:43 2016 UTC
2 Wed Feb 1 19:56:25 2017 UTC

226.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 0 0
Changed 0 0
Inserted 0 0
Removed 1 398

226.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

226.4 Active regular expressions

No regular expressions were active.

226.5 Comparison detail

1   // ======= ========== ========== ========== ========== ========== ========== ==        
2   //  This f ile is par t of the M icrosoft D ynamics CR M SDK code  samples.        
3   //        
4   //  Copyri ght (C) Mi crosoft Co rporation.   All righ ts reserve d.        
5   //        
6   //  This s ource code  is intend ed only as  a supplem ent to Mic rosoft        
7   //  Develo pment Tool s and/or o n-line doc umentation .  See the se other        
8   //  materi als for de tailed inf ormation r egarding M icrosoft c ode sample s.        
9   //        
10   //  THIS C ODE AND IN FORMATION  ARE PROVID ED "AS IS"  WITHOUT W ARRANTY OF  ANY        
11   //  KIND,  EITHER EXP RESSED OR  IMPLIED, I NCLUDING B UT NOT LIM ITED TO TH E        
12   //  IMPLIE D WARRANTI ES OF MERC HANTABILIT Y AND/OR F ITNESS FOR  A        
13   //  PARTIC ULAR PURPO SE.        
14   // ======= ========== ========== ========== ========== ========== ========== ==        
15          
16   //<snippet MarketingA utomation>        
17   using Syst em;        
18   using Syst em.Service Model;        
19   using Syst em.Linq;        
20   // This na mespace is  found in  Microsoft. Crm.Sdk.Pr oxy.dll as sembly        
21   // found i n the SDK\ bin folder .        
22   using Micr osoft.Crm. Sdk.Messag es;        
23   // These n amespaces  are found  in the Mic rosoft.Xrm .Sdk.dll a ssembly        
24   // located  in the SD K\bin fold er of the  SDK downlo ad.        
25   using Micr osoft.Xrm. Sdk;        
26   using Micr osoft.Xrm. Sdk.Client ;        
27   using Micr osoft.Xrm. Sdk.Messag es;        
28   using Micr osoft.Xrm. Sdk.Query;        
29          
30   namespace  Microsoft. Crm.Sdk.Sa mples        
31   {        
32       /// <s ummary>        
33       /// De monstrate  how to cre ate a dyna mic list a nd distrib ute campai gn activit ies to         
34       /// th e members  on the lis t.        
35       /// </ summary>        
36       /// <r emarks>        
37       /// At  run-time,  you will  be given t he option  to delete  all the        
38       /// da tabase rec ords creat ed by this  program.< /remarks>        
39       public  class Mar ketingAuto mation        
40       {        
41           #r egion Clas s Level Me mbers        
42          
43           pr ivate Guid  _salesMan agerId;        
44           pr ivate Guid  _accountI d;        
45           pr ivate Guid  _campaign Id;        
46           pr ivate Guid  _campaign ActivityId ;        
47           pr ivate Guid  _dynamicL istId;        
48           pr ivate Guid  _staticLi stId;        
49           pr ivate Orga nizationSe rviceProxy  _serviceP roxy;        
50          
51           #e ndregion C lass Level  Members        
52          
53           #r egion How  To Sample  Code        
54           // / <summary >        
55           // / This met hod first  connects t o the Orga nization s ervice. Af terwards a  dynamic        
56           // / list is  created an d associat ed to the  campaign a nd the cam paign's ac tivity.        
57           // / Then the  dynamic l ist is cop ied to a s tatic list  and assoc iated with  the same        
58           // / campaign  and campa ign activi ty. Finall y the samp le distrib utes the c ampaign        
59           // / to both  the dynami c and stat ic lists.        
60           // / </summar y>        
61           // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param>        
62           // / <param n ame="promp tforDelete ">When Tru e, the use r will be  prompted t o delete a ll        
63           // / created  entities.< /param>        
64           pu blic void  Run(Server Connection .Configura tion serve rConfig, b ool prompt forDelete)        
65           {        
66                try        
67                {        
68                    //<s nippetMark etingAutom ation1>        
69                    // C onnect to  the Organi zation ser vice.         
70                    // T he using s tatement a ssures tha t the serv ice proxy  will be pr operly dis posed.        
71                    usin g (_servic eProxy = n ew Organiz ationServi ceProxy(se rverConfig .Organizat ionUri, se rverConfig .HomeRealm Uri,server Config.Cre dentials,  serverConf ig.DeviceC redentials ))        
72                    {        
73                         // This st atement is  required  to enable  early-boun d type sup port.        
74                         _servicePr oxy.Enable ProxyTypes ();        
75          
76                         CreateRequ iredRecord s();        
77          
78                         #region Cr eate Dynam ic List        
79          
80                         // Create  FetchXml f or marketi ng list's  query whic h locates  accounts        
81                         // in Seat tle.        
82                         String fet chXml = @" <fetch ver sion='1.0'  output-fo rmat='xml- platform'  mapping='l ogical' di stinct='fa lse'>        
83                                               <entity na me='accoun t'>        
84                                               <attribute  name='nam e' />        
85                                               <attribute  name='add ress1_city ' />        
86                                               <attribute  name='pri marycontac tid' />        
87                                               <attribute  name='tel ephone1' / >        
88                                               <attribute  name='acc ountid' />        
89                                               <order att ribute='na me' descen ding='fals e' />        
90                                               <filter ty pe='and'>        
91                                               <condition  attribute ='address1 _city' ope rator='eq'  value='se attle' />        
92                                               </filter>        
93                                               </entity>        
94                                               </fetch>";        
95                         //<snippet AddItemCam paign>        
96                         // Create  dynamic li st. Set th e type to  true to de clare a dy namic        
97                         // list.        
98                         List dynam icList = n ew List()        
99                         {        
100                             Type =  true,        
101                             ListNa me = "Dyna mic List",        
102                             Create dFromCode  = new Opti onSetValue ((int)List CreatedFro mCode.Acco unt),        
103                             Query  = fetchXml        
104                         };        
105                         _dynamicLi stId = _se rviceProxy .Create(dy namicList) ;        
106                         dynamicLis t.Id = _dy namicListI d;        
107          
108                         Console.Wr iteLine("C reated dyn amic list. ");        
109          
110                         #endregion        
111          
112                         #region As sociate dy namic list  to campai gn        
113          
114                         // Create  a campaign .        
115                         Campaign c ampaign =  new Campai gn()        
116                         {        
117                             Name =  "Sample C ampaign"        
118                         };        
119                         _campaignI d = _servi ceProxy.Cr eate(campa ign);        
120                         campaign.I d = _campa ignId;        
121          
122                         // Add the  dynamic l ist to the  campaign.        
123                         AddItemCam paignReque st addList ToCampaign Request =        
124                             new Ad dItemCampa ignRequest ()        
125                             {        
126                                 Ca mpaignId =  _campaign Id,        
127                                 En tityId = _ dynamicLis tId,        
128                                 En tityName =  List.Enti tyLogicalN ame,        
129                             };        
130                         _servicePr oxy.Execut e(addListT oCampaignR equest);        
131          
132                         Console.Wr iteLine("A dded dynam ic list to  the campa ign.");        
133                         //</snippe tAddItemCa mpaign>        
134          
135                         //<snippet AddItemCam paignActiv ity>        
136                         // Create  a campaign  activity  to distrib ute fax to  the list  members.        
137                         CampaignAc tivity cam paignActiv ity = new  CampaignAc tivity()        
138                         {        
139                             Subjec t = "Sampl e Campaign  Activity" ,        
140                             Channe lTypeCode  = new Opti onSetValue ((int)Camp aignActivi tyChannelT ypeCode.Fa x),        
141                             Regard ingObjectI d = campai gn.ToEntit yReference ()        
142                         };        
143                         _campaignA ctivityId  = _service Proxy.Crea te(campaig nActivity) ;        
144          
145                         // Add dyn amic list  to campaig n activity .        
146                         AddItemCam paignActiv ityRequest  addListTo CampaignAc tivityRequ est =         
147                             new Ad dItemCampa ignActivit yRequest()        
148                         {        
149                             Campai gnActivity Id = _camp aignActivi tyId,        
150                             ItemId  = _dynami cListId,        
151                             Entity Name = Lis t.EntityLo gicalName        
152                         };        
153                         _servicePr oxy.Execut e(addListT oCampaignA ctivityReq uest);        
154          
155                         Console.Wr iteLine("A dded dynam ic list to  the campa ign activi ty.");        
156                         //</snippe tAddItemCa mpaignActi vity>        
157          
158                         #endregion        
159          
160                         #region As sociate st atic list  to campaig n        
161                         //<snippet CopyDynami cListToSta tic>        
162          
163                         // Copy th e dynamic  list to a  static lis t.        
164                         CopyDynami cListToSta ticRequest  copyReque st =         
165                             new Co pyDynamicL istToStati cRequest()        
166                             {        
167                                 Li stId = _dy namicListI d        
168                             };        
169                         CopyDynami cListToSta ticRespons e copyResp onse =        
170                             (CopyD ynamicList ToStaticRe sponse)_se rviceProxy .Execute(c opyRequest );        
171                         _staticLis tId = copy Response.S taticListI d;        
172          
173                         Console.Wr iteLine("C opied dyna mic list t o a static  list.");        
174                         //</snippe tCopyDynam icListToSt atic>        
175          
176                         // Add the  static li st to the  campaign.        
177                         AddItemCam paignReque st addStat icListToCa mpaignRequ est =        
178                             new Ad dItemCampa ignRequest ()        
179                             {        
180                                 Ca mpaignId =  _campaign Id,        
181                                 En tityId = _ staticList Id,        
182                                 En tityName =  List.Enti tyLogicalN ame        
183                             };        
184                         _servicePr oxy.Execut e(addStati cListToCam paignReque st);        
185          
186                         Console.Wr iteLine("A dded stati c list to  the campai gn.");        
187          
188                         // Add the  static li st to the  campaign a ctivity.        
189                         AddItemCam paignActiv ityRequest  addStatic ListToCamp aignActivi tyRequest         
190                             new Ad dItemCampa ignActivit yRequest()        
191                         {        
192                             Campai gnActivity Id = _camp aignActivi tyId,        
193                             ItemId  = _static ListId,        
194                             Entity Name = Lis t.EntityLo gicalName        
195                         };        
196                         _servicePr oxy.Execut e(addStati cListToCam paignActiv ityRequest );        
197          
198                         Console.Wr iteLine("A dded stati c list to  the campai gn's activ ity.");        
199          
200                         #endregion        
201          
202                         #region Cr eate fax f or campaig n's activi ty        
203                         // Create  a fax.        
204                         Fax fax =  new Fax()        
205                         {        
206                             Subjec t = "Examp le Fax"        
207                         };        
208          
209                         Console.Wr iteLine("C reated fax  for campa ign's acti vity.");        
210                         #endregion  Create fa x for camp aign's act ivity        
211          
212                         #region Di stribute f ax to the  marketing  list        
213                         //<snippet Distribute CampaignAc tivity>        
214                         // Distrib ute the ca mpaign act ivity to t he marketi ng lists.        
215                         Distribute CampaignAc tivityRequ est distri buteReques t =         
216                             new Di stributeCa mpaignActi vityReques t()         
217                             {         
218                                 Ca mpaignActi vityId = _ campaignAc tivityId,        
219                                 Ac tivity = f ax,        
220                                 Ow ner = new  EntityRefe rence("sys temuser",  _salesMana gerId),        
221                                 Pr opagate =  true,        
222                                 Se ndEmail =  false,        
223                                 Po stWorkflow Event = tr ue        
224                             };        
225                         _servicePr oxy.Execut e(distribu teRequest) ;        
226          
227                         Console.Wr iteLine("D istributed  fax to th e marketin g lists.") ;        
228                         //</snippe tDistribut eCampaignA ctivity>        
229                         #endregion  Distribut e fax to t he marketi ng list        
230          
231                         #region Re trieve col lection of  entities  from marke ting list        
232                         // Retriev e a collec tion of en tities tha t correspo nd         
233                         // to all  of the mem bers in a  marketing  list        
234                         // This ap proach of  retrieving  list memb ers allows  you to dy namically        
235                         // retriev e the memb ers of a l ist progra mmatically  without r equiring         
236                         // knowled ge of the  member ent ity type.        
237                         Organizati onServiceC ontext org Context =         
238                             new Or ganization ServiceCon text(_serv iceProxy);        
239          
240                         var member  = (from m b in orgCo ntext.Crea teQuery<Li st>()        
241                                        where  mb.Id == _ dynamicLis tId        
242                                        select  mb).First OrDefault( );        
243          
244                         string fet chQuery =  member.Que ry;        
245          
246                         RetrieveMu ltipleRequ est member Request =  new Retrie veMultiple Request();        
247                         FetchExpre ssion fetc h = new Fe tchExpress ion(fetchQ uery);        
248                         memberRequ est.Query  = fetch;        
249                         RetrieveMu ltipleResp onse membe rResponse         
250                             (Retri eveMultipl eResponse) _servicePr oxy.Execut e(memberRe quest);        
251          
252                         Console.Wr iteLine("R etrieved c ollection  of entitie s from a m arketing l ist.");        
253                         #endregion  Retrieve  collection  of entiti es from ma rketing li st        
254          
255                         DeleteRequ iredRecord s(promptfo rDelete);        
256                    }        
257                    //</ snippetMar ketingAuto mation1>        
258                }        
259          
260                // Catch  any servi ce fault e xceptions  that Micro soft Dynam ics CRM th rows.        
261                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>)        
262                {        
263                    // Y ou can han dle an exc eption her e or pass  it back to  the calli ng method.        
264                    thro w;        
265                }        
266           }        
267          
268           // / <summary >        
269           // / Creates  any entity  records t hat this s ample requ ires.        
270           // / </summar y>        
271           pu blic void  CreateRequ iredRecord s()        
272           {        
273                // Retri eve a sale s manager.        
274                _salesMa nagerId =        
275                    Syst emUserProv ider.Retri eveMarketi ngManager( _servicePr oxy);        
276          
277                // Creat e an accou nt.        
278                Account  account =  new Accoun t()        
279                {        
280                    Name  = "Fourth  Coffee",        
281                    Addr ess1_City  = "Seattle "        
282                };        
283                _account Id = _serv iceProxy.C reate(acco unt);        
284           }        
285          
286           // / <summary >        
287           // / Deletes  any entity  records t hat were c reated for  this samp le.        
288           // / <param n ame="promp t">Indicat es whether  to prompt  the user         
289           // / to delet e the reco rds create d in this  sample.</p aram>        
290           // / </summar y>        
291           pu blic void  DeleteRequ iredRecord s(bool pro mpt)        
292           {        
293                bool toB eDeleted =  true;        
294          
295                if (prom pt)        
296                {        
297                    // A sk the use r if the c reated ent ities shou ld be dele ted.        
298                    Cons ole.Write( "\nDo you  want these  entity re cords dele ted? (y/n)  [y]: ");        
299                    Stri ng answer  = Console. ReadLine() ;        
300                    if ( answer.Sta rtsWith("y ") ||        
301                         answer.Sta rtsWith("Y ") ||        
302                         answer ==  String.Emp ty)        
303                    {        
304                         toBeDelete d = true;        
305                    }        
306                    else        
307                    {        
308                         toBeDelete d = false;        
309                    }        
310                }        
311          
312                if (toBe Deleted)        
313                {        
314                    // D elete all  records cr eated in t his sample .        
315                    _ser viceProxy. Delete(Lis t.EntityLo gicalName,  _staticLi stId);        
316                    _ser viceProxy. Delete(Lis t.EntityLo gicalName,  _dynamicL istId);        
317                    _ser viceProxy. Delete("ca mpaignacti vity", _ca mpaignActi vityId);        
318                    _ser viceProxy. Delete("ca mpaign", _ campaignId );        
319                    _ser viceProxy. Delete("ac count", _a ccountId);        
320          
321                    Cons ole.WriteL ine("Entit y record(s ) have bee n deleted. ");        
322                }        
323           }        
324          
325           #e ndregion H ow To Samp le Code        
326          
327           #r egion Main  method        
328          
329           // / <summary >        
330           // / Standard  Main() me thod used  by most SD K samples.        
331           // / </summar y>        
332           // / <param n ame="args" ></param>        
333           st atic publi c void Mai n(string[]  args)        
334           {        
335                try        
336                {        
337                    // O btain the  target org anization' s Web addr ess and cl ient logon          
338                    // c redentials  from the  user.        
339                    Serv erConnecti on serverC onnect = n ew ServerC onnection( );        
340                    Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on();        
341          
342                    Mark etingAutom ation app  = new Mark etingAutom ation();        
343                    app. Run(config , true);        
344                }        
345                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex )        
346                {        
347                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
348                    Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p);        
349                    Cons ole.WriteL ine("Code:  {0}", ex. Detail.Err orCode);        
350                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Detail. Message);        
351                    Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text);        
352                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
353                         null == ex .Detail.In nerFault ?  "No Inner  Fault" :  "Has Inner  Fault");        
354                }        
355                catch (S ystem.Time outExcepti on ex)        
356                {        
357                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
358                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Message );        
359                    Cons ole.WriteL ine("Stack  Trace: {0 }", ex.Sta ckTrace);        
360                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
361                         null == ex .InnerExce ption.Mess age ? "No  Inner Faul t" : ex.In nerExcepti on.Message );        
362                }        
363                catch (S ystem.Exce ption ex)        
364                {        
365                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
366                    Cons ole.WriteL ine(ex.Mes sage);        
367          
368                    // D isplay the  details o f the inne r exceptio n.        
369                    if ( ex.InnerEx ception !=  null)        
370                    {        
371                         Console.Wr iteLine(ex .InnerExce ption.Mess age);        
372          
373                         FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e = ex.Inn erExceptio n        
374                             as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>;        
375                         if (fe !=  null)        
376                         {        
377                             Consol e.WriteLin e("Timesta mp: {0}",  fe.Detail. Timestamp) ;        
378                             Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code);        
379                             Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage);        
380                             Consol e.WriteLin e("Plugin  Trace: {0} ", fe.Deta il.TraceTe xt);        
381                             Consol e.WriteLin e("Inner F ault: {0}" ,        
382                                 nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault");        
383                         }        
384                    }        
385                }        
386                // Addit ional exce ptions to  catch: Sec urityToken Validation Exception,  ExpiredSe curityToke nException ,        
387                // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion.        
388          
389                finally        
390                {        
391                    Cons ole.WriteL ine("Press  <Enter> t o exit.");        
392                    Cons ole.ReadLi ne();        
393                }        
394           }        
395           #e ndregion M ain method        
396       }        
397   }        
398   //</snippe tMarketing Automation >