You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
464 lines
19 KiB
464 lines
19 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Data;
|
|
using System.Text;
|
|
using System.Collections;
|
|
using System.Reflection;
|
|
using System.Web.Script.Serialization;
|
|
using FangYar.Model;
|
|
using FangYar.BLL;
|
|
using Newtonsoft.Json.Linq;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace FangYar.WebUI.ashx
|
|
{
|
|
/// <summary>
|
|
/// OaLeaveHandler 的摘要说明
|
|
/// </summary>
|
|
public class OaRecipeCommentHandler : IHttpHandler
|
|
{
|
|
private FangYar.BLL.OA.OA_RECIPE_COMMENT bll = new FangYar.BLL.OA.OA_RECIPE_COMMENT();
|
|
public void ProcessRequest(HttpContext context)
|
|
{
|
|
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Other, "食谱评论操作请求", "");
|
|
|
|
context.Response.ContentType = "text/plain";
|
|
string action = context.Request.Params["Action"];
|
|
string returnstr = "";
|
|
|
|
switch (action)
|
|
{
|
|
case "List":
|
|
returnstr = GetList(context);
|
|
break;
|
|
case "CommentListByRecordID":
|
|
returnstr = GetCommentListByRecordID(context);
|
|
break;
|
|
case "Add":
|
|
returnstr = AddRecipe(context);
|
|
break;
|
|
case "Edit":
|
|
returnstr = EditRecipe(context);
|
|
break;
|
|
case "GetCommentSingleList":
|
|
returnstr = GetCommentSingleList(context);
|
|
break;
|
|
case "GetCommentSingleListByRF":
|
|
returnstr = GetCommentSingleListByRF(context);
|
|
break;
|
|
case "SimpleRecipeAddComments":
|
|
returnstr = SimpleRecipeAddComments(context);
|
|
break;
|
|
case "SimpleRecipeEditComments":
|
|
returnstr = SimpleRecipeEditComments(context);
|
|
break;
|
|
case "GetSimpleRecipeComments":
|
|
returnstr = GetSimpleRecipeComments(context);
|
|
break;
|
|
}
|
|
|
|
context.Response.Write(returnstr);
|
|
}
|
|
|
|
//查询
|
|
private string GetList(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string ORG_ID = context.Request.Params["OrgId"];
|
|
string keyword = context.Request.Params["keywords"];
|
|
string page = context.Request.Params["page"];
|
|
string limit = context.Request.Params["limit"];
|
|
|
|
int pageIndex = 1;
|
|
int pageSize = 10;
|
|
int startIndex = 0;
|
|
int endIndex = 10;
|
|
if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); }
|
|
if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); }
|
|
startIndex = (pageIndex - 1) * pageSize;
|
|
endIndex = pageSize;
|
|
|
|
string where = "";
|
|
if (!string.IsNullOrEmpty(ORG_ID))
|
|
{
|
|
where += " ORG_ID = '" + ORG_ID + "' ";
|
|
}
|
|
else
|
|
{
|
|
return "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
}
|
|
if (!string.IsNullOrEmpty(keyword))
|
|
{
|
|
where += " and DES like '%" + keyword + "%' ";
|
|
}
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
int count = bll.GetRecordCount(where);
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
DataTable dt = bll.GetListByPage(where, "STATE , NAME ", startIndex, endIndex).Tables[0];
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(dt);
|
|
}
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "食谱评论操作请求", "查询异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "食谱评论操作请求", "查询");
|
|
return returnstr;
|
|
}
|
|
|
|
//查询往期食谱
|
|
private string GetCommentListByRecordID(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string RecordID = context.Request.Params["RecordID"];
|
|
string U_ID = context.Request.Params["U_ID"];
|
|
returnstr += "{\"code\":200,\"data\":";
|
|
DataTable dt = bll.GetCommentListByRecordID(RecordID, U_ID);
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(dt);
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "食谱评论操作请求", "查询往期食谱异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "食谱评论操作请求", "查询往期食谱");
|
|
return returnstr;
|
|
}
|
|
|
|
//添加食谱评论
|
|
private string AddRecipe(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string ID = Guid.NewGuid().ToString("N");
|
|
string RECORD_ID = context.Request.Params["RECORD_ID"];
|
|
//string A_DATE = context.Request.Params["A_DATE"];
|
|
string DES = context.Request.Params["DES"];
|
|
string U_ID = context.Request.Params["U_ID"];
|
|
string U_NAME = context.Request.Params["U_NAME"];
|
|
string ORG_ID = context.Request.Params["ORG_ID"];
|
|
string DICDETAILID = context.Request.Params["DICDETAILID"]; //菜品ID
|
|
string MAKETIME = context.Request.Params["MAKETIME"]; //菜品时间
|
|
|
|
|
|
FangYar.Model.OA.OA_RECIPE_COMMENT model = new Model.OA.OA_RECIPE_COMMENT();
|
|
model.ID = ID;
|
|
model.RECORD_ID = RECORD_ID;
|
|
model.A_DATE = DateTime.Now.ToString();
|
|
model.U_ID = U_ID;
|
|
model.U_NAME = U_NAME;
|
|
model.DES = DES;
|
|
model.ORG_ID = ORG_ID;
|
|
model.EXTEND1 = DICDETAILID;
|
|
model.EXTEND2 = MAKETIME;
|
|
|
|
if (bll.Add(model))
|
|
{
|
|
code = 1;
|
|
msg = "添加成功";
|
|
}
|
|
else
|
|
{
|
|
code = 0;
|
|
msg = "添加失败";
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = "添加失败:" + e.Message;
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "食谱评论操作请求", "添加食谱评论异常:" + e);
|
|
}
|
|
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "食谱评论操作请求", "添加食谱评论");
|
|
return returnstr;
|
|
}
|
|
|
|
//修改食谱评论
|
|
private string EditRecipe(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string ID = context.Request.Params["ID"];
|
|
string RECORD_ID = context.Request.Params["RECORD_ID"];
|
|
//string A_DATE = context.Request.Params["A_DATE"];
|
|
string DES = context.Request.Params["DES"];
|
|
string U_ID = context.Request.Params["U_ID"];
|
|
string U_NAME = context.Request.Params["U_NAME"];
|
|
string ORG_ID = context.Request.Params["ORG_ID"];
|
|
string DICDETAILID = context.Request.Params["DICDETAILID"]; //菜品ID
|
|
string MAKETIME = context.Request.Params["MAKETIME"]; //菜品时间
|
|
|
|
|
|
FangYar.Model.OA.OA_RECIPE_COMMENT model = new Model.OA.OA_RECIPE_COMMENT();
|
|
model.ID = ID;
|
|
model.RECORD_ID = RECORD_ID;
|
|
model.A_DATE = DateTime.Now.ToString();
|
|
model.U_ID = U_ID;
|
|
model.U_NAME = U_NAME;
|
|
model.DES = DES;
|
|
model.ORG_ID = ORG_ID;
|
|
model.EXTEND1 = DICDETAILID;
|
|
model.EXTEND2 = MAKETIME;
|
|
|
|
if (bll.Update(model))
|
|
{
|
|
code = 1;
|
|
msg = "修改成功";
|
|
}
|
|
else
|
|
{
|
|
code = 0;
|
|
msg = "修改失败";
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = "修改失败:" + e.Message;
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "食谱评论操作请求", "修改食谱评论异常:" + e);
|
|
}
|
|
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Update, "食谱评论操作请求", "修改食谱评论");
|
|
return returnstr;
|
|
}
|
|
|
|
//查询获取某天菜品评价
|
|
private string GetCommentSingleList(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string RecordID = context.Request.Params["RecordID"];
|
|
string EXTEND1 = context.Request.Params["DICDETAILID"];
|
|
string EXTEND2 = context.Request.Params["MAKETIME"];
|
|
string page = context.Request.Params["page"];
|
|
string limit = context.Request.Params["limit"];
|
|
|
|
int pageIndex = 1;
|
|
int pageSize = 10;
|
|
if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); }
|
|
if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); }
|
|
int endnum = pageSize;
|
|
int startnum = (pageIndex - 1) * pageSize;
|
|
|
|
string strWhere = " RECORD_ID = '" + RecordID + "' and EXTEND1 = '" + EXTEND1 + "' and EXTEND2 = '" + EXTEND2 + "'";
|
|
|
|
returnstr += "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":";
|
|
DataTable dt = bll.GetListByPage(strWhere, " A_DATE desc", startnum, endnum).Tables[0];
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(dt);
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":-1,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "食谱评论操作请求", "查询获取某天菜品评价异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "食谱评论操作请求", "查询获取某天菜品评价");
|
|
return returnstr;
|
|
}
|
|
//查询获取某天菜品评价(不分页)
|
|
private string GetCommentSingleListByRF(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string RecordID = context.Request.Params["RecordID"];
|
|
string EXTEND1 = context.Request.Params["DICDETAILID"];
|
|
|
|
|
|
|
|
returnstr += "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":";
|
|
DataTable dt = bll.GetCommentListByRFID(RecordID, EXTEND1);
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(dt);
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":-1,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "食谱评论操作请求", "查询获取某天菜品评价异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "食谱评论操作请求", "查询获取某天菜品评价");
|
|
return returnstr;
|
|
}
|
|
/// <summary>
|
|
///获取评论
|
|
/// </summary>
|
|
/// <param name="context"></param>
|
|
/// <returns></returns>
|
|
private string GetSimpleRecipeComments(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string OrgId = context.Request.Params["OrgId"]?.Trim();
|
|
string RecordID = context.Request.Params["RecordID"]?.Trim();
|
|
string Page = context.Request.Params["Page"]?.Trim();
|
|
string Limit = context.Request.Params["Limit"]?.Trim();
|
|
if (string.IsNullOrEmpty(OrgId))
|
|
{
|
|
return "{\"code\":-1,\"msg\":\"请求异常,请联系平台管理员。\",\"error\":\"OrgId参数不能为空!\",\"count\":0,\"data\":[]}";
|
|
}
|
|
|
|
int pageIndex = 1;
|
|
int pageSize = 10;
|
|
if (!string.IsNullOrEmpty(Page)) { pageIndex = int.Parse(Page); }
|
|
if (!string.IsNullOrEmpty(Limit)) { pageSize = int.Parse(Limit); }
|
|
int endnum = pageIndex * pageSize;
|
|
int startnum = (pageIndex - 1) * pageSize;
|
|
|
|
string strWhere = " ORG_ID = '" + OrgId + "' AND RECORD_ID = '" + RecordID + "'";
|
|
returnstr += "{\"code\":1,\"count\":0,\"data\":";
|
|
DataTable dt = bll.GetListByPage(strWhere, " STR_TO_DATE(A_DATE, '%Y-%m-%d %H:%i:%s') desc", startnum, endnum).Tables[0];
|
|
returnstr += Common.JsonHelper.ToJson(dt);
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "食谱评论操作请求", "获取评论异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "食谱评论操作请求", "获取评论");
|
|
return returnstr;
|
|
}
|
|
|
|
//添加食谱评论
|
|
private string SimpleRecipeAddComments(HttpContext context)
|
|
{
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string ID = Guid.NewGuid().ToString("N");
|
|
string RecipeId = context.Request.Params["RecipeId"];
|
|
string Des = context.Request.Params["Des"];
|
|
string UserId = context.Request.Params["UserId"];
|
|
string UserName = context.Request.Params["UserName"];
|
|
string OrgId = context.Request.Params["OrgId"];
|
|
//string DICDETAILID = context.Request.Params["DICDETAILID"]; //菜品ID
|
|
//string MAKETIME = context.Request.Params["MAKETIME"]; //菜品时间
|
|
|
|
|
|
Model.OA.OA_RECIPE_COMMENT model = new Model.OA.OA_RECIPE_COMMENT();
|
|
model.ID = ID;
|
|
model.RECORD_ID = RecipeId;
|
|
model.A_DATE = DateTime.Now.ToString("G");
|
|
model.U_ID = UserId;
|
|
model.U_NAME = UserName;
|
|
model.DES = Des;
|
|
model.ORG_ID = OrgId;
|
|
|
|
if (bll.Add(model))
|
|
{
|
|
code = 1;
|
|
msg = "添加成功";
|
|
}
|
|
else
|
|
{
|
|
code = 0;
|
|
msg = "添加失败";
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = "添加失败:" + e.Message;
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "食谱评论操作请求", "添加食谱评论异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "食谱评论操作请求", "添加食谱评论");
|
|
return "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
|
|
|
|
}
|
|
|
|
|
|
//修改食谱评论
|
|
private string SimpleRecipeEditComments(HttpContext context)
|
|
{
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string ID = Guid.NewGuid().ToString("N");
|
|
string RecipeId = context.Request.Params["RecipeId"]?.Trim();
|
|
string Des = context.Request.Params["Des"]?.Trim();
|
|
string UserId = context.Request.Params["UserId"]?.Trim();
|
|
string UserName = context.Request.Params["UserName"]?.Trim();
|
|
string OrgId = context.Request.Params["OrgId"]?.Trim();
|
|
|
|
|
|
Model.OA.OA_RECIPE_COMMENT model = new Model.OA.OA_RECIPE_COMMENT();
|
|
model.ID = ID;
|
|
model.RECORD_ID = RecipeId;
|
|
model.U_ID = UserId;
|
|
model.U_NAME = UserName;
|
|
model.DES = Des;
|
|
model.ORG_ID = OrgId;
|
|
model.EXTEND1 = DateTime.Now.ToString("G");
|
|
|
|
if (bll.Update(model))
|
|
{
|
|
code = 1;
|
|
msg = "修改成功";
|
|
}
|
|
else
|
|
{
|
|
code = 0;
|
|
msg = "修改失败";
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = "修改失败:" + e.Message;
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "食谱评论操作请求", "修改食谱评论异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Update, "食谱评论操作请求", "修改食谱评论");
|
|
return "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
|
|
|
|
}
|
|
public bool IsReusable
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|