547. Araxis Merge File Comparison Report

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

547.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\ModernAndMobileApps\ModernSoapApp CurrentEnvironment.cs Tue Dec 20 19:51:47 2016 UTC
2 Wed Feb 1 19:56:50 2017 UTC

547.2 Comparison summary

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

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

547.4 Active regular expressions

No regular expressions were active.

547.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 nline docu mentation.   See thes e 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          
18   //<snippet ModernOdat aApp>        
19   using Micr osoft.Iden tityModel. Clients.Ac tiveDirect ory;        
20   using Syst em;        
21   using Syst em.Threadi ng.Tasks;        
22   using Wind ows.UI.Pop ups;        
23   using Wind ows.Securi ty.Authent ication.We b;        
24   using Syst em.Net;        
25   using Syst em.Threadi ng;        
26   using Syst em.IO;        
27   using Syst em.Text;        
28          
29   namespace  ModernSoap App        
30   {        
31       /// <s ummary>        
32       /// Ma nages auth entication  with the  organizati on web ser vice.        
33       /// </ summary>        
34       public  static cl ass Curren tEnvironme nt        
35       {        
36           #  region Cla ss Level M embers        
37          
38           pr ivate stat ic Authent icationCon text _auth entication Context;        
39          
40           //  TODO Set  these stri ng values  as appropp riate for  your app r egistratio n and orga nization.        
41           //  For more  informatio n, see the  SDK topic  "Walkthro ugh: Regis ter an app  with Acti ve Directo ry".        
42           pr ivate cons t string _ clientID =  "893262be -fbdc-4556 -9325-9f86 3b69495b";        
43           pu blic const  string Cr mServiceUr l = "https ://my-doma in.crm.dyn amics.com/ ";        
44          
45           #  endregion        
46          
47           //  <summary>        
48           // / Perform  any requir ed app ini tializatio n.        
49           // / This is  where auth entication  with Acti ve Directo ry is perf ormed.        
50           pu blic stati c async Ta sk<string>  Initializ e()        
51           {        
52                Uri serv iceUrl = n ew System. Uri(CrmSer viceUrl +  "/XRMServi ces/2011/O rganizatio n.svc/web? SdkClientV ersion=6.1 .0000.0000 ");        
53          
54                // Dyami cs CRM Onl ine OAuth  URL.        
55                string _ oauthUrl =  Discovery Authority( serviceUrl );        
56          
57                // Obtai n the redi rect URL f or the app . This is  only neede d for app  registrati on.        
58                Uri redi rectUri =  WebAuthent icationBro ker.GetCur rentApplic ationCallb ackUri();        
59          
60                // Obtai n an authe ntication  token to a ccess the  web servic e.         
61                _authent icationCon text = new  Authentic ationConte xt(_oauthU rl, false) ;        
62                Authenti cationResu lt result  = await _a uthenticat ionContext .AcquireTo kenAsync(C rmServiceU rl, _clien tID, redir ectUri);        
63          
64                // Verif y that an  access tok en was suc cessfully  acquired.        
65                if (resu lt.Status  != Authent icationSta tus.Succes s)        
66                {        
67                    if ( result.Err or == "aut henticatio n_failed")        
68                    {        
69                         // Try aga in.        
70                         _authentic ationConte xt = new A uthenticat ionContext (_oauthUrl , false);        
71                         result = a wait _auth entication Context.Ac quireToken Async(CrmS erviceUrl,  _clientID , redirect Uri);        
72                    }        
73                    else        
74                    {        
75                         DisplayErr orWhenAcqu ireTokenFa ils(result );        
76                    }        
77                }        
78                return r esult.Acce ssToken;        
79           }        
80          
81           // / <summary >        
82           // / Discover  the authe ntication  authority.        
83           // / </summar y>        
84           // / <param n ame="servi ceUrl">The  URL of th e organiza tion's SOA P endpoint . </param>        
85           // / <returns >The autho rity URL.< /returns>        
86           // / <remarks >The servi ce URL mus t contain  the SdkCli ent proper ty.</remar ks>        
87           // / <example >https://c ontoso.crm .dynamics. com/XRMSer vices/2011 /Organizat ion.svc/we b?SdkClien tVersion=6 .1.0.533;< /example>        
88           pu blic stati c string D iscoveryAu thority(Ur i serviceU rl)        
89           {        
90                // Use A uthenticat ionParamet ers to sen d a reques t to the o rganizatio n's endpoi nt and        
91                // recei ve tenant  informatio n in the 4 01 challen ge.         
92                Microsof t.Identity Model.Clie nts.Active Directory. Authentica tionParame ters param eters = nu ll;        
93                HttpWebR esponse re sponse = n ull;        
94                try        
95                {        
96                    // C reate a we b request  where the  authorizat ion header  contains  the word " Bearer".        
97                    Http WebRequest  httpWebRe quest = (H ttpWebRequ est)WebReq uest.Creat e(serviceU rl);        
98          
99                    // T he respons e is to be  encoded.        
100                    http WebRequest .ContentTy pe = "appl ication/x- www-form-u rlencoded" ;        
101                    resp onse = (Ht tpWebRespo nse)httpWe bRequest.G etResponse ();        
102                }        
103          
104                catch (W ebExceptio n ex)        
105                {        
106                    resp onse = (Ht tpWebRespo nse)ex.Res ponse;        
107          
108                    // A  401 error  should be  returned.  Extract a ny paramet ers from t he respons e.        
109                    // T he respons e should c ontain an  authorizat ion_uri pa rameter.        
110                    para meters = M icrosoft.I dentityMod el.Clients .ActiveDir ectory.Aut henticatio nParameter s.        
111                         CreateFrom ResponseAu thenticate Header((re sponse.Hea ders)["WWW -Authentic ate"]);        
112                }        
113                finally        
114                {        
115                    if ( response ! = null)        
116                         response.D ispose();        
117                }        
118                // Retur n the auth ority URL.        
119                return p arameters. Authority;        
120           }        
121          
122           // / <summary >        
123           // / Returns  a response  from an I nternet re source.         
124           // / </summar y>               
125           pu blic stati c WebRespo nse GetRes ponse(this  WebReques t request)        
126           {        
127                AutoRese tEvent aut oResetEven t = new Au toResetEve nt(false);        
128                IAsyncRe sult async Result = r equest.Beg inGetRespo nse(r => a utoResetEv ent.Set(),  null);        
129          
130                // Wait  until the  call is fi nished        
131                autoRese tEvent.Wai tOne(Defau ltRequestT imeout);        
132                return r equest.End GetRespons e(asyncRes ult);        
133           }        
134          
135           // / <summary >        
136           // / Get the  DefaultReq uestTimeou t from the  server.        
137           // / </summar y>        
138           pu blic stati c TimeSpan  DefaultRe questTimeo ut { get;  set; }        
139          
140           // / <summary >        
141           // / Display  an error m essage to  the user.        
142           // / </summar y>        
143           // / <param n ame="resul t">The aut henticatio n result r eturned fr om Acquire TokenAsync ().</param >        
144           pr ivate stat ic async v oid Displa yErrorWhen AcquireTok enFails(Au thenticati onResult r esult)        
145           {        
146                MessageD ialog dial og;        
147          
148                switch ( result.Err or)        
149                {        
150                    case  "authenti cation_can celed":        
151                         // User ca ncelled, s o no need  to display  a message .        
152                         break;        
153                    case  "temporar ily_unavai lable":        
154                    case  "server_e rror":        
155                         dialog = n ew Message Dialog("Pl ease retry  the opera tion. If t he error c ontinues,  please con tact your  administra tor.",        
156                             "Sorry , an error  has occur red.");        
157                         await dial og.ShowAsy nc();        
158                         break;        
159                    defa ult:        
160                         // An erro r occurred  when acqu iring a to ken so sho w the erro r descript ion in a M essageDial og.        
161                         dialog = n ew Message Dialog(str ing.Format (        
162                             "If th e error co ntinues, p lease cont act your a dministrat or.\n\nErr or: {0}\n\ nError Des cription:\ n\n{1}",        
163                             result .Error, re sult.Error Descriptio n), "Sorry , an error  has occur red.");        
164                         await dial og.ShowAsy nc();        
165                         break;        
166                }        
167           }        
168       }        
169   }        
170   //</snippe tModernOda taApp>