static void CustomerResponse(RequestHalfStep requestHalfStep, System.Net.Sockets.Socket client) { DBManager bdManager = new DBManager(); bdManager.Connect(); ChosenStep chosenStep = bdManager.GetChosenStep(requestHalfStep); server.Send(client, SerealizationManager.Serealize(chosenStep)); bdManager.Close(); }
/// <summary> /// Метод для отправки пакетов серверу /// </summary> /// <param name="msg"></param> public void Sender(string msg) { try { TransmittedPackets.RequestHalfStep zapros = new RequestHalfStep(randomMatri(), 10); client.Send(SerealizationManager.Serealize(zapros)); } catch { System.Console.WriteLine("Что же не так то пошло при отправке"); } }
/// <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("Нет подключения к базе данных"); } }