Skip to content

Commit c8154d0

Browse files
committed
Fixing logging style
1 parent e60f19b commit c8154d0

File tree

5 files changed

+43
-67
lines changed

5 files changed

+43
-67
lines changed

eFormCore/Communication/HttpFake.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,6 @@ public async Task<bool> FolderUpdate(int id, string name, string description, st
418418
{
419419
var url =
420420
$"/Folder/{id}?token={_token}&languageCode={languageCode}&name={Uri.EscapeDataString(name)}&description={Uri.EscapeDataString(description)}&parentId={parentId}&sdkVersion=";
421-
Console.WriteLine(url);
422421
// Synchronous fake implementation
423422
return true;
424423
}

eFormCore/Core.cs

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2481,7 +2481,8 @@ private async Task<string> DocxToPdf(int caseId, string templateId, string timeS
24812481
}
24822482
catch (Exception e)
24832483
{
2484-
Console.WriteLine(e);
2484+
Console.WriteLine($"fail: {e.Message}");
2485+
Console.WriteLine($" {e.StackTrace}");
24852486

24862487
string bigFilename = fileName;
24872488
fileName =
@@ -2675,7 +2676,8 @@ await GetFileFromS3Storage(fieldValue.UploadedDataObj.FileName)
26752676
}
26762677
catch (Exception e)
26772678
{
2678-
Console.WriteLine(e);
2679+
Console.WriteLine($"fail: {e.Message}");
2680+
Console.WriteLine($" {e.StackTrace}");
26792681
throw;
26802682
}
26812683
}
@@ -4023,7 +4025,8 @@ public async Task<bool> GetQuestionSet(int microtingUid, int questionSetId, int
40234025
}
40244026
catch (Exception exception)
40254027
{
4026-
Console.WriteLine(exception.Message);
4028+
Console.WriteLine($"fail: {exception.Message}");
4029+
Console.WriteLine($" {exception.StackTrace}");
40274030
}
40284031
}
40294032

@@ -4167,7 +4170,7 @@ private async Task SaveAnswer(JToken subItem, int questionSetId)
41674170
Answer answer = JsonConvert.DeserializeObject<Answer>(subItem.ToString(), settings);
41684171
if (answer == null)
41694172
{
4170-
Console.WriteLine("fdssd");
4173+
Console.WriteLine($"fail: Could not deserialize answer");
41714174
}
41724175

41734176
Answer result = null;
@@ -4180,8 +4183,8 @@ private async Task SaveAnswer(JToken subItem, int questionSetId)
41804183
}
41814184
catch (Exception ex)
41824185
{
4183-
Console.WriteLine(ex.StackTrace);
4184-
Console.WriteLine(ex.Message);
4186+
Console.WriteLine($"fail: {ex.Message}");
4187+
Console.WriteLine($" {ex.StackTrace}");
41854188
}
41864189
// if (result != null)
41874190
// {
@@ -4257,8 +4260,8 @@ await db.OptionTranslations.FirstAsync(x => x.OptionId == option.Id)
42574260
}
42584261
catch (Exception ex)
42594262
{
4260-
Console.WriteLine(ex.StackTrace);
4261-
Console.WriteLine(ex.Message);
4263+
Console.WriteLine($"fail: {ex.Message}");
4264+
Console.WriteLine($" {ex.StackTrace}");
42624265
}
42634266
}
42644267
else
@@ -4353,7 +4356,8 @@ await db.QuestionSets.FirstOrDefaultAsync(x => x.MicrotingUid == apiQuestionSetI
43534356
}
43544357
catch (Exception ex)
43554358
{
4356-
Console.WriteLine(ex.Message);
4359+
Console.WriteLine($"fail: {ex.Message}");
4360+
Console.WriteLine($" {ex.StackTrace}");
43574361
throw;
43584362
}
43594363
}
@@ -4388,7 +4392,8 @@ await db.QuestionSets.FirstOrDefaultAsync(x => x.MicrotingUid == apiQuestionSetI
43884392
}
43894393
catch (Exception ex)
43904394
{
4391-
Console.WriteLine(ex.Message);
4395+
Console.WriteLine($"fail: {ex.Message}");
4396+
Console.WriteLine($" {ex.StackTrace}");
43924397
}
43934398
}
43944399
}
@@ -5620,7 +5625,8 @@ await dbContext.CheckListTranslations.FirstAsync(x =>
56205625
}
56215626
catch (Exception ex)
56225627
{
5623-
Console.WriteLine(ex.Message);
5628+
Console.WriteLine($"fail: {ex.Message}");
5629+
Console.WriteLine($" {ex.StackTrace}");
56245630
}
56255631
}
56265632
// fieldValue generate end
@@ -6233,9 +6239,10 @@ public async Task<bool> DownloadUploadedData(int uploadedDataId)
62336239
}
62346240
}
62356241
}
6236-
catch (Exception)
6242+
catch (Exception ex)
62376243
{
6238-
// Console.WriteLine(e);
6244+
Console.WriteLine($"fail: {ex.Message}");
6245+
Console.WriteLine($" {ex.StackTrace}");
62396246
}
62406247

