/// <summary>
        /// 实现帖子的评论功能,将数据保存到数据库
        /// 帖子类型为1代表主贴的评论
        /// 帖子类型为2代表回帖的评论
        /// </summary>
        /// <returns></returns>
        public ActionResult AjaxTieZiComment()
        {
            int             postId              = Convert.ToInt32(Request["postId"]);
            string          commentUserName     = Request["commenterUserName"].ToString();
            User_bll        user_bll            = new User_bll();
            int             commenterId         = user_bll.GetUserId(commentUserName);
            string          beCommenterUserName = Request["beCommenterUserName"];
            int             beCommenterId       = user_bll.GetUserId(beCommenterUserName);
            string          content             = Request["content"].ToString();
            int             postType            = Convert.ToInt32(Request["postType"]);
            DateTime        datetime            = DateTime.Now;
            PostComment_bll postComment_bll     = new PostComment_bll();
            int             InsertCount         = postComment_bll.InsertComment(postId, commenterId, beCommenterId, content, datetime, postType);//插入评论数据的成功条数

            return(Content(InsertCount.ToString()));
        }
        /// <summary>
        /// 返回特定咨询页面
        /// </summary>
        /// <returns></returns>
        public ActionResult Consult()
        {
            if (Session["username"] == null)
            {
                return(View("loginremind"));
            }
            string userName = Session["username"].ToString();

            LoginStatusConfig();//配置登录状态


            User_bll        user_bll        = new User_bll();
            int             userId          = Convert.ToInt32(user_bll.GetUserId(userName)); //通过用户名获取userId
            CountUser_model countUser_model = user_bll.GetCountUser(userId);                 //获取用户的CountUser_model 数据:点赞数 关注数 粉丝数 收藏数 提问数 回帖数 特定咨询数 等

            ViewData["countUser_model"] = countUser_model;
            List <ExpertUserConsult_model> expertUserConsult_modelList = user_bll.GetExpertConsult();  //获取专家的ExpertUserConsult_model数据,用户填写特定咨询时,需要选择专家
            User_model user_model = new User_model();

            try {
                user_model = user_bll.GetUserDataConsult(userName);//用户的个人数据
            }
            catch (Exception e)
            {
                return(Content(e.ToString()));
            }

            ViewData["user_model"] = user_model;
            return(View(expertUserConsult_modelList));
        }
Exemple #3
0
        /// <summary>
        /// 遍历我的特定咨询过的帖子
        /// Creator:Simple
        /// </summary>
        /// <returns></returns>
        public ActionResult MySpecialConsult()
        {
            if (Session["userName"] == null)
            {
                return(RedirectToAction("LoginRemind", "Topic"));
            }
            LoginStatusConfig();//配置登录状态
            string userName = Session["userName"].ToString();
            ////判断用户类型是否为普通用户
            Rank_bll rank_bll   = new Rank_bll();
            string   rankNameDB = rank_bll.GetRankName(userName); //该用户数据库里的等级名

            rankNameDB = rankNameDB.Trim();                       //去除空格
            if (rankNameDB != "普通用户")
            {
                return(Content("错误提示:您不是普通用户"));
            }
            User_bll        user_bll        = new User_bll();
            int             userId          = Convert.ToInt32(user_bll.GetUserId(userName)); //通过用户名获取userId
            CountUser_model countUser_model = user_bll.GetCountUser(userId, rankNameDB);     //获取用户的CountUser_model 数据:点赞数 关注数 粉丝数 收藏数 提问数 回帖数 特定咨询数 等

            ViewData["countUser_model"] = countUser_model;
            ViewData["rankName"]        = rankNameDB;
            ViewData["actionName"]      = "MySpecialConsult";                                                   //当前action名
            SpecialConsult_bll          specialConsult_bll       = new SpecialConsult_bll();
            List <SpecialConsult_model> specialConsult_modelList = specialConsult_bll.GetMyConsultData(userId); //通过userId获取该用户的特定咨询数据

            return(View(specialConsult_modelList));
        }
        //特定咨询详情页面(用户和专家共用)
        public ActionResult ConsultDetails()
        {
            if (Session["userName"] == null)
            {
                return(RedirectToAction("LoginRemind", "Topic"));
            }
            LoginStatusConfig();//配置登录状态
            string userName = Session["userName"].ToString();
            ////获取用户等级名
            Rank_bll rank_bll   = new Rank_bll();
            string   rankNameDB = rank_bll.GetRankName(userName); //该用户数据库里的等级名

            rankNameDB = rankNameDB.Trim();                       //去除空格
            //string expertUserName = Request["expertUserName"].ToString();
            int specialConsultId = Convert.ToInt32(Request["specialConsultId"]);
            SpecialConsult_bll   specialConsult_bll   = new SpecialConsult_bll();
            SpecialConsult_model specialConsult_model = specialConsult_bll.GetOneSpecialConsult(specialConsultId);//通过specialConsultId获取用户特定咨询时填写的特定咨询数据

            ViewData["specialConsult_model"] = specialConsult_model;
            ViewData["rankName"]             = rankNameDB;
            SpecialConsultAnswer_bll specialConsultAnswer_bll = new SpecialConsultAnswer_bll();
            string   expertUserName = Request["expertUserName"].ToString();
            User_bll user_bll       = new User_bll();
            int      expertId       = user_bll.GetUserId(expertUserName);
            SpecialConsultAnswer_model specialConsultAnswer_model = specialConsultAnswer_bll.GetOneSpecialAnswerData(specialConsultId, expertId);//通过specialConsultId获取特定咨询的专家解答数据

            return(View(specialConsultAnswer_model));
        }
