Example #1
0
 public EntityMinecart (TypedEntity e)
     : base(e)
 {
     EntityMinecart e2 = e as EntityMinecart;
     if (e2 != null) {
         _type = e2._type;
     }
 }
Example #2
0
        /// <summary>
        /// Creates an instance of the specified cart.
        /// </summary>
        /// <param name="romBytes"></param>
        /// <param name="cartType"></param>
        /// <exception cref="Emu7800Exception">Specified CartType is unexpected.</exception>
        public static Cart Create(byte[] romBytes, CartType cartType)
        {
            if (cartType == CartType.None)
            {
                switch (romBytes.Length)
                {
                    case 2048:
                        cartType = CartType.A2K;
                        break;
                    case 4096:
                        cartType = CartType.A4K;
                        break;
                    case 8192:
                        cartType = CartType.A8K;
                        break;
                    case 16384:
                        cartType = CartType.A16K;
                        break;
                    case 32768:
                        cartType = CartType.A32K;
                        break;
                }
            }

            switch (cartType)
            {
                case CartType.A2K:     return new CartA2K(romBytes);
                case CartType.A4K:     return new CartA4K(romBytes);
                case CartType.A8K:     return new CartA8K(romBytes);
                case CartType.A8KR:    return new CartA8KR(romBytes);
                case CartType.A16K:    return new CartA16K(romBytes);
                case CartType.A16KR:   return new CartA16KR(romBytes);
                case CartType.DC8K:    return new CartDC8K(romBytes);
                case CartType.PB8K:    return new CartPB8K(romBytes);
                case CartType.TV8K:    return new CartTV8K(romBytes);
                case CartType.CBS12K:  return new CartCBS12K(romBytes);
                case CartType.A32K:    return new CartA32K(romBytes);
                case CartType.A32KR:   return new CartA32KR(romBytes);
                case CartType.MN16K:   return new CartMN16K(romBytes);
                case CartType.DPC:     return new CartDPC(romBytes);
                case CartType.M32N12K: return new CartA2K(romBytes, _multicartBankSelector++);
                case CartType.A7808:   return new Cart7808(romBytes);
                case CartType.A7816:   return new Cart7816(romBytes);
                case CartType.A7832P:  return new Cart7832P(romBytes);
                case CartType.A7832:   return new Cart7832(romBytes);
                case CartType.A7848:   return new Cart7848(romBytes);
                case CartType.A78SGP:  return new Cart78SGP(romBytes);
                case CartType.A78SG:   return new Cart78SG(romBytes, false);
                case CartType.A78SGR:  return new Cart78SG(romBytes, true);
                case CartType.A78S9:   return new Cart78S9(romBytes);
                case CartType.A78S4:   return new Cart78S4(romBytes, false);
                case CartType.A78S4R:  return new Cart78S4(romBytes, true);
                case CartType.A78AB:   return new Cart78AB(romBytes);
                case CartType.A78AC:   return new Cart78AC(romBytes);
                default:
                    throw new Emu7800Exception("Unexpected CartType: " + cartType);
            }
        }
Example #3
0
        public override TypedEntity LoadTree (TagNode tree)
        {
            TagNodeCompound ctree = tree as TagNodeCompound;
            if (ctree == null || base.LoadTree(tree) == null) {
                return null;
            }

            _type = (CartType)ctree["Type"].ToTagInt().Data;

            switch (_type) {
                case CartType.EMPTY:
                    return this;
                case CartType.CHEST:
                    return new EntityMinecartChest().LoadTreeSafe(tree);
                case CartType.FURNACE:
                    return new EntityMinecartFurnace().LoadTreeSafe(tree);
                default:
                    return this;
            }
        }
