/// <summary> /// 发邮件 /// </summary> void SendMailForGiftCode(List <GoodsData> GoodList, GiftCodeAwardData ItemData) { if (null == GoodList || null == ItemData) { return; } string Content = Global.GetLang("礼包码邮件"); string sSubject = string.Format(Global.GetLang("您的礼包码{0}使用成功。"), ItemData.CodeNo); bool bSuccess = Global.UseMailGivePlayerAward3(ItemData.RoleID, GoodList, Content, sSubject, 0); if (bSuccess) { GameClient client = GameManager.ClientMgr.FindClient(ItemData.RoleID); if (null != client) { GameManager.ClientMgr.SendSystemChatMessageToClient(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, Global.GetLang("您有新的邮件,请查收!")); } AddLogEvent(ItemData, (int)GiftCodeResultType.Success); } else { AddLogEvent(ItemData, (int)GiftCodeResultType.Fail); } }
public void ProcessGiftCodeList(string strcmd) { if (null != strcmd) { if (!GiftCodeNewManager.IsFuncOpen()) { LogManager.WriteLog(LogTypes.Info, string.Format("[GiftCodeNew]礼包码功能未开放,礼包码信息={0}", strcmd), null, true); } else { try { string[] fields = strcmd.Split(new char[] { '#' }); if (fields.Length > 0) { GiftCodeAwardData data = new GiftCodeAwardData(); for (int i = 0; i < fields.Length; i++) { string[] GiftData = fields[i].Split(new char[] { ',' }); if (GiftData.Length != 4) { LogManager.WriteLog(LogTypes.Error, string.Format("[GiftCodeNew]ProcessGiftCodeList[{0}]参数错误。", fields[i]), null, true); } else { data.reset(); data.UserId = GiftData[0]; data.RoleID = Convert.ToInt32(GiftData[1]); data.GiftId = GiftData[2]; data.CodeNo = GiftData[3]; if (data.RoleID <= 0) { LogManager.WriteLog(LogTypes.Error, string.Format("[GiftCodeNew]ProcessGiftCodeList[{0}]角色id错误。", data.RoleID), null, true); } else { this.SendAward(null, data); } } } } } catch (Exception ex) { DataHelper.WriteFormatExceptionLog(ex, "[GiftCodeNew]ProcessGiftCodeList error", false, false); } } } }
private void AddLogEvent(GiftCodeAwardData ItemData, int result) { if (null != ItemData) { EventLogManager.SystemRoleEvents[80].AddImporEvent(new object[] { GameManager.ServerId, ItemData.UserId, CacheManager.GetZoneIdByRoleId((long)ItemData.RoleID, GameManager.ServerId), ItemData.RoleID, ItemData.GiftId, ItemData.CodeNo, result }); } }
/// <summary> /// 网络处理 /// </summary> public void ProcessGiftCodeList(string strcmd) { if (null == strcmd) { return; } if (!IsFuncOpen()) { LogManager.WriteLog(LogTypes.Info, string.Format("[GiftCodeNew]礼包码功能未开放,礼包码信息={0}", strcmd)); return; } try { string[] fields = strcmd.Split('#'); if (fields.Length <= 0) { return; } GiftCodeAwardData data = new GiftCodeAwardData(); for (int i = 0; i < fields.Length; ++i) { string[] GiftData = fields[i].Split(','); //userid:rid:giftid:codeno if (GiftData.Length != 4) { LogManager.WriteLog(LogTypes.Error, string.Format("[GiftCodeNew]ProcessGiftCodeList[{0}]参数错误。", fields[i])); continue; } data.reset(); data.UserId = GiftData[0]; data.RoleID = Convert.ToInt32(GiftData[1]); data.GiftId = GiftData[2]; data.CodeNo = GiftData[3]; if (data.RoleID <= 0) { LogManager.WriteLog(LogTypes.Error, string.Format("[GiftCodeNew]ProcessGiftCodeList[{0}]角色id错误。", data.RoleID)); continue; } SendAward(data); } } catch (Exception ex) { DataHelper.WriteFormatExceptionLog(ex, "[GiftCodeNew]ProcessGiftCodeList error", false); } }
/// <summary> /// 记录log /// </summary> void AddLogEvent(GiftCodeAwardData ItemData, int result) { if (null == ItemData) { return; } EventLogManager.SystemRoleEvents[(int)RoleEvent.NewGiftCode].AddImporEvent( GameManager.ServerId, ItemData.UserId, CacheManager.GetZoneIdByRoleId(ItemData.RoleID, GameManager.ServerId), ItemData.RoleID, ItemData.GiftId, ItemData.CodeNo, result ); }
private void SendAward(GameClient client, GiftCodeAwardData ItemData) { if (null != ItemData) { try { GiftCodeInfo gift = this.GetGiftCodeInfo(ItemData.GiftId); if (null == gift) { this.AddLogEvent(ItemData, -2); } else if (null != gift.GoodsList) { int index = 0; List <GoodsData> lTmp = new List <GoodsData>(); foreach (GoodsData item in gift.GoodsList) { index++; lTmp.Add(item); if (index % 5 == 0) { this.SendMailForGiftCode(lTmp, ItemData, gift.GiftCodeName, gift.Description); lTmp.Clear(); } } if (lTmp.Count > 0) { this.SendMailForGiftCode(lTmp, ItemData, gift.GiftCodeName, gift.Description); lTmp.Clear(); } if (null != client) { client.ClientData.AddAwardRecord(RoleAwardMsg.LiPinDuiHuan, gift.GoodsList, false); GameManager.ClientMgr.NotifyGetAwardMsg(client, RoleAwardMsg.LiPinDuiHuan, ""); } } } catch (Exception ex) { this.AddLogEvent(ItemData, -4); DataHelper.WriteFormatExceptionLog(ex, "[GiftCodeNew]SendAward error", false, false); } } }
/// <summary> /// 发送奖励 /// </summary> void SendAward(GiftCodeAwardData ItemData) { if (null == ItemData) { return; } try { GiftCodeInfo gift = GetGiftCodeInfo(ItemData.GiftId); if (null == gift) { AddLogEvent(ItemData, (int)GiftCodeResultType.EAware); return; } if (null != gift.GoodsList) { int index = 0; List <GoodsData> lTmp = new List <GoodsData>(); foreach (var item in gift.GoodsList) { index++; lTmp.Add(item); if (index % 5 == 0) { SendMailForGiftCode(lTmp, ItemData); lTmp.Clear(); } } if (lTmp.Count > 0) { SendMailForGiftCode(lTmp, ItemData); lTmp.Clear(); } } } catch (Exception ex) { AddLogEvent(ItemData, (int)GiftCodeResultType.Exception); DataHelper.WriteFormatExceptionLog(ex, "[GiftCodeNew]SendAward error", false); } }
private void SendMailForGiftCode(List <GoodsData> GoodList, GiftCodeAwardData ItemData, string subject, string content) { if (GoodList != null && null != ItemData) { subject = (string.IsNullOrEmpty(subject) ? GLang.GetLang(121, new object[0]) : subject); content = (string.IsNullOrEmpty(content) ? GLang.GetLang(122, new object[0]) : content); content = string.Format(content, ItemData.GiftId, ItemData.CodeNo); bool bSuccess = Global.UseMailGivePlayerAward3(ItemData.RoleID, GoodList, subject, content, 0, 0, 0); if (bSuccess) { GameClient client = GameManager.ClientMgr.FindClient(ItemData.RoleID); if (null != client) { GameManager.ClientMgr.SendSystemChatMessageToClient(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, GLang.GetLang(123, new object[0])); } this.AddLogEvent(ItemData, 1); } else { this.AddLogEvent(ItemData, -3); } } }