logging enhancements
This commit is contained in:
		
							
								
								
									
										12
									
								
								Oqtane.Shared/Enums/LogFunction.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								Oqtane.Shared/Enums/LogFunction.cs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,12 @@ | ||||
| namespace Oqtane.Shared | ||||
| { | ||||
|     public enum LogFunction | ||||
|     { | ||||
|         Create, | ||||
|         Read, | ||||
|         Update, | ||||
|         Delete, | ||||
|         Security, | ||||
|         Other | ||||
|     } | ||||
| } | ||||
							
								
								
									
										10
									
								
								Oqtane.Shared/Enums/MessageType.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								Oqtane.Shared/Enums/MessageType.cs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,10 @@ | ||||
| namespace Oqtane.Shared | ||||
| { | ||||
|     public enum MessageType | ||||
|     { | ||||
|         Success, | ||||
|         Info, | ||||
|         Warning, | ||||
|         Error | ||||
|     } | ||||
| } | ||||
							
								
								
									
										10
									
								
								Oqtane.Shared/Enums/Reload.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								Oqtane.Shared/Enums/Reload.cs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,10 @@ | ||||
| namespace Oqtane.Shared | ||||
| { | ||||
|     public enum Reload | ||||
|     { | ||||
|         None, | ||||
|         Page, | ||||
|         Site, | ||||
|         Application | ||||
|     } | ||||
| } | ||||
| @ -13,7 +13,9 @@ namespace Oqtane.Models | ||||
|         public int? UserId { get; set; } | ||||
|         public string Url { get; set; } | ||||
|         public string Server { get; set; } | ||||
|         public string Category { get; set; } | ||||
|         public string Category { get; set; } // usually the full typename of the  | ||||
|         public string Feature { get; set; } | ||||
|         public string Function { get; set; } | ||||
|         public string Level { get; set; } | ||||
|         public string Message { get; set; } | ||||
|         public string MessageTemplate { get; set; } | ||||
|  | ||||
							
								
								
									
										213
									
								
								Oqtane.Shared/Shared/Utilities.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										213
									
								
								Oqtane.Shared/Shared/Utilities.cs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,213 @@ | ||||
