示例#1
0
        public void UserProcedureMethod1()
        {
            Logger.Log.Error("### UserProcedureMethod1 #############################################");
            int accountId = 0;
            string accountName = "";
            using (var context = new CommonContext()) {

                accountId = (from row in context.Account select row).Max(x => x.Acctidx) + 2;
                accountName = String.Format("test.{0}", accountId);
                Logger.Log.Debug("accountId = " + accountId + ", accountName = " + accountName);

                t_Account account = new t_Account() {
                    Acctidx = accountId,
                    Name = accountName,
                    PlayerIdx = 1,
                    DeviceIdx = 1,
                    SuccessiveLoginCount = 1,
                    Gold = 100,
                    Cash = 100,
                    FreeCash = 100,
                    EnchantStone = 100,
                    GoldenArrow = 100,
                    Honor = 100,
                    Level = 1,
                    Exp = 0,
                    Language = 0,
                    Location = 0,
                    UsePush = 0,
                    UseProfile = 0,
                    UsePushArrow = 0,
                    InventorySlotSize = 0
                };

                context.Account.Add(account);
                context.SaveChanges();
            }

            //Started transaction
            using (var context = new CommonContext()) {

                var query = String.Format("call uspJoinAfter({0})", accountId);
                var result = context.Database.ExecuteSqlCommand(query);

                Logger.Log.Debug("ExecuteSqlCommand : result = " + result);
            }
        }
示例#2
0
        public void UserProcedureMethod2()
        {
            Logger.Log.Error("### UserProcedureMethod2 #############################################");

            int accountId = 0;
            string accountName = "";
            using (var context = new CommonContext()) {

                accountId = (from row in context.Account select row).Max(x => x.Acctidx) + 2;
                accountName = String.Format("test.{0}", accountId);
                Logger.Log.Debug("accountId = " + accountId + ", accountName = " + accountName);

                t_Account account = new t_Account() {
                    Acctidx = accountId,
                    Name = accountName,
                    PlayerIdx = 1,
                    DeviceIdx = 1,
                    SuccessiveLoginCount = 1,
                    Gold = 100,
                    Cash = 100,
                    FreeCash = 100,
                    EnchantStone = 100,
                    GoldenArrow = 100,
                    Honor = 100,
                    Level = 1,
                    Exp = 0,
                    Language = 0,
                    Location = 0,
                    UsePush = 0,
                    UseProfile = 0,
                    UsePushArrow = 0,
                    InventorySlotSize = 0
                };

                context.Account.Add(account);
                context.SaveChanges();
            }

            var parameters = new List<MySqlParameter>
                {
                    new MySqlParameter("@account_id", (long)accountId),
                    new MySqlParameter("@retval", MySqlDbType.Int32) { Direction = ParameterDirection.Output }
                };

            int retval = 0;
            using (var connection = new MySqlConnection(ConfigurationManager.ConnectionStrings["_common_context"].ConnectionString)) {

                connection.Open();
                using (var command = new MySqlCommand("t_uspJoinAfter", connection)) {

                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.Parameters.AddRange((Array)parameters.ToArray());
                    command.ExecuteNonQuery();

                    retval = (int)command.Parameters["@retval"].Value;
                }
                connection.Close();
                Logger.Log.Debug(" : " + retval);
            }
        }
示例#3
0
 void Enter(int key, t_Account account)
 {
     IDatabase db = redis_.GetDatabase();
 }