Produced by Araxis Merge on 2/1/2017 2:56:31 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\DataManagement\DataImport | BulkImportHelper.cs | Tue Dec 20 19:51:43 2016 UTC |
| 2 | Wed Feb 1 19:56:30 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 0 | 0 |
| Removed | 1 | 123 |
| 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 BulkImport Helper> | |||||
| 17 | using Syst em; | |||||
| 18 | using Syst em.IO; | |||||
| 19 | using Micr osoft.Xrm. Sdk; | |||||
| 20 | using Micr osoft.Xrm. Sdk.Client ; | |||||
| 21 | using Micr osoft.Xrm. Sdk.Query; | |||||
| 22 | ||||||
| 23 | namespace Microsoft. Crm.Sdk.Sa mples | |||||
| 24 | { | |||||
| 25 | public static cl ass BulkIm portHelper | |||||
| 26 | { | |||||
| 27 | // / <summary > | |||||
| 28 | // / Reads da ta from th e specifie d .csv fil e | |||||
| 29 | // / </summar y> | |||||
| 30 | // / <param n ame="fileP ath"></par am> | |||||
| 31 | // / <returns ></returns > | |||||
| 32 | pu blic stati c string R eadCsvFile (string fi lePath) | |||||
| 33 | { | |||||
| 34 | string d ata = stri ng.Empty; | |||||
| 35 | using (S treamReade r reader = new Strea mReader(fi lePath)) | |||||
| 36 | { | |||||
| 37 | stri ng value = reader.Re adLine(); | |||||
| 38 | whil e (value ! = null) | |||||
| 39 | { | |||||
| 40 | data += va lue; | |||||
| 41 | data += "\ n"; | |||||
| 42 | value = re ader.ReadL ine(); | |||||
| 43 | } | |||||
| 44 | } | |||||
| 45 | return d ata; | |||||
| 46 | } | |||||
| 47 | ||||||
| 48 | // / <summary > | |||||
| 49 | // / Reads da ta from th e specifie d .xml fil e | |||||
| 50 | // / </summar y> | |||||
| 51 | // / <param n ame="fileP ath"></par am> | |||||
| 52 | // / <returns ></returns > | |||||
| 53 | pu blic stati c string R eadXmlFile (string fi lePath) | |||||
| 54 | { | |||||
| 55 | string d ata = stri ng.Empty; | |||||
| 56 | using (S treamReade r reader = new Strea mReader(fi lePath)) | |||||
| 57 | { | |||||
| 58 | data = reader. ReadToEnd( ); | |||||
| 59 | } | |||||
| 60 | return d ata; | |||||
| 61 | } | |||||
| 62 | ||||||
| 63 | // / <summary > | |||||
| 64 | // / Check fo r importlo g records | |||||
| 65 | // / </summar y> | |||||
| 66 | // / <param n ame="servi ce"></para m> | |||||
| 67 | // / <param n ame="impor tFileId">< /param> | |||||
| 68 | pu blic stati c void Rep ortErrors( Organizati onServiceP roxy servi ceProxy, G uid import FileId) | |||||
| 69 | { | |||||
| 70 | QueryByA ttribute i mportLogQu ery = new QueryByAtt ribute(); | |||||
| 71 | importLo gQuery.Ent ityName = ImportLog. EntityLogi calName; | |||||
| 72 | importLo gQuery.Col umnSet = n ew ColumnS et(true); | |||||
| 73 | importLo gQuery.Att ributes.Ad d("importf ileid"); | |||||
| 74 | importLo gQuery.Val ues.Add(ne w object[1 ]); | |||||
| 75 | importLo gQuery.Val ues[0] = i mportFileI d; | |||||
| 76 | ||||||
| 77 | EntityCo llection i mportLogs = serviceP roxy.Retri eveMultipl e(importLo gQuery); | |||||
| 78 | ||||||
| 79 | if (impo rtLogs.Ent ities.Coun t > 0) | |||||
| 80 | { | |||||
| 81 | Cons ole.WriteL ine("Numbe r of Failu res: " + i mportLogs. Entities.C ount.ToStr ing()); | |||||
| 82 | Cons ole.WriteL ine("Seque nce Number Error Number Descriptio n Colum n Header Column V alue Lin e Number") ; | |||||
| 83 | ||||||
| 84 | // D isplay err ors. | |||||
| 85 | fore ach (Impor tLog log i n importLo gs.Entitie s) | |||||
| 86 | { | |||||
| 87 | Console.Wr iteLine( | |||||
| 88 | string .Format("S equence Nu mber: {0}\ nError Num ber: {1}\n Descriptio n: {2}\nCo lumn Heade r: {3}\nCo lumn Value : {4}\nLin e Number: {5}", | |||||
| 89 | lo g.Sequence Number.Val ue, | |||||
| 90 | lo g.ErrorNum ber.Value, | |||||
| 91 | lo g.ErrorDes cription, | |||||
| 92 | lo g.HeaderCo lumn, | |||||
| 93 | lo g.ColumnVa lue, | |||||
| 94 | lo g.LineNumb er.Value)) ; | |||||
| 95 | } | |||||
| 96 | } | |||||
| 97 | } | |||||
| 98 | ||||||
| 99 | // / <summary > | |||||
| 100 | // / Waits fo r the asyn c job to c omplete. | |||||
| 101 | // / </summar y> | |||||
| 102 | // / <param n ame="async JobId"></p aram> | |||||
| 103 | pu blic stati c void Wai tForAsyncJ obCompleti on(Organiz ationServi ceProxy se rviceProxy , Guid asy ncJobId) | |||||
| 104 | { | |||||
| 105 | ColumnSe t cs = new ColumnSet ("statecod e", "statu scode"); | |||||
| 106 | AsyncOpe ration asy ncjob = | |||||
| 107 | (Asy ncOperatio n)serviceP roxy.Retri eve("async operation" , asyncJob Id, cs); | |||||
| 108 | ||||||
| 109 | int retr yCount = 1 00; | |||||
| 110 | ||||||
| 111 | while (a syncjob.St ateCode.Va lue != Asy ncOperatio nState.Com pleted && retryCount > 0) | |||||
| 112 | { | |||||
| 113 | asyn cjob = (As yncOperati on)service Proxy.Retr ieve("asyn coperation ", asyncJo bId, cs); | |||||
| 114 | Syst em.Threadi ng.Thread. Sleep(2000 ); | |||||
| 115 | retr yCount--; | |||||
| 116 | Cons ole.WriteL ine("Async operation state is " + asyncj ob.StateCo de.Value.T oString()) ; | |||||
| 117 | } | |||||
| 118 | ||||||
| 119 | Console. WriteLine( "Async job is " + as yncjob.Sta teCode.Val ue.ToStrin g() + " wi th status " + ((asyn coperation _statuscod e)asyncjob .StatusCod e.Value).T oString()) ; | |||||
| 120 | } | |||||
| 121 | } | |||||
| 122 | } | |||||
| 123 | //</snippe tBulkImpor tHelper> |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.