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

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

228.2 Comparison summary

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

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

228.4 Active regular expressions

No regular expressions were active.

228.5 Comparison detail

1   // ======= ========== ========== ========== ========== ========== ========== ==        
2   //        
3   //  This f ile is par t of the M icrosoft D ynamics CR M SDK code  samples.        
4   //        
5   //  Copyri ght (C) Mi crosoft Co rporation.   All righ ts reserve d.        
6   //        
7   //  This s ource code  is intend ed only as  a supplem ent to Mic rosoft        
8   //  Develo pment Tool s and/or o n-line doc umentation .  See the se other        
9   //  materi als for de tailed inf ormation r egarding M icrosoft c ode sample s.        
10   //        
11   //  THIS C ODE AND IN FORMATION  ARE PROVID ED "AS IS"  WITHOUT W ARRANTY OF  ANY        
12   //  KIND,  EITHER EXP RESSED OR  IMPLIED, I NCLUDING B UT NOT LIM ITED TO TH E        
13   //  IMPLIE D WARRANTI ES OF MERC HANTABILIT Y AND/OR F ITNESS FOR  A        
14   //  PARTIC ULAR PURPO SE.        
15   //        
16   // ======= ========== ========== ========== ========== ========== ========== ==        
17   //<snippet QuickCampa ign>        
18   using Syst em;        
19   using Syst em.Linq;        
20   using Syst em.Service Model;        
21   using Syst em.Service Model.Desc ription;        
22          
23   // These n amespaces  are found  in the Mic rosoft.Xrm .Sdk.dll a ssembly        
24   // found i n the SDK\ bin folder .        
25   using Micr osoft.Xrm. Sdk;        
26   using Micr osoft.Xrm. Sdk.Query;        
27   using Micr osoft.Xrm. Sdk.Client ;        
28   using Micr osoft.Xrm. Sdk.Messag es;        
29          
30   // This na mespace is  found in  Microsoft. Crm.Sdk.Pr oxy.dll as sembly        
31   // found i n the SDK\ bin folder .        
32   using Micr osoft.Crm. Sdk.Messag es;        
33          
34   namespace  Microsoft. Crm.Sdk.Sa mples        
35   {        
36       /// <s ummary>        
37       /// Th is sample  shows how  to distrib ute a quic k campaign  to the ma rketing li st members  or to the  accounts  selected b y a query.        
38       /// </ summary>        
39           pu blic class  QuickCamp aign        
40           {        
41                    #reg ion Class  Level Memb ers        
42                   
43           //  Define th e IDs as w ell as str ings neede d for this  sample.        
44           // private st atic strin g _uniqStr ingForThis Run;        
45           pr ivate Guid [] _accoun tIdArray;        
46           Em ail _templ ateEmailAc tivity;        
47           Le tter _temp lateLetter Activity;        
48           pr ivate Guid  _newListI d;        
49           pr ivate Guid  _currentU ser;        
50           pr ivate Guid  _qcBOId;        
51           pr ivate Orga nizationSe rviceProxy  _serviceP roxy;        
52          
53           #e ndregion C lass Level  Members        
54          
55           #r egion How  To Sample  Code        
56           // / <summary >        
57           // / Create a nd configu re the org anization  service pr oxy.        
58           // / Initiate  the metho d to creat e any data  that this  sample re quires.        
59           // / Delete a  new queue  instance.        
60           // / Optional ly delete  any entity  records t hat were c reated for  this samp le.        
61           // / </summar y>        
62           // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param>        
63           // / <param n ame="promp tforDelete ">When Tru e, the use r will be  prompted t o delete a ll        
64           // / created  entities.< /param>        
65           pu blic void  Run(Server Connection .Configura tion serve rConfig, b ool prompt forDelete)        
66           {        
67                try        
68                {        
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                         // Call th e method t o create a ny data th at this sa mple requi res.        
77                         CreateRequ iredRecord s();        
78          
79                         #region Ru n a QC wit h marketin g list as  input        
80          
81                         //<snippet QuickCampa ign1>         
82          
83                         List newLi st = new L ist()        
84                         {        
85                             ListNa me = "Test List",         
86                             Create dFromCode  = new Opti onSetValue ((int)List CreatedFro mCode.Acco unt)        
87                         };        
88          
89                         _newListId  = _servic eProxy.Cre ate(newLis t);        
90          
91                         for (int j  = 0; j <  5; j++)        
92                         {        
93                             AddMem berListReq uest addMe mberListRe quest = ne w AddMembe rListReque st();        
94                             addMem berListReq uest.Entit yId = _acc ountIdArra y[j];        
95                             addMem berListReq uest.ListI d = _newLi stId;        
96                             AddMem berListRes ponse addM emberListR esponse =         
97                                 _s erviceProx y.Execute( addMemberL istRequest ) as AddMe mberListRe sponse;        
98                         }        
99          
100                         Guid BOId  = CreateAn dRetrieveQ uickCampai gnForMarke tingList(        
101                             _templ ateLetterA ctivity,         
102                             _newLi stId,         
103                             Propag ationOwner shipOption s.ListMemb erOwner,         
104                             true);        
105          
106                         //</snippe tQuickCamp aign1>        
107          
108                         #endregion        
109          
110                         #region Ru n a QC wit h a list o f accounts  as input        
111          
112                         // Constru ct a Query  Expressio n(QE) whic h specifie s which re cords QC s hould incl ude                         
113                         QueryExpre ssion quer y = new Qu eryExpress ion("accou nt");        
114                         query.Colu mnSet = ne w ColumnSe t("account id");        
115                         query.Crit eria = new  FilterExp ression();        
116                         FilterExpr ession fil ter = quer y.Criteria .AddFilter (LogicalOp erator.Or) ;        
117                         for (int j  = 0; j <  5; j++)        
118                         {        
119                             filter .AddCondit ion("accou ntid", Con ditionOper ator.Equal , _account IdArray[j] );        
120                         }        
121                         _qcBOId =  CreateAndR etrieveQui ckCampaign ForQueryEx pression(        
122                             _templ ateEmailAc tivity,         
123                             query,          
124                             Propag ationOwner shipOption s.ListMemb erOwner,        
125                             true);        
126          
127                         #endregion        
128                                
129                         DeleteRequ iredRecord s(promptfo rDelete);        
130                    }        
131                }        
132                // Catch  any servi ce fault e xceptions  that Micro soft Dynam ics CRM th rows.        
133                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>)        
134                {        
135                    // Y ou can han dle an exc eption her e or pass  it back to  the calli ng method.        
136                    thro w;        
137                }        
138           }        
139          
140           // <snippetQu ickCampaig n2>         
141           // / <summary >        
142           // / This met hod create s a Quick  Campaign f or a set o f accounts  selected  by a query        
143           // / </summar y>        
144           // / <param n ame="activ ityEntity" >        
145           // / An objec t that ind icates act ivity type  for the q uick campa ign and         
146           // / contains  values fo r each of  activity t hat will b e created        
147           // / </param>        
148           // / <param n ame="query ">        
149           // / A query  that provi des a list  of accoun ts for whi ch         
150           // / the quic k campaign  is distri buted.        
151           // / </param>        
152           // / <param n ame="owner shipOption ">        
153           // / Specifie s who will  own the a ctivities  created by  the Quick  Campaign        
154           // /     The  Propagatio nOwnership Options en um is used  to specif y value fo r this par ameter        
155           // /     </pa ram>        
156           // / <param n ame="isPro pagate">        
157           // / Specifie s whether  the operat ion is to  be execute d.         
158           // / This inp ut is ofte n 'true' f or Quick C ampaign        
159           // / </param>                 
160           // / <returns ></returns >        
161           pu blic Guid  CreateAndR etrieveQui ckCampaign ForQueryEx pression(E ntity emai lActivityE ntity,         
162                QueryExp ression qu ery, Propa gationOwne rshipOptio ns ownersh ipOption,  bool isPro pagate)        
163           {        
164                        
165                // creat e the bulk operation        
166                Propagat eByExpress ionRequest  request =  new Propa gateByExpr essionRequ est() {        
167                    Acti vity = ema ilActivity Entity,        
168                    Exec uteImmedia tely = fal se, // Def ault value .        
169                    Frie ndlyName =  "Query Ba sed Quick  Campaign",        
170                    Owne rshipOptio ns = owner shipOption ,        
171                    Quer yExpressio n = query,        
172                    Owne r = new En tityRefere nce("syste muser", _c urrentUser ),        
173                    Post WorkflowEv ent = true ,        
174                    Send Email = fa lse,        
175                    Temp lateId = G uid.Empty        
176                };        
177          
178                Propagat eByExpress ionRespons e response  =         
179                    (Pro pagateByEx pressionRe sponse)_se rviceProxy .Execute(r equest);        
180          
181                Guid bul kOpId = re sponse.Bul kOperation Id;        
182                System.C onsole.Wri teLine(        
183                    "Qui ck Campaig n with fol lowing nam e has been  created.  "        
184                    + "P lease veri fy in Web  app manual ly: \n"         
185                    + re quest.Frie ndlyName +  "\nPress  enter to c ontinue... .");        
186                System.C onsole.Rea dLine();        
187                return b ulkOpId;        
188          
189           }        
190           // </snippetQ uickCampai gn2>         
191          
192           // <snippetQu ickCampaig n3>         
193           // / <summary >        
194           // / This met hod create s Quick Ca mpaign for  a given M arketing L ist and re truns the         
195           // / Guid of  the Quich  Campaign w hich is mo delled as  bulk opera tion in CR M        
196           // / </summar y>        
197           // / <param n ame="activ ityEntity" >        
198           // / An objec t that ind icates act ivity type  for the q uick campa ign and         
199           // / contains  values fo r each act ivity that  will be c reated        
200           // / </param>        
201           // / <param n ame="marke tingListId ">        
202           // / The ID o f the mark eting list  to which  quick camp aign is di stributed        
203           // / </param>        
204           // / <param n ame="owner shipOption ">        
205           // / Specifie s who will  own the a ctivities  created by  the Quick  Campaign        
206           // /     The  Propagatio nOwnership Options en um is used  to specif y value fo r this par ameter        
207           // /     </pa ram>        
208           // / <param n ame="isPro pagate">        
209           // / Specifie s whether  the operat ion is to  be execute d.         
210           // / This inp ut is ofte n 'true' f or Quick C ampaign        
211           // / </param>                                       
212           pu blic Guid  CreateAndR etrieveQui ckCampaign ForMarketi ngList(        
213                Entity l etterActiv ityEntity,          
214                Guid mar ketingList Id,         
215                Propagat ionOwnersh ipOptions  ownershipO ption,         
216                bool isP ropagate)        
217           {        
218                //Create  the reque st object  from input  parameter s        
219                CreateAc tivitiesLi stRequest  request =  new Create Activities ListReques t() {        
220                    Acti vity = let terActivit yEntity,        
221                    List Id = marke tingListId ,        
222                    Owne rshipOptio ns = owner shipOption ,        
223                    Prop agate = is Propagate,        
224                    Temp lateId = G uid.Empty,        
225                    Frie ndlyName =  "Quick Ca mpaign for  My List",        
226                    Owne r = new En tityRefere nce("syste muser", _c urrentUser ),        
227                    Post WorkflowEv ent = true        
228                };        
229          
230                //Execut e the requ est        
231                CreateAc tivitiesLi stResponse  response         
232                    (Cre ateActivit iesListRes ponse)_ser viceProxy. Execute(re quest);        
233          
234                //On exe cuting the  request a  BulkOpera tion recor d would be  created i n CRM.         
235                //If isP ropagate i s true, a  correspond ing Async  job is als o created  which runs  and creat es the req uired acti vities         
236                //The re sponse has  BulkOpera tionId. Th is is the  Id of the  bulkoperat ion that m imics Quic kCampaign  in CRM        
237                Guid BOI d = respon se.BulkOpe rationId;        
238                System.C onsole.Wri teLine(        
239                    "Qui ck Campaig n with fol lowing nam e has been  created.         
240                    + "P lease veri fy in Web  app manual ly: \n"         
241                    + re quest.Frie ndlyName         
242                    + "\ nPress ent er to cont inue....") ;        
243                System.C onsole.Rea dLine();        
244          
245                return B OId;        
246          
247           }         
248          //< /snippetQu ickCampaig n3>        
249          
250           // / <summary >        
251           // / This met hod create s any enti ty records  that this  sample re quires.        
252           // / Create a  new queue  instance.        
253           // / </summar y>        
254           pu blic void  CreateRequ iredRecord s()        
255           {        
256                WhoAmIRe quest whoR equest = n ew WhoAmIR equest();        
257                _current User = ((W hoAmIRespo nse)_servi ceProxy.Ex ecute(whoR equest)).U serId;        
258          
259                //Create  an activi ty objects  which wil l act like  a templat e during Q C distrbut ion.         
260                //The ac tivities c reated by  QC will cr eate activ ities with  content t hat this a ctivity ha s        
261                _templat eEmailActi vity = new  Email()        
262                {        
263                    Subj ect = "qcC reatedEmai lActivity"        
264                };        
265          
266                _templat eLetterAct ivity = ne w Letter()        
267                {        
268                    Subj ect = "qcC reatedLett erActivity "        
269                };        
270          
271                // Creat e accounts  on which  we want to  run QC        
272                _account IdArray =  new Guid[5 ];        
273                for (int  i = 0; i  < 5; i++)        
274                {        
275                    Acco unt acct =  new Accou nt() {        
276                         Name = "Ac count For  Quick Camp aign " + i .ToString( )        
277                    };        
278                    _acc ountIdArra y[i] = _se rviceProxy .Create(ac ct);        
279                    Cons ole.WriteL ine("Creat ed {0}.",  acct.Name) ;        
280                }        
281           }        
282          
283           // / <summary >        
284           // / Deletes/ Reverts th e record t hat was cr eated/chan ged for th is sample.        
285           // / <param n ame="promp t">Indicat es whether  to prompt  the user  to delete         
286           // / the reco rds create d in this  sample.</p aram>        
287           // / </summar y>        
288           pu blic void  DeleteRequ iredRecord s(bool pro mpt)        
289           {        
290                bool toB eDeleted =  true;        
291          
292                if (prom pt)        
293                {        
294                    // A sk the use r if the c reated ent ities shou ld be dele ted.        
295                    Cons ole.Write( "\nDo you  want these  entity re cords dele ted? (y/n)  [y]: ");        
296                    Stri ng answer  = Console. ReadLine() ;        
297                    if ( answer.Sta rtsWith("y ") ||        
298                         answer.Sta rtsWith("Y ") ||        
299                         answer ==  String.Emp ty)        
300                    {        
301                         toBeDelete d = true;        
302                    }        
303                    else        
304                    {        
305                         toBeDelete d = false;        
306                    }        
307                }        
308          
309                if (toBe Deleted)        
310                {        
311                    // D elete all  records cr eated in t his sample .        
312                    for  (int i = 0 ; i<_accou ntIdArray. Length; i+ +)         
313                         _servicePr oxy.Delete (Account.E ntityLogic alName, _a ccountIdAr ray[i]);        
314                    _ser viceProxy. Delete(Lis t.EntityLo gicalName,  _newListI d);        
315                    _ser viceProxy. Delete(Bul kOperation .EntityLog icalName,  _qcBOId);        
316                    Cons ole.WriteL ine("Entit y record(s ) have bee n deleted. ");        
317                }        
318           }        
319          
320           #e ndregion H ow To Samp le Code        
321          
322           #r egion Main  method        
323           // / <summary >        
324           // / Main. Ru ns the sam ple and pr ovides err or output.        
325           // / <param n ame="args" >Array of  arguments  to Main me thod.</par am>        
326           // / </summar y>        
327           st atic publi c void Mai n(string[]  args)        
328           {        
329                try        
330                {        
331                    // O btain the  target org anization' s Web addr ess and cl ient logon          
332                    // c redentials  from the  user.        
333                    Serv erConnecti on serverC onnect = n ew ServerC onnection( );        
334                    Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on();        
335          
336                    Quic kCampaign  app = new  QuickCampa ign();        
337                    app. Run(config , true);        
338                }        
339          
340                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex )        
341                {        
342                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
343                    Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p);        
344                    Cons ole.WriteL ine("Code:  {0}", ex. Detail.Err orCode);        
345                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Detail. Message);        
346                    Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text);        
347                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
348                         null == ex .Detail.In nerFault ?  "No Inner  Fault" :  "Has Inner  Fault");        
349                }        
350                catch (S ystem.Time outExcepti on ex)        
351                {        
352                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
353                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Message );        
354                    Cons ole.WriteL ine("Stack  Trace: {0 }", ex.Sta ckTrace);        
355                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
356                         null == ex .InnerExce ption.Mess age ? "No  Inner Faul t" : ex.In nerExcepti on.Message );        
357                }        
358                catch (S ystem.Exce ption ex)        
359                {        
360                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
361                    Cons ole.WriteL ine(ex.Mes sage);        
362          
363                    // D isplay the  details o f the inne r exceptio n.        
364                    if ( ex.InnerEx ception !=  null)        
365                    {        
366                         Console.Wr iteLine(ex .InnerExce ption.Mess age);        
367          
368                         FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e        
369                             = ex.I nnerExcept ion        
370                             as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>;        
371                         if (fe !=  null)        
372                         {        
373                             Consol e.WriteLin e("Timesta mp: {0}",  fe.Detail. Timestamp) ;        
374                             Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code);        
375                             Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage);        
376                             Consol e.WriteLin e("Plugin  Trace: {0} ", fe.Deta il.TraceTe xt);        
377                             Consol e.WriteLin e("Inner F ault: {0}" ,        
378                                 nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault");        
379                         }        
380                    }        
381                }        
382                // Addit onal excep tions to c atch: Secu rityTokenV alidationE xception,  ExpiredSec urityToken Exception,        
383                // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion.        
384          
385                finally        
386                {        
387                    Cons ole.WriteL ine("Press  <Enter> t o exit.");        
388                    Cons ole.ReadLi ne();        
389                }        
390          
391           }        
392           #e ndregion M ain method        
393       }        
394   }        
395   //</snippe tQuickCamp aign>