private bool DB_CreateMail(CSCommon.Data.MailData mail) { string condition = "MailId = " + mail.MailId; ServerFrame.DB.DBOperator dbOp = ServerFrame.DB.DBConnect.InsertData(condition, mail, true); return(mDBConnect._ExecuteInsert(dbOp)); }
private void button3_Click(object sender, EventArgs e) { CSCommon.Data.MailData mail = new CSCommon.Data.MailData(); mail.CreateTime = System.DateTime.Now; mail.EndTime = mail.CreateTime.AddDays(mSendInfo.ShelfLife); mail.Type = "1"; mail.Title = "1"; mail.ContentStr = "1"; mail.StrItems = "111"; mail.StrCurrencies = "111"; mail.Deleted = 0; int count = Convert.ToInt32(this.textBox5.Text); var start = System.DateTime.Now; for (int i = 0; i < count; i++) { mail.MailId = ServerFrame.Util.GenerateObjID(ServerFrame.GameObjectType.Email); mail.OwnerId = (ulong)i; DataRow row = mDataSet.Tables["MailData"].NewRow(); ServerFrame.DB.DBConnect.FillDataRow(row, mail); //mDataSet.Tables["MailData"].ImportRow(row); mDataSet.Tables["MailData"].Rows.Add(row); // var dbOp = ServerFrame.DB.DBConnect.InsertData("", mail, true); // ToolThread.Instance.DBConnect._ExecuteInsert(dbOp); } var end = System.DateTime.Now; var time = (end - start).TotalSeconds; this.textBox2.Text = Convert.ToString(time) + "秒" + mDataSet.Tables["MailData"].Rows.Count.ToString(); }
public void RPC_OneKeyGetItems(RPC.RPCForwardInfo fwd) { RPC.PackageWriter pkg = new RPC.PackageWriter(); H_RPCRoot.smInstance.HGet_ComServer(pkg).HGet_UserRoleManager(pkg).RPC_OneKeyGetItems(pkg, PlayerData.RoleDetail.RoleId); pkg.WaitDoCommand(IPlanesServer.Instance.ComConnect, RPC.CommandTargetType.DefaultType, null).OnFarCallFinished = delegate(RPC.PackageProxy _io, bool isTimeOut) { if (isTimeOut) { return; } RPC.PackageWriter retPkg = new RPC.PackageWriter(); List <CSCommon.Data.MailData> mails = new List <CSCommon.Data.MailData>(); int count = 0; _io.Read(out count); for (int i = 0; i < count; i++) { CSCommon.Data.MailData mail = new CSCommon.Data.MailData(); _io.Read(mail); if (_GetMailItems(mail.StrItems) == false) { retPkg.Write((sbyte)-1); //背包空间不足 retPkg.DoReturnPlanes2Client(fwd); return; } _GetMailCurrencies(mail.StrCurrencies); //删除邮件 RPC.PackageWriter delpkg = new RPC.PackageWriter(); H_RPCRoot.smInstance.HGet_ComServer(delpkg).HGet_UserRoleManager(delpkg).RPC_DelMail(delpkg, mail.MailId); delpkg.DoCommand(IPlanesServer.Instance.ComConnect, RPC.CommandTargetType.DefaultType); } retPkg.Write((sbyte)1); retPkg.DoReturnPlanes2Client(fwd); }; }
public void RPC_GetMails(RPC.RPCForwardInfo fwd) { RPC.PackageWriter pkg = new RPC.PackageWriter(); H_RPCRoot.smInstance.HGet_ComServer(pkg).HGet_UserRoleManager(pkg).RPC_GetMails(pkg, PlayerData.RoleDetail.RoleId); pkg.WaitDoCommand(IPlanesServer.Instance.ComConnect, RPC.CommandTargetType.DefaultType, null).OnFarCallFinished = delegate(RPC.PackageProxy _io, bool isTimeOut) { if (isTimeOut) { return; } RPC.PackageWriter retPkg = new RPC.PackageWriter(); retPkg.SetSinglePkg(); List <CSCommon.Data.MailData> mails = new List <CSCommon.Data.MailData>(); int count = 0; _io.Read(out count); retPkg.Write(count); for (int i = 0; i < count; i++) { CSCommon.Data.MailData mail = new CSCommon.Data.MailData(); _io.Read(mail); retPkg.Write(mail); } retPkg.DoReturnPlanes2Client(fwd); }; }
private void DB_UpdateMail(CSCommon.Data.MailData mail) { string condition = "MailId = " + mail.MailId; ServerFrame.DB.DBOperator dbOp = ServerFrame.DB.DBConnect.ReplaceData(condition, mail, true); mDBConnect._ExecuteInsert(dbOp); return; }
public void RPC_GetMailItems(ulong mailId, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd) { RPC.PackageWriter pkg = new RPC.PackageWriter(); CSCommon.Data.MailData mail = DB_GetMail(mailId); if (mail == null) { pkg.Write((sbyte)-1); pkg.DoReturnCommand2(connect, fwd.ReturnSerialId); return; } pkg.Write((sbyte)1); pkg.Write(mail); pkg.DoReturnCommand2(connect, fwd.ReturnSerialId); }
public void RPC_OpenMail(ulong mailId, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd) { RPC.PackageWriter pkg = new RPC.PackageWriter(); CSCommon.Data.MailData mail = DB_GetMail(mailId); if (mail == null) { pkg.Write((sbyte)-1); pkg.DoReturnCommand2(connect, fwd.ReturnSerialId); return; } mail.State = (byte)CSCommon.eMailState.Opened; DB_UpdateMail(mail); pkg.Write((sbyte)1); pkg.DoReturnCommand2(connect, fwd.ReturnSerialId); }
private CSCommon.Data.MailData DB_GetMail(ulong mailId) { string condition = "MailId = " + mailId; ServerFrame.DB.DBOperator dbOp = ServerFrame.DB.DBConnect.SelectData(condition, new CSCommon.Data.MailData(), ""); System.Data.DataTable tab = mDBConnect._ExecuteSelect(dbOp, "MailData"); if (tab == null || tab.Rows.Count != 1) { return(null); } CSCommon.Data.MailData mail = new CSCommon.Data.MailData(); if (false == ServerFrame.DB.DBConnect.FillObject(mail, tab.Rows[0])) { return(null); } return(mail); }
/// <summary> /// 生成邮件 /// </summary> /// <param name="targetId"></param> 主人Id /// <param name="type"></param> 邮件来源枚举,用于从模板表里查询邮件的标题、类型、内容等信息 /// <param name="arg"></param> 有些邮件内容携带参数 /// <param name="items"></param> 邮件附件物品 /// <param name="currencies"></param> 邮件附件货币 /// <returns></returns> public void CreateMailAndSend(ulong targetId, CSCommon.eMailFromType type, string arg = "", string items = "", string currencies = "") { CSCommon.Data.MailData mail = new CSCommon.Data.MailData(); mail.MailId = ServerFrame.Util.GenerateObjID(ServerFrame.GameObjectType.Email); mail.OwnerId = targetId; mail.StrItems = items; mail.StrCurrencies = currencies; var temp = CSTable.StaticDataManager.MailInfo[(int)type]; if (temp != null) { mail.Type = temp.Type; mail.Title = temp.Title; mail.ContentStr = string.Format(temp.Content, arg); } else { Log.Log.Mail.Print("MailInfo[(int){0}] is null", type.ToString()); } DB_CreateMail(mail); SendPlayerMail(targetId); }
public void RPC_GetMailItems(ulong mailId, RPC.RPCForwardInfo fwd) { RPC.PackageWriter pkg = new RPC.PackageWriter(); H_RPCRoot.smInstance.HGet_ComServer(pkg).HGet_UserRoleManager(pkg).RPC_GetMailItems(pkg, mailId); pkg.WaitDoCommand(IPlanesServer.Instance.ComConnect, RPC.CommandTargetType.DefaultType, null).OnFarCallFinished = delegate(RPC.PackageProxy _io, bool isTimeOut) { if (isTimeOut) { return; } RPC.PackageWriter retPkg = new RPC.PackageWriter(); sbyte result; _io.Read(out result); if (result == 1) { CSCommon.Data.MailData mail = new CSCommon.Data.MailData(); _io.Read(mail); if (_GetMailItems(mail.StrItems) == false) { pkg.Write((sbyte)-2); //背包空间不足 pkg.DoReturnPlanes2Client(fwd); return; } _GetMailCurrencies(mail.StrCurrencies); retPkg.Write((sbyte)1); //删除邮件 RPC.PackageWriter delpkg = new RPC.PackageWriter(); H_RPCRoot.smInstance.HGet_ComServer(delpkg).HGet_UserRoleManager(delpkg).RPC_DelMail(delpkg, mailId); delpkg.DoCommand(IPlanesServer.Instance.ComConnect, RPC.CommandTargetType.DefaultType); } else { retPkg.Write((sbyte)-1); } retPkg.DoReturnPlanes2Client(fwd); }; }
private List <CSCommon.Data.MailData> DB_GetMails(string condition) { List <CSCommon.Data.MailData> mails = new List <CSCommon.Data.MailData>(); ServerFrame.DB.DBOperator dbOp = ServerFrame.DB.DBConnect.SelectData(condition, new CSCommon.Data.MailData(), ""); System.Data.DataTable tab = mDBConnect._ExecuteSelect(dbOp, "MailData"); if (tab != null) { foreach (System.Data.DataRow r in tab.Rows) { CSCommon.Data.MailData mail = new CSCommon.Data.MailData(); if (false == ServerFrame.DB.DBConnect.FillObject(mail, r)) { continue; } mails.Add(mail); } } else { Log.Log.Mail.Print("RPC_GetRoleMails failed :{0}", condition); } return(mails); }
// 生成代码 private void button4_Click(object sender, EventArgs e) { bool bIsClient = this.textBox_Callee.Text == Config.Instance.CurProjectConfig.ClientCallee; if (System.IO.File.Exists(this.textBox_Callee.Text)) { System.IO.StreamWriter sw = new System.IO.StreamWriter(this.textBox_Callee.Text); if (sw != null) { if (bIsClient) { sw.Write(this.textBoxCallee.Text.Replace("SlimDX", "UnityEngine")); } else { sw.Write(this.textBoxCallee.Text); } sw.Close(); } } if (System.IO.File.Exists(this.textBox_Caller.Text)) { System.IO.StreamWriter sw = new System.IO.StreamWriter(this.textBox_Caller.Text); if (sw != null) { if (bIsClient) { sw.Write(this.textBoxCaller.Text.Replace("SlimDX", "UnityEngine")); } else { sw.Write(this.textBoxCaller.Text); } sw.Close(); } } if (bIsClient) { if (System.IO.File.Exists(Config.Instance.CurProjectConfig.ServCppCaller)) { System.IO.StreamWriter sw = new System.IO.StreamWriter(Config.Instance.CurProjectConfig.ServCppCaller); if (sw != null) { sw.Write(this.textBoxCaller.Text.Replace("UnityEngine", "SlimDX")); sw.Close(); } } } else { if (System.IO.File.Exists(Config.Instance.CurProjectConfig.ClientServCaller)) { System.IO.StreamWriter sw = new System.IO.StreamWriter(Config.Instance.CurProjectConfig.ClientServCaller); if (sw != null) { sw.Write(ServCallerToClient.Replace("SlimDX", "UnityEngine")); sw.Close(); } } } //====================== 客户端同步服务器的类结构 ====================== string outStruct = ""; //GetCppStructureDefine只发送基础属性 byte[] x = new byte[3], list<int> y = new list<int>();类似属性都将不发送 outStruct += new CSCommon.Data.RoleInfo().GetCppStructureDefine(); outStruct += new CSCommon.Data.NPCData().GetCppStructureDefine(); outStruct += new CSCommon.Data.RoleDetail().GetCppStructureDefine(); outStruct += new CSCommon.Data.RoleSyncInfo().GetCppStructureDefine(); outStruct += new CSCommon.Data.ItemData().GetCppStructureDefine(); outStruct += new CSCommon.Data.SocialData().GetCppStructureDefine(); outStruct += new CSCommon.Data.SocialRoleInfo().GetCppStructureDefine(); outStruct += new CSCommon.Data.GiftData().GetCppStructureDefine(); outStruct += new CSCommon.Data.TaskData().GetCppStructureDefine(); outStruct += new CSCommon.Data.MailData().GetCppStructureDefine(); outStruct += new CSCommon.Data.GuildCom().GetCppStructureDefine(); outStruct += new CSCommon.Data.RoleCom().GetCppStructureDefine(); outStruct += new CSCommon.Data.Message().GetCppStructureDefine(); outStruct += new CSCommon.Data.SkillData().GetCppStructureDefine(); outStruct += new CSCommon.Data.MartialData().GetCppStructureDefine(); outStruct += new CSCommon.Data.AchieveData().GetCppStructureDefine(); outStruct += new CSCommon.Data.AttrStruct().GetCppStructureDefine(); outStruct += new CSCommon.Data.CityForceData().GetCppStructureDefine(); outStruct += new CSCommon.Data.EfficiencyData().GetCppStructureDefine(); outStruct += new CSCommon.Data.CampForceData().GetCppStructureDefine(); //=================================================================== if (System.IO.File.Exists(Config.Instance.CurProjectConfig.ClientHeader)) { System.IO.StreamWriter sw = new System.IO.StreamWriter(Config.Instance.CurProjectConfig.ClientHeader); if (sw != null) { sw.Write(outStruct); sw.Close(); } } }