| using System.Globalization; | ||||
| using System.Text; | ||||
|  | ||||
| namespace Oqtane.Shared | ||||
| { | ||||
|     public class Utilities | ||||
|     { | ||||
|         public static string NavigateUrl(string alias, string path, string parameters, Reload reload) | ||||
|         { | ||||
|             string url = ""; | ||||
|             if (alias != "") | ||||
|             { | ||||
|                 url += alias + "/"; | ||||
|             } | ||||
|             if (path != "" && path != "/") | ||||
|             { | ||||
|                 url += path + "/"; | ||||
|             } | ||||
|             if (url.EndsWith("/")) | ||||
|             { | ||||
|                 url = url.Substring(0, url.Length - 1); | ||||
|             } | ||||
|             if (!string.IsNullOrEmpty(parameters)) | ||||
|             { | ||||
|                 url += "?" + parameters; | ||||
|             } | ||||
|             if (reload != Reload.None) | ||||
|             { | ||||
|                 url += ((string.IsNullOrEmpty(parameters)) ? "?" : "&") + "reload=" + ((int)reload).ToString(); | ||||
|             } | ||||
|             if (!url.StartsWith("/")) | ||||
|             { | ||||
|                 url = "/" + url; | ||||
|             } | ||||
|             return url; | ||||
|         } | ||||
|  | ||||
|         public static string EditUrl(string alias, string path, int moduleid, string action, string parameters) | ||||
|         { | ||||
|             string url = NavigateUrl(alias, path, "", Reload.None); | ||||
|             if (url == "/") url = ""; | ||||
|             if (moduleid != -1) | ||||
|             { | ||||
|                 url += "/" + moduleid.ToString(); | ||||
|             } | ||||
|             if (moduleid != -1 && action != "") | ||||
|             { | ||||
|                 url += "/" + action; | ||||
|             } | ||||
|             if (!string.IsNullOrEmpty(parameters)) | ||||
|             { | ||||
|                 url += "?" + parameters; | ||||
|             } | ||||
|             if (!url.StartsWith("/")) | ||||
|             { | ||||
|                 url = "/" + url; | ||||
|             } | ||||
|             return url; | ||||
|         } | ||||
|  | ||||
|         public static string GetTypeName(string fullyqualifiedtypename) | ||||
|         { | ||||
|             if (fullyqualifiedtypename.Contains(",")) | ||||
|             { | ||||
|                 return fullyqualifiedtypename.Substring(0, fullyqualifiedtypename.IndexOf(",")); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 return fullyqualifiedtypename; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         public static string GetTypeNameLastSegment(string typename, int segment) | ||||
|         { | ||||
|             if (typename.Contains(",")) | ||||
|             { | ||||
|                 // remove assembly if fully qualified type | ||||
|                 typename = typename.Substring(0, typename.IndexOf(",")); | ||||
|             } | ||||
|             // segment 0 is the last segment, segment 1 is the second to last segment, etc... | ||||
|             string[] segments = typename.Split('.'); | ||||
|             string name = ""; | ||||
|             if (segment < segments.Length) | ||||
|             { | ||||
|                 name = segments[segments.Length - (segment + 1)]; | ||||
|             } | ||||
|             return name; | ||||
|         } | ||||
|  | ||||
|         public static string GetFriendlyUrl(string text) | ||||
|         { | ||||
|             string result = ""; | ||||
|             if (text != null) | ||||
|             { | ||||
|                 var normalizedString = text.ToLowerInvariant().Normalize(NormalizationForm.FormD); | ||||
|                 var stringBuilder = new StringBuilder(); | ||||
|                 var stringLength = normalizedString.Length; | ||||
|                 var prevdash = false; | ||||
|                 char c; | ||||
|                 for (int i = 0; i < stringLength; i++) | ||||
|                 { | ||||
|                     c = normalizedString[i]; | ||||
|                     switch (CharUnicodeInfo.GetUnicodeCategory(c)) | ||||
|                     { | ||||
|                         case UnicodeCategory.LowercaseLetter: | ||||
|                         case UnicodeCategory.UppercaseLetter: | ||||
|                         case UnicodeCategory.DecimalDigitNumber: | ||||
|                             if (c < 128) | ||||
|                                 stringBuilder.Append(c); | ||||
|                             else | ||||
|                                 stringBuilder.Append(RemapInternationalCharToAscii(c)); | ||||
|                             prevdash = false; | ||||
|                             break; | ||||
|                         case UnicodeCategory.SpaceSeparator: | ||||
|                         case UnicodeCategory.ConnectorPunctuation: | ||||
|                         case UnicodeCategory.DashPunctuation: | ||||
|                         case UnicodeCategory.OtherPunctuation: | ||||
|                         case UnicodeCategory.MathSymbol: | ||||
|                             if (!prevdash) | ||||
|                             { | ||||
|                                 stringBuilder.Append('-'); | ||||
|                                 prevdash = true; | ||||
|                             } | ||||
|                             break; | ||||
|                     } | ||||
|                 } | ||||
|                 result = stringBuilder.ToString().Trim('-'); | ||||
|             } | ||||
|             return result; | ||||
|         } | ||||
|  | ||||
|         private static string RemapInternationalCharToAscii(char c) | ||||
|         { | ||||
|             string s = c.ToString().ToLowerInvariant(); | ||||
|             if ("àåáâäãåą".Contains(s)) | ||||
|             { | ||||
|                 return "a"; | ||||
|             } | ||||
|             else if ("èéêëę".Contains(s)) | ||||
|             { | ||||
|                 return "e"; | ||||
|             } | ||||
|             else if ("ìíîïı".Contains(s)) | ||||
|             { | ||||
|                 return "i"; | ||||
|             } | ||||
|             else if ("òóôõöøőð".Contains(s)) | ||||
|             { | ||||
|                 return "o"; | ||||
|             } | ||||
|             else if ("ùúûüŭů".Contains(s)) | ||||
|             { | ||||
|                 return "u"; | ||||
|             } | ||||
|             else if ("çćčĉ".Contains(s)) | ||||
|             { | ||||
|                 return "c"; | ||||
|             } | ||||
|             else if ("żźž".Contains(s)) | ||||
|             { | ||||
|                 return "z"; | ||||
|             } | ||||
|             else if ("śşšŝ".Contains(s)) | ||||
|             { | ||||
|                 return "s"; | ||||
|             } | ||||
|             else if ("ñń".Contains(s)) | ||||
|             { | ||||
|                 return "n"; | ||||
|             } | ||||
|             else if ("ýÿ".Contains(s)) | ||||
|             { | ||||
|                 return "y"; | ||||
|             } | ||||
|             else if ("ğĝ".Contains(s)) | ||||
|             { | ||||
|                 return "g"; | ||||
|             } | ||||
|             else if (c == 'ř') | ||||
|             { | ||||
|                 return "r"; | ||||
|             } | ||||
|             else if (c == 'ł') | ||||
|             { | ||||
|                 return "l"; | ||||
|             } | ||||
|             else if (c == 'đ') | ||||
|             { | ||||
|                 return "d"; | ||||
|             } | ||||
|             else if (c == 'ß') | ||||
|             { | ||||
|                 return "ss"; | ||||
|             } | ||||
|             else if (c == 'þ') | ||||
|             { | ||||
|                 return "th"; | ||||
|             } | ||||
|             else if (c == 'ĥ') | ||||
|             { | ||||
|                 return "h"; | ||||
|             } | ||||
|             else if (c == 'ĵ') | ||||
|             { | ||||
|                 return "j"; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 return ""; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 Shaun Walker
					Shaun Walker