Ejemplo n.º 1
0
 public static bool CopyAuctionDBItem(List <GoldAuctionDBItem> sData, ref List <GoldAuctionDBItem> rData)
 {
     try
     {
         foreach (GoldAuctionDBItem item in sData)
         {
             GoldAuctionDBItem tempItem = new GoldAuctionDBItem();
             CopyData.Copy <GoldAuctionDBItem>(item, ref tempItem);
             tempItem.BuyerData = new AuctionRoleData();
             CopyData.Copy <AuctionRoleData>(item.BuyerData, ref tempItem.BuyerData);
             if (tempItem != null)
             {
                 tempItem.RoleList = new List <AuctionRoleData>();
                 foreach (AuctionRoleData RoleData in item.RoleList)
                 {
                     AuctionRoleData tempRole = new AuctionRoleData();
                     CopyData.Copy <AuctionRoleData>(RoleData, ref tempRole);
                     tempItem.RoleList.Add(tempRole);
                 }
                 tempItem.OldAuctionType = tempItem.AuctionType;
                 rData.Add(tempItem);
             }
         }
         return(true);
     }
     catch (Exception ex)
     {
         LjlLog.WriteLog(LogTypes.Error, ex.ToString(), "");
     }
     return(false);
 }
Ejemplo n.º 2
0
        public static bool Update(GoldAuctionDBItem Item)
        {
            int ret = -1;

            try
            {
                using (MyDbConnection3 conn = new MyDbConnection3(false))
                {
                    string cmdText = string.Format("UPDATE t_gold_auction SET BuyerData='{0}', AuctionTime='{1}', AuctionType='{2}', UpDBWay='{3}', UpdateTime='{4}' WHERE AuctionSource='{5}' AND ProductionTime='{6}'", new object[]
                    {
                        Item.BuyerData.getAttackerValue(),
                        Item.AuctionTime,
                        Item.AuctionType,
                        ((DBAuctionUpEnum)Item.UpDBWay).ToString(),
                        DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                        Item.AuctionSource,
                        Item.ProductionTime
                    });
                    ret = conn.ExecuteNonQuery(cmdText, 0);
                    LjlLog.WriteLogFormat(LogTypes.Info, new string[]
                    {
                        "金团拍卖行更新",
                        (ret > -1).ToString(),
                        "  ",
                        cmdText
                    });
                }
            }
            catch (Exception ex)
            {
                LjlLog.WriteLog(LogTypes.Exception, ex.ToString(), "");
            }
            return(ret > -1);
        }
Ejemplo n.º 3
0
        private void SetGlodAuction(GameServerClient client, int nID, byte[] cmdParams, int count)
        {
            string msgStr = "false";

            try
            {
                GoldAuctionDBItem tempData = DataHelper.BytesToObject <GoldAuctionDBItem>(cmdParams, 0, count);
                if (3 <= tempData.AuctionType || 0 >= tempData.AuctionType)
                {
                    LjlLog.WriteLog(LogTypes.Error, string.Format("SetGlodAuction 金团类型错误 type={0}", tempData.AuctionType), "");
                }
                else if (tempData.UpDBWay == 2)
                {
                    msgStr = GoldAuctionDB.Insert(tempData).ToString();
                    LjlLog.WriteLog(LogTypes.Info, string.Format("Add 金团新物品 type={0}, time={1}, AuctionSource={2}, upway={3}, msgDbStr={4}", new object[]
                    {
                        tempData.AuctionType,
                        tempData.ProductionTime,
                        tempData.AuctionSource,
                        ((DBAuctionUpEnum)tempData.UpDBWay).ToString(),
                        msgStr
                    }), "");
                }
                else
                {
                    msgStr = GoldAuctionDB.Update(tempData).ToString();
                }
                client.sendCmd(nID, msgStr);
                if (msgStr.Equals("True"))
                {
                    List <GoldAuctionDBItem> tempList;
                    if (this.AuctionDict.TryGetValue(tempData.OldAuctionType, out tempList))
                    {
                        tempList.RemoveAll((GoldAuctionDBItem x) => x.ProductionTime == tempData.ProductionTime && x.AuctionSource == tempData.AuctionSource);
                    }
                    if (this.AuctionDict.TryGetValue(tempData.AuctionType, out tempList) && tempData.UpDBWay != 1)
                    {
                        tempList.Add(tempData);
                    }
                }
            }
            catch (Exception ex)
            {
                LjlLog.WriteLog(LogTypes.Exception, ex.ToString(), "");
            }
        }
