You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
331 lines
16 KiB
C#
331 lines
16 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web.Mvc;
|
|
using DSWeb.MvcShipping.Helper;
|
|
using DSWeb.MvcShipping.Models.MsOpTask;
|
|
using DSWeb.Areas.MvcShipping.DAL;
|
|
using HcUtility.Comm;
|
|
using DSWeb.EntityDA;
|
|
using DSWeb.MvcShipping.DAL.MsSysParamSet;
|
|
using DSWeb.MvcShipping.DAL.DsSendmail;
|
|
using DSWeb.MvcShipping.DAL.MsInfoClientMailProject;
|
|
using System.Data;
|
|
using DSWeb.MvcShipping.Models.MsOpMailLog;
|
|
using HcUtility.Core;
|
|
|
|
namespace DSWeb.MvcShipping.Controllers
|
|
{
|
|
|
|
[JsonRequestBehavior]
|
|
public class MsOpTaskController : Controller
|
|
{
|
|
|
|
|
|
public ActionResult Index()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
public ActionResult PiLiang()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
public ContentResult GetDataList(int start, int limit, string sort, string condition)
|
|
{
|
|
var dataList = MsOpTaskDAL.GetDataList(start, limit,condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort);
|
|
int count = MsOpTaskDAL.getTotalCount(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
var json = JsonConvert.Serialize(
|
|
new { Success = true, Message = "查询成功", totalCount = count, data = dataList });//list.ToList()
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
public ContentResult GetTaskTreeRefList(string PARENTID, string condition)
|
|
{
|
|
|
|
var dataList = MsOpTaskDAL.GetTaskTreeRefList(PARENTID, condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
public ContentResult GetData(string condition)
|
|
{
|
|
OpTask head = null;
|
|
head = MsOpTaskDAL.GetData(condition);
|
|
|
|
var json = JsonConvert.Serialize(
|
|
new { Success = true, Message = "查询成功", data = head });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
public ContentResult Delete(string bsno, string data)
|
|
{
|
|
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
|
|
{
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
}
|
|
//
|
|
var bodyList = JsonConvert.Deserialize<List<OpTask>>(data);
|
|
var result = new DBResult();
|
|
|
|
if (bodyList != null)
|
|
{
|
|
result = MsOpTaskDAL.DeleteTask(bodyList);
|
|
|
|
}
|
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
{
|
|
Success = result.Success,
|
|
Message = result.Message,
|
|
};
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
}
|
|
|
|
public ContentResult UpTransStatusList(string data, string transstatus, string statusdate = "", string arriverremark = "")
|
|
{
|
|
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
|
|
{
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
}
|
|
if (transstatus == "转发邮件")
|
|
{
|
|
|
|
return UpTaskEmail(data);
|
|
} else if (transstatus == "确认并完成")
|
|
{
|
|
|
|
return UpTaskOver(data);
|
|
}
|
|
else if (transstatus == "取消任务" || transstatus == "PENDING")
|
|
{
|
|
|
|
|
|
var bodyList = JsonConvert.Deserialize<List<OpTask>>(data);
|
|
|
|
var result = MsOpTaskDAL.UpTransStatus(bodyList, transstatus, Convert.ToString(Session["SHOWNAME"]).ToString().Trim());
|
|
|
|
var jsonRespose = new JsonResponse
|
|
{
|
|
Success = result.Success,
|
|
Message = result.Message
|
|
};
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
}
|
|
else {
|
|
var jsonRespose = new JsonResponse
|
|
{
|
|
Success =false,
|
|
Message ="当前状态无法处理!"
|
|
};
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
}
|
|
//
|
|
|
|
|
|
}
|
|
|
|
public ContentResult GetBcRemark(string data)
|
|
{
|
|
|
|
var result = new DBResult();
|
|
var bodyList = JsonConvert.Deserialize<List<OpTask>>(data);
|
|
|
|
if (bodyList != null)
|
|
{
|
|
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
|
|
|
|
foreach (var enumValue in bodyList)
|
|
{
|
|
result = MsOpTaskDAL.GetBcRemark(enumValue);
|
|
}
|
|
|
|
}
|
|
var jsonRespose = new JsonResponse
|
|
{
|
|
Success = result.Success,
|
|
Message = result.Message
|
|
};
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
}
|
|
|
|
public ContentResult UpTaskOver(string data)
|
|
{
|
|
|
|
var result = new DBResult();
|
|
var bodyList = JsonConvert.Deserialize<List<OpTask>>(data);
|
|
|
|
if (bodyList != null)
|
|
{
|
|
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
|
|
|
|
foreach (var enumValue in bodyList)
|
|
{
|
|
if (enumValue.TASKTYPE == "INVOIC") {
|
|
|
|
result=MsOpTaskDAL.ImpInvoice(enumValue, Convert.ToString(Session["SHOWNAME"]).ToString().Trim(), Convert.ToString(Session["USERID"]).ToString().Trim(), Convert.ToString(Session["COMPANYID"]).ToString().Trim());
|
|
} else
|
|
{
|
|
var blUpSQL = " insert into op_task_state (GID,TASKNO,TASKSTATUS,OP,OPTIME) values (newid(),'" + enumValue.TASKNO + "','已完成','" + Convert.ToString(Session["SHOWNAME"]).ToString().Trim() + "',GETDATE())";
|
|
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
|
|
|
|
blUpSQL = " update op_task set ISCOMPLETE=1,TASKSTATUS='已完成',COMPLETETYPE='人工',COMPLETETIME=GETDATE(),OP='" + Convert.ToString(Session["SHOWNAME"]).ToString().Trim() + "' where GID='" + enumValue.GID + "'";
|
|
bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
|
|
if (enumValue.ISCOMPLETE != "1" && (enumValue.TASKTYPE == "BA" || enumValue.TASKTYPE == "BC" || enumValue.TASKTYPE == "BCL" || enumValue.TASKTYPE == "ORIGINAL" || enumValue.TASKTYPE == "VC" || enumValue.TASKTYPE == "DRAFT" || enumValue.TASKTYPE == "SEAWAY"))
|
|
{
|
|
//blUpSQL = "INSERT INTO [Receipt_Doc](GID,BSNO,URL,Driect_URL,MODIFIEDUSER,MODIFIEDTIME,RECEIPTTYPE,DOCUMENTATTACHEDCODE,DOCUMENTATTACHEDNO)"
|
|
// + "VALUES(newid(),'" + enumValue.BSNO + "','" + enumValue.TASKTYPE + "','" + enumValue.FILEPATH + "','"+ Convert.ToString(Session["USERID"]).ToString().Trim()+ "',GETDATE(),'入货通知','','');";
|
|
// bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
|
|
}
|
|
result.Success = true;
|
|
result.Message = "确认完成";
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
var jsonRespose = new JsonResponse
|
|
{
|
|
Success = result.Success,
|
|
Message = result.Message
|
|
};
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
}
|
|
|
|
public ContentResult UpTaskEmail(string data)
|
|
{
|
|
|
|
var result = new DBResult();
|
|
var bodyList = JsonConvert.Deserialize<List<OpTask>>(data);
|
|
|
|
if (bodyList != null)
|
|
{
|
|
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
|
|
var MAILTONAME = "admin@dongshengsoft.com";
|
|
var PARAMVALUE = MsSysParamSetDAL.GetData("PARAMNAME='MAILTONAME'");
|
|
if (PARAMVALUE.PARAMVALUE != "") MAILTONAME = PARAMVALUE.PARAMVALUE;
|
|
var MAILTOPASSWORD = "ds!@#)(*";
|
|
PARAMVALUE = MsSysParamSetDAL.GetData("PARAMNAME='MAILTOPASSWORD'");
|
|
if (PARAMVALUE.PARAMVALUE != "") MAILTOPASSWORD = PARAMVALUE.PARAMVALUE;
|
|
var MAILTOSERVER = "smtpcom.263xmail.com";
|
|
PARAMVALUE = MsSysParamSetDAL.GetData("PARAMNAME='MAILTOSERVER'");
|
|
if (PARAMVALUE.PARAMVALUE != "") MAILTOSERVER = PARAMVALUE.PARAMVALUE;
|
|
var MAILTOPORT = "465";
|
|
PARAMVALUE = MsSysParamSetDAL.GetData("PARAMNAME='MAILTOPORT'");
|
|
if (PARAMVALUE.PARAMVALUE != "") MAILTOPORT = PARAMVALUE.PARAMVALUE;
|
|
foreach (var enumValue in bodyList)
|
|
{
|
|
result.Success = false;
|
|
if (enumValue.MAILNO != ""&& enumValue.TASKTYPE != "SEAWAY")
|
|
{
|
|
var mailrec = T_ALL_DA.GetDataSet("select MAILTITILE,MAILDESCRIP from op_mail_recv where MAILID='" + enumValue.MAILNO+"'");
|
|
string mailtopic = "";
|
|
string mailbody = "";
|
|
foreach (DataRow row in mailrec.Tables[0].Rows)
|
|
{
|
|
mailtopic = Convert.ToString(row["MAILTITILE"]);
|
|
mailbody = Convert.ToString(row["MAILDESCRIP"]);
|
|
}
|
|
var bltype = "";
|
|
bltype = enumValue.TASKTYPE;
|
|
if (bltype == "BA" || bltype == "BC") bltype = "入货通知";
|
|
else bltype = "提单留底";
|
|
var receiver = "";
|
|
var mailproject = MsInfoClientMailProjectDAL.GetBodyList(" BLTYPE='"+ bltype + "' AND PROJECTID in (select MAILPROJECT from op_seae where BSNO='" + enumValue.BSNO+"' )");
|
|
if (mailproject == null || mailproject.Count == 0)
|
|
{
|
|
result.Message = result.Message + " 提单号:" + enumValue.MBLNO + ",未设置邮件方案!";
|
|
var EMAIL = T_ALL_DA.GetStrSQL("EMAIL", "SELECT c.EMAIL EMAIL from info_client_contact c,(select customername,OPERATOR from op_seae where bsno='" + enumValue.BSNO + "') v where c.linkid in (select gid from info_client where shortname = v.customername) and c.showname = v.operator ");
|
|
if (EMAIL != "") receiver = EMAIL;
|
|
}
|
|
else
|
|
{
|
|
|
|
foreach (var mail in mailproject)
|
|
{
|
|
if (receiver == "")
|
|
receiver = mail.RECEIVER;
|
|
else receiver = receiver + "," + mail.RECEIVER;
|
|
}
|
|
}
|
|
|
|
if (receiver != "")
|
|
{
|
|
var email1 = T_ALL_DA.GetStrSQL("email1", "select email1 from VW_user WHERE SHOWNAME='" + enumValue.CREATEUSER + "' ");
|
|
if (email1 != "") MAILTONAME = email1;
|
|
|
|
SendEmail se = new SendEmail(receiver, MAILTONAME, "", "", "转发:" + mailtopic, mailbody, false);
|
|
// SendEmail se = new SendEmail("dev001@dongshengsoft.com", "admin@dongshengsoft.com", "", "", mailtopic, mailbody, false);
|
|
|
|
string filePath = Server.MapPath(enumValue.FILEPATH);
|
|
se.Attachments(filePath);
|
|
|
|
try
|
|
{
|
|
se.SetSmtp(MAILTONAME, MAILTOPASSWORD, MAILTOSERVER, Convert.ToInt32(MAILTOPORT), true, System.Net.Mail.MailPriority.Normal); //必须在所有参数设置完后调用此方法
|
|
result.Success = true;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
se.SetSmtp(MAILTONAME, MAILTOPASSWORD, MAILTOSERVER, Convert.ToInt32(MAILTOPORT), false, System.Net.Mail.MailPriority.Normal); //必须在所有参数设置完后调用此方法
|
|
|
|
}
|
|
}
|
|
if (result.Success) {
|
|
var head = new OpMailLog();
|
|
head.BSNO = enumValue.BSNO;
|
|
head.BLTYPE = enumValue.TASKTYPE;
|
|
head.RECEIVER = receiver;
|
|
head.SUBJECT = "转发:" + mailtopic;
|
|
head.DESCRIPTION = mailbody;
|
|
head.ATTACHMENT = enumValue.FILEPATH;
|
|
head.SENDER = Convert.ToString(Session["SHOWNAME"]).ToString().Trim();
|
|
head.SENDTIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
head.DbOperationType = DbOperationType.DbotIns;
|
|
var modb = new ModelObjectDB();
|
|
modb.Save(head);
|
|
|
|
}
|
|
|
|
|
|
if (result.Success) {
|
|
var blUpSQL = " insert into op_task_state (GID,TASKNO,TASKSTATUS,OP,OPTIME) values (newid(),'" + enumValue.TASKNO+ "','已转发','" + Convert.ToString(Session["SHOWNAME"]).ToString().Trim() + "',GETDATE())";
|
|
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
|
|
blUpSQL = " update op_task set ISCOMPLETE=1,TASKSTATUS='已转发',COMPLETETYPE='人工',COMPLETETIME=GETDATE(),OP='"+ Convert.ToString(Session["SHOWNAME"]).ToString().Trim() + "' where GID='" + enumValue.GID+"'";
|
|
bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
|
|
if (enumValue.ISCOMPLETE!="1"&&(enumValue.TASKTYPE=="BA"|| enumValue.TASKTYPE=="BC")) {
|
|
blUpSQL = "INSERT INTO [Receipt_Doc](GID,BSNO,URL,Driect_URL,MODIFIEDUSER,MODIFIEDTIME,RECEIPTTYPE,DOCUMENTATTACHEDCODE,DOCUMENTATTACHEDNO)"
|
|
+ "VALUES(newid(),'"+enumValue.BSNO+"','"+enumValue.TASKTYPE+"','"+enumValue.FILEPATH+"','"+ Convert.ToString(Session["USERID"]).ToString().Trim() + "',GETDATE(),'入货通知','','');";
|
|
bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
|
|
|
|
}
|
|
|
|
}
|
|
// }
|
|
}
|
|
}
|
|
}
|
|
var jsonRespose = new JsonResponse
|
|
{
|
|
Success = result.Success,
|
|
Message = result.Message
|
|
};
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|