|
|
@ -38,6 +38,7 @@ namespace ServiceLib.Common
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Logging.SaveLog(ex.Message, ex);
|
|
|
|
Logging.SaveLog(ex.Message, ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -58,6 +59,7 @@ namespace ServiceLib.Common
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Logging.SaveLog(ex.Message, ex);
|
|
|
|
Logging.SaveLog(ex.Message, ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -92,6 +94,7 @@ namespace ServiceLib.Common
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Logging.SaveLog(ex.Message, ex);
|
|
|
|
Logging.SaveLog(ex.Message, ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return string.Empty;
|
|
|
|
return string.Empty;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -116,6 +119,7 @@ namespace ServiceLib.Common
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Logging.SaveLog(ex.Message, ex);
|
|
|
|
Logging.SaveLog(ex.Message, ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -137,6 +141,7 @@ namespace ServiceLib.Common
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Logging.SaveLog(ex.Message, ex);
|
|
|
|
Logging.SaveLog(ex.Message, ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -156,6 +161,7 @@ namespace ServiceLib.Common
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Logging.SaveLog("Base64Encode", ex);
|
|
|
|
Logging.SaveLog("Base64Encode", ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return string.Empty;
|
|
|
|
return string.Empty;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -189,6 +195,7 @@ namespace ServiceLib.Common
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Logging.SaveLog("Base64Decode", ex);
|
|
|
|
Logging.SaveLog("Base64Decode", ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return string.Empty;
|
|
|
|
return string.Empty;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -251,14 +258,17 @@ namespace ServiceLib.Common
|
|
|
|
unit = "TB";
|
|
|
|
unit = "TB";
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
result = GBs + ((MBs % factor) / (factor + 0.0));
|
|
|
|
result = GBs + ((MBs % factor) / (factor + 0.0));
|
|
|
|
unit = "GB";
|
|
|
|
unit = "GB";
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
result = MBs + ((KBs % factor) / (factor + 0.0));
|
|
|
|
result = MBs + ((KBs % factor) / (factor + 0.0));
|
|
|
|
unit = "MB";
|
|
|
|
unit = "MB";
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
result = KBs + ((amount % factor) / (factor + 0.0));
|
|
|
|
result = KBs + ((amount % factor) / (factor + 0.0));
|
|
|
|
unit = "KB";
|
|
|
|
unit = "KB";
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -302,6 +312,7 @@ namespace ServiceLib.Common
|
|
|
|
{
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var key = Uri.UnescapeDataString(keyValue[0]);
|
|
|
|
var key = Uri.UnescapeDataString(keyValue[0]);
|
|
|
|
var val = Uri.UnescapeDataString(keyValue[1]);
|
|
|
|
var val = Uri.UnescapeDataString(keyValue[1]);
|
|
|
|
|
|
|
|
|
|
|
@ -323,6 +334,7 @@ namespace ServiceLib.Common
|
|
|
|
{
|
|
|
|
{
|
|
|
|
sb.Append(b.ToString("x2"));
|
|
|
|
sb.Append(b.ToString("x2"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return sb.ToString();
|
|
|
|
return sb.ToString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -337,6 +349,7 @@ namespace ServiceLib.Common
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return url;
|
|
|
|
return url;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Uri uri = new(url);
|
|
|
|
Uri uri = new(url);
|
|
|
@ -368,6 +381,7 @@ namespace ServiceLib.Common
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return text;
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return text.Replace(",", ",").Replace(Environment.NewLine, ",");
|
|
|
|
return text.Replace(",", ",").Replace(Environment.NewLine, ",");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -391,6 +405,7 @@ namespace ServiceLib.Common
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return text == "null";
|
|
|
|
return text == "null";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -424,6 +439,7 @@ namespace ServiceLib.Common
|
|
|
|
_ => false,
|
|
|
|
_ => false,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -448,6 +464,7 @@ namespace ServiceLib.Common
|
|
|
|
if (ipBytes[0] == 172 && ipBytes[1] >= 16 && ipBytes[1] <= 31) return true;
|
|
|
|
if (ipBytes[0] == 172 && ipBytes[1] >= 16 && ipBytes[1] <= 31) return true;
|
|
|
|
if (ipBytes[0] == 192 && ipBytes[1] == 168) return true;
|
|
|
|
if (ipBytes[0] == 192 && ipBytes[1] == 168) return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -468,6 +485,7 @@ namespace ServiceLib.Common
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Logging.SaveLog(ex.Message, ex);
|
|
|
|
Logging.SaveLog(ex.Message, ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -489,6 +507,7 @@ namespace ServiceLib.Common
|
|
|
|
catch
|
|
|
|
catch
|
|
|
|
{
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return 59090;
|
|
|
|
return 59090;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -512,7 +531,8 @@ namespace ServiceLib.Common
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (blFull)
|
|
|
|
if (blFull)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return $"{Global.AppName} - V{GetVersionInfo()} - {RuntimeInformation.ProcessArchitecture} - {File.GetLastWriteTime(GetExePath()):yyyy/MM/dd}";
|
|
|
|
return
|
|
|
|
|
|
|
|
$"{Global.AppName} - V{GetVersionInfo()} - {RuntimeInformation.ProcessArchitecture} - {File.GetLastWriteTime(GetExePath()):yyyy/MM/dd}";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -523,6 +543,7 @@ namespace ServiceLib.Common
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Logging.SaveLog(ex.Message, ex);
|
|
|
|
Logging.SaveLog(ex.Message, ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return Global.AppName;
|
|
|
|
return Global.AppName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -560,6 +581,7 @@ namespace ServiceLib.Common
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Logging.SaveLog(ex.Message, ex);
|
|
|
|
Logging.SaveLog(ex.Message, ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return string.Empty;
|
|
|
|
return string.Empty;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -572,7 +594,11 @@ namespace ServiceLib.Common
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (fileName.IsNullOrEmpty()) { return; }
|
|
|
|
if (fileName.IsNullOrEmpty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Process.Start(new ProcessStartInfo(fileName, arguments) { UseShellExecute = true });
|
|
|
|
Process.Start(new ProcessStartInfo(fileName, arguments) { UseShellExecute = true });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
@ -605,6 +631,7 @@ namespace ServiceLib.Common
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Logging.SaveLog(ex.Message, ex);
|
|
|
|
Logging.SaveLog(ex.Message, ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return systemHosts;
|
|
|
|
return systemHosts;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -629,17 +656,20 @@ namespace ServiceLib.Common
|
|
|
|
cmd = cmd.WithArguments(args);
|
|
|
|
cmd = cmd.WithArguments(args);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var result = await cmd.ExecuteBufferedAsync();
|
|
|
|
var result = await cmd.ExecuteBufferedAsync();
|
|
|
|
if (result.IsSuccess)
|
|
|
|
if (result.IsSuccess)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return result.StandardOutput.ToString();
|
|
|
|
return result.StandardOutput.ToString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Logging.SaveLog(result.ToString() ?? "");
|
|
|
|
Logging.SaveLog(result.ToString() ?? "");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Logging.SaveLog("GetCliWrapOutput", ex);
|
|
|
|
Logging.SaveLog("GetCliWrapOutput", ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -654,6 +684,7 @@ namespace ServiceLib.Common
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return startupPath;
|
|
|
|
return startupPath;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return Path.Combine(startupPath, fileName);
|
|
|
|
return Path.Combine(startupPath, fileName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -674,6 +705,7 @@ namespace ServiceLib.Common
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Directory.CreateDirectory(tempPath);
|
|
|
|
Directory.CreateDirectory(tempPath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (IsNullOrEmpty(filename))
|
|
|
|
if (IsNullOrEmpty(filename))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return tempPath;
|
|
|
|
return tempPath;
|
|
|
@ -691,6 +723,7 @@ namespace ServiceLib.Common
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Directory.CreateDirectory(tempPath);
|
|
|
|
Directory.CreateDirectory(tempPath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return Path.Combine(tempPath, filename);
|
|
|
|
return Path.Combine(tempPath, filename);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -701,6 +734,7 @@ namespace ServiceLib.Common
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Directory.CreateDirectory(tempPath);
|
|
|
|
Directory.CreateDirectory(tempPath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (Utils.IsNullOrEmpty(filename))
|
|
|
|
if (Utils.IsNullOrEmpty(filename))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return tempPath;
|
|
|
|
return tempPath;
|
|
|
@ -718,6 +752,7 @@ namespace ServiceLib.Common
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Directory.CreateDirectory(tempPath);
|
|
|
|
Directory.CreateDirectory(tempPath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (coreType != null)
|
|
|
|
if (coreType != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
tempPath = Path.Combine(tempPath, coreType.ToLower().ToString());
|
|
|
|
tempPath = Path.Combine(tempPath, coreType.ToLower().ToString());
|
|
|
@ -726,6 +761,7 @@ namespace ServiceLib.Common
|
|
|
|
Directory.CreateDirectory(tempPath);
|
|
|
|
Directory.CreateDirectory(tempPath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (IsNullOrEmpty(filename))
|
|
|
|
if (IsNullOrEmpty(filename))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return tempPath;
|
|
|
|
return tempPath;
|
|
|
@ -743,6 +779,7 @@ namespace ServiceLib.Common
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Directory.CreateDirectory(tempPath);
|
|
|
|
Directory.CreateDirectory(tempPath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (Utils.IsNullOrEmpty(filename))
|
|
|
|
if (Utils.IsNullOrEmpty(filename))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return tempPath;
|
|
|
|
return tempPath;
|
|
|
@ -760,6 +797,7 @@ namespace ServiceLib.Common
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Directory.CreateDirectory(tempPath);
|
|
|
|
Directory.CreateDirectory(tempPath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (Utils.IsNullOrEmpty(filename))
|
|
|
|
if (Utils.IsNullOrEmpty(filename))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return tempPath;
|
|
|
|
return tempPath;
|
|
|
@ -825,6 +863,13 @@ namespace ServiceLib.Common
|
|
|
|
return await GetCliWrapOutput("/bin/bash", arg);
|
|
|
|
return await GetCliWrapOutput("/bin/bash", arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static string? GetHomePath()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return IsWindows()
|
|
|
|
|
|
|
|
? Environment.ExpandEnvironmentVariables("%HOMEDRIVE%%HOMEPATH%")
|
|
|
|
|
|
|
|
: Environment.GetEnvironmentVariable("HOME");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion Platform
|
|
|
|
#endregion Platform
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|