clean up and various little improvements after search for static wasted memory objects (not found) At this point it appears I don't have any leaks and it's all pretty efficient.
This commit is contained in:
@@ -8,17 +8,9 @@ namespace AyaNova.Util
|
||||
/// </summary>
|
||||
internal static class ApplicationLogging
|
||||
{
|
||||
internal static ILogger theLogger{get;set;}
|
||||
internal static NLogLoggerProvider LoggerProvider { get; set; }// = new LoggerFactory();
|
||||
internal static ILogger CreateLogger<T>() => LoggerProvider.CreateLogger(typeof(T).FullName);
|
||||
//internal static ILogger CreateLogger(string categoryName) => theLogger;
|
||||
internal static ILogger CreateLogger(string categoryName)=> LoggerProvider.CreateLogger(categoryName);
|
||||
|
||||
|
||||
|
||||
// internal static ILoggerFactory LoggerFactory { get; set; }// = new LoggerFactory();
|
||||
// internal static ILogger CreateLogger<T>() => LoggerFactory.CreateLogger<T>();
|
||||
// internal static ILogger CreateLogger(string categoryName) => LoggerFactory.CreateLogger(categoryName);
|
||||
|
||||
internal static ILogger theLogger { get; set; }
|
||||
internal static NLogLoggerProvider LoggerProvider { get; set; }
|
||||
internal static ILogger CreateLogger<T>() => LoggerProvider.CreateLogger(typeof(T).FullName);
|
||||
internal static ILogger CreateLogger(string categoryName) => LoggerProvider.CreateLogger(categoryName);
|
||||
}
|
||||
}
|
||||
@@ -1,29 +1,11 @@
|
||||
namespace AyaNova.Util
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Version strings centrally located for convenience
|
||||
/// </summary>
|
||||
internal static class AyaNovaVersion
|
||||
{
|
||||
public static string VersionString
|
||||
{
|
||||
get
|
||||
{
|
||||
return "8.0.0-alpha.5";
|
||||
}
|
||||
}
|
||||
|
||||
public static string FullNameAndVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
return "AyaNova server " + VersionString;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public const string VersionString = "8.0.0-alpha.6";
|
||||
public const string FullNameAndVersion = "AyaNova server " + VersionString;
|
||||
}//eoc
|
||||
|
||||
}//eons
|
||||
@@ -1,8 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AyaNova.Util
|
||||
{
|
||||
|
||||
@@ -2,8 +2,6 @@ using System;
|
||||
|
||||
namespace AyaNova.Util
|
||||
{
|
||||
|
||||
|
||||
internal static class DateUtil
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -87,19 +87,6 @@ namespace AyaNova.Util
|
||||
}
|
||||
|
||||
|
||||
// /// <summary>
|
||||
// /// Delete a utility file (backup folder file)
|
||||
// /// </summary>
|
||||
// /// <param name="fileName"></param>
|
||||
// internal static void DeleteUtilityFile(string fileName)
|
||||
// {
|
||||
// var utilityFilePath = GetFullPathForUtilityFile(fileName);
|
||||
// if (File.Exists(utilityFilePath))
|
||||
// {
|
||||
// File.Delete(utilityFilePath);
|
||||
// }
|
||||
// }
|
||||
|
||||
public class BackupFileInfo
|
||||
{
|
||||
public string length { get; set; }
|
||||
@@ -311,42 +298,6 @@ namespace AyaNova.Util
|
||||
return zipEntries;
|
||||
}
|
||||
|
||||
// /// <summary>
|
||||
// /// Import utility - get individual files specified in zip archive as JSON objects
|
||||
// ///
|
||||
// /// </summary>
|
||||
// /// <param name="zipFileName">Name of utility zip import file</param>
|
||||
// /// <param name="entryList">Name of entries in utility file archive to fetch</param>
|
||||
// /// <returns></returns>
|
||||
// internal static List<JObject> ZipGetUtilityArchiveEntriesAsJsonObjects(List<string> entryList, string zipFileName)
|
||||
// {
|
||||
// List<JObject> jList = new List<JObject>();
|
||||
// var zipPath = GetFullPathForUtilityFile(zipFileName);
|
||||
// using (ZipArchive archive = ZipFile.OpenRead(zipPath))
|
||||
// {
|
||||
// foreach (string importFileName in entryList)
|
||||
// {
|
||||
// ZipArchiveEntry entry = archive.GetEntry(importFileName);
|
||||
// if (entry != null)
|
||||
// {
|
||||
// //stream entry into a new jobject and add it to the list
|
||||
// StreamReader reader = new StreamReader(entry.Open());
|
||||
// string text = reader.ReadToEnd();
|
||||
// var j = JObject.Parse(text);
|
||||
|
||||
// //Here add v7 import file name as sometimes it's needed later (Translations)
|
||||
// j.Add("V7_SOURCE_FILE_NAME", JToken.FromObject(importFileName));
|
||||
// jList.Add(j);
|
||||
// }
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
// return jList;
|
||||
|
||||
// }
|
||||
|
||||
|
||||
#endregion Zip handling
|
||||
|
||||
#region Attachment file handling
|
||||
|
||||
@@ -32,22 +32,6 @@ namespace AyaNova.Util
|
||||
return Convert.ToBase64String(salt);
|
||||
}
|
||||
|
||||
|
||||
// /// <summary>
|
||||
// /// Generate a random ID
|
||||
// /// </summary>
|
||||
// /// <returns>HEX</returns>
|
||||
// internal static string GenerateStrongId()
|
||||
// {
|
||||
// var s = new byte[32];
|
||||
// var random = RandomNumberGenerator.Create();
|
||||
// random.GetNonZeroBytes(s);
|
||||
// return BitConverter.ToString(s).Replace("-", string.Empty).ToLowerInvariant();
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
}//eoc
|
||||
|
||||
}//eons
|
||||
@@ -1,5 +1,3 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
@@ -28,14 +26,12 @@ namespace AyaNova.Util
|
||||
JArray j = JArray.Parse(jsonIn);
|
||||
return JsonConvert.SerializeObject(j, Formatting.None);
|
||||
}
|
||||
|
||||
if (jsonIn.StartsWith("{"))
|
||||
{
|
||||
JObject j = JObject.Parse(jsonIn);
|
||||
return JsonConvert.SerializeObject(j, Formatting.None);
|
||||
}
|
||||
|
||||
//Not an object or an array so just return it, possibly suspect, maybe log this shit
|
||||
//Not an object or an array so just return it
|
||||
return jsonIn;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,167 +0,0 @@
|
||||
// using App.Metrics;
|
||||
// using App.Metrics.Counter;
|
||||
// using App.Metrics.Gauge;
|
||||
// using App.Metrics.Histogram;
|
||||
// using App.Metrics.ReservoirSampling.Uniform;
|
||||
// using App.Metrics.Meter;
|
||||
// using App.Metrics.Timer;
|
||||
// using App.Metrics.Apdex;
|
||||
// using App.Metrics.ReservoirSampling.ExponentialDecay;
|
||||
|
||||
// namespace AyaNova.Util
|
||||
// {
|
||||
// /// <summary>
|
||||
// /// All metrics gathered by AyaNova are defined here
|
||||
// /// (except for endpoint ones gathered automatically by App.Metrics)
|
||||
// /// https://www.app-metrics.io
|
||||
// /// </summary>
|
||||
// public static class MetricsRegistry
|
||||
// {
|
||||
|
||||
// /// <summary>
|
||||
// /// Physical memory
|
||||
// /// Memory being used by this process (RAVEN)
|
||||
// /// </summary>
|
||||
// public static GaugeOptions PhysicalMemoryGauge = new GaugeOptions
|
||||
// {
|
||||
// Name = "Process Physical Memory",
|
||||
// MeasurementUnit = Unit.Bytes
|
||||
// };
|
||||
|
||||
// /// <summary>
|
||||
// /// Private bytes
|
||||
// /// The current size, in bytes, of the committed memory owned by this process.
|
||||
// /// Memory leaks are identified by a consistent and prolonged increase in Private Bytes.
|
||||
// /// This is the best performance counter for detecting memory leaks.
|
||||
// /// </summary>
|
||||
// public static GaugeOptions PrivateBytesGauge = new GaugeOptions
|
||||
// {
|
||||
// Name = "Process Private Bytes",
|
||||
// MeasurementUnit = Unit.Bytes
|
||||
// };
|
||||
|
||||
// /// <summary>
|
||||
// /// Exceptions that are handled by the ApiCustomExceptionFilter
|
||||
// /// Basically any exception that is not normal and expected
|
||||
// /// </summary>
|
||||
// public static MeterOptions UnhandledExceptionsMeter => new MeterOptions
|
||||
// {
|
||||
// Name = "Exceptions Meter",
|
||||
// MeasurementUnit = Unit.Calls
|
||||
// };
|
||||
|
||||
// /// <summary>
|
||||
// /// Login failed meter
|
||||
// /// </summary>
|
||||
// public static MeterOptions FailedLoginMeter => new MeterOptions
|
||||
// {
|
||||
// Name = "Failed Login Meter",
|
||||
// MeasurementUnit = Unit.Calls
|
||||
// };
|
||||
|
||||
// /// <summary>
|
||||
// /// Login failed meter
|
||||
// /// </summary>
|
||||
// public static MeterOptions SuccessfulLoginMeter => new MeterOptions
|
||||
// {
|
||||
// Name = "Successful Login Meter",
|
||||
// MeasurementUnit = Unit.Calls
|
||||
// };
|
||||
|
||||
// /// <summary>
|
||||
// /// Records in db
|
||||
// /// </summary>
|
||||
// public static GaugeOptions DBRecordsGauge = new GaugeOptions
|
||||
// {
|
||||
// Name = "DB Records",
|
||||
// MeasurementUnit = Unit.Items
|
||||
// };
|
||||
|
||||
// /// <summary>
|
||||
// /// Jobs in db
|
||||
// /// </summary>
|
||||
// public static GaugeOptions JobsGauge = new GaugeOptions
|
||||
// {
|
||||
// Name = "Jobs",
|
||||
// MeasurementUnit = Unit.Items
|
||||
// };
|
||||
|
||||
// /// <summary>
|
||||
// /// File count on disk
|
||||
// /// </summary>
|
||||
// public static GaugeOptions FileCountGauge = new GaugeOptions
|
||||
// {
|
||||
// Name = "File count",
|
||||
// MeasurementUnit = Unit.Items
|
||||
// };
|
||||
|
||||
// /// <summary>
|
||||
// /// File size on disk
|
||||
// /// </summary>
|
||||
// public static GaugeOptions FileSizeGauge = new GaugeOptions
|
||||
// {
|
||||
// Name = "File size",
|
||||
// MeasurementUnit = Unit.Bytes
|
||||
// };
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// // ==================================================================
|
||||
// // /// <summary>
|
||||
// // ///
|
||||
// // /// </summary>
|
||||
// // public static GaugeOptions Errors => new GaugeOptions
|
||||
// // {
|
||||
// // Context = "My_Gauge_context",
|
||||
// // Name = "Errors"
|
||||
// // };
|
||||
|
||||
|
||||
|
||||
// // /// <summary>
|
||||
// // ///
|
||||
// // /// </summary>
|
||||
// // public static HistogramOptions SampleHistogram => new HistogramOptions
|
||||
// // {
|
||||
// // Name = "Sample Histogram",
|
||||
// // Reservoir = () => new DefaultAlgorithmRReservoir(),
|
||||
// // MeasurementUnit = Unit.MegaBytes
|
||||
// // };
|
||||
|
||||
// // /// <summary>
|
||||
// // ///
|
||||
// // /// </summary>
|
||||
// // public static MeterOptions SampleMeter => new MeterOptions
|
||||
// // {
|
||||
// // Name = "Sample Meter",
|
||||
// // MeasurementUnit = Unit.Calls
|
||||
// // };
|
||||
|
||||
// // /// <summary>
|
||||
// // ///
|
||||
// // /// </summary>
|
||||
// // public static TimerOptions SampleTimer => new TimerOptions
|
||||
// // {
|
||||
// // Name = "Sample Timer",
|
||||
// // MeasurementUnit = Unit.Items,
|
||||
// // DurationUnit = TimeUnit.Milliseconds,
|
||||
// // RateUnit = TimeUnit.Milliseconds,
|
||||
// // Reservoir = () => new DefaultForwardDecayingReservoir(sampleSize: 1028, alpha: 0.015)
|
||||
// // };
|
||||
|
||||
// // /// <summary>
|
||||
// // ///
|
||||
// // /// </summary>
|
||||
// // public static ApdexOptions SampleApdex => new ApdexOptions
|
||||
// // {
|
||||
// // Name = "Sample Apdex"
|
||||
// // };
|
||||
|
||||
|
||||
|
||||
// }
|
||||
// }
|
||||
@@ -10,8 +10,7 @@ namespace AyaNova.Util
|
||||
/// </summary>
|
||||
public static class RetryHelper
|
||||
{
|
||||
//private static ILog logger = LogManager.GetLogger(); //use a logger or trace of your choice
|
||||
// private readonly ILogger log;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
|
||||
@@ -90,32 +90,6 @@ namespace AyaNova.Util
|
||||
}
|
||||
|
||||
|
||||
// /// <summary>
|
||||
// /// Make a unique but duplicate object name of desired length
|
||||
// /// (Used by Duplicate object function)
|
||||
// /// </summary>
|
||||
// /// <param name="s"></param>
|
||||
// /// <param name="maxLength"></param>
|
||||
// /// <returns></returns>
|
||||
// public static string NameUniquify(string s, int maxLength)
|
||||
// {
|
||||
// //Unique string
|
||||
// string unique = " - " + DateUtil.SortableShortCurrentDateTimeValue;
|
||||
// string ret = s + unique;
|
||||
// var diff = maxLength - ret.Length;
|
||||
// if (diff < 0)
|
||||
// {
|
||||
// if (unique.Length >= maxLength)
|
||||
// {
|
||||
// throw new System.ArgumentOutOfRangeException("StringUtil::nameUniquify - maxlength> unique value, source field too short for this function?");
|
||||
// }
|
||||
// ret = s.Substring(0, Math.Abs(diff)) + unique;
|
||||
// }
|
||||
|
||||
// return ret;
|
||||
// }
|
||||
|
||||
|
||||
//Used to ensure a unique name generated by appending -nnn is within length requirements by splitting and chopping part of text to keep name
|
||||
public static string UniqueNameBuilder(string oldName, long appendValue, int maxLength)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user