/// <summary> 组装邮件实体并推送 </summary> /// <param name="userid">接收用户Id</param> /// <param name="title">邮件的title</param> /// <param name="contents">邮件的contents</param> /// <param name="attachment">附件 无附件填""</param> public void BuildMessagesSend(Int64 userid, string title, string contents, string attachment) { var type = (attachment != String.Empty) ? (int)MessageIsAnnexType.HAVE_ANNEX : (int)MessageIsAnnexType.UN_ANNEX; var model = new tg_messages { send_id = 0, title = title, isattachment = type, receive_id = userid, contents = contents, attachment = attachment, type = (int)MessageType.SYSTEM_MAIL, isread = (int)MessageIsReadType.UN_READ, create_time = (DateTime.Now.Ticks - 621355968000000000) / 10000, }; model.Insert(); try { //var temp = string.Format("{0}_{1}_{2}_{3}", "插入邮件:" + model.id, "标题:" + model.title, "附件为:" + model.attachment, "是否有附件状态:" + (model.isattachment == (int)MessageIsAnnexType.HAVE_ANNEX)); //(new Log()).WriteLog(userid, (int)LogType.Insert, (int)ModuleNumber.MESSAGES, (int)MessageCommand.MESSAGE_PUSH, "邮件", "推送邮件", "邮件", 0, 0, 0, temp); } catch (Exception ex) { XTrace.WriteException(ex); } UnMessage(userid); }
/// <summary>Email 实体转换</summary> public static Email ToEmail(tg_messages model) { return(new Email() { id = model.id, title = model.title, content = model.contents, createtime = model.create_time, }); }
/* * /// <summary> * /// 发送系统邮件 * /// </summary> * /// <param name="token">令牌</param> * /// <param name="sn">启服服务器名称</param> * /// <param name="data">邮件实体</param> * /// <returns></returns> * public ResultMessage Email(string token, string sn, [FromBody]string data) * { * var rm = new ResultMessage(); * //设置连接字符串 * tg_messages.SetDbConnName(DBConnect.GameConnect(token, sn)); * var entity = tg_messages.FromJson(data); * if (entity == null) * { * rm.message = "参数为空"; * return rm; * } * if (entity.title == "") * { * rm.message = "邮件标题为空"; return rm; * } * if (entity.contents == "") * { * rm.message = "邮件内容为空"; return rm; * } * entity.Save(); * rm.result = 1; * rm.data = entity.ToJson(); * return rm; * } */ /* * /// <summary> * /// 发送系统公告 * /// </summary> * /// <param name="token">令牌</param> * /// <param name="sn">启服服务器名称</param> * /// <param name="start">开始时间</param> * /// <param name="end">结束时间</param> * /// <param name="space">时间间隔</param> * /// <param name="content">内容</param> * /// <returns></returns> * public ResultMessage Notice(string token, string sn, Int64 start, Int64 end, int space, string content) * { * var rm = new ResultMessage(); * * var now = DateTime.Now.Ticks; * if (space <= 0 || end < now || start <= 0) * { * rm.message = "时间设置有误"; * return rm; * } * if (content == "") * { * rm.message = "公告内容为空"; return rm; * } * //设置连接字符串 * tg_system_notice.SetDbConnName(DBConnect.GameConnect(token, sn)); * var entity = new tg_system_notice() { content = content, }; //时间格式不统一,暂不处理 * entity.Save(); * return rm; * } */ /// <summary>发送系统邮件</summary> /// <param name="token">令牌</param> /// <param name="sn">启服服务器名称</param> /// <param name="title">邮件标题</param> /// /// <param name="content">邮件内容</param> public Email PostEmail(string token, string sn, string title, string content) { if (!IsToken(token)) { return new Email { result = -1, message = "令牌不存在" } } ; //验证会话 SN = sn; //设置连接字符串 tg_messages.SetDbConnName(db_connection); if (string.IsNullOrEmpty(title)) { return(new Email() { result = -1, message = "邮件标题为空" }); } if (string.IsNullOrEmpty(content)) { return(new Email() { result = -1, message = "邮件内容为空" }); } var entity = new tg_messages() { attachment = "", create_time = DateTime.Now.Ticks, type = 1, isread = 0, title = title, contents = content, isattachment = 0, }; entity.Save(); var email = ToEntity.ToEmail(entity); email.result = 1; return(email); }
/// <summary> 组装邮件实体并推送 </summary> /// <param name="userid">接收用户Id</param> /// <param name="title">邮件的title</param> /// <param name="contents">邮件的contents</param> /// <param name="attachment">附件 无附件填""</param> public tg_messages BuildMessagesSend(Int64 userid, string title, string contents, string attachment) { var type = (attachment != String.Empty) ? 1 : 0; var model = new tg_messages { send_id = 0, title = title, isattachment = type,//type 0:无附件 1:有 receive_id = userid, contents = contents, attachment = attachment, type = 1, //0:玩家 1:系统 isread = 0, create_time = (DateTime.Now.Ticks - 621355968000000000) / 10000, }; return(model); }
private ASObject GetEmail(TGGSession session, int isatt) { var entity = new tg_messages { receive_id = session.Player.User.id, send_id = 0, type = 1, title = "测试邮件", isattachment = isatt, attachment = "6_4010005_0_99|7_6010001_0_1", contents = "测试邮件内容", create_time = (DateTime.Now.Ticks - 621355968000000000) / 10000, }; entity.Save(); (new Share.Message()).UnMessage(session.Player.User.id); return(BuildData((int)ResultType.SUCCESS)); }
/// <summary>发送邮件 </summary> public void GetEmail(Int64 userid, tg_activity_building tab) { var entity = new tg_messages { receive_id = userid, send_id = 0, type = 1, title = "一夜墨俣活动团队奖励", isattachment = 1, attachment = GetTeamReward(tab), contents = string.Format("尊敬的玩家:您今日参加了一夜墨俣活动,获得奖励如下:" + "您活动获得声望为{0},团队声望为{1},团队金钱奖励为{2}贯。" + "活动的团队奖励在附件中,请提取附件领取奖励。", tab.fame, tab.team_fame, tab.team_money / 1000), create_time = (DateTime.Now.Ticks - 621355968000000000) / 10000, }; entity.Save(); (new Share.Message()).UnMessage(userid); }