示例#1
0
        public int AddUserLetterByUser()
        {
            HttpContextBase context        = (HttpContextBase)Request.Properties["MS_HttpContext"];
            HttpRequestBase request        = context.Request;
            Authentication  authentication = new Authentication(request);

            if (!string.IsNullOrEmpty(authentication.state))
            {
                return(0);
            }
            using (Entity entity = new Entity())
            {
                UserExtend userExtend = entity.UserExtend.Find(authentication.userID);
                if (userExtend.Banned == 1 && userExtend.BannedEndTime > DateTime.Now)
                {
                    return(0);
                }
            }
            using (Entity entity = new Entity())
            {
                int ID    = Convert.ToInt32(request["ID"]);
                var black = entity.UserBlacklist.Where(userBlacklisto => userBlacklisto.InitiativeUserID == ID && userBlacklisto.PassivityUserID == authentication.userID).Count() > 0;
                if (black)
                {
                    return(0);
                }
                UserLetter o = UserLetterBLL.Create(authentication.userID, ID, request["Text"], 5);
                var        UserLetterList = new List <UserLetter>();
                o.User = entity.User.Find(authentication.userID);
                return(1);
            }
        }
        protected void DetailsView1_ItemUpdating(object sender, DetailsViewUpdateEventArgs e)
        {
            using (Entity entity = new Entity())
            {
                var circlePost         = entity.CirclePost.Find(Convert.ToInt32(DetailsView1.DataKey.Value));
                var CheckBoxList_State = ((CheckBoxList)DetailsView1.FindControl("CheckBoxList_State"));
                var tempshenhe         = (circlePost.State & 2) == 0;
                var tempjiajing        = (circlePost.State & 8) == 0;
                var tempshanchu        = (circlePost.State & 32) == 0;
                circlePost.State = 0;
                var DropDownList_Province = ((DropDownList)DetailsView1.FindControl("DropDownList_Province"));
                circlePost.Province = DropDownList_Province.SelectedValue;
                foreach (ListItem item in CheckBoxList_State.Items)
                {
                    if (item.Selected)
                    {
                        circlePost.State = circlePost.State | Convert.ToInt32(item.Value);
                    }
                }
                if ((circlePost.State & 2) > 0 && (circlePost.State & 1) > 0)
                {
                    circlePost.State--;
                }
                if (((circlePost.State & 2) > 0) && tempshenhe)
                {
                    new ExperienceLevelBLL().CirclePostPass(circlePost.UserID);
                }
                if (((circlePost.State & 8) > 0) && tempjiajing)
                {
                    new ExperienceLevelBLL().CirclePostJiajing(circlePost.UserID);
                }

                if (tempshenhe)
                {
                    if ((circlePost.State & 2) > 0)
                    {
                        string text = string.Format("您的帖子 {0} 已经审核通过", circlePost.Title);
                        UserLetterBLL.Create(Convert.ToInt32(Session["userID"]), circlePost.UserID, text, 1 | 16, circlePost.CirclePostID);
                    }
                }

                if (tempshanchu)
                {
                    if ((circlePost.State & 32) > 0)
                    {
                        string text = string.Format("您的帖子 {0} 已被管理员删除。{1}", circlePost.Title,
                                                    (e.NewValues["Mark"] == null ? "" : ("原因: " + e.NewValues["Mark"].ToString())));
                        UserLetterBLL.Create(Convert.ToInt32(Session["userID"]), circlePost.UserID, text, 1 | 16);
                        if (e.NewValues["Mark"] != null)
                        {
                            circlePost.Mark = e.NewValues["Mark"].ToString();
                        }
                    }
                }
                circlePost.UpdateTime = DateTime.Now;
                entity.SaveChanges();
            }
            Response.Redirect("CirclePostDetail.aspx?circlePostID=" + DetailsView1.DataKey.Value);
        }
