223. 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.

223.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 DistributeCampaignFromMarketingList.cs Tue Dec 20 19:51:43 2016 UTC
2 Wed Feb 1 19:56:25 2017 UTC

223.2 Comparison summary

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

223.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

223.4 Active regular expressions

No regular expressions were active.

223.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 Distribute CampaignFr omMarketin gList>        
17   using Syst em;        
18   using Syst em.Collect ions.Gener ic;        
19   using Syst em.Service Model;        
20   using Micr osoft.Crm. Sdk.Messag es;        
21   using Micr osoft.Xrm. Sdk;        
22   using Micr osoft.Xrm. Sdk.Client ;        
23   using Micr osoft.Xrm. Sdk.Query;        
24          
25   namespace  Microsoft. Crm.Sdk.Sa mples        
26   {        
27       public  class Dis tributeCam paignFromM arketingLi st        
28       {        
29           #r egion Clas s Level Me mbers        
30          
31           pr ivate Guid  _accountI d;        
32           pr ivate Orga nizationSe rviceProxy  _serviceP roxy;        
33           pr ivate read only List< Guid> _con tactIdList  = new Lis t<Guid>();        
34           pr ivate Guid  _marketin gListId;        
35           pr ivate Guid  _copiedMa rketingLis tId;        
36           pr ivate Guid  _campaign Id;        
37           pr ivate  Gui d _campaig nActivityI d;        
38           pr ivate Guid  _original CampaignId ;        
39          
40           #e ndregion C lass Level  Members        
41          
42           #r egion Nest ed Classes        
43          
44           //  This stat ic class c ontains th e possible  values fo r marketin g list typ es.        
45           pr ivate stat ic class M arketingLi stType        
46           {        
47                internal  static bo ol Static  = false;        
48                internal  static bo ol Dynamic  = true;        
49           }        
50          
51           //  This stat ic class c ontains va lues for o verriding  or removin g when mak ing a qual ify        
52           //  member li st request .  (Overri ding means  replacing  all membe rs of the  list with        
53           //  the speci fied membe rs in the  request.)        
54           pr ivate stat ic class O verrideOrR emove        
55           {        
56                internal  static bo ol Overrid e = true;        
57                internal  static bo ol Remove  = false;        
58           }        
59          
60           #e ndregion N ested Clas ses        
61          
62           #r egion How  To Sample  Code        
63          
64           pu blic void  Run(Server Connection .Configura tion serve rConfig,        
65           bo ol promptf orDelete)        
66           {        
67                using (_ servicePro xy = new O rganizatio nServicePr oxy(server Config.Org anizationU ri, server Config.Hom eRealmUri, serverConf ig.Credent ials, serv erConfig.D eviceCrede ntials))        
68                {        
69                    // T his statem ent is req uired to e nable earl y bound ty pe support .        
70                    _ser viceProxy. EnableProx yTypes();        
71                    Crea teRequired Records();        
72                    Crea teMarketin gList();        
73                    Dist ributeCamp aign();        
74                    Dele teRecords( promptforD elete);        
75                }        
76           }        
77          
78           pr ivate void  Distribut eCampaign( )        
79           {        
80                Console. WriteLine( "=== Creat ing and Di stributing  the Campa ign ===");        
81                // Creat e the camp aign.        
82                var camp aign = new  Campaign        
83                {        
84                    Name  = "Sample  Campaign"        
85                };        
86          
87                _origina lCampaignI d = _servi ceProxy.Cr eate(campa ign);        
88          
89                NotifyEn tityCreate d(Campaign .EntityLog icalName,  _originalC ampaignId) ;        
90          
91                //<snipp etDistribu teCampaign FromMarket ingList1>        
92                // Copy  the campai gn.        
93                var camp aignCopyRe quest = ne w CopyCamp aignReques t        
94                {        
95                    Base Campaign =  _original CampaignId        
96                };        
97          
98                var copy CampaignRe sponse =        
99                    (Cop yCampaignR esponse)_s erviceProx y.Execute( campaignCo pyRequest) ;        
100                _campaig nId = copy CampaignRe sponse.Cam paignCopyI d;        
101          
102                Console. WriteLine( "  Copied  the campai gn to new  campaign w ith GUID \ r\n\t{{{0} }}",        
103                    _cam paignId);        
104                //</snip petDistrib uteCampaig nFromMarke tingList1>        
105          
106                var acti vity = new  CampaignA ctivity        
107                {        
108                    Subj ect = "Sam ple phone  call",        
109                    Chan nelTypeCod e = new Op tionSetVal ue((int)Ca mpaignActi vityChanne lTypeCode. Phone),        
110                    Rega rdingObjec tId = new  EntityRefe rence(        
111                         Campaign.E ntityLogic alName, _c ampaignId)        
112                };        
113          
114                _campaig nActivityI d = _servi ceProxy.Cr eate(activ ity);        
115          
116                NotifyEn tityCreate d(Campaign Activity.E ntityLogic alName, _c ampaignAct ivityId);        
117          
118                // Find  the curren t user to  determine  who the ow ner of the  activity  should be.        
119                var whoA mI = new W hoAmIReque st();        
120                var curr entUser =  (WhoAmIRes ponse)_ser viceProxy. Execute(wh oAmI);        
121          
122                //<snipp etDistribu teCampaign FromMarket ingList2>        
123                // Add t he marketi ng list cr eated earl ier to the  campaign.        
124                var addL istToCampa ignRequest  = new Add ItemCampai gnRequest        
125                {        
126                    Camp aignId = _ campaignId ,        
127                    Enti tyId = _co piedMarket ingListId,        
128                    Enti tyName = L ist.Entity LogicalNam e,        
129                };        
130          
131                _service Proxy.Exec ute(addLis tToCampaig nRequest);        
132          
133                Console. WriteLine( "  Added t he marketi ng list to  the campa ign.");        
134                //</snip petDistrib uteCampaig nFromMarke tingList2>        
135          
136                //<snipp etDistribu teCampaign FromMarket ingList3>        
137                // Add t he marketi ng list cr eated earl ier to the  campaign  activity.        
138                var addL istToActiv ityRequest  = new Add ItemCampai gnActivity Request        
139                {        
140                    Camp aignActivi tyId = _ca mpaignActi vityId,        
141                    Item Id = _copi edMarketin gListId,        
142                    Enti tyName = L ist.Entity LogicalNam e        
143                };        
144          
145                _service Proxy.Exec ute(addLis tToActivit yRequest);        
146          
147                Console. WriteLine( "  Added t he marketi ng list to  the campa ign activi ty.");        
148                //</snip petDistrib uteCampaig nFromMarke tingList3>        
149          
150                // Creat e the phon e call to  use for di stribution .        
151                var phon ecall = ne w PhoneCal l        
152                {        
153                    Subj ect = "Sam ple Phone  Call"        
154                };        
155          
156                //<snipp etDistribu teCampaign FromMarket ingList4>        
157                // Distr ibute and  execute th e campaign  activity.        
158                // PostW orkflowEve nt signals  Microsoft  Dynamics  CRM to act ually crea te the pho ne call ac tivities.        
159                // Propa gate also  signals to  Microsoft  Dynamics  CRM to cre ate the ph one call a ctivities.        
160                // Owner shipOption s indicate s whom the  created a ctivities  should be  assigned        
161                // to.        
162                var dist ributeRequ est = new  Distribute CampaignAc tivityRequ est        
163                {        
164                    Acti vity = pho necall,        
165                    Camp aignActivi tyId = _ca mpaignActi vityId,        
166                    Owne r = new En tityRefere nce(        
167                         SystemUser .EntityLog icalName,  currentUse r.UserId),        
168                    Owne rshipOptio ns = Propa gationOwne rshipOptio ns.Caller,        
169                    Post WorkflowEv ent = true ,        
170                    Prop agate = tr ue,        
171                    Send Email = fa lse,        
172                };        
173          
174                var dist ributeResp onse =         
175                    (Dis tributeCam paignActiv ityRespons e)_service Proxy.Exec ute(distri buteReques t);        
176          
177                Console. WriteLine( "  Distrib uted and e xecuted th e campaign  activity  to the mar keting lis t.");        
178                //</snip petDistrib uteCampaig nFromMarke tingList4>        
179          
180                //<snipp etDistribu teCampaign FromMarket ingList5>        
181                // Retri eve the me mbers that  were dist ributed to .        
182                var retr ieveMember sRequest =  new Retri eveMembers BulkOperat ionRequest        
183                {        
184                    Bulk OperationI d = distri buteRespon se.BulkOpe rationId,        
185                    Bulk OperationS ource = (i nt)BulkOpe rationSour ce.Campaig nActivity,        
186                    Enti tySource =  (int)Enti tySource.C ontact,        
187                    Quer y = new Qu eryExpress ion(Contac t.EntityLo gicalName)        
188                };        
189          
190                var retr ieveMember sResponse  = (Retriev eMembersBu lkOperatio nResponse)        
191                    _ser viceProxy. Execute(re trieveMemb ersRequest );        
192          
193                Console. WriteLine( "  Contact s with the  following  GUIDs wer e distribu ted to:");        
194                //</snip petDistrib uteCampaig nFromMarke tingList5>        
195                foreach  (var membe r in retri eveMembers Response.E ntityColle ction.Enti ties)        
196                {        
197                    Cons ole.WriteL ine("\t{{{ 0}}}", mem ber.Id);        
198                }        
199           }        
200          
201           pr ivate void  CreateMar ketingList ()        
202           {        
203                Console. WriteLine( "=== Creat ing the Ma rketing Li st ===");        
204                // Creat e the mark eting list .  Make it  static be cause memb ers are go ing to be        
205                // added  to the li st.        
206                var list  = new Lis t        
207                {        
208                    Crea tedFromCod e = new Op tionSetVal ue((int)Li stCreatedF romCode.Co ntact),        
209                    List Name = "Sa mple Conta ct Marketi ng List",        
210                    Type  = Marketi ngListType .Static        
211                };        
212                        
213                _marketi ngListId =  _serviceP roxy.Creat e(list);        
214          
215                NotifyEn tityCreate d(List.Ent ityLogical Name, _mar ketingList Id);        
216          
217                //<snipp etDistribu teCampaign FromMarket ingList6>        
218                // Add a  list of c ontacts to  the marke ting list.        
219                var addM emberListR eq = new A ddListMemb ersListReq uest        
220                {        
221                    Memb erIds = ne w[] { _con tactIdList [0], _cont actIdList[ 2] },        
222                    List Id = _mark etingListI d        
223                };        
224          
225                _service Proxy.Exec ute(addMem berListReq );        
226          
227                Console. WriteLine( "  Contact s with GUI Ds \r\n\t{ {{0}}}\r\n \tand {{{1 }}}\r\n  w ere added  to the lis t.",        
228                    _con tactIdList [0], _cont actIdList[ 1]);        
229                //</snip petDistrib uteCampaig nFromMarke tingList6>        
230          
231                //<snipp etDistribu teCampaign FromMarket ingList7>        
232                // Copy  the market ing list.   First cre ate a new  one, and t hen copy o ver the        
233                // membe rs.        
234                list.Lis tName = li st.ListNam e + " Copy ";        
235                _copiedM arketingLi stId = _se rviceProxy .Create(li st);        
236                var copy Request =  new CopyMe mbersListR equest        
237                {        
238                    Sour ceListId =  _marketin gListId,        
239                    Targ etListId =  _copiedMa rketingLis tId        
240                };        
241          
242                _service Proxy.Exec ute(copyRe quest);        
243                //</snip petDistrib uteCampaig nFromMarke tingList7>        
244          
245                //<snipp etDistribu teCampaign FromMarket ingList8>        
246                // Add a  single co ntact to t he copied  marketing  list.        
247                var addM emberReq =  new AddMe mberListRe quest        
248                {        
249                    Enti tyId = _co ntactIdLis t[1],        
250                    List Id = _copi edMarketin gListId        
251                };        
252          
253                _service Proxy.Exec ute(addMem berReq);        
254          
255                Console. WriteLine( "  Contact  with GUID \r\n\t{{{0 }}}\r\n  w as added t o the list .",        
256                    _con tactIdList [1]);        
257                //</snip petDistrib uteCampaig nFromMarke tingList8>        
258          
259                //<snipp etDistribu teCampaign FromMarket ingList9>        
260                // Quali fy the mar keting lis t.        
261                var qual ifyRequest  = new Qua lifyMember ListReques t        
262                {        
263                    Over rideorRemo ve = Overr ideOrRemov e.Override ,        
264                    Memb ersId = ne w[] { _con tactIdList [0], _cont actIdList[ 1] },        
265                    List Id = _copi edMarketin gListId        
266                };        
267          
268                _service Proxy.Exec ute(qualif yRequest);        
269          
270                Console. WriteLine( "  Qualifi ed the cop ied market ing list s o that it  only\r\n     includes  the first  two membe rs.");        
271                //</snip petDistrib uteCampaig nFromMarke tingList9>        
272           }        
273          
274           pr ivate void  NotifyEnt ityCreated (string en tityName,  Guid entit yId)        
275           {        
276                Console. WriteLine( "  {0} cre ated with  GUID {{{1} }}",        
277                    enti tyName, en tityId);        
278           }        
279          
280           pr ivate void  CreateReq uiredRecor ds()        
281           {        
282                // Creat e an accou nt.        
283                var acco unt = new  Account        
284                {        
285                    Name  = "Litwar e, Inc.",        
286                    Addr ess1_State OrProvince  = "Colora do"        
287                };        
288                _account Id = _serv iceProxy.C reate(acco unt);        
289          
290                // Creat e the cont acts.        
291                var cont act = new  Contact        
292                {        
293                    Firs tName = "B en",        
294                    Last Name = "An drews",        
295                    EMai lAddress1  = "sample@ example.co m",        
296                    Addr ess1_City  = "Redmond ",        
297                    Addr ess1_State OrProvince  = "WA",        
298                    Addr ess1_Telep hone1 = "( 206)555-55 55",        
299                    Pare ntCustomer Id = new E ntityRefer ence        
300                    {        
301                         Id = _acco untId,        
302                         LogicalNam e = accoun t.LogicalN ame        
303                    }        
304                };        
305                _contact IdList.Add (_serviceP roxy.Creat e(contact) );        
306          
307                contact  = new Cont act        
308                {        
309                    Firs tName = "C olin",        
310                    Last Name = "Wi lcox",        
311                    EMai lAddress1  = "sample@ example.co m",        
312                    Addr ess1_City  = "Bellevu e",        
313                    Addr ess1_State OrProvince  = "WA",        
314                    Addr ess1_Telep hone1 = "( 425)555-55 55",        
315                    Pare ntCustomer Id = new E ntityRefer ence        
316                    {        
317                         Id = _acco untId,        
318                         LogicalNam e = accoun t.LogicalN ame        
319                    }        
320                };        
321                _contact IdList.Add (_serviceP roxy.Creat e(contact) );        
322          
323                contact  = new Cont act        
324                {        
325                    Firs tName = "L isa",        
326                    Last Name = "An drews",        
327                    EMai lAddress1  = "sample@ example.co m",        
328                    Addr ess1_City  = "Redmond ",        
329                    Addr ess1_State OrProvince  = "WA",        
330                    Addr ess1_Telep hone1 = "( 206)555-55 56",        
331                    Pare ntCustomer Id = new E ntityRefer ence        
332                    {        
333                         Id = _acco untId,        
334                         LogicalNam e = accoun t.LogicalN ame        
335                    }        
336                };        
337                _contact IdList.Add (_serviceP roxy.Creat e(contact) );        
338          
339           }        
340          
341           pr ivate void  RemoveRel ationships ()        
342           {        
343                //<snipp etDistribu teCampaign FromMarket ingList10>        
344                // Remov e the mark eting list  from the  campaign a ctivity.        
345                var remo veFromCamp aignActivi ty = new R emoveItemC ampaignAct ivityReque st        
346                {        
347                    Camp aignActivi tyId = _ca mpaignActi vityId,        
348                    Item Id = _copi edMarketin gListId        
349                };        
350          
351                _service Proxy.Exec ute(remove FromCampai gnActivity );        
352                Console. WriteLine( "  Removed  the marke ting list  from the c ampaign ac tivity.");        
353                //</snip petDistrib uteCampaig nFromMarke tingList10 >        
354          
355                //<snipp etDistribu teCampaign FromMarket ingList11>        
356                // Remov e the mark eting list  from the  campaign.        
357                var remo veFromCamp aign = new  RemoveIte mCampaignR equest        
358                {        
359                    Camp aignId = _ campaignId ,        
360                    Enti tyId = _co piedMarket ingListId        
361                };        
362          
363                _service Proxy.Exec ute(remove FromCampai gn);        
364                Console. WriteLine( "  Removed  the marke ting list  from the c ampaign.") ;        
365                //</snip petDistrib uteCampaig nFromMarke tingList11 >        
366           }        
367          
368           pr ivate void  DeleteRec ords(bool  prompt)        
369           {        
370                var toBe Deleted =  true;        
371                if (prom pt)        
372                {        
373                    // A sk the use r if the c reated ent ities shou ld be dele ted.        
374                    Cons ole.Write( "\nDo you  want these  entity re cords dele ted? (y/n)  [y]: ");        
375                    Stri ng answer  = Console. ReadLine() ;        
376                    if ( answer.Sta rtsWith("y ") ||        
377                         answer.Sta rtsWith("Y ") ||        
378                         answer ==  String.Emp ty)        
379                    {        
380                         toBeDelete d = true;        
381                    }        
382                    else        
383                    {        
384                         toBeDelete d = false;        
385                    }        
386                }        
387          
388                if (toBe Deleted)        
389                {        
390                    Remo veRelation ships();        
391          
392                    // D elete the  marketing  lists.        
393                    _ser viceProxy. Delete(Lis t.EntityLo gicalName,  _marketin gListId);        
394                    _ser viceProxy. Delete(Lis t.EntityLo gicalName,  _copiedMa rketingLis tId);        
395          
396                    // D elete the  contacts.        
397                    fore ach (var c ontactId i n _contact IdList)        
398                    {        
399                         _servicePr oxy.Delete (Contact.E ntityLogic alName, co ntactId);        
400                    }        
401          
402                    // D elete the  account.        
403                    _ser viceProxy. Delete(Acc ount.Entit yLogicalNa me, _accou ntId);        
404          
405                    // J ust delete  the campa ign, no ne ed to dele te the cam paign acti vity.        
406                    _ser viceProxy. Delete(Cam paign.Enti tyLogicalN ame, _camp aignId);        
407                    _ser viceProxy. Delete(Cam paign.Enti tyLogicalN ame, _orig inalCampai gnId);                          
408                }        
409           }        
410          
411           #e ndregion H ow To Samp le Code        
412          
413           #r egion Main  method        
414          
415           // / <summary >        
416           // / Standard  Main() me thod used  by most SD K samples.        
417           // / </summar y>        
418           // / <param n ame="args" ></param>        
419           st atic publi c void Mai n(string[]  args)        
420           {        
421                try        
422                {        
423                    // O btain the  target org anization' s web addr ess and cl ient logon          
424                    // c redentials  from the  user.        
425                    Serv erConnecti on serverC onnect = n ew ServerC onnection( );        
426                    Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on();        
427          
428                    var  app = new  Distribute CampaignFr omMarketin gList();        
429                    app. Run(config , true);        
430                }        
431                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex )        
432                {        
433                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
434                    Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p);        
435                    Cons ole.WriteL ine("Code:  {0}", ex. Detail.Err orCode);        
436                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Detail. Message);        
437                    Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text);        
438                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
439                         null == ex .Detail.In nerFault ?  "No Inner  Fault" :  "Has Inner  Fault");        
440                }        
441                catch (S ystem.Time outExcepti on ex)        
442                {        
443                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
444                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Message );        
445                    Cons ole.WriteL ine("Stack  Trace: {0 }", ex.Sta ckTrace);        
446                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
447                         null == ex .InnerExce ption.Mess age ? "No  Inner Faul t" : ex.In nerExcepti on.Message );        
448                }        
449                catch (S ystem.Exce ption ex)        
450                {        
451                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
452                    Cons ole.WriteL ine(ex.Mes sage);        
453          
454                    // D isplay the  details o f the inne r exceptio n.        
455                    if ( ex.InnerEx ception !=  null)        
456                    {        
457                         Console.Wr iteLine(ex .InnerExce ption.Mess age);        
458          
459                         FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e = ex.Inn erExceptio n        
460                             as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>;        
461                         if (fe !=  null)        
462                         {        
463                             Consol e.WriteLin e("Timesta mp: {0}",  fe.Detail. Timestamp) ;        
464                             Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code);        
465                             Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage);        
466                             Consol e.WriteLin e("Plugin  Trace: {0} ", fe.Deta il.TraceTe xt);        
467                             Consol e.WriteLin e("Inner F ault: {0}" ,        
468                                 nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault");        
469                         }        
470                    }        
471                }        
472                // Addit ional exce ptions to  catch: Sec urityToken Validation Exception,  ExpiredSe curityToke nException ,        
473                // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion.        
474          
475                finally        
476                {        
477                    Cons ole.WriteL ine("Press  <Enter> t o exit.");        
478                    Cons ole.ReadLi ne();        
479                }        
480           }        
481           #e ndregion M ain method        
482       }        
483   }        
484   //</snippe tDistribut eCampaignF romMarketi ngList>