コード例 #1
0
ファイル: DataAccess.cs プロジェクト: rrossenbg/vprint
        /// <summary>
        /// Creates a command for inserting message
        /// </summary>
        /// <param name="message"></param>
        /// <param name="source"></param>
        /// <param name="stacktrase"></param>
        /// <param name="onServer"></param>
        /// <returns></returns>
        private static SqlCommand CreateInsertMessage(string message, int clientID,
                                                      eSources source, eMessageTypes type,
                                                      string stackTrace, DateTime dateGenerated)
        {
            const string sql = "spInsertMessage";

            return(MSSQL.CreateCommand(ConnectionString,
                                       sql,
                                       CommandType.StoredProcedure,
                                       new SqlParameter("@ClientID", clientID),
                                       new SqlParameter("@Message", message),
                                       new SqlParameter("@Type", Convert.ToInt32(type)),
                                       new SqlParameter("@SourceID", Convert.ToInt32(source)),
                                       new SqlParameter("@StackTrace", stackTrace),
                                       new SqlParameter("@DateGenerated", dateGenerated)));
        }
コード例 #2
0
        public static MessageBase FromByteArray(byte[] b)
        {
            MemoryStream memoryStream = new MemoryStream(b);
            BinaryReader binaryReader = new BinaryReader(memoryStream);

            int           size         = binaryReader.ReadInt32();
            eMessageTypes eMessageType = (eMessageTypes)binaryReader.ReadInt32();

            MessageBase m;

            switch (eMessageType)
            {
            case eMessageTypes.ConnnectMessage:
                m = new ConnectMessage();
                break;

            case eMessageTypes.DisconnectMessage:
                m = new DisconnectMessage();
                break;

            case eMessageTypes.ReadyMessage:
                m = new ReadyMessage();
                break;

            case eMessageTypes.StartGameMessage:
                m = new StartGameMessage();
                break;

            case eMessageTypes.StopGameMessage:
                m = new StopGameMessage();
                break;

            case eMessageTypes.ChatMessage:
                m = new ChatMessage();
                break;

            case eMessageTypes.HeartbeatMessage:
                m = new HeartbeatMessage();
                break;

            case eMessageTypes.GameStateMessage:
                m = new GameStateMessage();
                break;

            case eMessageTypes.GameInputMessage:
                m = new GameInputMessage();
                break;

            case eMessageTypes.EndTurnMessage:
                m = new EndTurnMessage();
                break;

            case eMessageTypes.GameSettingsMessage:
                m = new GameSettingsMessage();
                break;

            case eMessageTypes.ClientInformationMessage:
                m = new ClientInformationMessage();
                break;

            case eMessageTypes.PlayerRenameMessage:
                m = new PlayerRenameMessage();
                break;

            case eMessageTypes.RoomCreationMessage:
                m = new RoomCreationMessage();
                break;

            case eMessageTypes.RoomListUpdateMessage:
                m = new RoomListUpdateMessage();
                break;

            case eMessageTypes.RoomJoinMessage:
                m = new RoomJoinMessage();
                break;

            case eMessageTypes.RoomInformationMessage:
                m = new RoomInformationMessage();
                break;

            case eMessageTypes.MapSendMessage:
                m = new MapSendMessage();
                break;

            case eMessageTypes.RoomLobbyMessage:
                m = new RoomLobbyMessage();
                break;

            case eMessageTypes.SurrenderMessage:
                m = new SurrenderMessage();
                break;

            default:
                //TODO: DONT LET THE SERVER CRASH (Default Chat Massage)
                throw new ArgumentOutOfRangeException();
            }

            m.Read(binaryReader);

            return(m);
        }
コード例 #3
0
ファイル: DataAccess.cs プロジェクト: rrossenbg/vprint
 /// <summary>
 /// Insert message to the database. Do not fire errors.
 /// </summary>
 /// <param name="message"></param>
 /// <param name="source"></param>
 /// <param name="stacktrase"></param>
 /// <param name="onServer"></param>
 public static void InsertMessageAsync(string message, int clientID, eSources source, eMessageTypes type, string stackTrase, DateTime dateGenerated)
 {
     // Do not refire errors
     SQLWorker.Default.Add(CreateInsertMessage(message, clientID, source, type, stackTrase, dateGenerated),
                           //No Errors!
                           PTFUtils.EmptyThreadExceptionEventHandler());
 }
コード例 #4
0
ファイル: DataAccess.cs プロジェクト: rrossenbg/vprint
 /// <summary>
 /// Insert message to the database. Do not fire errors.
 /// </summary>
 /// <param name="message"></param>
 /// <param name="source"></param>
 /// <param name="stacktrase"></param>
 /// <param name="onServer"></param>
 public static void InsertMessage(string message, int clientID, eSources source, eMessageTypes type, string stackTrase, DateTime dateGenerated)
 {
     // Do not refire errors
     SQL.ExecuteNonQuery(CreateInsertMessage(message, clientID, source, type, stackTrase, dateGenerated));
 }
コード例 #5
0
ファイル: DataAccess.cs プロジェクト: rrossenbg/vprint
        /// <summary>
        /// Creates command for inserting message to the client database
        /// </summary>
        /// <param name="message"></param>
        /// <param name="source"></param>
        /// <param name="stacktrase"></param>
        /// <param name="onServer"></param>
        /// <returns></returns>
        private static SqlCommand CreateInsertMessage(string message, eSources source, eMessageTypes type, string stackTrase)
        {
            const string sql = "INSERT INTO MESSAGES(Message, Source, Type, StackTrace, DateInserted) VALUES " +
                               "(@Message, @Source, @Type, @StackTrace, @DateInserted);";

            return(MSSQL.CreateCommand(ConnectionString,
                                       sql,
                                       new SqlParameter("@Message", message.Top(1024)),
                                       new SqlParameter("@Source", Convert.ToInt32(source)),
                                       new SqlParameter("@Type", Convert.ToInt32(type)),
                                       new SqlParameter("@StackTrace", stackTrase.Top(2028)),
                                       new SqlParameter("@DateInserted", DateTime.Now)));
        }
コード例 #6
0
ファイル: DataAccess.cs プロジェクト: rrossenbg/vprint
 /// <summary>
 /// Inserts message to the client database asynchronously
 /// </summary>
 /// <param name="message"></param>
 /// <param name="source"></param>
 /// <param name="type"></param>
 /// <param name="stacktrase"></param>
 public static void InsertMessageAsync(string message, eSources source, eMessageTypes type, string stacktrase)
 {
     // Do not refire errors
     SQLWorker.Default.Add(CreateInsertMessage(message, source, type, stacktrase));
 }
コード例 #7
0
ファイル: DataAccess.cs プロジェクト: rrossenbg/vprint
 /// <summary>
 /// Inserts message to the client database
 /// </summary>
 /// <param name="message"></param>
 /// <param name="source"></param>
 /// <param name="type"></param>
 /// <param name="stacktrase"></param>
 public static void InsertMessage(string message, eSources source, eMessageTypes type, string stacktrase)
 {
     SQL.ExecuteNonQuery(CreateInsertMessage(message, source, type, stacktrase));
 }