|
|
using BookingJieFeng.DB;
|
|
|
using BookingJieFeng.DB.Model;
|
|
|
using BookingJieFeng.Helper;
|
|
|
using BookingJieFeng.Models;
|
|
|
using Resources;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.IO;
|
|
|
using System.Linq;
|
|
|
using System.Runtime.Caching;
|
|
|
using System.Text;
|
|
|
using System.Web;
|
|
|
using System.Web.Mvc;
|
|
|
using System.Web.Security;
|
|
|
|
|
|
namespace BookingJieFeng.Controllers
|
|
|
{
|
|
|
public class CommonController : Controller
|
|
|
{
|
|
|
private JiefengDB jiefengDB = new JiefengDB();
|
|
|
private BookingDB bookingDB = new BookingDB();
|
|
|
|
|
|
public ActionResult GetCaptcha()
|
|
|
{
|
|
|
DrawCaptchaHelper objDrawValidationCode = new DrawCaptchaHelper();
|
|
|
objDrawValidationCode.Width = 100;
|
|
|
objDrawValidationCode.Height = 30;
|
|
|
|
|
|
objDrawValidationCode.CaptchaLength = 4;//验证码字符个数
|
|
|
objDrawValidationCode.IsPixel = false;//随机噪点
|
|
|
|
|
|
objDrawValidationCode.RandomStringCount = 2; //干扰字符个数
|
|
|
objDrawValidationCode.RandomStringFontSize = 20;//干扰字符字体大小
|
|
|
|
|
|
objDrawValidationCode.FontMinSize = 20;//验证码字体的大小的最小值
|
|
|
objDrawValidationCode.FontMaxSize = 22; //验证码字体的大小的最大值
|
|
|
|
|
|
//objDrawValidationCode.GaussianDeviation = 3; //默认0,不使用高斯模糊算法处理图像。
|
|
|
//objDrawValidationCode.BrightnessValue = 5; //明暗度,默认0,是使用明暗度算法处理图像
|
|
|
|
|
|
objDrawValidationCode.LineCount = 1; //默认3条。
|
|
|
objDrawValidationCode.BezierCount = 1;//默认3条。
|
|
|
|
|
|
//边框样式
|
|
|
//objDrawValidationCode.Border = DrawCaptchaHelper.BorderStyle.RoundRectangle;
|
|
|
|
|
|
MemoryStream ms = new MemoryStream();
|
|
|
objDrawValidationCode.CreateImage(ms);
|
|
|
ms.Position = 0;
|
|
|
Session["ValidateCode"] = objDrawValidationCode.CaptchaStr;//将验证码字符串存入session,用于登录验证
|
|
|
return File(ms, "image/jpeg");
|
|
|
}
|
|
|
|
|
|
public ActionResult GetMobileCode(string mobile)
|
|
|
{
|
|
|
RespCommon resp = new RespCommon();
|
|
|
string key1 = $"REM_{mobile}";
|
|
|
string key2 = $"MC_{mobile}";
|
|
|
if (MemoryCache.Default.Contains(key1))
|
|
|
{
|
|
|
resp.Success = false;
|
|
|
resp.Message = LangCommon.MsgGetCodeFrequent;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Random rnd = new Random();
|
|
|
string code = rnd.Next(1000, 10000).ToString();
|
|
|
MemoryCache.Default.Add(new CacheItem(key1, true), new CacheItemPolicy() { AbsoluteExpiration = DateTime.Now.AddSeconds(120) });
|
|
|
MemoryCache.Default.Remove(key2);
|
|
|
MemoryCache.Default.Add(new CacheItem(key2, code), new CacheItemPolicy() { AbsoluteExpiration = DateTime.Now.AddMinutes(5) });
|
|
|
AliMessageTools.SendSignCodeMsg(mobile, code);
|
|
|
resp.Success = true;
|
|
|
resp.Message = LangCommon.MsgMobileCodeSent;
|
|
|
}
|
|
|
|
|
|
return Json(resp);
|
|
|
}
|
|
|
|
|
|
//场站检索 Bootstrap Search Suggest
|
|
|
public ActionResult SuggestYard(string keyword)
|
|
|
{
|
|
|
RespSuggest resp = new RespSuggest();
|
|
|
if (!string.IsNullOrEmpty(keyword))
|
|
|
{
|
|
|
resp.value = jiefengDB.CrmClients.Where(y => y.场站 == true && (y.代码.IndexOf(keyword.ToLower()) > -1 || y.客户简称.IndexOf(keyword) > -1)).Select(y => new
|
|
|
{
|
|
|
CODENAME = y.代码,
|
|
|
SHORTNAME = y.客户简称
|
|
|
}).ToList();
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
resp.value = jiefengDB.CrmClients.Where(y => y.场站 == true).Select(y => new
|
|
|
{
|
|
|
CODENAME = y.代码,
|
|
|
SHORTNAME = y.客户简称
|
|
|
}).ToList();
|
|
|
|
|
|
}
|
|
|
resp.code = 200;
|
|
|
return Json(resp, JsonRequestBehavior.AllowGet);
|
|
|
|
|
|
}
|
|
|
|
|
|
//船公司检索 Bootstrap Search Suggest
|
|
|
public ActionResult SuggestCarrier(string keyword)
|
|
|
{
|
|
|
RespSuggest resp = new RespSuggest();
|
|
|
if (!string.IsNullOrEmpty(keyword))
|
|
|
{
|
|
|
resp.value = jiefengDB.CrmClients.Where(y => y.船公司 == true && (y.代码.IndexOf(keyword.ToLower()) > -1 || y.客户简称.IndexOf(keyword) > -1)).Select(y => new
|
|
|
{
|
|
|
CODENAME = y.代码,
|
|
|
SHORTNAME = y.客户简称
|
|
|
}).ToList();
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
resp.value = jiefengDB.CrmClients.Where(y => y.船公司 == true).Select(y => new
|
|
|
{
|
|
|
CODENAME = y.代码,
|
|
|
SHORTNAME = y.客户简称
|
|
|
}).ToList();
|
|
|
|
|
|
}
|
|
|
resp.code = 200;
|
|
|
return Json(resp, JsonRequestBehavior.AllowGet);
|
|
|
|
|
|
}
|
|
|
|
|
|
//装货港检索 Bootstrap Search Suggest
|
|
|
public ActionResult SuggestLoadport(string keyword)
|
|
|
{
|
|
|
RespSuggest resp = new RespSuggest();
|
|
|
if (!string.IsNullOrEmpty(keyword))
|
|
|
{
|
|
|
resp.value = jiefengDB.Loadports.Where(y => y.英文名.IndexOf(keyword.ToLower()) > -1 || y.EDI代码.IndexOf(keyword.ToLower()) > -1).Select(y => new
|
|
|
{
|
|
|
EDICODE = y.EDI代码,
|
|
|
PORT = y.英文名
|
|
|
}).ToList();
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
resp.value = jiefengDB.Loadports.Select(y => new
|
|
|
{
|
|
|
EDICODE = y.EDI代码,
|
|
|
PORT = y.英文名
|
|
|
}).ToList();
|
|
|
|
|
|
}
|
|
|
resp.code = 200;
|
|
|
return Json(resp, JsonRequestBehavior.AllowGet);
|
|
|
|
|
|
}
|
|
|
|
|
|
//卸货港检索 Bootstrap Search Suggest
|
|
|
public ActionResult SuggestDisport(string keyword)
|
|
|
{
|
|
|
RespSuggest resp = new RespSuggest();
|
|
|
if (!string.IsNullOrEmpty(keyword))
|
|
|
{
|
|
|
resp.value = jiefengDB.Disports.Where(y => y.英文名.IndexOf(keyword.ToLower()) > -1 || y.EDI代码.IndexOf(keyword.ToLower()) > -1).Select(y => new
|
|
|
{
|
|
|
EDICODE = y.EDI代码,
|
|
|
PORT = y.英文名
|
|
|
}).ToList();
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
resp.value = jiefengDB.Disports.Select(y => new
|
|
|
{
|
|
|
EDICODE = y.EDI代码,
|
|
|
PORT = y.英文名
|
|
|
}).ToList();
|
|
|
|
|
|
}
|
|
|
resp.code = 200;
|
|
|
return Json(resp, JsonRequestBehavior.AllowGet);
|
|
|
|
|
|
}
|
|
|
|
|
|
//签单方式检索 Bootstrap Search Suggest
|
|
|
public ActionResult SuggestIssuType(string keyword)
|
|
|
{
|
|
|
RespSuggest resp = new RespSuggest();
|
|
|
if (!string.IsNullOrEmpty(keyword))
|
|
|
{
|
|
|
resp.value = jiefengDB.IssuTypes.Where(y => y.签单方式.IndexOf(keyword.ToLower()) > -1).Select(y => new
|
|
|
{
|
|
|
GID = y.代码,
|
|
|
BLTYPE = y.签单方式
|
|
|
}).ToList();
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
resp.value = jiefengDB.IssuTypes.Select(y => new
|
|
|
{
|
|
|
GID = y.代码,
|
|
|
BLTYPE = y.签单方式
|
|
|
}).ToList();
|
|
|
|
|
|
}
|
|
|
resp.code = 200;
|
|
|
return Json(resp, JsonRequestBehavior.AllowGet);
|
|
|
|
|
|
}
|
|
|
|
|
|
//付费方式检索 Bootstrap Search Suggest
|
|
|
public ActionResult SuggestFRT(string keyword)
|
|
|
{
|
|
|
RespSuggest resp = new RespSuggest();
|
|
|
if (!string.IsNullOrEmpty(keyword))
|
|
|
{
|
|
|
resp.value = jiefengDB.Frts.Where(y => y.付费方式.IndexOf(keyword.ToLower()) > -1 || y.中文名称.IndexOf(keyword) > -1).Select(y => new
|
|
|
{
|
|
|
FRT = y.付费方式,
|
|
|
FRTCNAME = y.中文名称
|
|
|
}).ToList();
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
resp.value = jiefengDB.Frts.Select(y => new
|
|
|
{
|
|
|
FRT = y.付费方式,
|
|
|
FRTCNAME = y.中文名称
|
|
|
}).ToList();
|
|
|
|
|
|
}
|
|
|
resp.code = 200;
|
|
|
return Json(resp, JsonRequestBehavior.AllowGet);
|
|
|
|
|
|
}
|
|
|
|
|
|
//包装检索 Bootstrap Search Suggest
|
|
|
public ActionResult SuggestPackage(string keyword)
|
|
|
{
|
|
|
RespSuggest resp = new RespSuggest();
|
|
|
if (!string.IsNullOrEmpty(keyword))
|
|
|
{
|
|
|
resp.value = jiefengDB.Packages.Where(y => y.包装名称.IndexOf(keyword.ToLower()) > -1).Select(y => new
|
|
|
{
|
|
|
GID = y.代码,
|
|
|
PKGS = y.包装名称
|
|
|
}).ToList();
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
resp.value = jiefengDB.Packages.Select(y => new
|
|
|
{
|
|
|
GID = y.代码,
|
|
|
PKGS = y.包装名称
|
|
|
}).ToList();
|
|
|
|
|
|
}
|
|
|
resp.code = 200;
|
|
|
return Json(resp, JsonRequestBehavior.AllowGet);
|
|
|
|
|
|
}
|
|
|
|
|
|
//运输条款 Bootstrap Search Suggest
|
|
|
public ActionResult SuggestService(string keyword)
|
|
|
{
|
|
|
RespSuggest resp = new RespSuggest();
|
|
|
if (!string.IsNullOrEmpty(keyword))
|
|
|
{
|
|
|
resp.value = jiefengDB.Services.Where(y => y.运输条款.IndexOf(keyword.ToLower()) > -1).Select(y => new
|
|
|
{
|
|
|
GID = y.代码,
|
|
|
SERVICE = y.运输条款
|
|
|
}).ToList();
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
resp.value = jiefengDB.Services.Select(y => new
|
|
|
{
|
|
|
GID = y.代码,
|
|
|
SERVICE = y.运输条款
|
|
|
}).ToList();
|
|
|
|
|
|
}
|
|
|
resp.code = 200;
|
|
|
return Json(resp, JsonRequestBehavior.AllowGet);
|
|
|
|
|
|
}
|
|
|
|
|
|
//船名 Bootstrap Search Suggest
|
|
|
public ActionResult SuggestVESSEL(string keyword)
|
|
|
{
|
|
|
RespSuggest resp = new RespSuggest();
|
|
|
if (!string.IsNullOrEmpty(keyword))
|
|
|
{
|
|
|
resp.value = jiefengDB.Vessels.Where(y => y.英文船名.IndexOf(keyword.ToLower()) > -1).Select(y => new
|
|
|
{
|
|
|
VSID = y.VS_ID,
|
|
|
VESSEL = y.英文船名
|
|
|
}).ToList();
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
resp.value = jiefengDB.Vessels.Select(y => new
|
|
|
{
|
|
|
VSID = y.VS_ID,
|
|
|
VESSEL = y.英文船名
|
|
|
}).ToList();
|
|
|
|
|
|
}
|
|
|
resp.code = 200;
|
|
|
return Json(resp, JsonRequestBehavior.AllowGet);
|
|
|
|
|
|
}
|
|
|
|
|
|
//箱型 Bootstrap Search Suggest
|
|
|
public ActionResult SuggestCTN(string keyword)
|
|
|
{
|
|
|
RespSuggest resp = new RespSuggest();
|
|
|
if (!string.IsNullOrEmpty(keyword))
|
|
|
{
|
|
|
resp.value = jiefengDB.Ctns.Where(y => y.EDI代码.IndexOf(keyword.ToLower()) > -1).Select(y => new
|
|
|
{
|
|
|
CTNID = y.代码,
|
|
|
CTN = y.MSC代码
|
|
|
}).ToList();
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
resp.value = jiefengDB.Ctns.Select(y => new
|
|
|
{
|
|
|
CTNID = y.代码,
|
|
|
CTN = y.MSC代码
|
|
|
}).ToList();
|
|
|
|
|
|
}
|
|
|
resp.code = 200;
|
|
|
return Json(resp, JsonRequestBehavior.AllowGet);
|
|
|
|
|
|
}
|
|
|
|
|
|
//国家 Bootstrap Search Suggest
|
|
|
public ActionResult SuggestCountry(string keyword)
|
|
|
{
|
|
|
RespSuggest resp = new RespSuggest();
|
|
|
if (!string.IsNullOrEmpty(keyword))
|
|
|
{
|
|
|
resp.value = bookingDB.Countries.Where(y => y.NAME.IndexOf(keyword) > -1 || y.CODE.IndexOf(keyword.ToLower()) > -1).Select(y => new
|
|
|
{
|
|
|
y.NAME,
|
|
|
y.CODE
|
|
|
}).ToList();
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
resp.value = bookingDB.Countries.Select(y => new
|
|
|
{
|
|
|
y.NAME,
|
|
|
y.CODE
|
|
|
}).ToList();
|
|
|
|
|
|
}
|
|
|
resp.code = 200;
|
|
|
return Json(resp, JsonRequestBehavior.AllowGet);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
} |