Exemple #5
0
        /// <summary>
        /// 遍历我的回答过的帖子,即回帖
        /// Creator:Simple
        /// </summary>
        /// <returns></returns>
        public ActionResult myAnsweres()
        {
            if (Session["userName"] == null)
            {
                return(RedirectToAction("LoginRemind", "Topic"));
            }
            LoginStatusConfig();//配置登录状态
            string userName = Session["userName"].ToString();
            ////获取用户等级名
            Rank_bll rank_bll   = new Rank_bll();
            string   rankNameDB = rank_bll.GetRankName(userName); //该用户数据库里的等级名

            rankNameDB = rankNameDB.Trim();                       //去除空格

            User_bll        user_bll        = new User_bll();
            int             userId          = Convert.ToInt32(user_bll.GetUserId(userName)); //通过用户名获取userId
            CountUser_model countUser_model = user_bll.GetCountUser(userId, rankNameDB);     //获取用户的CountUser_model 数据:点赞数 关注数 粉丝数 收藏数 提问数 回帖数 特定咨询数 等

            ViewData["countUser_model"] = countUser_model;
            ViewData["rankName"]        = rankNameDB;
            ViewData["actionName"]      = "myAnsweres";//当前action名
            ReplyPost_bll          replyPost_bll       = new ReplyPost_bll();
            List <ReplyPost_model> replyPost_modelList = new List <ReplyPost_model>();

            replyPost_modelList = replyPost_bll.GetShortReplyPostData(userId);//获取用户的回帖数据
            return(View(replyPost_modelList));
        }
        /// <summary>
        /// 保存特定咨询的数据
        /// </summary>
        /// <returns></returns>
        public ActionResult MakeConsult()
        {
            if (Session["username"] == null)
            {
                return(View("loginremind"));
            }
            string   userName = Session["username"].ToString();
            User_bll user_bll = new User_bll();
            int      userId   = user_bll.GetUserId(userName);
            //string expertName=Request[].ToString();
            //int expertId = user_bll.GetUserId(expertName);
            string   occasion = Request["occasion"].ToString(); //场合
            string   details  = Request["details"].ToString();  //特定咨询详情
            DateTime datetime = DateTime.Now;

            //保存个人照片到文件夹:GeRenZhao
            byte[] imgGeRenZhao64Byte     = Convert.FromBase64String(Request["geRenZhao"]);//将图片数据转化为base64的格式
            System.IO.MemoryStream ms     = new System.IO.MemoryStream(imgGeRenZhao64Byte);
            System.Drawing.Bitmap  bitmap = new System.Drawing.Bitmap(ms);
            string geRenZhaoFileName      = Guid.NewGuid().ToString() + ".png";//唯一的文件名

            bitmap.Save(Server.MapPath("~/Images/ConsultImages/GeRenZhao/" + geRenZhaoFileName), System.Drawing.Imaging.ImageFormat.Png);
            //保存喜欢风格的照片到文件夹:LikeStyleImage
            byte[] likeStyleImageBase64    = Convert.FromBase64String(Request["likeStyleImage"]);//将图片数据转化为base64的格式
            System.IO.MemoryStream ms2     = new System.IO.MemoryStream(likeStyleImageBase64);
            System.Drawing.Bitmap  bitmap2 = new System.Drawing.Bitmap(ms2);
            string likeStyleImageFileName  = Guid.NewGuid().ToString() + ".png";//唯一的文件名

            bitmap2.Save(Server.MapPath("~/Images/ConsultImages/LikeStyleImage/" + likeStyleImageFileName), System.Drawing.Imaging.ImageFormat.Png);
            //保存不喜欢风格的照片到文件夹:DislikeStyleImage
            byte[] dislikeStyleImageBase64   = Convert.FromBase64String(Request["dislikeStyleImage"]);//将图片数据转化为base64的格式
            System.IO.MemoryStream ms3       = new System.IO.MemoryStream(dislikeStyleImageBase64);
            System.Drawing.Bitmap  bitmap3   = new System.Drawing.Bitmap(ms3);
            string dislikeStyleImageFileName = Guid.NewGuid().ToString() + ".png";//唯一的文件名

            bitmap3.Save(Server.MapPath("~/Images/ConsultImages/DislikeStyleImage/" + dislikeStyleImageFileName), System.Drawing.Imaging.ImageFormat.Png);

            SpecialConsult_bll specialConsult_bll = new SpecialConsult_bll();//保存特定咨询数据

            specialConsult_bll.InsertConsultData(userId, occasion, details, geRenZhaoFileName, likeStyleImageFileName, dislikeStyleImageFileName, datetime);
            //通过geRenZhaoFileName查询该咨询的id
            int specialConsult_Id = specialConsult_bll.GetSpecialConsultId(geRenZhaoFileName);
            //将用户特定咨询时选择的专家,添加到数据库
            SpecialConsultSelectExperts_bll specialConsultSelectExperts_bll = new SpecialConsultSelectExperts_bll();
            List <string> expertIdList = new List <string>();
            string        expertIdStr  = Request["expertIdList"].ToString();//获取用户选择的专家id

            foreach (string expertId in expertIdStr.Split(','))
            {
                expertIdList.Add(expertId);
            }
            specialConsultSelectExperts_bll.InsertSpecialConsultSelectExperts(specialConsult_Id, expertIdList);
            return(Content(specialConsult_Id.ToString()));//返回specialConsult_Id
        }
