Beispiel #1
0
        void EntryIntoDatabase(SaveHystoryParty objSaveHystory)
        {
            DBManager bdManager = new DBManager();

            bdManager.Connect();
            bdManager.Added(objSaveHystory);
            bdManager.Close();
        }
Beispiel #2
0
        /// <summary>
        /// Добавляет в базу обьект типа SaveHystoryParty
        /// </summary>
        /// <param name="hystoryParty"></param>
        public void Added(SaveHystoryParty hystoryParty)
        {
            if (isConnection)
            {
                MementoStep step;
                Analitic    analictic = new Analitic();
                foreach (var itemHystoryList in hystoryParty.Hystory)
                {
                    step = itemHystoryList;

                    if (analictic.ValidationArrangementFigures(step))
                    {
                        this.command = new SqlCommand("INSERT INTO StorageBestMoves(ArrangementFigures, Direction, Position, DepthOfGame)" +
                                                      "VALUES (@ArrangementFigures, @Direction, @Position, @DepthOfGame);", connection);
                        this.command.Parameters.Add("@ArrangementFigures", System.Data.SqlDbType.VarBinary);
                        this.command.Parameters["@ArrangementFigures"].Value = SerealizationManager.Serealize(step.ArrangementFigures);
                        this.command.Parameters.Add("@Direction", System.Data.SqlDbType.VarBinary);
                        this.command.Parameters["@Direction"].Value = SerealizationManager.Serealize(step.direction);
                        this.command.Parameters.Add("@Position", System.Data.SqlDbType.VarBinary);
                        this.command.Parameters["@Position"].Value = SerealizationManager.Serealize(step.position);
                        this.command.Parameters.Add("@DepthOfGame", System.Data.SqlDbType.Int);
                        this.command.Parameters["@DepthOfGame"].Value = step.stepIndex;

                        this.command.ExecuteNonQuery();
                    }
                    else
                    {
                        throw new System.ArgumentException("Index одной или нескльких фигур не соответствую заданой конигурации");
                    }
                }
            }
            else
            {
                throw new System.ArgumentException("Нет подключения к базе данных");
            }
        }