Example #1
0
 public static void CopyAuctionDB2Item(GoldAuctionDBItem sData, out GoldAuctionItem rData)
 {
     try
     {
         rData = new GoldAuctionItem();
         rData.ProductionTime = sData.ProductionTime;
         rData.AuctionTime    = sData.AuctionTime;
         rData.AuctionSource  = sData.AuctionSource;
         rData.StrGoods       = sData.StrGoods;
         rData.BuyerData      = new AuctionRoleData();
         CopyData.Copy <AuctionRoleData>(sData.BuyerData, ref rData.BuyerData);
         foreach (AuctionRoleData item in sData.RoleList)
         {
             AuctionRoleData temp = new AuctionRoleData();
             CopyData.Copy <AuctionRoleData>(item, ref temp);
             rData.RoleList.Add(temp);
         }
         rData.BossLife       = sData.BossLife;
         rData.KillBossRoleID = sData.KillBossRoleID;
         rData.UpDBWay        = sData.UpDBWay;
         rData.AuctionType    = sData.AuctionType;
         rData.OldAuctionType = sData.OldAuctionType;
         rData.Lock           = false;
     }
     catch (Exception ex)
     {
         rData = null;
         LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true);
     }
 }
Example #2
0
 public bool SendUpdate2DB(GoldAuctionItem AuctionItem)
 {
     try
     {
         lock (this.AuctionMutex)
         {
             if (AuctionItem == null)
             {
                 return(false);
             }
             GoldAuctionDBItem dbinfo;
             CopyData.CopyAuctionItem2DB(AuctionItem, out dbinfo);
             string msg = Global.Send2DB <GoldAuctionDBItem>(2081, dbinfo, 0);
             if ("True".Equals(msg))
             {
                 LogManager.WriteLog(LogTypes.Info, string.Format("[ljl]AuctionItem SendUpdate2DB true up type = {0},ProductionTime={1}, AuctionSource={2}", (DBAuctionUpEnum)dbinfo.UpDBWay, dbinfo.ProductionTime, dbinfo.AuctionSource), null, true);
                 return(true);
             }
             LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]AuctionItem SendUpdate2DB false up type = {0},ProductionTime={1}, AuctionSource={2}", (DBAuctionUpEnum)dbinfo.UpDBWay, dbinfo.ProductionTime, dbinfo.AuctionSource), null, true);
         }
     }
     catch (Exception ex)
     {
         LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true);
     }
     return(false);
 }
Example #3
0
        public bool UpdatePrice(GoldAuctionItem _item)
        {
            bool flag = false;

            try
            {
                lock (this.AuctionMutex)
                {
                    GoldAuctionItem item = this.getGoldAuctionItem(_item.ProductionTime, _item.AuctionSource);
                    if (item == null || item.AuctionType != _item.AuctionType)
                    {
                        return(flag);
                    }
                    CopyData.Copy <AuctionRoleData>(_item.BuyerData, ref item.BuyerData);
                    item.Lock           = false;
                    item.UpDBWay        = 3;
                    item.OldAuctionType = item.AuctionType;
                    flag = this.SendUpdate2DB(item);
                    if (flag)
                    {
                        this.S2CCache.Clear();
                    }
                }
            }
            catch (Exception ex)
            {
                LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true);
            }
            return(flag);
        }
Example #4
0
 private void InitFromDB()
 {
     try
     {
         for (int i = 1; i < 3; i++)
         {
             LogManager.WriteLog(LogTypes.Info, string.Format("[ljl]InitFromDB AuctionID={0}", i), null, true);
             GetAuctionDBData DBData = Global.sendToDB <GetAuctionDBData, string>(2080, i.ToString(), 0);
             if (DBData == null || !DBData.Flag)
             {
                 LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]GoldAuctionManager.InitFromDB DBData={0}, type={1}", null == DBData, i), null, true);
             }
             else
             {
                 foreach (GoldAuctionDBItem item in DBData.ItemList)
                 {
                     GoldAuctionItem temp = new GoldAuctionItem();
                     CopyData.CopyAuctionDB2Item(item, out temp);
                     AuctionConfig AuctionCfg = GoldAuctionConfigModel.GetAuctionConfig(item.AuctionSource);
                     if (null == AuctionCfg)
                     {
                         LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]GetAuctionConfig null == config AuctionSource ={0}", ((AuctionEnum)item.AuctionSource).ToString()), null, true);
                     }
                     else
                     {
                         temp.LifeTime = AuctionCfg.GetTimeByAuction(i);
                         if (temp.LifeTime == -1)
                         {
                             LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]GetTimeByAuction =-1 AuctionOrderEnum={0}", i), null, true);
                         }
                         else
                         {
                             this.AddNewAuctionItem(temp);
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true);
     }
 }
Example #5
0
 public static void CopyGoldAuctionItem(GoldAuctionItem sData, ref GoldAuctionItem rData)
 {
     try
     {
         rData = new GoldAuctionItem();
         CopyData.Copy <GoldAuctionItem>(sData, ref rData);
         rData.RoleList = new List <AuctionRoleData>();
         foreach (AuctionRoleData item in sData.RoleList)
         {
             AuctionRoleData temp = new AuctionRoleData();
             CopyData.Copy <AuctionRoleData>(item, ref temp);
             rData.RoleList.Add(temp);
         }
     }
     catch (Exception ex)
     {
         rData = null;
         LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true);
     }
 }
