private bool ValidCardType(int input) { try { object obj = PosContext.Instance.Config.CardMedia[input]; if (obj is CardMedia) { this.cardMedia = (CardMedia)obj; return(true); } else { return(false); } } catch (Exception ex) { return(false); } }
private void TerminalReportByCollections(TerminalReport report, int start, int end) { this.PrintReceipt(PosContext.Instance.Parameters.getParam("Collections"), 0, PosContext.Instance.Training); double totalCollection = 0; foreach (object obj in report.PosTotal.Totals) { EclipsePos.Data.Total total = obj as EclipsePos.Data.Total; String countLit = null; String amountLit = null; if ((total.Total_type > start) && (total.Total_type < end)) { int type = total.Total_type - start; switch (type) { case (int)TotalType.CASH_SALES: countLit = PosContext.Instance.Parameters.getParam("CashSalesCount"); amountLit = PosContext.Instance.Parameters.getParam("CashSalesAmount"); break; case (int)TotalType.GIFT_CERTIFICATE: countLit = PosContext.Instance.Parameters.getParam("GiftCertCount"); amountLit = PosContext.Instance.Parameters.getParam("GiftCertAmount"); break; case (int)TotalType.CHECK: case (int)TotalType.CHECK_IN_DRAWER: countLit = PosContext.Instance.Parameters.getParam("CheckCount"); amountLit = PosContext.Instance.Parameters.getParam("CheckAmount"); break; default: break; } if (type > 400 && type < 500) { object objCard = PosContext.Instance.Config.CardMediaByTotalType[type]; if (objCard is CardMedia) { CardMedia cMedia = objCard as CardMedia; countLit = cMedia.Media_name; amountLit = cMedia.Media_name; } } if (countLit != null) { this.PrintReceipt(amountLit.Trim(), total.Total_amount, PosContext.Instance.Training); totalCollection += total.Total_amount; } } } string strCollectionTotal = PosContext.Instance.Parameters.getParam("CollectionTotal"); this.PrintReceipt(strCollectionTotal, totalCollection, PosContext.Instance.Training); }
/// <summary> /// Parses the response received from the server. /// </summary> protected override void UnpackResponse() { base.UnpackResponse(); // Create the streams we will be reading from. MemoryStream responseStream = new MemoryStream(m_responsePayload); BinaryReader responseReader = new BinaryReader(responseStream, Encoding.Unicode); // Check the response length. if (responseStream.Length < MinResponseMessageLength) { throw new MessageWrongSizeException("Get Game Cards"); } // Try to unpack the data. try { // Seek past return code. responseReader.BaseStream.Seek(sizeof(int), SeekOrigin.Begin); // Same Cards m_sameCards = responseReader.ReadBoolean(); // Consecutive Cards m_consecutiveCards = responseReader.ReadBoolean(); // Get the count of games. ushort gameCount = responseReader.ReadUInt16(); // Clear any existing games. m_games.Clear(); // Read all the game data. for (ushort currentGame = 0; currentGame < gameCount; currentGame++) { BingoGame game = new BingoGame(); // Game Number game.LinearNumber = responseReader.ReadInt32(); // Display Game Number game.DisplayNumber = responseReader.ReadInt32(); // Game Type Id game.Type = (GameType)responseReader.ReadInt32(); // Set whether this game has consecutive cards. game.ConsecutiveCards = m_consecutiveCards; // Get the count of card types. ushort cardTypeCount = responseReader.ReadUInt16(); for (ushort currentType = 0; currentType < cardTypeCount; currentType++) { // Card Type Id CardType cardType = (CardType)responseReader.ReadInt32(); // Rally DE2312 - Selling CBB cards returns an error. CardMedia mediaType = (CardMedia)responseReader.ReadInt32(); // Get the count of levels. ushort levelCount = responseReader.ReadUInt16(); for (ushort currentLevel = 0; currentLevel < levelCount; currentLevel++) { // Card Level Id int cardLevelId = responseReader.ReadInt32(); // Rally US505 CardLevel level = null; if (game.Type != GameType.CrystalBall && game.Type != GameType.PickYurPlatter) // Rally TA6385 { // Try to find the level in the array we have. if (m_levels == null || m_levels.Length == 0) { throw new ModuleException(Resources.UnknownCardLevel); } foreach (CardLevel lvl in m_levels) { if (lvl.Id == cardLevelId) { level = lvl; break; } } // Rally US229 & US505 if (level == null) { throw new ModuleException(Resources.UnknownCardLevel); } } // Get the count of cards. ushort cardCount = responseReader.ReadUInt16(); for (ushort currentCard = 0; currentCard < cardCount; currentCard++) { BingoCard card = null; // Rally TA5749 // First Card bool firstCard = responseReader.ReadBoolean(); // Card Number int cardNum = responseReader.ReadInt32(); // PDTS 1098 // Rally DE2312 // Create the card. card = BingoCardFactory.CreateBingoCard(game.Type, cardType, mediaType); card.Number = cardNum; card.Level = level; card.IsStartingCard = firstCard; // END: TA5749 // Rally US505 // Rally TA6385 if (m_getFaces || game.Type == GameType.CrystalBall || game.Type == GameType.PickYurPlatter) { // Rally US498 card.ParseFaceData(responseReader); } game.AddCard(card); } } } m_games.Add(game); } } catch (EndOfStreamException e) { throw new MessageWrongSizeException("Get Game Cards", e); } catch (Exception e) { throw new ServerException("Get Game Cards", e); } // Close the streams. responseReader.Close(); }