Produced by Araxis Merge on 2/1/2017 2:56:29 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\Client\Outlook | UseOutlookSdk.cs | Tue Dec 20 19:51:45 2016 UTC |
| 2 | Wed Feb 1 19:56:29 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 0 | 0 |
| Removed | 1 | 187 |
| 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 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 UseOutlook Sdk> | |||||
| 17 | using Syst em; | |||||
| 18 | using Syst em.Service Model; | |||||
| 19 | ||||||
| 20 | // These n amespaces are found in the Mic rosoft.Xrm .Sdk.dll a ssembly | |||||
| 21 | // located in the SD K\bin fold er of the SDK downlo ad. | |||||
| 22 | using Micr osoft.Xrm. Sdk.Client ; | |||||
| 23 | ||||||
| 24 | // This na mespace is found in Microsoft. Crm.Outloo k.Sdk.dll assembly | |||||
| 25 | // found i n the SDK\ bin folder . | |||||
| 26 | using Micr osoft.Crm. Outlook.Sd k; | |||||
| 27 | ||||||
| 28 | namespace Microsoft. Crm.Sdk.Sa mples | |||||
| 29 | { | |||||
| 30 | /// <s ummary> | |||||
| 31 | /// Sh ows how to use the m ethods of the CrmOut lookServic e located in the | |||||
| 32 | /// Mi crosoft.Cr m.Outlook. Sdk.dll as sembly.</s ummary> | |||||
| 33 | /// <r emarks> | |||||
| 34 | /// NO TE: Before running t his sample , you shou ld start t he Outlook client.</ remarks> | |||||
| 35 | public class Use OutlookSdk | |||||
| 36 | { | |||||
| 37 | #r egion How To Sample Code | |||||
| 38 | // / <summary > | |||||
| 39 | // / This met hod first connects t o the Outl ook servic e. Afterwa rds, | |||||
| 40 | // / client i nformation is retrie ved and th e client s tate is ch anged. | |||||
| 41 | // / </summar y> | |||||
| 42 | // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param> | |||||
| 43 | // / <param n ame="promp tforDelete ">When Tru e, the use r will be prompted t o delete a ll | |||||
| 44 | // / created entities.< /param> | |||||
| 45 | pu blic void Run(Server Connection .Configura tion serve rConfig, b ool prompt forDelete) | |||||
| 46 | { | |||||
| 47 | try | |||||
| 48 | { | |||||
| 49 | //<s nippetUseO utlookSdk1 > | |||||
| 50 | // S et up the CRM Servic e. | |||||
| 51 | CrmO utlookServ ice outloo kService = new CrmOu tlookServi ce(); | |||||
| 52 | ||||||
| 53 | // D etermine i f the Outl ook client is runnin g | |||||
| 54 | if ( outlookSer vice.IsCrm ClientLoad ed) | |||||
| 55 | { | |||||
| 56 | if (outloo kService.I sCrmDeskto pClient) | |||||
| 57 | { | |||||
| 58 | // The desktop c lient cann ot go offl ine | |||||
| 59 | Consol e.WriteLin e("CRM Cli ent Deskto p URL: " + | |||||
| 60 | ou tlookServi ce.ServerU ri.Absolut eUri); | |||||
| 61 | Consol e.WriteLin e("CRM Cli ent state: " + | |||||
| 62 | ou tlookServi ce.State.T oString()) ; | |||||
| 63 | } | |||||
| 64 | else | |||||
| 65 | { | |||||
| 66 | // See if laptop client is offline | |||||
| 67 | if (ou tlookServi ce.IsCrmCl ientOfflin e) | |||||
| 68 | { | |||||
| 69 | Co nsole.Writ eLine("CRM Client Of fline URL: " + | |||||
| 70 | outlookS ervice.Ser verUri.Abs oluteUri); | |||||
| 71 | Co nsole.Writ eLine("CRM Client st ate: " + | |||||
| 72 | outlookS ervice.Sta te.ToStrin g()); | |||||
| 73 | ||||||
| 74 | // Take clie nt online | |||||
| 75 | // NOTE: GoO nline() wi ll automat ically Syn c up with CRM | |||||
| 76 | // database, no need t o call Syn c() manual ly | |||||
| 77 | Co nsole.Writ eLine("Goi ng Online. .."); | |||||
| 78 | ou tlookServi ce.GoOnlin e(); | |||||
| 79 | ||||||
| 80 | Co nsole.Writ eLine("CRM Client st ate: " + | |||||
| 81 | outlookS ervice.Sta te.ToStrin g()); | |||||
| 82 | } | |||||
| 83 | else | |||||
| 84 | { | |||||
| 85 | Co nsole.Writ eLine("CRM Client On line URL: " + | |||||
| 86 | outlookS ervice.Ser verUri.Abs oluteUri); | |||||
| 87 | Co nsole.Writ eLine("CRM Client st ate: " + | |||||
| 88 | outlookS ervice.Sta te.ToStrin g()); | |||||
| 89 | ||||||
| 90 | // Take clie nt offline | |||||
| 91 | // NOTE: GoO ffline tri ggers a sy nchronizat ion of the | |||||
| 92 | // offline d atabase wi th the onl ine server . | |||||
| 93 | // If a sync is not re quired, yo u can use SetOffline (). | |||||
| 94 | Co nsole.Writ eLine("Goi ng Offline ..."); | |||||
| 95 | ou tlookServi ce.GoOffli ne(); | |||||
| 96 | ||||||
| 97 | Co nsole.Writ eLine("CRM Client st ate: " + | |||||
| 98 | outlookS ervice.Sta te.ToStrin g()); | |||||
| 99 | } | |||||
| 100 | } | |||||
| 101 | } | |||||
| 102 | //</ snippetUse OutlookSdk 1> | |||||
| 103 | } | |||||
| 104 | ||||||
| 105 | // Catch any servi ce fault e xceptions that Micro soft Dynam ics CRM th rows. | |||||
| 106 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>) | |||||
| 107 | { | |||||
| 108 | // Y ou can han dle an exc eption her e or pass it back to the calli ng method. | |||||
| 109 | thro w; | |||||
| 110 | } | |||||
| 111 | } | |||||
| 112 | ||||||
| 113 | #e ndregion H ow To Samp le Code | |||||
| 114 | ||||||
| 115 | #r egion Main method | |||||
| 116 | ||||||
| 117 | // / <summary > | |||||
| 118 | // / Standard Main() me thod used by most SD K samples. | |||||
| 119 | // / </summar y> | |||||
| 120 | // / <param n ame="args" ></param> | |||||
| 121 | st atic publi c void Mai n(string[] args) | |||||
| 122 | { | |||||
| 123 | try | |||||
| 124 | { | |||||
| 125 | // O btain the target org anization' s Web addr ess and cl ient logon | |||||
| 126 | // c redentials from the user. | |||||
| 127 | Serv erConnecti on serverC onnect = n ew ServerC onnection( ); | |||||
| 128 | Serv erConnecti on.Configu ration con fig = | |||||
| 129 | serverConn ect.GetSer verConfigu ration(); | |||||
| 130 | ||||||
| 131 | UseO utlookSdk app = new UseOutlook Sdk(); | |||||
| 132 | app. Run(config , true); | |||||
| 133 | } | |||||
| 134 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex ) | |||||
| 135 | { | |||||
| 136 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 137 | Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p); | |||||
| 138 | Cons ole.WriteL ine("Code: {0}", ex. Detail.Err orCode); | |||||
| 139 | Cons ole.WriteL ine("Messa ge: {0}", ex.Detail. Message); | |||||
| 140 | Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text); | |||||
| 141 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 142 | null == ex .Detail.In nerFault ? "No Inner Fault" : "Has Inner Fault"); | |||||
| 143 | } | |||||
| 144 | catch (S ystem.Time outExcepti on ex) | |||||
| 145 | { | |||||
| 146 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 147 | Cons ole.WriteL ine("Messa ge: {0}", ex.Message ); | |||||
| 148 | Cons ole.WriteL ine("Stack Trace: {0 }", ex.Sta ckTrace); | |||||
| 149 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 150 | null == ex .InnerExce ption.Mess age ? "No Inner Faul t" : ex.In nerExcepti on.Message ); | |||||
| 151 | } | |||||
| 152 | catch (S ystem.Exce ption ex) | |||||
| 153 | { | |||||
| 154 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 155 | Cons ole.WriteL ine(ex.Mes sage); | |||||
| 156 | ||||||
| 157 | // D isplay the details o f the inne r exceptio n. | |||||
| 158 | if ( ex.InnerEx ception != null) | |||||
| 159 | { | |||||
| 160 | Console.Wr iteLine(ex .InnerExce ption.Mess age); | |||||
| 161 | ||||||
| 162 | FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e = ex.Inn erExceptio n | |||||
| 163 | as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>; | |||||
| 164 | if (fe != null) | |||||
| 165 | { | |||||
| 166 | Consol e.WriteLin e("Timesta mp: {0}", fe.Detail. Timestamp) ; | |||||
| 167 | Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code); | |||||
| 168 | Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage); | |||||
| 169 | Consol e.WriteLin e("Plugin Trace: {0} ", fe.Deta il.TraceTe xt); | |||||
| 170 | Consol e.WriteLin e("Inner F ault: {0}" , | |||||
| 171 | nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault"); | |||||
| 172 | } | |||||
| 173 | } | |||||
| 174 | } | |||||
| 175 | // Addit ional exce ptions to catch: Sec urityToken Validation Exception, ExpiredSe curityToke nException , | |||||
| 176 | // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion. | |||||
| 177 | ||||||
| 178 | finally | |||||
| 179 | { | |||||
| 180 | Cons ole.WriteL ine("Press <Enter> t o exit."); | |||||
| 181 | Cons ole.ReadLi ne(); | |||||
| 182 | } | |||||
| 183 | } | |||||
| 184 | #e ndregion M ain method | |||||
| 185 | } | |||||
| 186 | } | |||||
| 187 | //</snippe tUseOutloo kSdk> |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.