Example #4
0
        private MemoryBankController CreateMBC(CartType cartType, Stream fileStream)
        {
            MemoryBankController mbc = null;

            switch (cartType)
            {
                case CartType.RomOnly:
                    mbc = new RomOnly(fileStream);
                    break;
                case CartType.MBC1:
                    mbc = new Mbc1(fileStream);
                    break;
                case CartType.MBC2:
                    mbc = new Mbc2(fileStream);
                    break;
            }

            return mbc;
        }
        /// <summary>
        /// Return the rules related to the cart, telling what type of extraction and upload options are valid
        /// These are general rules related to the cart type, not specific to the client.
        /// </summary>
        /// <returns>DashCartDefinition</returns>
        public static DashCartDefinition GetCartRules(CartType cartType)
        {
            //note, this is defined here instead of using an abstract method
            //so that cart rules can exist for cart types that don't have extractors

            var rules = new DashCartDefinition{ CartId = (int)cartType, CartValue = cartType.ToString() };
            switch (cartType)
            {
                case CartType.BigCommerce:
                    rules.CartDisplayName = "BigCommerce";
                    rules.HasCartExtractor = true;
                    rules.CanExtractCatalog = true;
                    rules.CanExtractAllSales = true;
                    rules.CanExtractSalesUpdate = false;
                    rules.HasManualUpload = true;
                    rules.HasManualUploadLink = false;
                    break;
                case CartType.CommerceV3:
                    rules.CartDisplayName = "Commerce V3";
                    rules.HasCartExtractor = true;
                    rules.CanExtractCatalog = true;
                    rules.CanExtractAllSales = true;
                    rules.CanExtractSalesUpdate = false;
                    rules.HasManualUpload = true;
                    rules.HasManualUploadLink = false;
                    break;
                case CartType.MivaMerchant:
                    rules.CartDisplayName = "MivaMerchant";
                    rules.HasCartExtractor = true;
                    rules.CanExtractCatalog = true;
                    rules.CanExtractAllSales = true;
                    rules.CanExtractSalesUpdate = true;
                    rules.HasManualUpload = true;
                    rules.HasManualUploadLink = false;
                    break;
                case CartType.ThreeDCart:
                    rules.CartDisplayName = "3dcart";
                    rules.HasCartExtractor = true;
                    rules.CanExtractCatalog = true;
                    rules.CanExtractAllSales = true;
                    rules.CanExtractSalesUpdate = false;
                    rules.HasManualUpload = true;
                    rules.HasManualUploadLink = false;
                    break;
                case CartType.Volusion:
                    rules.CartDisplayName = "Volusion";
                    rules.HasCartExtractor = true;
                    rules.CanExtractCatalog = true;
                    rules.CanExtractAllSales = true;
                    rules.CanExtractSalesUpdate = false;
                    rules.HasManualUpload = true;
                    rules.HasManualUploadLink = false;
                    break;
                case CartType.Shopify:
                    rules.CartDisplayName = "Shopify";
                    rules.HasCartExtractor = true;
                    rules.CanExtractCatalog = true;
                    rules.CanExtractAllSales = true;
                    rules.CanExtractSalesUpdate = true;
                    rules.HasManualUpload = true;
                    rules.HasManualUploadLink = false;
                    break;
                case CartType.NetSuite:
                    rules.CartDisplayName = "NetSuite";
                    rules.HasCartExtractor = true;
                    rules.CanExtractCatalog = true;
                    rules.CanExtractAllSales = true;
                    rules.CanExtractSalesUpdate = true;
                    rules.HasManualUpload = true;
                    rules.HasManualUploadLink = false;
                    break;
                case CartType.JsonFeed:
                    rules.CartDisplayName = "JsonFeed";
                    rules.HasCartExtractor = true;
                    rules.CanExtractCatalog = true;
                    rules.CanExtractAllSales = true;
                    rules.CanExtractSalesUpdate = true;
                    rules.HasManualUpload = true;
                    rules.HasManualUploadLink = false;
                    break;
                case CartType.XmlFeed:
                    rules.CartDisplayName = "XmlFeed";
                    rules.HasCartExtractor = true;
                    rules.CanExtractCatalog = true;
                    rules.CanExtractAllSales = true;
                    rules.CanExtractSalesUpdate = true;
                    rules.HasManualUpload = true;
                    rules.HasManualUploadLink = false;
                    break;
                case CartType.TabbedFeed:
                case CartType.osCommerce:
                case CartType.Magento:
                case CartType.PrestaShop:
                case CartType.WebsitePipeline:
                case CartType.Other:
                default:
                    rules.CartDisplayName = cartType.ToString();
                    rules.HasCartExtractor = false;
                    rules.CanExtractCatalog = false;
                    rules.CanExtractAllSales = false;
                    rules.CanExtractSalesUpdate = false;
                    rules.HasManualUpload = true;
                    rules.HasManualUploadLink = false;
                    break;
            }
            return rules;
        }
