Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Collections.Specialized;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Net;
- using System.Net.NetworkInformation;
- using System.Net.Mail;
- using System.Reflection;
- using System.IO;
- using System.Xml;
- using System.Threading;
- using System.Data.Odbc;
- using Server;
- using Server.Accounting;
- using Server.EUO.Donations.MySQL;
- using Server.EUO.Donations.Encryption;
- namespace Server.EUO.Donations
- {
- public sealed class ADCTrackerOptions
- {
- [CommandProperty(AccessLevel.Administrator)]
- public string Execute
- {
- get { return String.Empty; }
- set
- {
- switch (value.ToUpper())
- {
- case "SYNC": { ADCTracker.Sync(); } break;
- case "LOAD": { ADCTracker.Load(); } break;
- case "SAVE": { ADCTracker.Save(); } break;
- case "LOADCONFIG": { ADCTracker.LoadConfig(); } break;
- case "SAVECONFIG": { ADCTracker.SaveConfig(); } break;
- case "IMPORTDB": { ADCTracker.ImportDatabase(); } break;
- case "EXPORTDB": { ADCTracker.ExportDatabase(); } break;
- case "IMPORTMYSQL": { ADCTracker.ImportMySQL(); } break;
- case "EXPORTMYSQL": { ADCTracker.ExportMySQL(); } break;
- }
- }
- }
- [CommandProperty(AccessLevel.Administrator)]
- public bool Running { get { return ADCTracker.Running; } }
- [CommandProperty(AccessLevel.Administrator)]
- public bool Connected { get { return ADCTracker.Connection.Connected; } }
- [CommandProperty(AccessLevel.Administrator)]
- public int ProfileTotal { get { return ADCTracker.CentralDatabase.Registry.Count; } }
- [CommandProperty(AccessLevel.Administrator)]
- public ADCDatabaseStatus Status { get { return ADCTracker.CentralDatabase.Status; } }
- private bool _QuietMode;
- [CommandProperty(AccessLevel.Administrator)]
- public bool QuietMode { get { return _QuietMode; } set { _QuietMode = value; } }
- private double _ExchangeRate = 1.0;
- [CommandProperty(AccessLevel.Administrator)]
- public double ExchangeRate
- {
- get
- {
- if (_ExchangeRate < 0)
- { _ExchangeRate = 0; }
- return _ExchangeRate;
- }
- set
- {
- if (value < 0)
- { value = 0; }
- _ExchangeRate = value;
- }
- }
- private int _MySQLRetries;
- [CommandProperty(AccessLevel.Administrator)]
- public int MySQLRetries
- {
- get
- {
- if (_MySQLRetries < 0)
- { _MySQLRetries = 0; }
- return _MySQLRetries;
- }
- set
- {
- if (value < 0)
- { value = 0; }
- _MySQLRetries = value;
- }
- }
- private TimeSpan _ImportTimeOut = TimeSpan.FromSeconds(30.0);
- [CommandProperty(AccessLevel.Administrator)]
- public TimeSpan ImportTimeOut { get { return _ImportTimeOut; } set { _ImportTimeOut = value; } }
- private TimeSpan _ExportTimeOut = TimeSpan.FromSeconds(30.0);
- [CommandProperty(AccessLevel.Administrator)]
- public TimeSpan ExportTimeOut { get { return _ExportTimeOut; } set { _ExportTimeOut = value; } }
- private string _MySQLDatabase = "adc_db";
- [CommandProperty(AccessLevel.Administrator)]
- public string MySQLDatabase
- {
- get { return _MySQLDatabase; }
- set
- {
- if (value != _MySQLDatabase)
- { _MySQLDatabase = value; }
- }
- }
- private string _MySQLTable = "adc_trans";
- [CommandProperty(AccessLevel.Administrator)]
- public string MySQLTable
- {
- get { return _MySQLTable; }
- set
- {
- if (value != _MySQLTable)
- { _MySQLTable = value; }
- }
- }
- public ADCTrackerOptions()
- { }
- public override string ToString()
- { return "..."; }
- }
- [PropertyObject]
- public sealed class ADCTracker
- {
- private static FileInfo _ConfigFile;
- public static FileInfo ConfigFile
- {
- get
- {
- if (_ConfigFile == null)
- { _ConfigFile = new FileInfo(@"ADC\Config.bin"); }
- return _ConfigFile;
- }
- set
- {
- if (value == null)
- { ADCEvents.InvokeException(new ArgumentNullException("ConfigFile `value`"), "ConfigFile can not be null"); }
- else
- {
- if (value != _ConfigFile)
- { _ConfigFile = value; }
- }
- }
- }
- private static ADCTrackerOptions _Options = new ADCTrackerOptions();
- public static ADCTrackerOptions Options { get { return _Options; } }
- public static Dictionary<IAccount, ADCDonationProfile> Registry { get { return CentralDatabase.Registry; } }
- private static MySQLConnection _Connection;
- public static MySQLConnection Connection
- {
- get
- {
- if (_Connection == null || !_Connection.Connected)
- { _Connection = new MySQLConnection(MySQLConfig.DefaultCredentials); }
- return _Connection;
- }
- }
- private static IADCDatabase _CentralDatabase;
- public static IADCDatabase CentralDatabase
- {
- get
- {
- if (_CentralDatabase == null)
- { _CentralDatabase = new ADCDatabaseBinary(@"ADC\Databases\Central.bin"); }
- return _CentralDatabase;
- }
- set
- {
- if (value == null)
- { ADCEvents.InvokeException(new ArgumentNullException("Database `value`"), "Database can not be null"); }
- else
- {
- if (value != _CentralDatabase)
- { _CentralDatabase = value; }
- }
- }
- }
- private static bool _Running;
- public static bool Running { get { return _Running; } }
- private static TimeSpan _LoadTime, _SaveTime, _SyncTime;
- private static void OnWorldCrashed(CrashedEventArgs e)
- {
- if (!_Options.QuietMode)
- { Console.WriteLine(); }
- Save();
- }
- private static void OnWorldSave(WorldSaveEventArgs e)
- {
- if (!_Options.QuietMode)
- { Console.WriteLine(); }
- Sync();
- SaveConfig();
- }
- public static void Invoke()
- {
- try
- {
- LoadConfig();
- if (_Running)
- {
- if (!_Options.QuietMode)
- { Console.WriteLine("[ADC/Tracker]: Could not Invoke ADC Tracker, the ADC Tracker is already running."); }
- ADCEvents.InvokeException(new InvalidOperationException("Could not Invoke ADC Tracker"), "ADC Tracker is already running.");
- return;
- }
- EventSink.WorldSave += new WorldSaveEventHandler(OnWorldSave);
- EventSink.Crashed += new CrashedEventHandler(OnWorldCrashed);
- _Running = true;
- InvokeMySQL();
- Load();
- }
- catch (Exception e)
- {
- _Running = false;
- if (!_Options.QuietMode)
- {
- Console.WriteLine("[ADC/Tracker]: An unexpected exception occured that was not specified. (Tracker Invokation)");
- Console.WriteLine(e);
- }
- ADCEvents.InvokeException(e, "An unexpected exception occured that was not specified. (Tracker Invokation)");
- }
- }
- public static void LoadConfig()
- {
- if (!ConfigFile.Exists || ConfigFile.Length == 0)
- { return; }
- using (FileStream fs = _ConfigFile.Open(FileMode.OpenOrCreate, FileAccess.Read))
- {
- GenericReader gr = new BinaryFileReader(new BinaryReader(fs));
- CentralDatabase = (IADCDatabase)Type.GetType(gr.ReadString()).GetConstructor(new Type[] { typeof(string) }).Invoke(new object[] { gr.ReadString() });
- _Options.MySQLDatabase = gr.ReadString();
- _Options.MySQLTable = gr.ReadString();
- _Options.MySQLRetries = gr.ReadInt();
- _Options.QuietMode = gr.ReadBool();
- _Options.ImportTimeOut = gr.ReadTimeSpan();
- _Options.ExportTimeOut = gr.ReadTimeSpan();
- }
- }
- public static void SaveConfig()
- {
- if (!_ConfigFile.Exists)
- { _ConfigFile.Create().Close(); }
- using (FileStream fs = _ConfigFile.Open(FileMode.OpenOrCreate, FileAccess.Write))
- {
- GenericWriter gw = new BinaryFileWriter(fs, true);
- gw.Write(_CentralDatabase.GetType().FullName);
- gw.Write(_CentralDatabase.Document.FullName);
- gw.Write(_Options.MySQLDatabase);
- gw.Write(_Options.MySQLTable);
- gw.Write(_Options.MySQLRetries);
- gw.Write(_Options.QuietMode);
- gw.Write(_Options.ImportTimeOut);
- gw.Write(_Options.ExportTimeOut);
- gw.Close();
- }
- }
- public static void Load()
- {
- if (!_Running)
- {
- ADCEvents.InvokeException(new InvalidOperationException("Could not perform method call"), "ADC Tracker is not running, call Invoke to start the Tracker");
- return;
- }
- if (!_Options.QuietMode)
- { Console.WriteLine("[ADC/Tracker]: Loading..."); }
- DateTime then = DateTime.Now;
- ImportDatabase();
- ImportMySQL();
- _LoadTime = TimeSpan.FromSeconds((DateTime.Now - then).TotalSeconds);
- if (!_Options.QuietMode)
- {
- Console.WriteLine("[ADC/Tracker]: Load completed in {0:F2} second{1}.", _LoadTime.TotalSeconds, _LoadTime.TotalSeconds != 1 ? "s" : String.Empty);
- DatabaseReport();
- }
- }
- public static void Save()
- {
- if (!_Running)
- {
- ADCEvents.InvokeException(new InvalidOperationException("Could not perform method call"), "ADC Tracker is not running, call Invoke to start the Tracker");
- return;
- }
- if (!_Options.QuietMode)
- { Console.WriteLine("[ADC/Tracker]: Saving..."); }
- DateTime then = DateTime.Now;
- ExportDatabase();
- ExportMySQL();
- _SaveTime = TimeSpan.FromSeconds((DateTime.Now - then).TotalSeconds);
- if (!_Options.QuietMode)
- {
- Console.WriteLine("[ADC/Tracker]: Save completed in {0:F2} second{1}.", _SaveTime.TotalSeconds, _SaveTime.TotalSeconds != 1 ? "s" : String.Empty);
- DatabaseReport();
- }
- }
- public static void Sync()
- {
- if (!_Running)
- {
- ADCEvents.InvokeException(new InvalidOperationException("Could not perform method call"), "ADC Tracker is not running, call Invoke to start the Tracker");
- return;
- }
- if (!_Options.QuietMode)
- { Console.WriteLine("[ADC/Tracker]: Syncing..."); }
- DateTime then = DateTime.Now;
- ImportMySQL();
- ExportDatabase();
- ExportMySQL();
- _SyncTime = TimeSpan.FromSeconds((DateTime.Now - then).TotalSeconds);
- if (!_Options.QuietMode)
- {
- Console.WriteLine("[ADC/Tracker]: Sync completed in {0:F2} second{1}.", _SyncTime.TotalSeconds, _SyncTime.TotalSeconds != 1 ? "s" : String.Empty);
- DatabaseReport();
- }
- }
- public static void DatabaseReport()
- {
- if (!_Options.QuietMode)
- { Console.WriteLine("[ADC/Tracker]: The Database reports status as {0} with {1} profile entr{2}.", ADCTracker.CentralDatabase.Status.ToString(), (ADCTracker.CentralDatabase.Registry.Count == 0) ? "no" : ADCTracker.CentralDatabase.Registry.Count.ToString("#,#"), (ADCTracker.CentralDatabase.Registry.Count != 1) ? "ies" : "y"); }
- }
- public static void ImportDatabase()
- {
- DateTime now = DateTime.Now;
- ADCDatabaseResult result = ADCDatabaseResult.Busy;
- while (result == ADCDatabaseResult.Busy)
- {
- if (DateTime.Now < (now + _Options.ImportTimeOut))
- { result = CentralDatabase.Import(); }
- else
- { break; }
- }
- if (result == ADCDatabaseResult.Error || result == ADCDatabaseResult.Null)
- {
- if (CentralDatabase.HasErrors)
- {
- if (!_Options.QuietMode)
- {
- foreach (Exception e in CentralDatabase.Errors)
- { Console.WriteLine(e); }
- Console.WriteLine("[ADC/Tracker]: There {0} {1} error{2}.",
- CentralDatabase.Errors.Count != 1 ? "are" : "is",
- CentralDatabase.Errors.Count > 0 ? CentralDatabase.Errors.Count.ToString("#,#") : "no",
- CentralDatabase.Errors.Count != 1 ? "s" : "");
- }
- }
- else
- {
- if (!_Options.QuietMode)
- { Console.WriteLine("[ADC/Tracker]: An unexpected exception occured that was not specified. (Database Import)"); }
- }
- }
- if (result != ADCDatabaseResult.OK)
- {
- if (!_Options.QuietMode)
- { Console.WriteLine("[ADC/Tracker]: A problem with the central database was detected, import will not continue."); }
- }
- else
- {
- if (!_Options.QuietMode)
- {
- Console.WriteLine("[ADC/Tracker]: {0} Profile record{1} imported from central database.",
- CentralDatabase.Registry.Count > 0 ? CentralDatabase.Registry.Count.ToString("#,#") : "No",
- CentralDatabase.Registry.Count != 1 ? "s" : "");
- }
- ADCEvents.InvokeDatabaseImported(CentralDatabase);
- }
- }
- public static ADCDatabaseResult ExportDatabase()
- {
- DateTime now = DateTime.Now;
- ADCDatabaseResult result = ADCDatabaseResult.Busy;
- while (result == ADCDatabaseResult.Busy)
- {
- if (DateTime.Now < (now + _Options.ExportTimeOut))
- { result = CentralDatabase.Export(); }
- else
- { break; }
- }
- if (result == ADCDatabaseResult.Error || result == ADCDatabaseResult.Null)
- {
- if (CentralDatabase.HasErrors)
- {
- if (!_Options.QuietMode)
- {
- foreach (Exception e in CentralDatabase.Errors)
- { Console.WriteLine(e); }
- Console.WriteLine("[ADC/Tracker]: There {0} {1} error{2}.",
- CentralDatabase.Errors.Count != 1 ? "are" : "is",
- CentralDatabase.Errors.Count > 0 ? CentralDatabase.Errors.Count.ToString("#,#") : "no",
- CentralDatabase.Errors.Count != 1 ? "s" : "");
- }
- }
- else
- {
- if (!_Options.QuietMode)
- { Console.WriteLine("[ADC/Tracker]: An unexpected exception occured that was not specified. (Database Export)"); }
- }
- }
- if (result != ADCDatabaseResult.OK)
- {
- if (!_Options.QuietMode)
- { Console.WriteLine("[ADC/Tracker]: A problem with the central database was detected, export will not continue."); }
- }
- else
- {
- if (!_Options.QuietMode)
- {
- Console.WriteLine("[ADC/Tracker]: {0} Profile record{1} exported to central database.",
- CentralDatabase.Registry.Count > 0 ? CentralDatabase.Registry.Count.ToString("#,#") : "No",
- CentralDatabase.Registry.Count != 1 ? "s" : "");
- }
- ADCEvents.InvokeDatabaseExported(CentralDatabase);
- }
- return result;
- }
- public static void InvokeMySQL()
- {
- if (Connection.Connect(_Options.MySQLRetries))
- {
- Connection.NonQuery(@"CREATE DATABASE IF NOT EXISTS `{0}` DEFAULT CHARSET `utf8` DEFAULT COLLATE `utf8_bin`", _Options.MySQLDatabase);
- Connection.UseDatabase(_Options.MySQLDatabase);
- string query = @"CREATE TABLE IF NOT EXISTS `" + _Options.MySQLTable + @"` ("
- + @"`id` varchar(255) collate utf8_bin NOT NULL,"
- + @"`state` varchar(255) collate utf8_bin NOT NULL,"
- + @"`account` varchar(255) collate utf8_bin NOT NULL,"
- + @"`email` varchar(255) collate utf8_bin NOT NULL,"
- + @"`total` decimal(10,2) NOT NULL,"
- + @"`credit` bigint(20) NOT NULL,"
- + @"`time` int(11) NOT NULL,"
- + @"`version` int(11),"
- + @"`notes` text collate utf8_bin,"
- + @"`extra` text collate utf8_bin,"
- + @"PRIMARY KEY (`id`),"
- + @"KEY `state` (`state`),"
- + @"KEY `account` (`account`),"
- + @"KEY `email` (`email`)"
- + @") ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;";
- if (Connection.NonQuery(query) > 0)
- {
- if (!_Options.QuietMode)
- { Console.WriteLine("[ADC/Tracker]: Created MySQL Table '" + _Options.MySQLTable + "' for use with ADC."); }
- }
- }
- }
- public static void ImportMySQL()
- {
- ImportMySQL(ADCTransactionState.PENDING);
- ImportMySQL(ADCTransactionState.PROCESSED);
- ImportMySQL(ADCTransactionState.CLAIMED);
- ImportMySQL(ADCTransactionState.VOIDED);
- }
- public static void ImportMySQL(ADCTransactionState state)
- {
- if (Connection.Connect(_Options.MySQLRetries))
- {
- int count = 0;
- Connection.UseDatabase(_Options.MySQLDatabase);
- MySQLRow[] rows = Connection.Select(_Options.MySQLTable, null, new MySQLData[] { new MySQLData("state", state) }, "time", MySQLSortOrder.ASC);
- if (Connection.HasError)
- {
- if (!_Options.QuietMode)
- {
- foreach (OdbcError e in Connection.Errors)
- { Console.WriteLine(e); }
- Console.WriteLine("[ADC/Tracker]: There {0} {1} error{2}.",
- CentralDatabase.Errors.Count != 1 ? "are" : "is",
- CentralDatabase.Errors.Count > 0 ? CentralDatabase.Errors.Count.ToString("#,#") : "no",
- CentralDatabase.Errors.Count != 1 ? "s" : "");
- }
- }
- else if (rows.Length > 0)
- {
- List<ADCTransaction> gTrans = new List<ADCTransaction>(rows.Length);
- foreach (MySQLRow row in rows)
- {
- try
- {
- decimal total = row["total"].GetValue<decimal>();
- long credit = row["credit"].GetValue<long>();
- int
- time = row["time"].GetValue<int>(),
- version = row["version"].GetValue<int>();
- string
- id = row["id"].GetValue<string>(),
- email = row["email"].GetValue<string>(),
- notes = row["notes"].GetValue<string>(),
- extra = row["extra"].GetValue<string>(),
- status = row["state"].GetValue<string>(),
- account = row["account"].GetValue<string>();
- gTrans.Add(new ADCTransaction(id, (ADCTransactionState)Enum.Parse(typeof(ADCTransactionState), status, true), (Account)Accounts.GetAccount(account), email, total, new ADCCredits(credit), TimeStamp.FromUnixTimeStamp(time), version, notes, extra));
- }
- catch (Exception e)
- { ADCEvents.InvokeException(e, "Could not load MySQL data for ADCTransaction in row {0}", row.ID.ToString("#,#")); }
- }
- List<Exception> errors = new List<Exception>();
- foreach (ADCTransaction trans in gTrans)
- {
- try
- {
- if (!CentralDatabase.Registry.ContainsKey(trans.Account))
- { Register(trans.Account, new ADCDonationProfile(trans.Account)); }
- if (!CentralDatabase.Registry[trans.Account].Contains(trans))
- { CentralDatabase.Registry[trans.Account].Add(trans); }
- switch (trans.State)
- {
- case ADCTransactionState.PENDING:
- {
- if (CentralDatabase.Registry[trans.Account].Process(trans))
- { }
- count++;
- } break;
- case ADCTransactionState.PROCESSED: { count++; } break;
- case ADCTransactionState.CLAIMED: { count++; } break;
- case ADCTransactionState.VOIDED:
- {
- if (CentralDatabase.Registry[trans.Account].Void(trans))
- { }
- count++;
- } break;
- }
- }
- catch (Exception e)
- {
- ADCEvents.InvokeException(e, "Could not load MySQL data for ADCTransaction ID {0}", trans.ID);
- errors.Add(e);
- }
- }
- if (errors.Count > 0)
- {
- if (!_Options.QuietMode)
- {
- foreach (Exception e in errors)
- { Console.WriteLine(e); }
- Console.WriteLine("[ADC/Tracker]: There {0} {1} error{2}.",
- errors.Count != 1 ? "are" : "is",
- errors.Count > 0 ? errors.Count.ToString("#,#") : "no",
- errors.Count != 1 ? "s" : "");
- }
- }
- }
- if (!_Options.QuietMode)
- {
- Console.WriteLine("[ADC/Tracker]: {0} ({1}) Transaction record{2} imported from MySQL.",
- count > 0 ? count.ToString("#,#") : "No",
- state.ToString(),
- count != 1 ? "s" : "");
- }
- }
- }
- public static void ExportMySQL()
- {
- ExportMySQL(ADCTransactionState.PENDING);
- ExportMySQL(ADCTransactionState.PROCESSED);
- ExportMySQL(ADCTransactionState.CLAIMED);
- ExportMySQL(ADCTransactionState.VOIDED);
- }
- public static void ExportMySQL(ADCTransactionState state)
- {
- if (Connection.Connect(_Options.MySQLRetries))
- {
- Connection.UseDatabase(_Options.MySQLDatabase);
- List<Exception> errors = new List<Exception>();
- int count = 0;
- foreach (ADCDonationProfile dp in CentralDatabase.Registry.Values)
- {
- foreach (ADCTransaction trans in dp)
- {
- try
- {
- if (trans.State != state)
- { continue; }
- if (Connection.Contains(_Options.MySQLTable, "id", new MySQLData[] { new MySQLData("id", trans.ID) }))
- {
- Connection.Update(_Options.MySQLTable, new MySQLData[] {
- new MySQLData("state", trans.State),
- new MySQLData("version", trans.Version),
- new MySQLData("notes", trans.Notes),
- new MySQLData("extra", trans.Extra)},
- new MySQLData[] { new MySQLData("id", trans.ID) });
- }
- else
- {
- Connection.Insert(_Options.MySQLTable, new MySQLData[] {
- new MySQLData("id", trans.ID),
- new MySQLData("state", trans.State),
- new MySQLData("account", trans.Account.Username),
- new MySQLData("email", trans.Email),
- new MySQLData("total", trans.Total),
- new MySQLData("credit", trans.Credit.Value),
- new MySQLData("time", trans.Time.Stamp),
- new MySQLData("version", trans.Version),
- new MySQLData("notes", trans.Notes),
- new MySQLData("extra", trans.Extra)});
- }
- count++;
- }
- catch (Exception e)
- {
- ADCEvents.InvokeException(e, "Could not save MySQL data for ADCTransaction ID {0}", trans.ID);
- errors.Add(e);
- }
- }
- }
- if (errors.Count > 0)
- {
- if (!_Options.QuietMode)
- {
- foreach (Exception e in errors)
- { Console.WriteLine(e); }
- Console.WriteLine("[ADC/Tracker]: There {0} {1} error{2}.",
- errors.Count != 1 ? "are" : "is",
- errors.Count > 0 ? errors.Count.ToString("#,#") : "no",
- errors.Count != 1 ? "s" : "");
- }
- }
- if (!_Options.QuietMode)
- {
- Console.WriteLine("[ADC/Tracker]: {0} ({1}) Transaction record{2} exported to MySQL.",
- count > 0 ? count.ToString("#,#") : "No",
- state.ToString(),
- count != 1 ? "s" : "");
- }
- }
- }
- public static void Register(IAccount a, ADCDonationProfile dp)
- {
- if (a == null || dp == null)
- {
- if (a == null && dp == null)
- { ADCEvents.InvokeException(new ArgumentNullException("Account `a`, DonationProfile `dp`"), "Failed to register unknown DonationProfile to unknown Account"); }
- else if (a == null && dp != null)
- { ADCEvents.InvokeException(new ArgumentNullException("Account `a`"), "Failed to register DonationProfile `{0}` to unknown Account", dp); }
- else if (a != null && dp == null)
- { ADCEvents.InvokeException(new ArgumentNullException("DonationProfile `dp`"), "Failed to register unknown DonationProfile to Account `{0}`", a); }
- return;
- }
- if (CentralDatabase.Registry.ContainsKey(a))
- { CentralDatabase.Registry[a] = dp; }
- else
- { CentralDatabase.Registry.Add(a, dp); }
- }
- public static ADCDonationProfile Find(IAccount a)
- {
- if (a == null)
- { return null; }
- if (Validate(a))
- { return CentralDatabase.Registry[a]; }
- return null;
- }
- public static IAccount Find(ADCDonationProfile dp)
- {
- if (dp == null)
- { return null; }
- if (CentralDatabase.Registry.ContainsValue(dp))
- {
- foreach (KeyValuePair<IAccount, ADCDonationProfile> kvp in CentralDatabase.Registry)
- {
- if (kvp.Value == dp)
- { return kvp.Key; }
- }
- }
- return null;
- }
- public static bool Validate(IAccount a)
- {
- if (a == null)
- { return false; }
- return (CentralDatabase.Registry.ContainsKey(a));
- }
- }
- }
Add Comment
Please, Sign In to add comment