192 lines
7.8 KiB
C#
192 lines
7.8 KiB
C#
using CRM.Core.BLL.Base;
|
|
using CRM.Core.BLL.Cms;
|
|
using CRM.Core.BLL.Csvr;
|
|
using CRM.Core.DTO.Cms;
|
|
using CRM.Core.Model.Entity;
|
|
using CRM.Core.Model.Enum;
|
|
using System;
|
|
using System.Configuration;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using WX.CRM.Common;
|
|
|
|
namespace ZXDService
|
|
{
|
|
/// <summary>
|
|
/// CmsNewUpload 的摘要说明
|
|
/// </summary>
|
|
public class CmsNewUpload : IHttpHandler
|
|
{
|
|
|
|
public void ProcessRequest(HttpContext context)
|
|
{
|
|
try
|
|
{
|
|
CMS_News_BL _news = new CMS_News_BL();
|
|
Csvr_Message_BL _msg = new Csvr_Message_BL();
|
|
CMS_News_Log_BL _newslog = new CMS_News_Log_BL();
|
|
Bas_CompanyVirtual_BL _company = new Bas_CompanyVirtual_BL();
|
|
context.Response.ContentType = "text/html";
|
|
|
|
var yearMonth = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString();
|
|
var uploadFolder = ConfigurationManager.AppSettings["UploadTemFileDic"];
|
|
|
|
//Stream sourceStream = request.FileData;
|
|
|
|
if (!Directory.Exists(uploadFolder))
|
|
{
|
|
Directory.CreateDirectory(uploadFolder);
|
|
}
|
|
LogHelper.Info(context.Request.Params["param"]);
|
|
var json = Newtonsoft.Json.JsonConvert.DeserializeObject<Cms_News_Dto>(context.Request.Params["param"]);
|
|
|
|
if (context.Request.Files.Count > 0)//上传文件大于零
|
|
{
|
|
LogHelper.Info("有文件");
|
|
HttpPostedFile file = context.Request.Files[0];
|
|
var vPath = System.Configuration.ConfigurationManager.AppSettings["UploadTemFileDic"] + "/att";
|
|
string filePath = Path.Combine(vPath, file.FileName);
|
|
file.SaveAs(filePath);
|
|
}
|
|
|
|
CMS_News news = new CRM.Core.Model.Entity.CMS_News()
|
|
{
|
|
Att = json.ATT,
|
|
Content = json.CONTENT,
|
|
CreateUser = Convert.ToInt32(json.CREATEUSER),
|
|
CreateUserName = json.CREATEUSERNAME,
|
|
Id = Convert.ToInt32(json.ID),
|
|
CTime = json.CTIME,
|
|
NewsType = json.NEWSTYPE,
|
|
Remark = json.REMARK,
|
|
Status = Convert.ToInt32(json.STATUS),
|
|
Title = json.TITLE,
|
|
deptcode = json.DEPTCODE,
|
|
Companycode = json.companycode ?? json.DEPTCODE,
|
|
Channel = json.CHANNEL,
|
|
UploadName = json.UPLOADNAME
|
|
};
|
|
string[] ss = { "DNG1", "DNG2", "DNG3", "DNG8" };
|
|
if (ss.Contains(news.Companycode))
|
|
{
|
|
news.Companycode = "DNG8";
|
|
news.deptcode = "DNG8";
|
|
}
|
|
string[] ss2 = { "DNZZ05", "DNZZ06", "DNRW06", "DNRW07", "DNRW08", "DNRW09", "DNRW10" };
|
|
if (ss2.Contains(news.Companycode) || ss2.Contains(news.deptcode))
|
|
{
|
|
news.Companycode = "DNZZ";
|
|
news.deptcode = "DNZZ";
|
|
}
|
|
|
|
|
|
string[] ss3 = { "DNBB01", "DNCC01" };
|
|
if (ss3.Contains(news.Companycode) || ss3.Contains(news.deptcode))
|
|
{
|
|
news.Companycode = "DNBB";
|
|
news.deptcode = "DNBB";
|
|
}
|
|
|
|
var model = _news.Get(p => p.Id == news.Id && p.Companycode == news.deptcode);
|
|
|
|
if (model == null)
|
|
{
|
|
_newslog.Add(new CMS_News_Log()
|
|
{
|
|
CTime = DateTime.Now,
|
|
Att = news.Att,
|
|
Content = news.Content,
|
|
deptcode = news.deptcode,
|
|
newid = news.Id,
|
|
NewsType = news.NewsType,
|
|
OpEvent = "提交",
|
|
OpName = news.CreateUserName,
|
|
OpUser = news.CreateUser,
|
|
Remark = news.Remark,
|
|
Status = news.Status,
|
|
Title = news.Title,
|
|
Channel = news.Channel
|
|
});
|
|
_news.Add(news);
|
|
|
|
#region 发送通知
|
|
var comcode = _company.Get(m => m.CompanyCode.Contains(news.deptcode));
|
|
string fromer = news.CreateUserName;
|
|
if (comcode != null)
|
|
fromer = comcode.CompanyName;
|
|
_msg.PushNewsMsg("WASH", $"文案【{news.Title}】已经【提交】,请您审核!", fromer, null, news.deptcode);
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
if (model.Status == 1)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
model.Att = news.Att;
|
|
model.Content = news.Content;
|
|
if (model.Status == -1)
|
|
{
|
|
model.Status = 0;//重新上传审核
|
|
}
|
|
model.NewsType = news.NewsType;
|
|
model.Remark = news.Remark;
|
|
model.Title = news.Title;
|
|
model.AuditImg1 = "";
|
|
model.AuditImg2 = "";
|
|
model.AuditImg3 = "";
|
|
model.AuditImg4 = "";
|
|
model.AuditImg5 = "";
|
|
model.AuditImg6 = "";
|
|
model.AuditRemark = "";//再一次提交,需要将数据清空
|
|
_newslog.Add(new CMS_News_Log()
|
|
{
|
|
CTime = DateTime.Now,
|
|
Att = news.Att,
|
|
Content = news.Content,
|
|
deptcode = news.deptcode,
|
|
newid = news.Id,
|
|
NewsType = news.NewsType,
|
|
OpEvent = "复提交",
|
|
OpName = news.CreateUserName,
|
|
OpUser = news.CreateUser,
|
|
Remark = news.Remark,
|
|
Status = news.Status,
|
|
Title = news.Title,
|
|
Channel = news.Channel,
|
|
UploadName = news.UploadName,
|
|
});
|
|
model.deptcode = news.deptcode;
|
|
_news.Update(model);
|
|
#region 发送通知
|
|
var comcode = _company.Get(m => m.CompanyCode.Contains(news.deptcode));
|
|
string fromer = news.CreateUserName;
|
|
if (comcode != null)
|
|
fromer = comcode.CompanyName;
|
|
_msg.PushNewsMsg("WASH", $"文案【{news.Title}】已经【复提交】,请您审核!", fromer, null, news.deptcode);
|
|
#endregion
|
|
}
|
|
}
|
|
HttpContext.Current.Response.Write(Utility.ObjectToJson(new { result = true, retcode = (int)EnumInterfaceErrcode.调用成功, retmsg = "接收成功" }));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Error("错误:" + ex.ToString());
|
|
//HttpContext.Current.Response.Clear();
|
|
HttpContext.Current.Response.Write(Utility.ObjectToJson(new { result = false, retcode = (int)EnumInterfaceErrcode.调用成功但有错误, retmsg = "接收失败:" + ex.Message }));
|
|
}
|
|
}
|
|
|
|
|
|
public bool IsReusable
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
} |