Produced by Araxis Merge on 2/1/2017 2:56:51 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.
| # | 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\Plug-ins | WebClientPlugin.cs | Tue Dec 20 19:51:42 2016 UTC |
| 2 | Wed Feb 1 19:56:51 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 0 | 0 |
| Removed | 1 | 119 |
| 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 |
No regular expressions were active.
| 1 | // ======= ========== ========== ========== ========== ========== ========== == | |||||
| 2 | // This f ile is par t of the M icrosoft C RM SDK Cod e 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 | //<snippet WebClientP lugin> | |||||
| 16 | using Syst em; | |||||
| 17 | using Syst em.Globali zation; | |||||
| 18 | using Syst em.IO; | |||||
| 19 | using Syst em.Text; | |||||
| 20 | using Syst em.Net; | |||||
| 21 | ||||||
| 22 | // Microso ft Dynamic s CRM name space(s) | |||||
| 23 | using Micr osoft.Xrm. Sdk; | |||||
| 24 | ||||||
| 25 | namespace Microsoft. Crm.Sdk.Sa mples | |||||
| 26 | { | |||||
| 27 | /// <s ummary> | |||||
| 28 | /// A sandboxed plug-in th at can acc ess networ k (Web) re sources. | |||||
| 29 | /// </ summary> | |||||
| 30 | /// <r emarks>Reg ister this plug-in i n the sand box. You c an provide an unsecu re string | |||||
| 31 | /// du ring regis tration th at specifi es the Web address ( URI) to ac cess from the plug-i n. | |||||
| 32 | /// </ remarks> | |||||
| 33 | public sealed cl ass WebCli entPlugin : IPlugin | |||||
| 34 | { | |||||
| 35 | pr ivate stri ng webAddr ess; | |||||
| 36 | ||||||
| 37 | // / <summary > | |||||
| 38 | // / The plug -in constr uctor. | |||||
| 39 | // / </summar y> | |||||
| 40 | // / <param n ame="confi g">The Web address t o access. An empty o r null str ing | |||||
| 41 | // / defaults to access ing www.bi ng.com. Th e Web addr ess can us e the HTTP or | |||||
| 42 | // / HTTPS pr otocol.</p aram> | |||||
| 43 | pu blic WebCl ientPlugin (string co nfig) | |||||
| 44 | { | |||||
| 45 | if (Stri ng.IsNullO rEmpty(con fig)) | |||||
| 46 | { | |||||
| 47 | webA ddress = " http://www .bing.com" ; | |||||
| 48 | } | |||||
| 49 | else | |||||
| 50 | { | |||||
| 51 | webA ddress = c onfig; | |||||
| 52 | } | |||||
| 53 | } | |||||
| 54 | ||||||
| 55 | // / <summary > | |||||
| 56 | // / Main exe cute metho d that is required b y the IPlu gin interf ace. Uses the WebCli ent | |||||
| 57 | // / .NET cla ss to acce ss the tar get Web ad dress. | |||||
| 58 | // / </summar y> | |||||
| 59 | // / <param n ame="servi ceProvider ">The serv ice provid er from wh ich you ca n obtain t he | |||||
| 60 | // / tracing service, p lug-in exe cution con text, orga nization s ervice, an d more.</p aram> | |||||
| 61 | pu blic void Execute(IS erviceProv ider servi ceProvider ) | |||||
| 62 | { | |||||
| 63 | //Extrac t the trac ing servic e for use in plug-in debugging . | |||||
| 64 | ITracing Service tr acingServi ce = | |||||
| 65 | (ITr acingServi ce)service Provider.G etService( typeof(ITr acingServi ce)); | |||||
| 66 | ||||||
| 67 | try | |||||
| 68 | { | |||||
| 69 | trac ingService .Trace("Do wnloading the target URI: " + webAddress ); | |||||
| 70 | ||||||
| 71 | try | |||||
| 72 | { | |||||
| 73 | //<snippet WebClientP lugin2> | |||||
| 74 | // Downloa d the targ et URI usi ng a Web c lient. Any .NET clas s that use s the | |||||
| 75 | // HTTP or HTTPS pro tocols and a DNS loo kup should work. | |||||
| 76 | using (Web Client cli ent = new WebClient( )) | |||||
| 77 | { | |||||
| 78 | byte[] responseB ytes = cli ent.Downlo adData(web Address); | |||||
| 79 | string response = Encoding .UTF8.GetS tring(resp onseBytes) ; | |||||
| 80 | //</sn ippetWebCl ientPlugin 2> | |||||
| 81 | tracin gService.T race(respo nse); | |||||
| 82 | ||||||
| 83 | // For demonstra tion purpo ses, throw an except ion so tha t the resp onse | |||||
| 84 | // is shown in t he trace d ialog of t he Microso ft Dynamic s CRM user interface . | |||||
| 85 | throw new Invali dPluginExe cutionExce ption("Web ClientPlug in complet ed success fully."); | |||||
| 86 | } | |||||
| 87 | } | |||||
| 88 | ||||||
| 89 | catc h (WebExce ption exce ption) | |||||
| 90 | { | |||||
| 91 | string str = string. Empty; | |||||
| 92 | if (except ion.Respon se != null ) | |||||
| 93 | { | |||||
| 94 | using (StreamRea der reader = | |||||
| 95 | ne w StreamRe ader(excep tion.Respo nse.GetRes ponseStrea m())) | |||||
| 96 | { | |||||
| 97 | st r = reader .ReadToEnd (); | |||||
| 98 | } | |||||
| 99 | except ion.Respon se.Close() ; | |||||
| 100 | } | |||||
| 101 | if (except ion.Status == WebExc eptionStat us.Timeout ) | |||||
| 102 | { | |||||
| 103 | throw new Invali dPluginExe cutionExce ption( | |||||
| 104 | "T he timeout elapsed w hile attem pting to i ssue the r equest.", exception) ; | |||||
| 105 | } | |||||
| 106 | throw new InvalidPlu ginExecuti onExceptio n(String.F ormat(Cult ureInfo.In variantCul ture, | |||||
| 107 | "A Web exception occurred while atte mpting to issue the request. { 0}: {1}", | |||||
| 108 | except ion.Messag e, str), e xception); | |||||
| 109 | } | |||||
| 110 | } | |||||
| 111 | catch (E xception e ) | |||||
| 112 | { | |||||
| 113 | trac ingService .Trace("Ex ception: { 0}", e.ToS tring()); | |||||
| 114 | thro w; | |||||
| 115 | } | |||||
| 116 | } | |||||
| 117 | } | |||||
| 118 | } | |||||
| 119 | //</snippe tWebClient Plugin> |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.