示例#1
0
        public void LoadOffer()
        {
            CurrentOffer = null;

            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                queryReactor.SetQuery("SELECT * FROM catalog_targeted_offers WHERE enabled = '1' LIMIT 1");

                DataRow row = queryReactor.GetRow();

                if (row == null)
                    return;

                CurrentOffer = new TargetedOffer((int)row["id"], (string)row["identifier"], (uint)row["cost_credits"],
                    (uint)row["cost_duckets"], (uint)row["cost_diamonds"], (int)row["purchase_limit"],
                    (int)row["expiration_time"], (string)row["title"], (string)row["description"],
                    (string)row["image"], (string)row["products"]);
            }
        }
示例#2
0
        internal static void GenerateMessage(ServerMessage message, TargetedOffer offer)
        {
            message.Init(LibraryParser.OutgoingRequest("TargetedOfferMessageComposer"));
            message.AppendInteger(1);
            message.AppendInteger(offer.Id);
            message.AppendString(offer.Identifier);
            message.AppendString(offer.Identifier);
            message.AppendInteger(offer.CostCredits);

            if (offer.CostDiamonds > 0)
            {
                message.AppendInteger(offer.CostDiamonds);
                message.AppendInteger(105);
            }
            else
            {
                message.AppendInteger(offer.CostDuckets);
                message.AppendInteger(0);
            }

            message.AppendInteger(offer.PurchaseLimit);

            int timeLeft = offer.ExpirationTime - Yupi.GetUnixTimeStamp();

            message.AppendInteger(timeLeft);
            message.AppendString(offer.Title);
            message.AppendString(offer.Description);
            message.AppendString(offer.Image);
            message.AppendString(string.Empty);
            message.StartArray();

            foreach (string product in offer.Products)
            {
                message.AppendString(product);
                message.SaveArray();
            }

            message.EndArray();
        }