Example #6
0
        static Cart New(BinaryReader rom, CartType cartType)
        {
            Cart c;

            switch (cartType)
            {
                case CartType.A2K:
                    c = new CartA2K(rom);
                    break;
                case CartType.A4K:
                    c = new CartA4K(rom);
                    break;
                case CartType.A8K:
                    c = new CartA8K(rom);
                    break;
                case CartType.A8KR:
                    c = new CartA8KR(rom);
                    break;
                case CartType.A16K:
                    c = new CartA16K(rom);
                    break;
                case CartType.A16KR:
                    c = new CartA16KR(rom);
                    break;
                case CartType.DC8K:
                    c = new CartDC8K(rom);
                    break;
                case CartType.PB8K:
                    c = new CartPB8K(rom);
                    break;
                case CartType.TV8K:
                    c = new CartTV8K(rom);
                    break;
                case CartType.CBS12K:
                    c = new CartCBS12K(rom);
                    break;
                case CartType.A32K:
                    c = new CartA32K(rom);
                    break;
                case CartType.A32KR:
                    c = new CartA32KR(rom);
                    break;
                case CartType.MN16K:
                    c = new CartMN16K(rom);
                    break;
                case CartType.DPC:
                    c = new CartDPC(rom);
                    break;
                case CartType.A7808:
                    c = new Cart7808(rom);
                    break;
                case CartType.A7816:
                    c = new Cart7816(rom);
                    break;
                case CartType.A7832P:
                case CartType.A7832:
                    c = new Cart7832(rom);
                    break;
                case CartType.A7848:
                    c = new Cart7848(rom);
                    break;
                case CartType.A78SGP:
                case CartType.A78SG:
                    c = new Cart78SG(rom, false);
                    break;
                case CartType.A78SGR:
                    c = new Cart78SG(rom, true);
                    break;
                case CartType.A78S9:
                    c = new Cart78S9(rom);
                    break;
                case CartType.A78S4:
                    c = new Cart78S4(rom, false);
                    break;
                case CartType.A78S4R:
                    c = new Cart78S4(rom, true);
                    break;
                case CartType.A78AB:
                    c = new Cart78AB(rom);
                    break;
                case CartType.A78AC:
                    c = new Cart78AC(rom);
                    break;
                default:
                    throw new Exception("Unexpected CartType: " + cartType.ToString());
            }
            return c;
        }