Example #6
0
 public static bool Copy2AuctionItemS2C(AuctionItemS2C sData, out AuctionItemS2C rData, GoldAuctionItem AuctionItem)
 {
     rData = new AuctionItemS2C();
     try
     {
         CopyData.Copy <AuctionItemS2C>(sData, ref rData);
         rData.Goods = new GoodsData();
         if (null != AuctionItem)
         {
             rData.LastTime = TimeUtil.GetDiffTimeSeconds(DateTime.Parse(AuctionItem.AuctionTime).AddHours((double)AuctionItem.LifeTime), TimeUtil.NowDateTime(), false);
         }
         CopyData.Copy <GoodsData>(sData.Goods, ref rData.Goods);
         return(true);
     }
     catch (Exception ex)
     {
         LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true);
     }
     return(false);
 }
Example #7
0
        public GoldAuctionItem GetGoldAuctionItem(int type, string ProductionTime, int AuctionSource, bool isLock)
        {
            GoldAuctionItem temp = null;

            try
            {
                lock (this.AuctionMutex)
                {
                    GoldAuctionItem item = this.getGoldAuctionItem(ProductionTime, AuctionSource);
                    if (item == null || item.AuctionType != type)
                    {
                        return(null);
                    }
                    item.Lock = isLock;
                    CopyData.CopyGoldAuctionItem(item, ref temp);
                }
            }
            catch (Exception ex)
            {
                LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true);
            }
            return(temp);
        }
 public void KillBossAddAuction(int KillBossRole, long BossLife, List <AuctionRoleData> PointInfoList, AuctionEnum AuctionSource)
 {
     try
     {
         lock (this.AuctionMsgMutex)
         {
             AuctionAwardConfig AuctionAwardCfg = GoldAuctionConfigModel.RandAuctionAwardConfig();
             if (null == AuctionAwardCfg)
             {
                 LogManager.WriteLog(LogTypes.Error, "[ljl]KillBossAddAuction RandAuctionAwardConfig null == config", null, true);
             }
             else
             {
                 AuctionConfig AuctionCfg = GoldAuctionConfigModel.GetAuctionConfig((int)AuctionSource);
                 if (null == AuctionCfg)
                 {
                     LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]GoldAuctionConfigModel.GetAuctionConfig({0}) null == config", AuctionSource), null, true);
                 }
                 else
                 {
                     GoldAuctionItem item = new GoldAuctionItem();
                     item.AuctionSource      = (int)AuctionSource;
                     item.KillBossRoleID     = KillBossRole;
                     item.UpDBWay            = 2;
                     item.ProductionTime     = TimeUtil.NowDataTimeString("yyyy-MM-dd HH:mm:ss.fff");
                     item.BuyerData          = new AuctionRoleData();
                     item.BuyerData.m_RoleID = 0;
                     item.BuyerData.Value    = (long)AuctionCfg.OriginPrice;
                     int index = Global.GetRandomNumber(AuctionAwardCfg.StartValues, AuctionAwardCfg.EndValues) - 1;
                     index         = Math.Min(index, AuctionAwardCfg.strGoodsList.Count - 1);
                     item.StrGoods = AuctionAwardCfg.strGoodsList[index];
                     if (null == GlobalNew.ParseGoodsData(AuctionAwardCfg.strGoodsList[index]))
                     {
                         LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]null == item.Goods index={0}  ,  GoodsList.Count = {1}", index, AuctionAwardCfg.strGoodsList.Count), null, true);
                     }
                     else
                     {
                         item.BossLife = 0L;
                         foreach (AuctionRoleData PointInfo in PointInfoList)
                         {
                             item.BossLife += PointInfo.Value;
                             if (PointInfo.Value >= GameManager.systemParamsList.GetParamValueIntByName("AngelTempleAuction", -1))
                             {
                                 AuctionRoleData RoleData = new AuctionRoleData();
                                 CopyData.Copy <AuctionRoleData>(PointInfo, ref RoleData);
                                 item.RoleList.Add(RoleData);
                             }
                         }
                         if (item.BossLife < 1L)
                         {
                             item.BossLife = BossLife;
                         }
                         bool addFlag = false;
                         for (int i = 0; i < AuctionCfg.OrderList.Count; i++)
                         {
                             if (GoldAuctionManager.IsOpenAuction((AuctionOrderEnum)AuctionCfg.OrderList[i]))
                             {
                                 item.AuctionType = AuctionCfg.OrderList[i];
                                 item.LifeTime    = AuctionCfg.TimeList[i];
                                 if (item.AuctionType > 0 && item.AuctionType < 3)
                                 {
                                     if (this.GoldAuctionMgr.SendUpdate2DB(item))
                                     {
                                         this.GoldAuctionMgr.AddNewAuctionItem(item);
                                     }
                                     else
                                     {
                                         LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]新拍卖物品存库失败 未加入 time={0},AuctionSource={1}", item.ProductionTime, AuctionSource), null, true);
                                     }
                                     addFlag = true;
                                     break;
                                 }
                                 LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]AuctionType ={1} err,AuctionSource={0}", AuctionSource, item.AuctionType), null, true);
                             }
                         }
                         if (!addFlag)
                         {
                             int roleID = item.GetMaxmDamageID();
                             this.GoldAuctionMgr.SendItem(roleID, item.RoleList.Find((AuctionRoleData x) => x.m_RoleID == roleID), item, AuctionCfg);
                             LogManager.WriteLog(LogTypes.Info, string.Format("[ljl]新拍卖物品未加入 直接邮件发送给玩家第一名 time={0},AuctionSource={1}", item.ProductionTime, AuctionSource), null, true);
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true);
     }
 }
        private void SetGlodAuction(GameClient client, int nID, byte[] bytes, string[] cmdParams, ref int Info)
        {
            GoldAuctionItem item = null;

            Info = 0;
            try
            {
                int      type    = Convert.ToInt32(cmdParams[1]);
                string[] itemKey = cmdParams[2].Split(new char[]
                {
                    '|'
                });
                int Price = Convert.ToInt32(cmdParams[3]);
                if (itemKey == null || itemKey.Length != 2)
                {
                    Info = 3;
                }
                else
                {
                    string ProductionTime = itemKey[0].Replace(',', ':');
                    int    AuctionSource  = Convert.ToInt32(itemKey[1]);
                    if (type == 1 && client.ClientData.Faction < 1)
                    {
                        Info = 1;
                    }
                    AuctionConfig AuctionCfg = GoldAuctionConfigModel.GetAuctionConfig(AuctionSource);
                    if (null == AuctionCfg)
                    {
                        LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]SetGlodAuction ({0}) null == config", AuctionSource), null, true);
                        Info = 4;
                    }
                    else
                    {
                        item = this.GoldAuctionMgr.GetGoldAuctionItem(type, ProductionTime, AuctionSource, true);
                        if (item == null || item.AuctionType != type)
                        {
                            Info = 9;
                        }
                        else if (client.ClientData.RoleID == item.BuyerData.m_RoleID)
                        {
                            Info = 11;
                        }
                        else if (item.BuyerData.m_RoleID == 0 && Price < AuctionCfg.OriginPrice)
                        {
                            Info = 5;
                        }
                        else if (Price < AuctionCfg.UnitPrice)
                        {
                            Info = 6;
                        }
                        else if ((long)Price <= item.BuyerData.Value)
                        {
                            Info = 10;
                        }
                        else if (!GameManager.ClientMgr.SubUserMoney(client, Price, "金团拍卖购买", false, false, false, false, DaiBiSySType.None))
                        {
                            Info = 7;
                        }
                        if (Info != 0)
                        {
                            this.GoldAuctionMgr.UnLock(item.ProductionTime, item.AuctionSource);
                        }
                        else
                        {
                            AuctionRoleData oldBuyerData = new AuctionRoleData();
                            CopyData.Copy <AuctionRoleData>(item.BuyerData, ref oldBuyerData);
                            bool upFlag   = false;
                            int  newBuyer = client.ClientData.RoleID;
                            item.BuyerData.Value      = (long)Price;
                            item.BuyerData.m_RoleID   = client.ClientData.RoleID;
                            item.BuyerData.m_RoleName = client.ClientData.RoleName;
                            item.BuyerData.ZoneID     = client.ClientData.ZoneID;
                            item.BuyerData.strUserID  = client.strUserID;
                            item.BuyerData.ServerId   = client.ServerId;
                            if (Price >= AuctionCfg.MaxPrice && AuctionCfg.MaxPrice > 0)
                            {
                                if (!this.GoldAuctionMgr.DisposeAward(item))
                                {
                                    Info = 8;
                                    LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]一口价 RoleId={0}, Price={1},itemKey={2} fail", newBuyer, Price, cmdParams[1]), null, true);
                                }
                                else
                                {
                                    this.GoldAuctionMgr.DelGoldAuction(item, "金团拍卖购买su");
                                    upFlag = true;
                                }
                            }
                            else if (!this.GoldAuctionMgr.UpdatePrice(item))
                            {
                                Info = 8;
                                LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]更新价格 RoleId={0}, Price={1},itemKey={2} fail", newBuyer, Price, cmdParams[1]), null, true);
                            }
                            else
                            {
                                upFlag = true;
                            }
                            if (upFlag)
                            {
                                this.GoldAuctionMgr.ReturnOldAuctionMoney(oldBuyerData, item.StrGoods);
                            }
                            else
                            {
                                this.GoldAuctionMgr.UnLock(item.ProductionTime, item.AuctionSource);
                                GameManager.logDBCmdMgr.AddMessageLog(-1, "钻石", "金团购买失败扣除钻石", client.ClientData.RoleName, client.ClientData.RoleName, "减少", Price, client.ClientData.ZoneID, client.strUserID, -1, client.ServerId, "");
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                if (null != item)
                {
                    this.GoldAuctionMgr.UnLock(item.ProductionTime, item.AuctionSource);
                }
                Info = 100;
                LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true);
            }
        }
