コード例 #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(XHD.Model.ssn_question model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ssn_question(");
            strSql.Append("q_time,title,q_uid,q_name,type,content,score,sp_uid,sp_name,att_file,re_uid,re_name,move_time,status,tel,e_mail,receive_type,isdeleted)");
            strSql.Append(" values (");
            strSql.Append("@q_time,@title,@q_uid,@q_name,@type,@content,@score,@sp_uid,@sp_name,@att_file,@re_uid,@re_name,@move_time,@status,@tel,@e_mail,@receive_type,@isdeleted)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@q_time",       MySqlDbType.DateTime),
                new MySqlParameter("@title",        MySqlDbType.VarChar,   200),
                new MySqlParameter("@q_uid",        MySqlDbType.Int32,      11),
                new MySqlParameter("@q_name",       MySqlDbType.VarChar,    60),
                new MySqlParameter("@type",         MySqlDbType.Int32,      11),
                new MySqlParameter("@content",      MySqlDbType.Text),
                new MySqlParameter("@score",        MySqlDbType.Int32,       4),
                new MySqlParameter("@sp_uid",       MySqlDbType.VarChar,   500),
                new MySqlParameter("@sp_name",      MySqlDbType.VarChar,    60),
                new MySqlParameter("@att_file",     MySqlDbType.VarChar,   200),
                new MySqlParameter("@re_uid",       MySqlDbType.Int32,      11),
                new MySqlParameter("@re_name",      MySqlDbType.VarChar,    60),
                new MySqlParameter("@move_time",    MySqlDbType.DateTime),
                new MySqlParameter("@status",       MySqlDbType.Int32,       4),
                new MySqlParameter("@tel",          MySqlDbType.VarChar,    20),
                new MySqlParameter("@e_mail",       MySqlDbType.VarChar,    60),
                new MySqlParameter("@receive_type", MySqlDbType.Int32,       2),
                new MySqlParameter("@isdeleted",    MySqlDbType.Int32, 2)
            };
            parameters[0].Value  = model.q_time;
            parameters[1].Value  = model.title;
            parameters[2].Value  = model.q_uid;
            parameters[3].Value  = model.q_name;
            parameters[4].Value  = model.type;
            parameters[5].Value  = model.content;
            parameters[6].Value  = model.score;
            parameters[7].Value  = model.sp_uid;
            parameters[8].Value  = model.sp_name;
            parameters[9].Value  = model.att_file;
            parameters[10].Value = model.re_uid;
            parameters[11].Value = model.re_name;
            parameters[12].Value = model.move_time;
            parameters[13].Value = model.status;
            parameters[14].Value = model.tel;
            parameters[15].Value = model.e_mail;
            parameters[16].Value = model.receive_type;
            parameters[17].Value = model.isdeleted;

            int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #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);
         }
     }
 }
コード例 #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);
         }
     }
 }
コード例 #4
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);
                }
            }
            //跳转页面查看文章详情
            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();
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public XHD.Model.ssn_question GetModel(long id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id,q_time,title,q_uid,q_name,type,content,score,sp_uid,sp_name,att_file,re_uid,re_name,move_time,status,tel,e_mail,receive_type,isdeleted from ssn_question ");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@id", MySqlDbType.Int64)
            };
            parameters[0].Value = id;

            XHD.Model.ssn_question model = new XHD.Model.ssn_question();
            DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
コード例 #6
0
        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;
            }
        }