62416248
MemoryStream memoryStream = new MemoryStream();
@@ -6304,9 +6311,10 @@ public async Task<bool> DownloadUploadedData(int uploadedDataId)
63046311
}
63056312
}
63066313
}
6307-
catch (Exception)
6314+
catch (Exception ex)
63086315
{
6309-
// Console.WriteLine(e);
6316+
Console.WriteLine($"fail: {ex.Message}");
6317+
Console.WriteLine($" {ex.StackTrace}");
63106318
}
63116319

63126320
decimal currentRation = image.Height / (decimal)image.Width;
@@ -6375,9 +6383,10 @@ public async Task<bool> DownloadUploadedData(int uploadedDataId)
63756383
}
63766384
}
63776385
}
6378-
catch (Exception)
6386+
catch (Exception ex)
63796387
{
6380-
// Console.WriteLine(e);
6388+
Console.WriteLine($"fail: {ex.Message}");
6389+
Console.WriteLine($" {ex.StackTrace}");
63816390
}
63826391

63836392
decimal currentRation = image.Height / (decimal)image.Width;
@@ -6414,7 +6423,8 @@ await _sqlController
64146423
}
64156424
catch (Exception ex)
64166425
{
6417-
Console.WriteLine(ex.Message);
6426+
Console.WriteLine($"fail: {ex.Message}");
6427+
Console.WriteLine($" {ex.StackTrace}");
64186428
}
64196429

64206430
return false;

