///// <summary>
        ///// 阅读站内信
        ///// </summary>
        //public void ReadInnerMail(string innerMailId, string userId)
        //{
        //    using (var biz = new GameBiz.Business.GameBizBusinessManagement())
        //    {
        //        biz.BeginTran();
        //        using (var manager = new InnerMailManager())
        //        {
        //            var user = manager.LoadUser(userId);
        //            var mail = manager.GetInnerMailById(innerMailId);
        //            var record = manager.GetReadRecord(mail, user);
        //            if (record == null)
        //            {
        //                record = new InnerMailReadRecord
        //                {
        //                    Mail = mail,
        //                    Receiver = user,
        //                    HandleType = InnerMailHandleType.Readed,
        //                };
        //                manager.AddReadRecord(record);
        //            }
        //            else
        //            {
        //                record.HandleType = InnerMailHandleType.Readed;
        //                manager.UpdateReadRecord(record);
        //            }
        //        }
        //        biz.CommitTran();
        //    }
        //}

        /// <summary>
        /// 阅读站内信
        /// </summary>
        public void ReadInnerMail(string innerMailId, string userId)
        {
            using (var biz = new GameBiz.Business.GameBizBusinessManagement())
            {
                using (var manager = new InnerMailManager())
                {
                    var mail = manager.QuerySiteMessageInnerMailListNewByMailId(innerMailId);
                    if (mail != null)
                    {
                        mail.ReadTime   = DateTime.Now;
                        mail.HandleType = InnerMailHandleType.Readed;
                        manager.UpdateSiteMessageInnerMailListNew(mail);
                    }
                }
            }
        }
        //public InnerMailInfo_Query QueryInnerMailDetailById(string innerMailId)
        //{
        //    using (var manager = new InnerMailManager())
        //    {
        //        var mail = manager.GetInnerMailById(innerMailId);
        //        var info = new InnerMailInfo_Query
        //        {
        //            MailId = mail.MailId,
        //            Title = mail.Title,
        //            Content = mail.Content,
        //            SenderId = mail.Sender.UserId,
        //            SendTime = mail.SendTime,
        //            UpdateTime = mail.UpdateTime,
        //            ActionTime = mail.ActionTime,
        //        };
        //        return info;
        //    }
        //}

        public InnerMailInfo_Query QueryInnerMailDetailById(string innerMailId)
        {
            using (var manager = new InnerMailManager())
            {
                var mail = manager.QuerySiteMessageInnerMailListNewByMailId(innerMailId);
                var info = new InnerMailInfo_Query
                {
                    MailId   = mail.MailId,
                    Title    = mail.Title,
                    Content  = mail.MsgContent,
                    SenderId = mail.SenderId,
                    SendTime = mail.SendTime,
                };
                return(info);
            }
        }
        //public void DeleteInnerMail(string innerMailId, string userId)
        //{
        //    using (var biz = new GameBiz.Business.GameBizBusinessManagement())
        //    {
        //        biz.BeginTran();
        //        using (var manager = new InnerMailManager())
        //        {
        //            var user = manager.LoadUser(userId);
        //            var mail = manager.GetInnerMailById(innerMailId);
        //            var record = manager.GetReadRecord(mail, user);
        //            if (record == null)
        //            {
        //                record = new InnerMailReadRecord
        //                {
        //                    Mail = mail,
        //                    Receiver = user,
        //                    HandleType = InnerMailHandleType.Deleted,
        //                };
        //                manager.AddReadRecord(record);
        //            }
        //            else
        //            {
        //                record.HandleType = InnerMailHandleType.Deleted;
        //                manager.UpdateReadRecord(record);
        //            }
        //        }
        //        biz.CommitTran();
        //    }
        //}

        public void DeleteInnerMail(string innerMailId, string userId)
        {
            using (var biz = new GameBiz.Business.GameBizBusinessManagement())
            {
                using (var manager = new InnerMailManager())
                {
                    var mail = manager.QuerySiteMessageInnerMailListNewByMailId(innerMailId);
                    if (mail != null)
                    {
                        mail.HandleType = InnerMailHandleType.Deleted;
                        if (!mail.ReadTime.HasValue || mail.ReadTime.Value.Year <= 1900)
                        {
                            mail.ReadTime = DateTime.Now;
                        }
                        manager.UpdateSiteMessageInnerMailListNew(mail);
                    }
                }
            }
        }