public DonationTransactionOverviewGump( PlayerMobile user, Gump parent, DonationProfile profile, DonationTransaction trans) : base(user, parent) { Profile = profile; Transaction = trans; }
public static void DisplayTo(Mobile user, DonationProfile profile, bool refreshOnly, string node) { var info = EnumerateInstances<DonationProfileUI>(user).FirstOrDefault(g => g != null && !g.IsDisposed && g.IsOpen); if (info == null) { if (refreshOnly) { return; } info = new DonationProfileUI(user, profile); } else if (profile != null) { info.Profile = profile; } if (!String.IsNullOrWhiteSpace(node)) { info.SelectedNode = node; } info.Refresh(true); }
public DonationGiftGump( PlayerMobile user, Gump parent, DonationProfile profile, DonationTransaction trans, PlayerMobile to = null) : base(user, parent) { Profile = profile; Transaction = trans; To = to; }
public static void DisplayTo(Mobile user, DonationProfile profile, bool refreshOnly, DonationTransaction trans) { var node = trans.IsPending ? ("Transactions|Pending|" + trans.ID) : trans.IsProcessed // ? ("Transactions|Claim|" + trans.ID) : !trans.Hidden // ? ("History|" + trans.FullPath) : "History"; DisplayTo(user, profile, refreshOnly, node); }
private static Tuple<IAccount, DonationProfile> DeserializeProfiles(GenericReader reader) { IAccount key = null; DonationProfile val = null; var version = reader.GetVersion(); reader.ReadBlock( r => { key = r.ReadAccount(); switch (version) { case 1: val = new DonationProfile(r); break; case 0: val = r.ReadTypeCreate<DonationProfile>(r); break; } }); if (key == null) { if (val != null && val.Account != null) { key = val.Account; } else { return null; } } return Tuple.Create(key, val); }
protected virtual string GetSearchKey(DonationProfile profile) { return String.Format("{0}", profile.Account); }
public static void Register(IAccount a, DonationProfile dp) { if (a == null || dp == null) { if (a == null && dp == null) { OnExceptionThrown(new ArgumentNullException("a"), "Failed to register unknown DonationProfile to unknown Account"); } else if (a == null) { OnExceptionThrown( new ArgumentNullException("a"), "Failed to register DonationProfile `{0}` to unknown Account", dp); } else { OnExceptionThrown(new ArgumentNullException("a"), "Failed to register unknown DonationProfile to Account `{0}`", a); } return; } if (!Profiles.ContainsKey(a)) { Profiles.Add(a, dp); } else { Profiles[a] = dp; } }
private static bool SerializeProfiles(GenericWriter writer, IAccount key, DonationProfile val) { var version = writer.SetVersion(1); writer.WriteBlock( w => { w.Write(key); switch (version) { case 1: val.Serialize(w); break; case 0: w.WriteType(val, t => val.Serialize(w)); break; } }); return true; }
public static void DisplayTo(Mobile user, DonationProfile profile, string node) { DisplayTo(user, profile, false, node); }
public static void DisplayTo(Mobile user, DonationProfile profile, bool refreshOnly) { DisplayTo(user, profile, refreshOnly, String.Empty); }
private static void ImportMySQL(DonationTransactionState state) { Connection.UseDatabase(CMOptions.MySQL.Database); int count = 0; var rows = Connection.Select( CMOptions.TableName, null, new[] {new MySQLCondition("state", state.ToString().ToUpper())}, "time", MySQLSortOrder.ASC); if (Connection.HasError) { if (!CMOptions.ModuleQuietMode) { foreach (OdbcError e in Connection.Errors) { OnExceptionThrown(new Exception(e.Message), "OdbcError"); } } } else if (rows.Length > 0) { var gTrans = new List<DonationTransaction>(rows.Length); foreach (MySQLRow row in rows) { VitaNexCore.TryCatch( () => { var total = row["total"].GetValue<decimal>(); var 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>(); IAccount a = Accounts.GetAccount(account ?? String.Empty) ?? Accounts.GetAccounts().FirstOrDefault(ac => ac.AccessLevel == AccessLevel.Owner); DonationTransactionState s; if (a == null || !Enum.TryParse(status, true, out s)) { s = DonationTransactionState.Void; } gTrans.Add(new DonationTransaction(id, s, a, email, total, credit, time, version, notes, extra)); ++count; }, e => OnExceptionThrown(e, "Could not load MySQL data for transaction in row {0:#,0}", row.ID)); } gTrans.TrimExcess(); foreach (DonationTransaction trans in gTrans) { VitaNexCore.TryCatch( () => { DonationProfile dp; if (!Profiles.TryGetValue(trans.Account, out dp)) { Profiles.Add(trans.Account, dp = new DonationProfile(trans.Account)); } else if (dp == null) { Profiles[trans.Account] = dp = new DonationProfile(trans.Account); } if (!dp.Contains(trans)) { dp.Add(trans); } switch (trans.State) { case DonationTransactionState.Pending: { if (dp.Process(trans)) { } } break; case DonationTransactionState.Processed: break; case DonationTransactionState.Claimed: break; case DonationTransactionState.Void: { if (dp.Void(trans)) { } } break; } }, e => OnExceptionThrown(e, "Could not load MySQL data for transaction ID {0}", trans.ID)); } } CMOptions.ToConsole("Imported {0} {1} transactions.", count, state); }
public TransExchangeEventArgs(DonationTransaction trans, DonationProfile dp) { Transaction = trans; Profile = dp; Exchanged = Transaction.Credit; }
protected override void Compile() { _Admin = User.AccessLevel >= AutoDonate.Access; if (Profile == null || Profile.Account == null || (!_Admin && User.AccessLevel <= Profile.Account.AccessLevel && !Profile.Account.IsSharedWith(User.Account))) { Profile = AutoDonate.EnsureProfile(User.Account); } if (Profile != null) { _DonationTier = Profile.Tier; _DonationValue = Profile.TotalValue; _DonationCredit = Profile.TotalCredit; _DonationCount = _Admin ? Profile.Transactions.Count : Profile.Visible.Count(); Title = "Donations: " + Profile.Account; } base.Compile(); }
public static IAccount Find(DonationProfile dp) { return dp != null && Profiles.ContainsValue(dp) ? Profiles.FirstOrDefault(kvp => kvp.Value == dp).Key : null; }
public DonationProfileUI(Mobile user, DonationProfile profile = null) : base(user, null, null, null, null, null, "Donations") { _Indicies = new int[3, 2]; _Transactions = new List<DonationTransaction>(); Profile = profile; CanMove = true; CanClose = true; CanDispose = true; CanResize = false; AutoRefreshRate = TimeSpan.FromMinutes(1.0); AutoRefresh = true; ForceRecompile = true; }
public TransPackEventArgs(DonationTransaction trans, DonationProfile dp, Container cont) { Transaction = trans; Profile = dp; Container = cont; }
public static Container InvokeTransPack(DonationTransaction trans, DonationProfile dp) { var cont = new Bag { Name = "A Donation Reward Bag", Hue = 1152 }; var e = new TransPackEventArgs(trans, dp, cont); if (OnTransPack != null) { OnTransPack(e); } return e.Container; }
protected virtual void OnProfileInfo(DonationProfile profile) { Refresh(true); DonationProfileUI.DisplayTo(User, profile, false); }
public static void DisplayTo(Mobile user, DonationProfile profile) { DisplayTo(user, profile, String.Empty); }
public static void DisplayTo(Mobile user, DonationProfile profile, DonationTransaction trans) { DisplayTo(user, profile, false, trans); }
public static long InvokeTransExchange(DonationTransaction trans, DonationProfile dp) { var e = new TransExchangeEventArgs(trans, dp); if (OnTransExchange != null) { OnTransExchange(e); } return e.Exchanged; }
private static bool SerializeProfiles(GenericWriter writer, IAccount key, DonationProfile val) { int version = writer.SetVersion(0); switch (version) { case 0: { writer.WriteBlock( w => { w.Write(key); w.WriteType(val, t => val.Serialize(w)); }); } break; } return true; }
public static DonationProfile EnsureProfile(IAccount a) { var p = Profiles.GetValue(a); if (p == null && a != null) { Profiles[a] = p = new DonationProfile(a); } return p; }