Exemple #7
0
        public ActionResult Change_Data()
        {
            LoginStatusConfig();//配置登录状态
            if (Session["userName"] == null)
            {
                return(RedirectToAction("LoginRemind", "Topic"));
            }
            string          userName        = Session["userName"].ToString();
            User_bll        user_bll        = new User_bll();
            int             userId          = Convert.ToInt32(user_bll.GetUserId(userName)); //通过用户名获取userId
            CountUser_model countUser_model = user_bll.GetCountUser(userId);                 //获取用户的CountUser_model 数据:点赞数 关注数 粉丝数 收藏数 提问数 回帖数 特定咨询数 等

            ViewData["countUser_model"] = countUser_model;
            return(View());
        }
Exemple #8
0
        /// <summary>
        ///遍历我的提问过的帖子
        /// </summary>
        /// <returns></returns>
        public ActionResult myAsks()
        {
            if (Session["userName"] == null)
            {
                return(RedirectToAction("LoginRemind", "Topic"));
            }
            LoginStatusConfig();//配置登录状态
            string          userName        = Session["userName"].ToString();
            User_bll        user_bll        = new User_bll();
            int             userId          = Convert.ToInt32(user_bll.GetUserId(userName)); //通过用户名获取userId
            CountUser_model countUser_model = user_bll.GetCountUser(userId);                 //获取用户的CountUser_model 数据:点赞数 关注数 粉丝数 收藏数 提问数 回帖数 特定咨询数 等

            ViewData["countUser_model"] = countUser_model;
            Post_bll          post_bll       = new Post_bll();
            List <Post_model> post_modelList = post_bll.GetShortPostData(userId);//获取用户的提问过的贴子

            return(View(post_modelList));
        }
        /// <summary>
        /// 保存特定咨询的数据
        /// </summary>
        /// <returns></returns>
        public ActionResult MakeConsult()
        {
            if (Session["username"] == null)
            {
                return(View("loginremind"));
            }
            string   userName = Session["username"].ToString();
            User_bll user_bll = new User_bll();
            int      userId   = user_bll.GetUserId(userName);
            //string expertName=Request[].ToString();
            //int expertId = user_bll.GetUserId(expertName);
            int      expertId = Convert.ToInt32(Request["expertId"]);
            string   occasion = Request["occasion"].ToString(); //场合
            string   details  = Request["details"].ToString();  //特定咨询详情
            DateTime datetime = DateTime.Now;

            //保存个人照片到文件夹:GeRenZhao
            byte[] imgGeRenZhao64Byte     = Convert.FromBase64String(Request["geRenZhao"]);//将图片数据转化为base64的格式
            System.IO.MemoryStream ms     = new System.IO.MemoryStream(imgGeRenZhao64Byte);
            System.Drawing.Bitmap  bitmap = new System.Drawing.Bitmap(ms);
            string geRenZhaoFileName      = Guid.NewGuid().ToString() + ".png";//唯一的文件名

            bitmap.Save(Server.MapPath("~/Images/ConsultImages/GeRenZhao/" + geRenZhaoFileName), System.Drawing.Imaging.ImageFormat.Png);
            //保存喜欢风格的照片到文件夹:LikeStyleImage
            byte[] likeStyleImageBase64    = Convert.FromBase64String(Request["likeStyleImage"]);//将图片数据转化为base64的格式
            System.IO.MemoryStream ms2     = new System.IO.MemoryStream(likeStyleImageBase64);
            System.Drawing.Bitmap  bitmap2 = new System.Drawing.Bitmap(ms2);
            string likeStyleImageFileName  = Guid.NewGuid().ToString() + ".png";//唯一的文件名

            bitmap2.Save(Server.MapPath("~/Images/ConsultImages/LikeStyleImage/" + likeStyleImageFileName), System.Drawing.Imaging.ImageFormat.Png);
            //保存不喜欢风格的照片到文件夹:DislikeStyleImage
            byte[] dislikeStyleImageBase64   = Convert.FromBase64String(Request["dislikeStyleImage"]);//将图片数据转化为base64的格式
            System.IO.MemoryStream ms3       = new System.IO.MemoryStream(dislikeStyleImageBase64);
            System.Drawing.Bitmap  bitmap3   = new System.Drawing.Bitmap(ms3);
            string dislikeStyleImageFileName = Guid.NewGuid().ToString() + ".png";//唯一的文件名

            bitmap3.Save(Server.MapPath("~/Images/ConsultImages/DislikeStyleImage/" + dislikeStyleImageFileName), System.Drawing.Imaging.ImageFormat.Png);

            SpecialConsult_bll specialConsult_bll = new SpecialConsult_bll();//保存特定咨询数据

            specialConsult_bll.InsertConsultData(userId, expertId, occasion, details, geRenZhaoFileName, likeStyleImageFileName, dislikeStyleImageFileName, datetime);
            return(Content("特定咨询成功"));
        }
