public DonationTransactionOverviewGump( PlayerMobile user, Gump parent, DonationProfile profile, DonationTransaction trans) : base(user, parent) { Profile = profile; Transaction = trans; }
public static void InvokeTransProcessed(DonationTransaction trans) { if (OnTransProcessed != null) { OnTransProcessed(new TransProcessedEventArgs(trans)); } }
public static void InvokeTransDelivered(DonationTransaction trans) { if (OnTransDelivered != null) { OnTransDelivered.Invoke(new TransDeliveredEventArgs(trans)); } }
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); }
public TransClaimedEventArgs(DonationTransaction trans) { Transaction = trans; }
protected virtual string GetSearchKey(DonationTransaction trans) { return String.Format( "{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}", trans.ID, trans.State, trans.Time, trans.Account, trans.Email, trans.Notes, trans.Extra, trans.DeliveredTo != null ? trans.DeliveredTo.RawName : String.Empty); }
public static long InvokeTransExchange(DonationTransaction trans, DonationProfile dp) { var e = new TransExchangeEventArgs(trans, dp); if (OnTransExchange != null) { OnTransExchange(e); } return e.Exchanged; }
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); }
protected virtual void OnTransactionDelete(DonationTransaction trans) { new ConfirmDialogGump(User, Refresh()) { Title = "Delete Transaction", Html = "Click OK to delete this thransaction.\nThis action can not be undone!", AcceptHandler = b => { if (AutoDonate.Transactions.Remove(trans.ID)) { trans.DeliveredTo = null; trans.SetAccount(null); } User.SendMessage(0x55, "Transaction '{0}' has been deleted.", trans.ID); Refresh(true); }, CancelHandler = Refresh }.Send(); }
public TransPendingEventArgs(DonationTransaction trans) { Transaction = trans; }
public TransClaimedEventArgs(DonationTransaction trans, Mobile deliverTo) { Transaction = trans; DeliverTo = deliverTo; }
public TransExchangeEventArgs(DonationTransaction trans, DonationProfile dp) { Transaction = trans; Profile = dp; Exchanged = Transaction.Credit; }
public static void InvokeStateChanged(DonationTransaction trans, DonationTransactionState oldState) { if (OnStateChanged != null) { OnStateChanged.Invoke(new StateChangedEventArgs(trans, oldState)); } }
public static void DisplayTo(Mobile user, DonationProfile profile, DonationTransaction trans) { DisplayTo(user, profile, false, trans); }
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; }
public TransPackEventArgs(DonationTransaction trans, DonationProfile dp, Container cont) { Transaction = trans; Profile = dp; Container = cont; }
protected virtual void GetTransactionOverview( DonationTransaction trans, StringBuilder info, bool details, bool exchange, bool status) { if (details) { info.AppendLine(); info.AppendLine("Details"); info.AppendLine(); info.AppendLine("ID: {0}", trans.ID); info.AppendLine("Date: {0}", trans.Time.Value); if (_Admin) { info.AppendLine(); info.AppendLine("Notes: {0}", trans.Notes); info.AppendLine(); info.AppendLine("Extra: {0}", trans.Extra); } } if (exchange) { info.AppendLine(); info.AppendLine("Exchange"); info.AppendLine(); info.AppendLine( "Value: {0}{1:#,0.00} {2}", AutoDonate.CMOptions.MoneySymbol, trans.Total, AutoDonate.CMOptions.MoneyAbbr); long credit, bonus; var total = trans.GetCredit(Profile, out credit, out bonus); info.AppendLine("Credit: {0:#,0} {1}", credit, AutoDonate.CMOptions.CurrencyName); info.AppendLine("Bonus: {0:#,0} {1}", bonus, AutoDonate.CMOptions.CurrencyName); info.AppendLine("Total: {0:#,0} {1}", total, AutoDonate.CMOptions.CurrencyName); } if (status) { info.AppendLine(); info.AppendLine("Status"); info.AppendLine(); info.AppendLine("State: {0}", trans.State); switch (trans.State) { case TransactionState.Voided: info.AppendLine("Transaction has been voided."); break; case TransactionState.Pending: info.AppendLine("Transaction is pending verification."); break; case TransactionState.Processed: info.AppendLine("Transaction is complete and can be claimed."); break; case TransactionState.Claimed: { info.AppendLine("Transaction has been delivered."); info.AppendLine(); info.AppendLine("Date: {0}", trans.DeliveryTime.Value); if (trans.DeliveredTo != null) { info.AppendLine("Recipient: {0}", trans.DeliveredTo.RawName); } } break; } } }
protected virtual void OnTransactionEdit(DonationTransaction trans) { Refresh(); if (_Admin) { User.SendGump(new PropertiesGump(User, trans)); } }
protected virtual DonationTransaction CreateTransaction( string id, TransactionState state, IAccount account, string email, double total, long credit, double time, int version, string notes, string extra) { using (var stream = new MemoryStream()) { var writer = stream.GetBinaryWriter(); writer.SetVersion(0); writer.Write(id); writer.WriteFlag(state); writer.Write(account); writer.Write(email); writer.Write(total); writer.Write(credit); writer.Write(time); writer.Write(version); writer.Write(0); writer.Write(notes); writer.Write(extra); var mobiles = account.FindMobiles<PlayerMobile>().OrderByDescending(m => m.GameTime.Ticks); var recipient = mobiles.FirstOrDefault(); writer.Write(recipient); writer.Write(recipient); writer.Write(0.0); writer.Flush(); stream.Position = 0; var reader = stream.GetBinaryReader(); var t = new DonationTransaction(reader); writer.Close(); reader.Close(); return t; } }
protected virtual void OnTransactionTransfer(DonationTransaction trans) { new InputDialogGump(User, Refresh()) { Title = "Transfer Transaction", Html = "Enter the account name of the recipient for the transfer.", InputText = trans.Account != null ? trans.Account.Username : String.Empty, Callback = (b, a) => { if (User.AccessLevel >= AutoDonate.Access) { var acc = Accounts.GetAccount(a); if (acc == null) { User.SendMessage(34, "The account '{0}' does not exist.", a); } else if (trans.Account == acc) { User.SendMessage(34, "The transaction is already bound to '{0}'", a); } else { trans.SetAccount(acc); User.SendMessage(85, "The transaction has been transferred to '{0}'", a); } } Refresh(true); } }.Send(); }
public TransVoidedEventArgs(DonationTransaction trans) { Transaction = trans; }
protected virtual void OnPendingTransaction(DonationTransaction trans) { var html = new StringBuilder(); GetTransactionOverview(trans, html, false, false, true); new NoticeDialogGump(User, Refresh()) { Title = "Transaction Pending", Html = html.ToString() }.Send(); }
public static void DisplayTo(Mobile user, DonationProfile profile, DonationTransaction trans) { DisplayTo(user, profile, false, trans); }
protected virtual void OnClaimTransaction(DonationTransaction trans) { var html = new StringBuilder(); GetTransactionOverview(trans, html, false, true, false); html.AppendLine(); html.AppendLine("Click OK to claim this transaction!"); new ConfirmDialogGump(User, Refresh()) { Title = "Reward Claim", Html = html.ToString(), AcceptHandler = b => { if (trans.Claim(User)) { SelectedNode = "Transactions|" + trans.FullPath; User.SendMessage(85, "You claimed the transaction!"); } Refresh(true); } }.Send(); }
protected virtual void GetTransactionOverview( DonationTransaction trans, StringBuilder info, bool details, bool exchange, bool status) { if (details) { info.AppendLine(); info.AppendLine("Details"); info.AppendLine(); info.AppendLine("ID: {0}", trans.ID); info.AppendLine("Date: {0}", trans.Time.Value); if (_Admin) { info.AppendLine(); info.AppendLine("Notes: {0}", trans.Notes); info.AppendLine(); info.AppendLine("Extra: {0}", trans.Extra); } } if (exchange) { info.AppendLine(); info.AppendLine("Exchange"); info.AppendLine(); info.AppendLine( "Value: {0}{1:#,0.00} {2}", AutoDonate.CMOptions.MoneySymbol, trans.Total, AutoDonate.CMOptions.MoneyAbbr); long credit, bonus; var total = trans.GetCredit(Profile, out credit, out bonus); info.AppendLine("Credit: {0:#,0} {1}", credit, AutoDonate.CMOptions.CurrencyName); info.AppendLine("Bonus: {0:#,0} {1}", bonus, AutoDonate.CMOptions.CurrencyName); info.AppendLine("Total: {0:#,0} {1}", total, AutoDonate.CMOptions.CurrencyName); } if (status) { info.AppendLine(); info.AppendLine("Status"); info.AppendLine(); info.AppendLine("State: {0}", trans.State); switch (trans.State) { case TransactionState.Voided: info.AppendLine("Transaction has been voided."); break; case TransactionState.Pending: info.AppendLine("Transaction is pending verification."); break; case TransactionState.Processed: info.AppendLine("Transaction is complete and can be claimed."); break; case TransactionState.Claimed: { info.AppendLine("Transaction has been delivered."); info.AppendLine(); info.AppendLine("Date: {0}", trans.DeliveryTime.Value); if (trans.DeliveredTo != null) { info.AppendLine("Recipient: {0}", trans.DeliveredTo); } } break; } } }
protected virtual void OnClaimedTransaction(DonationTransaction trans) { var info = new StringBuilder(); GetTransactionOverview(trans, info, false, false, true); new NoticeDialogGump(User, Refresh()) { Title = "Reward Delivered", Html = info.ToString() }.Send(); }
protected virtual void OnTransactionInfo(DonationTransaction trans) { Refresh(true); var profile = AutoDonate.EnsureProfile(trans.Account); DonationProfileUI.DisplayTo(User, profile, trans); }
private static bool DeserializeTransactions(GenericReader reader) { reader.GetVersion(); reader.ReadBlockDictionary( r => { var t = new DonationTransaction(r); return new KeyValuePair<string, DonationTransaction>(t.ID, t); }, Transactions); return true; }
protected virtual void OnTransactionAdd(TransactionAddState state) { var profile = AutoDonate.EnsureProfile(state.Account); var trans = new DonationTransaction( state.ID, state.Account, state.Email, state.Value, (long)(state.Value / AutoDonate.CMOptions.CurrencyPrice), String.Empty, "{MANUAL ADD}"); AutoDonate.Transactions[trans.ID] = trans; profile.Add(trans); if (trans.Process()) { AutoDonate.SpotCheck(trans.Account); } Refresh(true); DonationProfileUI.DisplayTo(User, profile, trans); }
protected virtual void RenderTransaction(int x, int y, int w, int h, DonationTransaction t, int r, int c) { var bgCol = r % 2 != 0 ? Color.DarkSlateGray : Color.Black; var fgCol = r % 2 != 0 ? Color.White : Color.WhiteSmoke; ApplyPadding(ref x, ref y, ref w, ref h, 2); if (r < 0) // headers { var label = String.Empty; switch (c) { case -1: AddHtml(x, y, w, h, label, fgCol, bgCol); break; case 0: label = "ID"; goto case -1; case 1: label = "Date"; goto case -1; case 2: label = "Recipient"; goto case -1; case 3: label = AutoDonate.CMOptions.MoneySymbol + AutoDonate.CMOptions.MoneyAbbr; goto case -1; case 4: label = AutoDonate.CMOptions.CurrencyName; goto case -1; case 5: label = "Status"; goto case -1; } } else if (t != null) { switch (c) { case 0: // ID AddHtml(x, y, w, h, t.ID, fgCol, bgCol); break; case 1: // Date { AddHtml(x, y, w, h, t.Time.Value.ToSimpleString("m/d/y"), fgCol, bgCol); AddTooltip(t.Time.Value.ToSimpleString()); } break; case 2: // Recipient { AddHtml(x, y, w, h, t.DeliveredTo ?? String.Empty, fgCol, bgCol); if (!String.IsNullOrWhiteSpace(t.DeliveredTo)) { AddTooltip(t.DeliveryTime.Value.ToSimpleString()); } } break; case 3: // Value AddHtml(x, y, w, h, AutoDonate.CMOptions.MoneySymbol + t.Total.ToString("#,0.00"), fgCol, bgCol); break; case 4: // Credit { if (t.Bonus > 0) { AddHtml(x, y, w, h, String.Format("{0:#,0} +{1:#,0}", t.Credit, t.Bonus), fgCol, bgCol); } else { AddHtml(x, y, w, h, t.Credit.ToString("#,0"), fgCol, bgCol); } } break; case 5: // Status { string node; if (t.IsPending) { node = "Transactions|Pending|" + t.ID; } else if (t.IsProcessed) { node = "Transactions|Claim|" + t.ID; } else { node = "History|" + t.FullPath; } var label = String.Empty; var color = fgCol; switch (t.State) { case TransactionState.Voided: { label = UniGlyph.CircleX.ToString(); color = Color.IndianRed; } break; case TransactionState.Pending: { label = UniGlyph.Coffee.ToString(); color = Color.Yellow; } break; case TransactionState.Processed: { label = UniGlyph.StarEmpty.ToString(); color = Color.SkyBlue; } break; case TransactionState.Claimed: { label = UniGlyph.StarFill.ToString(); color = Color.LawnGreen; } break; } label = label.WrapUOHtmlColor(color, fgCol); label += " " + t.State.ToString(true); AddHtmlButton(x, y, w, h, b => SelectNode(node), label, fgCol, bgCol); } break; } } }
public TransVoidedEventArgs(DonationTransaction trans) { Transaction = trans; }
public TransClaimedEventArgs(DonationTransaction trans) { Transaction = trans; }
public TransProcessedEventArgs(DonationTransaction trans) { Transaction = trans; }
public TransProcessedEventArgs(DonationTransaction trans) { Transaction = trans; }
public StateChangedEventArgs(DonationTransaction trans, DonationTransactionState oldState) { Transaction = trans; OldState = oldState; }
public StateChangedEventArgs(DonationTransaction trans, TransactionState oldState) { Transaction = trans; OldState = oldState; }
public TransDeliveredEventArgs(DonationTransaction trans) { Transaction = trans; }
public TransactionDeletedEventArgs(DonationTransaction trans) { Transaction = trans; }
private static void ProcessTransaction(WebAPIQueries queries) { var id = queries["txn_id"]; if (String.IsNullOrWhiteSpace(id)) { return; } var type = queries["txn_type"]; if (String.IsNullOrWhiteSpace(type) || !type.EqualsAny(true, _AcceptedTypes)) { return; } var status = queries["payment_status"]; if (String.IsNullOrWhiteSpace(status)) { return; } TransactionState state; switch (status.Trim().ToUpper()) { case "PENDING": case "PROCESSED": case "CREATED": state = TransactionState.Pending; break; case "COMPLETED": state = TransactionState.Processed; break; default: state = TransactionState.Voided; break; } long credit; double value; ExtractCart(queries, out credit, out value); var custom = queries["custom"] ?? String.Empty; var trans = Transactions.GetValue(id); var create = trans == null; if (create) { var email = queries["payer_email"] ?? String.Empty; var notes = queries["payer_note"] ?? String.Empty; var extra = queries["extra_info"] ?? String.Empty; var a = Accounts.GetAccount(custom) ?? CMOptions.FallbackAccount; Transactions[id] = trans = new DonationTransaction(id, a, email, value, credit, notes, extra); var profile = EnsureProfile(a); if (profile == null) { state = TransactionState.Voided; trans.Extra += "{VOID: NO PROFILE}"; } else { profile.Add(trans); } } if (!VerifyValue(queries, "business", CMOptions.Business) && !VerifyValue(queries, "receiver_email", CMOptions.Business) && !VerifyValue(queries, "receiver_id", CMOptions.Business)) { state = TransactionState.Voided; trans.Extra += "{VOID: UNEXPECTED BUSINESS}"; } if (trans.Total != value) { state = TransactionState.Voided; trans.Extra += "{VOID: TOTAL CHANGED}"; } if (queries["test"] != null || queries["test_ipn"] != null) { state = TransactionState.Voided; trans.Extra += "{VOID: TESTING}"; } switch (state) { case TransactionState.Processed: trans.Process(); break; case TransactionState.Voided: trans.Void(); break; } if (create && trans.IsPending) { DonationEvents.InvokeTransPending(trans); } SpotCheck(trans.Account); }
private static void ProcessTransaction(WebAPIQueries queries) { var id = queries["txn_id"]; if (String.IsNullOrWhiteSpace(id)) { return; } var status = queries["payment_status"]; if (String.IsNullOrWhiteSpace(status)) { return; } TransactionState state; status = status.Trim(); switch (status.ToUpper()) { case "PENDING": case "IN-PROGRESS": state = TransactionState.Pending; break; case "COMPLETED": state = TransactionState.Processed; break; default: state = TransactionState.Voided; break; } long credit; double value; ExtractCart(queries, out credit, out value); var custom = queries["custom"] ?? String.Empty; var trans = Transactions.GetValue(id); if (trans == null) { var email = queries["payer_email"] ?? String.Empty; var notes = queries["payer_note"] ?? String.Empty; var extra = queries["extra_info"] ?? String.Empty; var a = Accounts.GetAccount(custom) ?? CMOptions.FallbackAccount; Transactions[id] = trans = new DonationTransaction(id, a, email, value, credit, notes, extra); var profile = EnsureProfile(a); if (profile == null) { state = TransactionState.Voided; trans.Extra += "{VOID: NO PROFILE}"; } else { profile.Add(trans); } } if (!VerifyValue(queries, "business", CMOptions.Business) && !VerifyValue(queries, "receiver_email", CMOptions.Business) && !VerifyValue(queries, "receiver_id", CMOptions.Business)) { state = TransactionState.Voided; trans.Extra += "{VOID: UNEXPECTED BUSINESS}"; } if (trans.Total != value) { state = TransactionState.Voided; trans.Extra += "{VOID: TOTAL CHANGED}"; } if (queries["test"] != null || queries["test_ipn"] != null) { state = TransactionState.Voided; trans.Extra += "{VOID: TESTING}"; } switch (state) { case TransactionState.Processed: trans.Process(); break; case TransactionState.Voided: trans.Void(); break; } SpotCheck(trans.Account); }