public bool CancelSellOrder(SellStonesOrder order, CustomerMySqlTransaction trans)
        {
            MySqlCommand mycmd = null;

            try
            {
                mycmd = trans.CreateCommand();

                string cmdTextA = "delete from sellstonesorder where OrderNumber = @OrderNumber;";

                mycmd.CommandText = cmdTextA;
                mycmd.Parameters.AddWithValue("@OrderNumber", order.OrderNumber);

                mycmd.ExecuteNonQuery();

                return(true);
            }
            finally
            {
                if (mycmd != null)
                {
                    mycmd.Dispose();
                }
            }
        }
Esempio n. 2
0
 public void AddSellOrder(SellStonesOrder order, int userID, CustomerMySqlTransaction myTrans)
 {
     lock (this._lockListSellOrders)
     {
         DBProvider.StoneOrderDBProvider.AddSellOrder(order, userID, myTrans);
         dicSellOrders[order.OrderNumber] = new StoneOrderRunnable(order);
     }
 }
Esempio n. 3
0
 public void ClearSellStonesOrder(SellStonesOrder order)
 {
     lock (this._lockListSellOrders)
     {
         StoneOrderRunnable runnable = null;
         dicSellOrders.TryRemove(order.OrderNumber, out runnable);
     }
 }
Esempio n. 4
0
        /// <summary>
        /// RESULTCODE_ORDER_NOT_EXIST; RESULTCODE_ORDER_NOT_BELONE_CURRENT_PLAYER; RESULTCODE_ORDER_BE_LOCKED; RESULTCODE_TRUE; RESULTCODE_FALSE
        /// </summary>
        /// <param name="orderNumber"></param>
        /// <returns></returns>
        public int CancelSellOrder(string sellUserName, string orderNumber)
        {
            lock (this._lockListSellOrders)
            {
                StoneOrderRunnable runnable = null;
                this.dicSellOrders.TryGetValue(orderNumber, out runnable);
                if (runnable == null)
                {
                    return(OperResult.RESULTCODE_ORDER_NOT_EXIST);
                }
                SellStonesOrder order = runnable.SellOrder;
                if (order.SellerUserName != sellUserName)
                {
                    return(OperResult.RESULTCODE_ORDER_NOT_BELONE_CURRENT_PLAYER);
                }
                if (order.OrderState != SellOrderState.Wait)
                {
                    return(OperResult.RESULTCODE_ORDER_BE_LOCKED);
                }

                CustomerMySqlTransaction trans = null;

                try
                {
                    trans = MyDBHelper.Instance.CreateTrans();
                    PlayerController.Instance.CancelSellStones(order, trans);
                    DBProvider.StoneOrderDBProvider.CancelSellOrder(order, trans);

                    trans.Commit();

                    this.dicSellOrders.TryRemove(orderNumber, out runnable);
                    return(OperResult.RESULTCODE_TRUE);
                }
                catch (Exception exc)
                {
                    trans.Rollback();
                    LogHelper.Instance.AddErrorLog("玩家[" + orderNumber + "]取消矿石订单:" + sellUserName + "异常。", exc);
                    return(OperResult.RESULTCODE_FALSE);
                }
                finally
                {
                    if (trans != null)
                    {
                        trans.Dispose();
                    }
                }
            }
        }
        public bool AddSellOrder(SellStonesOrder order, int userID, CustomerMySqlTransaction trans)
        {
            MySqlCommand mycmd = null;

            try
            {
                mycmd = trans.CreateCommand();

                string cmdTextA = "insert into sellstonesorder " +
                                  "(`OrderNumber`, `SellerUserName`, `SellStonesCount`, `Expense`, `ValueRMB`, `SellTime`, `OrderState` ) " +
                                  " values " +
                                  "(@OrderNumber, @SellerUserName, @SellStonesCount, @Expense, @ValueRMB, @SellTime, @OrderState); ";

                mycmd.CommandText = cmdTextA;
                mycmd.Parameters.AddWithValue("@OrderNumber", order.OrderNumber);
                mycmd.Parameters.AddWithValue("@SellerUserName", DESEncrypt.EncryptDES(order.SellerUserName));
                mycmd.Parameters.AddWithValue("@SellStonesCount", order.SellStonesCount);
                mycmd.Parameters.AddWithValue("@Expense", order.Expense);
                mycmd.Parameters.AddWithValue("@ValueRMB", order.ValueRMB);
                mycmd.Parameters.AddWithValue("@SellTime", order.SellTime);
                mycmd.Parameters.AddWithValue("@OrderState", order.OrderState);

                mycmd.ExecuteNonQuery();

                PlayerLastSellStoneRecord lastrecord = new PlayerLastSellStoneRecord()
                {
                    UserID = userID,
                    SellStoneOrderNumber = order.OrderNumber,
                    SellTime             = order.SellTime
                };
                string cmdTextB = "delete from playerlastsellstonerecord where `UserID` = @UserID ;" +
                                  "insert into playerlastsellstonerecord " +
                                  "(`UserID`, `SellStoneOrderNumber`, `SellTime` ) " +
                                  " values " +
                                  "(@UserID, @OrderNumber, @SellTime ); ";

                mycmd.CommandText = cmdTextB;
                mycmd.Parameters.AddWithValue("@UserID", lastrecord.UserID);

                mycmd.ExecuteNonQuery();

                return(true);
            }
            finally
            {
                mycmd.Dispose();
            }
        }