Exemple #10
0
        /// <summary>
        /// 遍历我的特定咨询过的帖子
        /// </summary>
        /// <returns></returns>
        public ActionResult MySpecialConsult()
        {
            if (Session["userName"] == null)
            {
                return(RedirectToAction("LoginRemind", "Topic"));
            }
            LoginStatusConfig();//配置登录状态

            string          userName        = Session["userName"].ToString();
            User_bll        user_bll        = new User_bll();
            int             userId          = Convert.ToInt32(user_bll.GetUserId(userName)); //通过用户名获取userId
            CountUser_model countUser_model = user_bll.GetCountUser(userId);                 //获取用户的CountUser_model 数据:点赞数 关注数 粉丝数 收藏数 提问数 回帖数 特定咨询数 等

            ViewData["countUser_model"] = countUser_model;
            SpecialConsult_bll          specialConsult_bll       = new SpecialConsult_bll();
            List <SpecialConsult_model> specialConsult_modelList = specialConsult_bll.GetMyConsultData(userId); //通过userId获取该用户的特定咨询数据

            return(View(specialConsult_modelList));
        }
Exemple #11
0
        /// <summary>
        /// 模板页,查看我的  “回答 提问 收藏 ” 帖子,
        /// </summary>
        /// <returns></returns>
        public ActionResult MyPostTemplate()
        {
            LoginStatusConfig();//配置登录状态
            if (Session["userName"] == null)
            {
                return(RedirectToAction("LoginRemind", "Topic"));
            }
            string   userName = Session["userName"].ToString();
            User_bll user_bll = new User_bll();
            int      userId   = Convert.ToInt32(user_bll.GetUserId(userName));//通过用户名获取userId
            ////获取用户等级名
            Rank_bll rank_bll   = new Rank_bll();
            string   rankNameDB = rank_bll.GetRankName(userName);                        //该用户数据库里的等级名

            rankNameDB = rankNameDB.Trim();                                              //去除空格
            CountUser_model countUser_model = user_bll.GetCountUser(userId, rankNameDB); //获取用户的CountUser_model 数据:点赞数 关注数 粉丝数 收藏数 提问数 回帖数 特定咨询数 等

            ViewData["countUser_model"] = countUser_model;
            return(View());
        }
