Ejemplo n.º 1
0
 public void LoadDataFromDB(DBManager DBMgr)
 {
     try
     {
         lock (this.AuctionMsgMutex)
         {
             GoldAuctionDB.DelData(string.Format("UpDBWay='Del' AND UpdateTime < '{0}'", DateTime.Now.AddDays(-365.0).ToString("yyyy-MM-dd HH:mm:ss")));
             this.AuctionDict.Clear();
             for (int i = 1; i < 3; i++)
             {
                 List <GoldAuctionDBItem> dList;
                 if (GoldAuctionDB.Select(out dList, i))
                 {
                     this.AuctionDict.Add(i, dList);
                     LjlLog.WriteLog(LogTypes.Info, string.Format("初始化金团数据type={0},len={1}", ((AuctionOrderEnum)i).ToString(), dList.Count), "");
                 }
                 else
                 {
                     LjlLog.WriteLog(LogTypes.Info, string.Format("初始化金团数据type={0},false", ((AuctionOrderEnum)i).ToString()), "");
                 }
             }
         }
     }
     catch (Exception ex)
     {
         LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true);
     }
 }
Ejemplo n.º 2
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.º 3
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.º 4
0
 private static void Copy <T>(T sData, ref T rData)
 {
     try
     {
         foreach (FieldInfo info in rData.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
         {
             info.SetValue(rData, info.GetValue(sData));
         }
     }
     catch (Exception ex)
     {
         rData = default(T);
         LjlLog.WriteLog(LogTypes.Error, ex.ToString(), "");
     }
 }
Ejemplo n.º 5
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.º 6
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.º 7
0
        private void GetGlodAuction(GameServerClient client, int nID, byte[] cmdParams, int count)
        {
            GetAuctionDBData msgData = new GetAuctionDBData();

            try
            {
                string cmdData = new UTF8Encoding().GetString(cmdParams, 0, count);
                int    type    = Convert.ToInt32(cmdData);
                List <GoldAuctionDBItem> tempList;
                if (3 <= type || 0 >= type)
                {
                    msgData.Flag = false;
                    LjlLog.WriteLog(LogTypes.Error, string.Format("GetGlodAuction 金团类型错误{0} type=", type), "");
                }
                else if (this.AuctionDict.TryGetValue(type, out tempList))
                {
                    msgData.Flag = CopyData.CopyAuctionDBItem(tempList, ref msgData.ItemList);
                }
                else
                {
                    msgData.Flag = GoldAuctionDB.Select(out msgData.ItemList, type);
                    if (msgData.Flag)
                    {
                        tempList = new List <GoldAuctionDBItem>();
                        if (CopyData.CopyAuctionDBItem(msgData.ItemList, ref tempList))
                        {
                            this.AuctionDict.Add(type, tempList);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LjlLog.WriteLog(LogTypes.Exception, ex.ToString(), "");
            }
            client.sendCmd <GetAuctionDBData>(nID, msgData);
        }
Ejemplo n.º 8
0
        public static bool DelData(string Sql)
        {
            int ret = -1;

            try
            {
                using (MyDbConnection3 conn = new MyDbConnection3(false))
                {
                    ret = conn.ExecuteNonQuery(string.Format("delete from t_gold_auction where {0}", Sql), 0);
                    LjlLog.WriteLogFormat(LogTypes.Info, new string[]
                    {
                        "DelData ",
                        (ret > -1).ToString(),
                        " ,delete from t_gold_auction where ",
                        Sql
                    });
                }
            }
            catch (Exception ex)
            {
                LjlLog.WriteLog(LogTypes.Exception, ex.ToString(), "");
            }
            return(ret > -1);
        }
Ejemplo n.º 9
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);
        }