private ErrorCode DBAsynQueryGameMailList(DBActiveWrapper db, long objIdx) { string sqlStr = "select * from game_mail where mail_del_state<> " + MailCurtState.Del; if (objIdx > 0) { sqlStr += " and mail_user_id = " + objIdx; } else { sqlStr += " and (mail_user_id is NULL or mail_user_id < 1) "; } sqlStr += " and unix_timestamp(mail_over_time ) > unix_timestamp(NOW()) order by mail_id DESC;"; ErrorCode errorCode = db.SqlExecQuery(sqlStr, dataReader => { while (dataReader.Read()) { MailDBData mailDb = new MailDBData { mailId = dataReader.GetInt32("mail_id"), mailType = ( MailType )dataReader.GetInt32("mail_type"), channelId = dataReader.GetInt32("mail_sdk"), mailTitle = dataReader.GetString("mail_title"), mailContent = dataReader.GetString("mail_content"), mailGift = dataReader.GetString("mail_gift"), szSender = dataReader.GetString("mail_send"), mCreateTime = dataReader.GetString("mail_create_time"), mEndTime = dataReader.GetString("mail_over_time") }; mailDb.objIdx = objIdx > 0 ? objIdx : mailDb.objIdx; DBToCS.MailCallBack pMsg = new DBToCS.MailCallBack { Mailid = mailDb.mailId, Mailtype = ( int )mailDb.mailType, Channel = mailDb.channelId, Title = mailDb.mailTitle, Content = mailDb.mailContent, Gift = mailDb.mailGift, Sender = mailDb.szSender, Createtime = mailDb.mCreateTime, Objid = mailDb.objIdx }; CS.instance.userMgr.EncodeAndSendToLogicThread(pMsg, ( int )DBToCS.MsgID.EMailCallBack); } return(ErrorCode.Success); }); return(errorCode); }
private void SynHandleMailCallback(GBuffer buffer) { DBToCS.MailCallBack pMsg = new DBToCS.MailCallBack(); pMsg.MergeFrom(buffer.GetBuffer(), 0, ( int )buffer.length); MailDBData mailDb = new MailDBData(); mailDb.mailId = pMsg.Mailid; mailDb.mailType = ( MailType )pMsg.Mailtype; mailDb.channelId = pMsg.Channel; mailDb.mailContent = pMsg.Content; mailDb.mailTitle = pMsg.Title; mailDb.mailGift = pMsg.Gift; mailDb.szSender = pMsg.Sender; mailDb.mCreateTime = pMsg.Createtime; //todo //mailDb.n64CreateTime = CFunction::FormatTime2TimeT( mailDb.mCreateTime ); //mailDb.n64EndTime = CFunction::FormatTime2TimeT( mailDb.mEndTime ); mailDb.objIdx = pMsg.Objid; CS.instance.mailMgr.AddGameMail(mailDb); }