Exemple #12
0
        /// <summary>
        /// 对主贴的回帖
        /// </summary>
        /// <returns></returns>
        public ActionResult MakePostReply()
        {
            ////--------先把前端传回来的content内容保存为静态页面
            byte[] byteData = new byte[Request.InputStream.Length]; //定义一个字节数组保存前端传回来的Post数据全部数据
            Request.InputStream.Read(byteData, 0, byteData.Length); //将流读取到byteData,InputStream读取到的是http头里的主体数据
            //string postData = System.Text.Encoding.Default.GetString(byteData);//系统的默认编码为gb2312,不适用这种
            string postData = System.Text.Encoding.UTF8.GetString(byteData);

            postData = Server.UrlDecode(postData);                                         //对数据进行url解码
            string[] datas       = postData.Split('&');                                    //对前端传回来的数据进行分割,提取出文本框里的html数据
            string   contentData = datas[0].ToString();                                    //data[0]为变量名为content的内容

            contentData = contentData.Substring(contentData.IndexOf('=') + 1);             //去除变量名,如content=aaa,只取出aaa
            DateTime datetime     = DateTime.Now;
            string   fileName     = datetime.ToString("yyyyMMddHHmmss_ffff") + ".html";    //定义文件名fileName
            string   fileNamePath = Server.MapPath("~/StaticHtml/HuiTieHtml/") + fileName; //物理路径

            while (System.IO.File.Exists(fileNamePath))                                    //先判断文件是否存在,若存在:更换文件名
            {
                datetime     = DateTime.Now;
                fileName     = datetime.ToString("yyyyMMddHHmmss_ffff") + ".html";
                fileNamePath = Server.MapPath("~/StaticHtml/HuiTieHtml/") + fileName;
            }
            System.IO.FileStream fs = new System.IO.FileStream(fileNamePath, System.IO.FileMode.Create);
            byte[] contentBytes     = System.Text.Encoding.UTF8.GetBytes(contentData);
            //byte[] contentBytes = System.Text.Encoding.Default.GetBytes(contentData);
            fs.Write(contentBytes, 0, contentBytes.Length);
            fs.Close();//---------保存静态html成功
            ///----------/将数据保存到数据库里tb_ReplyPost (主贴编号 回帖者Id
            ///回帖内容的前200字符 点赞数 日期 回帖的静态html)
            int      postId        = Convert.ToInt32(Request["hidPostId"]); //主贴id
            int      supportCount  = 0;                                     //点赞数
            string   replyUserName = Request["hidHuiTieUserName"].ToString();
            User_bll user_bll      = new User_bll();
            int      replyUserId   = user_bll.GetUserId(replyUserName); //回帖者id
            string   editorContent = datas[3].ToString();               //回帖内容的纯文本包含图片,data[3]的为前端传回来的发帖内容的纯文本 (备注:不能从request["editorContent"]读取,会报错提示说存在html标签)

            editorContent = editorContent.Substring(editorContent.IndexOf('=') + 1);
            System.Text.RegularExpressions.Regex regexImg = new System.Text.RegularExpressions.Regex(@"<img[^>]+>");
            editorContent = regexImg.Replace(editorContent, "");//过滤掉editorContent里图片
            int len = editorContent.Length;

            if (len > 200)//如果editorContent的长度超过200,取editorContent里的前两百个字符,将用于保存到数据库
            {
                len = 200;
            }
            string        content200       = editorContent.Substring(0, len);      //回帖的200字符
            string        staticHuiTieHtml = "/StaticHtml/HuiTieHtml/" + fileName; //相对路径
            ReplyPost_bll replyPost_bll    = new ReplyPost_bll();

            replyPost_bll.InsertReplyPost(postId, replyUserId, content200, supportCount, datetime, staticHuiTieHtml);
            //--------回帖数据保存成功

            //////获取回帖里的所有图片的路径,并且将图片路径保存到数据库里tb_PostPhoto (PostPhoto_PostType=)
            int replyPostId = replyPost_bll.GetReplyPostId(staticHuiTieHtml);                                                                                                                                                                                                          //根据回帖的静态html路径查询数据库,得到该贴子的replyPost_Id

            System.Text.RegularExpressions.Regex           regImg2 = new System.Text.RegularExpressions.Regex(@"<img\b[^<>]*?\bsrc[\s\t\r\n]*=[\s\t\r\n]*[""']?[\s\t\r\n]*(?<imgUrl>[^\s\t\r\n""'<>]*)[^<>]*?/?[\s\t\r\n]*>", System.Text.RegularExpressions.RegexOptions.IgnoreCase); // 定义正则表达式用来匹配 img 标签
            System.Text.RegularExpressions.MatchCollection matches = regImg2.Matches(contentData);
            int i = 0;

            string[] strUrlList = new string[matches.Count];
            foreach (System.Text.RegularExpressions.Match match in matches)
            {
                strUrlList[i++] = match.Groups["imgUrl"].Value;// 取得匹配项列表
            }
            if (strUrlList.Length >= 1)
            {
                PostPhoto_bll postPhoto_bll = new PostPhoto_bll();
                if (postPhoto_bll.InsertPhotoUrl(replyPostId, strUrlList, 2) < 0)
                {
                    return(Content("保存图片路径时数据库出错"));
                }
            }
            return(RedirectToAction("../Topic/PostDetails", new { postId = postId }));
        }
        /// <summary>
        /// 专家对特定咨询的回帖,当点击提交时调用此函数
        /// </summary>
        /// <returns></returns>
        public ActionResult MakeExpertAnswer()
        {
            if (Session["userName"] == null)
            {
                return(RedirectToAction("LoginRemind", "Topic"));
            }
            LoginStatusConfig();//配置登录状态
            string expertUserName = Session["userName"].ToString();
            //检查用户是否为专家
            Rank_bll rank_bll = new Rank_bll();
            string   rankName = rank_bll.GetRankName(expertUserName); //获取用户的等级名称

            rankName = rankName.Trim();                               //去除字符串里的空格
            if (rankName != "专家")
            {
                return(Content("您不是专家"));
            }
            User_bll user_bll = new User_bll();
            int      expertId = user_bll.GetUserId(expertUserName);

            ////先把前端传回来的content内容保存为静态页面
            byte[] byteData = new byte[Request.InputStream.Length]; //定义一个字节数组保存前端传回来的Post数据全部数据
            Request.InputStream.Read(byteData, 0, byteData.Length); //将流读取到byteData,InputStream读取到的是http头里的主体数据
            //string postData = System.Text.Encoding.Default.GetString(byteData);//系统的默认编码为gb2312,不适用这种
            string postData = System.Text.Encoding.UTF8.GetString(byteData);

            string[] datas       = postData.Split('&');                                           //对前端传回来的数据进行分割,提取出文本框里的html数据
            string   contentData = datas[2].ToString();                                           //data[0]为变量名为content的内容

            contentData = contentData.Substring(contentData.IndexOf('=') + 1);                    //去除变量名,如content=aaa,只取出aaa
            contentData = Server.UrlDecode(contentData);                                          //对数据进行url解码,这个解码的操作要放在Split('&')之后,因为可能content里会含有&符号
            DateTime datetime     = DateTime.Now;
            string   fileName     = datetime.ToString("yyyyMMddHHmmss_ffff") + ".html";           //定义文件名fileName
            string   fileNamePath = Server.MapPath("~/StaticHtml/ConsultAnswerHtml/") + fileName; //物理路径

            while (System.IO.File.Exists(fileNamePath))                                           //先判断文件是否存在,若存在:更换文件名
            {
                datetime     = DateTime.Now;
                fileName     = datetime.ToString("yyyyMMddHHmmss_ffff") + ".html";
                fileNamePath = Server.MapPath("~/StaticHtml/ConsultAnswerHtml/") + fileName;
            }
            System.IO.FileStream fs = new System.IO.FileStream(fileNamePath, System.IO.FileMode.Create);
            byte[] contentBytes     = System.Text.Encoding.UTF8.GetBytes(contentData);
            //byte[] contentBytes = System.Text.Encoding.Default.GetBytes(contentData);
            fs.Write(contentBytes, 0, contentBytes.Length);
            fs.Close();//保存静态html成功

            ////将数据保存到数据库里tb_SpecialConsultAnswer  SpecialConsultAnswer_SpecialConsultId   SpecialConsultAnswer_HtmlUrl
            int                specialConsultId        = Convert.ToInt32(Request["hidSpecialConsultId"]); //用户特定咨询的id
            string             staticConsultAnswerHtml = "/StaticHtml/ConsultAnswerHtml/" + fileName;     //相对路径
            SpecialConsult_bll specialConsult_bll      = new SpecialConsult_bll();

            specialConsult_bll.InsertAnswerData(specialConsultId, expertId, staticConsultAnswerHtml, datetime);

            ////保存购买链接
            int specialConsultAnswer_Id = specialConsult_bll.GetConsultAnswerId(staticConsultAnswerHtml);
            int selectCount             = Convert.ToInt32(Request["selectCount"]);             //代表购买链接的条数
            Dictionary <string, string> selectClothUrlDic = new Dictionary <string, string>(); //服饰类型名:购买链接

            for (int i = 1; i <= selectCount; i++)
            {
                try
                {
                    selectClothUrlDic.Add(Request["selectCloth" + i].ToString(), Request["clothShoppingUrl" + i].ToString());
                }
                catch (Exception e)
                {
                    return(Content("<script type='text/javascript'>alert('请不要出入两种同样的服饰,请重新操作');window.location.href = '../Consult/ExpertAnswer';</script>"));
                }
            }
            SpecialConsultAnswerClothes_bll specialConsultAnswerClothes_bll = new SpecialConsultAnswerClothes_bll();

            specialConsultAnswerClothes_bll.InsertConsultAnswerClothes(specialConsultAnswer_Id, selectClothUrlDic);
            return(RedirectToAction("ConsultDetails", new { specialConsultId = specialConsultId, expertUserName = expertId }));
        }
