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 DSWeb.EntityDA; using DSWeb.Authority; using System.Text; namespace DSWeb.Charts { public partial class ChartGridSource : System.Web.UI.Page { private string strHandle; public string strUserID;//用户GID private string strCompanyID;//公司GID private string strShowName;//用户显示名 private string strDeptName;//部门名称 private string strSortName;//排序名称 private string strSortIndex;//排序方向 asc desc private string strSearchCacheName;//综合查询条件缓存 private string stroplb = "";//业务类别 protected void Page_Load(object sender, EventArgs e) { if (Session["USERID"] != null) { strUserID = Session["USERID"].ToString().Trim(); } if (Session["SHOWNAME"] != null) { strShowName = Session["SHOWNAME"].ToString(); } if (Session["COMPANYID"] != null) { strCompanyID = Session["COMPANYID"].ToString(); } if (Session["DEPTNAME"] != null) { strDeptName = Session["DEPTNAME"].ToString(); } if (Request.QueryString["handle"] != null) { strHandle = Request.QueryString["handle"].ToString().Trim().ToLower(); } if (Request.QueryString["oplb"] != null) { stroplb = Request.QueryString["oplb"].ToString(); } if (Request.QueryString["sort"] != null) { strSortName = Request.QueryString["sort"].ToString().Trim().ToUpper(); } if (Request.QueryString["sortindex"] != null) { strSortIndex = Request.QueryString["sortindex"].ToString().Trim().ToUpper(); if (strSortIndex.Equals("DES")) { strSortIndex = "DESC"; } } if (Request.QueryString["searchcachename"] != null) { strSearchCacheName = Request.QueryString["searchcachename"].ToString(); } if (strHandle != null) { if (strHandle == "opseaetotal") { Response.Write(GetOpSeaeTotalSource()); } if (strHandle == "opseaechartjson") { Response.Write(GetOpSeaeTotalChartJson()); } } } #region 获取海运出口统计图表信息(列表信息) /// /// 获取海运出口统计图表信息(列表信息) /// /// 返回列表信息 public string GetOpSeaeTotalSource() { ReportDA reportDA = new ReportDA(); DataTable sourceTable; string strCondition = ""; string tempCacheSearch = ""; if (strSearchCacheName != null) { tempCacheSearch = Session[strSearchCacheName].ToString(); string tempSearch = tempCacheSearch; tempSearch = tempSearch.Replace("{", ""); tempSearch = tempSearch.Replace("}", ""); tempSearch = tempSearch.Replace("[", ""); tempSearch = tempSearch.Replace("]", ""); string[] searchArg = tempSearch.Split(new char[] { ',' }); ArrayList optionList = new ArrayList(); for (int i = 0; i < searchArg.Length; i++) { string[] strArg = searchArg[i].Split(new char[] { ':' }); //if (!strArg[1].Replace("\"", "").Trim().Equals("")) //{ switch (strArg[0].Replace("\"", "")) { case "search1"://search1 strCondition += "( " + String.Format(" {0} ", strArg[1].Replace("\"", "").Trim().ToUpper()); break; case "equal1"://equal1 strCondition += GetEqual(strArg[1].Replace("\"", "").Trim().ToLower()); break; case "type1"://type1 strCondition = String.Format(strCondition, GetEqualValueType(strArg[1].Replace("\"", "").Trim().ToLower())); break; case "value1"://value1 strCondition = String.Format(strCondition, strArg[1].Replace("\"", "").Trim()) + " )"; break; case "option2": strCondition = GetOption(strArg[1].Replace("\"", "").Trim(), optionList, strCondition); optionList.Add(strArg[1].Replace("\"", "").Trim()); break; case "search2"://search2 strCondition += "( " + String.Format(" {0} ", strArg[1].Replace("\"", "").Trim().ToUpper()); break; case "equal2"://equal2 strCondition += GetEqual(strArg[1].Replace("\"", "").Trim().ToLower()); break; case "type2"://type2 strCondition = String.Format(strCondition, GetEqualValueType(strArg[1].Replace("\"", "").Trim().ToLower())); break; case "value2"://value3 strCondition = String.Format(strCondition, strArg[1].Replace("\"", "").Trim()) + " )"; break; case "option3": strCondition = GetOption(strArg[1].Replace("\"", "").Trim(), optionList, strCondition); optionList.Add(strArg[1].Replace("\"", "").Trim()); break; case "search3"://search3 strCondition += "( " + String.Format(" {0} ", strArg[1].Replace("\"", "").Trim().ToUpper()); break; case "equal3"://equal3 strCondition += GetEqual(strArg[1].Replace("\"", "").Trim().ToLower()); break; case "type3"://type3 strCondition = String.Format(strCondition, GetEqualValueType(strArg[1].Replace("\"", "").Trim().ToLower())); break; case "value3"://value4 strCondition = String.Format(strCondition, strArg[1].Replace("\"", "").Trim()) + " )"; break; case "option4": strCondition = GetOption(strArg[1].Replace("\"", "").Trim(), optionList, strCondition); optionList.Add(strArg[1].Replace("\"", "").Trim()); break; case "search4"://search4 strCondition += "( " + String.Format(" {0} ", strArg[1].Replace("\"", "").Trim().ToUpper()); break; case "equal4"://equal4 strCondition += GetEqual(strArg[1].Replace("\"", "").Trim().ToLower()); break; case "type4"://type4 strCondition = String.Format(strCondition, GetEqualValueType(strArg[1].Replace("\"", "").Trim().ToLower())); break; case "value4"://value4 strCondition = String.Format(strCondition, strArg[1].Replace("\"", "").Trim()) + " )"; break; case "option5": strCondition = GetOption(strArg[1].Replace("\"", "").Trim(), optionList, strCondition); optionList.Add(strArg[1].Replace("\"", "").Trim()); break; case "search5"://search5 strCondition += "( " + String.Format(" {0} ", strArg[1].Replace("\"", "").Trim().ToUpper()); break; case "equal5"://equal5 strCondition += GetEqual(strArg[1].Replace("\"", "").Trim().ToLower()); break; case "type5"://type5 strCondition = String.Format(strCondition, GetEqualValueType(strArg[1].Replace("\"", "").Trim().ToLower())); break; case "value5"://value5 strCondition = String.Format(strCondition, strArg[1].Replace("\"", "").Trim()) + " )"; break; case "option6": strCondition = GetOption(strArg[1].Replace("\"", "").Trim(), optionList, strCondition); optionList.Add(strArg[1].Replace("\"", "").Trim()); break; case "search6"://search6 strCondition += "( " + String.Format(" {0} ", strArg[1].Replace("\"", "").Trim().ToUpper()); break; case "equal6"://equal6 strCondition += GetEqual(strArg[1].Replace("\"", "").Trim().ToLower()); break; case "type6"://type6 strCondition = String.Format(strCondition, GetEqualValueType(strArg[1].Replace("\"", "").Trim().ToLower())); break; case "value6"://value6 strCondition = String.Format(strCondition, strArg[1].Replace("\"", "").Trim()) + " )"; break; default: break; } //} } strCondition = " AND " + strCondition + " "; } string strAuthorityCondition = ""; UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modOrderManagement"); if (userAuthorityManage.OperateType != AuthorityType.NULL) { if (stroplb == "op_Seae") { strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.OPSEAELIST, strShowName, strCompanyID, strDeptName, strUserID); } else if (stroplb == "op_Seai") { strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.OPSEAILIST, strShowName, strCompanyID, strDeptName, strUserID); } } string strSortCondition = ""; if (strSortName != null && strSortIndex != null) { strSortCondition = String.Format(" ORDER BY {0} {1}", strSortName, strSortIndex); } else { strSortCondition = String.Format(" ORDER BY {0} {1}", "YEARINT", "DESC"); } sourceTable = reportDA.GetDataTableSourceByCondtion(ReportType.OPSEAETOTAL, (strAuthorityCondition + strCondition),strSortCondition); StringBuilder sourceBuilder = new StringBuilder(); sourceBuilder.Append("{"); sourceBuilder.Append("rows:["); 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++) { if (j == sourceTable.Columns.Count - 1) { sourceBuilder.Append("\"" + sourceTable.Rows[i][j].ToString() + "\""); } else { sourceBuilder.Append("\"" + sourceTable.Rows[i][j].ToString() + "\","); } } if (i == sourceTable.Rows.Count - 1) { sourceBuilder.Append("]}"); } else { sourceBuilder.Append("]},"); } } sourceBuilder.Append("]"); sourceBuilder.Append("}"); return sourceBuilder.ToString(); } #endregion #region 获取海运出口统计信息图标JSON信息 /// /// 获取海运出口统计信息图标JSON信息 /// /// 返回JSON数据 public string GetOpSeaeTotalChartJson() { ReportDA reportDA = new ReportDA(); DataTable sourceTable; string strCondition = ""; string tempCacheSearch = ""; if (strSearchCacheName != null) { tempCacheSearch = Session[strSearchCacheName].ToString(); string tempSearch = tempCacheSearch; tempSearch = tempSearch.Replace("{", ""); tempSearch = tempSearch.Replace("}", ""); tempSearch = tempSearch.Replace("[", ""); tempSearch = tempSearch.Replace("]", ""); string[] searchArg = tempSearch.Split(new char[] { ',' }); ArrayList optionList = new ArrayList(); for (int i = 0; i < searchArg.Length; i++) { string[] strArg = searchArg[i].Split(new char[] { ':' }); //if (!strArg[1].Replace("\"", "").Trim().Equals("")) //{ switch (strArg[0].Replace("\"", "")) { case "search1"://search1 strCondition += "( " + String.Format(" {0} ", strArg[1].Replace("\"", "").Trim().ToUpper()); break; case "equal1"://equal1 strCondition += GetEqual(strArg[1].Replace("\"", "").Trim().ToLower()); break; case "type1"://type1 strCondition = String.Format(strCondition, GetEqualValueType(strArg[1].Replace("\"", "").Trim().ToLower())); break; case "value1"://value1 strCondition = String.Format(strCondition, strArg[1].Replace("\"", "").Trim()) + " )"; break; case "option2": strCondition = GetOption(strArg[1].Replace("\"", "").Trim(), optionList, strCondition); optionList.Add(strArg[1].Replace("\"", "").Trim()); break; case "search2"://search2 strCondition += "( " + String.Format(" {0} ", strArg[1].Replace("\"", "").Trim().ToUpper()); break; case "equal2"://equal2 strCondition += GetEqual(strArg[1].Replace("\"", "").Trim().ToLower()); break; case "type2"://type2 strCondition = String.Format(strCondition, GetEqualValueType(strArg[1].Replace("\"", "").Trim().ToLower())); break; case "value2"://value3 strCondition = String.Format(strCondition, strArg[1].Replace("\"", "").Trim()) + " )"; break; case "option3": strCondition = GetOption(strArg[1].Replace("\"", "").Trim(), optionList, strCondition); optionList.Add(strArg[1].Replace("\"", "").Trim()); break; case "search3"://search3 strCondition += "( " + String.Format(" {0} ", strArg[1].Replace("\"", "").Trim().ToUpper()); break; case "equal3"://equal3 strCondition += GetEqual(strArg[1].Replace("\"", "").Trim().ToLower()); break; case "type3"://type3 strCondition = String.Format(strCondition, GetEqualValueType(strArg[1].Replace("\"", "").Trim().ToLower())); break; case "value3"://value4 strCondition = String.Format(strCondition, strArg[1].Replace("\"", "").Trim()) + " )"; break; case "option4": strCondition = GetOption(strArg[1].Replace("\"", "").Trim(), optionList, strCondition); optionList.Add(strArg[1].Replace("\"", "").Trim()); break; case "search4"://search4 strCondition += "( " + String.Format(" {0} ", strArg[1].Replace("\"", "").Trim().ToUpper()); break; case "equal4"://equal4 strCondition += GetEqual(strArg[1].Replace("\"", "").Trim().ToLower()); break; case "type4"://type4 strCondition = String.Format(strCondition, GetEqualValueType(strArg[1].Replace("\"", "").Trim().ToLower())); break; case "value4"://value4 strCondition = String.Format(strCondition, strArg[1].Replace("\"", "").Trim()) + " )"; break; case "option5": strCondition = GetOption(strArg[1].Replace("\"", "").Trim(), optionList, strCondition); optionList.Add(strArg[1].Replace("\"", "").Trim()); break; case "search5"://search5 strCondition += "( " + String.Format(" {0} ", strArg[1].Replace("\"", "").Trim().ToUpper()); break; case "equal5"://equal5 strCondition += GetEqual(strArg[1].Replace("\"", "").Trim().ToLower()); break; case "type5"://type5 strCondition = String.Format(strCondition, GetEqualValueType(strArg[1].Replace("\"", "").Trim().ToLower())); break; case "value5"://value5 strCondition = String.Format(strCondition, strArg[1].Replace("\"", "").Trim()) + " )"; break; case "option6": strCondition = GetOption(strArg[1].Replace("\"", "").Trim(), optionList, strCondition); optionList.Add(strArg[1].Replace("\"", "").Trim()); break; case "search6"://search6 strCondition += "( " + String.Format(" {0} ", strArg[1].Replace("\"", "").Trim().ToUpper()); break; case "equal6"://equal6 strCondition += GetEqual(strArg[1].Replace("\"", "").Trim().ToLower()); break; case "type6"://type6 strCondition = String.Format(strCondition, GetEqualValueType(strArg[1].Replace("\"", "").Trim().ToLower())); break; case "value6"://value6 strCondition = String.Format(strCondition, strArg[1].Replace("\"", "").Trim()) + " )"; break; default: break; } //} } strCondition = " AND " + strCondition + " "; } string strAuthorityCondition = ""; UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modOrderManagement"); if (userAuthorityManage.OperateType != AuthorityType.NULL) { if (stroplb == "op_Seae") { strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.OPSEAELIST, strShowName, strCompanyID, strDeptName, strUserID); } else if (stroplb == "op_Seai") { strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.OPSEAILIST, strShowName, strCompanyID, strDeptName, strUserID); } } string strSortCondition = ""; if (strSortName != null && strSortIndex != null) { strSortCondition = String.Format(" ORDER BY {0} {1}", strSortName, strSortIndex); } else { strSortCondition = String.Format(" ORDER BY {0} {1}", "YEARINT", "DESC"); } sourceTable = reportDA.GetDataTableSourceByCondtion(ReportType.OPSEAETOTAL, (strAuthorityCondition + strCondition),strSortCondition); StringBuilder sourceBuilder = new StringBuilder(); //sourceBuilder.Append("{"); sourceBuilder.Append("["); //sourceBuilder.Append("{"); for (int i = 0; i < sourceTable.Rows.Count; i++) { if (i == 0) { //sourceBuilder.Append("{id:\"" + sourceTable.Rows[i][0].ToString() + "\","); sourceBuilder.Append("{id:\"" + (i + 1) + "\","); } else { //sourceBuilder.Append(",{id:\"" + sourceTable.Rows[i][0].ToString() + "\","); sourceBuilder.Append(",{id:\"" + (i + 1) + "\","); } sourceBuilder.Append("year:\"" + sourceTable.Rows[i][1].ToString() + "\","); sourceBuilder.Append("yearmonth:\"" + (sourceTable.Rows[i][1].ToString() + "-" + sourceTable.Rows[i][2].ToString()) + "\",");//YEAE-MONTH sourceBuilder.Append("month:\"" + sourceTable.Rows[i][2].ToString() + "\","); sourceBuilder.Append("teu:" + sourceTable.Rows[i][3].ToString() + ","); sourceBuilder.Append("order:" + sourceTable.Rows[i][4].ToString() + ","); sourceBuilder.Append("profit:" + sourceTable.Rows[i][5].ToString() + "}"); } sourceBuilder.Append("]"); //sourceBuilder.Append("}"); return sourceBuilder.ToString(); } #endregion #region 解析多条件检索相关联信息 /// /// 解析多条件检索相关联信息 /// /// /// /// /// private string GetOption(string tempOption, ArrayList tempList, string tempCondition) { string tempResult = ""; switch (tempOption) { case "1": if (tempList.Count > 0) { if (tempList[(tempList.Count - 1)].ToString().Trim() != "1") { tempResult = " (" + tempCondition + ") AND "; } else { tempResult = tempCondition + " AND "; } } else { tempResult = tempCondition + " AND "; } break; case "2": if (tempList.Count > 0) { if (tempList[(tempList.Count - 1)].ToString().Trim() != "2") { tempResult = " (" + tempCondition + ") OR "; } else { tempResult = tempCondition + " OR "; } } else { tempResult = tempCondition + " OR "; } break; } return tempResult; } #endregion #region 解析检索符号 /// /// 解析检索符号 /// /// 检索符号 /// 返回相应的SQL检索符号 private string GetEqual(string tempEqual) { string tempResult = ""; switch (tempEqual) { case "=": tempResult = " = {0} "; break; case "<": tempResult = " < {0} "; break; case ">": tempResult = " > {0} "; break; case "in": tempResult = " LIKE {0} "; break; case "notin": tempResult = " NOT LIKE {0} "; break; case "null": tempResult = " IS NULL "; break; case "notnull": tempResult = " IS NOT NULL "; break; case ">=": tempResult = " >= {0} "; break; case "<=": tempResult = " <= {0} "; break; } return tempResult; } #endregion #region 获取检索值类型查询值 /// /// 获取检索值类型查询值 /// /// 检索值类型名称 str-字符型 sdate-日期型 bool-逻辑型 int-整型 /// private string GetEqualValueType(string typeName) { string tempResult = ""; switch (typeName) { case "str": tempResult = "'{0}'"; break; case "sdate": tempResult = "'{0}'"; break; case "bool": tempResult = "{0}"; break; case "int": tempResult = "{0}"; break; } return tempResult; } #endregion } }