コード例 #7
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public XHD.Model.ssn_question DataRowToModel(DataRow row)
 {
     XHD.Model.ssn_question model = new XHD.Model.ssn_question();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = long.Parse(row["id"].ToString());
         }
         if (row["q_time"] != null && row["q_time"].ToString() != "")
         {
             model.q_time = DateTime.Parse(row["q_time"].ToString());
         }
         if (row["title"] != null)
         {
             model.title = row["title"].ToString();
         }
         if (row["q_uid"] != null && row["q_uid"].ToString() != "")
         {
             model.q_uid = int.Parse(row["q_uid"].ToString());
         }
         if (row["q_name"] != null)
         {
             model.q_name = row["q_name"].ToString();
         }
         if (row["type"] != null && row["type"].ToString() != "")
         {
             model.type = int.Parse(row["type"].ToString());
         }
         if (row["content"] != null)
         {
             model.content = row["content"].ToString();
         }
         if (row["score"] != null && row["score"].ToString() != "")
         {
             model.score = int.Parse(row["score"].ToString());
         }
         if (row["sp_uid"] != null)
         {
             model.sp_uid = row["sp_uid"].ToString();
         }
         if (row["sp_name"] != null)
         {
             model.sp_name = row["sp_name"].ToString();
         }
         if (row["att_file"] != null)
         {
             model.att_file = row["att_file"].ToString();
         }
         if (row["re_uid"] != null && row["re_uid"].ToString() != "")
         {
             model.re_uid = int.Parse(row["re_uid"].ToString());
         }
         if (row["re_name"] != null)
         {
             model.re_name = row["re_name"].ToString();
         }
         if (row["move_time"] != null && row["move_time"].ToString() != "")
         {
             model.move_time = DateTime.Parse(row["move_time"].ToString());
         }
         if (row["status"] != null && row["status"].ToString() != "")
         {
             model.status = int.Parse(row["status"].ToString());
         }
         if (row["tel"] != null)
         {
             model.tel = row["tel"].ToString();
         }
         if (row["e_mail"] != null)
         {
             model.e_mail = row["e_mail"].ToString();
         }
         if (row["receive_type"] != null && row["receive_type"].ToString() != "")
         {
             model.receive_type = int.Parse(row["receive_type"].ToString());
         }
         if (row["isdeleted"] != null && row["isdeleted"].ToString() != "")
         {
             model.receive_type = int.Parse(row["isdeleted"].ToString());
         }
     }
     return(model);
 }
コード例 #8
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(XHD.Model.ssn_question model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ssn_question set ");
            strSql.Append("q_time=@q_time,");
            strSql.Append("title=@title,");
            strSql.Append("q_uid=@q_uid,");
            strSql.Append("q_name=@q_name,");
            strSql.Append("type=@type,");
            strSql.Append("content=@content,");
            strSql.Append("score=@score,");
            strSql.Append("sp_uid=@sp_uid,");
            strSql.Append("sp_name=@sp_name,");
            strSql.Append("att_file=@att_file,");
            strSql.Append("re_uid=@re_uid,");
            strSql.Append("re_name=@re_name,");
            strSql.Append("move_time=@move_time,");
            strSql.Append("status=@status,");
            strSql.Append("tel=@tel,");
            strSql.Append("e_mail=@e_mail,");
            strSql.Append("receive_type=@receive_type,");
            strSql.Append("isdeleted=@isdeleted");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@q_time",       MySqlDbType.DateTime),
                new MySqlParameter("@title",        MySqlDbType.VarChar,   200),
                new MySqlParameter("@q_uid",        MySqlDbType.Int32,      11),
                new MySqlParameter("@q_name",       MySqlDbType.VarChar,    60),
                new MySqlParameter("@type",         MySqlDbType.Int32,      11),
                new MySqlParameter("@content",      MySqlDbType.Text),
                new MySqlParameter("@score",        MySqlDbType.Int32,       4),
                new MySqlParameter("@sp_uid",       MySqlDbType.VarChar,   500),
                new MySqlParameter("@sp_name",      MySqlDbType.VarChar,    60),
                new MySqlParameter("@att_file",     MySqlDbType.VarChar,   200),
                new MySqlParameter("@re_uid",       MySqlDbType.Int32,      11),
                new MySqlParameter("@re_name",      MySqlDbType.VarChar,    60),
                new MySqlParameter("@move_time",    MySqlDbType.DateTime),
                new MySqlParameter("@status",       MySqlDbType.Int32,       4),
                new MySqlParameter("@tel",          MySqlDbType.VarChar,    20),
                new MySqlParameter("@e_mail",       MySqlDbType.VarChar,    60),
                new MySqlParameter("@receive_type", MySqlDbType.Int32,       2),
                new MySqlParameter("@isdeleted",    MySqlDbType.Int32,       2),
                new MySqlParameter("@id",           MySqlDbType.Int64, 20)
            };
            parameters[0].Value  = model.q_time;
            parameters[1].Value  = model.title;
            parameters[2].Value  = model.q_uid;
            parameters[3].Value  = model.q_name;
            parameters[4].Value  = model.type;
            parameters[5].Value  = model.content;
            parameters[6].Value  = model.score;
            parameters[7].Value  = model.sp_uid;
            parameters[8].Value  = model.sp_name;
            parameters[9].Value  = model.att_file;
            parameters[10].Value = model.re_uid;
            parameters[11].Value = model.re_name;
            parameters[12].Value = model.move_time;
            parameters[13].Value = model.status;
            parameters[14].Value = model.tel;
            parameters[15].Value = model.e_mail;
            parameters[16].Value = model.receive_type;
            parameters[17].Value = model.isdeleted;
            parameters[18].Value = model.id;

            int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #9
0
        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
        }