eFormCore/Handlers/EformCompletedHandler.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ await SaveResult(resp, respXml, dbContext, microtingUid, checkIdLastKnown, aCase
145145
if (noResults)
146146
{
147147
CaseDto cDto = await _sqlController.CaseReadByMUId(microtingUid);
148-
Console.WriteLine($"{DateTime.Now} FireHandleCaseCompleted");
148+
Console.WriteLine($"info: {DateTime.Now} FireHandleCaseCompleted");
149149
await _core.FireHandleCaseCompleted(cDto);
150150
}
151151

@@ -204,13 +204,13 @@ private async Task<int> SaveResult(Response resp, string respXml, MicrotingDbCon
204204
.Single(x => x.MicrotingUid == int.Parse(check.WorkerId))
205205
.MicrotingUid; //sqlController.WorkerRead(int.Parse(check.WorkerId)).Result.WorkerUId;
206206
_log.LogVariable(_t.GetMethodName("EformCompletedHandler"), nameof(workerUId), workerUId);
207-
Console.WriteLine($"{DateTime.Now} ChecksCreate start");
207+
Console.WriteLine($"info: {DateTime.Now} ChecksCreate start");
208208

209209
List<int> uploadedDataIds =
210210
await _sqlController.ChecksCreate(resp, checks.ChildNodes[i].OuterXml, i);
211-
Console.WriteLine($"{DateTime.Now} ChecksCreate end");
211+
Console.WriteLine($"info: {DateTime.Now} ChecksCreate end");
212212

213-
Console.WriteLine($"{DateTime.Now} uploadedDataIds");
213+
Console.WriteLine($"info: {DateTime.Now} uploadedDataIds");
214214
foreach (int uploadedDataid in uploadedDataIds)
215215
{
216216
if (await _core.DownloadUploadedData(uploadedDataid))
@@ -237,7 +237,7 @@ await _sqlController.CaseUpdateCompleted(microtingUid, (int)check.Id, dateTime,
237237

238238
// IF needed retract case, thereby completing the process
239239

240-
Console.WriteLine($"{DateTime.Now} checkIdLastKnown");
240+
Console.WriteLine($"info: {DateTime.Now} checkIdLastKnown");
241241
if (checkIdLastKnown == null)
242242
{
243243
await _communicator.Delete(aCase.MicrotingUId.ToString(), aCase.SiteUId);
@@ -257,7 +257,7 @@ await _sqlController.CaseUpdateCompleted(microtingUid, (int)check.Id, dateTime,
257257
_log.LogEverything(_t.GetMethodName("EformCompletedHandler"), "sqlController.CaseRetract(...)");
258258
// TODO add case.id
259259
CaseDto cDto = await _sqlController.CaseReadByMUId(microtingUid);
260-
Console.WriteLine($"{DateTime.Now} FireHandleCaseCompleted");
260+
Console.WriteLine($"info: {DateTime.Now} FireHandleCaseCompleted");
261261
await _core.FireHandleCaseCompleted(cDto);
262262
_log.LogStandard(_t.GetMethodName("EformCompletedHandler"), cDto + " has been completed");
263263
i++;

eFormCore/Helpers/ReportHelper.cs

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,10 @@ public static void ConvertToPdf(string docxFileName, string outputFolder)
275275
Trace.WriteLine(output);
276276
pdfProcess.WaitForExit();
277277
}
278-
catch (Exception e)
278+
catch (Exception ex)
279279
{
280-
Console.WriteLine(e);
280+
Console.WriteLine($"fail: {ex.Message}");
281+
Console.WriteLine($" {ex.StackTrace}");
281282
throw;
282283
}
283284
}
@@ -308,7 +309,8 @@ public static void InsertHeader(string header, WordprocessingDocument wordDoc, s
308309
}
309310
catch (Exception ex)
310311
{
311-
Console.WriteLine(ex.Message);
312+
Console.WriteLine($"fail: {ex.Message}");
313+
Console.WriteLine($" {ex.StackTrace}");
312314
}
313315
}
314316

@@ -403,43 +405,6 @@ public static void InsertPicture(List<string> values, WordprocessingDocument wor
403405
AddImageToBody(wordDoc, mainPart.GetIdOfPart(imagePart), iWidth, iHeight, paragraph);
404406
}
405407

406-
public static void ValidateWordDocument(string filepath)
407-
{
408-
using (WordprocessingDocument wordprocessingDocument =
409-
WordprocessingDocument.Open(filepath, true))
410-
{
411-
try
412-
{
413-
OpenXmlValidator validator = new OpenXmlValidator();
414-
int count = 0;
415-
foreach (ValidationErrorInfo error in
416-
validator.Validate(wordprocessingDocument))
417-
{
418-
count++;
419-
Console.WriteLine("Error " + count);
420-
Console.WriteLine("Description: " + error.Description);
421-
Console.WriteLine("ErrorType: " + error.ErrorType);
422-
Console.WriteLine("Id: " + error.Id);
423-
Console.WriteLine("Node: " + error.Node);
424-
// Console.WriteLine("Node InnerXML: " + error.Node.InnerXml);
425-
// Console.WriteLine("Node InnerText: " + error.Node.InnerText);
426-
Console.WriteLine("Path: " + error.Path.XPath);
427-
Console.WriteLine("Part: " + error.Part.Uri);
428-
Console.WriteLine("-------------------------------------------");
429-
}
430-
431-
Console.WriteLine("count={0}", count);
432-
}
433-
434-
catch (Exception ex)
435-
{
436-
Console.WriteLine(ex.Message);
437-
}
438-
439-
wordprocessingDocument.Dispose();
440-
}
441-
}
442-
443408
private static void AddImageToBody(WordprocessingDocument wordDoc, string relationshipId, Int64Value cx,
444409
Int64Value cy, Paragraph paragraph = null)
445410
{

eFormCore/Infrastructure/SqlController.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ public SqlController(DbContextHelper dbContextHelper)
8686
}
8787
catch (Exception ex)
8888
{
89-
Console.WriteLine(ex.Message);
89+
Console.WriteLine($"fail: {ex.Message}");
90+
Console.WriteLine($" {ex.StackTrace}");
9091
throw;
9192
}
9293
//
@@ -1470,7 +1471,8 @@ public async Task<List<int>> ChecksCreate(Response response, string xmlString, i
14701471
}
14711472
catch (Exception ex)
14721473
{
1473-
Console.WriteLine($"{DateTime.Now} {ex.Message}");
1474+
Console.WriteLine($"fail: {ex.Message}");
1475+
Console.WriteLine($" {ex.StackTrace}");
14741476

14751477
throw new Exception(methodName + " failed", ex);
14761478
}

0 commit comments

Comments
 (0)