Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            XHD.Model.hr_employee empModel = new GetEmpInfo().GetEmpModel(Request);
            XHD.BLL.ssn_question  question = new XHD.BLL.ssn_question();

            if (!IsPostBack)
            {
                if (!string.IsNullOrEmpty(empModel.title))
                {
                    this.Image1.ImageUrl = "http://172.178.1.211:8087/images/upload/portrait/" + empModel.title;
                    this.Image2.ImageUrl = "http://172.178.1.211:8087/images/upload/portrait/" + empModel.title;
                }
                else
                {
                    this.Image1.ImageUrl = "../file/user/unset.jpg";
                    this.Image2.ImageUrl = "../file/user/unset.jpg";
                }
                this.lblNmae.Text  = empModel.name;
                this.lblName1.Text = empModel.name;
                //this.lblSum.Text = "39";
                //this.lblUnread.Text = "您有26条未读消息";
                //this.lblReply.Text = "您有13条回复消息";
                this.lblWelcome.Text = "您好," + empModel.name + ",欢迎使用SSN问答中心。";
                DataSet ds   = question.GetQAInfo(empModel.ID);
                int     qNum = Convert.ToInt32(ds.Tables[0].Rows[0]["qNum"].ToString());
                int     aNum = Convert.ToInt32(ds.Tables[0].Rows[0]["aNum"].ToString());
                int     bNum = Convert.ToInt32(ds.Tables[0].Rows[0]["bNum"].ToString());
                int     gNum = Convert.ToInt32(ds.Tables[0].Rows[0]["gNum"].ToString());

                this.lblScore.Text    = "0";
                this.lblQuestion.Text = qNum.ToString();
                this.lblAnswer.Text   = aNum.ToString();

                if (aNum == 0 || bNum == 0)
                {
                    this.lblRate.Text = "0";
                }
                else
                {
                    double rate = bNum * 100.0 / aNum;
                    this.lblRate.Text = Math.Round(rate, 2).ToString() + "%";
                }

                if (gNum == 0 || bNum == 0)
                {
                    this.lblGood.Text = "0";
                }
                else
                {
                    double rate = gNum * 100.0 / bNum;
                    this.lblGood.Text = Math.Round(rate, 2).ToString() + "%";
                }
            }
        }
Esempio n. 2
0
 protected void repCustomer_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.CommandName == "delete")
     {
         int id = Convert.ToInt32(e.CommandArgument);
         XHD.Model.ssn_question question = new XHD.Model.ssn_question();
         question           = new XHD.BLL.ssn_question().GetModel(id);
         question.isdeleted = 1;
         bool isdeleted = new XHD.BLL.ssn_question().Update(question);
         if (isdeleted)
         {
             selectBind(selectVal, searchVal);
         }
     }
 }
