コード例 #1
0
ファイル: Events.cs プロジェクト: thehaunted88/Core
            public TransPackEventArgs(DonationTransaction trans, DonationProfile dp, Container cont)
            {
                Transaction = trans;
                Profile     = dp;

                Container = cont;
            }
コード例 #2
0
        private static Tuple <IAccount, DonationProfile> DeserializeProfile(GenericReader reader)
        {
            var version = reader.GetVersion();

            return(reader.ReadBlock(
                       r =>
            {
                var key = r.ReadAccount();

                DonationProfile val = null;

                switch (version)
                {
                case 1:
                    val = new DonationProfile(r);
                    break;

                case 0:
                    val = r.ReadTypeCreate <DonationProfile>(r);
                    break;
                }

                if (key == null && val != null && val.Account != null)
                {
                    key = val.Account;
                }

                return Tuple.Create(key, val);
            }));
        }
コード例 #3
0
ファイル: AutoDonate.cs プロジェクト: uotools/JustUO
        private static void SpotCheck(PlayerMobile user)
        {
            if (user == null || user.Deleted || !user.IsOnline() || !user.Alive || CMOptions.Status != DataStoreStatus.Idle ||
                CMOptions.CurrencyType == null || CMOptions.ExchangeRate <= 0)
            {
                return;
            }

            DonationProfile profile = Find(user.Account);

            if (profile == null)
            {
                return;
            }

            if (profile.Any(trans => !trans.Hidden && trans.State == DonationTransactionState.Processed))
            {
                SuperGump.Send(
                    new ConfirmDialogGump(
                        user,
                        null,
                        title: "You Have Rewards!",
                        html: "You have unclaimed donation rewards!\nWould you like to view them now?",
                        onAccept: b => CheckDonate(user)));
            }
        }
コード例 #4
0
ファイル: Events.cs プロジェクト: thehaunted88/Core
            public TransExchangeEventArgs(DonationTransaction trans, DonationProfile dp)
            {
                Transaction = trans;
                Profile     = dp;

                Exchanged = Transaction.Credit;
            }
コード例 #5
0
ファイル: AutoDonate.cs プロジェクト: uotools/JustUO
        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;
            }
        }
コード例 #6
0
ファイル: TransactionGump.cs プロジェクト: uotools/JustUO
 public DonationTransactionOverviewGump(
     PlayerMobile user, Gump parent, DonationProfile profile, DonationTransaction trans)
     : base(user, parent)
 {
     Profile     = profile;
     Transaction = trans;
 }
コード例 #7
0
        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);
        }
コード例 #8
0
        private static Tuple <IAccount, DonationProfile> DeserializeProfiles(GenericReader reader)
        {
            IAccount        key = null;
            DonationProfile val = null;

            int version = reader.GetVersion();

            switch (version)
            {
            case 0:
            {
                reader.ReadBlock(
                    r =>
                    {
                        key = r.ReadAccount();
                        val = r.ReadTypeCreate <DonationProfile>(r);
                    });
            }
            break;
            }

            if (key == null)
            {
                if (val != null && val.Account != null)
                {
                    key = val.Account;
                }
                else
                {
                    return(null);
                }
            }

            return(new Tuple <IAccount, DonationProfile>(key, val));
        }
コード例 #9
0
 public DonationGiftGump(
     PlayerMobile user, Gump parent, DonationProfile profile, DonationTransaction trans, PlayerMobile to = null)
     : base(user, parent)
 {
     Profile     = profile;
     Transaction = trans;
     To          = to;
 }
コード例 #10
0
        public static DonationProfile EnsureProfile(IAccount a)
        {
            var p = Profiles.GetValue(a);

            if (p == null && a != null)
            {
                Profiles[a] = p = new DonationProfile(a);
            }

            return(p);
        }
コード例 #11
0
ファイル: Events.cs プロジェクト: thehaunted88/Core
        public static long InvokeTransExchange(DonationTransaction trans, DonationProfile dp)
        {
            var e = new TransExchangeEventArgs(trans, dp);

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

            return(e.Exchanged);
        }
コード例 #12
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);
        }
コード例 #13
0
ファイル: PlayerSelectGump.cs プロジェクト: LordEnigma/UO
 public DonationGiftPlayerSelectGump(
     PlayerMobile user,
     DonationProfile profile,
     DonationTransaction trans,
     Gump parent = null,
     IEnumerable <PlayerMobile> list = null)
     : base(user, parent, list: list)
 {
     Profile        = profile;
     Transaction    = trans;
     EntriesPerPage = 8;
 }
コード例 #14
0
ファイル: Profile.cs プロジェクト: uotools/JustUO
        public bool Equals(DonationProfile other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return(Equals(Account, other.Account));
        }
