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/DSWebMobile/Handler/Sale.ashx.cs

311 lines
14 KiB
C#

3 years ago
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using DSWeb.MvcShipping.Controllers;
using Newtonsoft.Json;
using DSWebMobileService;
using DSWebMobileService.Common;
namespace DSWebMobile.Handler
{
/// <summary>
/// Sale 的摘要说明
/// </summary>
public class Sale : IHttpHandler, System.Web.SessionState.IRequiresSessionState
{
public void ProcessRequest(HttpContext context)
{
string action = context.Request.QueryString["action"].ToString();
switch (action)
{
case "0":
GetDataList(context);
break;
case "1":
GetDataInfo(context);
break;
case "2":
GetDataDetail(context);
break;
case "3":
GetDataListByCondition(context);
break;
}
}
private void GetDataDetail(HttpContext context)
{
string relCodeName = "";
string relBSFromDate = "";
string relBSToDate = "";
string relACCFromDate = "";
string relACCToDate = "";
string codeName = Encrypt.DesDecrypt("#7c&e@63", context.Request.QueryString["u"].ToString());
string bsFromDate = Encrypt.DesDecrypt("#7c&e@63", context.Request.QueryString["bf"].ToString());
string bsToDate = Encrypt.DesDecrypt("#7c&e@63", context.Request.QueryString["bt"].ToString());
string accFromDate = Encrypt.DesDecrypt("#7c&e@63", context.Request.QueryString["af"].ToString());
string accToDate = Encrypt.DesDecrypt("#7c&e@63", context.Request.QueryString["at"].ToString());
string pattern = "\0";
string replacement = "";
string returnValue = "";
Regex rgx = new Regex(pattern);
relCodeName = rgx.Replace(codeName, replacement);
relBSFromDate = rgx.Replace(bsFromDate, replacement);
relBSToDate = rgx.Replace(bsToDate, replacement);
relACCFromDate = rgx.Replace(accFromDate, replacement);
relACCToDate = rgx.Replace(accToDate, replacement);
pattern = "\t";
Regex rgx2 = new Regex(pattern);
relCodeName = rgx2.Replace(relCodeName, replacement);
relBSFromDate = rgx2.Replace(relBSFromDate, replacement);
relBSToDate = rgx2.Replace(relBSToDate, replacement);
relACCFromDate = rgx2.Replace(relACCFromDate, replacement);
relACCToDate = rgx2.Replace(relACCToDate, replacement);
/*if (Common.HsTable.HasItem("Sale|" + relCodeName))
{
returnValue = Common.HsTable.GetHsTableItem("Sale|" + relCodeName);
}
string[] valueArray = returnValue.Split(',');
string relGID = valueArray[0].ToString();
string relCompanyID = valueArray[1].ToString();
string relPassword = valueArray[3].ToString();
string relCacheKey = valueArray[4].ToString();
string relStrCondition = valueArray[5].ToString();
string relSale = valueArray[6].ToString();
Module.UserInfomationModule _user = new UserInfomationModule();
_user.GID = relGID;
_user.CompanyID = relCompanyID;
_user.CodeName = relCodeName;
_user.Password = relPassword;
DataTable dt = BaseInfo.SaleAnalysisListDBServer.SaleAnalysisListInfo(relCacheKey, _user, relSale, relStrCondition, relBSFromDate, relBSToDate, relACCFromDate, relACCToDate);
*/
StringBuilder sb = new StringBuilder();
/*if (dt == null || dt.Rows.Count == 0) { sb.Append("[{\"SALE\":\"\"}]"); }
else { sb.Append(JsonClass.DataTable2JsonNoneTotalCount(dt)); }*/
context.Response.ContentType = "text/plain";
context.Response.Write(sb.ToString());
context.Response.End();
}
private void GetDataInfo(HttpContext context)
{
string relSale = "";
string relCacheKey = "";
string sale = Encrypt.DesDecrypt("#7c&e@63", context.Request.QueryString["s"].ToString());
string cacheKey = Encrypt.DesDecrypt("#7c&e@63", context.Request.QueryString["k"].ToString());
string pattern = "\0";
string replacement = "";
Regex rgx = new Regex(pattern);
relSale = rgx.Replace(sale, replacement);
relCacheKey = rgx.Replace(cacheKey, replacement);
pattern = "\t";
Regex rgx2 = new Regex(pattern);
relSale = rgx2.Replace(relSale, replacement);
relCacheKey = rgx2.Replace(relCacheKey, replacement);
/*Module.UserInfomationModule _user = new UserInfomationModule();
_user.ShowName = relSale;
//DataTable dt = BaseInfo.PaymentAuditingListDBServer.PaymentAuditingList(cacheKey, _user, pageIndex, pageCount, ref TotalCount, strCondition, IsAudit);
DataTable dt = BaseInfo.SaleAnalysisListDBServer.SaleAnalysisInfo(relCacheKey, _user);*/
StringBuilder sb = new StringBuilder();
/*if (dt == null || dt.Rows.Count == 0) { sb.Append("[{\"SALE\":\"\"}]"); }
else { sb.Append(JsonClass.DataTable2JsonNoneTotalCount(dt)); }*/
context.Response.ContentType = "text/plain";
context.Response.Write(sb.ToString());
context.Response.End();
}
private void GetDataListByCondition(HttpContext context)
{
string relStartMonth = "";
string relEndMonth = "";
string relBeginFrom = "";
string relBeginTo = "";
string relAccFrom = "";
string relAccTo = "";
string relStrCondition = "";
string strCondition = Encrypt.DesDecrypt("#7c&e@63", context.Request.Form["s"].ToString());
string startMonth = Encrypt.DesDecrypt("#7c&e@63", context.Request.Form["sm"].ToString());
string endMonth = Encrypt.DesDecrypt("#7c&e@63", context.Request.Form["em"].ToString());
string bfd = Encrypt.DesDecrypt("#7c&e@63", context.Request.Form["bfd"].ToString());
string btd = Encrypt.DesDecrypt("#7c&e@63", context.Request.Form["btd"].ToString());
string afd = Encrypt.DesDecrypt("#7c&e@63", context.Request.Form["afd"].ToString());
string atd = Encrypt.DesDecrypt("#7c&e@63", context.Request.Form["atd"].ToString());
string pattern = "\0";
string replacement = "";
int start = int.Parse(context.Request.QueryString["t"].ToString());
int limit = int.Parse(context.Request.QueryString["l"].ToString());
Regex rgx = new Regex(pattern);
relStrCondition = rgx.Replace(strCondition, replacement);
relStartMonth = rgx.Replace(startMonth, replacement);
relEndMonth = rgx.Replace(endMonth, replacement);
relBeginFrom = rgx.Replace(bfd, replacement);
relBeginTo = rgx.Replace(btd, replacement);
relAccFrom = rgx.Replace(afd, replacement);
relAccTo = rgx.Replace(atd, replacement);
pattern = "\t";
Regex rgx2 = new Regex(pattern);
relStrCondition = rgx2.Replace(relStrCondition, replacement);
relStartMonth = rgx2.Replace(relStartMonth, replacement);
relEndMonth = rgx2.Replace(relEndMonth, replacement);
relBeginFrom = rgx2.Replace(relBeginFrom, replacement);
relBeginTo = rgx2.Replace(relBeginTo, replacement);
relAccFrom = rgx2.Replace(relAccFrom, replacement);
relAccTo = rgx2.Replace(relAccTo, replacement);
if (strCondition != "")
{
if (relStrCondition[0] == ',') { relStrCondition = relStrCondition.Substring(1, relStrCondition.Length - 1); }
}
if (relBeginFrom != "")
{
if (relStrCondition != "")
{
relStrCondition += " and B.OPDATE>='" + relBeginFrom + " 00:00:00' ";
}
else
{
relStrCondition = " B.OPDATE>='" + relBeginFrom + " 00:00:00' ";
}
}
if (relBeginTo != "")
{
relStrCondition += " and B.OPDATE<='" + relBeginTo + " 23:59:59' ";
}
if (relStrCondition != "" && relAccFrom != "")
{
relStrCondition += " and B.ACCDATE>='" + relAccFrom.Substring(0, 7) + "' ";
}
else if (relStrCondition == "" && relAccFrom != "") { relStrCondition += " B.ACCDATE>='" + relAccFrom.Substring(0, 7) + "' "; }
if (relAccTo != "")
{
relStrCondition += " and B.ACCDATE<='" + relAccTo.Substring(0, 7) + "' ";
}
var listData = DSWebMobileService.MsRptOpProfitMonth.SaleListDataByCondition(relStrCondition, null, null, null, relStartMonth, relEndMonth);
string result = listData.Content.ToString();
StringBuilder sb = new StringBuilder();
if (listData == null) { sb.Append("[{\"SALE\":\"\"}]"); }
else { sb.AppendLine(result); }
context.Response.ContentType = "text/plain";
context.Response.Write(sb.ToString());
context.Response.End();
}
private void GetDataList(HttpContext context)
{
string relStartMonth = "";
string relEndMonth = "";
string relBeginFrom = "";
string relBeginTo = "";
string relAccFrom = "";
string relAccTo = "";
string relStrCondition = "";
string strCondition = Encrypt.DesDecrypt("#7c&e@63", context.Request.Form["s"].ToString());
string startMonth = Encrypt.DesDecrypt("#7c&e@63", context.Request.Form["sm"].ToString());
string endMonth = Encrypt.DesDecrypt("#7c&e@63", context.Request.Form["em"].ToString());
string bfd = Encrypt.DesDecrypt("#7c&e@63", context.Request.Form["bfd"].ToString());
string btd = Encrypt.DesDecrypt("#7c&e@63", context.Request.Form["btd"].ToString());
string afd = Encrypt.DesDecrypt("#7c&e@63", context.Request.Form["afd"].ToString());
string atd = Encrypt.DesDecrypt("#7c&e@63", context.Request.Form["atd"].ToString());
string pattern = "\0";
string replacement = "";
int start = int.Parse(context.Request.QueryString["t"].ToString());
int limit = int.Parse(context.Request.QueryString["l"].ToString());
Regex rgx = new Regex(pattern);
relStrCondition = rgx.Replace(strCondition, replacement);
relStartMonth = rgx.Replace(startMonth, replacement);
relEndMonth = rgx.Replace(endMonth, replacement);
relBeginFrom = rgx.Replace(bfd, replacement);
relBeginTo = rgx.Replace(btd, replacement);
relAccFrom = rgx.Replace(afd, replacement);
relAccTo = rgx.Replace(atd, replacement);
pattern = "\t";
Regex rgx2 = new Regex(pattern);
relStrCondition = rgx2.Replace(relStrCondition, replacement);
relStartMonth = rgx2.Replace(relStartMonth, replacement);
relEndMonth = rgx2.Replace(relEndMonth, replacement);
relBeginFrom = rgx2.Replace(relBeginFrom, replacement);
relBeginTo = rgx2.Replace(relBeginTo, replacement);
relAccFrom = rgx2.Replace(relAccFrom, replacement);
relAccTo = rgx2.Replace(relAccTo, replacement);
if (strCondition != "")
{
if (relStrCondition[0] == ',') { relStrCondition = relStrCondition.Substring(1, relStrCondition.Length - 1); }
}
if (relBeginFrom != "")
{
if (relStrCondition != "")
{
relStrCondition += " and B.OPDATE>='" + relBeginFrom + " 00:00:00' ";
}
else
{
relStrCondition = " B.OPDATE>='" + relBeginFrom + " 00:00:00' ";
}
}
if (relBeginTo != "")
{
relStrCondition += " and B.OPDATE<='" + relBeginTo + " 23:59:59' ";
}
if (relStrCondition != "" && relAccFrom != "")
{
relStrCondition += " and B.ACCDATE>='" + relAccFrom.Substring(0, 7) + "' ";
}
else if (relStrCondition == "" && relAccFrom != "") { relStrCondition += " B.ACCDATE>='" + relAccFrom.Substring(0, 7) + "' "; }
if (relAccTo != "")
{
relStrCondition += " and B.ACCDATE<='" + relAccTo.Substring(0, 7) + "' ";
}
//MsRptOpProfitMonthController _saleList = new MsRptOpProfitMonthController();
//var listData = _saleList.SaleListData(start, limit, relStrCondition, null, null, null, relStartMonth, relEndMonth);
var dataList = DSWebMobileService.MsRptOpProfitMonth.SaleListData(start, limit, relStrCondition, null, null, null, relStartMonth, relEndMonth);
string result = dataList.Content.ToString();
result = result.Replace("\r\n", "");
result = "[" + result.Substring(1, result.Length - 2) + "]";
StringBuilder sb = new StringBuilder();
if (dataList == null) { sb.Append("[{\"GID\":\"\"}]"); }
else { sb.AppendLine(result); }
context.Response.ContentType = "text/plain";
context.Response.Write(sb.ToString());
context.Response.End();
}
public bool IsReusable
{
get
{
return false;
}
}
}
}