Esempio n. 6
0
        /// <summary>
        /// 如果事务提交失败,则需调用ClearSellStonesOrder方法从集合中清除该方法返回的订单
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="sellStonesCount"></param>
        /// <param name="myTrans"></param>
        /// <returns></returns>
        public SellStonesOrder CreateSellOrder(string userName, int userExpValue, long creditValue, int sellStonesCount)
        {
            decimal         valueRMB = sellStonesCount / GlobalConfig.GameConfig.Stones_RMB;
            DateTime        time     = DateTime.Now;
            SellStonesOrder order    = new SellStonesOrder()
            {
                OrderNumber       = OrderController.Instance.CreateOrderNumber(userName, time, AlipayTradeInType.BuyStone),
                SellStonesCount   = sellStonesCount,
                OrderState        = SellOrderState.Wait,
                SellerUserName    = userName,
                SellerCreditValue = creditValue,
                SellerExpValue    = userExpValue,
                ValueRMB          = valueRMB,
                Expense           = GetExpense(valueRMB),
                SellTime          = time,
            };

            return(order);
        }
        public SellStonesOrder GetSellOrder(string orderNumber)
        {
            SellStonesOrder order  = null;
            MySqlConnection myconn = null;

            try
            {
                DataTable table = new DataTable();

                myconn = MyDBHelper.Instance.CreateConnection();
                myconn.Open();
                string cmdText = "select s.*, f.CreditValue as SellerCreditValue, f.Exp as SellerExpValue " +
                                 " from sellstonesorder s  left join playerfortuneinfo f on f.userId = (select u.id from playersimpleinfo u where u.UserName = s.SellerUserName)" +
                                 " where s.OrderNumber = @OrderNumber";

                MySqlCommand mycmd = new MySqlCommand(cmdText, myconn);
                mycmd.Parameters.AddWithValue("@OrderNumber", orderNumber);

                MySqlDataAdapter adapter = new MySqlDataAdapter(mycmd);
                adapter.Fill(table);
                if (table != null && table.Rows.Count > 0)
                {
                    order = MetaDBAdapter <SellStonesOrder> .GetSellStonesOrderFromDataTable(table)[0];
                }
                table.Clear();
                table.Dispose();
                adapter.Dispose();

                mycmd.Dispose();

                return(order);
            }
            finally
            {
                MyDBHelper.Instance.DisposeConnection(myconn);
            }
        }
