| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Data;
- using HySoft.Common;
- namespace HySoft.BaseCallCenter.Web.askmanage.ajax
- {
- /// <summary>
- /// pageritems 的摘要说明
- /// </summary>
- public class pageritems : IHttpHandler
- {
- public void ProcessRequest(HttpContext context)
- {
- context.Response.ContentType = "text/plain";
- string action = CommonRequest.GetQueryString("action");
- switch (action)
- {
- case "getlist":
- context.Response.Write(LoadList(context));
- break;
- case "add":
- context.Response.Write(Add(context));
- break;
- case "addall":
- context.Response.Write(AddAll(context));
- break;
- case "modify":
- context.Response.Write(Modify(context));
- break;
- case "move":
- context.Response.Write(Move(context));
- break;
- case "delete":
- context.Response.Write(Delete(context));
- break;
- case "deleteall":
- context.Response.Write(DeleteAll(context));
- break;
- case "gettemplist":
- context.Response.Write(LoadTempList(context));
- break;
- case "addtemp":
- context.Response.Write(AddTemp(context));
- break;
- case "addalltemp":
- context.Response.Write(AddAllTemp(context));
- break;
- case "modifytemp":
- context.Response.Write(ModifyTemp(context));
- break;
- case "movetemp":
- context.Response.Write(MoveTemp(context));
- break;
- case "deletetemp":
- context.Response.Write(DeleteTemp(context));
- break;
- case "deletealltemp":
- context.Response.Write(DeleteAllTemp(context));
- break;
- }
- }
- #region 选项数据操作
- #region 获取数据
- private string LoadList(HttpContext context)
- {
- string res = "";
- DataTable dt = new DataTable();
- string sql = " ";
- try
- {
- string strpageindex = context.Request.Params["page"];
- int pageindex = 1;
- string strpagesize = context.Request.Params["pagesize"];
- int pagesize = 10;
- string questionid = "0";
- try
- {
- questionid = context.Request.Params["questionid"];
- if (questionid.Trim() != "")
- {
- sql = " and F_QuestionId=" + questionid + " ";
- }
- }
- catch
- { }
- if (strpageindex.Trim() != "")
- {
- try
- {
- pageindex = Convert.ToInt32(strpageindex);
- }
- catch
- { }
- }
- if (strpagesize.Trim() != "")
- {
- try
- {
- pagesize = Convert.ToInt32(strpagesize);
- }
- catch
- { }
- }
- int recordCount = 0;
- Model.PageData<Model.T_Ask_QuestionItems> pageModel = new Model.PageData<Model.T_Ask_QuestionItems>();
- dt = BLL.PagerBLL.GetListPager(
- "T_Ask_QuestionItems",
- "F_ItemId",
- "*",
- " " + sql,
- "ORDER BY F_Sort ",
- pagesize,
- pageindex,
- true,
- out recordCount);
- System.Collections.Generic.List<Model.T_Ask_QuestionItems> modelList = new BLL.T_Ask_QuestionItems().DataTableToList(dt);
- pageModel.Rows = modelList;
- pageModel.Total = recordCount;
- System.Runtime.Serialization.Json.DataContractJsonSerializer serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(Model.PageData<Model.T_Ask_QuestionItems>));
- using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
- {
- //JSON序列化
- serializer.WriteObject(stream, pageModel);
- res = System.Text.Encoding.UTF8.GetString(stream.ToArray());
- }
- }
- catch (Exception err)
- {
- //res = err.ToString();
- }
- finally
- {
- dt.Clear();
- dt.Dispose();
- }
- return res;
- }
- #endregion
- #region 添加数据
- private string Add(HttpContext context)
- {
- string res = "error";
- try
- {
- Model.T_Ask_PagerItems itemmodel = new Model.T_Ask_PagerItems();
- int pagerid = 0;
- try
- {
- pagerid = Convert.ToInt32(context.Request.Params["id"]);
- }
- catch
- { }
- itemmodel.F_PagerId = pagerid;
- int questionid = 0;
- try
- {
- questionid = Convert.ToInt32(context.Request.Params["questionid"]);
- }
- catch
- { }
- itemmodel.F_QuestionId = questionid;
- string sort = "0";
- try
- {
- sort = context.Request.Params["sort"];
- if (sort.Trim() != "")
- {
- itemmodel.F_Sort = Convert.ToInt32(sort) + 1;
- }
- }
- catch
- { }
- int itemid = new BLL.T_Ask_PagerItems().Add(itemmodel);
- if (itemid > 0)
- {
- res = "success";
- }
- }
- catch
- { }
- return res;
- }
- #endregion
- #region 批量添加数据
- private string AddAll(HttpContext context)
- {
- string res = "error";
- try
- {
- string arr = context.Request.Params["arrid"];
- string[] arrid = arr.Split(',');
- string sort = "0";
- int intsort = 0;
- try
- {
- sort = context.Request.Params["sort"];
- intsort = Convert.ToInt32(sort) + 1;
- }
- catch
- { }
- foreach (string squestionid in arrid)
- {
- Model.T_Ask_PagerItems model = new Model.T_Ask_PagerItems();
- int pagerid = 0;
- try
- {
- pagerid = Convert.ToInt32(context.Request.Params["id"]);
- }
- catch
- { }
- model.F_PagerId = pagerid;
- int questionid = 0;
- try
- {
- questionid = Convert.ToInt32(squestionid);
- }
- catch
- { }
- model.F_QuestionId = questionid;
- try
- {
- if (sort.Trim() != "")
- {
- model.F_Sort = intsort;
- intsort++;
- }
- }
- catch
- { }
- int i = new BLL.T_Ask_PagerItems().Add(model);
- if (i > 0)
- {
- res = "success";
- }
- }
- }
- catch
- { }
- return res;
- }
- #endregion
- #region 修改数据
- private string Modify(HttpContext context)
- {
- string res = "error";
- try
- {
- Model.T_Ask_PagerItems model = new BLL.T_Ask_PagerItems().GetModel(Convert.ToInt32(context.Request.Params["itemid"]));
- //model.F_ItemName = context.Request.Params["itemvalue"];
- if (new BLL.T_Ask_PagerItems().Update(model))
- {
- res = "success";
- }
- }
- catch
- { }
- return res;
- }
- #endregion
- #region 移动排序
- private string Move(HttpContext context)
- {
- string res = "error";
- DataTable dt = new DataTable();
- try
- {
- //"ajax/pageritems.ashx?action=" + optaction + "&pagerid=" + id + "&itemid=" + itemid + "&sort=" + ssort + "&movetype=" + type + "&timeno=" + timeno
- string sql = "";
- string order = "";
- int sort = Convert.ToInt32(context.Request.Params["sort"]);
- int itemid = Convert.ToInt32(context.Request.Params["itemid"]);
- int pagerid = Convert.ToInt32(context.Request.Params["pagerid"]);
- sql += " F_PagerId=" + pagerid + " ";
- int newsort = 0;
- int newitemid = 0;
- if (context.Request.Params["movetype"] == "-1")
- {
- sql += " and F_Sort<" + sort.ToString();
- order = " order by F_Sort desc";
- }
- else
- {
- sql += " and F_Sort>" + sort.ToString();
- order = " order by F_Sort ";
- }
- dt = new BLL.T_Ask_PagerItems().GetList(sql + " " + order).Tables[0];
- if (dt.Rows.Count > 0)
- {
- newitemid = Convert.ToInt32(dt.Rows[0]["F_ItemId"].ToString());
- newsort = Convert.ToInt32(dt.Rows[0]["F_Sort"].ToString());
- }
- Model.T_Ask_PagerItems newmodel = new BLL.T_Ask_PagerItems().GetModel(newitemid);
- newmodel.F_Sort = sort;
- if (new BLL.T_Ask_PagerItems().Update(newmodel))
- {
- res = "success";
- }
- Model.T_Ask_PagerItems model = new BLL.T_Ask_PagerItems().GetModel(itemid);
- model.F_Sort = newsort;
- if (new BLL.T_Ask_PagerItems().Update(model))
- {
- res = "success";
- }
- }
- catch
- { }
- finally
- {
- dt.Clear();
- dt.Dispose();
- }
- return res;
- }
- #endregion
- #region 删除数据
- private string Delete(HttpContext context)
- {
- string res = "error";
- try
- {
- if (new BLL.T_Ask_PagerItems().Delete(Convert.ToInt32(context.Request.Params["itemid"])))
- {
- res = "success";
- }
- }
- catch
- { }
- return res;
- }
- #endregion
- #region 批量删除数据
- private string DeleteAll(HttpContext context)
- {
- string res = "error";
- try
- {
- string arr = context.Request.Params["arrid"];
- string[] arrid = arr.Split(',');
- foreach (string itemid in arrid)
- {
- if (new BLL.T_Ask_PagerItems().Delete(Convert.ToInt32(itemid)))
- {
- res = "success";
- }
- }
- }
- catch
- { }
- return res;
- }
- #endregion
- #endregion
- #region 选项临时数据操作
- #region 获取临时数据
- private string LoadTempList(HttpContext context)
- {
- string res = "";
-
- return res;
- }
- #endregion
- #region 添加临时数据
- private string AddTemp(HttpContext context)
- {
- string res = "error";
- try
- {
- Model.T_Sys_TempItems model = new Model.T_Sys_TempItems();
- model.F_TempName = "T_Ask_PagerItems";
- string userid = "0";
- try
- {
- userid = context.Request.Params["userid"];
- if (userid.Trim() != "")
- {
- model.F_UserId = Convert.ToInt32(userid);
- }
- }
- catch
- { }
- string questionid = "0";
- try
- {
- questionid = context.Request.Params["questionid"];
- if (questionid.Trim() != "")
- {
- model.ExpandIntField1 = Convert.ToInt32(questionid);
- }
- }
- catch
- { }
- string sort = "0";
- try
- {
- sort = context.Request.Params["sort"];
- if (sort.Trim() != "")
- {
- model.ExpandIntField3 = Convert.ToInt32(sort) + 1;
- }
- }
- catch
- { }
- int i = new BLL.T_Sys_TempItems().Add(model);
- if (i > 0)
- {
- res = "success";
- }
- }
- catch
- { }
- return res;
- }
- #endregion
- #region 添加临时数据
- private string AddAllTemp(HttpContext context)
- {
- string res = "error";
- try
- {
- string arr = context.Request.Params["arrid"];
- string[] arrid = arr.Split(',');
- string sort = "0";
- int intsort = 0;
- try
- {
- sort = context.Request.Params["sort"];
- intsort = Convert.ToInt32(sort) + 1;
- }
- catch
- { }
- foreach (string questionid in arrid)
- {
- Model.T_Sys_TempItems model = new Model.T_Sys_TempItems();
- model.F_TempName = "T_Ask_PagerItems";
- string userid = "0";
- try
- {
- userid = context.Request.Params["userid"];
- if (userid.Trim() != "")
- {
- model.F_UserId = Convert.ToInt32(userid);
- }
- }
- catch
- { }
- try
- {
- model.ExpandIntField1 = Convert.ToInt32(questionid);
- }
- catch
- { }
- try
- {
- if (sort.Trim() != "")
- {
- model.ExpandIntField3 = intsort;
- intsort++;
- }
- }
- catch
- { }
- int i = new BLL.T_Sys_TempItems().Add(model);
- if (i > 0)
- {
- res = "success";
- }
- }
- }
- catch
- { }
- return res;
- }
- #endregion
- #region 修改临时数据
- private string ModifyTemp(HttpContext context)
- {
- string res = "error";
- try
- {
- Model.T_Sys_TempItems model = new BLL.T_Sys_TempItems().GetModel(Convert.ToInt32(context.Request.Params["itemid"]));
- model.ExpandVchField1 = context.Request.Params["itemvalue"];
- if (new BLL.T_Sys_TempItems().Update(model))
- {
- res = "success";
- }
- }
- catch
- { }
- return res;
- }
- #endregion
- #region 移动排序
- private string MoveTemp(HttpContext context)
- {
- string res = "error";
- DataTable dt = new DataTable();
- try
- {
- //ajax/questionitems.ashx?action=" + optaction + "&questionid=" + id + "&itemid=" + itemid+"&sort="+sort+"&movetype="+type
- string sql = "";
- string order = "";
- int sort = Convert.ToInt32(context.Request.Params["sort"]);
- int itemid = Convert.ToInt32(context.Request.Params["itemid"]);
- int newsort = 0;
- int newitemid = 0;
- if (context.Request.Params["movetype"] == "-1")
- {
- sql = " ExpandIntField3<" + sort.ToString();
- order = " order by ExpandIntField3 desc";
- }
- else
- {
- sql = " ExpandIntField3>" + sort.ToString();
- order = " order by ExpandIntField3 ";
- }
- dt = new BLL.T_Sys_TempItems().GetList(sql + " " + order).Tables[0];
- if (dt.Rows.Count > 0)
- {
- newitemid = Convert.ToInt32(dt.Rows[0]["F_Id"].ToString());
- newsort = Convert.ToInt32(dt.Rows[0]["ExpandIntField3"].ToString());
- }
- Model.T_Sys_TempItems newmodel = new BLL.T_Sys_TempItems().GetModel(newitemid);
- newmodel.ExpandIntField3 = sort;
- if (new BLL.T_Sys_TempItems().Update(newmodel))
- {
- res = "success";
- }
- Model.T_Sys_TempItems model = new BLL.T_Sys_TempItems().GetModel(itemid);
- model.ExpandIntField3 = newsort;
- if (new BLL.T_Sys_TempItems().Update(model))
- {
- res = "success";
- }
- }
- catch
- { }
- finally
- {
- dt.Clear();
- dt.Dispose();
- }
- return res;
- }
- #endregion
- #region 删除临时数据
- private string DeleteTemp(HttpContext context)
- {
- string res = "error";
- try
- {
- if (new BLL.T_Sys_TempItems().Delete(Convert.ToInt32(context.Request.Params["itemid"])))
- {
- res = "success";
- }
- }
- catch
- { }
- return res;
- }
- #endregion
- #region 删除临时数据
- private string DeleteAllTemp(HttpContext context)
- {
- string res = "error";
- try
- {
- string arr = context.Request.Params["arrid"];
- string[] arrid = arr.Split(',');
- foreach (string itemid in arrid)
- {
- if (new BLL.T_Sys_TempItems().Delete(Convert.ToInt32(itemid)))
- {
- res = "success";
- }
- }
- }
- catch
- { }
- return res;
- }
- #endregion
- #endregion
- public bool IsReusable
- {
- get
- {
- return false;
- }
- }
- }
- }
|