Example #1
0
        /// <summary>
        /// 设置邮件 已读、未读
        /// </summary>
        /// <param name="EmailId">邮件主键</param>
        /// <param name="UserId">当前用户</param>
        /// <param name="IsRead">是否已读:0-未读;1-已读</param>
        /// <returns></returns>
        public void ReadEmail(string EmailId, string UserId, int IsRead)
        {
            Base_EmailAddressee entity = this.GetEmailAddressee(EmailId, UserId);

            if (entity.ReadDate == null)
            {
                entity.ReadDate = DateTime.Now;
            }
            if (entity.ReadCount == null)
            {
                entity.ReadCount = 0;
            }
            StringBuilder strSql = new StringBuilder();

            strSql.Append(@"UPDATE  Base_EmailAddressee
                            SET     IsRead = @IsRead ,
                                    ReadCount = @ReadCount ,
                                    ReadDate = @ReadDate ,
                                    EndReadDate = @EndReadDate
                            WHERE   AddresseeId = @AddresseeId
                                    AND EmailId = @EmailId");
            List <DbParameter> parameter = new List <DbParameter>();

            parameter.Add(DbFactory.CreateDbParameter("@IsRead", IsRead));
            parameter.Add(DbFactory.CreateDbParameter("@ReadCount", entity.ReadCount + 1));
            parameter.Add(DbFactory.CreateDbParameter("@ReadDate", entity.ReadDate));
            parameter.Add(DbFactory.CreateDbParameter("@EndReadDate", DateTime.Now));
            parameter.Add(DbFactory.CreateDbParameter("@AddresseeId", UserId));
            parameter.Add(DbFactory.CreateDbParameter("@EmailId", EmailId));
            int IsOk = DataFactory.Database().ExecuteBySql(strSql, parameter.ToArray());
        }
Example #2
0
        /// <summary>
        /// 删除邮件
        /// </summary>
        /// <param name="KeyValue">主键</param>
        /// <param name="Category">分类</param>
        /// <param name="DeleteMark">删除标识</param>
        /// <returns></returns>
        public ActionResult DeleteEmail(string KeyValue, string Category, int DeleteMark)
        {
            IDatabase     database    = DataFactory.Database();
            DbTransaction isOpenTrans = database.BeginTrans();

            string[] array = KeyValue.Split(',');
            try
            {
                string Id = "";
                foreach (string item in array)
                {
                    if (item.Length > 0)
                    {
                        Id = item;
                        string[] arrayId = item.Split('|');
                        if (arrayId.Length > 1)
                        {
                            Id       = arrayId[0];
                            Category = arrayId[1];
                        }
                        if (Category == "1")//收件
                        {
                            Base_EmailAddressee emailaddressee = new Base_EmailAddressee();
                            emailaddressee.EmailAddresseeId = Id;
                            emailaddressee.DeleteMark       = DeleteMark;
                            database.Update(emailaddressee, isOpenTrans);
                        }
                        else//发件
                        {
                            Base_Email base_email = new Base_Email();
                            base_email.EmailId    = Id;
                            base_email.DeleteMark = DeleteMark;
                            database.Update(base_email, isOpenTrans);
                        }
                    }
                }
                database.Commit();
                return(Content(new JsonMessage {
                    Success = true, Code = "1", Message = "删除成功。"
                }.ToString()));
            }
            catch (Exception ex)
            {
                database.Rollback();
                database.Close();
                return(Content(new JsonMessage {
                    Success = false, Code = "-1", Message = "操作失败:" + ex.Message
                }.ToString()));
            }
        }