Example #7
0
        private bool SaveCart(SessionCart tempCart, CartSummary summary, int userId, string transactionId, CartType cartType)
        {
            try
            {
                Cart cart = new Cart
                {
                    TransactionDate = DateTime.Now,
                    TransactionId = transactionId,
                    UserId = userId,
                    CartType = cartType,
                    CartItems = new List<CartItem>(),
                    TotalCost = summary.TotalCost
                };

                _repository.Carts.Create(cart);
                _repository.SaveChanges();

                foreach (var summaryItem in summary.CartItems)
                {
                    CartItem newItem = new CartItem
                        {
                            CartId = cart.CartId,
                            PurchaseItemId = summaryItem.PurchaseItemId,
                            Cost = summaryItem.ItemCost,
                            Total = summaryItem.ItemTotal,
                            StandAloneItem = summaryItem.ProcessType == ProcessType.Individual ? true : false,
                            LocalTaxPercentage = summaryItem.LocalTaxPercentage,
                            LocalTaxValue = summaryItem.LocalTax,
                            StateTaxPercentage = summaryItem.StateTaxPercentage,
                            StateTaxValue = summaryItem.StateTax,
                            DiscountItemId = summaryItem.DiscountItemId,
                            DiscountValue = summaryItem.DiscountValue,
                            DiscountType = summaryItem.DiscountType,
                            DiscountValueTotal = summaryItem.DiscountTotal
                        };

                    cart.CartItems.Add(newItem);

                    _repository.SaveChanges();

                    if (summaryItem.SessionKey.HasValue && tempCart.ActionItems[summaryItem.SessionKey.Value].ActionObject != null)
                    {
                        ActionItem action = tempCart.ActionItems[summaryItem.SessionKey.Value];
                        int? discountId = summaryItem.DiscountItemId;
                        CompleteActions(action, newItem.CartItemId, discountId, transactionId);
                    }

                }

                IEmailService emailService = new EmailService();
                emailService.SendPaymentConfirmationEmail(cart.CartId);

                tempCart.ResultingConfirmationCode = cart.TransactionId;

                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
Example #8
0
		public static extern bool libyabause_init(ref CDInterface intf, string biosfn, bool usegl, CartType carttype, bool quickload, bool clocksync, int clockbase);
        private CartExtractor m_cart; //cart specific settings are stored in the cart extractor

        #endregion Fields

        #region Constructors

        public Client(XElement settings, bool createCart = true)
        {
            Alias = GetValue(settings, "alias");
            PocName = GetValue(settings, "pocName");
            PocEmail = GetValue(settings, "pocEmail");
            ReportLevel = GetValue(settings, "reportLevel");

            IEnumerable<XElement> ipList = settings.Elements("approvedUploadIP");
            if (ipList != null)
                UploadAddresses = ipList.Select(ip => ip.Value).ToList<string>();

            CartLevel = 0;
            m_cart = null;
            if (createCart)
            {
                try
                {
            #if DEBUG
                    string test = GetValue(settings, "cartType");
                    BoostLog.Instance.WriteEntry(string.Format("CartType for {0} is {1}", Alias, test),EventLogEntryType.Information, Alias);
            #endif
                    CartType = (CartType)Enum.Parse(typeof(CartType), GetValue(settings, "cartType"), true);
                    string level = GetValue(settings, "cartLevel");
                    switch (CartType)
                    {
                        case CartType.Magento:
                            MagentoLevel mLevel = (MagentoLevel)Enum.Parse(typeof(MagentoLevel), level, true);
                            CartLevel = (int)mLevel;
                            if (mLevel == MagentoLevel.Go)
                                m_cart = (CartExtractor)new MagentoExtractor(Alias, settings);
                            break;
                        case CartType.ThreeDCart:
                            ThreeDCartLevel tLevel = (ThreeDCartLevel)Enum.Parse(typeof(ThreeDCartLevel), level, true);
                            CartLevel = (int)tLevel;
                            m_cart = (CartExtractor)new ThreeDCartExtractor(Alias, settings);
                            break;
                        case CartType.Volusion:
                            CartLevel = 0;
                            m_cart = (CartExtractor)new VolusionExtractor(Alias, settings);
                            break;
                        case CartType.MivaMerchant:
                            CartLevel = 0;
                            m_cart = (CartExtractor)new MivaMerchantExtractor(Alias, settings);
                            break;
                        case CartType.BigCommerce:
                            CartLevel = 0;
                            m_cart = (CartExtractor)new BigCommerceExtractor(Alias, settings);
                            break;
                        default:
                            if (level.Length > 0)
                                CartLevel = Convert.ToInt32(level); //default is just a numeric level
                            break;
                    }
                }
                catch
                {
                    CartType = CartType.other;
                    m_cart = null;
                    CartLevel = 0;
                }
            }
        }
 public ArrayList GetAliasList(CartType cart)
 {
     var aliasList = new ArrayList();
     foreach (Client c in m_clients)
     {
         if (c.CartType == cart)
             aliasList.Add(c.Alias);
     }
     return aliasList;
 }
        /// <summary>
        /// Creates a newset of SiteRules using the default settings for the given cart type
        /// </summary>
        /// <param name="alias"></param>
        /// <param name="url"></param>
        /// <param name="tier"></param>
        /// <param name="cart"></param>
        /// <param name="key"></param>
        public SiteRules(string alias, string url, BoostTier tier, CartType cart, string key, bool saveRules = true)
        {
            Alias = alias;
            StoreShortUrl = CleanUpUrl(url);
            Tier = tier;
            CartType = cart;
            ApiKey = key; //auto-calculated key is removed for certain platforms in SetCartDefaults

            InitializeStructures();
            SetDefaultValues();
            SetCartDefaults();
            if (saveRules)
                QueueSettings();
        }
        public XElement ReadCartRules(CartType cartType)
        {
            //TODO: define rules to read files uploaded from osCommerce
            if (cartType.Equals(CartType.osCommerce) || cartType.Equals(CartType.Other))
                return null;

            XElement cartRules;
            lock (_cartRules)
            {
                if (!_cartRules.TryGetValue(cartType, out cartRules))
                {
                    var path = "";
                    try
                    {
                        path = DataPath.Instance.Root + cartType.ToString() + "Rules.xml";
                        cartRules = XElement.Load(path);
                        if (!cartRules.IsEmpty)
                            _cartRules.Add(cartType, cartRules);
                    }
                    catch (Exception ex)
                    {
                        if (BoostLog.Instance != null)
                            BoostLog.Instance.WriteEntry(EventLogEntryType.Error, "Error reading CartRules from " + path, ex, "");
                    }
                }
            }
            return cartRules;
        }
Example #13
0
    void UpdateCart(int id, RepeaterItem item, CartType mode)
    {
        dsCart.CartRow drCart = da.Cart_GetDataByID(id);
        if (drCart != null)
        {
            #region Optional Items
            // Only applicable to machine
            if (mode == CartType.Machine)
            {
                Repeater repOptional = (Repeater)item.FindControl("repOptional");
                foreach (RepeaterItem itemOptional in repOptional.Items)
                {
                    HiddenField hidOptionalItemID = (HiddenField)itemOptional.FindControl("hidOptionalItemID");

                    TextBox txtOptionalQuantity = (TextBox)itemOptional.FindControl("txtOptionalQuantity");

                    dsCartOptionalItem.CartOptionalItemRow cartOptionalRow = da.CartOptionalItem_Get(int.Parse(hidOptionalItemID.Value));
                    if (Common.IsNum(txtOptionalQuantity.Text) && int.Parse(txtOptionalQuantity.Text) <= 9999)
                        cartOptionalRow.Quantity = int.Parse(txtOptionalQuantity.Text);
                    else
                        cartOptionalRow.Quantity = 1;

                    // Remove Item
                    if (cartOptionalRow.Quantity == 0)
                        cartOptionalRow.Delete();

                    da.CartOptionalItem_Update(cartOptionalRow);
                }
            }
            #endregion

            TextBox txtQuantity = (TextBox)item.FindControl("txtQuantity");
            if (Common.IsNum(txtQuantity.Text) && int.Parse(txtQuantity.Text) <= 9999)
                drCart.Quantity = int.Parse(txtQuantity.Text);
            else
                drCart.Quantity = 1;
            
            // Remove Item
            if (drCart.Quantity == 0)
                drCart.Delete();

            da.Cart_Update(drCart);

            MasterBase.Message = WebLib.UpdatedSuccessfullyMessage;
        }
    }