Produced by Araxis Merge on 2/1/2017 2:56:23 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\BusinessDataModel\BusinessManagement | AssignQueueItemWorker.cs | Tue Dec 20 19:51:44 2016 UTC |
| 2 | Wed Feb 1 19:56:23 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 0 | 0 |
| Removed | 1 | 276 |
| 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 | // | |||||
| 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 | ||||||
| 18 | //<snippet AssignQueu eItemWorke r> | |||||
| 19 | using Syst em; | |||||
| 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 | ||||||
| 28 | ||||||
| 29 | // This na mespace is found in Microsoft. Crm.Sdk.Pr oxy.dll as sembly | |||||
| 30 | // found i n the SDK\ bin folder . | |||||
| 31 | using Micr osoft.Crm. Sdk.Messag es; | |||||
| 32 | using Micr osoft.Xrm. Sdk.Client ; | |||||
| 33 | ||||||
| 34 | namespace Microsoft. Crm.Sdk.Sa mples | |||||
| 35 | { | |||||
| 36 | /// <s ummary> | |||||
| 37 | /// Th is sample shows how to assign queue item work to s ome user. | |||||
| 38 | /// </ summary> | |||||
| 39 | public class Ass ignQueueIt emWorker | |||||
| 40 | { | |||||
| 41 | #r egion Clas s Level Me mbers | |||||
| 42 | ||||||
| 43 | ||||||
| 44 | // / <summary > | |||||
| 45 | // / Stores t he organiz ation serv ice proxy. | |||||
| 46 | // / </summar y> | |||||
| 47 | pr ivate Orga nizationSe rviceProxy _serviceP roxy; | |||||
| 48 | ||||||
| 49 | ||||||
| 50 | // Define th e IDs need ed for thi s sample. | |||||
| 51 | pr ivate Guid _queueIte mId; | |||||
| 52 | pr ivate Guid _letterId ; | |||||
| 53 | pr ivate Guid _queueId; | |||||
| 54 | pr ivate Guid _userId; | |||||
| 55 | #e ndregion C lass Level Members | |||||
| 56 | ||||||
| 57 | #r egion How To Sample Code | |||||
| 58 | // / <summary > | |||||
| 59 | // / This met hod first connects t o the Orga nization s ervice. | |||||
| 60 | // / Initiate method to create an y entity r ecords tha t this sam ple requir es. | |||||
| 61 | // / Retrieve s new owne r's detail s. | |||||
| 62 | // / Update t he queue i tem record to assign it to new owner. | |||||
| 63 | // / Optional ly delete any entity records t hat were c reated for this samp le. | |||||
| 64 | // / <para na me="organi zationFrie ndlyName"> The friend ly name of the | |||||
| 65 | // / target o rganizatio n.</para> | |||||
| 66 | // / <para na me="discov eryServer" >The name of the dis covery ser ver.</para > | |||||
| 67 | // / <param n ame="promp tForDelete ">Indicate s whether to prompt the user t o | |||||
| 68 | // / delete t he records created i n this sam ple.</para m> | |||||
| 69 | // / </summar y> | |||||
| 70 | pu blic void Run(Server Connection .Configura tion serve rConfig, b ool prompt ForDelete) | |||||
| 71 | { | |||||
| 72 | try | |||||
| 73 | { | |||||
| 74 | // C onnect to the Organi zation ser vice. | |||||
| 75 | // T he using s tatement a ssures tha t the serv ice proxy will be pr operly dis posed. | |||||
| 76 | usin g (_servic eProxy = n ew Organiz ationServi ceProxy(se rverConfig .Organizat ionUri, se rverConfig .HomeRealm Uri, | |||||
| 77 | s erverConfi g.Credenti als, serve rConfig.De viceCreden tials)) | |||||
| 78 | { | |||||
| 79 | // This st atement is required to enable early-boun d type sup port. | |||||
| 80 | _servicePr oxy.Enable ProxyTypes (); | |||||
| 81 | ||||||
| 82 | ||||||
| 83 | // Call th e method t o create a ny data th at this sa mple requi res. | |||||
| 84 | CreateRequ iredRecord s(); | |||||
| 85 | ||||||
| 86 | //<snippet AssignQueu eItemWorke r1> | |||||
| 87 | // Retriev e the curr ent user i nformation . | |||||
| 88 | WhoAmIRequ est whoAmI Request = new WhoAmI Request(); | |||||
| 89 | WhoAmIResp onse whoAm IResponse = (WhoAmIR esponse)_s erviceProx y.Execute( | |||||
| 90 | whoAmI Request); | |||||
| 91 | ||||||
| 92 | ColumnSet columnSet = new Colu mnSet("ful lname"); | |||||
| 93 | SystemUser currentUs er = (Syst emUser)_se rviceProxy .Retrieve( | |||||
| 94 | System User.Entit yLogicalNa me, | |||||
| 95 | whoAmI Response.U serId, col umnSet); | |||||
| 96 | String cur rentUserNa me = curre ntUser.Ful lName; | |||||
| 97 | _userId = currentUse r.Id; | |||||
| 98 | ||||||
| 99 | // Create an instanc e of an ex isting que ueitem in order to s pecify | |||||
| 100 | // the use r that wil l be worki ng on it u sing PickF romQueueRe quest. | |||||
| 101 | ||||||
| 102 | PickFromQu eueRequest pickFromQ ueueReques t = new Pi ckFromQueu eRequest | |||||
| 103 | { | |||||
| 104 | QueueI temId = _q ueueItemId , | |||||
| 105 | Worker Id = _user Id | |||||
| 106 | }; | |||||
| 107 | ||||||
| 108 | _servicePr oxy.Execut e(pickFrom QueueReque st); | |||||
| 109 | //</snippe tAssignQue ueItemWork er1> | |||||
| 110 | ||||||
| 111 | Console.Wr iteLine("T he letter queue item is queued for new o wner {0}." , | |||||
| 112 | curren tUserName) ; | |||||
| 113 | ||||||
| 114 | DeleteRequ iredRecord s(promptFo rDelete); | |||||
| 115 | } | |||||
| 116 | } | |||||
| 117 | // Catch any servi ce fault e xceptions that Micro soft Dynam ics CRM th rows. | |||||
| 118 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>) | |||||
| 119 | { | |||||
| 120 | // Y ou can han dle an exc eption her e or pass it back to the calli ng method. | |||||
| 121 | thro w; | |||||
| 122 | } | |||||
| 123 | } | |||||
| 124 | ||||||
| 125 | // / <summary > | |||||
| 126 | // / This met hod create s any enti ty records that this sample re quires. | |||||
| 127 | // / Create a queue rec ord. | |||||
| 128 | // / Create a letter re cord. | |||||
| 129 | // / Create a queue ite m for queu e record. | |||||
| 130 | // / </summar y> | |||||
| 131 | pu blic void CreateRequ iredRecord s() | |||||
| 132 | { | |||||
| 133 | // Creat e a privat e queue in stance and set its p roperty va lues. | |||||
| 134 | Queue ne wQueue = n ew Queue | |||||
| 135 | { | |||||
| 136 | Name = "Exampl e Queue.", | |||||
| 137 | Desc ription = "This is a n example queue.", | |||||
| 138 | Queu eViewType= new Option SetValue(( int)QueueQ ueueViewTy pe.Private ) | |||||
| 139 | }; | |||||
| 140 | ||||||
| 141 | // Creat e a new qu eue and st ore its re turned GUI D in a var iable | |||||
| 142 | // for l ater use. | |||||
| 143 | _queueId = _servic eProxy.Cre ate(newQue ue); | |||||
| 144 | ||||||
| 145 | Console. WriteLine( "Created { 0}.", newQ ueue.Name) ; | |||||
| 146 | ||||||
| 147 | Letter n ewLetter = new Lette r | |||||
| 148 | { | |||||
| 149 | Desc ription = "Example L etter" | |||||
| 150 | }; | |||||
| 151 | ||||||
| 152 | _letterI d = _servi ceProxy.Cr eate(newLe tter); | |||||
| 153 | ||||||
| 154 | Console. WriteLine( "Created { 0}.", newL etter.Desc ription); | |||||
| 155 | ||||||
| 156 | // Creat e a new in stance of a queueite m and init ialize its | |||||
| 157 | // prope rties. | |||||
| 158 | QueueIte m item = n ew QueueIt em | |||||
| 159 | { | |||||
| 160 | Queu eId = new EntityRefe rence(Queu e.EntityLo gicalName, _queueId) , | |||||
| 161 | Obje ctId = new EntityRef erence(Let ter.Entity LogicalNam e, _letter Id) | |||||
| 162 | }; | |||||
| 163 | ||||||
| 164 | // Creat e the queu eitem on t he server, which wil l associat e | |||||
| 165 | // the l etter with the queue . | |||||
| 166 | _queueIt emId = _se rviceProxy .Create(it em); | |||||
| 167 | ||||||
| 168 | Console. WriteLine( "Created t he letter queue item for the q ueue."); | |||||
| 169 | ||||||
| 170 | return; | |||||
| 171 | } | |||||
| 172 | ||||||
| 173 | // / <summary > | |||||
| 174 | // / Deletes any entity records t hat were c reated for this samp le. | |||||
| 175 | // / <param n ame="promp t">Indicat es whether to prompt the user to | |||||
| 176 | // / delete t he records created i n this sam ple.</para m> | |||||
| 177 | // / </summar y> | |||||
| 178 | pu blic void DeleteRequ iredRecord s(bool pro mpt) | |||||
| 179 | { | |||||
| 180 | bool del eteRecords = true; | |||||
| 181 | ||||||
| 182 | if (prom pt) | |||||
| 183 | { | |||||
| 184 | Cons ole.WriteL ine("\nDo you want t hese entit y records deleted? ( y/n)"); | |||||
| 185 | Stri ng answer = Console. ReadLine() ; | |||||
| 186 | ||||||
| 187 | dele teRecords = (answer. StartsWith ("y") || a nswer.Star tsWith("Y" )); | |||||
| 188 | } | |||||
| 189 | ||||||
| 190 | if (dele teRecords) | |||||
| 191 | { | |||||
| 192 | _ser viceProxy. Delete(Que ueItem.Ent ityLogical Name, _que ueItemId); | |||||
| 193 | _ser viceProxy. Delete(Let ter.Entity LogicalNam e, _letter Id); | |||||
| 194 | _ser viceProxy. Delete(Que ue.EntityL ogicalName , _queueId ); | |||||
| 195 | ||||||
| 196 | Cons ole.WriteL ine("Entit y records have been deleted.") ; | |||||
| 197 | } | |||||
| 198 | } | |||||
| 199 | ||||||
| 200 | #e ndregion H ow To Samp le Code | |||||
| 201 | ||||||
| 202 | #r egion Main | |||||
| 203 | // / <summary > | |||||
| 204 | // / Main. Ru ns the sam ple and pr ovides err or output. | |||||
| 205 | // / <param n ame="args" >Array of arguments to Main me thod.</par am> | |||||
| 206 | // / </summar y> | |||||
| 207 | st atic publi c void Mai n(string[] args) | |||||
| 208 | { | |||||
| 209 | try | |||||
| 210 | { | |||||
| 211 | // O btain the target org anization' s Web addr ess and cl ient logon | |||||
| 212 | // c redentials from the user. | |||||
| 213 | Serv erConnecti on serverC onnect = n ew ServerC onnection( ); | |||||
| 214 | Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on(); | |||||
| 215 | ||||||
| 216 | Assi gnQueueIte mWorker ap p = new As signQueueI temWorker( ); | |||||
| 217 | app. Run(config , true); | |||||
| 218 | } | |||||
| 219 | ||||||
| 220 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex ) | |||||
| 221 | { | |||||
| 222 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 223 | Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p); | |||||
| 224 | Cons ole.WriteL ine("Code: {0}", ex. Detail.Err orCode); | |||||
| 225 | Cons ole.WriteL ine("Messa ge: {0}", ex.Detail. Message); | |||||
| 226 | Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text); | |||||
| 227 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 228 | null == ex .Detail.In nerFault ? "No Inner Fault" : "Has Inner Fault"); | |||||
| 229 | } | |||||
| 230 | catch (S ystem.Time outExcepti on ex) | |||||
| 231 | { | |||||
| 232 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 233 | Cons ole.WriteL ine("Messa ge: {0}", ex.Message ); | |||||
| 234 | Cons ole.WriteL ine("Stack Trace: {0 }", ex.Sta ckTrace); | |||||
| 235 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 236 | null == ex .InnerExce ption.Mess age ? "No Inner Faul t" : ex.In nerExcepti on.Message ); | |||||
| 237 | } | |||||
| 238 | catch (S ystem.Exce ption ex) | |||||
| 239 | { | |||||
| 240 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 241 | Cons ole.WriteL ine(ex.Mes sage); | |||||
| 242 | ||||||
| 243 | // D isplay the details o f the inne r exceptio n. | |||||
| 244 | if ( ex.InnerEx ception != null) | |||||
| 245 | { | |||||
| 246 | Console.Wr iteLine(ex .InnerExce ption.Mess age); | |||||
| 247 | ||||||
| 248 | FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e = | |||||
| 249 | ex.Inn erExceptio n | |||||
| 250 | as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>; | |||||
| 251 | if (fe != null) | |||||
| 252 | { | |||||
| 253 | Consol e.WriteLin e("Timesta mp: {0}", fe.Detail. Timestamp) ; | |||||
| 254 | Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code); | |||||
| 255 | Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage); | |||||
| 256 | Consol e.WriteLin e("Plugin Trace: {0} ", fe.Deta il.TraceTe xt); | |||||
| 257 | Consol e.WriteLin e("Inner F ault: {0}" , | |||||
| 258 | nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault"); | |||||
| 259 | } | |||||
| 260 | } | |||||
| 261 | } | |||||
| 262 | // Addit ional exce ptions to catch: Sec urityToken Validation Exception, ExpiredSe curityToke nException , | |||||
| 263 | // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion. | |||||
| 264 | ||||||
| 265 | finally | |||||
| 266 | { | |||||
| 267 | Cons ole.WriteL ine("Press <Enter> t o exit."); | |||||
| 268 | Cons ole.ReadLi ne(); | |||||
| 269 | } | |||||
| 270 | ||||||
| 271 | } | |||||
| 272 | #e ndregion M ain | |||||
| 273 | } | |||||
| 274 | } | |||||
| 275 | //</snippe tAssignQue ueItemWork er> | |||||
| 276 |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.