Пример #1
0
		public DonationTransactionOverviewGump(
			PlayerMobile user, Gump parent, DonationProfile profile, DonationTransaction trans)
			: base(user, parent)
		{
			Profile = profile;
			Transaction = trans;
		}
Пример #2
0
		public static void InvokeTransProcessed(DonationTransaction trans)
		{
			if (OnTransProcessed != null)
			{
				OnTransProcessed(new TransProcessedEventArgs(trans));
			}
		}
Пример #3
0
		public static void InvokeTransDelivered(DonationTransaction trans)
		{
			if (OnTransDelivered != null)
			{
				OnTransDelivered.Invoke(new TransDeliveredEventArgs(trans));
			}
		}
Пример #4
0
		public DonationGiftGump(
			PlayerMobile user, Gump parent, DonationProfile profile, DonationTransaction trans, PlayerMobile to = null)
			: base(user, parent)
		{
			Profile = profile;
			Transaction = trans;
			To = to;
		}
Пример #5
0
		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);
		}
Пример #6
0
			public TransClaimedEventArgs(DonationTransaction trans)
			{
				Transaction = trans;
			}
Пример #7
0
		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);
		}
Пример #8
0
		public static long InvokeTransExchange(DonationTransaction trans, DonationProfile dp)
		{
			var e = new TransExchangeEventArgs(trans, dp);

			if (OnTransExchange != null)
			{
				OnTransExchange(e);
			}

			return e.Exchanged;
		}
Пример #9
0
        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);
        }
Пример #10
0
		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();
		}
Пример #11
0
 public TransPendingEventArgs(DonationTransaction trans)
 {
     Transaction = trans;
 }
Пример #12
0
 public TransClaimedEventArgs(DonationTransaction trans, Mobile deliverTo)
 {
     Transaction = trans;
     DeliverTo   = deliverTo;
 }
Пример #13
0
			public TransExchangeEventArgs(DonationTransaction trans, DonationProfile dp)
			{
				Transaction = trans;
				Profile = dp;

				Exchanged = Transaction.Credit;
			}
Пример #14
0
		public static void InvokeStateChanged(DonationTransaction trans, DonationTransactionState oldState)
		{
			if (OnStateChanged != null)
			{
				OnStateChanged.Invoke(new StateChangedEventArgs(trans, oldState));
			}
		}
Пример #15
0
		public static void DisplayTo(Mobile user, DonationProfile profile, DonationTransaction trans)
		{
			DisplayTo(user, profile, false, trans);
		}
Пример #16
0
		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;
		}
Пример #17
0
			public TransPackEventArgs(DonationTransaction trans, DonationProfile dp, Container cont)
			{
				Transaction = trans;
				Profile = dp;

				Container = cont;
			}
Пример #18
0
		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;
				}
			}
		}
Пример #19
0
		protected virtual void OnTransactionEdit(DonationTransaction trans)
		{
			Refresh();

			if (_Admin)
			{
				User.SendGump(new PropertiesGump(User, trans));
			}
		}
Пример #20
0
        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;
            }
        }
Пример #21
0
		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();
		}
Пример #22
0
 public TransVoidedEventArgs(DonationTransaction trans)
 {
     Transaction = trans;
 }
Пример #23
0
		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();
		}
Пример #24
0
 public static void DisplayTo(Mobile user, DonationProfile profile, DonationTransaction trans)
 {
     DisplayTo(user, profile, false, trans);
 }
Пример #25
0
		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();
		}
Пример #26
0
        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;
                }
            }
        }
Пример #27
0
		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();
		}
Пример #28
0
		protected virtual void OnTransactionInfo(DonationTransaction trans)
		{
			Refresh(true);

			var profile = AutoDonate.EnsureProfile(trans.Account);

			DonationProfileUI.DisplayTo(User, profile, trans);
		}
Пример #29
0
		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;
		}
Пример #30
0
		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);
		}
Пример #31
0
        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;
                }
            }
        }
Пример #32
0
			public TransVoidedEventArgs(DonationTransaction trans)
			{
				Transaction = trans;
			}
Пример #33
0
 public TransClaimedEventArgs(DonationTransaction trans)
 {
     Transaction = trans;
 }
Пример #34
0
			public TransProcessedEventArgs(DonationTransaction trans)
			{
				Transaction = trans;
			}
Пример #35
0
 public TransProcessedEventArgs(DonationTransaction trans)
 {
     Transaction = trans;
 }
Пример #36
0
			public StateChangedEventArgs(DonationTransaction trans, DonationTransactionState oldState)
			{
				Transaction = trans;
				OldState = oldState;
			}
Пример #37
0
 public StateChangedEventArgs(DonationTransaction trans, TransactionState oldState)
 {
     Transaction = trans;
     OldState    = oldState;
 }
Пример #38
0
			public TransDeliveredEventArgs(DonationTransaction trans)
			{
				Transaction = trans;
			}
Пример #39
0
 public TransactionDeletedEventArgs(DonationTransaction trans)
 {
     Transaction = trans;
 }
Пример #40
0
        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);
        }
Пример #41
0
		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);
		}