Example #10
0
 public void GetGoldAuctionS2C(int Auctiontype, int ordeType, int sortNum, int startNum, int maxNum, string Seach, int Color, ref GoldAuctionS2C clientData)
 {
     try
     {
         lock (this.AuctionMutex)
         {
             string memKey = string.Format("{0}|{1}|{2}|{3}|{4}", new object[]
             {
                 Auctiontype,
                 ordeType,
                 sortNum,
                 Seach,
                 Color
             });
             int allNum = 0;
             List <AuctionItemS2C> dList = new List <AuctionItemS2C>();
             AuctionS2CCache       Cache;
             if (!this.S2CCache.TryGetValue(memKey, out Cache))
             {
                 Cache = new AuctionS2CCache();
                 foreach (GoldAuctionItem item in this.AuctionItemList)
                 {
                     if (item.AuctionType == Auctiontype)
                     {
                         allNum++;
                         AuctionItemS2C temp;
                         if (CopyData.Copy2AuctionItemS2C(item, out temp, Seach, Color))
                         {
                             dList.Add(temp);
                         }
                     }
                 }
                 dList.Sort(new GlodAuctionIComparer(ordeType, sortNum > 0));
                 Cache.MaxNum = allNum;
                 Cache.dList.AddRange(dList);
                 this.S2CCache.Add(memKey, Cache);
             }
             else
             {
                 allNum = Cache.MaxNum;
                 foreach (AuctionItemS2C item2 in Cache.dList)
                 {
                     string[] itemKey = item2.AuctionItemKey.Split(new char[]
                     {
                         '|'
                     });
                     GoldAuctionItem AuctionItem = this.getGoldAuctionItem(itemKey[0].Replace(',', ':'), Convert.ToInt32(itemKey[1]));
                     AuctionItemS2C  temp;
                     if (CopyData.Copy2AuctionItemS2C(item2, out temp, AuctionItem))
                     {
                         dList.Add(temp);
                     }
                 }
             }
             int len       = maxNum;
             int starIndex = (startNum - 1) * maxNum;
             clientData.CurrentPage = startNum;
             if (starIndex < 1 || starIndex >= dList.Count)
             {
                 clientData.CurrentPage = 1;
                 len = Math.Min(maxNum, dList.Count);
             }
             else if (starIndex + maxNum > dList.Count)
             {
                 len = dList.Count - starIndex;
             }
             clientData.TotalCount = allNum;
             clientData.ItemList.AddRange(dList.GetRange(starIndex, len));
         }
     }
     catch (Exception ex)
     {
         LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true);
     }
 }