Produced by Araxis Merge on 11/5/2018 10:29:46 AM Central 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 | CRM_PE_OCT.zip\Integrations\Medallia\Medallia.VEFT\Processors | PostToS3Processor.cs | Mon Aug 20 02:58:24 2018 UTC |
2 | CRM_PE_OCT.zip\Integrations\Medallia\Medallia.VEFT\Processors | PostToS3Processor.cs | Mon Nov 5 02:23:31 2018 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 2 | 366 |
Changed | 1 | 4 |
Inserted | 0 | 0 |
Removed | 0 | 0 |
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 | using Syst em; | |
2 | using Syst em.IO; | |
3 | using Syst em.Threadi ng; | |
4 | using Syst em.Collect ions.Gener ic; | |
5 | using VRM. Integratio n.Serviceb us.Core; | |
6 | using VRM. Integratio n.Serviceb us.Extensi ons; | |
7 | using Meda llia.VEFT. Messages; | |
8 | using Meda llia.VEFT. Configurat ion; | |
9 | using Amaz on; | |
10 | using Amaz on.S3; | |
11 | using Amaz on.S3.Mode l; | |
12 | ||
13 | namespace Medallia.V EFT.Proces sors | |
14 | { | |
15 | class PostToS3Pr ocessor | |
16 | { | |
17 | pr ivate stri ng _logBuf fer { get; set; } | |
18 | st atic IAmaz onS3 _clie nt; | |
19 | pr ivate stri ng _bucket Name = Med alliaSecur ityConfigu ration.Cur rent.Bucke t_Name; | |
20 | pr ivate stri ng onPremi seVIMTDACS tring = Me dalliaSecu rityConfig uration.Cu rrent.DAC_ URI; | |
21 | // private st ring _buck etName = " inbound.va .ugw1-atla s-prod.us- gov-west-1 .medallia" ; | |
22 | //private static str ing onPrem iseVIMTDAC String = " https:// URL /VINEXT"; //Producti on | |
23 | //private static str ing onPrem iseVIMTDAC String = " https:// URL /INT/VEFT/ VINEXT"; / /Nonproduc tion | |
24 | // private st ring _key = $"Update ProdStatus _{DateTime .Now}"; // Production | |
25 | pr ivate stri ng _key = $"UpdateSt atus_{Date Time.Now}" ; //Nonpro duction | |
26 | pr ivate int _retry = 0 ; | |
27 | Po stToS3Resp onse respo nse = new PostToS3Re sponse(); | |
28 | ||
29 | pu blic IMess ageBase Ex ecute(Post ToS3Reques t request) | |
30 | { | |
31 | #region initialize | |
32 | //respon se.Failure Details = new List<F ailureDeta il>(); | |
33 | response .Exception Occurred = false; | |
34 | response .Exception Message = ""; | |
35 | response .FailureDe tails = ne w List<Fai lureDetail >(); | |
36 | string r oot = Meda lliaSecuri tyConfigur ation.Curr ent.FilePa th; | |
37 | //if (on PremiseVIM TDACString .IndexOf(" veft.prod" ) != -1) | |
38 | // ro ot = "D:\\ WWWRoot\\I netpub\\VE FT\\VINEXT \\"; | |
39 | //else { root = "D :\\InetPub \\WWWRoot\ \NonProd\\ INT\\VEFT\ \ViNEXT\\" ; } | |
40 | ||
41 | if (requ est == nul l) | |
42 | { | |
43 | resp onse.Excep tionMessag e = "Calle d with no message"; | |
44 | resp onse.Excep tionOccurr ed = true; | |
45 | retu rn respons e; | |
46 | } | |
47 | #endregi on | |
48 | #region POST to S3 | |
49 | var s3Co nfig = new AmazonS3C onfig | |
50 | { | |
51 | Serv iceURL = M edalliaSec urityConfi guration.C urrent.Ser vice_URI, | |
52 | //Se rviceURL = "https:// s3-fips-us -gov-west- 1.amazonaw s.com", | |
53 | Regi onEndpoint = RegionE ndpoint.US GovCloudWe st1 | |
54 | }; | |
55 | //using (_client = new Amazo nS3Client( "AKIAKYKWO YKEIURPP4O Q", "2rfT2 PnRRyuZa+b L3nqs5d+hf ftlHupcg9P PsSur", s3 Config)) | |
56 | using (_ client = n ew AmazonS 3Client(Me dalliaSecu rityConfig uration.Cu rrent.S3_K ey, Medall iaSecurity Configurat ion.Curren t.S3_Secre t, s3Confi g)) | |
57 | { | |
58 | try | |
59 | { | |
60 | var _bodyT ext = tryG etFile(roo t, "Pendin gMedalliaU pdates.csv "); | |
61 | //var _bod yText = Fi le.ReadAll Text("D:\\ WWWRoot\\I netpub\\VE FT\\VINEXT \\PendingM edalliaUpd ates.csv") ; ; | |
62 | ||
63 | if (_bodyT ext != nul l && _body Text != "" ) | |
64 | { | |
65 | PutObj ectRequest putReques t = new Pu tObjectReq uest() | |
66 | { | |
67 | Co ntentBody = _bodyTex t, | |
68 | Bu cketName = _bucketNa me, | |
69 | Ke y = _key | |
70 | }; | |
71 | putReq uest.Metad ata.Add("t itle", $"U pdateStatu s_{DateTim e.Now}"); //Nonprodu ction | |
72 | //putR equest.Met adata.Add( "title", $ "UpdatePro dStatus_{D ateTime.No w}"); //Pr oduction | |
73 | PutObj ectRespons e putRespo nse = _cli ent.PutObj ect(putReq uest); | |
74 | } | |
75 | } | |
76 | catc h (AmazonS 3Exception amazonS3E xception) | |
77 | { | |
78 | if (amazon S3Exceptio n.ErrorCod e != null && | |
79 | (amazo nS3Excepti on.ErrorCo de.Equals( "InvalidAc cessKeyId" ) || | |
80 | amazon S3Exceptio n.ErrorCod e.Equals(" InvalidSec urity"))) | |
81 | { | |
82 | respon se.Failure Details.Ad d(new Fail ureDetail( ) | |
83 | { | |
84 | Re ason = Fai lureReason .SecurityE xception, | |
85 | De tails = $" AWS Creden tial Failu re: {amazo nS3Excepti on.Message }" | |
86 | }); | |
87 | } | |
88 | else | |
89 | { | |
90 | respon se.Failure Details.Ad d(new Fail ureDetail( ) | |
91 | { | |
92 | Re ason = Fai lureReason .OtherExce ption, | |
93 | De tails = $" AWS Failur e during u pload: {am azonS3Exce ption.Mess age}" | |
94 | }); | |
95 | } | |
96 | response.E xceptionOc curred = t rue; | |
97 | response.E xceptionMe ssage = $" Exception occurred w hen Puttin g to S3: { amazonS3Ex ception.Me ssage}"; | |
98 | return res ponse; | |
99 | } | |
100 | catc h (Excepti on ex) | |
101 | { | |
102 | response.F ailureDeta ils.Add(ne w FailureD etail() | |
103 | { | |
104 | Reason = Failure Reason.Une xpectedExc eption, | |
105 | Detail s = $"Unex pected Fai lure durin g upload: {ex.Messag e}" | |
106 | }); | |
107 | response.E xceptionOc curred = t rue; | |
108 | response.E xceptionMe ssage = $" Exception occurred w hen Puttin g to S3: { ex.Message }"; | |
109 | return res ponse; | |
110 | } | |
111 | } | |
112 | #endregi on | |
113 | tryWrite File(root, "PendingM edalliaUpd ates.csv", ""); | |
114 | return r esponse; | |
115 | } | |
116 | pr ivate stri ng tryGetF ile(string root, str ing fileNa me) | |
117 | { | |
118 | try | |
119 | { | |
120 | stri ng getStri ng = File. ReadAllTex t(root + f ileName); | |
121 | _ret ry = 0; | |
122 | retu rn getStri ng; | |
123 | } | |
124 | catch (F ileNotFoun dException ) | |
125 | { | |
126 | resp onse.Failu reDetails. Add(new Fa ilureDetai l() | |
127 | { | |
128 | Reason = F ailureReas on.OtherEx ception, | |
129 | Details = "File Not Found Exce ption: Una ble to fin d temp Med allia impo rt File" | |
130 | }); | |
131 | resp onse.Excep tionOccurr ed = true; | |
132 | resp onse.Excep tionMessag e = "File Not Found Exception: Unable to find temp Medallia import fil e"; | |
133 | retu rn null; | |
134 | } | |
135 | catch (E xception e x) | |
136 | { | |
137 | _ret ry++; | |
138 | if ( _retry <= 10) | |
139 | { | |
140 | Thread.Sle ep(1000); | |
141 | var result = tryGetF ile(root, fileName); | |
142 | return res ult; | |
143 | } | |
144 | else | |
145 | { | |
146 | response.F ailureDeta ils.Add(ne w FailureD etail() | |
147 | { | |
148 | Reason = Failure Reason.Une xpectedExc eption, | |
149 | Detail s = $"Unkn own except ion while trying to read temp Medallia i mport file : {ex.Mess age}" | |
150 | }); | |
151 | response.E xceptionOc curred = t rue; | |
152 | response.E xceptionMe ssage = $" Unexpected exception while try ing to rea d temp Med allia impo rt file: { ex.Message }"; | |
153 | return nul l; | |
154 | } | |
155 | } | |
156 | } | |
157 | pr ivate void tryWriteF ile(string root, str ing fileNa me, string _bodyText ) | |
158 | { | |
159 | try | |
160 | { | |
161 | File .WriteAllT ext(root + fileName, _bodyText ); | |
162 | _ret ry = 0; | |
163 | } | |
164 | catch (E xception e x) | |
165 | { | |
166 | _ret ry++; | |
167 | if ( _retry <= 10) | |
168 | { | |
169 | Thread.Sle ep(3000); | |
170 | tryWriteFi le(root, f ileName, _ bodyText); | |
171 | } | |
172 | else | |
173 | { | |
174 | response.F ailureDeta ils.Add(ne w FailureD etail() | |
175 | { | |
176 | Reason = Failure Reason.Une xpectedExc eption, | |
177 | Detail s = $"Unkn own except ion while trying to write temp Medallia import fil e: {ex.Mes sage}" | |
178 | }); | |
179 | response.E xceptionOc curred = t rue; | |
180 | response.E xceptionMe ssage = $" Unexpected exception while try ing to wri te temp Me dallia imp ort file: {ex.Messag e}"; | |
181 | } | |
182 | } | |
183 | } | |
184 | } | |
185 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.