示例#3
0
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "StateDelete")
            {
                using (Entity entity = new Entity())
                {
                    int circlePostReplyID = Convert.ToInt32(e.CommandArgument);
                    var circlePostReply   = entity.CirclePostReply.Find(circlePostReplyID);
                    circlePostReply.State = 2;
                    circlePostReply.CirclePost.ReplyNum = circlePostReply.CirclePost.ReplyNum - 1;
                    entity.SaveChanges();
                    string text = string.Format("您在\"{0}\"的一条回复已被管理员删除", circlePostReply.CirclePost.Title);
                    UserLetterBLL.Create(Convert.ToInt32(Session["userID"]), circlePostReply.UserID, text, 1 | 16, circlePostReply.CirclePostID);
                }
                BindData(Convert.ToInt32(ViewState["circlePostID"]));
            }
            else if (e.CommandName == "StateZhiding")
            {
                using (Entity entity = new Entity())
                {
                    int circlePostReplyID = Convert.ToInt32(e.CommandArgument);
                    var circlePostReply   = entity.CirclePostReply.Find(circlePostReplyID);
                    circlePostReply.State = circlePostReply.State | 4;

                    entity.SaveChanges();
                }
                BindData(Convert.ToInt32(ViewState["circlePostID"]));
            }
            else if (e.CommandName == "StateQuxiao")
            {
                using (Entity entity = new Entity())
                {
                    int circlePostReplyID = Convert.ToInt32(e.CommandArgument);
                    var circlePostReply   = entity.CirclePostReply.Find(circlePostReplyID);
                    circlePostReply.State = circlePostReply.State - (circlePostReply.State & 4);

                    entity.SaveChanges();
                }
                BindData(Convert.ToInt32(ViewState["circlePostID"]));
            }
            else if (e.CommandName == "ChildDelete")
            {
                using (Entity entity = new Entity())
                {
                    int    circlePostReplyChildID = Convert.ToInt32(e.CommandArgument);
                    var    circlePostReplyChild   = entity.CirclePostReplyChild.Find(circlePostReplyChildID);
                    string title = circlePostReplyChild.CirclePost.Title;
                    entity.CirclePostReplyChild.Remove(circlePostReplyChild);
                    entity.SaveChanges();
                    string text = string.Format("您在\"{0}\"的一条回复已被管理员删除", title);
                    UserLetterBLL.Create(Convert.ToInt32(Session["userID"]), circlePostReplyChild.InitiativeUserID, text, 1 | 16, circlePostReplyChild.CirclePostID);
                }

                BindData(Convert.ToInt32(ViewState["circlePostID"]));
            }
        }
