public static void AddToCart(CartInfo entity) { List <SqlParameter> list = new List <SqlParameter> { new SqlParameter("@CartNo", entity.CartNo), new SqlParameter("@UserID", entity.UserID), new SqlParameter("@UserName", entity.UserName), new SqlParameter("@ProID", entity.ProID), new SqlParameter("@ProName", entity.ProName), new SqlParameter("@ProImg", entity.ProImg), new SqlParameter("@Quantity", entity.Quantity), new SqlParameter("@Price", entity.Price), new SqlParameter("@SellType", entity.SellType), new SqlParameter("@GoodsAttr", entity.GoodsAttr), new SqlParameter("@GoodsAttrStr", entity.GoodsAttrStr), new SqlParameter("@Remark", entity.Remark), new SqlParameter("@AutoTimeStamp", entity.AutoTimeStamp) }; BizBase.dbo.ExecProcReValue("p_System_AddToCart", list.ToArray()); }
public void CheckoutUser(int customerID) { Guid TransactionID = Guid.NewGuid(); IQueryable <ShoppingCarts> customerCart = CartInfo.Where(m => m.UserID == customerID); foreach (var line in customerCart) { Transaction tempTrans = new Transaction() { TicketID = line.TicketID, DateMade = DateTime.UtcNow, DealID = TransactionID.ToString(), UserID = line.UserID, PricePaid = TicketInfo.First(x => x.TicketID == line.TicketID).Price *line.Quantity }; context.Transactions.Add(tempTrans); } context.SaveChanges(); RemoveAllFromCart(customerID); }
public IList <CartInfo> GetList(int pageIndex, int pageSize, string sqlWhere, params SqlParameter[] cmdParms) { StringBuilder sb = new StringBuilder(250); int startIndex = (pageIndex - 1) * pageSize + 1; int endIndex = pageIndex * pageSize; sb.Append(@"select * from(select row_number() over(order by LastUpdatedDate desc) as RowNumber, ProfileId,ProductId,CategoryId,Price,Quantity,Named,IsShoppingCart,LastUpdatedDate from Cart " ); if (!string.IsNullOrEmpty(sqlWhere)) { sb.AppendFormat(" where 1=1 {0} ", sqlWhere); } sb.AppendFormat(@")as objTable where RowNumber between {0} and {1} ", startIndex, endIndex); IList <CartInfo> list = new List <CartInfo>(); using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcShopDbConnString, CommandType.Text, sb.ToString(), cmdParms)) { if (reader != null && reader.HasRows) { while (reader.Read()) { CartInfo model = new CartInfo(); model.ProfileId = reader.GetGuid(1); model.ProductId = reader.GetGuid(2); model.CategoryId = reader.GetGuid(3); model.Price = reader.GetDecimal(4); model.Quantity = reader.GetInt32(5); model.Named = reader.GetString(6); model.IsShoppingCart = reader.GetBoolean(7); model.LastUpdatedDate = reader.GetDateTime(8); list.Add(model); } } } return(list); }
/// <summary> /// 购物车 /// </summary> public ActionResult Index() { //当商城不允许游客使用购物车时 if (WorkContext.ShopConfig.IsGuestSC == 0 && WorkContext.Uid < 1) { return(Redirect(Url.Action("login", "account", new RouteValueDictionary { { "returnUrl", Url.Action("index") } }))); } //购物车商品列表 List <OrderProductInfo> orderProductList = Carts.GetCartProductList(WorkContext.Uid, WorkContext.Sid); //商品数量 int pCount = Carts.SumOrderProductCount(orderProductList); //购物车信息 CartInfo cartInfo = Carts.TidyOrderProductList(orderProductList); //商品总数量 int totalCount = Carts.SumOrderProductCount(cartInfo.SelectedOrderProductList); //商品合计 decimal productAmount = Carts.SumOrderProductAmount(cartInfo.SelectedOrderProductList); //满减折扣 int fullCut = Carts.SumFullCut(cartInfo); //订单合计 decimal orderAmount = productAmount - fullCut; CartModel model = new CartModel { TotalCount = totalCount, ProductAmount = productAmount, FullCut = fullCut, OrderAmount = orderAmount, CartInfo = cartInfo }; //将购物车中商品数量写入cookie Carts.SetCartProductCountCookie(pCount); return(View(model)); }
public ViewResult Checkout(ShoppingCart cart) { string countryName = RegionInfo.CurrentRegion.DisplayName; if (cart.ProductLines.Count() == 0) { ModelState.AddModelError("", "Sorry your cart is empty"); } if (ModelState.IsValid) { // this message will be used by popup dialog window ViewData["message"] = "Would you like to update your details?"; // user is logged in - use their details if (Session["Profile"] != null) { // initialize objects to be passed to the view ShippingInfo shipInfo = InitializeModel(repo); return(View(shipInfo)); } else { // if the user is not registered return a blank class return(View(new ShippingInfo(repo) { ShipDet = new ShippingDetails { Country = countryName } })); } } else { CartInfo inf = new CartInfo { Cart = cart, ReturnUrl = "/" }; return(View("Index", inf)); } }
public CartOperationInfo <CartInfo> Create() { var cartInfo = new CartInfo(); var cartEntry = new CartsCollection.CartsCollectionEntry(cartInfo, this.cartFactory.Create()); try { this.dataSource.Add(cartEntry); } catch (Exception e) { this.logger?.LogError($"Could not create new cart: {cartInfo.Id}"); return(new CartOperationInfo <CartInfo>(CartOperationType.Create, CartOperationStatus.Error, e)); } this.logger?.LogInformation($"Created new cart: {cartInfo.Id}"); return(new CartOperationInfo <CartInfo>(CartOperationType.Create, CartOperationStatus.Successful) { Body = cartInfo }); }
private static CartInfo GetCartInfo(IDataRecord rdr) { if (rdr == null) { return(null); } var cartInfo = new CartInfo(); var i = 0; cartInfo.Id = rdr.IsDBNull(i) ? 0 : rdr.GetInt32(i); i++; cartInfo.SiteId = rdr.IsDBNull(i) ? 0 : rdr.GetInt32(i); i++; cartInfo.OrderId = rdr.IsDBNull(i) ? 0 : rdr.GetInt32(i); i++; cartInfo.UserName = rdr.IsDBNull(i) ? string.Empty : rdr.GetString(i); i++; cartInfo.SessionId = rdr.IsDBNull(i) ? string.Empty : rdr.GetString(i); i++; cartInfo.ProductId = rdr.IsDBNull(i) ? string.Empty : rdr.GetString(i); i++; cartInfo.ProductName = rdr.IsDBNull(i) ? string.Empty : rdr.GetString(i); i++; cartInfo.ImageUrl = rdr.IsDBNull(i) ? string.Empty : rdr.GetString(i); i++; cartInfo.LinkUrl = rdr.IsDBNull(i) ? string.Empty : rdr.GetString(i); i++; cartInfo.Fee = rdr.IsDBNull(i) ? 0 : rdr.GetDecimal(i); i++; cartInfo.IsDelivery = !rdr.IsDBNull(i) && rdr.GetBoolean(i); i++; cartInfo.Count = rdr.IsDBNull(i) ? 0 : rdr.GetInt32(i); i++; cartInfo.AddDate = rdr.IsDBNull(i) ? DateTime.Now : rdr.GetDateTime(i); return(cartInfo); }
/// <summary> /// 购物车快照 /// </summary> public ActionResult Snap() { //当商城不允许游客使用购物车时 if (WorkContext.ShopConfig.IsGuestSC == 0 && WorkContext.Uid < 1) { return(AjaxResult("nologin", "请先登录")); } //购物车商品列表 List <OrderProductInfo> orderProductList = Carts.GetCartProductList(WorkContext.Uid, WorkContext.Sid); //商品数量 int pCount = Carts.SumOrderProductCount(orderProductList); //购物车信息 CartInfo cartInfo = Carts.TidyOrderProductList(orderProductList); //商品总数量 int totalCount = Carts.SumOrderProductCount(cartInfo.SelectedOrderProductList); //商品合计 decimal productAmount = Carts.SumOrderProductAmount(cartInfo.SelectedOrderProductList); //满减折扣 int fullCut = Carts.SumFullCut(cartInfo); //订单合计 decimal orderAmount = productAmount - fullCut; CartModel model = new CartModel { TotalCount = totalCount, ProductAmount = productAmount, FullCut = fullCut, OrderAmount = orderAmount, CartInfo = cartInfo }; //将购物车中商品数量写入cookie Carts.SetCartProductCountCookie(pCount); return(View(model)); }
/// <summary> /// GetClearance code from ShopCommerceService WCF /// </summary> /// <param name="cartInfo"></param> /// <returns></returns> public CartInfo GetClearanceCode(CartInfo cartInfo) { //Convert local cartItem into ShopCommerce cartItems var shopCartInfo = new ShopCommerce.CartInfo() { CartItems = cartInfo.CartItems.Select(x => new ShopCommerce.CartInfoItem() { CartId = x.CartId, ItemId = x.ItemId }).ToList() }; //Convert ShopCommerce cartItem into local cartItems shopCartInfo = _shopCommerceClient.GetClearanceCode(shopCartInfo); cartInfo.CartItems = shopCartInfo.CartItems.Select(x => new CartInfoItem() { CartId = x.CartId, ItemId = x.ItemId, ClearanceCode = x.ClearanceCode }).ToList(); return(cartInfo); }
/// <summary> /// 根据主键ID更新一条记录 /// </summary> /// <param name="model">更新后的实体</param> /// <returns>执行结果受影响行数</returns> public int Update(CartInfo model) { #region SQL语句 const string sql = @" UPDATE [dbo].[CartInfo] SET [cartId] = @cartId ,[productInventory] = @productInventory ,[add_time] = @add_time ,[productStatus] = @productStatus ,[productStone] = @productStone ,[userId] = @userId ,[productId] = @productId ,[productCount] = @productCount ,[addTime] = @addTime ,[productName] = @productName ,[categoryId] = @categoryId ,[productPrice] = @productPrice ,[productIMG] = @productIMG WHERE [cartId] = @cartId"; #endregion return(SqlHelper.ExecuteNonQuery(sql, new SqlParameter("@cartId", model.cartId), new SqlParameter("@productInventory", model.productInventory), new SqlParameter("@add_time", model.add_time), new SqlParameter("@productStatus", model.productStatus), new SqlParameter("@productStone", model.productStone), new SqlParameter("@userId", model.userId), new SqlParameter("@productId", model.productId), new SqlParameter("@productCount", model.productCount), new SqlParameter("@addTime", model.addTime), new SqlParameter("@productName", model.productName), new SqlParameter("@categoryId", model.categoryId), new SqlParameter("@productPrice", model.productPrice), new SqlParameter("@productIMG", model.productIMG) )); }
/// <summary> /// 读取购物车的产品 /// </summary> /// <returns></returns> public static List <CartInfo> ReadCart() { DecodeCart(); List <CartInfo> cartList = new List <CartInfo>(); string[] cartIdArray = ht["cartId"].ToString().Split('#'); string[] productIdArray = ht["productId"].ToString().Split('#'); string[] productNameArray = ht["productName"].ToString().Split('#'); string[] standardValueListArray = ht["standardValueList"].ToString().Split('#'); string[] buyCountArray = ht["buyCount"].ToString().Split('#'); string[] randNumberArray = ht["randNumber"].ToString().Split('#'); for (int i = 1; i < productIdArray.Length - 1; i++) { CartInfo cart = new CartInfo(); cart.Id = Convert.ToInt32(cartIdArray[i]); cart.ProductId = Convert.ToInt32(productIdArray[i]); cart.ProductName = productNameArray[i]; cart.StandardValueList = standardValueListArray[i]; cart.BuyCount = Convert.ToInt32(buyCountArray[i]); cart.RandNumber = randNumberArray[i]; cartList.Add(cart); } return(cartList); }
public void AddCart(int id, int accId) { try { int cartId = GetCartListId(accId); CartInfo ci = new CartInfo(); ci.CartId = cartId; ci.CreationDate = DateTime.Now; ci.ProductId = id; ci.Amount = 1; db.CartInfos.Add(ci); db.SaveChanges(); } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { System.Console.WriteLine("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage); } } } }
public IList <CartInfo> GetList(string sqlWhere, params SqlParameter[] cmdParms) { StringBuilder sb = new StringBuilder(250); sb.Append(@"select ProfileId,ProductId,CategoryId,Price,Quantity,Named,IsShoppingCart,LastUpdatedDate from Cart "); if (!string.IsNullOrEmpty(sqlWhere)) { sb.AppendFormat(" where 1=1 {0} ", sqlWhere); } IList <CartInfo> list = new List <CartInfo>(); using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcShopDbConnString, CommandType.Text, sb.ToString(), cmdParms)) { if (reader != null && reader.HasRows) { while (reader.Read()) { CartInfo model = new CartInfo(); model.ProfileId = reader.GetGuid(0); model.ProductId = reader.GetGuid(1); model.CategoryId = reader.GetGuid(2); model.Price = reader.GetDecimal(3); model.Quantity = reader.GetInt32(4); model.Named = reader.GetString(5); model.IsShoppingCart = reader.GetBoolean(6); model.LastUpdatedDate = reader.GetDateTime(7); list.Add(model); } } } return(list); }
public static int AddToCart(CartInfo cart) { Hashtable hashtable; object obj2; DecodeCart(); int index = ht["productID"].ToString().Split(new char[] { '#' }).Length - 2; int num2 = 1; if (index > 0) { num2 = Convert.ToInt32(ht["cartID"].ToString().Split(new char[] { '#' })[index]) + 1; } (hashtable = ht)[obj2 = "cartID"] = hashtable[obj2] + num2.ToString() + "#"; (hashtable = ht)[obj2 = "productID"] = hashtable[obj2] + cart.ProductID.ToString() + "#"; (hashtable = ht)[obj2 = "productName"] = hashtable[obj2] + cart.ProductName.ToString() + "#"; (hashtable = ht)[obj2 = "buyCount"] = hashtable[obj2] + cart.BuyCount.ToString() + "#"; (hashtable = ht)[obj2 = "fatherID"] = hashtable[obj2] + cart.FatherID.ToString() + "#"; (hashtable = ht)[obj2 = "randNumber"] = hashtable[obj2] + cart.RandNumber + "#"; (hashtable = ht)[obj2 = "giftPackID"] = hashtable[obj2] + cart.GiftPackID.ToString() + "#"; EncodeCart(); HttpContext.Current.Response.Cookies.Add(cartCookies); return(num2); }
protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); int portalId = PortalSettings.PortalId; StoreInfo storeInfo = StoreController.GetStoreInfo(portalId); if (storeInfo != null) { NumberFormatInfo localFormat = (NumberFormatInfo)NumberFormatInfo.CurrentInfo.Clone(); string text; phControls.Visible = true; lblStoreMicroCartItemsTitle.CssClass = _itemsTitleCssClass; lblStoreMicroCartTotalTitle.CssClass = _totalTitleCssClass; lblStoreMicroCartItems.CssClass = _itemsCssClass; lblStoreMicroCartTotal.CssClass = _totalCssClass; string resource = TemplateSourceDirectory + "/App_LocalResources/MicroCart.ascx.resx"; lblStoreMicroCartItemsTitle.Text = Localization.GetString("CartItemsTitle.Text", resource); lblStoreMicroCartTotalTitle.Text = Localization.GetString("CartTotalTitle.Text", resource); try { CartInfo cartInfo = CurrentCart.GetInfo(portalId, storeInfo.SecureCookie); if (!string.IsNullOrEmpty(storeInfo.CurrencySymbol)) { localFormat.CurrencySymbol = storeInfo.CurrencySymbol; } ITaxProvider taxProvider = StoreController.GetTaxProvider(storeInfo.TaxName); ITaxInfo taxInfo = taxProvider.GetDefautTaxRates(portalId); bool showTax = taxInfo.ShowTax; decimal defaultTaxRate = taxInfo.DefaultTaxRate; text = Localization.GetString("CartItems.Text", resource); if (cartInfo != null && cartInfo.Items > 0) { lblStoreMicroCartItems.Text = string.Format(text, cartInfo.Items); decimal cartTotal = cartInfo.Total; if (showTax && _includeVAT && cartInfo.Total > 0) { cartTotal = (cartTotal + (cartTotal * (defaultTaxRate / 100))); } lblStoreMicroCartTotal.Text = cartTotal.ToString("C", localFormat); } else { lblStoreMicroCartItems.Text = string.Format(text, 0); lblStoreMicroCartTotal.Text = (0D).ToString("C", localFormat); } } catch { text = Localization.GetString("Error.Text", resource); lblStoreMicroCartItems.Text = text; lblStoreMicroCartTotalTitle.Text = text; } } else { phControls.Visible = false; } }
public IQueryable <ShoppingCarts> GetUserCart(int customerID) { return(CartInfo.Where(x => x.UserID == customerID)); }
/// <summary> /// finds a board class which can handle the provided cart /// </summary> static Type FindBoard(CartInfo cart, EDetectionOrigin origin, Dictionary<string, string> properties) { NES nes = new NES(); nes.cart = cart; Type ret = null; lock(INESBoardImplementors) foreach (var type in INESBoardImplementors) { using (NESBoardBase board = (NESBoardBase)Activator.CreateInstance(type)) { //unif demands that the boards set themselves up with expected legal values based on the board size //except, i guess, for the rom/chr sizes. go figure. //so, disable the asserts here if (origin == EDetectionOrigin.UNIF) board.DisableConfigAsserts = true; board.Create(nes); board.InitialRegisterValues = properties; if (board.Configure(origin)) { #if DEBUG if (ret != null) throw new Exception(string.Format("Boards {0} and {1} both responded to Configure!", ret, type)); else ret = type; #else return type; #endif } } } return ret; }
/// <summary> /// 修改数据 /// </summary> /// <param name="model"></param> /// <returns></returns> public int Update(CartInfo model) { return(dal.Update(model)); }
/// <summary> /// 根据主键ID更新一条记录 /// </summary> /// <param name="model">更新后的实体</param> /// <returns>执行结果受影响行数</returns> public int Update(CartInfo model) { return(_dao.Update(model)); }
/// <summary> /// 修改购物车中套装数量 /// </summary> public ActionResult ChangeSuitCount() { //当商城不允许游客使用购物车时 if (WorkContext.ShopConfig.IsGuestSC == 0 && WorkContext.Uid < 1) { return(AjaxResult("nologin", "请先登录")); } int pmId = WebHelper.GetQueryInt("pmId"); //套装id int buyCount = WebHelper.GetQueryInt("buyCount"); //购买数量 string selectedCartItemKeyList = WebHelper.GetQueryString("selectedCartItemKeyList"); //选中的购物车项键列表 //购物车商品列表 List <OrderProductInfo> orderProductList = Carts.GetCartProductList(WorkContext.Uid, WorkContext.Sid); //套装商品列表 List <OrderProductInfo> suitOrderProductList = Carts.GetSuitOrderProductList(pmId, orderProductList, true); if (suitOrderProductList.Count > 0) //当套装已经存在 { if (buyCount < 1) //当购买数量小于1时,删除此套装 { Carts.DeleteCartSuit(ref orderProductList, pmId); } else { OrderProductInfo orderProductInfo = suitOrderProductList.Find(x => x.Type == 3); int oldBuyCount = orderProductInfo.RealCount / orderProductInfo.ExtCode2; if (buyCount != oldBuyCount) { Carts.AddExistSuitToCart(ref orderProductList, suitOrderProductList, buyCount); } } } //商品数量 int pCount = Carts.SumOrderProductCount(orderProductList); //购物车信息 CartInfo cartInfo = Carts.TidyOrderProductList(StringHelper.SplitString(selectedCartItemKeyList), orderProductList); //商品总数量 int totalCount = Carts.SumOrderProductCount(cartInfo.SelectedOrderProductList); //商品合计 decimal productAmount = Carts.SumOrderProductAmount(cartInfo.SelectedOrderProductList); //满减折扣 int fullCut = Carts.SumFullCut(cartInfo); //订单合计 decimal orderAmount = productAmount - fullCut; CartModel model = new CartModel { TotalCount = totalCount, ProductAmount = productAmount, FullCut = fullCut, OrderAmount = orderAmount, CartInfo = cartInfo }; //将购物车中商品数量写入cookie Carts.SetCartProductCountCookie(pCount); return(View("ajaxindex", model)); }
public BootGodDB() { //notes: there can be multiple each of prg,chr,wram,vram //we arent tracking the individual hashes yet. //in anticipation of any slowness annoying people, and just for shits and giggles, i made a super fast parser int state = 0; var xmlreader = XmlReader.Create(new MemoryStream(_GetDatabaseBytes())); CartInfo currCart = null; string currName = null; while (xmlreader.Read()) { switch (state) { case 0: if (xmlreader.NodeType == XmlNodeType.Element && xmlreader.Name == "game") { currName = xmlreader.GetAttribute("name"); state = 1; } break; case 2: if (xmlreader.NodeType == XmlNodeType.Element && xmlreader.Name == "board") { currCart.board_type = xmlreader.GetAttribute("type"); currCart.pcb = xmlreader.GetAttribute("pcb"); int mapper = int.Parse(xmlreader.GetAttribute("mapper")); if (validate && mapper > 255) { throw new Exception("didnt expect mapper>255!"); } // we don't actually use this value at all; only the board name state = 3; } break; case 3: if (xmlreader.NodeType == XmlNodeType.Element) { switch (xmlreader.Name) { case "prg": currCart.prg_size += (short)ParseSize(xmlreader.GetAttribute("size")); break; case "chr": currCart.chr_size += (short)ParseSize(xmlreader.GetAttribute("size")); break; case "vram": currCart.vram_size += (short)ParseSize(xmlreader.GetAttribute("size")); break; case "wram": currCart.wram_size += (short)ParseSize(xmlreader.GetAttribute("size")); if (xmlreader.GetAttribute("battery") != null) { currCart.wram_battery = true; } break; case "pad": currCart.pad_h = byte.Parse(xmlreader.GetAttribute("h")); currCart.pad_v = byte.Parse(xmlreader.GetAttribute("v")); break; case "chip": currCart.chips.Add(xmlreader.GetAttribute("type")); break; } } else if (xmlreader.NodeType == XmlNodeType.EndElement && xmlreader.Name == "board") { state = 4; } break; case 4: if (xmlreader.NodeType == XmlNodeType.EndElement && xmlreader.Name == "cartridge") { sha1_table[currCart.sha1].Add(currCart); currCart = null; state = 5; } break; case 5: case 1: if (xmlreader.NodeType == XmlNodeType.Element && xmlreader.Name == "cartridge") { currCart = new CartInfo(); currCart.system = xmlreader.GetAttribute("system"); currCart.sha1 = "sha1:" + xmlreader.GetAttribute("sha1"); currCart.name = currName; state = 2; } if (xmlreader.NodeType == XmlNodeType.EndElement && xmlreader.Name == "game") { currName = null; state = 0; } break; } } //end xmlreader loop }
static CartController() { Cart = new CartInfo(); }
public BootGodDB() { //notes: there can be multiple each of prg,chr,wram,vram //we arent tracking the individual hashes yet. //in anticipation of any slowness annoying people, and just for shits and giggles, i made a super fast parser int state=0; var xmlreader = XmlReader.Create(new MemoryStream(_GetDatabaseBytes())); CartInfo currCart = null; string currName = null; while (xmlreader.Read()) { switch (state) { case 0: if (xmlreader.NodeType == XmlNodeType.Element && xmlreader.Name == "game") { currName = xmlreader.GetAttribute("name"); state = 1; } break; case 2: if (xmlreader.NodeType == XmlNodeType.Element && xmlreader.Name == "board") { currCart.board_type = xmlreader.GetAttribute("type"); currCart.pcb = xmlreader.GetAttribute("pcb"); int mapper = int.Parse(xmlreader.GetAttribute("mapper")); if (validate && mapper > 255) throw new Exception("didnt expect mapper>255!"); // we don't actually use this value at all; only the board name state = 3; } break; case 3: if (xmlreader.NodeType == XmlNodeType.Element) { switch(xmlreader.Name) { case "prg": currCart.prg_size += (short)ParseSize(xmlreader.GetAttribute("size")); break; case "chr": currCart.chr_size += (short)ParseSize(xmlreader.GetAttribute("size")); break; case "vram": currCart.vram_size += (short)ParseSize(xmlreader.GetAttribute("size")); break; case "wram": currCart.wram_size += (short)ParseSize(xmlreader.GetAttribute("size")); if (xmlreader.GetAttribute("battery") != null) currCart.wram_battery = true; break; case "pad": currCart.pad_h = byte.Parse(xmlreader.GetAttribute("h")); currCart.pad_v = byte.Parse(xmlreader.GetAttribute("v")); break; case "chip": currCart.chips.Add(xmlreader.GetAttribute("type")); break; } } else if (xmlreader.NodeType == XmlNodeType.EndElement && xmlreader.Name == "board") { state = 4; } break; case 4: if (xmlreader.NodeType == XmlNodeType.EndElement && xmlreader.Name == "cartridge") { sha1_table[currCart.sha1].Add(currCart); currCart = null; state = 5; } break; case 5: case 1: if (xmlreader.NodeType == XmlNodeType.Element && xmlreader.Name == "cartridge") { currCart = new CartInfo(); currCart.system = xmlreader.GetAttribute("system"); currCart.sha1 = "sha1:" + xmlreader.GetAttribute("sha1"); currCart.name = currName; state = 2; } if (xmlreader.NodeType == XmlNodeType.EndElement && xmlreader.Name == "game") { currName = null; state = 0; } break; } } //end xmlreader loop }
/// <summary> /// 根据配送方式,配送地址,读取邮费价格【按单个商品独立计算运费】 /// 如买了2件商品,一件商品买了2个,一件商品买了1个,则需计算两次,第一次重量叠加计算(相同商品购买多个则叠加计算) /// </summary> /// <returns></returns> public static decimal ReadShippingMoney(ShippingInfo shipping, ShippingRegionInfo shippingRegion, CartInfo cart) { decimal shippingMoney = 0; switch (shipping.ShippingType) { case (int)ShippingType.Fixed: shippingMoney = shippingRegion.FixedMoeny; break; case (int)ShippingType.Weight: decimal cartProductWeight = cart.BuyCount * cart.Product.Weight; if (cartProductWeight <= shipping.FirstWeight) { shippingMoney = shippingRegion.FirstMoney; } else { shippingMoney = shippingRegion.FirstMoney + Math.Ceiling((cartProductWeight - shipping.FirstWeight) / shipping.AgainWeight) * shippingRegion.AgainMoney; } break; case (int)ShippingType.ProductCount: int cartProductCount = cart.BuyCount; shippingMoney = shippingRegion.OneMoeny + (cartProductCount - 1) * shippingRegion.AnotherMoeny; break; default: break; } return(shippingMoney); }
public static void HandlerCartList(List <CartInfo> cartList, ref List <CartGiftPackVirtualInfo> cartGiftPackVirtualList, ref List <CartCommonProductVirtualInfo> cartCommonProductVirtualList) { string str; string str2; decimal num2; int num3; foreach (CartInfo info in cartList) { CartGiftPackVirtualInfo current; if (!(info.RandNumber != string.Empty) || (info.GiftPackID <= 0)) { goto Label_00F8; } bool flag = false; using (List <CartGiftPackVirtualInfo> .Enumerator enumerator2 = cartGiftPackVirtualList.GetEnumerator()) { while (enumerator2.MoveNext()) { current = enumerator2.Current; if (current.RandNumber == info.RandNumber) { flag = true; current.CartList.Add(info); goto Label_00A5; } } } Label_00A5: if (!flag) { current = new CartGiftPackVirtualInfo(); { current.RandNumber = info.RandNumber; current.GiftPackBuyCount = info.BuyCount; current.LeftStorageCount = info.LeftStorageCount; }; current.CartList.Add(info); cartGiftPackVirtualList.Add(current); } goto Label_018A; Label_00F8: if (info.FatherID == 0) { CartCommonProductVirtualInfo item = new CartCommonProductVirtualInfo(); { item.FatherCart = info; } cartCommonProductVirtualList.Add(item); } else { foreach (CartCommonProductVirtualInfo info3 in cartCommonProductVirtualList) { if (info3.FatherCart.ID == info.FatherID) { info3.ChildCartList.Add(info); break; } } } Label_018A :; } if (cartGiftPackVirtualList.Count > 0) { foreach (CartGiftPackVirtualInfo info2 in cartGiftPackVirtualList) { int id = 0; str = string.Empty; str2 = string.Empty; num2 = 0M; num3 = 0; foreach (CartInfo info in info2.CartList) { if (str == string.Empty) { str = info.ProductID.ToString(); str2 = info.ID.ToString(); } else { str = str + "," + info.ProductID.ToString(); str2 = str2 + "," + info.ID.ToString(); } num2 += info.ProductWeight; num3 += info.SendPoint; id = info.GiftPackID; } GiftPackInfo info4 = GiftPackBLL.ReadGiftPack(id); info2.GiftPackID = id; info2.GiftPackName = info4.Name; info2.GiftPackPhoto = info4.Photo; info2.StrProductID = str; info2.StrCartID = str2; info2.TotalProductWeight = num2; info2.TotalSendPoint = num3; info2.TotalPrice = info4.Price; } } if (cartCommonProductVirtualList.Count > 0) { foreach (CartCommonProductVirtualInfo info3 in cartCommonProductVirtualList) { str = info3.FatherCart.ProductID.ToString(); str2 = info3.FatherCart.ID.ToString(); num2 = 0M; num3 = 0; foreach (CartInfo info in info3.ChildCartList) { str = str + "," + info.ProductID.ToString(); str2 = str2 + "," + info.ID.ToString(); num2 += info.ProductWeight; num3 += info.SendPoint; } info3.StrProductID = str; info3.StrCartID = str2; CartInfo fatherCart = info3.FatherCart; fatherCart.ProductWeight += num2; CartInfo info5 = info3.FatherCart; info5.SendPoint += num3; } } }
public void Init(GameInfo gameInfo, byte[] rom, byte[] fdsbios = null) { LoadReport = new StringWriter(); LoadWriteLine("------"); LoadWriteLine("BEGIN NES rom analysis:"); byte[] file = rom; Type boardType = null; CartInfo choice = null; CartInfo iNesHeaderInfo = null; CartInfo iNesHeaderInfoV2 = null; List<string> hash_sha1_several = new List<string>(); string hash_sha1 = null, hash_md5 = null; Unif unif = null; Dictionary<string, string> InitialMapperRegisterValues = new Dictionary<string, string>(SyncSettings.BoardProperties); origin = EDetectionOrigin.None; if (file.Length < 16) throw new Exception("Alleged NES rom too small to be anything useful"); if (file.Take(4).SequenceEqual(System.Text.Encoding.ASCII.GetBytes("UNIF"))) { unif = new Unif(new MemoryStream(file)); LoadWriteLine("Found UNIF header:"); LoadWriteLine(unif.CartInfo); LoadWriteLine("Since this is UNIF we can confidently parse PRG/CHR banks to hash."); hash_sha1 = unif.CartInfo.sha1; hash_sha1_several.Add(hash_sha1); LoadWriteLine("headerless rom hash: {0}", hash_sha1); } else if (file.Take(4).SequenceEqual(System.Text.Encoding.ASCII.GetBytes("FDS\x1A")) || file.Take(4).SequenceEqual(System.Text.Encoding.ASCII.GetBytes("\x01*NI"))) { // danger! this is a different codepath with an early return. accordingly, some // code is duplicated twice... // FDS roms are just fed to the board, we don't do much else with them origin = EDetectionOrigin.FDS; LoadWriteLine("Found FDS header."); if (fdsbios == null) throw new MissingFirmwareException("Missing FDS Bios"); cart = new CartInfo(); var fdsboard = new FDS(); fdsboard.biosrom = fdsbios; fdsboard.SetDiskImage(rom); fdsboard.Create(this); // at the moment, FDS doesn't use the IRVs, but it could at some point in the future fdsboard.InitialRegisterValues = InitialMapperRegisterValues; fdsboard.Configure(origin); board = fdsboard; //create the vram and wram if necessary if (cart.wram_size != 0) board.WRAM = new byte[cart.wram_size * 1024]; if (cart.vram_size != 0) board.VRAM = new byte[cart.vram_size * 1024]; board.PostConfigure(); Console.WriteLine("Using NTSC display type for FDS disk image"); _display_type = Common.DisplayType.NTSC; HardReset(); return; } else { byte[] nesheader = new byte[16]; Buffer.BlockCopy(file, 0, nesheader, 0, 16); if (!DetectFromINES(nesheader, out iNesHeaderInfo, out iNesHeaderInfoV2)) throw new InvalidOperationException("iNES header not found"); //now that we know we have an iNES header, we can try to ignore it. hash_sha1 = "sha1:" + file.HashSHA1(16, file.Length - 16); hash_sha1_several.Add(hash_sha1); hash_md5 = "md5:" + file.HashMD5(16, file.Length - 16); LoadWriteLine("Found iNES header:"); LoadWriteLine(iNesHeaderInfo.ToString()); if (iNesHeaderInfoV2 != null) { LoadWriteLine("Found iNES V2 header:"); LoadWriteLine(iNesHeaderInfoV2); } LoadWriteLine("Since this is iNES we can (somewhat) confidently parse PRG/CHR banks to hash."); LoadWriteLine("headerless rom hash: {0}", hash_sha1); LoadWriteLine("headerless rom hash: {0}", hash_md5); if (iNesHeaderInfo.prg_size == 16) { //8KB prg can't be stored in iNES format, which counts 16KB prg banks. //so a correct hash will include only 8KB. LoadWriteLine("Since this rom has a 16 KB PRG, we'll hash it as 8KB too for bootgod's DB:"); var msTemp = new MemoryStream(); msTemp.Write(file, 16, 8 * 1024); //add prg msTemp.Write(file, 16 + 16 * 1024, iNesHeaderInfo.chr_size * 1024); //add chr msTemp.Flush(); var bytes = msTemp.ToArray(); var hash = "sha1:" + bytes.HashSHA1(0, bytes.Length); LoadWriteLine(" PRG (8KB) + CHR hash: {0}", hash); hash_sha1_several.Add(hash); hash = "md5:" + bytes.HashMD5(0, bytes.Length); LoadWriteLine(" PRG (8KB) + CHR hash: {0}", hash); } } if (USE_DATABASE) { if (hash_md5 != null) choice = IdentifyFromGameDB(hash_md5); if (choice == null) choice = IdentifyFromGameDB(hash_sha1); if (choice == null) LoadWriteLine("Could not locate game in bizhawk gamedb"); else { origin = EDetectionOrigin.GameDB; LoadWriteLine("Chose board from bizhawk gamedb: " + choice.board_type); //gamedb entries that dont specify prg/chr sizes can infer it from the ines header if (iNesHeaderInfo != null) { if (choice.prg_size == -1) choice.prg_size = iNesHeaderInfo.prg_size; if (choice.chr_size == -1) choice.chr_size = iNesHeaderInfo.chr_size; if (choice.vram_size == -1) choice.vram_size = iNesHeaderInfo.vram_size; if (choice.wram_size == -1) choice.wram_size = iNesHeaderInfo.wram_size; } else if (unif != null) { if (choice.prg_size == -1) choice.prg_size = unif.CartInfo.prg_size; if (choice.chr_size == -1) choice.chr_size = unif.CartInfo.chr_size; // unif has no wram\vram sizes; hope the board impl can figure it out... if (choice.vram_size == -1) choice.vram_size = 0; if (choice.wram_size == -1) choice.wram_size = 0; } } //if this is still null, we have to try it some other way. nescartdb perhaps? if (choice == null) { choice = IdentifyFromBootGodDB(hash_sha1_several); if (choice == null) LoadWriteLine("Could not locate game in nescartdb"); else { LoadWriteLine("Chose board from nescartdb:"); LoadWriteLine(choice); origin = EDetectionOrigin.BootGodDB; } } } //if choice is still null, try UNIF and iNES if (choice == null) { if (unif != null) { LoadWriteLine("Using information from UNIF header"); choice = unif.CartInfo; origin = EDetectionOrigin.UNIF; } if (iNesHeaderInfo != null) { LoadWriteLine("Attempting inference from iNES header"); // try to spin up V2 header first, then V1 header if (iNesHeaderInfoV2 != null) { try { boardType = FindBoard(iNesHeaderInfoV2, origin, InitialMapperRegisterValues); } catch { } if (boardType == null) LoadWriteLine("Failed to load as iNES V2"); else choice = iNesHeaderInfoV2; // V2 might fail but V1 might succeed because we don't have most V2 aliases setup; and there's // no reason to do so except when needed } if (boardType == null) { choice = iNesHeaderInfo; // we're out of options, really boardType = FindBoard(iNesHeaderInfo, origin, InitialMapperRegisterValues); if (boardType == null) LoadWriteLine("Failed to load as iNES V1"); // do not further meddle in wram sizes. a board that is being loaded from a "MAPPERxxx" // entry should know and handle the situation better for the individual board } LoadWriteLine("Chose board from iNES heuristics:"); LoadWriteLine(choice); origin = EDetectionOrigin.INES; } } game_name = choice.name; //find a INESBoard to handle this if (choice != null) boardType = FindBoard(choice, origin, InitialMapperRegisterValues); else throw new Exception("Unable to detect ROM"); if (boardType == null) throw new Exception("No class implements the necessary board type: " + choice.board_type); if (choice.DB_GameInfo != null) choice.bad = choice.DB_GameInfo.IsRomStatusBad(); LoadWriteLine("Final game detection results:"); LoadWriteLine(choice); LoadWriteLine("\"" + game_name + "\""); LoadWriteLine("Implemented by: class " + boardType.Name); if (choice.bad) { LoadWriteLine("~~ ONE WAY OR ANOTHER, THIS DUMP IS KNOWN TO BE *BAD* ~~"); LoadWriteLine("~~ YOU SHOULD FIND A BETTER FILE ~~"); } LoadWriteLine("END NES rom analysis"); LoadWriteLine("------"); board = CreateBoardInstance(boardType); cart = choice; board.Create(this); board.InitialRegisterValues = InitialMapperRegisterValues; board.Configure(origin); if (origin == EDetectionOrigin.BootGodDB) { RomStatus = RomStatus.GoodDump; CoreComm.RomStatusAnnotation = "Identified from BootGod's database"; } if (origin == EDetectionOrigin.UNIF) { RomStatus = RomStatus.NotInDatabase; CoreComm.RomStatusAnnotation = "Inferred from UNIF header; somewhat suspicious"; } if (origin == EDetectionOrigin.INES) { RomStatus = RomStatus.NotInDatabase; CoreComm.RomStatusAnnotation = "Inferred from iNES header; potentially wrong"; } if (origin == EDetectionOrigin.GameDB) { if (choice.bad) { RomStatus = RomStatus.BadDump; } else { RomStatus = choice.DB_GameInfo.Status; } } LoadReport.Flush(); CoreComm.RomStatusDetails = LoadReport.ToString(); //create the board's rom and vrom if (iNesHeaderInfo != null) { //pluck the necessary bytes out of the file board.ROM = new byte[choice.prg_size * 1024]; Array.Copy(file, 16, board.ROM, 0, board.ROM.Length); if (choice.chr_size > 0) { board.VROM = new byte[choice.chr_size * 1024]; int vrom_offset = iNesHeaderInfo.prg_size * 1024; // if file isn't long enough for VROM, truncate Array.Copy(file, 16 + vrom_offset, board.VROM, 0, Math.Min(board.VROM.Length, file.Length - 16 - vrom_offset)); } } else { board.ROM = unif.PRG; board.VROM = unif.CHR; } // IF YOU DO ANYTHING AT ALL BELOW THIS LINE, MAKE SURE THE APPROPRIATE CHANGE IS MADE TO FDS (if applicable) //create the vram and wram if necessary if (cart.wram_size != 0) board.WRAM = new byte[cart.wram_size * 1024]; if (cart.vram_size != 0) board.VRAM = new byte[cart.vram_size * 1024]; board.PostConfigure(); // set up display type NESSyncSettings.Region fromrom = DetectRegion(cart.system); NESSyncSettings.Region fromsettings = SyncSettings.RegionOverride; if (fromsettings != NESSyncSettings.Region.Default) { Console.WriteLine("Using system region override"); fromrom = fromsettings; } switch (fromrom) { case NESSyncSettings.Region.Dendy: _display_type = Common.DisplayType.DENDY; break; case NESSyncSettings.Region.NTSC: _display_type = Common.DisplayType.NTSC; break; case NESSyncSettings.Region.PAL: _display_type = Common.DisplayType.PAL; break; default: _display_type = Common.DisplayType.NTSC; break; } Console.WriteLine("Using NES system region of {0}", _display_type); HardReset(); }
public void WhenCreatedThenCartIsMarkedAsNotCheckedout() { var cartInfo = new CartInfo(); Assert.False(cartInfo.CheckedOut); }
protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); lblStoreMicroCartItemsTitle.CssClass = _itemsTitleCssClass; lblStoreMicroCartTotalTitle.CssClass = _totalTitleCssClass; lblStoreMicroCartItems.CssClass = _itemsCssClass; lblStoreMicroCartTotal.CssClass = _totalCssClass; _resource = this.TemplateSourceDirectory + "/App_LocalResources/MicroCart.ascx.resx"; lblStoreMicroCartItemsTitle.Text = Localization.GetString("CartItemsTitle.Text", _resource); lblStoreMicroCartTotalTitle.Text = Localization.GetString("CartTotalTitle.Text", _resource); try { if (storeInfo == null) { portalId = this.PortalSettings.PortalId; cartInfo = CurrentCart.GetInfo(portalId); StoreController storeController = new StoreController(); storeInfo = storeController.GetStoreInfo(portalId); if (storeInfo.CurrencySymbol != string.Empty) { LocalFormat.CurrencySymbol = storeInfo.CurrencySymbol; } } _text = Localization.GetString("CartItems.Text", _resource); int _items = cartInfo.Items; if (_items > 0) { lblStoreMicroCartItems.Text = string.Format(_text, _items); lblStoreMicroCartTotal.Text = cartInfo.Total.ToString("C", LocalFormat); } else { lblStoreMicroCartItems.Text = string.Format(_text, 0); lblStoreMicroCartTotal.Text = (0D).ToString("C", LocalFormat); } } catch { _text = Localization.GetString("Error.Text", _resource); lblStoreMicroCartItems.Text = _text; lblStoreMicroCartTotalTitle.Text = _text; } }
public static bool Update(CartInfo entity) { return(entity != null && BizBase.dbo.UpdateModel <CartInfo>(entity)); }
/// <summary> /// 添加满赠到购物车 /// </summary> public ActionResult AddFullSend() { //当商城不允许游客使用购物车时 if (WorkContext.ShopConfig.IsGuestSC == 0 && WorkContext.Uid < 1) { return(AjaxResult("nologin", "请先登录")); } int pmId = WebHelper.GetQueryInt("pmId"); //满赠id int pid = WebHelper.GetQueryInt("pid"); //商品id string selectedCartItemKeyList = WebHelper.GetQueryString("selectedCartItemKeyList"); //选中的购物车项键列表 //添加的商品 PartProductInfo partProductInfo = Products.GetPartProductById(pid); if (partProductInfo == null) { return(AjaxResult("noproduct", "请选择商品")); } //商品库存 int stockNumber = Products.GetProductStockNumberByPid(pid); if (stockNumber < 1) { return(AjaxResult("stockout", "商品库存不足")); } //满赠促销活动 FullSendPromotionInfo fullSendPromotionInfo = Promotions.GetFullSendPromotionByPmIdAndTime(pmId, DateTime.Now); if (fullSendPromotionInfo == null) { return(AjaxResult("nopromotion", "满赠促销活动不存在或已经结束")); } //购物车商品列表 List <OrderProductInfo> orderProductList = Carts.GetCartProductList(WorkContext.Uid, WorkContext.Sid); //满赠主商品列表 List <OrderProductInfo> fullSendMainOrderProductList = Carts.GetFullSendMainOrderProductList(pmId, orderProductList); if (fullSendMainOrderProductList.Count < 1) { return(AjaxResult("nolimit", "不符合活动条件")); } decimal amount = Carts.SumOrderProductAmount(fullSendMainOrderProductList); if (fullSendPromotionInfo.LimitMoney > amount) { return(AjaxResult("nolimit", "不符合活动条件")); } if (!Promotions.IsExistFullSendProduct(pmId, pid, 1)) { return(AjaxResult("nofullsendproduct", "此商品不是满赠商品")); } //赠送商品 OrderProductInfo fullSendMinorOrderProductInfo = Carts.GetFullSendMinorOrderProduct(pmId, orderProductList); if (fullSendMinorOrderProductInfo != null) { if (fullSendMinorOrderProductInfo.Pid != pid) { Carts.DeleteCartFullSend(ref orderProductList, fullSendMinorOrderProductInfo); } else { return(AjaxResult("exist", "此商品已经添加")); } } //添加满赠商品 Carts.AddFullSendToCart(ref orderProductList, partProductInfo, fullSendPromotionInfo, WorkContext.Sid, WorkContext.Uid, DateTime.Now); //商品数量 int pCount = Carts.SumOrderProductCount(orderProductList); //购物车信息 CartInfo cartInfo = Carts.TidyOrderProductList(StringHelper.SplitString(selectedCartItemKeyList), orderProductList); //商品总数量 int totalCount = Carts.SumOrderProductCount(cartInfo.SelectedOrderProductList); //商品合计 decimal productAmount = Carts.SumOrderProductAmount(cartInfo.SelectedOrderProductList); //满减折扣 int fullCut = Carts.SumFullCut(cartInfo); //订单合计 decimal orderAmount = productAmount - fullCut; CartModel model = new CartModel { TotalCount = totalCount, ProductAmount = productAmount, FullCut = fullCut, OrderAmount = orderAmount, CartInfo = cartInfo }; //将购物车中商品数量写入cookie Carts.SetCartProductCountCookie(pCount); return(View("ajaxindex", model)); }
public void WhenCreatedThenNewIdIsAutomaticallyGenerated() { var cartInfo = new CartInfo(); Assert.NotNull(cartInfo.Id); }
/// <summary> /// looks up from the game DB /// </summary> CartInfo IdentifyFromGameDB(string hash) { var gi = Database.CheckDatabase(hash); if (gi == null) return null; CartInfo cart = new CartInfo(); //try generating a bootgod cart descriptor from the game database var dict = gi.GetOptionsDict(); cart.DB_GameInfo = gi; if (!dict.ContainsKey("board")) throw new Exception("NES gamedb entries must have a board identifier!"); cart.board_type = dict["board"]; if (dict.ContainsKey("system")) cart.system = dict["system"]; cart.prg_size = -1; cart.vram_size = -1; cart.wram_size = -1; cart.chr_size = -1; if (dict.ContainsKey("PRG")) cart.prg_size = short.Parse(dict["PRG"]); if (dict.ContainsKey("CHR")) cart.chr_size = short.Parse(dict["CHR"]); if(dict.ContainsKey("VRAM")) cart.vram_size = short.Parse(dict["VRAM"]); if (dict.ContainsKey("WRAM")) cart.wram_size = short.Parse(dict["WRAM"]); if (dict.ContainsKey("PAD_H")) cart.pad_h = byte.Parse(dict["PAD_H"]); if (dict.ContainsKey("PAD_V")) cart.pad_v = byte.Parse(dict["PAD_V"]); if(dict.ContainsKey("MIR")) if (dict["MIR"] == "H") { cart.pad_v = 1; cart.pad_h = 0; } else if (dict["MIR"] == "V") { cart.pad_h = 1; cart.pad_v = 0; } if (dict.ContainsKey("BAD")) cart.bad = true; if (dict.ContainsKey("MMC3")) cart.chips.Add(dict["MMC3"]); if (dict.ContainsKey("PCB")) cart.pcb = dict["PCB"]; if (dict.ContainsKey("BATT")) cart.wram_battery = bool.Parse(dict["BATT"]); return cart; }
/// <summary> /// 添加数据到数据库 /// </summary> /// <param name="model"></param> /// <returns></returns> public int Insert(CartInfo model) { return(dal.Insert(model)); }
public static bool DetectFromINES(byte[] data, out CartInfo Cart, out CartInfo CartV2) { byte[] ID = new byte[4]; Buffer.BlockCopy(data, 0, ID, 0, 4); if (!ID.SequenceEqual(Encoding.ASCII.GetBytes("NES\x1A"))) { Cart = null; CartV2 = null; return false; } if ((data[7] & 0x0c) == 0x08) { // process as iNES v2 CartV2 = new CartInfo(); CartV2.prg_size = data[4] | data[9] << 8 & 0xf00; CartV2.chr_size = data[5] | data[9] << 4 & 0xf00; CartV2.prg_size *= 16; CartV2.chr_size *= 8; CartV2.wram_battery = (data[6] & 2) != 0; // should this be respected in v2 mode?? int wrambat = iNES2Wram(data[10] >> 4); int wramnon = iNES2Wram(data[10] & 15); CartV2.wram_battery |= wrambat > 0; // fixme - doesn't handle sizes not divisible by 1024 CartV2.wram_size = (short)((wrambat + wramnon) / 1024); int mapper = data[6] >> 4 | data[7] & 0xf0 | data[8] << 8 & 0xf00; int submapper = data[8] >> 4; CartV2.board_type = string.Format("MAPPER{0:d4}-{1:d2}", mapper, submapper); int vrambat = iNES2Wram(data[11] >> 4); int vramnon = iNES2Wram(data[11] & 15); // hopefully a game with battery backed vram understands what to do internally CartV2.wram_battery |= vrambat > 0; CartV2.vram_size = (vrambat + vramnon) / 1024; CartV2.inesmirroring = data[6] & 1 | data[6] >> 2 & 2; switch (CartV2.inesmirroring) { case 0: CartV2.pad_v = 1; break; case 1: CartV2.pad_h = 1; break; } } else { CartV2 = null; } // process as iNES v1 // the DiskDude cleaning is no longer; get better roms Cart = new CartInfo(); Cart.prg_size = data[4]; Cart.chr_size = data[5]; if (Cart.prg_size == 0) Cart.prg_size = 256; Cart.prg_size *= 16; Cart.chr_size *= 8; Cart.wram_battery = (data[6] & 2) != 0; Cart.wram_size = 8; // should be data[8], but that never worked { int mapper = data[6] >> 4 | data[7] & 0xf0; Cart.board_type = string.Format("MAPPER{0:d3}", mapper); } Cart.vram_size = Cart.chr_size > 0 ? 0 : 8; Cart.inesmirroring = data[6] & 1 | data[6] >> 2 & 2; switch (Cart.inesmirroring) { case 0: Cart.pad_v = 1; break; case 1: Cart.pad_h = 1; break; } if (data[6].Bit(2)) Console.WriteLine("DANGER: According to the flags, this iNES has a trainer in it! We don't support this garbage."); return true; }
/// <summary> /// 向数据库中添加一条记录 /// </summary> /// <param name="model">要添加的实体</param> /// <returns>插入数据的ID</returns> public int Insert(CartInfo model) { return(_dao.Insert(model)); }
public static CartInfo BuildCart() { CartInfo cart = new CartInfo(); return(cart); }
public void UpdateCart(CartInfo cartInfo) { DataProvider.Instance().UpdateCart(cartInfo.CartID, cartInfo.UserID); }