Exemple #1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public XHD.Model.ssn_question_add DataRowToModel(DataRow row)
 {
     XHD.Model.ssn_question_add model = new XHD.Model.ssn_question_add();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = long.Parse(row["id"].ToString());
         }
         if (row["answer_id"] != null && row["answer_id"].ToString() != "")
         {
             model.answer_id = long.Parse(row["answer_id"].ToString());
         }
         if (row["content"] != null)
         {
             model.content = row["content"].ToString();
         }
         if (row["type"] != null && row["type"].ToString() != "")
         {
             model.type = int.Parse(row["type"].ToString());
         }
         if (row["answer_uid"] != null && row["answer_uid"].ToString() != "")
         {
             model.answer_uid = long.Parse(row["answer_uid"].ToString());
         }
         if (row["answer_name"] != null)
         {
             model.answer_name = row["answer_name"].ToString();
         }
         if (row["question_id"] != null && row["question_id"].ToString() != "")
         {
             model.question_id = long.Parse(row["question_id"].ToString());
         }
         if (row["question_uid"] != null && row["question_uid"].ToString() != "")
         {
             model.question_uid = long.Parse(row["question_uid"].ToString());
         }
         if (row["question_name"] != null)
         {
             model.question_name = row["question_name"].ToString();
         }
         if (row["answer_other_uid"] != null && row["answer_other_uid"].ToString() != "")
         {
             model.answer_other_uid = long.Parse(row["answer_other_uid"].ToString());
         }
         if (row["answer_other_name"] != null)
         {
             model.answer_other_name = row["answer_other_name"].ToString();
         }
         if (row["operatortime"] != null && row["operatortime"].ToString() != "")
         {
             model.operatortime = DateTime.Parse(row["operatortime"].ToString());
         }
         if (row["isdeleted"] != null && row["isdeleted"].ToString() != "")
         {
             model.type = int.Parse(row["isdeleted"].ToString());
         }
     }
     return(model);
 }
Exemple #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(XHD.Model.ssn_question_add model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ssn_question_add set ");
            strSql.Append("answer_id=@answer_id,");
            strSql.Append("content=@content,");
            strSql.Append("type=@type,");
            strSql.Append("answer_uid=@answer_uid,");
            strSql.Append("answer_name=@answer_name,");
            strSql.Append("question_id=@question_id,");
            strSql.Append("question_uid=@question_uid,");
            strSql.Append("question_name=@question_name,");
            strSql.Append("answer_other_uid=@answer_other_uid,");
            strSql.Append("answer_other_name=@answer_other_name,");
            strSql.Append("operatortime=@operatortime,");
            strSql.Append("isdeleted=@isdeleted");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@answer_id",         MySqlDbType.Int64,     20),
                new MySqlParameter("@content",           MySqlDbType.Text),
                new MySqlParameter("@type",              MySqlDbType.Int32,      4),
                new MySqlParameter("@answer_uid",        MySqlDbType.Int64,     20),
                new MySqlParameter("@answer_name",       MySqlDbType.VarChar,   60),
                new MySqlParameter("@question_id",       MySqlDbType.Int64,     20),
                new MySqlParameter("@question_uid",      MySqlDbType.Int64,     20),
                new MySqlParameter("@question_name",     MySqlDbType.VarChar,   60),
                new MySqlParameter("@answer_other_uid",  MySqlDbType.Int64,     20),
                new MySqlParameter("@answer_other_name", MySqlDbType.VarChar,   60),
                new MySqlParameter("@operatortime",      MySqlDbType.DateTime),
                new MySqlParameter("@isdeleted",         MySqlDbType.Int32,      2),
                new MySqlParameter("@id",                MySqlDbType.Int64, 20)
            };
            parameters[0].Value  = model.answer_id;
            parameters[1].Value  = model.content;
            parameters[2].Value  = model.type;
            parameters[3].Value  = model.answer_uid;
            parameters[4].Value  = model.answer_name;
            parameters[5].Value  = model.question_id;
            parameters[6].Value  = model.question_uid;
            parameters[7].Value  = model.question_name;
            parameters[8].Value  = model.answer_other_uid;
            parameters[9].Value  = model.answer_other_name;
            parameters[10].Value = model.operatortime;
            parameters[11].Value = model.isdeleted;
            parameters[12].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(XHD.Model.ssn_question_add model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ssn_question_add(");
            strSql.Append("answer_id,content,type,answer_uid,answer_name,question_id,question_uid,question_name,answer_other_uid,answer_other_name,operatortime,isdeleted)");
            strSql.Append(" values (");
            strSql.Append("@answer_id,@content,@type,@answer_uid,@answer_name,@question_id,@question_uid,@question_name,@answer_other_uid,@answer_other_name,@operatortime,@isdeleted)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@answer_id",         MySqlDbType.Int64,     20),
                new MySqlParameter("@content",           MySqlDbType.Text),
                new MySqlParameter("@type",              MySqlDbType.Int32,      4),
                new MySqlParameter("@answer_uid",        MySqlDbType.Int64,     20),
                new MySqlParameter("@answer_name",       MySqlDbType.VarChar,   60),
                new MySqlParameter("@question_id",       MySqlDbType.Int64,     20),
                new MySqlParameter("@question_uid",      MySqlDbType.Int64,     20),
                new MySqlParameter("@question_name",     MySqlDbType.VarChar,   60),
                new MySqlParameter("@answer_other_uid",  MySqlDbType.Int64,     20),
                new MySqlParameter("@answer_other_name", MySqlDbType.VarChar,   60),
                new MySqlParameter("@operatortime",      MySqlDbType.DateTime),
                new MySqlParameter("@isdeleted",         MySqlDbType.Int32, 2)
            };
            parameters[0].Value  = model.answer_id;
            parameters[1].Value  = model.content;
            parameters[2].Value  = model.type;
            parameters[3].Value  = model.answer_uid;
            parameters[4].Value  = model.answer_name;
            parameters[5].Value  = model.question_id;
            parameters[6].Value  = model.question_uid;
            parameters[7].Value  = model.question_name;
            parameters[8].Value  = model.answer_other_uid;
            parameters[9].Value  = model.answer_other_name;
            parameters[10].Value = model.operatortime;
            parameters[11].Value = model.isdeleted;
            int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public XHD.Model.ssn_question_add GetModel(long id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id,answer_id,content,type,answer_uid,answer_name,question_id,question_uid,question_name,answer_other_uid,answer_other_name,operatortime,isdeleted from ssn_question_add ");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@id", MySqlDbType.Int64)
            };
            parameters[0].Value = id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
        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
        }