CPE_learningsite
This repository has no backups
This repository's network speed is throttled to 100KB/sec
Upgrade your account to fix these warnings, or use backups.vc for automated backups
4cd176a439ea516368a5d8827cdf8726027259a6
CPE_learningsite / CPE / CPE.App / CPE.App.Web / Code / Extensions.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
using System; using System.Collections.Generic; using System.Configuration; using System.Diagnostics; using System.Linq; using System.Web; using CPE.App.Web.Models; namespace CPE.App.Web.Code { public static class Extensions { public static DateTime GetLocalDateTime(DateTime UtcDateTime) { var timezoneId = ConfigurationManager.AppSettings["TimezoneId"] ?? "Eastern Standard Time"; var timezoneInfo = TimeZoneInfo.FindSystemTimeZoneById(timezoneId); return TimeZoneInfo.ConvertTimeFromUtc(UtcDateTime, timezoneInfo); } public static string GetPercentComplete(double val1, double val2) { if (val1 == 0) return 1.ToString("p"); return (val2 / val1).ToString("p"); } public static double GetPollPercentComplete(double val1, double val2) { if (val1 == 0) return 1.0; return (val2 / val1); } public static int ReentryCutoff() { var cuttoff = ConfigurationManager.AppSettings["ReEntryCutoffMinutes"] ?? "5"; return int.Parse(cuttoff); } public static void LogServiceError(string service, string message, Exception ex) { try { var context = CPEWebDataContext.GetContext(); var serviceError = new ServiceError() { Logged = DateTime.UtcNow, ServiceMethod = service, Message = message, StackTrace = ex.ToString() }; context.ServiceErrors.InsertOnSubmit(serviceError); context.SubmitChanges(); } catch (Exception blackhole) { //swallow logging errors Debug.WriteLine(blackhole.Message); } } public static void LogServiceError(string service, Exception ex) { try { var context = CPEWebDataContext.GetContext(); var serviceError = new ServiceError() { Logged = DateTime.UtcNow, ServiceMethod = service, Message = ex.Message, StackTrace = ex.ToString() }; context.ServiceErrors.InsertOnSubmit(serviceError); context.SubmitChanges(); } catch (Exception blackhole) { //swallow logging errors Debug.WriteLine(blackhole.Message); } } public static void LogServiceCall(string service, string details) { try { var context = CPEWebDataContext.GetContext(); var serviceLog = new ServiceLog() { ServiceMethod = service, Details = details, Created = DateTime.UtcNow, LogKey = Guid.NewGuid() }; context.ServiceLogs.InsertOnSubmit(serviceLog); context.SubmitChanges(); } catch (Exception blackhole) { //swallow logging errors Debug.WriteLine(blackhole.Message); } } } } |
Commits for CPE_learningsiteCPE/CPE.App/CPE.App.Web/Code/Extensions.cs
Revision | Author | Commited | Message |
---|---|---|---|
4cd176 ... | v.shishlov | Fri 27 Aug, 2021 14:33:17 +0000 | initial commit |