Exemple #14
0
        public ActionResult Index()
        {
            if (Session["userName"] == null)
            {
                return(RedirectToAction("LoginRemind", "Topic"));
            }
            LoginStatusConfig();//配置登录状态

            People_bll user     = new People_bll();
            string     userName = Session["userName"].ToString();

            //检测姓名是否为空
            if (user.CheckRealName(userName) == null)
            {
                ViewData["realName"] = "请输入您的真实姓名";
            }
            else
            {
                ViewData["realName"] = user.CheckRealName(userName);
            }
            // 检测出生年月是否为空
            if (user.CheckBirthDate(userName) == null)
            {
                ViewData["BirthDate"] = "请输入您的出生年月";
            }
            else
            {
                ViewData["BirthDate"] = user.CheckBirthDate(userName);
            }
            //检测职业是否为空
            if (user.CheckProfession(userName) == null)
            {
                ViewData["Profession"] = "请输入您的职业";
            }
            else
            {
                ViewData["Profession"] = user.CheckProfession(userName);
            }
            // 检测手机号是否为空
            if (user.CheckPhoneNumber(userName) == null)
            {
                ViewData["PhoneNumber"] = "请输入您的手机号";
            }
            else
            {
                ViewData["PhoneNumber"] = user.CheckPhoneNumber(userName);
            }
            //检测学历是否为空
            if (user.CheckEducationalBackground(userName) == null)
            {
                ViewData["CheckEducationalBackground"] = "请输入您的手机号";
            }
            else
            {
                ViewData["CheckEducationalBackground"] = user.CheckEducationalBackground(userName);
            }
            //检测爱好是否为空
            if (user.CheckInterest(userName) == null)
            {
                ViewData["Interest"] = "请输入您的兴趣";
            }
            else
            {
                ViewData["Interest"] = user.CheckInterest(userName);
            }

            //检测肤色是否为空
            if (user.GetSkinColor(userName) == null)
            {
                ViewData["SkinColor"] = "请输入您的肤色";
            }
            else
            {
                ViewData["SkinColor"] = user.GetSkinColor(userName);
            }
            //检测体重是否为空
            if (user.GetWeight(userName) == -1)
            {
                ViewData["Weight"] = "请输入您的体重";
            }
            else
            {
                ViewData["Weight"] = user.GetWeight(userName);
            }

            //检测臀围是否为空
            if (user.GetTunWei(userName) == -1)
            {
                ViewData["TunWei"] = "请输入您的臀围";
            }
            else
            {
                ViewData["TunWei"] = user.GetTunWei(userName);
            }
            //检测胸围是否为空
            if (user.GetXiongWei(userName) == -1)
            {
                ViewData["XiongWei"] = "请输入您的胸围";
            }
            else
            {
                ViewData["XiongWei"] = user.GetXiongWei(userName);
            }
            //检测腰围是否为空
            if (user.GetYaoWei(userName) == -1)
            {
                ViewData["YaoWei"] = "请输入您的腰围";
            }
            else
            {
                ViewData["YaoWei"] = user.GetYaoWei(userName);
            }
            //检测身高是否为空
            if (user.GetHeight(userName) == -1)
            {
                ViewData["Height"] = "请输入您的身高";
            }
            else
            {
                ViewData["Height"] = user.GetHeight(userName);
            }
            //检测腿长是否为空
            if (user.GetThighGirth(userName) == -1)
            {
                ViewData["LegLength"] = "请输入您的腿长";
            }
            else
            {
                ViewData["LegLength"] = user.GetLegLength(userName);
            }
            //检测大腿围是否为空
            if (user.GetThighGirth(userName) == -1)
            {
                ViewData["ThighGirth"] = "请输入您的大腿围";
            }
            else
            {
                ViewData["ThighGirth"] = user.GetThighGirth(userName);
            }
            //检测小腿围是否为空
            if (user.GetCalfGirth(userName) == -1)
            {
                ViewData["CalfGirth"] = "请输入您的小腿围";
            }
            else
            {
                ViewData["CalfGirth"] = user.GetCalfGirth(userName);
            }
            //检测手臂围是否为空
            if (user.GetArmGirth(userName) == -1)
            {
                ViewData["ArmGirth"] = "请输入您的手臂围";
            }
            else
            {
                ViewData["ArmGirth"] = user.GetArmGirth(userName);
            }
            //检测手臂围是否为空
            if (user.GetQuanShenZhao(userName) == "1")
            {
                ViewData["QuanShenZhao"] = "请输入您的手臂围";
            }
            else
            {
                ViewData["QuanShenZhao"] = user.GetQuanShenZhao(userName);
            }

            //获取用户的CountUser_model 数据:点赞数 关注数 粉丝数 收藏数 提问数 回帖数 特定咨询数 等
            User_bll        user_bll        = new User_bll();
            int             userId          = user_bll.GetUserId(userName);
            CountUser_model countUser_model = user_bll.GetCountUser(userId);

            ViewData["countUser_model"] = countUser_model;
            return(View());
        }