Move main ArchiLogger from ASF to Program

It makes more sense to put it in ASF class due to sharing potential, but I want to unify ArchiBoT logging and this makes it easier for maintenance
This commit is contained in:
JustArchi
2016-12-23 18:49:52 +01:00
parent 4219107d2b
commit 30c69cf57c
23 changed files with 192 additions and 190 deletions

View File

@@ -34,8 +34,6 @@ using ArchiSteamFarm.JSON;
namespace ArchiSteamFarm { namespace ArchiSteamFarm {
internal static class ASF { internal static class ASF {
internal static readonly ArchiLogger ArchiLogger = new ArchiLogger(SharedInfo.ASF);
private static readonly ConcurrentDictionary<Bot, DateTime> LastWriteTimes = new ConcurrentDictionary<Bot, DateTime>(); private static readonly ConcurrentDictionary<Bot, DateTime> LastWriteTimes = new ConcurrentDictionary<Bot, DateTime>();
private static Timer AutoUpdatesTimer; private static Timer AutoUpdatesTimer;
@@ -44,7 +42,7 @@ namespace ArchiSteamFarm {
internal static async Task CheckForUpdate(bool updateOverride = false) { internal static async Task CheckForUpdate(bool updateOverride = false) {
string exeFile = Assembly.GetEntryAssembly().Location; string exeFile = Assembly.GetEntryAssembly().Location;
if (string.IsNullOrEmpty(exeFile)) { if (string.IsNullOrEmpty(exeFile)) {
ArchiLogger.LogNullError(nameof(exeFile)); Program.ArchiLogger.LogNullError(nameof(exeFile));
return; return;
} }
@@ -58,8 +56,8 @@ namespace ArchiSteamFarm {
try { try {
File.Delete(oldExeFile); File.Delete(oldExeFile);
} catch (Exception e) { } catch (Exception e) {
ArchiLogger.LogGenericException(e); Program.ArchiLogger.LogGenericException(e);
ArchiLogger.LogGenericError("Could not remove old ASF binary, please remove " + oldExeFile + " manually in order for update function to work!"); Program.ArchiLogger.LogGenericError("Could not remove old ASF binary, please remove " + oldExeFile + " manually in order for update function to work!");
} }
} }
@@ -72,7 +70,7 @@ namespace ArchiSteamFarm {
TimeSpan.FromDays(1) // Period TimeSpan.FromDays(1) // Period
); );
ArchiLogger.LogGenericInfo("ASF will automatically check for new versions every 24 hours"); Program.ArchiLogger.LogGenericInfo("ASF will automatically check for new versions every 24 hours");
} }
string releaseURL = SharedInfo.GithubReleaseURL; string releaseURL = SharedInfo.GithubReleaseURL;
@@ -80,20 +78,20 @@ namespace ArchiSteamFarm {
releaseURL += "/latest"; releaseURL += "/latest";
} }
ArchiLogger.LogGenericInfo("Checking new version..."); Program.ArchiLogger.LogGenericInfo("Checking new version...");
GitHub.ReleaseResponse releaseResponse; GitHub.ReleaseResponse releaseResponse;
if (Program.GlobalConfig.UpdateChannel == GlobalConfig.EUpdateChannel.Stable) { if (Program.GlobalConfig.UpdateChannel == GlobalConfig.EUpdateChannel.Stable) {
releaseResponse = await Program.WebBrowser.UrlGetToJsonResultRetry<GitHub.ReleaseResponse>(releaseURL).ConfigureAwait(false); releaseResponse = await Program.WebBrowser.UrlGetToJsonResultRetry<GitHub.ReleaseResponse>(releaseURL).ConfigureAwait(false);
if (releaseResponse == null) { if (releaseResponse == null) {
ArchiLogger.LogGenericWarning("Could not check latest version!"); Program.ArchiLogger.LogGenericWarning("Could not check latest version!");
return; return;
} }
} else { } else {
List<GitHub.ReleaseResponse> releases = await Program.WebBrowser.UrlGetToJsonResultRetry<List<GitHub.ReleaseResponse>>(releaseURL).ConfigureAwait(false); List<GitHub.ReleaseResponse> releases = await Program.WebBrowser.UrlGetToJsonResultRetry<List<GitHub.ReleaseResponse>>(releaseURL).ConfigureAwait(false);
if ((releases == null) || (releases.Count == 0)) { if ((releases == null) || (releases.Count == 0)) {
ArchiLogger.LogGenericWarning("Could not check latest version!"); Program.ArchiLogger.LogGenericWarning("Could not check latest version!");
return; return;
} }
@@ -101,33 +99,33 @@ namespace ArchiSteamFarm {
} }
if (string.IsNullOrEmpty(releaseResponse.Tag)) { if (string.IsNullOrEmpty(releaseResponse.Tag)) {
ArchiLogger.LogGenericWarning("Could not check latest version!"); Program.ArchiLogger.LogGenericWarning("Could not check latest version!");
return; return;
} }
Version newVersion = new Version(releaseResponse.Tag); Version newVersion = new Version(releaseResponse.Tag);
ArchiLogger.LogGenericInfo("Local version: " + SharedInfo.Version + " | Remote version: " + newVersion); Program.ArchiLogger.LogGenericInfo("Local version: " + SharedInfo.Version + " | Remote version: " + newVersion);
if (SharedInfo.Version.CompareTo(newVersion) >= 0) { // If local version is the same or newer than remote version if (SharedInfo.Version.CompareTo(newVersion) >= 0) { // If local version is the same or newer than remote version
return; return;
} }
if (!updateOverride && !Program.GlobalConfig.AutoUpdates) { if (!updateOverride && !Program.GlobalConfig.AutoUpdates) {
ArchiLogger.LogGenericInfo("New version is available!"); Program.ArchiLogger.LogGenericInfo("New version is available!");
ArchiLogger.LogGenericInfo("Consider updating yourself!"); Program.ArchiLogger.LogGenericInfo("Consider updating yourself!");
await Task.Delay(5000).ConfigureAwait(false); await Task.Delay(5000).ConfigureAwait(false);
return; return;
} }
if (File.Exists(oldExeFile)) { if (File.Exists(oldExeFile)) {
ArchiLogger.LogGenericWarning("Refusing to proceed with auto update as old " + oldExeFile + " binary could not be removed, please remove it manually"); Program.ArchiLogger.LogGenericWarning("Refusing to proceed with auto update as old " + oldExeFile + " binary could not be removed, please remove it manually");
return; return;
} }
// Auto update logic starts here // Auto update logic starts here
if (releaseResponse.Assets == null) { if (releaseResponse.Assets == null) {
ArchiLogger.LogGenericWarning("Could not proceed with update because that version doesn't include assets!"); Program.ArchiLogger.LogGenericWarning("Could not proceed with update because that version doesn't include assets!");
return; return;
} }
@@ -135,17 +133,17 @@ namespace ArchiSteamFarm {
GitHub.ReleaseResponse.Asset binaryAsset = releaseResponse.Assets.FirstOrDefault(asset => !string.IsNullOrEmpty(asset.Name) && asset.Name.Equals(exeFileName, StringComparison.OrdinalIgnoreCase)); GitHub.ReleaseResponse.Asset binaryAsset = releaseResponse.Assets.FirstOrDefault(asset => !string.IsNullOrEmpty(asset.Name) && asset.Name.Equals(exeFileName, StringComparison.OrdinalIgnoreCase));
if (binaryAsset == null) { if (binaryAsset == null) {
ArchiLogger.LogGenericWarning("Could not proceed with update because there is no asset that relates to currently running binary!"); Program.ArchiLogger.LogGenericWarning("Could not proceed with update because there is no asset that relates to currently running binary!");
return; return;
} }
if (string.IsNullOrEmpty(binaryAsset.DownloadURL)) { if (string.IsNullOrEmpty(binaryAsset.DownloadURL)) {
ArchiLogger.LogGenericWarning("Could not proceed with update because download URL is empty!"); Program.ArchiLogger.LogGenericWarning("Could not proceed with update because download URL is empty!");
return; return;
} }
ArchiLogger.LogGenericInfo("Downloading new version..."); Program.ArchiLogger.LogGenericInfo("Downloading new version...");
ArchiLogger.LogGenericInfo("While waiting, consider donating if you appreciate the work being done :)"); Program.ArchiLogger.LogGenericInfo("While waiting, consider donating if you appreciate the work being done :)");
byte[] result = await Program.WebBrowser.UrlGetToBytesRetry(binaryAsset.DownloadURL).ConfigureAwait(false); byte[] result = await Program.WebBrowser.UrlGetToBytesRetry(binaryAsset.DownloadURL).ConfigureAwait(false);
if (result == null) { if (result == null) {
@@ -158,7 +156,7 @@ namespace ArchiSteamFarm {
try { try {
File.WriteAllBytes(newExeFile, result); File.WriteAllBytes(newExeFile, result);
} catch (Exception e) { } catch (Exception e) {
ArchiLogger.LogGenericException(e); Program.ArchiLogger.LogGenericException(e);
return; return;
} }
@@ -166,7 +164,7 @@ namespace ArchiSteamFarm {
try { try {
File.Move(exeFile, oldExeFile); File.Move(exeFile, oldExeFile);
} catch (Exception e) { } catch (Exception e) {
ArchiLogger.LogGenericException(e); Program.ArchiLogger.LogGenericException(e);
try { try {
// Cleanup // Cleanup
File.Delete(newExeFile); File.Delete(newExeFile);
@@ -180,7 +178,7 @@ namespace ArchiSteamFarm {
try { try {
File.Move(newExeFile, exeFile); File.Move(newExeFile, exeFile);
} catch (Exception e) { } catch (Exception e) {
ArchiLogger.LogGenericException(e); Program.ArchiLogger.LogGenericException(e);
try { try {
// Cleanup // Cleanup
File.Move(oldExeFile, exeFile); File.Move(oldExeFile, exeFile);
@@ -191,7 +189,7 @@ namespace ArchiSteamFarm {
return; return;
} }
ArchiLogger.LogGenericInfo("Update process finished!"); Program.ArchiLogger.LogGenericInfo("Update process finished!");
await RestartOrExit().ConfigureAwait(false); await RestartOrExit().ConfigureAwait(false);
} }
@@ -215,7 +213,7 @@ namespace ArchiSteamFarm {
} }
if (Bot.Bots.Count == 0) { if (Bot.Bots.Count == 0) {
ArchiLogger.LogGenericWarning("No bots are defined, did you forget to configure your ASF?"); Program.ArchiLogger.LogGenericWarning("No bots are defined, did you forget to configure your ASF?");
} }
} }
@@ -238,7 +236,7 @@ namespace ArchiSteamFarm {
private static async Task CreateBot(string botName) { private static async Task CreateBot(string botName) {
if (string.IsNullOrEmpty(botName)) { if (string.IsNullOrEmpty(botName)) {
ArchiLogger.LogNullError(nameof(botName)); Program.ArchiLogger.LogNullError(nameof(botName));
return; return;
} }
@@ -258,7 +256,7 @@ namespace ArchiSteamFarm {
private static async void OnChanged(object sender, FileSystemEventArgs e) { private static async void OnChanged(object sender, FileSystemEventArgs e) {
if ((sender == null) || (e == null)) { if ((sender == null) || (e == null)) {
ArchiLogger.LogNullError(nameof(sender) + " || " + nameof(e)); Program.ArchiLogger.LogNullError(nameof(sender) + " || " + nameof(e));
return; return;
} }
@@ -268,7 +266,7 @@ namespace ArchiSteamFarm {
} }
if (botName.Equals(SharedInfo.ASF)) { if (botName.Equals(SharedInfo.ASF)) {
ArchiLogger.LogGenericWarning("Global config file has been changed!"); Program.ArchiLogger.LogGenericWarning("Global config file has been changed!");
await RestartOrExit().ConfigureAwait(false); await RestartOrExit().ConfigureAwait(false);
return; return;
} }
@@ -310,7 +308,7 @@ namespace ArchiSteamFarm {
private static void OnCreated(object sender, FileSystemEventArgs e) { private static void OnCreated(object sender, FileSystemEventArgs e) {
if ((sender == null) || (e == null)) { if ((sender == null) || (e == null)) {
ArchiLogger.LogNullError(nameof(sender) + " || " + nameof(e)); Program.ArchiLogger.LogNullError(nameof(sender) + " || " + nameof(e));
return; return;
} }
@@ -324,7 +322,7 @@ namespace ArchiSteamFarm {
private static void OnDeleted(object sender, FileSystemEventArgs e) { private static void OnDeleted(object sender, FileSystemEventArgs e) {
if ((sender == null) || (e == null)) { if ((sender == null) || (e == null)) {
ArchiLogger.LogNullError(nameof(sender) + " || " + nameof(e)); Program.ArchiLogger.LogNullError(nameof(sender) + " || " + nameof(e));
return; return;
} }
@@ -334,7 +332,7 @@ namespace ArchiSteamFarm {
} }
if (botName.Equals(SharedInfo.ASF)) { if (botName.Equals(SharedInfo.ASF)) {
ArchiLogger.LogGenericError("Global config file has been removed, exiting..."); Program.ArchiLogger.LogGenericError("Global config file has been removed, exiting...");
Program.Exit(1); Program.Exit(1);
return; return;
} }
@@ -347,7 +345,7 @@ namespace ArchiSteamFarm {
private static void OnRenamed(object sender, RenamedEventArgs e) { private static void OnRenamed(object sender, RenamedEventArgs e) {
if ((sender == null) || (e == null)) { if ((sender == null) || (e == null)) {
ArchiLogger.LogNullError(nameof(sender) + " || " + nameof(e)); Program.ArchiLogger.LogNullError(nameof(sender) + " || " + nameof(e));
return; return;
} }
@@ -357,7 +355,7 @@ namespace ArchiSteamFarm {
} }
if (oldBotName.Equals(SharedInfo.ASF)) { if (oldBotName.Equals(SharedInfo.ASF)) {
ArchiLogger.LogGenericError("Global config file has been renamed, exiting..."); Program.ArchiLogger.LogGenericError("Global config file has been renamed, exiting...");
Program.Exit(1); Program.Exit(1);
return; return;
} }
@@ -377,11 +375,11 @@ namespace ArchiSteamFarm {
private static async Task RestartOrExit() { private static async Task RestartOrExit() {
if (Program.GlobalConfig.AutoRestart) { if (Program.GlobalConfig.AutoRestart) {
ArchiLogger.LogGenericInfo("Restarting..."); Program.ArchiLogger.LogGenericInfo("Restarting...");
await Task.Delay(5000).ConfigureAwait(false); await Task.Delay(5000).ConfigureAwait(false);
Program.Restart(); Program.Restart();
} else { } else {
ArchiLogger.LogGenericInfo("Exiting..."); Program.ArchiLogger.LogGenericInfo("Exiting...");
await Task.Delay(5000).ConfigureAwait(false); await Task.Delay(5000).ConfigureAwait(false);
Program.Exit(); Program.Exit();
} }

View File

@@ -395,7 +395,7 @@ namespace ArchiSteamFarm {
KeyValue receiptInfo = new KeyValue(); KeyValue receiptInfo = new KeyValue();
using (MemoryStream ms = new MemoryStream(msg.purchase_receipt_info)) { using (MemoryStream ms = new MemoryStream(msg.purchase_receipt_info)) {
if (!receiptInfo.TryReadAsBinary(ms)) { if (!receiptInfo.TryReadAsBinary(ms)) {
ASF.ArchiLogger.LogNullError(nameof(ms)); Program.ArchiLogger.LogNullError(nameof(ms));
return; return;
} }
} }
@@ -412,14 +412,14 @@ namespace ArchiSteamFarm {
// Valid, coupons have PackageID of -1 (don't ask me why) // Valid, coupons have PackageID of -1 (don't ask me why)
packageID = lineItem["ItemAppID"].AsUnsignedInteger(); packageID = lineItem["ItemAppID"].AsUnsignedInteger();
if (packageID == 0) { if (packageID == 0) {
ASF.ArchiLogger.LogNullError(nameof(packageID)); Program.ArchiLogger.LogNullError(nameof(packageID));
return; return;
} }
} }
string gameName = lineItem["ItemDescription"].Value; string gameName = lineItem["ItemDescription"].Value;
if (string.IsNullOrEmpty(gameName)) { if (string.IsNullOrEmpty(gameName)) {
ASF.ArchiLogger.LogNullError(nameof(gameName)); Program.ArchiLogger.LogNullError(nameof(gameName));
return; return;
} }

View File

@@ -950,7 +950,7 @@ namespace ArchiSteamFarm {
private static uint GetAppIDFromMarketHashName(string hashName) { private static uint GetAppIDFromMarketHashName(string hashName) {
if (string.IsNullOrEmpty(hashName)) { if (string.IsNullOrEmpty(hashName)) {
ASF.ArchiLogger.LogNullError(nameof(hashName)); Program.ArchiLogger.LogNullError(nameof(hashName));
return 0; return 0;
} }
@@ -965,7 +965,7 @@ namespace ArchiSteamFarm {
private static Steam.Item.EType GetItemType(string name) { private static Steam.Item.EType GetItemType(string name) {
if (string.IsNullOrEmpty(name)) { if (string.IsNullOrEmpty(name)) {
ASF.ArchiLogger.LogNullError(nameof(name)); Program.ArchiLogger.LogNullError(nameof(name));
return Steam.Item.EType.Unknown; return Steam.Item.EType.Unknown;
} }
@@ -1006,32 +1006,32 @@ namespace ArchiSteamFarm {
private static bool ParseItems(Dictionary<ulong, Tuple<uint, Steam.Item.EType>> descriptions, List<KeyValue> input, HashSet<Steam.Item> output) { private static bool ParseItems(Dictionary<ulong, Tuple<uint, Steam.Item.EType>> descriptions, List<KeyValue> input, HashSet<Steam.Item> output) {
if ((descriptions == null) || (input == null) || (input.Count == 0) || (output == null)) { if ((descriptions == null) || (input == null) || (input.Count == 0) || (output == null)) {
ASF.ArchiLogger.LogNullError(nameof(descriptions) + " || " + nameof(input) + " || " + nameof(output)); Program.ArchiLogger.LogNullError(nameof(descriptions) + " || " + nameof(input) + " || " + nameof(output));
return false; return false;
} }
foreach (KeyValue item in input) { foreach (KeyValue item in input) {
uint appID = item["appid"].AsUnsignedInteger(); uint appID = item["appid"].AsUnsignedInteger();
if (appID == 0) { if (appID == 0) {
ASF.ArchiLogger.LogNullError(nameof(appID)); Program.ArchiLogger.LogNullError(nameof(appID));
return false; return false;
} }
ulong contextID = item["contextid"].AsUnsignedLong(); ulong contextID = item["contextid"].AsUnsignedLong();
if (contextID == 0) { if (contextID == 0) {
ASF.ArchiLogger.LogNullError(nameof(contextID)); Program.ArchiLogger.LogNullError(nameof(contextID));
return false; return false;
} }
ulong classID = item["classid"].AsUnsignedLong(); ulong classID = item["classid"].AsUnsignedLong();
if (classID == 0) { if (classID == 0) {
ASF.ArchiLogger.LogNullError(nameof(classID)); Program.ArchiLogger.LogNullError(nameof(classID));
return false; return false;
} }
uint amount = item["amount"].AsUnsignedInteger(); uint amount = item["amount"].AsUnsignedInteger();
if (amount == 0) { if (amount == 0) {
ASF.ArchiLogger.LogNullError(nameof(amount)); Program.ArchiLogger.LogNullError(nameof(amount));
return false; return false;
} }

View File

@@ -297,14 +297,14 @@ namespace ArchiSteamFarm {
try { try {
return JsonConvert.SerializeObject(response); return JsonConvert.SerializeObject(response);
} catch (JsonException e) { } catch (JsonException e) {
ASF.ArchiLogger.LogGenericException(e); Program.ArchiLogger.LogGenericException(e);
return null; return null;
} }
} }
internal static void InitializeCMs(uint cellID, IServerListProvider serverListProvider) { internal static void InitializeCMs(uint cellID, IServerListProvider serverListProvider) {
if (serverListProvider == null) { if (serverListProvider == null) {
ASF.ArchiLogger.LogNullError(nameof(serverListProvider)); Program.ArchiLogger.LogNullError(nameof(serverListProvider));
return; return;
} }
@@ -824,7 +824,7 @@ namespace ArchiSteamFarm {
return (steamID == Program.GlobalConfig.SteamOwnerID) || (Debugging.IsDebugBuild && (steamID == SharedInfo.ArchiSteamID)); return (steamID == Program.GlobalConfig.SteamOwnerID) || (Debugging.IsDebugBuild && (steamID == SharedInfo.ArchiSteamID));
} }
ASF.ArchiLogger.LogNullError(nameof(steamID)); Program.ArchiLogger.LogNullError(nameof(steamID));
return false; return false;
} }
@@ -833,7 +833,7 @@ namespace ArchiSteamFarm {
return Regex.IsMatch(key, @"^[0-9A-Z]{4,7}-[0-9A-Z]{4,7}-[0-9A-Z]{4,7}(?:(?:-[0-9A-Z]{4,7})?(?:-[0-9A-Z]{4,7}))?$", RegexOptions.IgnoreCase); return Regex.IsMatch(key, @"^[0-9A-Z]{4,7}-[0-9A-Z]{4,7}-[0-9A-Z]{4,7}(?:(?:-[0-9A-Z]{4,7})?(?:-[0-9A-Z]{4,7}))?$", RegexOptions.IgnoreCase);
} }
ASF.ArchiLogger.LogNullError(nameof(key)); Program.ArchiLogger.LogNullError(nameof(key));
return false; return false;
} }
@@ -1504,7 +1504,7 @@ namespace ArchiSteamFarm {
private static async Task<string> Response2FA(ulong steamID, string botName) { private static async Task<string> Response2FA(ulong steamID, string botName) {
if ((steamID == 0) || string.IsNullOrEmpty(botName)) { if ((steamID == 0) || string.IsNullOrEmpty(botName)) {
ASF.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botName)); Program.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botName));
return null; return null;
} }
@@ -1543,7 +1543,7 @@ namespace ArchiSteamFarm {
private static async Task<string> Response2FAConfirm(ulong steamID, string botName, bool confirm) { private static async Task<string> Response2FAConfirm(ulong steamID, string botName, bool confirm) {
if ((steamID == 0) || string.IsNullOrEmpty(botName)) { if ((steamID == 0) || string.IsNullOrEmpty(botName)) {
ASF.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botName)); Program.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botName));
return null; return null;
} }
@@ -1595,7 +1595,7 @@ namespace ArchiSteamFarm {
private static async Task<string> ResponseAddLicense(ulong steamID, string botName, string games) { private static async Task<string> ResponseAddLicense(ulong steamID, string botName, string games) {
if ((steamID == 0) || string.IsNullOrEmpty(botName) || string.IsNullOrEmpty(games)) { if ((steamID == 0) || string.IsNullOrEmpty(botName) || string.IsNullOrEmpty(games)) {
ASF.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botName) + " || " + nameof(games)); Program.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botName) + " || " + nameof(games));
return null; return null;
} }
@@ -1632,13 +1632,13 @@ namespace ArchiSteamFarm {
return !IsOwner(steamID) ? null : GetAPIStatus(); return !IsOwner(steamID) ? null : GetAPIStatus();
} }
ASF.ArchiLogger.LogNullError(nameof(steamID)); Program.ArchiLogger.LogNullError(nameof(steamID));
return null; return null;
} }
private static string ResponseExit(ulong steamID) { private static string ResponseExit(ulong steamID) {
if (steamID == 0) { if (steamID == 0) {
ASF.ArchiLogger.LogNullError(nameof(steamID)); Program.ArchiLogger.LogNullError(nameof(steamID));
return null; return null;
} }
@@ -1676,7 +1676,7 @@ namespace ArchiSteamFarm {
private static async Task<string> ResponseFarm(ulong steamID, string botName) { private static async Task<string> ResponseFarm(ulong steamID, string botName) {
if ((steamID == 0) || string.IsNullOrEmpty(botName)) { if ((steamID == 0) || string.IsNullOrEmpty(botName)) {
ASF.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botName)); Program.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botName));
return null; return null;
} }
@@ -1756,7 +1756,7 @@ namespace ArchiSteamFarm {
private static async Task<string> ResponseLoot(ulong steamID, string botName) { private static async Task<string> ResponseLoot(ulong steamID, string botName) {
if ((steamID == 0) || string.IsNullOrEmpty(botName)) { if ((steamID == 0) || string.IsNullOrEmpty(botName)) {
ASF.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botName)); Program.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botName));
return null; return null;
} }
@@ -1774,7 +1774,7 @@ namespace ArchiSteamFarm {
private static async Task<string> ResponseLootAll(ulong steamID) { private static async Task<string> ResponseLootAll(ulong steamID) {
if (steamID == 0) { if (steamID == 0) {
ASF.ArchiLogger.LogNullError(nameof(steamID)); Program.ArchiLogger.LogNullError(nameof(steamID));
return null; return null;
} }
@@ -1802,7 +1802,7 @@ namespace ArchiSteamFarm {
private static string ResponseLootSwitch(ulong steamID, string botName) { private static string ResponseLootSwitch(ulong steamID, string botName) {
if ((steamID == 0) || string.IsNullOrEmpty(botName)) { if ((steamID == 0) || string.IsNullOrEmpty(botName)) {
ASF.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botName)); Program.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botName));
return null; return null;
} }
@@ -1875,7 +1875,7 @@ namespace ArchiSteamFarm {
private static async Task<string> ResponseOwns(ulong steamID, string botName, string query) { private static async Task<string> ResponseOwns(ulong steamID, string botName, string query) {
if ((steamID == 0) || string.IsNullOrEmpty(botName) || string.IsNullOrEmpty(query)) { if ((steamID == 0) || string.IsNullOrEmpty(botName) || string.IsNullOrEmpty(query)) {
ASF.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botName) + " || " + nameof(query)); Program.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botName) + " || " + nameof(query));
return null; return null;
} }
@@ -1893,7 +1893,7 @@ namespace ArchiSteamFarm {
private static async Task<string> ResponseOwnsAll(ulong steamID, string query) { private static async Task<string> ResponseOwnsAll(ulong steamID, string query) {
if ((steamID == 0) || string.IsNullOrEmpty(query)) { if ((steamID == 0) || string.IsNullOrEmpty(query)) {
ASF.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(query)); Program.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(query));
return null; return null;
} }
@@ -1930,7 +1930,7 @@ namespace ArchiSteamFarm {
private static string ResponsePassword(ulong steamID, string botName) { private static string ResponsePassword(ulong steamID, string botName) {
if ((steamID == 0) || string.IsNullOrEmpty(botName)) { if ((steamID == 0) || string.IsNullOrEmpty(botName)) {
ASF.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botName)); Program.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botName));
return null; return null;
} }
@@ -1976,7 +1976,7 @@ namespace ArchiSteamFarm {
private static async Task<string> ResponsePause(ulong steamID, string botName, bool sticky) { private static async Task<string> ResponsePause(ulong steamID, string botName, bool sticky) {
if ((steamID == 0) || string.IsNullOrEmpty(botName)) { if ((steamID == 0) || string.IsNullOrEmpty(botName)) {
ASF.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botName)); Program.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botName));
return null; return null;
} }
@@ -2016,7 +2016,7 @@ namespace ArchiSteamFarm {
private static async Task<string> ResponsePlay(ulong steamID, string botName, string games) { private static async Task<string> ResponsePlay(ulong steamID, string botName, string games) {
if ((steamID == 0) || string.IsNullOrEmpty(botName) || string.IsNullOrEmpty(games)) { if ((steamID == 0) || string.IsNullOrEmpty(botName) || string.IsNullOrEmpty(games)) {
ASF.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botName) + " || " + nameof(games)); Program.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botName) + " || " + nameof(games));
return null; return null;
} }
@@ -2179,7 +2179,7 @@ namespace ArchiSteamFarm {
private static async Task<string> ResponseRedeem(ulong steamID, string botName, string message, ERedeemFlags redeemFlags = ERedeemFlags.None) { private static async Task<string> ResponseRedeem(ulong steamID, string botName, string message, ERedeemFlags redeemFlags = ERedeemFlags.None) {
if ((steamID == 0) || string.IsNullOrEmpty(botName) || string.IsNullOrEmpty(message)) { if ((steamID == 0) || string.IsNullOrEmpty(botName) || string.IsNullOrEmpty(message)) {
ASF.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botName) + " || " + nameof(message)); Program.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botName) + " || " + nameof(message));
return null; return null;
} }
@@ -2197,7 +2197,7 @@ namespace ArchiSteamFarm {
private static string ResponseRejoinChat(ulong steamID) { private static string ResponseRejoinChat(ulong steamID) {
if (steamID == 0) { if (steamID == 0) {
ASF.ArchiLogger.LogNullError(nameof(steamID)); Program.ArchiLogger.LogNullError(nameof(steamID));
return null; return null;
} }
@@ -2214,7 +2214,7 @@ namespace ArchiSteamFarm {
private static string ResponseRestart(ulong steamID) { private static string ResponseRestart(ulong steamID) {
if (steamID == 0) { if (steamID == 0) {
ASF.ArchiLogger.LogNullError(nameof(steamID)); Program.ArchiLogger.LogNullError(nameof(steamID));
return null; return null;
} }
@@ -2256,7 +2256,7 @@ namespace ArchiSteamFarm {
private static string ResponseResume(ulong steamID, string botName) { private static string ResponseResume(ulong steamID, string botName) {
if ((steamID == 0) || string.IsNullOrEmpty(botName)) { if ((steamID == 0) || string.IsNullOrEmpty(botName)) {
ASF.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botName)); Program.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botName));
return null; return null;
} }
@@ -2293,7 +2293,7 @@ namespace ArchiSteamFarm {
private static string ResponseStart(ulong steamID, string botName) { private static string ResponseStart(ulong steamID, string botName) {
if ((steamID == 0) || string.IsNullOrEmpty(botName)) { if ((steamID == 0) || string.IsNullOrEmpty(botName)) {
ASF.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botName)); Program.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botName));
return null; return null;
} }
@@ -2311,7 +2311,7 @@ namespace ArchiSteamFarm {
private static string ResponseStartAll(ulong steamID) { private static string ResponseStartAll(ulong steamID) {
if (steamID == 0) { if (steamID == 0) {
ASF.ArchiLogger.LogNullError(nameof(steamID)); Program.ArchiLogger.LogNullError(nameof(steamID));
return null; return null;
} }
@@ -2375,7 +2375,7 @@ namespace ArchiSteamFarm {
private static string ResponseStatus(ulong steamID, string botName) { private static string ResponseStatus(ulong steamID, string botName) {
if ((steamID == 0) || string.IsNullOrEmpty(botName)) { if ((steamID == 0) || string.IsNullOrEmpty(botName)) {
ASF.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botName)); Program.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botName));
return null; return null;
} }
@@ -2393,7 +2393,7 @@ namespace ArchiSteamFarm {
private static string ResponseStatusAll(ulong steamID) { private static string ResponseStatusAll(ulong steamID) {
if (steamID == 0) { if (steamID == 0) {
ASF.ArchiLogger.LogNullError(nameof(steamID)); Program.ArchiLogger.LogNullError(nameof(steamID));
return null; return null;
} }
@@ -2427,7 +2427,7 @@ namespace ArchiSteamFarm {
private static string ResponseStop(ulong steamID, string botName) { private static string ResponseStop(ulong steamID, string botName) {
if ((steamID == 0) || string.IsNullOrEmpty(botName)) { if ((steamID == 0) || string.IsNullOrEmpty(botName)) {
ASF.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botName)); Program.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botName));
return null; return null;
} }
@@ -2454,7 +2454,7 @@ namespace ArchiSteamFarm {
private static async Task<string> ResponseUpdate(ulong steamID) { private static async Task<string> ResponseUpdate(ulong steamID) {
if (steamID == 0) { if (steamID == 0) {
ASF.ArchiLogger.LogNullError(nameof(steamID)); Program.ArchiLogger.LogNullError(nameof(steamID));
return null; return null;
} }

View File

@@ -121,7 +121,7 @@ namespace ArchiSteamFarm {
internal static BotConfig Load(string filePath) { internal static BotConfig Load(string filePath) {
if (string.IsNullOrEmpty(filePath)) { if (string.IsNullOrEmpty(filePath)) {
ASF.ArchiLogger.LogNullError(nameof(filePath)); Program.ArchiLogger.LogNullError(nameof(filePath));
return null; return null;
} }
@@ -134,12 +134,12 @@ namespace ArchiSteamFarm {
try { try {
botConfig = JsonConvert.DeserializeObject<BotConfig>(File.ReadAllText(filePath)); botConfig = JsonConvert.DeserializeObject<BotConfig>(File.ReadAllText(filePath));
} catch (Exception e) { } catch (Exception e) {
ASF.ArchiLogger.LogGenericException(e); Program.ArchiLogger.LogGenericException(e);
return null; return null;
} }
if (botConfig == null) { if (botConfig == null) {
ASF.ArchiLogger.LogNullError(nameof(botConfig)); Program.ArchiLogger.LogNullError(nameof(botConfig));
return null; return null;
} }
@@ -155,7 +155,7 @@ namespace ArchiSteamFarm {
return botConfig; return botConfig;
} }
ASF.ArchiLogger.LogGenericWarning("Playing more than " + CardsFarmer.MaxGamesPlayedConcurrently + " games concurrently is not possible, only first " + CardsFarmer.MaxGamesPlayedConcurrently + " entries from GamesPlayedWhileIdle will be used"); Program.ArchiLogger.LogGenericWarning("Playing more than " + CardsFarmer.MaxGamesPlayedConcurrently + " games concurrently is not possible, only first " + CardsFarmer.MaxGamesPlayedConcurrently + " entries from GamesPlayedWhileIdle will be used");
HashSet<uint> validGames = new HashSet<uint>(botConfig.GamesPlayedWhileIdle.Take(CardsFarmer.MaxGamesPlayedConcurrently)); HashSet<uint> validGames = new HashSet<uint>(botConfig.GamesPlayedWhileIdle.Take(CardsFarmer.MaxGamesPlayedConcurrently));
botConfig.GamesPlayedWhileIdle.IntersectWith(validGames); botConfig.GamesPlayedWhileIdle.IntersectWith(validGames);

View File

@@ -82,7 +82,7 @@ namespace ArchiSteamFarm {
internal static BotDatabase Load(string filePath) { internal static BotDatabase Load(string filePath) {
if (string.IsNullOrEmpty(filePath)) { if (string.IsNullOrEmpty(filePath)) {
ASF.ArchiLogger.LogNullError(nameof(filePath)); Program.ArchiLogger.LogNullError(nameof(filePath));
return null; return null;
} }
@@ -95,12 +95,12 @@ namespace ArchiSteamFarm {
try { try {
botDatabase = JsonConvert.DeserializeObject<BotDatabase>(File.ReadAllText(filePath)); botDatabase = JsonConvert.DeserializeObject<BotDatabase>(File.ReadAllText(filePath));
} catch (Exception e) { } catch (Exception e) {
ASF.ArchiLogger.LogGenericException(e); Program.ArchiLogger.LogGenericException(e);
return null; return null;
} }
if (botDatabase == null) { if (botDatabase == null) {
ASF.ArchiLogger.LogNullError(nameof(botDatabase)); Program.ArchiLogger.LogNullError(nameof(botDatabase));
return null; return null;
} }
@@ -111,7 +111,7 @@ namespace ArchiSteamFarm {
internal void Save() { internal void Save() {
string json = JsonConvert.SerializeObject(this); string json = JsonConvert.SerializeObject(this);
if (string.IsNullOrEmpty(json)) { if (string.IsNullOrEmpty(json)) {
ASF.ArchiLogger.LogNullError(nameof(json)); Program.ArchiLogger.LogNullError(nameof(json));
return; return;
} }
@@ -121,7 +121,7 @@ namespace ArchiSteamFarm {
File.WriteAllText(FilePath, json); File.WriteAllText(FilePath, json);
break; break;
} catch (Exception e) { } catch (Exception e) {
ASF.ArchiLogger.LogGenericException(e); Program.ArchiLogger.LogGenericException(e);
} }
Thread.Sleep(1000); Thread.Sleep(1000);

View File

@@ -33,7 +33,7 @@ namespace ArchiSteamFarm.CMsgs {
void ISteamSerializable.Deserialize(Stream stream) { void ISteamSerializable.Deserialize(Stream stream) {
if (stream == null) { if (stream == null) {
ASF.ArchiLogger.LogNullError(nameof(stream)); Program.ArchiLogger.LogNullError(nameof(stream));
return; return;
} }
@@ -46,7 +46,7 @@ namespace ArchiSteamFarm.CMsgs {
void ISteamSerializable.Serialize(Stream stream) { void ISteamSerializable.Serialize(Stream stream) {
if (stream == null) { if (stream == null) {
ASF.ArchiLogger.LogNullError(nameof(stream)); Program.ArchiLogger.LogNullError(nameof(stream));
return; return;
} }

View File

@@ -32,7 +32,7 @@ namespace ArchiSteamFarm {
internal static string Decrypt(ECryptoMethod cryptoMethod, string encrypted) { internal static string Decrypt(ECryptoMethod cryptoMethod, string encrypted) {
if (string.IsNullOrEmpty(encrypted)) { if (string.IsNullOrEmpty(encrypted)) {
ASF.ArchiLogger.LogNullError(nameof(encrypted)); Program.ArchiLogger.LogNullError(nameof(encrypted));
return null; return null;
} }
@@ -50,7 +50,7 @@ namespace ArchiSteamFarm {
internal static string Encrypt(ECryptoMethod cryptoMethod, string decrypted) { internal static string Encrypt(ECryptoMethod cryptoMethod, string decrypted) {
if (string.IsNullOrEmpty(decrypted)) { if (string.IsNullOrEmpty(decrypted)) {
ASF.ArchiLogger.LogNullError(nameof(decrypted)); Program.ArchiLogger.LogNullError(nameof(decrypted));
return null; return null;
} }
@@ -68,7 +68,7 @@ namespace ArchiSteamFarm {
internal static void SetEncryptionKey(string key) { internal static void SetEncryptionKey(string key) {
if (string.IsNullOrEmpty(key)) { if (string.IsNullOrEmpty(key)) {
ASF.ArchiLogger.LogNullError(nameof(key)); Program.ArchiLogger.LogNullError(nameof(key));
return; return;
} }
@@ -77,7 +77,7 @@ namespace ArchiSteamFarm {
private static string DecryptAES(string encrypted) { private static string DecryptAES(string encrypted) {
if (string.IsNullOrEmpty(encrypted)) { if (string.IsNullOrEmpty(encrypted)) {
ASF.ArchiLogger.LogNullError(nameof(encrypted)); Program.ArchiLogger.LogNullError(nameof(encrypted));
return null; return null;
} }
@@ -91,14 +91,14 @@ namespace ArchiSteamFarm {
decryptedData = SteamKit2.CryptoHelper.SymmetricDecrypt(decryptedData, key); decryptedData = SteamKit2.CryptoHelper.SymmetricDecrypt(decryptedData, key);
return Encoding.UTF8.GetString(decryptedData); return Encoding.UTF8.GetString(decryptedData);
} catch (Exception e) { } catch (Exception e) {
ASF.ArchiLogger.LogGenericException(e); Program.ArchiLogger.LogGenericException(e);
return null; return null;
} }
} }
private static string DecryptProtectedDataForCurrentUser(string encrypted) { private static string DecryptProtectedDataForCurrentUser(string encrypted) {
if (string.IsNullOrEmpty(encrypted)) { if (string.IsNullOrEmpty(encrypted)) {
ASF.ArchiLogger.LogNullError(nameof(encrypted)); Program.ArchiLogger.LogNullError(nameof(encrypted));
return null; return null;
} }
@@ -108,14 +108,14 @@ namespace ArchiSteamFarm {
return Encoding.UTF8.GetString(decryptedData); return Encoding.UTF8.GetString(decryptedData);
} catch (Exception e) { } catch (Exception e) {
ASF.ArchiLogger.LogGenericException(e); Program.ArchiLogger.LogGenericException(e);
return null; return null;
} }
} }
private static string EncryptAES(string decrypted) { private static string EncryptAES(string decrypted) {
if (string.IsNullOrEmpty(decrypted)) { if (string.IsNullOrEmpty(decrypted)) {
ASF.ArchiLogger.LogNullError(nameof(decrypted)); Program.ArchiLogger.LogNullError(nameof(decrypted));
return null; return null;
} }
@@ -129,14 +129,14 @@ namespace ArchiSteamFarm {
encryptedData = SteamKit2.CryptoHelper.SymmetricEncrypt(encryptedData, key); encryptedData = SteamKit2.CryptoHelper.SymmetricEncrypt(encryptedData, key);
return Convert.ToBase64String(encryptedData); return Convert.ToBase64String(encryptedData);
} catch (Exception e) { } catch (Exception e) {
ASF.ArchiLogger.LogGenericException(e); Program.ArchiLogger.LogGenericException(e);
return null; return null;
} }
} }
private static string EncryptProtectedDataForCurrentUser(string decrypted) { private static string EncryptProtectedDataForCurrentUser(string decrypted) {
if (string.IsNullOrEmpty(decrypted)) { if (string.IsNullOrEmpty(decrypted)) {
ASF.ArchiLogger.LogNullError(nameof(decrypted)); Program.ArchiLogger.LogNullError(nameof(decrypted));
return null; return null;
} }
@@ -146,7 +146,7 @@ namespace ArchiSteamFarm {
return Convert.ToBase64String(encryptedData); return Convert.ToBase64String(encryptedData);
} catch (Exception e) { } catch (Exception e) {
ASF.ArchiLogger.LogGenericException(e); Program.ArchiLogger.LogGenericException(e);
return null; return null;
} }
} }

View File

@@ -38,11 +38,11 @@ namespace ArchiSteamFarm {
internal sealed class DebugListener : IDebugListener { internal sealed class DebugListener : IDebugListener {
public void WriteLine(string category, string msg) { public void WriteLine(string category, string msg) {
if (string.IsNullOrEmpty(category) && string.IsNullOrEmpty(msg)) { if (string.IsNullOrEmpty(category) && string.IsNullOrEmpty(msg)) {
ASF.ArchiLogger.LogNullError(nameof(category) + " && " + nameof(msg)); Program.ArchiLogger.LogNullError(nameof(category) + " && " + nameof(msg));
return; return;
} }
ASF.ArchiLogger.LogGenericDebug(category + " | " + msg); Program.ArchiLogger.LogGenericDebug(category + " | " + msg);
} }
} }
} }

View File

@@ -33,7 +33,7 @@ namespace ArchiSteamFarm {
return; return;
} }
ASF.ArchiLogger.LogGenericInfo("No bots are running, exiting"); Program.ArchiLogger.LogGenericInfo("No bots are running, exiting");
await Task.Delay(5000).ConfigureAwait(false); await Task.Delay(5000).ConfigureAwait(false);
Program.Shutdown(); Program.Shutdown();
} }

View File

@@ -109,7 +109,7 @@ namespace ArchiSteamFarm {
internal static GlobalConfig Load(string filePath) { internal static GlobalConfig Load(string filePath) {
if (string.IsNullOrEmpty(filePath)) { if (string.IsNullOrEmpty(filePath)) {
ASF.ArchiLogger.LogNullError(nameof(filePath)); Program.ArchiLogger.LogNullError(nameof(filePath));
return null; return null;
} }
@@ -122,12 +122,12 @@ namespace ArchiSteamFarm {
try { try {
globalConfig = JsonConvert.DeserializeObject<GlobalConfig>(File.ReadAllText(filePath)); globalConfig = JsonConvert.DeserializeObject<GlobalConfig>(File.ReadAllText(filePath));
} catch (Exception e) { } catch (Exception e) {
ASF.ArchiLogger.LogGenericException(e); Program.ArchiLogger.LogGenericException(e);
return null; return null;
} }
if (globalConfig == null) { if (globalConfig == null) {
ASF.ArchiLogger.LogNullError(nameof(globalConfig)); Program.ArchiLogger.LogNullError(nameof(globalConfig));
return null; return null;
} }
@@ -138,24 +138,24 @@ namespace ArchiSteamFarm {
case ProtocolType.Udp: case ProtocolType.Udp:
break; break;
default: default:
ASF.ArchiLogger.LogGenericWarning("Configured SteamProtocol is invalid: " + globalConfig.SteamProtocol); Program.ArchiLogger.LogGenericWarning("Configured SteamProtocol is invalid: " + globalConfig.SteamProtocol);
return null; return null;
} }
// User might not know what he's doing // User might not know what he's doing
// Ensure that he can't screw core ASF variables // Ensure that he can't screw core ASF variables
if (globalConfig.MaxFarmingTime == 0) { if (globalConfig.MaxFarmingTime == 0) {
ASF.ArchiLogger.LogGenericWarning("Configured MaxFarmingTime is invalid: " + globalConfig.MaxFarmingTime); Program.ArchiLogger.LogGenericWarning("Configured MaxFarmingTime is invalid: " + globalConfig.MaxFarmingTime);
return null; return null;
} }
if (globalConfig.FarmingDelay == 0) { if (globalConfig.FarmingDelay == 0) {
ASF.ArchiLogger.LogGenericWarning("Configured FarmingDelay is invalid: " + globalConfig.FarmingDelay); Program.ArchiLogger.LogGenericWarning("Configured FarmingDelay is invalid: " + globalConfig.FarmingDelay);
return null; return null;
} }
if (globalConfig.HttpTimeout == 0) { if (globalConfig.HttpTimeout == 0) {
ASF.ArchiLogger.LogGenericWarning("Configured HttpTimeout is invalid: " + globalConfig.HttpTimeout); Program.ArchiLogger.LogGenericWarning("Configured HttpTimeout is invalid: " + globalConfig.HttpTimeout);
return null; return null;
} }
@@ -163,7 +163,7 @@ namespace ArchiSteamFarm {
return globalConfig; return globalConfig;
} }
ASF.ArchiLogger.LogGenericWarning("Configured WCFPort is invalid: " + globalConfig.WCFPort); Program.ArchiLogger.LogGenericWarning("Configured WCFPort is invalid: " + globalConfig.WCFPort);
return null; return null;
} }

View File

@@ -84,7 +84,7 @@ namespace ArchiSteamFarm {
internal static GlobalDatabase Load(string filePath) { internal static GlobalDatabase Load(string filePath) {
if (string.IsNullOrEmpty(filePath)) { if (string.IsNullOrEmpty(filePath)) {
ASF.ArchiLogger.LogNullError(nameof(filePath)); Program.ArchiLogger.LogNullError(nameof(filePath));
return null; return null;
} }
@@ -97,12 +97,12 @@ namespace ArchiSteamFarm {
try { try {
globalDatabase = JsonConvert.DeserializeObject<GlobalDatabase>(File.ReadAllText(filePath), CustomSerializerSettings); globalDatabase = JsonConvert.DeserializeObject<GlobalDatabase>(File.ReadAllText(filePath), CustomSerializerSettings);
} catch (Exception e) { } catch (Exception e) {
ASF.ArchiLogger.LogGenericException(e); Program.ArchiLogger.LogGenericException(e);
return null; return null;
} }
if (globalDatabase == null) { if (globalDatabase == null) {
ASF.ArchiLogger.LogNullError(nameof(globalDatabase)); Program.ArchiLogger.LogNullError(nameof(globalDatabase));
return null; return null;
} }
@@ -115,7 +115,7 @@ namespace ArchiSteamFarm {
private void Save() { private void Save() {
string json = JsonConvert.SerializeObject(this, CustomSerializerSettings); string json = JsonConvert.SerializeObject(this, CustomSerializerSettings);
if (string.IsNullOrEmpty(json)) { if (string.IsNullOrEmpty(json)) {
ASF.ArchiLogger.LogNullError(nameof(json)); Program.ArchiLogger.LogNullError(nameof(json));
return; return;
} }
@@ -125,7 +125,7 @@ namespace ArchiSteamFarm {
File.WriteAllText(FilePath, json); File.WriteAllText(FilePath, json);
break; break;
} catch (Exception e) { } catch (Exception e) {
ASF.ArchiLogger.LogGenericException(e); Program.ArchiLogger.LogGenericException(e);
} }
Thread.Sleep(1000); Thread.Sleep(1000);

View File

@@ -39,7 +39,7 @@ namespace ArchiSteamFarm {
public Task UpdateServerListAsync(IEnumerable<IPEndPoint> endPoints) { public Task UpdateServerListAsync(IEnumerable<IPEndPoint> endPoints) {
if (endPoints == null) { if (endPoints == null) {
ASF.ArchiLogger.LogNullError(nameof(endPoints)); Program.ArchiLogger.LogNullError(nameof(endPoints));
return Task.Delay(0); return Task.Delay(0);
} }

View File

@@ -67,25 +67,25 @@ namespace ArchiSteamFarm.JSON {
HtmlNode htmlNode = HtmlDocument.DocumentNode.SelectSingleNode("//div[@class='tradeoffer']"); HtmlNode htmlNode = HtmlDocument.DocumentNode.SelectSingleNode("//div[@class='tradeoffer']");
if (htmlNode == null) { if (htmlNode == null) {
ASF.ArchiLogger.LogNullError(nameof(htmlNode)); Program.ArchiLogger.LogNullError(nameof(htmlNode));
return 0; return 0;
} }
string id = htmlNode.GetAttributeValue("id", null); string id = htmlNode.GetAttributeValue("id", null);
if (string.IsNullOrEmpty(id)) { if (string.IsNullOrEmpty(id)) {
ASF.ArchiLogger.LogNullError(nameof(id)); Program.ArchiLogger.LogNullError(nameof(id));
return 0; return 0;
} }
int index = id.IndexOf('_'); int index = id.IndexOf('_');
if (index < 0) { if (index < 0) {
ASF.ArchiLogger.LogNullError(nameof(index)); Program.ArchiLogger.LogNullError(nameof(index));
return 0; return 0;
} }
index++; index++;
if (id.Length <= index) { if (id.Length <= index) {
ASF.ArchiLogger.LogNullError(nameof(id.Length)); Program.ArchiLogger.LogNullError(nameof(id.Length));
return 0; return 0;
} }
@@ -94,7 +94,7 @@ namespace ArchiSteamFarm.JSON {
return _TradeOfferID; return _TradeOfferID;
} }
ASF.ArchiLogger.LogNullError(nameof(_TradeOfferID)); Program.ArchiLogger.LogNullError(nameof(_TradeOfferID));
return 0; return 0;
} }
} }
@@ -131,13 +131,13 @@ namespace ArchiSteamFarm.JSON {
HtmlNode htmlNode = HtmlDocument.DocumentNode.SelectSingleNode("//a/@data-miniprofile"); HtmlNode htmlNode = HtmlDocument.DocumentNode.SelectSingleNode("//a/@data-miniprofile");
if (htmlNode == null) { if (htmlNode == null) {
ASF.ArchiLogger.LogNullError(nameof(htmlNode)); Program.ArchiLogger.LogNullError(nameof(htmlNode));
return 0; return 0;
} }
string miniProfile = htmlNode.GetAttributeValue("data-miniprofile", null); string miniProfile = htmlNode.GetAttributeValue("data-miniprofile", null);
if (string.IsNullOrEmpty(miniProfile)) { if (string.IsNullOrEmpty(miniProfile)) {
ASF.ArchiLogger.LogNullError(nameof(miniProfile)); Program.ArchiLogger.LogNullError(nameof(miniProfile));
return 0; return 0;
} }
@@ -145,7 +145,7 @@ namespace ArchiSteamFarm.JSON {
return _OtherSteamID3; return _OtherSteamID3;
} }
ASF.ArchiLogger.LogNullError(nameof(_OtherSteamID3)); Program.ArchiLogger.LogNullError(nameof(_OtherSteamID3));
return 0; return 0;
} }
} }
@@ -182,7 +182,7 @@ namespace ArchiSteamFarm.JSON {
set { set {
if (value == null) { if (value == null) {
ASF.ArchiLogger.LogNullError(nameof(value)); Program.ArchiLogger.LogNullError(nameof(value));
return; return;
} }
@@ -237,13 +237,13 @@ namespace ArchiSteamFarm.JSON {
set { set {
if (string.IsNullOrEmpty(value)) { if (string.IsNullOrEmpty(value)) {
ASF.ArchiLogger.LogNullError(nameof(value)); Program.ArchiLogger.LogNullError(nameof(value));
return; return;
} }
uint amount; uint amount;
if (!uint.TryParse(value, out amount) || (amount == 0)) { if (!uint.TryParse(value, out amount) || (amount == 0)) {
ASF.ArchiLogger.LogNullError(nameof(amount)); Program.ArchiLogger.LogNullError(nameof(amount));
return; return;
} }
@@ -258,13 +258,13 @@ namespace ArchiSteamFarm.JSON {
set { set {
if (string.IsNullOrEmpty(value)) { if (string.IsNullOrEmpty(value)) {
ASF.ArchiLogger.LogNullError(nameof(value)); Program.ArchiLogger.LogNullError(nameof(value));
return; return;
} }
uint appID; uint appID;
if (!uint.TryParse(value, out appID) || (appID == 0)) { if (!uint.TryParse(value, out appID) || (appID == 0)) {
ASF.ArchiLogger.LogNullError(nameof(appID)); Program.ArchiLogger.LogNullError(nameof(appID));
return; return;
} }
@@ -278,13 +278,13 @@ namespace ArchiSteamFarm.JSON {
set { set {
if (string.IsNullOrEmpty(value)) { if (string.IsNullOrEmpty(value)) {
ASF.ArchiLogger.LogNullError(nameof(value)); Program.ArchiLogger.LogNullError(nameof(value));
return; return;
} }
ulong assetID; ulong assetID;
if (!ulong.TryParse(value, out assetID) || (assetID == 0)) { if (!ulong.TryParse(value, out assetID) || (assetID == 0)) {
ASF.ArchiLogger.LogNullError(nameof(assetID)); Program.ArchiLogger.LogNullError(nameof(assetID));
return; return;
} }
@@ -299,7 +299,7 @@ namespace ArchiSteamFarm.JSON {
set { set {
if (string.IsNullOrEmpty(value)) { if (string.IsNullOrEmpty(value)) {
ASF.ArchiLogger.LogNullError(nameof(value)); Program.ArchiLogger.LogNullError(nameof(value));
return; return;
} }
@@ -319,13 +319,13 @@ namespace ArchiSteamFarm.JSON {
set { set {
if (string.IsNullOrEmpty(value)) { if (string.IsNullOrEmpty(value)) {
ASF.ArchiLogger.LogNullError(nameof(value)); Program.ArchiLogger.LogNullError(nameof(value));
return; return;
} }
ulong contextID; ulong contextID;
if (!ulong.TryParse(value, out contextID) || (contextID == 0)) { if (!ulong.TryParse(value, out contextID) || (contextID == 0)) {
ASF.ArchiLogger.LogNullError(nameof(contextID)); Program.ArchiLogger.LogNullError(nameof(contextID));
return; return;
} }
@@ -407,7 +407,7 @@ namespace ArchiSteamFarm.JSON {
} }
if (OtherSteamID3 == 0) { if (OtherSteamID3 == 0) {
ASF.ArchiLogger.LogNullError(nameof(OtherSteamID3)); Program.ArchiLogger.LogNullError(nameof(OtherSteamID3));
return 0; return 0;
} }

View File

@@ -116,7 +116,7 @@ namespace ArchiSteamFarm {
private static void OnConfigurationChanged(object sender, LoggingConfigurationChangedEventArgs e) { private static void OnConfigurationChanged(object sender, LoggingConfigurationChangedEventArgs e) {
if ((sender == null) || (e == null)) { if ((sender == null) || (e == null)) {
ASF.ArchiLogger.LogNullError(nameof(sender) + " || " + nameof(e)); Program.ArchiLogger.LogNullError(nameof(sender) + " || " + nameof(e));
return; return;
} }

View File

@@ -35,6 +35,8 @@ using SteamKit2;
namespace ArchiSteamFarm { namespace ArchiSteamFarm {
internal static class Program { internal static class Program {
internal static readonly ArchiLogger ArchiLogger = new ArchiLogger(SharedInfo.ASF);
internal static bool IsWCFRunning => WCF.IsServerRunning; internal static bool IsWCFRunning => WCF.IsServerRunning;
internal static GlobalConfig GlobalConfig { get; private set; } internal static GlobalConfig GlobalConfig { get; private set; }
internal static GlobalDatabase GlobalDatabase { get; private set; } internal static GlobalDatabase GlobalDatabase { get; private set; }
@@ -59,7 +61,7 @@ namespace ArchiSteamFarm {
} }
if (GlobalConfig.Headless || !Runtime.IsUserInteractive) { if (GlobalConfig.Headless || !Runtime.IsUserInteractive) {
ASF.ArchiLogger.LogGenericWarning("Received a request for user input, but process is running in headless mode!"); ArchiLogger.LogGenericWarning("Received a request for user input, but process is running in headless mode!");
return null; return null;
} }
@@ -123,7 +125,7 @@ namespace ArchiSteamFarm {
try { try {
Process.Start(Assembly.GetEntryAssembly().Location, string.Join(" ", Environment.GetCommandLineArgs().Skip(1))); Process.Start(Assembly.GetEntryAssembly().Location, string.Join(" ", Environment.GetCommandLineArgs().Skip(1)));
} catch (Exception e) { } catch (Exception e) {
ASF.ArchiLogger.LogGenericException(e); ArchiLogger.LogGenericException(e);
} }
ShutdownResetEvent.Set(); ShutdownResetEvent.Set();
@@ -169,10 +171,10 @@ namespace ArchiSteamFarm {
} }
Logging.InitLoggers(); Logging.InitLoggers();
ASF.ArchiLogger.LogGenericInfo("ASF V" + SharedInfo.Version); ArchiLogger.LogGenericInfo("ASF V" + SharedInfo.Version);
if (!Runtime.IsRuntimeSupported) { if (!Runtime.IsRuntimeSupported) {
ASF.ArchiLogger.LogGenericError("ASF detected unsupported runtime version, program might NOT run correctly in current environment. You're running it at your own risk!"); ArchiLogger.LogGenericError("ASF detected unsupported runtime version, program might NOT run correctly in current environment. You're running it at your own risk!");
Thread.Sleep(10000); Thread.Sleep(10000);
} }
@@ -211,7 +213,7 @@ namespace ArchiSteamFarm {
GlobalConfig = GlobalConfig.Load(globalConfigFile); GlobalConfig = GlobalConfig.Load(globalConfigFile);
if (GlobalConfig == null) { if (GlobalConfig == null) {
ASF.ArchiLogger.LogGenericError("Global config could not be loaded, please make sure that " + globalConfigFile + " exists and is valid! Did you forget to read wiki?"); ArchiLogger.LogGenericError("Global config could not be loaded, please make sure that " + globalConfigFile + " exists and is valid! Did you forget to read wiki?");
Thread.Sleep(5000); Thread.Sleep(5000);
Exit(1); Exit(1);
} }
@@ -220,7 +222,7 @@ namespace ArchiSteamFarm {
GlobalDatabase = GlobalDatabase.Load(globalDatabaseFile); GlobalDatabase = GlobalDatabase.Load(globalDatabaseFile);
if (GlobalDatabase == null) { if (GlobalDatabase == null) {
ASF.ArchiLogger.LogGenericError("Global database could not be loaded, if issue persists, please remove " + globalDatabaseFile + " in order to recreate database!"); ArchiLogger.LogGenericError("Global database could not be loaded, if issue persists, please remove " + globalDatabaseFile + " in order to recreate database!");
Thread.Sleep(5000); Thread.Sleep(5000);
Exit(1); Exit(1);
} }
@@ -229,7 +231,7 @@ namespace ArchiSteamFarm {
WebBrowser.Init(); WebBrowser.Init();
WCF.Init(); WCF.Init();
WebBrowser = new WebBrowser(ASF.ArchiLogger); WebBrowser = new WebBrowser(ArchiLogger);
} }
private static bool InitShutdownSequence() { private static bool InitShutdownSequence() {
@@ -268,7 +270,7 @@ namespace ArchiSteamFarm {
private static void ParsePostInitArgs(IEnumerable<string> args) { private static void ParsePostInitArgs(IEnumerable<string> args) {
if (args == null) { if (args == null) {
ASF.ArchiLogger.LogNullError(nameof(args)); ArchiLogger.LogNullError(nameof(args));
return; return;
} }
@@ -294,11 +296,11 @@ namespace ArchiSteamFarm {
} }
if (!Mode.HasFlag(EMode.Client)) { if (!Mode.HasFlag(EMode.Client)) {
ASF.ArchiLogger.LogGenericWarning("Ignoring command because --client wasn't specified: " + arg); ArchiLogger.LogGenericWarning("Ignoring command because --client wasn't specified: " + arg);
break; break;
} }
ASF.ArchiLogger.LogGenericInfo("Response received: " + WCF.SendCommand(arg)); ArchiLogger.LogGenericInfo("Response received: " + WCF.SendCommand(arg));
break; break;
} }
} }
@@ -306,7 +308,7 @@ namespace ArchiSteamFarm {
private static void ParsePreInitArgs(IEnumerable<string> args) { private static void ParsePreInitArgs(IEnumerable<string> args) {
if (args == null) { if (args == null) {
ASF.ArchiLogger.LogNullError(nameof(args)); ArchiLogger.LogNullError(nameof(args));
return; return;
} }
@@ -334,20 +336,20 @@ namespace ArchiSteamFarm {
private static void UnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs args) { private static void UnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs args) {
if (args?.ExceptionObject == null) { if (args?.ExceptionObject == null) {
ASF.ArchiLogger.LogNullError(nameof(args) + " || " + nameof(args.ExceptionObject)); ArchiLogger.LogNullError(nameof(args) + " || " + nameof(args.ExceptionObject));
return; return;
} }
ASF.ArchiLogger.LogFatalException((Exception) args.ExceptionObject); ArchiLogger.LogFatalException((Exception) args.ExceptionObject);
} }
private static void UnobservedTaskExceptionHandler(object sender, UnobservedTaskExceptionEventArgs args) { private static void UnobservedTaskExceptionHandler(object sender, UnobservedTaskExceptionEventArgs args) {
if (args?.Exception == null) { if (args?.Exception == null) {
ASF.ArchiLogger.LogNullError(nameof(args) + " || " + nameof(args.Exception)); ArchiLogger.LogNullError(nameof(args) + " || " + nameof(args.Exception));
return; return;
} }
ASF.ArchiLogger.LogFatalException(args.Exception); ArchiLogger.LogFatalException(args.Exception);
} }
[Flags] [Flags]

View File

@@ -39,38 +39,38 @@ namespace ArchiSteamFarm {
if (IsRunningOnMono) { if (IsRunningOnMono) {
Version monoVersion = GetMonoVersion(); Version monoVersion = GetMonoVersion();
if (monoVersion == null) { if (monoVersion == null) {
ASF.ArchiLogger.LogNullError(nameof(monoVersion)); Program.ArchiLogger.LogNullError(nameof(monoVersion));
return false; return false;
} }
Version minMonoVersion = new Version(4, 6); Version minMonoVersion = new Version(4, 6);
if (monoVersion >= minMonoVersion) { if (monoVersion >= minMonoVersion) {
ASF.ArchiLogger.LogGenericInfo("Your Mono version is OK. Required: " + minMonoVersion + " | Found: " + monoVersion); Program.ArchiLogger.LogGenericInfo("Your Mono version is OK. Required: " + minMonoVersion + " | Found: " + monoVersion);
_IsRuntimeSupported = true; _IsRuntimeSupported = true;
return true; return true;
} }
ASF.ArchiLogger.LogGenericWarning("Your Mono version is too old. Required: " + minMonoVersion + " | Found: " + monoVersion); Program.ArchiLogger.LogGenericWarning("Your Mono version is too old. Required: " + minMonoVersion + " | Found: " + monoVersion);
_IsRuntimeSupported = false; _IsRuntimeSupported = false;
return false; return false;
} }
Version netVersion = GetNetVersion(); Version netVersion = GetNetVersion();
if (netVersion == null) { if (netVersion == null) {
ASF.ArchiLogger.LogNullError(nameof(netVersion)); Program.ArchiLogger.LogNullError(nameof(netVersion));
return false; return false;
} }
Version minNetVersion = new Version(4, 6, 1); Version minNetVersion = new Version(4, 6, 1);
if (netVersion >= minNetVersion) { if (netVersion >= minNetVersion) {
ASF.ArchiLogger.LogGenericInfo("Your .NET version is OK. Required: " + minNetVersion + " | Found: " + netVersion); Program.ArchiLogger.LogGenericInfo("Your .NET version is OK. Required: " + minNetVersion + " | Found: " + netVersion);
_IsRuntimeSupported = true; _IsRuntimeSupported = true;
return true; return true;
} }
ASF.ArchiLogger.LogGenericWarning("Your .NET version is too old. Required: " + minNetVersion + " | Found: " + netVersion); Program.ArchiLogger.LogGenericWarning("Your .NET version is too old. Required: " + minNetVersion + " | Found: " + netVersion);
_IsRuntimeSupported = false; _IsRuntimeSupported = false;
return false; return false;
} }
@@ -107,25 +107,25 @@ namespace ArchiSteamFarm {
private static Version GetMonoVersion() { private static Version GetMonoVersion() {
if (MonoRuntime == null) { if (MonoRuntime == null) {
ASF.ArchiLogger.LogNullError(nameof(MonoRuntime)); Program.ArchiLogger.LogNullError(nameof(MonoRuntime));
return null; return null;
} }
MethodInfo displayName = MonoRuntime.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static); MethodInfo displayName = MonoRuntime.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static);
if (displayName == null) { if (displayName == null) {
ASF.ArchiLogger.LogNullError(nameof(displayName)); Program.ArchiLogger.LogNullError(nameof(displayName));
return null; return null;
} }
string versionString = (string) displayName.Invoke(null, null); string versionString = (string) displayName.Invoke(null, null);
if (string.IsNullOrEmpty(versionString)) { if (string.IsNullOrEmpty(versionString)) {
ASF.ArchiLogger.LogNullError(nameof(versionString)); Program.ArchiLogger.LogNullError(nameof(versionString));
return null; return null;
} }
int index = versionString.IndexOf(' '); int index = versionString.IndexOf(' ');
if (index <= 0) { if (index <= 0) {
ASF.ArchiLogger.LogNullError(nameof(index)); Program.ArchiLogger.LogNullError(nameof(index));
return null; return null;
} }
@@ -136,7 +136,7 @@ namespace ArchiSteamFarm {
return version; return version;
} }
ASF.ArchiLogger.LogNullError(nameof(version)); Program.ArchiLogger.LogNullError(nameof(version));
return null; return null;
} }
@@ -144,18 +144,18 @@ namespace ArchiSteamFarm {
uint release; uint release;
using (RegistryKey registryKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey("SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v4\\Full\\")) { using (RegistryKey registryKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey("SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v4\\Full\\")) {
if (registryKey == null) { if (registryKey == null) {
ASF.ArchiLogger.LogNullError(nameof(registryKey)); Program.ArchiLogger.LogNullError(nameof(registryKey));
return null; return null;
} }
object releaseObj = registryKey.GetValue("Release"); object releaseObj = registryKey.GetValue("Release");
if (releaseObj == null) { if (releaseObj == null) {
ASF.ArchiLogger.LogNullError(nameof(releaseObj)); Program.ArchiLogger.LogNullError(nameof(releaseObj));
return null; return null;
} }
if (!uint.TryParse(releaseObj.ToString(), out release) || (release == 0)) { if (!uint.TryParse(releaseObj.ToString(), out release) || (release == 0)) {
ASF.ArchiLogger.LogNullError(nameof(release)); Program.ArchiLogger.LogNullError(nameof(release));
return null; return null;
} }
} }

View File

@@ -90,7 +90,7 @@ namespace ArchiSteamFarm {
internal async Task OnPersonaState(SteamFriends.PersonaStateCallback callback) { internal async Task OnPersonaState(SteamFriends.PersonaStateCallback callback) {
if (callback == null) { if (callback == null) {
ASF.ArchiLogger.LogNullError(nameof(callback)); Program.ArchiLogger.LogNullError(nameof(callback));
return; return;
} }

View File

@@ -38,7 +38,7 @@ namespace ArchiSteamFarm {
internal static string GetCookieValue(this CookieContainer cookieContainer, string url, string name) { internal static string GetCookieValue(this CookieContainer cookieContainer, string url, string name) {
if (string.IsNullOrEmpty(url) || string.IsNullOrEmpty(name)) { if (string.IsNullOrEmpty(url) || string.IsNullOrEmpty(name)) {
ASF.ArchiLogger.LogNullError(nameof(url) + " || " + nameof(name)); Program.ArchiLogger.LogNullError(nameof(url) + " || " + nameof(name));
return null; return null;
} }
@@ -47,7 +47,7 @@ namespace ArchiSteamFarm {
try { try {
uri = new Uri(url); uri = new Uri(url);
} catch (UriFormatException e) { } catch (UriFormatException e) {
ASF.ArchiLogger.LogGenericException(e); Program.ArchiLogger.LogGenericException(e);
return null; return null;
} }
@@ -59,7 +59,7 @@ namespace ArchiSteamFarm {
internal static int RandomNext(int maxWithout) { internal static int RandomNext(int maxWithout) {
if (maxWithout <= 0) { if (maxWithout <= 0) {
ASF.ArchiLogger.LogNullError(nameof(maxWithout)); Program.ArchiLogger.LogNullError(nameof(maxWithout));
return -1; return -1;
} }

View File

@@ -54,7 +54,7 @@ namespace ArchiSteamFarm {
public string HandleCommand(string input) { public string HandleCommand(string input) {
if (string.IsNullOrEmpty(input)) { if (string.IsNullOrEmpty(input)) {
ASF.ArchiLogger.LogNullError(nameof(input)); Program.ArchiLogger.LogNullError(nameof(input));
return null; return null;
} }
@@ -73,7 +73,7 @@ namespace ArchiSteamFarm {
// We must keep it synchronous until either Mono gets fixed, or culprit for freeze located (and corrected) // We must keep it synchronous until either Mono gets fixed, or culprit for freeze located (and corrected)
string output = bot.Response(Program.GlobalConfig.SteamOwnerID, command).Result; string output = bot.Response(Program.GlobalConfig.SteamOwnerID, command).Result;
ASF.ArchiLogger.LogGenericInfo("Answered to WCF command: " + input + " with: " + output); Program.ArchiLogger.LogGenericInfo("Answered to WCF command: " + input + " with: " + output);
return output; return output;
} }
@@ -90,11 +90,11 @@ namespace ArchiSteamFarm {
internal string SendCommand(string input) { internal string SendCommand(string input) {
if (string.IsNullOrEmpty(input)) { if (string.IsNullOrEmpty(input)) {
ASF.ArchiLogger.LogNullError(nameof(input)); Program.ArchiLogger.LogNullError(nameof(input));
return null; return null;
} }
ASF.ArchiLogger.LogGenericInfo("Sending command: " + input + " to WCF server on " + URL + "..."); Program.ArchiLogger.LogGenericInfo("Sending command: " + input + " to WCF server on " + URL + "...");
if (Client == null) { if (Client == null) {
Client = new Client(new NetTcpBinding { Security = { Mode = SecurityMode.None } }, new EndpointAddress(URL)); Client = new Client(new NetTcpBinding { Security = { Mode = SecurityMode.None } }, new EndpointAddress(URL));
@@ -108,19 +108,19 @@ namespace ArchiSteamFarm {
return; return;
} }
ASF.ArchiLogger.LogGenericInfo("Starting WCF server on " + URL + "..."); Program.ArchiLogger.LogGenericInfo("Starting WCF server on " + URL + "...");
try { try {
ServiceHost = new ServiceHost(typeof(WCF), new Uri(URL)); ServiceHost = new ServiceHost(typeof(WCF), new Uri(URL));
ServiceHost.AddServiceEndpoint(typeof(IWCF), new NetTcpBinding { Security = { Mode = SecurityMode.None } }, string.Empty); ServiceHost.AddServiceEndpoint(typeof(IWCF), new NetTcpBinding { Security = { Mode = SecurityMode.None } }, string.Empty);
ServiceHost.Open(); ServiceHost.Open();
ASF.ArchiLogger.LogGenericInfo("WCF server ready!"); Program.ArchiLogger.LogGenericInfo("WCF server ready!");
} catch (AddressAccessDeniedException) { } catch (AddressAccessDeniedException) {
ASF.ArchiLogger.LogGenericError("WCF service could not be started because of AddressAccessDeniedException!"); Program.ArchiLogger.LogGenericError("WCF service could not be started because of AddressAccessDeniedException!");
ASF.ArchiLogger.LogGenericWarning("If you want to use WCF service provided by ASF, consider starting ASF as administrator, or giving proper permissions!"); Program.ArchiLogger.LogGenericWarning("If you want to use WCF service provided by ASF, consider starting ASF as administrator, or giving proper permissions!");
} catch (Exception e) { } catch (Exception e) {
ASF.ArchiLogger.LogGenericException(e); Program.ArchiLogger.LogGenericException(e);
} }
} }
@@ -133,7 +133,7 @@ namespace ArchiSteamFarm {
try { try {
ServiceHost.Close(); ServiceHost.Close();
} catch (Exception e) { } catch (Exception e) {
ASF.ArchiLogger.LogGenericException(e); Program.ArchiLogger.LogGenericException(e);
} }
} }
@@ -158,14 +158,14 @@ namespace ArchiSteamFarm {
internal string HandleCommand(string input) { internal string HandleCommand(string input) {
if (string.IsNullOrEmpty(input)) { if (string.IsNullOrEmpty(input)) {
ASF.ArchiLogger.LogNullError(nameof(input)); Program.ArchiLogger.LogNullError(nameof(input));
return null; return null;
} }
try { try {
return Channel.HandleCommand(input); return Channel.HandleCommand(input);
} catch (Exception e) { } catch (Exception e) {
ASF.ArchiLogger.LogGenericException(e); Program.ArchiLogger.LogGenericException(e);
return null; return null;
} }
} }

View File

@@ -33,7 +33,7 @@ namespace ArchiSteamFarm {
internal static void OnPersonaState(Bot bot, SteamFriends.PersonaStateCallback callback) { internal static void OnPersonaState(Bot bot, SteamFriends.PersonaStateCallback callback) {
if (bot == null) { if (bot == null) {
ASF.ArchiLogger.LogNullError(nameof(bot)); Program.ArchiLogger.LogNullError(nameof(bot));
return; return;
} }

View File

@@ -23,7 +23,7 @@ namespace GUI {
internal static void UpdateBotAvatar(string botName, Image image) { internal static void UpdateBotAvatar(string botName, Image image) {
if (string.IsNullOrEmpty(botName) || (image == null)) { if (string.IsNullOrEmpty(botName) || (image == null)) {
ASF.ArchiLogger.LogNullError(nameof(botName) + " || " + nameof(image)); Program.ArchiLogger.LogNullError(nameof(botName) + " || " + nameof(image));
return; return;
} }
@@ -68,10 +68,10 @@ namespace GUI {
BotListView.LargeImageList = BotListView.SmallImageList = AvatarImageList; BotListView.LargeImageList = BotListView.SmallImageList = AvatarImageList;
await Task.Run(async () => { await Task.Run(async () => {
ASF.ArchiLogger.LogGenericInfo("ASF V" + SharedInfo.Version); Program.ArchiLogger.LogGenericInfo("ASF V" + SharedInfo.Version);
if (!Directory.Exists(SharedInfo.ConfigDirectory)) { if (!Directory.Exists(SharedInfo.ConfigDirectory)) {
ASF.ArchiLogger.LogGenericError("Config directory could not be found!"); Program.ArchiLogger.LogGenericError("Config directory could not be found!");
Environment.Exit(1); Environment.Exit(1);
} }
@@ -133,7 +133,7 @@ namespace GUI {
private static Bitmap ResizeImage(Image image, int width, int height) { private static Bitmap ResizeImage(Image image, int width, int height) {
if ((image == null) || (width <= 0) || (height <= 0)) { if ((image == null) || (width <= 0) || (height <= 0)) {
ASF.ArchiLogger.LogNullError(nameof(image) + " || " + nameof(width) + " || " + nameof(height)); Program.ArchiLogger.LogNullError(nameof(image) + " || " + nameof(width) + " || " + nameof(height));
return null; return null;
} }

View File

@@ -13,6 +13,8 @@ using SteamKit2;
namespace ArchiSteamFarm { namespace ArchiSteamFarm {
internal static class Program { internal static class Program {
internal static readonly ArchiLogger ArchiLogger = new ArchiLogger(SharedInfo.ASF);
internal static GlobalConfig GlobalConfig { get; private set; } internal static GlobalConfig GlobalConfig { get; private set; }
internal static GlobalDatabase GlobalDatabase { get; private set; } internal static GlobalDatabase GlobalDatabase { get; private set; }
internal static WebBrowser WebBrowser { get; private set; } internal static WebBrowser WebBrowser { get; private set; }
@@ -38,7 +40,7 @@ namespace ArchiSteamFarm {
try { try {
Process.Start(Assembly.GetEntryAssembly().Location, string.Join(" ", Environment.GetCommandLineArgs().Skip(1))); Process.Start(Assembly.GetEntryAssembly().Location, string.Join(" ", Environment.GetCommandLineArgs().Skip(1)));
} catch (Exception e) { } catch (Exception e) {
ASF.ArchiLogger.LogGenericException(e); ArchiLogger.LogGenericException(e);
} }
Environment.Exit(0); Environment.Exit(0);
@@ -51,7 +53,7 @@ namespace ArchiSteamFarm {
Logging.InitCoreLoggers(); Logging.InitCoreLoggers();
if (!Runtime.IsRuntimeSupported) { if (!Runtime.IsRuntimeSupported) {
ASF.ArchiLogger.LogGenericError("ASF detected unsupported runtime version, program might NOT run correctly in current environment. You're running it at your own risk!"); ArchiLogger.LogGenericError("ASF detected unsupported runtime version, program might NOT run correctly in current environment. You're running it at your own risk!");
} }
string homeDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); string homeDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
@@ -101,7 +103,7 @@ namespace ArchiSteamFarm {
GlobalConfig = GlobalConfig.Load(globalConfigFile); GlobalConfig = GlobalConfig.Load(globalConfigFile);
if (GlobalConfig == null) { if (GlobalConfig == null) {
ASF.ArchiLogger.LogGenericError("Global config could not be loaded, please make sure that " + globalConfigFile + " exists and is valid!"); ArchiLogger.LogGenericError("Global config could not be loaded, please make sure that " + globalConfigFile + " exists and is valid!");
Exit(1); Exit(1);
} }
@@ -109,14 +111,14 @@ namespace ArchiSteamFarm {
GlobalDatabase = GlobalDatabase.Load(globalDatabaseFile); GlobalDatabase = GlobalDatabase.Load(globalDatabaseFile);
if (GlobalDatabase == null) { if (GlobalDatabase == null) {
ASF.ArchiLogger.LogGenericError("Global database could not be loaded, if issue persists, please remove " + globalDatabaseFile + " in order to recreate database!"); ArchiLogger.LogGenericError("Global database could not be loaded, if issue persists, please remove " + globalDatabaseFile + " in order to recreate database!");
Exit(1); Exit(1);
} }
ArchiWebHandler.Init(); ArchiWebHandler.Init();
WebBrowser.Init(); WebBrowser.Init();
WebBrowser = new WebBrowser(ASF.ArchiLogger); WebBrowser = new WebBrowser(ArchiLogger);
} }
/// <summary> /// <summary>
@@ -132,20 +134,20 @@ namespace ArchiSteamFarm {
private static void UnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs args) { private static void UnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs args) {
if (args?.ExceptionObject == null) { if (args?.ExceptionObject == null) {
ASF.ArchiLogger.LogNullError(nameof(args) + " || " + nameof(args.ExceptionObject)); ArchiLogger.LogNullError(nameof(args) + " || " + nameof(args.ExceptionObject));
return; return;
} }
ASF.ArchiLogger.LogFatalException((Exception) args.ExceptionObject); ArchiLogger.LogFatalException((Exception) args.ExceptionObject);
} }
private static void UnobservedTaskExceptionHandler(object sender, UnobservedTaskExceptionEventArgs args) { private static void UnobservedTaskExceptionHandler(object sender, UnobservedTaskExceptionEventArgs args) {
if (args?.Exception == null) { if (args?.Exception == null) {
ASF.ArchiLogger.LogNullError(nameof(args) + " || " + nameof(args.Exception)); ArchiLogger.LogNullError(nameof(args) + " || " + nameof(args.Exception));
return; return;
} }
ASF.ArchiLogger.LogFatalException(args.Exception); ArchiLogger.LogFatalException(args.Exception);
} }
} }
} }