Esempio n. 8
0
 public void UpdateLockedOrder(LockSellStonesOrder lockInfo)
 {
     _lockOrderObject = lockInfo;
     this._sellOrder  = lockInfo.StonesOrder;
 }
Esempio n. 9
0
 public StoneOrderRunnable(LockSellStonesOrder lockInfo)
 {
     _lockOrderObject = lockInfo;
     this._sellOrder  = lockInfo.StonesOrder;
 }
Esempio n. 10
0
 public StoneOrderRunnable(SellStonesOrder sellOrder)
 {
     this._sellOrder = sellOrder;
 }
Esempio n. 11
0
        public void EndProcessRequest(IAsyncResult result)
        {
            try
            {
                MyGetNotFinishedSellStoneAsyncResult myresult = result as MyGetNotFinishedSellStoneAsyncResult;
                if (myresult == null)
                {
                    return;
                }

                myresult.Context.Response.ContentType = "text/plain";
                myresult.Context.Response.Cache.VaryByParams.IgnoreParams = false;
                myresult.Context.Response.Cache.SetCacheability(HttpCacheability.Public);
                myresult.Context.Response.Cache.SetExpires(DateTime.Now.AddSeconds(5));

                if (myresult.Exception != null)
                {
                    LogHelper.Instance.AddErrorLog("AsyncGetSellStoneOrderHandler.GetResult Exception", myresult.Exception);
                    myresult.Context.Response.Write("0" + myresult.Exception.Message);
                    return;
                }

                string jsonString = "";
                if (myresult.Result != null)
                {
                    SellStonesOrder[] orders = myresult.Result as SellStonesOrder[];

                    Dictionary <string, SellStonesOrder> dicOrders_VipPlayer = new Dictionary <string, SellStonesOrder>();
                    List <SellStonesOrder> listOrders_NormalPlayer           = new List <SellStonesOrder>();
                    foreach (var item in orders)
                    {
                        if (item.OrderState == SellOrderState.Wait && item.SellerExpLevel > 0)
                        {
                            if (!dicOrders_VipPlayer.ContainsKey(item.SellerUserName))
                            {
                                dicOrders_VipPlayer.Add(item.SellerUserName, item);
                                continue;
                            }
                        }

                        listOrders_NormalPlayer.Add(item);
                    }

                    var listASC_VipOrders     = dicOrders_VipPlayer.Values.OrderByDescending(s => s.SellTime).OrderByDescending(s => s.SellerCreditValue);
                    var listASC_NormalOrders  = listOrders_NormalPlayer.OrderByDescending(s => s.SellTime).OrderByDescending(s => s.SellerCreditValue).OrderBy(s => s.OrderStateInt);
                    SellStonesOrder[] listAll = new SellStonesOrder[orders.Length];

                    int i = 0;
                    foreach (var item in listASC_VipOrders)
                    {
                        listAll[i] = item;
                        i++;
                    }
                    foreach (var item in listASC_NormalOrders)
                    {
                        listAll[i] = item;
                        i++;
                    }

                    DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(SellStonesOrder[]));
                    MemoryStream ms = new MemoryStream();
                    serializer.WriteObject(ms, listAll);
                    jsonString = Encoding.UTF8.GetString(ms.ToArray());
                    ms.Close();
                }
                myresult.Context.Response.Write("1" + jsonString);
            }
            catch (Exception exc)
            {
                LogHelper.Instance.AddErrorLog("AsyncGetSellStoneOrderHandler.EndProcessRequest Exception", exc);
            }
        }
Esempio n. 12
0
 public SellStoneOrderUIModel(SellStonesOrder parent)
 {
     this.ParentObject = parent;
 }
 public StoneOrderNotFinishedRecordUIModel(SellStonesOrder parent)
 {
     this.SellStonesOrderObject = parent;
 }