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.
DS7/DSWeb/PriceCarrier/HtmlSearchServiceLCL.aspx.cs

538 lines
27 KiB
C#

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Text;
using System.Text.RegularExpressions;
using DSWeb.Models;
using DSWeb.EntityDA;
namespace DSWeb.PriceCarrier
{
public partial class HtmlSearchServiceLCL : System.Web.UI.Page
{
private int iPage;
private int iRows;
private string strSidx;
private string strSord;
private string strSearchString;
private string strUserName;
private string strPassWord;
private string strHandle;
private string strUserID;
private string strSearchOper;
public string strCompanyID="";//公司GID
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["handle"] != null)
{
strHandle = Request.QueryString["handle"].ToString().Trim().ToLower();
}
if (Request.QueryString["page"] != null)
{
iPage = int.Parse(Request.QueryString["page"].ToString());
}
else
{
iPage = 0;
}
if (Request.QueryString["rows"] != null)
{
iRows = int.Parse(Request.QueryString["rows"].ToString());
}
else
{
iRows = 0;
}
if (Request.QueryString["sidx"] != null)
{
strSidx = Request.QueryString["sidx"].ToString();
}
if (Request.QueryString["sord"] != null)
{
strSord = Request.QueryString["sord"].ToString();
}
if (Request.QueryString["searchField"] != null)
{
strUserID = Request.QueryString["searchField"].ToString().Trim();
}
if (Request.QueryString["searchString"] != null)
{
UnicodeEncoding unicode = new UnicodeEncoding();
strSearchString = unicode.GetString(unicode.GetBytes(Regex.Unescape(Request.QueryString["searchString"].ToString())));
}
if (Request.QueryString["searchOper"] != null)
{
strSearchOper = Request.QueryString["searchOper"].ToString();
if (strSearchOper.Trim().Equals("0"))
{
strSearchOper = " and 1>2";
}
else //if (strSearchOper.Trim().Equals("1"))
{
strSearchOper = "";
}
}
if (iPage > 0)
{
Response.Write(GetSearchSeaPrice());
}
if (Request.QueryString["username"] != null)
{
strUserName = Request.QueryString["username"].ToString().Trim();
}
if (Request.QueryString["password"] != null)
{
strPassWord = Request.QueryString["username"].ToString().Trim();
}
if (strHandle != null)
{
if (strUserName != null && strPassWord != null)
{
}
}
}
private bool ValidateSignIn(string strTempUserID)
{
bool bResult = false;
UserLoginStatusDA userLoginStatusDA = new UserLoginStatusDA();
UserLoginStatusEntity userLoginStatusEntity = new UserLoginStatusEntity();
//查看是否当前登录用户是否是时效内重新登录的用户
userLoginStatusEntity = userLoginStatusDA.GetLoginStatusByUserID(strUserID);
if (userLoginStatusEntity.GID != null)
{
DateTime signDateTime = userLoginStatusEntity.SignInTime;
DateTime serverDateTime = userLoginStatusEntity.ServerDateTime;
double expiresMinutes = double.Parse(userLoginStatusEntity.ExpiresMinutes.ToString());
if (signDateTime.AddMinutes(expiresMinutes).CompareTo(serverDateTime) <= 0)
{
//userLoginStatusDA.DeleteUserLoginStatus(userLoginStatusEntity.GID);
//userLoginStatusEntity.GID = Guid.NewGuid().ToString();
//userLoginStatusEntity.SessionID = "USERID";
//userLoginStatusEntity.ExpiresMinutes = 200;
//userLoginStatusDA.InsertLoginStatus(userLoginStatusEntity);
bResult = false;
}
else
{
userLoginStatusDA.UpdateLoginStatusForReSign(userLoginStatusEntity);
bResult = true;
}
}
else
{
bResult = false;//用户未正常登录
}
return bResult;
}
private int GetEBPriceQueryTotal()
{
EBPricequeryDA ebPriceQueryDA = new EBPricequeryDA();
string strSql = "SELECT COUNT(*) FROM eb_pricequery WHERE TYPE='LCL' and CORPID='" + strCompanyID.Trim() + "' " + strSearchOper;
//string strAuthorityCondition = "";
//UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modRecvSettleList");
//if (userAuthorityManage.OperateType != AuthorityType.NULL)
//{
// strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.RECVSETTLELIST, strShowName, strCompanyID, strDeptName, strUserID);
// strSql += strAuthorityCondition;
//}
string strCondition = "";
if (!ValidateSignIn(strUserID))
{
strSql = "SELECT COUNT(*) FROM eb_pricequery WHERE TYPE='LCL' and CORPID='" + strCompanyID.Trim() + "' " + strSearchOper;
}
else
{
if (strSearchString != null)
{
if (!strSearchString.Trim().Equals(""))
{
string tempSearch = strSearchString;
tempSearch = tempSearch.Replace("{", "");
tempSearch = tempSearch.Replace("}", "");
tempSearch = tempSearch.Replace("[", "");
tempSearch = tempSearch.Replace("]", "");
string[] searchArg = tempSearch.Split(new char[] { ',' });
for (int i = 0; i < searchArg.Length; i++)
{
if (i != (searchArg.Length - 1))
{
if (searchArg[i + 1].IndexOf(":") < 0)
{
string[] strArg = (searchArg[i] + "," + searchArg[i + 1]).Split(new char[] { ':' });
if (!strArg[1].Replace("\"", "").Trim().Equals(""))
{
switch (strArg[0].Replace("\"", ""))
{
case "companyid"://Customer
strCompanyID = strArg[1].Replace("\"", "").Replace("##", ",");
strCondition += String.Format(" AND CORPID= '{0}' ", strCompanyID.Trim());
break;
case "lane"://Customer
strCondition += String.Format(" AND LANE = '{0}' ", strArg[1].Replace("\"", "").Replace("##", ","));
break;
case "carr"://BillNO
strCondition += String.Format(" AND CARRIER = '{0}' ", strArg[1].Replace("\"", "").Replace("##", ","));
break;
case "dis"://ETD BeginDate
strCondition += String.Format(" AND DESTINATION = '{0}' ", strArg[1].Replace("\"", "").Replace("##", ","));
break;
case "load"://ETD EndDate
strCondition += String.Format(" AND PODLOAD = '{0}'", strArg[1].Replace("\"", "").Replace("##", ","));
break;
default:
break;
}
}
}
else
{
string[] strArg = searchArg[i].Split(new char[] { ':' });
if (!strArg[1].Replace("\"", "").Trim().Equals(""))
{
switch (strArg[0].Replace("\"", ""))
{
case "companyid"://Customer
strCompanyID = strArg[1].Replace("\"", "").Replace("##", ",");
strCondition += String.Format(" AND CORPID= '{0}' ", strCompanyID.Trim());
break;
case "lane"://Customer
strCondition += String.Format(" AND LANE = '{0}' ", strArg[1].Replace("\"", "").Replace("##", ","));
break;
case "carr"://BillNO
strCondition += String.Format(" AND CARRIER = '{0}' ", strArg[1].Replace("\"", "").Replace("##", ","));
break;
case "dis"://ETD BeginDate
strCondition += String.Format(" AND DESTINATION = '{0}' ", strArg[1].Replace("\"", "").Replace("##", ","));
break;
case "load"://ETD EndDate
strCondition += String.Format(" AND PODLOAD = '{0}'", strArg[1].Replace("\"", "").Replace("##", ","));
break;
default:
break;
}
}
}
}
else
{
if (searchArg[i].IndexOf(":") > 0)
{
string[] strArg = searchArg[i].Split(new char[] { ':' });
if (!strArg[1].Replace("\"", "").Trim().Equals(""))
{
switch (strArg[0].Replace("\"", ""))
{
case "companyid"://Customer
strCompanyID = strArg[1].Replace("\"", "").Replace("##", ",");
strCondition += String.Format(" AND CORPID= '{0}' ", strCompanyID.Trim());
break;
case "lane"://Customer
strCondition += String.Format(" AND LANE = '{0}' ", strArg[1].Replace("\"", "").Replace("##", ","));
break;
case "carr"://BillNO
strCondition += String.Format(" AND CARRIER = '{0}' ", strArg[1].Replace("\"", "").Replace("##", ","));
break;
case "dis"://ETD BeginDate
strCondition += String.Format(" AND DESTINATION = '{0}' ", strArg[1].Replace("\"", "").Replace("##", ","));
break;
case "load"://ETD EndDate
strCondition += String.Format(" AND PODLOAD = '{0}'", strArg[1].Replace("\"", "").Replace("##", ","));
break;
default:
break;
}
}
}
}
}
strSql += strCondition;
}
}
}
int iTotal = int.Parse(ebPriceQueryDA.GetExcuteSql(strSql).Tables[0].Rows[0][0].ToString());
return iTotal;
}
private string GetSearchSeaPrice()
{
EBPricequeryDA ebPriceQueryDA = new EBPricequeryDA();
DataTable sourceTable;
int iTotalCount = GetEBPriceQueryTotal();
string strCondition = "";
string strTopNotInclude = "";
string strTopInclude = "";
string strSql = "";
int iPageTotal = 0;
string strLane = "";
string strCarrier = "";
string strDischarge = "";
string strPortLoad = "";
if (strSearchString != null)
{
if (!strSearchString.Trim().Equals(""))
{
string tempSearch = strSearchString;
tempSearch = tempSearch.Replace("{", "");
tempSearch = tempSearch.Replace("}", "");
tempSearch = tempSearch.Replace("[", "");
tempSearch = tempSearch.Replace("]", "");
string[] searchArg = tempSearch.Split(new char[] { ',' });
for (int i = 0; i < searchArg.Length; i++)
{
if (i != (searchArg.Length - 1))
{
if (searchArg[i + 1].IndexOf(":") < 0)
{
string[] strArg = (searchArg[i] + "," + searchArg[i + 1]).Split(new char[] { ':' });
if (!strArg[1].Replace("\"", "").Trim().Equals(""))
{
switch (strArg[0].Replace("\"", ""))
{
case "companyid"://Customer
strCompanyID = strArg[1].Replace("\"", "").Replace("##", ",");
strCondition += String.Format(" AND CORPID= '{0}' ", strCompanyID.Trim());
break;
case "lane"://Customer
strCondition += String.Format(" AND LANE = '{0}' ", strArg[1].Replace("\"", "").Replace("##", ","));
strLane = strArg[1].Replace("\"", "").Replace("##", ",");
break;
case "carr"://BillNO
strCondition += String.Format(" AND CARRIER = '{0}' ", strArg[1].Replace("\"", "").Replace("##", ","));
strCarrier = strArg[1].Replace("\"", "").Replace("##", ",");
break;
case "dis"://ETD BeginDate
strCondition += String.Format(" AND DESTINATION = '{0}' ", strArg[1].Replace("\"", "").Replace("##", ","));
strDischarge = strArg[1].Replace("\"", "").Replace("##", ",");
break;
case "load"://ETD EndDate
strCondition += String.Format(" AND PODLOAD = '{0}'", strArg[1].Replace("\"", "").Replace("##", ","));
strPortLoad = strArg[1].Replace("\"", "").Replace("##", ",");
break;
default:
break;
}
}
}
else
{
string[] strArg = searchArg[i].Split(new char[] { ':' });
if (!strArg[1].Replace("\"", "").Trim().Equals(""))
{
switch (strArg[0].Replace("\"", ""))
{
case "companyid"://Customer
strCompanyID = strArg[1].Replace("\"", "").Replace("##", ",");
strCondition += String.Format(" AND CORPID= '{0}' ", strCompanyID.Trim());
break;
case "lane"://Customer
strCondition += String.Format(" AND LANE = '{0}' ", strArg[1].Replace("\"", "").Replace("##", ","));
strLane = strArg[1].Replace("\"", "").Replace("##", ",");
break;
case "carr"://BillNO
strCondition += String.Format(" AND CARRIER = '{0}' ", strArg[1].Replace("\"", "").Replace("##", ","));
strCarrier = strArg[1].Replace("\"", "").Replace("##", ",");
break;
case "dis"://ETD BeginDate
strCondition += String.Format(" AND DESTINATION = '{0}' ", strArg[1].Replace("\"", "").Replace("##", ","));
strDischarge = strArg[1].Replace("\"", "").Replace("##", ",");
break;
case "load"://ETD EndDate
strCondition += String.Format(" AND PODLOAD = '{0}'", strArg[1].Replace("\"", "").Replace("##", ","));
strPortLoad = strArg[1].Replace("\"", "").Replace("##", ",");
break;
default:
break;
}
}
}
}
else
{
if (searchArg[i].IndexOf(":") > 0)
{
string[] strArg = searchArg[i].Split(new char[] { ':' });
if (!strArg[1].Replace("\"", "").Trim().Equals(""))
{
switch (strArg[0].Replace("\"", ""))
{
case "companyid"://Customer
strCompanyID = strArg[1].Replace("\"", "").Replace("##", ",");
strCondition += String.Format(" AND CORPID= '{0}' ", strCompanyID.Trim());
break;
case "lane"://Customer
strCondition += String.Format(" AND LANE = '{0}' ", strArg[1].Replace("\"", "").Replace("##", ","));
strLane = strArg[1].Replace("\"", "").Replace("##", ",");
break;
case "carr"://BillNO
strCondition += String.Format(" AND CARRIER = '{0}' ", strArg[1].Replace("\"", "").Replace("##", ","));
strCarrier = strArg[1].Replace("\"", "").Replace("##", ",");
break;
case "dis"://ETD BeginDate
strCondition += String.Format(" AND DESTINATION = '{0}' ", strArg[1].Replace("\"", "").Replace("##", ","));
strDischarge = strArg[1].Replace("\"", "").Replace("##", ",");
break;
case "load"://ETD EndDate
strCondition += String.Format(" AND PODLOAD = '{0}'", strArg[1].Replace("\"", "").Replace("##", ","));
strPortLoad = strArg[1].Replace("\"", "").Replace("##", ",");
break;
default:
break;
}
}
}
}
}
}
}
if (iTotalCount > 0)
{
iPageTotal = (iTotalCount % iRows) > 0 ? ((iTotalCount / iRows) + 1) : (iTotalCount / iRows);
}
else
{
iPageTotal = 0;
}
if (!ValidateSignIn(strUserID))
{
//strSql = String.Format(" SELECT GID,LANE,DESTINATION,CARRIER,LCLPRICE,ETD,TT,VIA,EFFECTIVEDATE,CISF,REMARK,REMARK2 FROM eb_pricequery WHERE TYPE='LCL' " + strSearchOper);
if (iPage > 0 && iRows > 0)
{
if (iPage == 1)
{
strSql = String.Format(" SELECT {0} GID,LANE,DESTINATION,CARRIER,LCLPRICE,ETD,TT,VIA,EFFECTIVEDATE,CISF,REMARK,REMARK2 FROM eb_pricequery WHERE TYPE='LCL' " + strCondition + strSearchOper + " ORDER BY " + strSidx + " " + strSord + " ", "top " + iRows.ToString());
}
else
{
strTopNotInclude = "top " + (iRows * (iPage - 1)).ToString();//RowCount*PageNum
strTopInclude = "top " + iRows.ToString();
strSql = String.Format(" SELECT {0} GID,LANE,DESTINATION,CARRIER,LCLPRICE,ETD,TT,VIA,EFFECTIVEDATE,CISF,REMARK,REMARK2 FROM eb_pricequery WHERE GID NOT IN (SELECT {1} GID FROM eb_pricequery WHERE TYPE='LCL' " + strCondition + strSearchOper + " ORDER BY " + strSidx + " " + strSord + " ) and TYPE='LCL' " + strCondition + strSearchOper + " ORDER BY " + strSidx + " " + strSord + " ", strTopInclude, strTopNotInclude);
}
}
else
{
strSql = String.Format(" SELECT GID,LANE,DESTINATION,CARRIER,LCLPRICE,ETD,TT,VIA,EFFECTIVEDATE,CISF,REMARK,REMARK2 FROM eb_pricequery WHERE TYPE='LCL' " + strCondition + strSearchOper + " ORDER BY " + strSidx + " " + strSord + " ");
}
}
else
{
if (iPage > 0 && iRows > 0)
{
if (iPage == 1)
{
strSql = String.Format(" SELECT {0} GID,LANE,DESTINATION,CARRIER,LCLPRICE,ETD,TT,VIA,EFFECTIVEDATE,CISF,REMARK,REMARK2 FROM eb_pricequery "
+ " WHERE TYPE='LCL' " + strCondition + strSearchOper + " ORDER BY " + strSidx + " " + strSord + " ", "top " + iRows.ToString());
}
else
{
strTopNotInclude = "top " + (iRows * (iPage - 1)).ToString();//RowCount*PageNum
strTopInclude = "top " + iRows.ToString();
strSql = String.Format(" SELECT {0} GID,LANE,DESTINATION,CARRIER,LCLPRICE,ETD,TT,VIA,EFFECTIVEDATE,CISF,REMARK,REMARK2 FROM eb_pricequery WHERE GID NOT IN (SELECT {1} GID FROM eb_pricequery WHERE TYPE='LCL' " + strCondition + strSearchOper + " ORDER BY " + strSidx + " " + strSord + " ) and TYPE='LCL' " + strCondition + strSearchOper + " ORDER BY " + strSidx + " " + strSord + " ", strTopInclude, strTopNotInclude);
}
}
else
{
strSql = String.Format(" SELECT GID,LANE,DESTINATION,CARRIER,LCLPRICE,ETD,TT,VIA,EFFECTIVEDATE,CISF,REMARK,REMARK2 FROM eb_pricequery WHERE TYPE='LCL' " + strCondition + strSearchOper + " ORDER BY " + strSidx + " " + strSord + " ");
}
}
sourceTable = ebPriceQueryDA.GetExcuteSql(strSql).Tables[0];
StringBuilder sourceBuilder = new StringBuilder();
sourceBuilder.Append("{");
sourceBuilder.Append("\"griddatas\":[");
for (int i = 0; i < sourceTable.Rows.Count; i++)
{
sourceBuilder.Append("{\"id\":\"" + sourceTable.Rows[i][0].ToString() + "\",");
//sourceBuilder.Append("data:[");
//sourceBuilder.Append("\"0\",");
for (int j = 1; j < sourceTable.Columns.Count; j++)
{
string ls = sourceTable.Rows[i][j].ToString();
ls = ls.Replace("\r\n", " ");
ls = ls.Replace("\n", " ");
//
if (j == sourceTable.Columns.Count - 1)
{
sourceBuilder.Append("\"" + sourceTable.Columns[j].ColumnName.ToString().ToLower() + "\":\"" + ls + "\"");
}
else
{
sourceBuilder.Append("\"" + sourceTable.Columns[j].ColumnName.ToString().ToLower() + "\":\"" + ls + "\",");
}
}
if (i == sourceTable.Rows.Count - 1)
{
sourceBuilder.Append("}");
}
else
{
sourceBuilder.Append("},");
}
}
sourceBuilder.Append("],");
sourceBuilder.Append("\"page\": " + iPage + ",");
sourceBuilder.Append("\"record\":" + iTotalCount + ",");
sourceBuilder.Append("\"rows\": " + iRows + ",");
sourceBuilder.Append("\"total\":" + iPageTotal);
sourceBuilder.Append("}");
string alt = "'" + strPortLoad + "','','" + strCarrier + "','" + strLane + "','" + strDischarge + "','LCL'";
//
if (strLane != "" || strCarrier != "" || strDischarge != "" || strPortLoad != "")
{
T_ALL_DA T_ALL_DA = new T_ALL_DA();
bool bl = T_ALL_DA.GetEBPricequeryListLOG(alt, strUserID, strCompanyID.Trim());
}
return sourceBuilder.ToString();
}
}
}