171. Araxis Merge File Comparison Report

Produced by Araxis Merge on 2/1/2017 2:56:22 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.

171.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\Activities WorkingWithActivityParties.cs Tue Dec 20 19:51:44 2016 UTC
2 Wed Feb 1 19:56:22 2017 UTC

171.2 Comparison summary

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

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

171.4 Active regular expressions

No regular expressions were active.

171.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 WorkingWit hActivityP arties>        
17   using Syst em;        
18   using Syst em.Collect ions.Gener ic;        
19   using Syst em.Linq;        
20   using Syst em.Service Model;        
21          
22   // These n amespaces  are found  in the Mic rosoft.Xrm .Sdk.dll a ssembly        
23   // located  in the SD K\bin fold er of the  SDK downlo ad.        
24   using Micr osoft.Xrm. Sdk;        
25   using Micr osoft.Xrm. Sdk.Client ;        
26          
27   namespace  Microsoft. Crm.Sdk.Sa mples        
28   {        
29       /// <s ummary>        
30       /// De monstrates  how to pr ogrammatic ally work  with Activ ity Party  records.</ summary>        
31       /// <r emarks>        
32       /// At  run-time,  you will  be given t he option  to delete  all the        
33       /// da tabase rec ords creat ed by this  program.< /remarks>        
34       public  class Wor kingWithAc tivityPart ies        
35       {        
36           #r egion Clas s Level Me mbers        
37          
38           pr ivate Guid [] _contac tIds = new  Guid[3];        
39           pr ivate Dict ionary<Gui d, String>  _recordId s = new Di ctionary<G uid, Strin g>();        
40           pr ivate Orga nizationSe rviceProxy  _serviceP roxy;        
41          
42           #e ndregion C lass Level  Members        
43          
44           #r egion How  To Sample  Code        
45           // / <summary >        
46           // / This met hod first  connects t o the Orga nization s ervice. Af terwards,        
47           // / activity  party rec ords are c reated and  associate d with an  activity.        
48           // / </summar y>        
49           // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param>        
50           // / <param n ame="promp tforDelete ">When Tru e, the use r will be  prompted t o delete        
51           // / all crea ted entiti es.</param >        
52           pu blic void  Run(Server Connection .Configura tion serve rConfig, b ool prompt forDelete)        
53           {        
54                try        
55                {        
56                    //<s nippetWork ingWithAct ivityParti es1>        
57                    // C onnect to  the Organi zation ser vice.         
58                    // T he using s tatement a ssures tha t the serv ice proxy  will be pr operly dis posed.        
59                    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 ))        
60                    {        
61                         // This st atement is  required  to enable  early-boun d type sup port.        
62                         _servicePr oxy.Enable ProxyTypes ();        
63          
64                         CreateRequ iredRecord s();        
65          
66                         Organizati onServiceC ontext org Context =        
67                             new Or ganization ServiceCon text(_serv iceProxy);        
68          
69                         // Retriev e the Cont act record s that we  created pr eviously.        
70                         List<Conta ct> contac ts = (from  c in orgC ontext.Cre ateQuery<C ontact>()        
71                                                     wher e c.Addres s1_City ==  "Sammamis h"        
72                                                     sele ct new Con tact        
73                                                     {        
74                                                          ContactId  = c.Contac tId,        
75                                                          FirstName  = c.FirstN ame,        
76                                                          LastName =  c.LastNam e        
77                                                     }).T oList<Cont act>();        
78                         Console.Wr ite("Conta cts retrie ved, ");        
79          
80                         // Create  an Activit y Party re cord for e ach Contac t.        
81                         var activi tyParty1 =  new Activ ityParty        
82                         {        
83                             PartyI d = new En tityRefere nce(Contac t.EntityLo gicalName,        
84                                 co ntacts[0]. ContactId. Value),        
85                         };        
86          
87                         var activi tyParty2 =  new Activ ityParty        
88                         {        
89                             PartyI d = new En tityRefere nce(Contac t.EntityLo gicalName,        
90                                 co ntacts[1]. ContactId. Value),        
91                         };        
92          
93                         var activi tyParty3 =  new Activ ityParty        
94                         {        
95                             PartyI d = new En tityRefere nce(Contac t.EntityLo gicalName,        
96                                 co ntacts[2]. ContactId. Value),        
97                         };        
98          
99                         Console.Wr ite("Activ ityParty i nstances c reated, ") ;        
100          
101                         // Create  Letter Act ivity and  set From a nd To fiel ds to the        
102                         // respect ive Activi ty Party e ntities.        
103                         var letter  = new Let ter        
104                         {        
105                             Regard ingObjectI d = new En tityRefere nce(Contac t.EntityLo gicalName,        
106                                 co ntacts[2]. ContactId. Value),        
107                             Subjec t = "Sampl e Letter A ctivity",        
108                             Schedu ledEnd = D ateTime.No w + TimeSp an.FromDay s(5),        
109                             Descri ption = @" Greetings,  Mr. Andre shak,        
110          
111   This is a  sample let ter activi ty as part  of the Mi crosoft Dy namics CRM  SDK.        
112          
113   Sincerely,        
114   Mary Kay A ndersen        
115          
116   cc: Denise  Smith",        
117                             From =  new Activ ityParty[]  { activit yParty1 },        
118                             To = n ew Activit yParty[] {  activityP arty3, act ivityParty 2 }        
119                         };        
120                         orgContext .AddObject (letter);        
121                         orgContext .SaveChang es();        
122          
123                         Console.Wr iteLine("a nd Letter  Activity c reated.");        
124          
125                         DeleteRequ iredRecord s(promptfo rDelete);        
126                    }        
127                    //</ snippetWor kingWithAc tivityPart ies1>        
128                }        
129          
130                // Catch  any servi ce fault e xceptions  that Micro soft Dynam ics CRM th rows.        
131                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>)        
132                {        
133                    // Y ou can han dle an exc eption her e or pass  it back to  the calli ng method.        
134                    thro w;        
135                }        
136           }        
137          
138           // / <summary >        
139           // / Creates  any entity  records t hat this s ample requ ires.        
140           // / </summar y>        
141           pu blic void  CreateRequ iredRecord s()        
142           {        
143                // Creat e 3 Contac t records  to use in  the Run()  method.        
144                Contact  contact1 =  new Conta ct()        
145                {        
146                    Firs tName = "M ary Kay",        
147                    Last Name = "An dersen",        
148                    Addr ess1_Line1  = "23 Mar ket St.",        
149                    Addr ess1_City  = "Sammami sh",        
150                    Addr ess1_State OrProvince  = "MT",        
151                    Addr ess1_Posta lCode = "9 9999",        
152                    Tele phone1 = " 12345678",        
153                    EMai lAddress1  = "marykay @contoso.c om"        
154                };        
155                _contact Ids[0] = _ servicePro xy.Create( contact1);        
156          
157                Contact  contact2 =  new Conta ct()        
158                {        
159                    Firs tName = "J oe",        
160                    Last Name = "An dreshak",        
161                    Addr ess1_Line1  = "23 Mar ket St.",        
162                    Addr ess1_City  = "Sammami sh",        
163                    Addr ess1_State OrProvince  = "MT",        
164                    Addr ess1_Posta lCode = "9 9999",        
165                    Tele phone1 = " 12345678",        
166                    EMai lAddress1  = "joe@con toso.com"        
167                };        
168                _contact Ids[1] = _ servicePro xy.Create( contact2);        
169          
170                Contact  contact3 =  new Conta ct()        
171                {        
172                    Firs tName = "D enise",        
173                    Last Name = "Sm ith",        
174                    Addr ess1_Line1  = "23 Mar ket St.",        
175                    Addr ess1_City  = "Sammami sh",        
176                    Addr ess1_State OrProvince  = "MT",        
177                    Addr ess1_Posta lCode = "9 9999",        
178                    Tele phone1 = " 12345678",        
179                    EMai lAddress1  = "denise@ contoso.co m"        
180                };        
181                _contact Ids[2] = _ servicePro xy.Create( contact3);        
182          
183           }        
184          
185           // / <summary >        
186           // / Deletes  any entity  records t hat were c reated for  this samp le.        
187           // / <param n ame="promp t">Indicat es whether  to prompt  the user         
188           // / to delet e the reco rds create d in this  sample.</p aram>        
189           // / </summar y>        
190           pu blic void  DeleteRequ iredRecord s(bool pro mpt)        
191           {        
192                bool toB eDeleted =  true;        
193          
194                if (prom pt)        
195                {        
196                    // A sk the use r if the c reated ent ities shou ld be dele ted.        
197                    Cons ole.Write( "\nDo you  want these  entity re cords dele ted? (y/n)  [y]: ");        
198                    Stri ng answer  = Console. ReadLine() ;        
199                    if ( answer.Sta rtsWith("y ") ||        
200                         answer.Sta rtsWith("Y ") ||        
201                         answer ==  String.Emp ty)        
202                    {        
203                         toBeDelete d = true;        
204                    }        
205                    else        
206                    {        
207                         toBeDelete d = false;        
208                    }        
209                }        
210          
211                if (toBe Deleted)        
212                {        
213                    // D elete all  records cr eated in t his sample .        
214                    fore ach (Guid  contactId  in _contac tIds)        
215                    {        
216                         _servicePr oxy.Delete (Contact.E ntityLogic alName, co ntactId);        
217                    }        
218                    Cons ole.WriteL ine("Entit y record(s ) have bee n deleted. ");        
219                }        
220           }        
221          
222           #e ndregion H ow To Samp le Code        
223          
224           #r egion Main  method        
225          
226           // / <summary >        
227           // / Standard  Main() me thod used  by most SD K samples.        
228           // / </summar y>        
229           // / <param n ame="args" ></param>        
230           st atic publi c void Mai n(string[]  args)        
231           {        
232                try        
233                {        
234                    // O btain the  target org anization' s Web addr ess and cl ient logon          
235                    // c redentials  from the  user.        
236                    Serv erConnecti on serverC onnect = n ew ServerC onnection( );        
237                    Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on();        
238          
239                    Work ingWithAct ivityParti es app = n ew Working WithActivi tyParties( );        
240                    app. Run(config , true);        
241                }        
242                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex )        
243                {        
244                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
245                    Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p);        
246                    Cons ole.WriteL ine("Code:  {0}", ex. Detail.Err orCode);        
247                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Detail. Message);        
248                    Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text);        
249                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
250                         null == ex .Detail.In nerFault ?  "No Inner  Fault" :  "Has Inner  Fault");        
251                }        
252                catch (S ystem.Time outExcepti on ex)        
253                {        
254                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
255                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Message );        
256                    Cons ole.WriteL ine("Stack  Trace: {0 }", ex.Sta ckTrace);        
257                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
258                         null == ex .InnerExce ption.Mess age ? "No  Inner Faul t" : ex.In nerExcepti on.Message );        
259                }        
260                catch (S ystem.Exce ption ex)        
261                {        
262                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
263                    Cons ole.WriteL ine(ex.Mes sage);        
264          
265                    // D isplay the  details o f the inne r exceptio n.        
266                    if ( ex.InnerEx ception !=  null)        
267                    {        
268                         Console.Wr iteLine(ex .InnerExce ption.Mess age);        
269          
270                         FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e = ex.Inn erExceptio n        
271                             as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>;        
272                         if (fe !=  null)        
273                         {        
274                             Consol e.WriteLin e("Timesta mp: {0}",  fe.Detail. Timestamp) ;        
275                             Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code);        
276                             Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage);        
277                             Consol e.WriteLin e("Plugin  Trace: {0} ", fe.Deta il.TraceTe xt);        
278                             Consol e.WriteLin e("Inner F ault: {0}" ,        
279                                 nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault");        
280                         }        
281                    }        
282                }        
283                // Addit ional exce ptions to  catch: Sec urityToken Validation Exception,  ExpiredSe curityToke nException ,        
284                // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion.        
285          
286                finally        
287                {        
288                    Cons ole.WriteL ine("Press  <Enter> t o exit.");        
289                    Cons ole.ReadLi ne();        
290                }        
291           }        
292           #e ndregion M ain method        
293       }        
294   }        
295   //</snippe tWorkingWi thActivity Parties>