Example #1
0
        public static void Save(MySqlConnection sqlConnection, S_Game game, S_Frame frame)
        {
            long?frameId = null;

            frame.gameId = game.id;

            if (!FrameManager.FrameExistByGameIdAndFrameNumber(sqlConnection, game.id, frame.frameNumber, out frameId))
            {
                frame.id = Insert(sqlConnection, frame).Value;
            }
            else
            {
                frame.id = frameId.Value;
                // update progressiveTotal and isConvertedsplit
                Update(sqlConnection, frame);
            }

            if (frame.bowl1 != null)
            {
                frame.bowl1.bowlNumber = 1;
                BowlManager.Save(sqlConnection, frame, frame.bowl1);
            }

            if (frame.bowl2 != null)
            {
                frame.bowl2.bowlNumber = 2;
                BowlManager.Save(sqlConnection, frame, frame.bowl2);
            }

            if (frame.bowl3 != null)
            {
                frame.bowl3.bowlNumber = 3;
                BowlManager.Save(sqlConnection, frame, frame.bowl3);
            }
        }
Example #2
0
        private static S_Game GetGame(XmlNode xmlGameNode)
        {
            S_Game game = new S_Game();

            game.frames = new List <S_Frame>();

            try
            {
                #region xml example
                //<Game>
                //  <IDGame>53</IDGame>
                //  <LaneNumber>1</LaneNumber>
                //  <PlayerName>Rita</PlayerName>
                //  <FullName>Rita</FullName>
                //  <FreeEntryCode/>
                //  <PlayerPosition>2</PlayerPosition>
                //  <StartDateTime>201308270953</StartDateTime>
                //  <EndDateTime>201308270955</EndDateTime>
                //  <GameNumber>1</GameNumber>
                //  <Hdcp>0</Hdcp>
                //  <Total>137</Total>
                //  <Frames>
                //      <Frame>....</Frame>
                //      <Frame>....</Frame>
                //  </Frames>
                //</Game>
                #endregion

                // all child nodes in Game
                XmlNodeList xmlGameChildNodeList = xmlGameNode.SelectNodes("*");

                foreach (XmlNode xmlGameChildNode in xmlGameChildNodeList)
                {
                    switch (xmlGameChildNode.Name)
                    {
                    case "IDGame":
                        game.gameCode = Conversion.StringToInt(xmlGameChildNode.InnerText).Value;
                        break;

                    case "LaneNumber":
                        game.laneNumber = Conversion.StringToInt(xmlGameChildNode.InnerText).Value;
                        break;

                    case "PlayerName":
                        game.playerName = Conversion.StringToString(xmlGameChildNode.InnerText);
                        break;

                    case "PlayerFullName":
                        game.fullName = Conversion.StringToString(xmlGameChildNode.InnerText);
                        break;

                    case "FreeEntryCode":
                        game.freeEntryCode = Conversion.StringToString(xmlGameChildNode.InnerText);
                        break;

                    case "PlayerPosition":
                        game.playerPosition = Conversion.StringToInt(xmlGameChildNode.InnerText).Value;
                        break;

                    case "StartDateTime":
                        game.startDateTime = Conversion.StringToDateTimeQubica(xmlGameChildNode.InnerText).Value;
                        break;

                    case "EndDateTime":
                        game.endDateTime = Conversion.StringToDateTimeQubica(xmlGameChildNode.InnerText).Value;
                        break;

                    case "GameNumber":
                        game.gameNumber = Conversion.StringToInt(xmlGameChildNode.InnerText).Value;
                        break;

                    case "Hdcp":
                        game.handicap = Conversion.StringToInt(xmlGameChildNode.InnerText).Value;
                        break;

                    case "Total":
                        game.total = Conversion.StringToInt(xmlGameChildNode.InnerText).Value;
                        break;

                    case "Frames":
                        // all child nodes in Games (game)
                        XmlNodeList xmlFramesNodeList = xmlGameChildNode.SelectNodes("*");

                        // loop over all Frame nodes for this Game
                        foreach (XmlNode xmlFrameNode in xmlFramesNodeList)
                        {
                            game.frames.Add(GetFrame(xmlFrameNode));
                        }
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(String.Format("Error parsing Game from response: {0}", ex.Message));
            }

            return(game);
        }