示例#4
0
        public List <UserLetter> AddUserLetter()
        {
            HttpContextBase context        = (HttpContextBase)Request.Properties["MS_HttpContext"];
            HttpRequestBase request        = context.Request;
            Authentication  authentication = new Authentication(request);

            if (!string.IsNullOrEmpty(authentication.state))
            {
                return(new List <UserLetter>());
            }
            using (Entity entity = new Entity())
            {
                UserExtend userExtend = entity.UserExtend.Find(authentication.userID);
                if (userExtend.Banned == 1 && userExtend.BannedEndTime > DateTime.Now)
                {
                    return(null);
                }
            }
            using (Entity entity = new Entity())
            {
                int ID = Convert.ToInt32(request["ID"]);

                int PassivityUserID = entity.UserLetter.Find(ID).InitiativeUserID;

                var black = entity.UserBlacklist.Where(userBlacklisto => userBlacklisto.InitiativeUserID == PassivityUserID && userBlacklisto.PassivityUserID == authentication.userID).Count() > 0;
                if (black)
                {
                    return(null);
                }

                UserLetter o = UserLetterBLL.Create(authentication.userID, PassivityUserID, request["Text"], 5);
                var        UserLetterList = new List <UserLetter>();
                o.User = entity.User.Find(authentication.userID);
                UserLetterList.Add(new UserLetter()
                {
                    InitiativeUserID = o.InitiativeUserID,
                    PassivityUserID  = o.PassivityUserID,
                    Text             = o.Text,
                    Type             = o.Type,
                    CreateTime       = o.CreateTime,
                    User             = new User()
                    {
                        HeadPortrait = ConfigurationManager.AppSettings["UploadUrl"] + o.User.HeadPortrait,
                        UserID       = o.User.UserID,
                        NickName     = o.User.NickName,
                        UserExtend   = new UserExtend()
                        {
                            ExperienceLevel = o.User.UserExtend.ExperienceLevel,
                            ExperienceName  = o.User.UserExtend.ExperienceName,
                        }
                    },
                    UserLetterID = o.UserLetterID
                });
                return(UserLetterList);
            }
        }
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrWhiteSpace(TextBox1.Text))
     {
         return;
     }
     UserLetterBLL.Create(Convert.ToInt32(Session["userID"]), Convert.ToInt32(ViewState["userID"]), TextBox1.Text, 1 | 16);
     BindData(Convert.ToInt32(ViewState["userID"]));
     ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", string.Format("<script>alert('{0}')</script>", "私信发送成功"));
 }
 protected void Button3_Click(object sender, EventArgs e)
 {
     using (Entity entity = new Entity())
     {
         var user = entity.User.Find(Convert.ToInt32(DetailsView1.DataKey.Value));
         user.NickName = "分享玩家";
         entity.SaveChanges();
     }
     BindData(Convert.ToInt32(ViewState["userID"]));
     UserLetterBLL.Create(Convert.ToInt32(Session["userID"]), Convert.ToInt32(ViewState["userID"]), "您的昵称违规,已经被管理员设置为默认昵称。", 1 | 16);
     ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", string.Format("<script>alert('{0}')</script>", "修改昵称成功"));
 }
        protected void Button2_Click(object sender, EventArgs e)
        {
            using (Entity entity = new Entity())
            {
                var user = entity.User.Find(Convert.ToInt32(DetailsView1.DataKey.Value));
                if (user.Gender == "男")
                {
                    user.HeadPortrait = "init/man.jpg";
                }
                else
                {
                    user.HeadPortrait = "init/woman.jpg";
                }
                entity.SaveChanges();
            }
            BindData(Convert.ToInt32(ViewState["userID"]));
            UserLetterBLL.Create(Convert.ToInt32(Session["userID"]), Convert.ToInt32(ViewState["userID"]), "您上传的头像违规,已经被管理员设置为默认头像。", 1 | 16);

            ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", string.Format("<script>alert('{0}')</script>", "修改头像成功"));
        }
        public CirclePostReplyChild CreateReplyChild()
        {
            HttpContextBase context        = (HttpContextBase)Request.Properties["MS_HttpContext"];
            HttpRequestBase request        = context.Request;
            Authentication  authentication = new Authentication(request);

            if (!string.IsNullOrEmpty(authentication.state))
            {
                return(null);
            }
            using (Entity entity = new Entity())
            {
                UserExtend userExtend = entity.UserExtend.Find(authentication.userID);
                if (userExtend.Banned == 1 && userExtend.BannedEndTime > DateTime.Now)
                {
                    throw new Exception("禁言中...");
                }
            }
            string circlePostIDTemp = request["circlePostID"];

            if (circlePostIDTemp == null)
            {
                return(null);
            }
            if (request["text"] == null)
            {
                return(null);
            }
            int circlePostID;

            if (!int.TryParse(circlePostIDTemp, out circlePostID))
            {
                return(null);
            }
            int CirclePostReplyID = Convert.ToInt32(request["circlePostReplyID"]);

            using (Entity entity = new Entity())
            {
                CirclePost circlePost = entity.CirclePost.Find(circlePostID);
                circlePost.ReplyNum++;
                circlePost.UpdateTime = DateTime.Now;
                CirclePostReplyChild circlePostReplyChild = new CirclePostReplyChild()
                {
                    InitiativeUserID  = authentication.userID,
                    PassivityUserID   = circlePost.UserID,
                    CirclePostID      = circlePostID,
                    CirclePostReplyID = CirclePostReplyID,
                    Detail            = request["text"],
                    ImgList           = request["imglist"],
                    State             = 0,
                    CreateTime        = DateTime.Now,
                };
                circlePost.CirclePostReplyChild.Add(circlePostReplyChild);
                new ExperienceLevelBLL().CirclePostReply(authentication.userID);
                entity.SaveChanges();
                if (authentication.userID != circlePost.UserID)
                {
                    var    user = entity.User.Find(authentication.userID);
                    string text = string.Format(" {0} 回复了您的帖子 {1}", user.NickName, circlePost.Title);
                    UserLetterBLL.Create(1, circlePost.UserID, text, 1 | 16, circlePost.CirclePostID);
                }

                return(entity.CirclePostReplyChild.Include("User").Where(o => o.CirclePostReplyChildID == circlePostReplyChild.CirclePostReplyChildID).ToList().Select(o =>
                                                                                                                                                                       new CirclePostReplyChild()
                {
                    InitiativeUserID = o.InitiativeUserID,
                    Detail = o.Detail,
                    ImgList = XFXExt.imgList(o.ImgList, ConfigurationManager.AppSettings["UploadUrl"], false),
                    User = new User()
                    {
                        NickName = o.User.NickName,
                        UserID = o.User.UserID
                    }
                }
                                                                                                                                                                       ).First());
            }
        }
        public IEnumerable <CirclePostReply> CreateReply()
        {
            HttpContextBase context        = (HttpContextBase)Request.Properties["MS_HttpContext"];
            HttpRequestBase request        = context.Request;
            Authentication  authentication = new Authentication(request);

            if (!string.IsNullOrEmpty(authentication.state))
            {
                return(null);
            }
            using (Entity entity = new Entity())
            {
                UserExtend userExtend = entity.UserExtend.Find(authentication.userID);
                if (userExtend.Banned == 1 && userExtend.BannedEndTime > DateTime.Now)
                {
                    throw new Exception("禁言中...");
                }
            }
            string circlePostIDTemp = request["id"];

            if (circlePostIDTemp == null)
            {
                return(null);
            }
            if (request["text"] == null)
            {
                return(null);
            }
            int circlePostID;

            if (!int.TryParse(circlePostIDTemp, out circlePostID))
            {
                return(null);
            }
            using (Entity entity = new Entity())
            {
                CirclePost circlePost = entity.CirclePost.Find(circlePostID);
                circlePost.ReplyNum++;
                circlePost.UpdateTime = DateTime.Now;
                CirclePostReply circlePostReply = new CirclePostReply()
                {
                    UserID       = authentication.userID,
                    CirclePostID = circlePostID,
                    Detail       = request["text"],
                    ImgList      = request["imglist"],
                    State        = 0,
                    CreateTime   = DateTime.Now,
                    Floor        = circlePost.ReplyNum
                };
                circlePost.CirclePostReply.Add(circlePostReply);
                new ExperienceLevelBLL().CirclePostReply(authentication.userID);
                entity.SaveChanges();
                if (authentication.userID != circlePost.UserID)
                {
                    var    user = entity.User.Find(authentication.userID);
                    string text = string.Format(" {0} 回复了您的帖子 {1}", user.NickName, circlePost.Title);
                    UserLetterBLL.Create(1, circlePost.UserID, text, 1 | 16, circlePost.CirclePostID);
                }


                return(entity.CirclePostReply.Include("User").Include("User.UserExtend").Where(o => o.CirclePostReplyID == circlePostReply.CirclePostReplyID).ToList()
                       .Select(o => new CirclePostReply()
                {
                    CirclePostReplyID = o.CirclePostReplyID,
                    CirclePostID = o.CirclePostID,
                    Detail = o.Detail,
                    ImgList = XFXExt.imgList(o.ImgList, ConfigurationManager.AppSettings["UploadUrl"], false),
                    User = new User()
                    {
                        NickName = o.User.NickName,
                        UserExtend = new UserExtend()
                        {
                            ExperienceLevel = o.User.UserExtend.ExperienceLevel,
                            ExperienceName = o.User.UserExtend.ExperienceName
                        },
                        UserID = o.UserID,
                        Gender = o.User.Gender,
                        Location = o.User.Location,
                        HeadPortrait = ConfigurationManager.AppSettings["UploadUrl"] + o.User.HeadPortrait,
                        Type = o.User.Type.getUserType()
                    },
                    UserID = o.UserID,
                    Floor = o.Floor,
                    State = o.State,
                    CreateTime = o.CreateTime,
                }));
            }
        }
        protected void DetailsView1_ItemUpdating(object sender, DetailsViewUpdateEventArgs e)
        {
            try
            {
                using (Entity entity = new Entity())
                {
                    var order = entity.Order.Find(DetailsView1.DataKey.Value.ToString());

                    var CheckBoxList_State = ((CheckBoxList)DetailsView1.FindControl("CheckBoxList_State"));
                    order.State = 0;
                    int fahuoTemp = order.State & 4;
                    foreach (ListItem item in CheckBoxList_State.Items)
                    {
                        if (item.Selected)
                        {
                            order.State = order.State | Convert.ToInt32(item.Value);
                        }
                    }

                    if (fahuoTemp == 0)
                    {
                        if ((order.State & 4) > 0)
                        {
                            OrderLog orderLog = new OrderLog();
                            orderLog.OrderID    = order.OrderID;
                            orderLog.State      = 2;
                            orderLog.CreateTime = DateTime.Now;
                            orderLog.Mark       = "卖家发货";
                            orderLog.UserId     = Convert.ToInt32(Session["userID"]);
                            entity.OrderLog.Add(orderLog);
                            if (order.UserID != null)
                            {
                                string text = string.Format("您的订单{0}已经发货", order.OrderID);
                                UserLetterBLL.Create(Convert.ToInt32(Session["userID"]), order.UserID.Value, text, 1 | 8);

                                ThreadPool.QueueUserWorkItem(delegate(object a)
                                {
                                    string tt = @"您的订单 " + order.OrderID + " 已经发货,不日则到。请注意查收您的订单 ";
                                    using (Entity entity1 = new Entity())
                                    {
                                        UserSMS userSMS = new UserSMS()
                                        {
                                            Tel = entity1.User.Find(order.UserID).Tel
                                        };

                                        string bb = SMS.sendSMS(userSMS.Tel, tt, userSMS.SerialNumber);
                                    }
                                });
                            }
                        }
                    }


                    var DropDownList1 = ((DropDownList)DetailsView1.FindControl("DropDownList1"));
                    order.LogisticsCompany = DropDownList1.SelectedValue;
                    if (e.NewValues["LogisticsNumber"] != null)
                    {
                        order.LogisticsNumber = e.NewValues["LogisticsNumber"].ToString();
                    }
                    order.UpdateTime = DateTime.Now;

                    entity.SaveChanges();

                    Response.Redirect("OrderDetail.aspx?OrderID=" + order.OrderID);
                }
            }
            catch (Exception exception)
            {
                string error = exception.GetErrorMessage().Replace("'", "\\'").Replace("\"", "\\\"").Replace("\r\n", "\\r\\n");
                ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", string.Format("<script>alert('{0}')</script>", error));
            }
        }
        protected void DetailsView1_ItemUpdating(object sender, DetailsViewUpdateEventArgs e)
        {
            try
            {
                using (Entity entity = new Entity())
                {
                    var user = entity.User.Find(Convert.ToInt32(DetailsView1.DataKey.Value));
                    var CheckBoxList_Type = ((CheckBoxList)DetailsView1.FindControl("CheckBoxList_Type"));
                    user.Type = 0;
                    foreach (ListItem item in CheckBoxList_Type.Items)
                    {
                        if (item.Selected)
                        {
                            user.Type = user.Type | Convert.ToInt32(item.Value);
                        }
                    }
                    var RadioButtonList_Statet = ((RadioButtonList)DetailsView1.FindControl("RadioButtonList_State"));
                    user.State = Convert.ToInt32(RadioButtonList_Statet.SelectedValue);

                    var RadioButtonList_Banned = ((RadioButtonList)DetailsView1.FindControl("RadioButtonList_Banned"));
                    int bannedTemp             = user.UserExtend.Banned;
                    user.UserExtend.Banned = Convert.ToInt32(RadioButtonList_Banned.SelectedValue);
                    if (user.UserExtend.Banned == 1 && bannedTemp != 1)
                    {
                        new ExperienceLevelBLL().Jinyan(user.UserID);
                        user.UserExtend.BannedStartTime = DateTime.Now;
                        user.UserExtend.BannedEndTime   = user.UserExtend.BannedStartTime.Value.AddDays(3);
                        UserLetterBLL.Create(Convert.ToInt32(Session["userID"]), Convert.ToInt32(ViewState["userID"]), "您的发言被用户举报,已经被禁言三天。", 1 | 16);
                    }
                    else if (user.UserExtend.Banned == 0)
                    {
                        user.UserExtend.BannedEndTime = user.UserExtend.BannedStartTime = null;
                    }

                    if (e.NewValues["UserExtend.ExperienceLevel"] != null)
                    {
                        int level = Convert.ToInt32(e.NewValues["UserExtend.ExperienceLevel"]);
                        if (level == 0)
                        {
                            level = 1;
                        }
                        if (user.UserExtend.ExperienceLevel != level)
                        {
                            ExperienceLevel experienceLevel = entity.ExperienceLevel.Where(o => o.ExperienceLevelValue == level).FirstOrDefault();
                            if (experienceLevel == null)
                            {
                                throw new Exception("经验等级和等级不对应");
                            }
                            user.UserExtend.ExperienceLevel = experienceLevel.ExperienceLevelValue;
                            user.UserExtend.ExperienceValue = experienceLevel.ExperienceValueMin;
                            if (user.Gender == "男")
                            {
                                user.UserExtend.ExperienceName = experienceLevel.NameMan;
                            }
                            else
                            {
                                user.UserExtend.ExperienceName = experienceLevel.NameWoman;
                            }
                        }
                    }
                    entity.SaveChanges();
                }
                Response.Redirect("UserDetail.aspx?userID=" + DetailsView1.DataKey.Value);
            }
            catch (Exception exception)
            {
                string error = exception.GetErrorMessage().Replace("'", "\\'").Replace("\"", "\\\"").Replace("\r\n", "\\r\\n");
                ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", string.Format("<script>alert('{0}')</script>", error));
            }
        }