Пример #1
0
        public SqlStatus_ _runSql <__t>(ISqlSerialize nSqlSerialize, List <__t> nValues) where __t : ISqlStream
        {
            string         sqlCommand_     = nSqlSerialize._sqlCommand();
            SqlStatus_     sqlStatus_      = SqlStatus_.mSucess_;
            MySqlSingleton mySqlSingleton_ = __singleton <MySqlSingleton> ._instance();

            string          connectionString_ = mySqlSingleton_._getConnectionString();
            MySqlConnection mySqlConnection_  = new MySqlConnection(connectionString_);

            try
            {
                mySqlConnection_.Open();
                MySqlCommand    mySqlCommand_    = new MySqlCommand(sqlCommand_, mySqlConnection_);
                MySqlDataReader mySqlDataReader_ = mySqlCommand_.ExecuteReader();
                if (mySqlDataReader_.Read())
                {
                    MySqlDataReaderSerialize mySqlDataReaderSerialize_ = new MySqlDataReaderSerialize(mySqlDataReader_);
                    __t t_ = Activator.CreateInstance <__t>();
                    t_._serialize(mySqlDataReaderSerialize_);
                    nValues.Add(t_);
                }
                mySqlDataReader_.Close();
            }
            catch (Exception exception_)
            {
                LogSingleton logSingleton_ = __singleton <LogSingleton> ._instance();

                logSingleton_._logError(exception_.ToString());
                sqlStatus_ = SqlStatus_.mFail_;
            }
            mySqlConnection_.Close();
            return(sqlStatus_);
        }
Пример #2
0
        public SqlStatus_ _runSql(ISqlSerialize nSqlSerialize, ISqlSerialize nSqlSerializeEx, ISqlStream nSqlStream)
        {
            string sqlCommand_ = nSqlSerialize._sqlCommand();

            sqlCommand_ += nSqlSerializeEx._sqlCommand();
            SqlStatus_     sqlStatus_      = SqlStatus_.mSucess_;
            MySqlSingleton mySqlSingleton_ = __singleton <MySqlSingleton> ._instance();

            string          connectionString_ = mySqlSingleton_._getConnectionString();
            MySqlConnection mySqlConnection_  = new MySqlConnection(connectionString_);

            try
            {
                mySqlConnection_.Open();
                MySqlCommand    mySqlCommand_    = new MySqlCommand(sqlCommand_, mySqlConnection_);
                MySqlDataReader mySqlDataReader_ = mySqlCommand_.ExecuteReader();
                if (mySqlDataReader_.Read())
                {
                    MySqlDataReaderSerialize mySqlDataReaderSerialize_ = new MySqlDataReaderSerialize(mySqlDataReader_);
                    nSqlStream._serialize(mySqlDataReaderSerialize_);
                }
                mySqlDataReader_.Close();
            }
            catch (Exception exception_)
            {
                LogSingleton logSingleton_ = __singleton <LogSingleton> ._instance();

                logSingleton_._logError(exception_.ToString());
                sqlStatus_ = SqlStatus_.mFail_;
            }
            mySqlConnection_.Close();
            return(sqlStatus_);
        }
Пример #3
0
        ErrorCode_ _getErrorCode(SqlStatus_ nSqlStatus)
        {
            ErrorCode_ result_ = ErrorCode_.mSucess_;

            if (SqlStatus_.mFail_ == nSqlStatus)
            {
                result_ = ErrorCode_.mFail_;
            }
            return(result_);
        }
Пример #4
0
        public ErrorCode_ _createAccount(string nAccountName, string nNickname, string nPassward)
        {
            AccountB accountB_ = new AccountB();

            accountB_._setAccountName(nAccountName);
            accountB_._setNickName(nNickname);
            accountB_._setPassward(nPassward);
            accountB_._setMgrId(mId);
            accountB_._setTicks(DateTime.Now.Ticks);

            MySqlInsert mySqlInsert_ = new MySqlInsert();

            mySqlInsert_._selectStream(accountB_._streamName());
            accountB_._serialize(mySqlInsert_);

            MySqlSingleton mySqlSingleton_ = __singleton <MySqlSingleton> ._instance();

            SqlStatus_ sqlStatus_ = mySqlSingleton_._runSql(mySqlInsert_);

            return(_getErrorCode(sqlStatus_));
        }
Пример #5
0
        __tuple <SqlStatus_, AccountB> _LoginAccountB(string nAccountName)
        {
            AccountB accountB_ = new AccountB();

            accountB_._setMgrId(mId);
            accountB_._setAccountName(nAccountName);

            MySqlSelect mySqlSelect_ = new MySqlSelect();

            mySqlSelect_._selectStream(accountB_._streamName());
            accountB_._serialize(mySqlSelect_);

            MySqlWhere mySqlWhere_ = new MySqlWhere();

            mySqlWhere_._selectStream(accountB_._loginWhere());

            MySqlSingleton mySqlSingleton_ = __singleton <MySqlSingleton> ._instance();

            SqlStatus_ sqlStatus_ = mySqlSingleton_._runSql(mySqlSelect_, mySqlWhere_, accountB_);

            return(new __tuple <SqlStatus_, AccountB>(sqlStatus_, accountB_));
        }
Пример #6
0
        public SqlStatus_ _runSql(ISqlSerialize nSqlSerialize)
        {
            string          sqlCommand_      = nSqlSerialize._sqlCommand();
            SqlStatus_      sqlStatus_       = SqlStatus_.mSucess_;
            MySqlConnection mySqlConnection_ = new MySqlConnection(mConnectionString);

            try
            {
                mySqlConnection_.Open();
                MySqlCommand mySqlCommand_ = new MySqlCommand(sqlCommand_, mySqlConnection_);
                mySqlCommand_.ExecuteNonQuery();
            }
            catch (Exception exception_)
            {
                LogSingleton logSingleton_ = __singleton <LogSingleton> ._instance();

                logSingleton_._logError(exception_.ToString());
                sqlStatus_ = SqlStatus_.mFail_;
            }
            mySqlConnection_.Close();
            return(sqlStatus_);
        }