|
|
using System;
|
|
|
using System.Data;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Text;
|
|
|
using DSWeb.MvcShipping.Models.BookingConfirm;
|
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
|
using DSWeb.Areas.CommMng.Models;
|
|
|
using HcUtility.Comm;
|
|
|
using System.Web.Mvc;//ContentResult
|
|
|
using DSWeb.TruckMng.Helper.Repository;//ModelObjectRepository
|
|
|
using DSWeb.MvcShipping.Helper;
|
|
|
using DSWeb.Areas.CommMng.DAL;//使用获取权限子句
|
|
|
using DSWeb.MvcShipping.Models.MsOpSeae;
|
|
|
using BookingWeb.DB;
|
|
|
using BookingWeb.DB.Model;
|
|
|
using System.Linq;
|
|
|
using DSWeb.MvcShipping.DAL.MsSysParamSet;
|
|
|
using DSWeb.MvcShipping.DAL.DsSendmail;
|
|
|
using static DSWeb.MvcShipping.Controllers.BookingConfirmController;
|
|
|
|
|
|
namespace DSWeb.Areas.MvcShipping.DAL.BookingConfirm
|
|
|
{
|
|
|
public class BookingConfirmDAL
|
|
|
{
|
|
|
#region 订舱 Order 头表
|
|
|
|
|
|
static public List<BookingConfirmmb> GetBookingList ( string strCondition,string USERID, string sort = "" )
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
|
|
|
|
strSql.Append(getHeadListStr(strCondition, USERID));
|
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(" order by (select max(optime) from OP_LOG where billno=ORDNO and JsonValue like '%\"BSSTATUS\":\"Submit\"%') desc ");
|
|
|
}
|
|
|
return SetBookingData(strSql, USERID);
|
|
|
}
|
|
|
/*
|
|
|
public static BookingConfirmmb GetBookingData(string condition, string USERID)
|
|
|
{
|
|
|
var dataList = GetBookingList(condition, USERID);
|
|
|
|
|
|
var result = new BookingConfirmmb();
|
|
|
|
|
|
if (dataList.Count > 0)
|
|
|
{
|
|
|
result = dataList[0];
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
*/
|
|
|
public static string getHeadListStr(string condition, string USERID) {
|
|
|
string sql = BookingConfirmmb.getSQL() ;
|
|
|
|
|
|
//var rangestr = BasicDataRefDAL.GetVisableRange("modBookingConfirm", USERID, "COMPANYID", "CREATEUSER", "DEPTID");
|
|
|
|
|
|
var CLIENT_ID = EntityDA.T_ALL_DA.GetSQL_str("PARAMVALUE", "select top 1 PARAMVALUE from sys_param_set where PARAMNAME='Booking_CLIENT_GID' ");
|
|
|
|
|
|
sql += " and userid in (select GID from sys_user where CLIENT_ID='"+ CLIENT_ID + "') and BSSTATUS in('Submit','Confirm','Back') ";
|
|
|
|
|
|
if (!string.IsNullOrEmpty(condition)) { sql += " and " + condition; }
|
|
|
|
|
|
return sql;
|
|
|
}
|
|
|
|
|
|
private static List<BookingConfirmmb> SetBookingData(StringBuilder strSql,string USERID)//, List<HcUtility.Core.Fieldmb> fieldlist
|
|
|
{
|
|
|
var headList = new List<BookingConfirmmb>();
|
|
|
|
|
|
//此处使用webconfig中的 booking内定义的订舱平台地址
|
|
|
Database db = DatabaseFactory.CreateDatabase("BookingDB");
|
|
|
|
|
|
string sql = strSql.ToString();
|
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, sql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
|
|
|
////根据字段名设定同名属性值
|
|
|
BookingConfirmmb data = new BookingConfirmmb();
|
|
|
data.SetExtendValue(reader);
|
|
|
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 集装箱表 明细表
|
|
|
|
|
|
static public List<Booking_Ctnmb> GetCtnList(string strCondition, string sort = "")
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
|
|
|
|
strSql.Append(getCtnListStr(strCondition));
|
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(" order by CTNALL ");
|
|
|
}
|
|
|
return SetCtnData(strSql);
|
|
|
}
|
|
|
|
|
|
public static Booking_Ctnmb GetCtnData(string condition)
|
|
|
{
|
|
|
var dataList = GetCtnList(condition);
|
|
|
|
|
|
var result = new Booking_Ctnmb();
|
|
|
|
|
|
if (dataList.Count > 0)
|
|
|
{
|
|
|
result = dataList[0];
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public static string getCtnListStr(string condition)
|
|
|
{
|
|
|
string sql = Booking_Ctnmb.getSQL();
|
|
|
|
|
|
if (!string.IsNullOrEmpty(condition)) { sql += " where " + condition; }
|
|
|
|
|
|
return sql;
|
|
|
}
|
|
|
|
|
|
private static List<Booking_Ctnmb> SetCtnData(StringBuilder strSql)//, List<HcUtility.Core.Fieldmb> fieldlist
|
|
|
{
|
|
|
var headList = new List<Booking_Ctnmb>();
|
|
|
|
|
|
//此处使用webconfig中的 booking内定义的订舱平台地址
|
|
|
Database db = DatabaseFactory.CreateDatabase("BookingDB");
|
|
|
|
|
|
string sql = strSql.ToString();
|
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, sql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
|
|
|
////根据字段名设定同名属性值
|
|
|
Booking_Ctnmb data = new Booking_Ctnmb();
|
|
|
data.SetExtendValue(reader);
|
|
|
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 集装箱装箱明细表 明细表
|
|
|
|
|
|
static public List<Booking_CtnDetailmb> GetCtnDetailList(string strCondition, string USERID, string sort = "")
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
|
|
|
|
strSql.Append(GetCtnDetailListStr(strCondition, USERID));
|
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//strSql.Append(" order by CTNALL ");
|
|
|
}
|
|
|
return SetCtnDetailData(strSql, USERID);
|
|
|
}
|
|
|
|
|
|
public static Booking_CtnDetailmb GetCtnDetailData(string condition, string USERID)
|
|
|
{
|
|
|
var dataList = GetCtnDetailList(condition, USERID);
|
|
|
|
|
|
var result = new Booking_CtnDetailmb();
|
|
|
|
|
|
if (dataList.Count > 0)
|
|
|
{
|
|
|
result = dataList[0];
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public static string GetCtnDetailListStr(string condition, string USERID)
|
|
|
{
|
|
|
string sql = Booking_CtnDetailmb.getSQL();
|
|
|
|
|
|
if (!string.IsNullOrEmpty(condition)) { sql += " where " + condition; }
|
|
|
|
|
|
return sql;
|
|
|
}
|
|
|
|
|
|
private static List<Booking_CtnDetailmb> SetCtnDetailData(StringBuilder strSql, string USERID)//, List<HcUtility.Core.Fieldmb> fieldlist
|
|
|
{
|
|
|
var headList = new List<Booking_CtnDetailmb>();
|
|
|
|
|
|
//此处使用webconfig中的 booking内定义的订舱平台地址
|
|
|
Database db = DatabaseFactory.CreateDatabase("BookingDB");
|
|
|
|
|
|
string sql = strSql.ToString();
|
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, sql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
|
|
|
////根据字段名设定同名属性值
|
|
|
Booking_CtnDetailmb data = new Booking_CtnDetailmb();
|
|
|
data.SetExtendValue(reader);
|
|
|
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 提单确认表 头表//截单对比中的本地数据
|
|
|
|
|
|
static public List<Booking_OP_SEAE_SImb> GetBooking_SIList(string strCondition, string USERID, string sort = "")
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
|
strSql.Append(getBooking_SIListStr(strCondition, USERID));
|
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(" order by (select max(optime) from OP_LOG where billno=SINO and JsonValue like '%\"BSSTATUS\":\"Submit\"%') ");
|
|
|
}
|
|
|
return SetSIData(strSql, USERID);
|
|
|
}
|
|
|
|
|
|
public static Booking_OP_SEAE_SImb GetBooking_SIData(string condition, string USERID)
|
|
|
{
|
|
|
var dataList = GetBooking_SIList(condition, USERID);
|
|
|
|
|
|
var result = new Booking_OP_SEAE_SImb();
|
|
|
|
|
|
if (dataList.Count > 0)
|
|
|
{
|
|
|
result = dataList[0];
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public static string getBooking_SIListStr(string condition, string USERID)
|
|
|
{
|
|
|
string sql = Booking_OP_SEAE_SImb.getSQL();
|
|
|
|
|
|
string _condition = " BSSTATUS <>'Create' ";
|
|
|
|
|
|
sql += " where " + _condition;
|
|
|
|
|
|
var CLIENT_ID = EntityDA.T_ALL_DA.GetSQL_str("PARAMVALUE", "select top 1 PARAMVALUE from sys_param_set where PARAMNAME='Booking_CLIENT_GID' ");
|
|
|
|
|
|
sql += " and userid in (select GID from sys_user where CLIENT_ID='" + CLIENT_ID + "') and BSSTATUS in('Submit','Confirm','Reject')";
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(condition)) { sql += " and " + condition; }
|
|
|
|
|
|
return sql;
|
|
|
}
|
|
|
|
|
|
private static List<Booking_OP_SEAE_SImb> SetSIData(StringBuilder strSql, string USERID)//, List<HcUtility.Core.Fieldmb> fieldlist
|
|
|
{
|
|
|
var headList = new List<Booking_OP_SEAE_SImb>();
|
|
|
|
|
|
//此处使用webconfig中的 booking内定义的订舱平台地址
|
|
|
Database db = DatabaseFactory.CreateDatabase("BookingDB");
|
|
|
|
|
|
string sql = strSql.ToString();
|
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, sql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
|
|
|
////根据字段名设定同名属性值
|
|
|
Booking_OP_SEAE_SImb data = new Booking_OP_SEAE_SImb();
|
|
|
data.SetExtendValue(reader);
|
|
|
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 获取字段列表:存在于op_seae,不存在于op_seae_billmanage,且在“需要同步”的范围之内
|
|
|
/// <summary>
|
|
|
/// 获取字段列表:存在于op_seae,不存在于op_seae_billmanage,且在“需要同步”的范围之内
|
|
|
/// </summary>
|
|
|
/// <param name="HeadSIFieldList"></param>
|
|
|
/// <returns></returns>
|
|
|
public static List<DiffFieldmb> GetMoreField(List<DiffFieldmb> HeadSIFieldList) {
|
|
|
//最初为数据库比较 后改为固定范围
|
|
|
//var noexistfieldList = SetNoExistList();
|
|
|
|
|
|
var noexistfieldList = new List<DiffFieldmb>();
|
|
|
|
|
|
var SIREMARK = new DiffFieldmb("SIREMARK", "");
|
|
|
noexistfieldList.Add(SIREMARK);
|
|
|
var COPYNOBILL = new DiffFieldmb("COPYNOBILL", "");
|
|
|
noexistfieldList.Add(COPYNOBILL);
|
|
|
var ISCONTAINERSOC = new DiffFieldmb("ISCONTAINERSOC", "");
|
|
|
noexistfieldList.Add(ISCONTAINERSOC);
|
|
|
|
|
|
var result = new List<DiffFieldmb>();
|
|
|
foreach (var item in HeadSIFieldList)
|
|
|
{
|
|
|
foreach (var field in noexistfieldList)
|
|
|
{
|
|
|
if (item.FieldName == field.FieldName)
|
|
|
{
|
|
|
result.Add(item);
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
private static List<DiffFieldmb> SetNoExistList()
|
|
|
{
|
|
|
var headList = new List<DiffFieldmb>();
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
|
string sql = " Select name from syscolumns Where ID=OBJECT_ID('op_seae') and name not in (select name from syscolumns Where ID = OBJECT_ID('op_seae_billmanage')) ";
|
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, sql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
|
|
|
////根据字段名设定同名属性值
|
|
|
DiffFieldmb data = new DiffFieldmb(Convert.ToString(reader["name"]),"");
|
|
|
//data.FieldName= Convert.ToString(reader["name"]);
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 向Booking.Op_seae_order写入数据
|
|
|
/// </summary>
|
|
|
/// <param name="head"></param>
|
|
|
/// <returns></returns>
|
|
|
private BookingDB bookingDB = new BookingDB();
|
|
|
|
|
|
public static DBResult SavetoBooking(MsOpSeae head,string CORPNAME)
|
|
|
{
|
|
|
var bookingDB = new BookingDB();
|
|
|
var result = new DBResult(false, "", null);
|
|
|
OP_SEAE_ORDER model = bookingDB.Orders.First(o => o.BSNO == head.BSNO);
|
|
|
|
|
|
model.MBLNO = head.MBLNO;
|
|
|
model.VESSEL = head.VESSEL;
|
|
|
model.VOYNO = head.VOYNO;
|
|
|
model.YARD = head.YARD;
|
|
|
|
|
|
if(!string.IsNullOrWhiteSpace(head.ETD))
|
|
|
model.ETD = Convert.ToDateTime( head.ETD);
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(head.CLOSINGDATE))
|
|
|
model.CLOSINGDATE = Convert.ToDateTime(head.CLOSINGDATE);
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(head.CLOSEDOCDATE))
|
|
|
model.CLOSEDOCDATE = Convert.ToDateTime(head.CLOSEDOCDATE);
|
|
|
|
|
|
model.VESSELID = head.VESSELID;
|
|
|
model.CARRIER = head.CARRIER;
|
|
|
|
|
|
var _r = bookingDB.SaveChanges();
|
|
|
|
|
|
if (_r>0) {
|
|
|
//保存日志
|
|
|
|
|
|
var viewModel = OrderEditViewModelExt.AsEditViewModel(model);
|
|
|
|
|
|
LogHelper.Log(OpLogModule.Order, OpLogType.Save, model.ORDNO, model.MBLNO,model.CORPID,CORPNAME, Newtonsoft.Json.JsonConvert.SerializeObject(viewModel));
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 判断Booking.OP_seae_order的状态是否能进行指定变化
|
|
|
/// </summary>
|
|
|
/// <param name="BSNO"></param>
|
|
|
/// <param name="STATUS"></param>
|
|
|
/// <returns></returns>
|
|
|
public static DBResult Order_CanConfirm(string BSNO, string STATUS)
|
|
|
{
|
|
|
var bookingDB = new BookingDB();
|
|
|
var result = new DBResult(false, "", null);
|
|
|
if (string.IsNullOrEmpty(BSNO)) {
|
|
|
result.Success = true;
|
|
|
return result;
|
|
|
}
|
|
|
OP_SEAE_ORDER model = bookingDB.Orders.First(o => o.BSNO == BSNO);
|
|
|
|
|
|
if (DoingOrder.IsDoing(model.ORDERNO))
|
|
|
{
|
|
|
result.Message = "该业务正在处理,请刷新后重试";
|
|
|
return result;
|
|
|
}
|
|
|
else {
|
|
|
DoingOrder.Add(model.ORDERNO);
|
|
|
}
|
|
|
|
|
|
var Confirms = bookingDB.Confirms.Where(o => o.ORDNO == model.ORDNO && (o.BSSTATUS == OrderStatus.Submit.ToString() || o.BSSTATUS == OrderStatus.Confirm.ToString()));
|
|
|
|
|
|
if (Confirms.Count() > 0)
|
|
|
{
|
|
|
result.Message = "已经开始截单的订舱业务不能更改订舱状态";
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
if ((model.BSSTATUS == OrderStatus.Submit.ToString() && STATUS == OrderStatus.Confirm.ToString()) || ((model.BSSTATUS == OrderStatus.Confirm.ToString() || model.BSSTATUS == OrderStatus.Submit.ToString()) && STATUS == OrderStatus.Back.ToString())) {
|
|
|
result.Success = true;
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
result.Message="当前状态不能进行此操作";
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 更改Booking.Op_Seae_Order的状态
|
|
|
/// 如果需要的话 对Booking.OP_STATUS_LOG进行操作
|
|
|
/// </summary>
|
|
|
/// <param name="BSNO"></param>
|
|
|
/// <param name="CORPNAME"></param>
|
|
|
/// <returns></returns>
|
|
|
public static DBResult BookingStatus_Order(OP_SEAE_ORDER model, string STATUS, string CORPNAME)
|
|
|
{
|
|
|
var bookingDB = new BookingDB();
|
|
|
var result = new DBResult(false, "", null);
|
|
|
|
|
|
//OP_SEAE_ORDER model = bookingDB.Orders.FirstOrDefault(o => o.BSNO == BSNO);
|
|
|
|
|
|
//1.Confirm
|
|
|
if (STATUS == OrderStatus.Confirm.ToString()) {
|
|
|
OP_STATUS_LOG confirmlog = new OP_STATUS_LOG();
|
|
|
confirmlog.GID = System.Guid.NewGuid().ToString();
|
|
|
confirmlog.RELATIVE_ID = model.ORDNO;
|
|
|
confirmlog.STATUS = OrderLogStatus.OrderConfirm.ToString();
|
|
|
confirmlog.OP_TIME = System.DateTime.Now;
|
|
|
confirmlog.OP_USER = CORPNAME;
|
|
|
bookingDB.StatusLogs.Add(confirmlog);
|
|
|
}
|
|
|
|
|
|
//statusLogs = bookingDB.StatusLogs.Where(o => o.RELATIVE_ID == model.ORDNO && o.STATUS == OrderLogStatus.OrderSubmit.ToString());
|
|
|
|
|
|
//2.Back
|
|
|
if (STATUS == OrderStatus.Back.ToString())
|
|
|
{
|
|
|
bookingDB.StatusLogs.RemoveRange(bookingDB.StatusLogs.Where(o => o.RELATIVE_ID == model.ORDNO && (o.STATUS == OrderLogStatus.OrderSubmit.ToString() || o.STATUS == OrderLogStatus.OrderConfirm.ToString())));
|
|
|
result.Success = true;
|
|
|
}
|
|
|
|
|
|
//model.BSSTATUS = STATUS;
|
|
|
|
|
|
var _r = bookingDB.SaveChanges();
|
|
|
if (_r > 1) {
|
|
|
result.Success = true;
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 写回订舱网站端的订舱状态
|
|
|
/// </summary>
|
|
|
/// <param name="ORDNO"></param>
|
|
|
/// <param name="BSNO"></param>
|
|
|
/// <param name="STATUS"></param>
|
|
|
/// <param name="CORPNAME"></param>
|
|
|
/// <returns></returns>
|
|
|
public static DBResult BookingStatus_Order(string ORDNO, string BSNO, string STATUS, string CORPNAME,string OPEmail="") {
|
|
|
var bookingDB = new BookingDB();
|
|
|
OP_SEAE_ORDER model = bookingDB.Orders.FirstOrDefault(o => o.ORDNO == ORDNO);
|
|
|
model.BSNO = BSNO;
|
|
|
model.BSSTATUS = STATUS;//写回订舱状态
|
|
|
|
|
|
if (STATUS== OrderStatus.Confirm.ToString()) {
|
|
|
model.EMAIL = OPEmail;
|
|
|
}
|
|
|
bookingDB.SaveChanges();
|
|
|
|
|
|
return BookingStatus_Order(model, STATUS, CORPNAME);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 判断Booking.OP_seae_order的状态是否能进行指定变化
|
|
|
/// </summary>
|
|
|
/// <param name="BSNO"></param>
|
|
|
/// <param name="STATUS"></param>
|
|
|
/// <returns></returns>
|
|
|
public static DBResult SI_CanConfirm(string SINO, string ConfirmStatus)
|
|
|
{
|
|
|
var result = new DBResult(false, "", null);
|
|
|
var bookingDB = new BookingDB();
|
|
|
var confirm = bookingDB.Confirms.FirstOrDefault(o => o.SINO == SINO);
|
|
|
|
|
|
OP_SEAE_ORDER model = bookingDB.Orders.First(o => o.ORDNO == confirm.ORDNO);
|
|
|
|
|
|
var Confirms = bookingDB.Confirms.Where(o => o.ORDNO == confirm.ORDNO);
|
|
|
|
|
|
if (ConfirmStatus == OrderConfirmStatus.Reject.ToString())
|
|
|
{
|
|
|
if (confirm.BSSTATUS == OrderConfirmStatus.Confirm.ToString())
|
|
|
{
|
|
|
result.Message = "已经确认的截单不能再驳回";
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (confirm.BSSTATUS != OrderConfirmStatus.Submit.ToString())
|
|
|
{
|
|
|
result.Message = "当前状态不能进行此操作";
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
result.Success = true;
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 对Booking.Op_Seae_SI进行状态变更操作
|
|
|
/// </summary>
|
|
|
/// <param name="SINO"></param>
|
|
|
/// <param name="ConfirmStatus"></param>
|
|
|
/// <param name="CORPNAME"></param>
|
|
|
/// <returns></returns>
|
|
|
public static DBResult BookingStatus_Confirm(string SINO,string ConfirmStatus, string CORPNAME,string USERID="")
|
|
|
{
|
|
|
var result = new DBResult(false, "", null);
|
|
|
var bookingDB = new BookingDB();
|
|
|
var confirm = bookingDB.Confirms.FirstOrDefault(o => o.SINO == SINO);
|
|
|
|
|
|
OP_SEAE_ORDER model = bookingDB.Orders.First(o => o.ORDNO == confirm.ORDNO);
|
|
|
|
|
|
var Confirms = bookingDB.Confirms.Where(o => o.ORDNO == confirm.ORDNO).ToList();
|
|
|
|
|
|
if (ConfirmStatus == OrderConfirmStatus.Reject.ToString()) {
|
|
|
|
|
|
//if (confirm.BSSTATUS == OrderConfirmStatus.Confirm.ToString()) {
|
|
|
// result.Message = "已经确认的截单不能再驳回";
|
|
|
// return result;
|
|
|
//}
|
|
|
confirm.BSSTATUS = OrderConfirmStatus.Reject.ToString();
|
|
|
|
|
|
model.SISTATUS = OrderConfirmStatus.Reject.ToString();
|
|
|
|
|
|
//if (Confirms.Where(o => o.BSSTATUS == OrderConfirmStatus.Reject.ToString()).Count() > 0)
|
|
|
//{
|
|
|
bookingDB.StatusLogs.RemoveRange(bookingDB.StatusLogs.Where(o => o.RELATIVE_ID == confirm.ORDNO && (o.STATUS == OrderLogStatus.ConfirmSubmit.ToString() || o.STATUS == OrderLogStatus.ConfirmConfirm.ToString())));
|
|
|
//}
|
|
|
bookingDB.SaveChanges();
|
|
|
result.Success = true;
|
|
|
}
|
|
|
|
|
|
if (ConfirmStatus == OrderConfirmStatus.Confirm.ToString())
|
|
|
{
|
|
|
|
|
|
confirm.BSSTATUS = OrderConfirmStatus.Confirm.ToString();
|
|
|
bookingDB.SaveChanges();
|
|
|
|
|
|
if (Confirms.Where(o => o.BSSTATUS == OrderConfirmStatus.Confirm.ToString()).Count() == Confirms.Count())
|
|
|
{
|
|
|
OP_STATUS_LOG confirmlog = new OP_STATUS_LOG();
|
|
|
confirmlog.GID = System.Guid.NewGuid().ToString();
|
|
|
confirmlog.RELATIVE_ID = confirm.ORDNO;
|
|
|
confirmlog.STATUS = OrderLogStatus.ConfirmConfirm.ToString();
|
|
|
confirmlog.OP_TIME = System.DateTime.Now;
|
|
|
confirmlog.OP_USER = CORPNAME;
|
|
|
bookingDB.StatusLogs.Add(confirmlog);
|
|
|
|
|
|
model.SISTATUS = OrderConfirmStatus.Confirm.ToString();
|
|
|
}
|
|
|
|
|
|
try
|
|
|
{
|
|
|
bookingDB.SaveChanges();
|
|
|
|
|
|
}
|
|
|
catch(Exception e) {
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
result.Success = true;
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#region 订舱 邮件
|
|
|
/// <summary>
|
|
|
/// ORDNO ,TYPE类型(订舱确认/驳回订舱)
|
|
|
/// </summary>
|
|
|
/// <param name="ORDER"></param>
|
|
|
/// <param name="TYPE"></param>
|
|
|
/// <returns></returns>
|
|
|
public static DBResult SendMail_Order(string ORDNO, string TYPE, string REASON, string EMAIL, string USERID,string COMPANYNAME,MsOpSeae headData=null)
|
|
|
{
|
|
|
|
|
|
DBResult result = new DBResult(true, "", null);
|
|
|
var bookingDB = new BookingDB();
|
|
|
var Order = bookingDB.Orders.FirstOrDefault(o => o.ORDNO == ORDNO);
|
|
|
|
|
|
|
|
|
|
|
|
var mailtopic = TYPE + ":" + Order.ORDERNO+"|"+ Order.CARRIER+"|ETD:"+Order.ETD+"|"+Order.CNTRTOTAL+"|"+ Order.PORTDISCHARGE;
|
|
|
//var userlist = MsBaseInfoDAL.MsBaseInfoDAL.GetUserBaseList("USERID='" + userid + "'");
|
|
|
//var tel = "";
|
|
|
//var email = "";
|
|
|
var SENDEREMAIL = "";
|
|
|
var qq = "";
|
|
|
|
|
|
var p = BasicDataRefDAL.GetPhoneWithUserId(USERID, out SENDEREMAIL, out qq);
|
|
|
|
|
|
var mailbody = "订舱公司:" + COMPANYNAME + "</br>"
|
|
|
+ "订舱编号:" + Order.ORDERNO + "</br>"
|
|
|
+ "ETD:" + Order.ETD + "</br>"
|
|
|
+ "船公司:" + Order.CARRIER + "</br>"
|
|
|
+ "箱型箱量:" + Order.CNTRTOTAL + "</br>"
|
|
|
+ "卸货港:" + Order.PORTDISCHARGE + "</br>";
|
|
|
|
|
|
if (!string.IsNullOrEmpty(REASON))
|
|
|
mailbody += "" + REASON + "</br>";
|
|
|
|
|
|
if (headData != null) {
|
|
|
mailbody += getmailinfo(headData.OP,headData.SERVICE,headData.SALE);
|
|
|
}
|
|
|
|
|
|
mailbody += "发送邮箱:" + SENDEREMAIL;
|
|
|
|
|
|
mailbody+= "</br>" + "</br>" + "</br>" + "<p style=\"color:blue\">本邮件为 " + COMPANYNAME + " 工作平台自动发送,请勿回复</p>";
|
|
|
//string toNames = "frank,lee";
|
|
|
|
|
|
var MAILTONAME = "dongshengcangdan@h8j.top";//"admin@dongshengsoft.com";
|
|
|
var PARAMVALUE = MsSysParamSetDAL.GetData("PARAMNAME='MAILTONAME'");
|
|
|
if (PARAMVALUE.PARAMVALUE != "") MAILTONAME = PARAMVALUE.PARAMVALUE;
|
|
|
var MAILTOPASSWORD = "A1B2C3ds040201";//"ds!@#)(*";
|
|
|
PARAMVALUE = MsSysParamSetDAL.GetData("PARAMNAME='MAILTOPASSWORD'");
|
|
|
if (PARAMVALUE.PARAMVALUE != "") MAILTOPASSWORD = PARAMVALUE.PARAMVALUE;
|
|
|
var MAILTOSERVER = "smtpdm.aliyun.com";// "smtpcom.263xmail.com";
|
|
|
PARAMVALUE = MsSysParamSetDAL.GetData("PARAMNAME='MAILTOSERVER'");
|
|
|
if (PARAMVALUE.PARAMVALUE != "") MAILTOSERVER = PARAMVALUE.PARAMVALUE;
|
|
|
var MAILTOPORT = "80";// "465";
|
|
|
PARAMVALUE = MsSysParamSetDAL.GetData("PARAMNAME='MAILTOPORT'");
|
|
|
if (PARAMVALUE.PARAMVALUE != "") MAILTOPORT = PARAMVALUE.PARAMVALUE;
|
|
|
var MAILISSSL = false;
|
|
|
PARAMVALUE = MsSysParamSetDAL.GetData("PARAMNAME='MAILISSSL'");
|
|
|
if (PARAMVALUE.PARAMVALUE == "1") MAILISSSL = true;
|
|
|
|
|
|
SendEmail se = new SendEmail(EMAIL, MAILTONAME, "", "", mailtopic, mailbody, true);
|
|
|
// SendEmail se = new SendEmail("dev001@dongshengsoft.com", "admin@dongshengsoft.com", "", "", mailtopic, mailbody, false);
|
|
|
|
|
|
|
|
|
try
|
|
|
{
|
|
|
se.SetSmtp_thread(MAILTONAME, MAILTOPASSWORD, MAILTOSERVER, Convert.ToInt32(MAILTOPORT), MAILISSSL, System.Net.Mail.MailPriority.Normal);
|
|
|
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
se.SetSmtp_thread(MAILTONAME, MAILTOPASSWORD, MAILTOSERVER, Convert.ToInt32(MAILTOPORT), MAILISSSL, System.Net.Mail.MailPriority.Normal);
|
|
|
|
|
|
}
|
|
|
result.Success = true;
|
|
|
result.Message = "";
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
public static DBResult SendMail_SI(string SINO, string TYPE, string REASON,MsOpSeae headData, string EMAIL, string USERID, string COMPANYNAME)
|
|
|
{
|
|
|
|
|
|
DBResult result = new DBResult(true, "", null);
|
|
|
var bookingDB = new BookingDB();
|
|
|
var SI = bookingDB.Confirms.FirstOrDefault(o => o.SINO == SINO);
|
|
|
|
|
|
|
|
|
|
|
|
var mailtopic = TYPE + " MBLNO:" + SI.MBLNO+"|" + SI.CARRIER + "|ETD:" + SI.ETD + "|"+SI.CNTRTOTAL+"|" + SI.PORTDISCHARGE; ;
|
|
|
//var userlist = MsBaseInfoDAL.MsBaseInfoDAL.GetUserBaseList("USERID='" + userid + "'");
|
|
|
//var tel = "";
|
|
|
//var email = "";
|
|
|
var SENDEREMAIL = "";
|
|
|
var qq = "";
|
|
|
|
|
|
var p = BasicDataRefDAL.GetPhoneWithUserId(USERID, out SENDEREMAIL, out qq);
|
|
|
|
|
|
//if (!string.IsNullOrWhiteSpace(REASON)) {
|
|
|
// REASON = "原因:" + "</br>" + REASON;
|
|
|
//}
|
|
|
|
|
|
//var mailbody = "公司:" + COMPANYNAME + "\r\n" + "MBLNO:" + SI.MBLNO + "\r\n" + "订舱编号:" + SI.ORDERNO + "\r\n" + "卸货港:" + SI.PORTDISCHARGE + "\r\n" + "ETD:" + SI.ETD + "\r\n" + "" + REASON + "\r\n" + "邮箱:" + SENDEREMAIL;
|
|
|
var mailbody = "</br>" + "MBLNO:" + SI.MBLNO + "</br>"
|
|
|
+ "订舱编号:" + SI.ORDERNO + "</br>"
|
|
|
+ "卸货港:" + SI.PORTDISCHARGE + "</br>"
|
|
|
+ "ETD:" + SI.ETD + "</br>";
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(REASON))
|
|
|
{
|
|
|
mailbody += "原因:" + "</br>" + REASON + "</br>";
|
|
|
if (headData != null)
|
|
|
{
|
|
|
mailbody += getmailinfo(headData.OP, headData.SERVICE, headData.SALE);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
mailbody += "" + REASON + "";
|
|
|
|
|
|
mailbody += "</br>" + "</br>" + "</br>" + "<p style=\"color:blue\">本邮件为 " + COMPANYNAME + " 工作平台自动发送,请勿回复</p>";
|
|
|
//string toNames = "frank,lee";
|
|
|
|
|
|
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;
|
|
|
var MAILISSSL = false;
|
|
|
PARAMVALUE = MsSysParamSetDAL.GetData("PARAMNAME='MAILISSSL'");
|
|
|
if (PARAMVALUE.PARAMVALUE == "1") MAILISSSL = true;
|
|
|
|
|
|
SendEmail se = new SendEmail(EMAIL, MAILTONAME, "", "", mailtopic, mailbody, true);
|
|
|
// SendEmail se = new SendEmail("dev001@dongshengsoft.com", "admin@dongshengsoft.com", "", "", mailtopic, mailbody, false);
|
|
|
|
|
|
|
|
|
try
|
|
|
{
|
|
|
se.SetSmtp_thread(MAILTONAME, MAILTOPASSWORD, MAILTOSERVER, Convert.ToInt32(MAILTOPORT), MAILISSSL, System.Net.Mail.MailPriority.Normal);
|
|
|
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
se.SetSmtp_thread(MAILTONAME, MAILTOPASSWORD, MAILTOSERVER, Convert.ToInt32(MAILTOPORT), MAILISSSL, System.Net.Mail.MailPriority.Normal);
|
|
|
|
|
|
}
|
|
|
result.Success = true;
|
|
|
result.Message = "";
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
///
|
|
|
/// </summary>
|
|
|
/// <param name="opname">操作</param>
|
|
|
/// <param name="servicename">客服</param>
|
|
|
/// <param name="salename">销售</param>
|
|
|
/// <returns></returns>
|
|
|
private static string getmailinfo(string opname,string servicename,string salename)
|
|
|
{
|
|
|
var qq = "";
|
|
|
|
|
|
var result = "";
|
|
|
|
|
|
if(!string.IsNullOrWhiteSpace(opname))
|
|
|
result += "操作:" + getmailinfo(opname);
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(servicename))
|
|
|
result += "客服:" + getmailinfo(servicename);
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(salename))
|
|
|
result += "销售:" + getmailinfo(salename);
|
|
|
|
|
|
return result = "";
|
|
|
}
|
|
|
|
|
|
private static string getmailinfo(string showname) {
|
|
|
var qq = "";
|
|
|
|
|
|
var result = "";
|
|
|
|
|
|
var name = showname;
|
|
|
var mail = "";
|
|
|
var tel = BasicDataRefDAL.GetPhoneWithUserId(name, out mail, out qq);
|
|
|
|
|
|
return name + "< >" + tel + "< >" + mail+ "</br>";
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
}
|