コード例 #15
0
ファイル: Events.cs プロジェクト: thehaunted88/Core
        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);
        }
コード例 #16
0
        public DonationProfileUI(Mobile user, DonationProfile profile = null)
            : base(user, null, null, null, null, null, "Donations")
        {
            _Indicies = new int[6, 2];

            Profile = profile;

            CanMove    = true;
            CanClose   = true;
            CanDispose = true;
            CanResize  = false;

            Width  = 900;
            Height = 500;

            ForceRecompile = true;
        }
コード例 #17
0
ファイル: ProfileUI.cs プロジェクト: somedude373/NeverFade
        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;

            Sorted = false;

            ForceRecompile = true;
        }
コード例 #18
0
        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;
        }
コード例 #19
0
ファイル: Transaction.cs プロジェクト: somedude373/NeverFade
        private long GetCredit(DonationProfile dp, bool delivering, out long credit, out long bonus)
        {
            if (!delivering && State != TransactionState.Processed)
            {
                return((credit = Credit) + (bonus = Bonus));
            }

            var total = DonationEvents.InvokeTransExchange(this, dp);

            if (AutoDonate.CMOptions.CreditBonus > 0)
            {
                total += (long)Math.Floor(Credit * AutoDonate.CMOptions.CreditBonus);
            }

            bonus  = Math.Max(0, total - Credit);
            credit = Math.Max(0, total - bonus);

            return(total);
        }
コード例 #20
0
        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);
        }
コード例 #21
0
        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();
        }
コード例 #22
0
        private static bool SerializeProfile(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);
        }
コード例 #23
0
 public static void DisplayTo(Mobile user, DonationProfile profile, string node)
 {
     DisplayTo(user, profile, false, node);
 }
コード例 #24
0
 public DonationProfileGump(PlayerMobile user, DonationProfile profile, Gump parent = null)
     : base(user, parent)
 {
     Profile        = profile;
     EntriesPerPage = 8;
 }
コード例 #25
0
 public static void DisplayTo(Mobile user, DonationProfile profile)
 {
     DisplayTo(user, profile, String.Empty);
 }
コード例 #26
0
ファイル: AutoDonate.cs プロジェクト: uotools/JustUO
        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);
        }
コード例 #27
0
ファイル: AutoDonate.cs プロジェクト: uotools/JustUO
        public static void CheckDonate(PlayerMobile user, bool message = true)
        {
            if (user == null || user.Deleted)
            {
                return;
            }

            if (!CMOptions.ModuleEnabled)
            {
                if (message)
                {
                    user.SendMessage("The donation system is currently unavailable, please try again later.");
                }

                return;
            }

            if (!user.Alive)
            {
                if (message)
                {
                    user.SendMessage("You must be alive to use this command!");
                }

                return;
            }

            if (CMOptions.Status != DataStoreStatus.Idle)
            {
                if (message)
                {
                    user.SendMessage("The donation system is busy, please try again in a few moments.");
                }

                return;
            }

            if (CMOptions.CurrencyType == null || CMOptions.ExchangeRate <= 0)
            {
                if (message)
                {
                    user.SendMessage("Currency conversion is currently disabled - contact a member of staff to handle your donations.");
                }

                return;
            }

            DonationProfile profile = Find(user.Account);

            if (profile != null)
            {
                if (profile.Transactions.Count == 0 || profile.TrueForAll(trans => trans.Hidden))
                {
                    if (message)
                    {
                        user.SendMessage("There are no current donation records for your account.");
                    }
                }
                else
                {
                    if (message)
                    {
                        user.SendMessage("Thank you for your donation{0}, {1}!", profile.Transactions.Count != 1 ? "s" : "", user.RawName);
                    }

                    new DonationProfileGump(user, profile).Send();
                }
            }
            else if (message)
            {
                user.SendMessage("There are no current donation records for your account.");
            }
        }
コード例 #28
0
ファイル: AutoDonate.cs プロジェクト: uotools/JustUO
 public static IAccount Find(DonationProfile dp)
 {
     return(dp != null && Profiles.ContainsValue(dp) ? Profiles.FirstOrDefault(kvp => kvp.Value == dp).Key : null);
 }
コード例 #29
0
ファイル: Profile.cs プロジェクト: thehaunted88/Core
		public bool Equals(DonationProfile other)
		{
			return !ReferenceEquals(other, null) && (ReferenceEquals(other, this) || UID.Equals(other.UID));
		}
コード例 #30
0
 public static void DisplayTo(Mobile user, DonationProfile profile, bool refreshOnly)
 {
     DisplayTo(user, profile, refreshOnly, String.Empty);
 }