Ejemplo n.º 4
0
        public static bool Insert(GoldAuctionDBItem Item)
        {
            int ret = -1;

            try
            {
                using (MyDbConnection3 conn = new MyDbConnection3(false))
                {
                    string strAttackerList = DataHelper.ObjectToHexString <List <AuctionRoleData> >(Item.RoleList);
                    string temp            = "INSERT INTO t_gold_auction(BuyerData, AuctionTime, AuctionType, AuctionSource, ProductionTime,";
                    temp += "StrGoods, BossLife, KillBossRoleID, UpDBWay, UpdateTime, AttackerList)";
                    temp += " VALUES('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', {10})";
                    string cmdText = string.Format(temp, new object[]
                    {
                        Item.BuyerData.getAttackerValue(),
                        Item.AuctionTime,
                        Item.AuctionType,
                        Item.AuctionSource,
                        Item.ProductionTime,
                        Item.StrGoods,
                        Item.BossLife,
                        Item.KillBossRoleID,
                        ((DBAuctionUpEnum)Item.UpDBWay).ToString(),
                        DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                        strAttackerList
                    });
                    ret = conn.ExecuteNonQuery(cmdText, 0);
                    LjlLog.WriteLogFormat(LogTypes.Info, new string[]
                    {
                        "SQL  Insert ",
                        (ret > -1).ToString()
                    });
                }
            }
            catch (Exception ex)
            {
                LjlLog.WriteLog(LogTypes.Exception, ex.ToString(), "");
            }
            return(ret > -1);
        }
Ejemplo n.º 5
0
        public static bool Select(out List <GoldAuctionDBItem> dList, int type)
        {
            MySQLConnection conn  = null;
            DBManager       dbMgr = DBManager.getInstance();

            dList = new List <GoldAuctionDBItem>();
            try
            {
                conn = dbMgr.DBConns.PopDBConnection();
                string          cmdText = "SELECT BuyerData, AuctionTime, AuctionType, AuctionSource, ProductionTime, StrGoods, BossLife, KillBossRoleID, AttackerList FROM t_gold_auction WHERE UpDBWay!='Del' AND AuctionType='{0}';";
                MySQLCommand    cmd     = new MySQLCommand(string.Format(cmdText, type), conn);
                MySQLDataReader reader  = cmd.ExecuteReaderEx();
                while (reader.Read())
                {
                    GoldAuctionDBItem AuctionItem = new GoldAuctionDBItem
                    {
                        AuctionTime    = reader["AuctionTime"].ToString(),
                        AuctionType    = Convert.ToInt32(reader["AuctionType"].ToString()),
                        AuctionSource  = Convert.ToInt32(reader["AuctionSource"].ToString()),
                        ProductionTime = reader["ProductionTime"].ToString(),
                        StrGoods       = reader["StrGoods"].ToString(),
                        BossLife       = Convert.ToInt64(reader["BossLife"].ToString()),
                        KillBossRoleID = Convert.ToInt32(reader["KillBossRoleID"].ToString())
                    };
                    string   BuyerData = reader["BuyerData"].ToString();
                    string[] fields    = BuyerData.Split(new char[]
                    {
                        ','
                    });
                    AuctionItem.BuyerData = new AuctionRoleData();
                    if (6 == fields.Length)
                    {
                        AuctionItem.BuyerData.m_RoleID   = Convert.ToInt32(fields[0]);
                        AuctionItem.BuyerData.Value      = Convert.ToInt64(fields[1]);
                        AuctionItem.BuyerData.m_RoleName = fields[2];
                        AuctionItem.BuyerData.ZoneID     = Convert.ToInt32(fields[3]);
                        AuctionItem.BuyerData.strUserID  = fields[4];
                        AuctionItem.BuyerData.ServerId   = Convert.ToInt32(fields[5]);
                    }
                    AuctionItem.OldAuctionType = AuctionItem.AuctionType;
                    byte[] bytes = (reader["AttackerList"] as byte[]) ?? new byte[0];
                    AuctionItem.RoleList = DataHelper.BytesToObject <List <AuctionRoleData> >(bytes, 0, bytes.Length);
                    if (null == AuctionItem.RoleList)
                    {
                        AuctionItem.RoleList = new List <AuctionRoleData>();
                    }
                    dList.Add(AuctionItem);
                }
                GameDBManager.SystemServerSQLEvents.AddEvent(string.Format("+SQL: {0}", string.Format(cmdText, type)), EventLevels.Important);
                cmd.Dispose();
            }
            catch (Exception ex)
            {
                LjlLog.WriteLog(LogTypes.Exception, ex.ToString(), "");
                return(false);
            }
            finally
            {
                if (null != conn)
                {
                    dbMgr.DBConns.PushDBConnection(conn);
                }
            }
            return(true);
        }