Esempio n. 3
0
 protected void repCustomer_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     //if (e.CommandName == "update")
     //{
     //    //跳转至修改页面
     //}
     if (e.CommandName == "delete")
     {
         int id = Convert.ToInt32(e.CommandArgument);
         XHD.Model.ssn_question question = new XHD.Model.ssn_question();
         question           = new XHD.BLL.ssn_question().GetModel(id);
         question.isdeleted = 1;
         bool isdeleted = new XHD.BLL.ssn_question().Update(question);
         if (isdeleted)
         {
             selectBind(selectVal, searchVal);
         }
     }
     //跳转页面查看文章详情
     else if (e.CommandName == "showQuestion")
     {
         int id = Convert.ToInt32(e.CommandArgument);
         //Session["question_id"] = id.ToString();
         //Session["from"] = "question";
         //Server.Transfer("QuestionView.aspx");
         Response.Redirect("QuestionView.aspx?question_id=" + id + "&from=answer");
     }
     //问题换衣
     else if (e.CommandName == "transfer")
     {
         int id = Convert.ToInt32(e.CommandArgument);
         XHD.Model.ssn_question question = new XHD.Model.ssn_question();
         question        = new XHD.BLL.ssn_question().GetModel(id);
         question.sp_uid = "";
         bool tranfer = new XHD.BLL.ssn_question().Update(question);
         if (tranfer)
         {
             selectBind(selectVal, searchVal);
         }
     }
 }
        protected void repCustomer_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "delete")
            {
                int id = Convert.ToInt32(e.CommandArgument);
                XHD.Model.ssn_question question = new XHD.Model.ssn_question();
                question           = new XHD.BLL.ssn_question().GetModel(id);
                question.isdeleted = 1;
                bool isdeleted = new XHD.BLL.ssn_question().Update(question);
                if (isdeleted)
                {
                    selectBind(selectVal, searchVal);
                }
            }
            //跳转页面查看文章详情
            else if (e.CommandName == "showQuestion")
            {
                int id = Convert.ToInt32(e.CommandArgument);
                //Session["question_id"] = id.ToString();
                //Session["from"] = "question";
                //Server.Transfer("QuestionView.aspx");
                Response.Redirect("QuestionView.aspx?question_id=" + id + "&from=question");
            }
            else if (e.CommandName == "MakeEvaluat")
            {
                int id = Convert.ToInt32(e.CommandArgument);

                DataSet ds = new XHD.BLL.ssn_answer().GetList(" qid=" + id + " and is_best=1");
                if (ds.Tables[0].Rows.Count <= 0)
                {
                    return;
                }
                else
                {
                    this.evaluat.DataSource = ds;
                    this.evaluat.DataBind();
                }
            }
        }
        public static string PostUrl = ConfigurationManager.AppSettings["WebReference.Service.PostUrl"];//短信接口地址
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";


            HttpRequest          request = context.Request;
            JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();

            XHD.Model.hr_employee empModel = new GetEmpInfo().GetEmpModel(request);

            string json   = null;
            string Action = request["Action"];

            switch (Action)
            {
            case "action":
                bool   success          = false;
                string filesVal         = request["filesVal"];
                string txtQuestionTitle = request["txtQuestionTitle"];
                if (string.IsNullOrEmpty(txtQuestionTitle))
                {
                    var result = new { success = success, text = "问题标题不能为空!" };
                    json = javaScriptSerializer.Serialize(result);
                    context.Response.Write(json);
                }
                string selQestionType = request["selQestionType"];
                if (selQestionType == "-1")
                {
                    var result = new { success = success, text = "请选择问题类型!" };
                    json = javaScriptSerializer.Serialize(result);
                    context.Response.Write(json);
                }
                string txtQestionContent = request["txtQestionContent"];
                string telPhone          = request["telPhone"];
                string radTime           = request["radTime"];
                string txtEmail          = request["txtEmail"];
                string sp_uid            = request["sp_uid"];

                XHD.Model.ssn_question question = new XHD.Model.ssn_question();
                question.att_file = filesVal;
                question.content  = txtQestionContent;
                question.e_mail   = txtEmail;
                question.type     = Convert.ToInt32(selQestionType);
                question.title    = txtQuestionTitle;
                question.tel      = telPhone;
                question.q_time   = DateTime.Now;
                question.q_uid    = empModel.ID;
                question.q_name   = empModel.name;
                question.sp_uid   = sp_uid;
                success           = new XHD.BLL.ssn_question().Add(question);
                if (success)
                {
                    #region 发送短信
                    //string account = "cf_denny";
                    //string password = "******";//密码可以使用明文密码或使用32位MD5加密
                    //string mobile = telPhone;
                    //Random rad = new Random();
                    ////int mobile_code = rad.Next(1000, 10000);
                    ////string content = "您的验证码是:" + mobile_code + " 。请不要把验证码泄露给其他人。";
                    //int int1 = 1;
                    //string strcontent = "你最近吃饭了吗?";
                    //string content = "你好," + int1 + "需采购以下产品," + strcontent + "。 ";
                    ////Session["mobile"] = mobile;
                    ////Session["mobile_code"] = mobile_code;

                    //string postStrTpl = "account={0}&password={1}&mobile={2}&content={3}";

                    //UTF8Encoding encoding = new UTF8Encoding();
                    //byte[] postData = encoding.GetBytes(string.Format(postStrTpl, account, password, mobile, content));

                    //HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(PostUrl);
                    //myRequest.Method = "POST";
                    //myRequest.ContentType = "application/x-www-form-urlencoded";
                    //myRequest.ContentLength = postData.Length;

                    //Stream newStream = myRequest.GetRequestStream();
                    //// Send the data.
                    //newStream.Write(postData, 0, postData.Length);
                    //newStream.Flush();
                    //newStream.Close();

                    //HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
                    #region 提示是否发送成功,暂时只管发送不验证成功与否
                    //if (myResponse.StatusCode == HttpStatusCode.OK)
                    //{
                    //    StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8);

                    //    //Response.Write(reader.ReadToEnd());

                    //    string res = reader.ReadToEnd();
                    //    int len1 = res.IndexOf("</code>");
                    //    int len2 = res.IndexOf("<code>");
                    //    string code = res.Substring((len2 + 6), (len1 - len2 - 6));
                    //    //Response.Write(code);

                    //    int len3 = res.IndexOf("</msg>");
                    //    int len4 = res.IndexOf("<msg>");
                    //    string msg = res.Substring((len4 + 5), (len3 - len4 - 5));
                    //    context.Response.Write(msg);

                    //    //Response.End();

                    //}
                    //else
                    //{
                    //    //访问失败
                    //}
                    #endregion
                    #endregion
                    var dataResult = new { success = success, text = "提交成功!" };
                    json = javaScriptSerializer.Serialize(dataResult);
                }
                else
                {
                    var dataResult = new { success = success, text = "提交失败!" };
                    json = javaScriptSerializer.Serialize(dataResult);
                }
                context.Response.Write(json);
                break;

            case "deleteFile":
                string path      = string.Empty;
                string fileName  = request["fileName"];
                string targetDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory + "File/question");
                path = System.IO.Path.Combine(targetDir, fileName);
                File.Delete(path);
                context.Response.Write("删除成功!");
                break;

            case "getAboutQuestionList":
                //获得相关问题列表
                string strWhere    = "1=1";
                string strWhereArt = "1=1";
                XHD.BLL.ssn_question questionBll = new XHD.BLL.ssn_question();
                XHD.BLL.ssn_art      artBll      = new XHD.BLL.ssn_art();
                string txtQuestionTitleEx        = request["txtQuestionTitle"];
                if (!string.IsNullOrEmpty(txtQuestionTitleEx))
                {
                    List <string> strList  = new List <string>();
                    char[]        charList = txtQuestionTitleEx.ToArray();
                    for (int i = 0; i < charList.Length; i++)
                    {
                        if (i == 0)
                        {
                            strWhere    += " and title like '%" + charList[i] + "%'";
                            strWhereArt += " and Art_title like '%" + charList[i] + "%'";
                        }
                        else
                        {
                            strWhere    += " or title like '%" + charList[i] + "%'";
                            strWhereArt += " or Art_title like '%" + charList[i] + "%'";
                        }
                        if (!strList.Contains(charList[i].ToString()))
                        {
                            strList.Add(charList[i].ToString());
                        }
                    }
                    Segment seg = new Segment();
                    seg.InitWordDics();
                    seg.EnablePrefix = true;
                    seg.Separator    = " ";
                    string Seg_Title = seg.SegmentText(txtQuestionTitleEx, false).Trim();

                    string[] titleArray = Seg_Title.Split(' ');
                    for (int i = 0; i < titleArray.Length; i++)
                    {
                        strWhere    += " or title like '%" + titleArray[i] + "%'";
                        strWhereArt += " or Art_title like '%" + titleArray[i] + "%'";
                    }
                    List <XHD.Model.ssn_question> questionList = new List <XHD.Model.ssn_question>();
                    questionList = questionBll.GetModelList(strWhere);

                    List <XHD.Model.ssn_art> artList = new List <XHD.Model.ssn_art>();
                    artList = artBll.GetModelList(strWhereArt);

                    List <XHD.Model.question> modelList = new List <XHD.Model.question>();
                    foreach (XHD.Model.ssn_question item in questionList)
                    {
                        XHD.Model.question model = new XHD.Model.question();
                        model.id     = item.id;
                        model.title  = item.title;
                        model.q_time = item.q_time;
                        model.status = 1;
                        modelList.Add(model);
                    }
                    foreach (XHD.Model.ssn_art item in artList)
                    {
                        XHD.Model.question model = new XHD.Model.question();
                        model.id     = item.Id;
                        model.title  = item.Art_title;
                        model.q_time = item.Create_Date;
                        model.status = 2;
                        modelList.Add(model);
                    }
                    for (int i = 0; i < modelList.Count; i++)
                    {
                        string temStr = modelList[i].title.ToString();
                        for (int j = 0; j < strList.Count; j++)
                        {
                            if (temStr.Contains(strList[j]))
                            {
                                modelList[i].title = modelList[i].title.ToString().Replace(strList[j], "<span style='color:red' >" + strList[j] + "</span>");
                            }
                        }
                    }
                    var data = new { rows = modelList };
                    json = javaScriptSerializer.Serialize(data);
                    context.Response.Write(json);
                }
                break;

            case "getQuestionType":
                XHD.BLL.ssn_art_menu          questionTypeBll  = new XHD.BLL.ssn_art_menu();
                List <XHD.Model.ssn_art_menu> questionTyleList = new List <XHD.Model.ssn_art_menu>();
                string strQuestionTypeWhere = "1=1";
                strQuestionTypeWhere += " and App_id=1 and parentid<>0";
                questionTyleList      = questionTypeBll.GetModelList(strQuestionTypeWhere);
                var questionTypeData = new { rows = questionTyleList };
                json = javaScriptSerializer.Serialize(questionTypeData);
                context.Response.Write(json);
                break;

            default:
                string pathFile = string.Empty;
                try
                {
                    //获取客户端上传的文件集合
                    HttpFileCollection files = System.Web.HttpContext.Current.Request.Files;
                    //判断是否存在文件
                    if (files.Count > 0)
                    {
                        //获取文件集合中的第一个文件(每次只上传一个文件)
                        HttpPostedFile file = files[0];
                        //定义文件存放的目标路径
                        string targetDirFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory + "File/question");
                        if (!Directory.Exists(targetDirFile))
                        {
                            Directory.CreateDirectory(targetDirFile);
                        }
                        //组合成文件的完整路径
                        pathFile = System.IO.Path.Combine(targetDirFile, System.IO.Path.GetFileName(file.FileName));
                        //保存上传的文件到指定路径中
                        file.SaveAs(pathFile);
                        context.Response.Write(file.FileName);
                    }
                }
                catch
                {
                }
                break;
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest request = context.Request;

            XHD.BLL.ssn_answer         answer        = new XHD.BLL.ssn_answer();
            XHD.BLL.ssn_question       question      = new XHD.BLL.ssn_question();
            XHD.BLL.ssn_question_add   q_add         = new XHD.BLL.ssn_question_add();
            XHD.Model.ssn_answer       model         = new XHD.Model.ssn_answer();
            XHD.Model.ssn_question     questionmodel = new XHD.Model.ssn_question();
            XHD.Model.ssn_question_add modelAdd      = new XHD.Model.ssn_question_add();
            XHD.Model.hr_employee      empModel      = new GetEmpInfo().GetEmpModel(request);

            #region 问题回复
            if (request["Action"] == "q_reply")
            {
                string q_id      = request["q_id"];
                string reply_str = HttpUtility.UrlDecode(HttpUtility.UrlDecode(request["reply_str"]));
                if (!string.IsNullOrEmpty(q_id) && !string.IsNullOrEmpty(reply_str))
                {
                    model.answer_time    = DateTime.Now;
                    model.answer_content = reply_str;
                    model.answer_name    = empModel.name;
                    model.answer_uid     = empModel.ID;
                    model.qid            = Convert.ToInt64(q_id);
                    if (answer.Add(model))
                    {
                        //获取model对象
                        XHD.Model.ssn_question modelQ = question.GetModel(Convert.ToInt64(q_id));
                        //更改问题状态
                        modelQ.status = 1;
                        //更新到数据库
                        question.Update(modelQ);

                        string re_str = "{success:true,msg:\"回复完成\"}";
                        context.Response.Write(re_str);
                    }
                    else
                    {
                        string re_str = "{success:false,msg:\"回复失败,数据库操作异常!\"}";
                        context.Response.Write(re_str);
                    }
                }
                else
                {
                    string re_str = "{success:false,msg:\"回复失败,数据库操作异常!\"}";
                    context.Response.Write(re_str);
                }
            }
            #endregion

            #region 设置回复是否可用
            else if (request["Action"] == "permission_reply")
            {
                string q_id = request["q_id"];
                if (!string.IsNullOrEmpty(q_id))
                {
                    string  re_str = "{";
                    DataSet ds     = question.GetList("id=" + q_id);
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        //当问题为自己提问或已完成时,隐藏回答
                        if (ds.Tables[0].Rows[0]["sp_uid"].ToString() != ",all," && (ds.Tables[0].Rows[0]["sp_uid"].ToString().IndexOf(empModel.ID + ",") < 0) || ds.Tables[0].Rows[0]["status"].ToString() == "4" || ds.Tables[0].Rows[0]["isdeleted"].ToString() == "1" || ds.Tables[0].Rows[0]["status"].ToString() == "3")
                        {
                            re_str += "success:true,msg:\"不能回答!\"";
                        }
                        else if (empModel.ID.ToString() == ds.Tables[0].Rows[0]["q_uid"].ToString())
                        {
                            re_str += "success:true,msg:\"不能回答!\"";
                        }
                        else
                        {
                            re_str += "success:false,msg:\"通过!\"";
                        }
                    }
                    else
                    {
                        re_str += "success:false,msg:\"数据库操作异常!\"";
                    }
                    #region 判断是否含有最佳答案 如果已含有则不在显示“评最佳答案”按钮

                    DataSet dsAnswer = answer.GetList("qid=" + q_id + " and is_best=1");
                    if (dsAnswer.Tables[0].Rows.Count > 0)
                    {
                        re_str += ",flag:true,id:" + dsAnswer.Tables[0].Rows[0]["id"] + ",evaluatelevel:" + dsAnswer.Tables[0].Rows[0]["evaluatelevel"];
                    }
                    else
                    {
                        re_str += ",flag:false";
                    }
                    #endregion
                    re_str += "}";
                    context.Response.Write(re_str);
                }
            }
            #endregion

            #region 追答
            else if (request["Action"] == "add_reply")
            {
                string answer_id = request["curID"];
                string q_id      = request["q_id"];
                string curName   = request["curName"];
                string curUid    = request["curUid"];
                string content   = PageValidate.InputText(request["content"], Int32.MaxValue);

                if (!string.IsNullOrEmpty(content))
                {
                    modelAdd.answer_id     = Convert.ToInt32(answer_id);
                    modelAdd.answer_name   = empModel.name;
                    modelAdd.answer_uid    = empModel.ID;
                    modelAdd.content       = content;
                    modelAdd.operatortime  = DateTime.Now;
                    modelAdd.question_name = curName;
                    modelAdd.question_uid  = Convert.ToInt32(curUid);
                    modelAdd.type          = 0;
                    modelAdd.question_id   = Convert.ToInt32(q_id);

                    if (q_add.Add(modelAdd))
                    {
                        string re_str = "{success:true,msg:\"成功!\"}";
                        context.Response.Write(re_str);
                    }
                    else
                    {
                        string re_str = "{success:flase,msg:\"数据库操作异常!\"}";
                        context.Response.Write(re_str);
                    }
                }
                else
                {
                    string re_str = "{success:flase,msg:\"程序执行异常!\"}";
                    context.Response.Write(re_str);
                }
            }
            else if (request["Action"] == "makeBestAnswer")
            {
                bool success         = false;
                bool successquestion = false;
                model = answer.GetModel(Convert.ToInt64(request["id"]));
                if (model != null)
                {
                    using (TransactionScope transaction = new TransactionScope())
                    {
                        try
                        {
                            model.is_best        = 1;
                            success              = answer.Update(model);
                            questionmodel        = question.GetModel(model.qid.Value);
                            questionmodel.status = Convert.ToInt32(QuestionStatus.待评价);
                            successquestion      = question.Update(questionmodel);
                            transaction.Complete();
                        }
                        catch
                        {
                            transaction.Dispose();
                        }
                    }
                }
                var dataResult = new { succ = success, evaluatelevel = model.evaluatelevel };
                JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
                var json = javaScriptSerializer.Serialize(dataResult);
                context.Response.Write(json);

                //model = answer.GetModel(Convert.ToInt64(request["id"]));
                //if (model!=null)
                //{
                //    model.is_best = 1;
                //    success = answer.Update(model);

                //}
                //context.Response.Write(success);

                //model = answer.GetModel(Convert.ToInt64(request["id"]));
                //if (model != null)
                //{
                //    model.is_best = 1;
                //    success = answer.Update(model);

                //}
                //context.Response.Write(success);
            }
            #endregion


            else if (request["Action"] == "SubmitEvaluatVal")
            {
                bool   sucess          = false;
                bool   successquestion = false;
                string text            = string.Empty;
                string answerid        = request["answerid"];
                if (answerid == null)
                {
                    text = "没设最佳答案,不能评分,请设置最佳答案后再评分!";
                    context.Response.Write(text);
                    return;
                }
                string evaluatVal = request["evaluatVal"];
                XHD.Model.ssn_answer answermodel = new XHD.Model.ssn_answer();
                XHD.BLL.ssn_answer   answerBll   = new XHD.BLL.ssn_answer();
                using (TransactionScope transaction = new TransactionScope())
                {
                    try
                    {
                        answermodel = answerBll.GetModel(Convert.ToInt64(answerid));
                        if (answermodel != null)
                        {
                            if (answermodel.evaluatelevel > 0)
                            {
                                text = "已评价,不允许重复评价!";
                                context.Response.Write(text);
                                return;
                            }
                            answermodel.evaluatelevel = Convert.ToInt32(evaluatVal);
                        }
                        sucess = answerBll.Update(answermodel);
                        if (sucess)
                        {
                            questionmodel        = question.GetModel(answermodel.qid.Value);
                            questionmodel.status = Convert.ToInt32(QuestionStatus.已完成);
                            successquestion      = question.Update(questionmodel);
                            if (successquestion)
                            {
                                text = "提交成功!";
                            }
                        }
                        else
                        {
                            text = "提交失败!";
                        }
                        context.Response.Write(text);
                        transaction.Complete();
                    }
                    catch
                    {
                        transaction.Dispose();
                    }
                }
            }

            #region 问题转移
            else if (request["Action"] == "transfer")
            {
                string qid = request["qid"];
                string rid = request["rid"];
                if (!string.IsNullOrEmpty(qid) && !string.IsNullOrEmpty(rid))
                {
                    XHD.Model.ssn_question modelq = new XHD.Model.ssn_question();
                    modelq = question.GetModel(Convert.ToInt32(qid));
                    if (modelq.sp_uid != ",all,")
                    {
                        modelq.sp_uid    = rid;
                        modelq.move_time = DateTime.Now;
                        if (question.Update(modelq))
                        {
                            string re_str = "{success:true,msg:\"转移成功!\"}";
                            context.Response.Write(re_str);
                        }
                        else
                        {
                            string re_str = "{success:false,msg:\"数据库操作异常!\"}";
                            context.Response.Write(re_str);
                        }
                    }
                    else
                    {
                        string re_str = "{success:false,msg:\"公开问题无需转移!\"}";
                        context.Response.Write(re_str);
                    }
                }
            }
            #endregion
        }