From 91912ad24d477ff24be56f0a22438303a8eae552 Mon Sep 17 00:00:00 2001 From: wzp <2880584989@qq.com> Date: 星期四, 16 九月 2021 16:12:52 +0800 Subject: [PATCH] Merge branch 'Release' of ssh://8.129.227.30:29418/SMGW_NewWeb into Release --- web/web/GwSp.ashx | 882 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 882 insertions(+), 0 deletions(-) diff --git a/web/web/GwSp.ashx b/web/web/GwSp.ashx new file mode 100644 index 0000000..e7cf40e --- /dev/null +++ b/web/web/GwSp.ashx @@ -0,0 +1,882 @@ +锘�<%@ WebHandler Language="C#" Class="GwSpHandler" %> + +using Common; +using Dao; +using Model; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; + +public class GwSpHandler : PageHandler<SysUser> +{ + private GwSpDao _Dao = new GwSpDao(); + private GwSpDao _GwSpDao = new GwSpDao(); + private List<GwOp> _OpList; + private List<GwOpGroup> _GroupList; + private List<GwClient> _ClientList; + private List<GwDiverter> _DiverterList; + private List<GwAp> _APList; + private List<GwStrategy> _StrategyList; + + private List<GwOp> OpList + { + get + { + if (this._OpList == null) + { + using (GwOpDao gwOpDao = new GwOpDao()) + this._OpList = gwOpDao.LoadInfoList(); + } + return this._OpList; + } + } + + private List<GwOpGroup> GroupList + { + get + { + if (this._GroupList == null) + { + using (GwOpGroupDao gwOpGroupDao = new GwOpGroupDao()) + this._GroupList = gwOpGroupDao.GetGroupList(); + } + return this._GroupList; + } + } + + private List<GwClient> ClientList + { + get + { + if (this._ClientList == null) + { + using (GwClientDao gwClientDao = new GwClientDao()) + this._ClientList = gwClientDao.LoadInfoList("", "", "", ""); + } + return this._ClientList; + } + } + + private List<GwDiverter> DiverterList + { + get + { + if (this._DiverterList == null) + { + using (GwDiverterDao gwDiverterDao = new GwDiverterDao()) + this._DiverterList = gwDiverterDao.LoadList(); + } + return this._DiverterList; + } + } + + private List<GwAp> APList + { + get + { + if (this._APList == null) + { + using (GwApDao gwApDao = new GwApDao()) + this._APList = gwApDao.LoadInfoList(); + } + return this._APList; + } + } + + private List<GwStrategy> StrategyList + { + get + { + if (this._StrategyList == null) + { + using (GwStrategyDao gwStrategyDao = new GwStrategyDao()) + this._StrategyList = gwStrategyDao.LoadInfoList(string.Empty, string.Empty); + } + return this._StrategyList; + } + } + + public override JsonPageResult ProcessRequestInternal(PageContext<SysUser> context) + { + string @string = context.GetString("action"); + switch (@string) + { + case "updateSpStatus": + return this.UpdateSpStatus(context); + case "getGwspDetailed": + return this.GetGwspDetailed(context); + case "loadChargeLogPageList": + return this.LoadChargeLogPageList(context); + case "batchUpdateOp": + return this.BatchUpdateOp(context); + case "charge": + return this.Charge(context); + case "loadChargeLog": + return this.LoadChargeLog(context); + case "payMentDetails": + return this.PayMentDetails(context); + case "delete": + return this.Delete(context); + case "add": + return this.Add(context); + case "loadGwSpPageList": + return this.LoadGwSpPageList(context); + case "loadGwSpAccountPageList": + return this.LoadGwSpAccountPageList(context); + case "update": + return this.Update(context); + case "getSignatureInfo": + return this.GetSignatureInfo(context); + case "updateSignature": + return this.UpdateSignature(context); + case "updatePattern": + return this.UpdatePattern(context); + case "getPatternInfo": + return this.GetPatternInfo(context); + case "loadPrePatternList": + return this.LoadPrePatternList(context); + case "updatePrePatternStatus": + return this.UpdatePrePatternStatus(context); + case "getPrePattern": + return this.GetPrePattern(context); + default: + throw new Exception("Invalid Action=" + @string); + } + } + + //鏂板姞 + + private JsonPageResult UpdateSpStatus(PageContext<SysUser> context) + { + string @string = context.GetString("spid"); + int @int = context.GetInt("status"); + if (string.IsNullOrEmpty(@string)) + throw new ArgumentException("鑾峰彇瀹㈡埛璐﹀彿鍙傛暟SPID澶辫触"); + if (!this._GwSpDao.UpdateSpStatus(@string, @int)) + throw new ArgumentNullException("淇敼澶辫触锛�"); + // WriteSysLogHelper.WriteSysLog(context.SessionObject.Account, 3023, 302, string.Format("閫氶亾璐﹀彿{0}鐢眥2}鐘舵�佷慨鏀逛负{1}鐘舵��", (object)@string, @int != 1 ? (object)"鍋滅敤" : (object)"鍚敤", @int == 1 ? (object)"鍋滅敤" : (object)"鍚敤"), context.ClientIP); + return new JsonPageResult(true, (object)"鏇存敼璐﹀彿鐘舵�佹垚鍔燂紒"); + } + + //缁撴潫 + + private JsonPageResult GetGwspDetailed(PageContext<SysUser> context) + { + string @string = context.GetString("spID"); + if (string.IsNullOrEmpty(@string)) + throw new ArgumentException("鑾峰彇SPID閿欒"); + using (GwSpDao gwSpDao = new GwSpDao()) + { + GwSp gwSp = gwSpDao.Get(@string); + string[] strArray = gwSp.McExpression.Split(new char[1] + { + ';' + }, StringSplitOptions.RemoveEmptyEntries); + string str = (Convert.ToInt32(strArray[0]) != 0 ? strArray[0] + "鏉�/1鍒嗛挓;" : "") + (Convert.ToInt32(strArray[1]) != 0 ? strArray[1] + "鏉�/5鍒嗛挓;" : "") + (Convert.ToInt32(strArray[2]) != 0 ? strArray[2] + "鏉�/10鍒嗛挓;" : "") + (Convert.ToInt32(strArray[3]) != 0 ? strArray[3] + "鏉�/鍗婂皬鏃�;" : "") + (Convert.ToInt32(strArray[4]) != 0 ? strArray[4] + "鏉�/1灏忔椂;" : "") + (Convert.ToInt32(strArray[5]) != 0 ? strArray[5] + "鏉�/4灏忔椂;" : "") + (Convert.ToInt32(strArray[6]) != 0 ? strArray[6] + "鏉�/6灏忔椂;" : "") + (Convert.ToInt32(strArray[7]) != 0 ? strArray[7] + "鏉�/12灏忔椂;" : "") + (Convert.ToInt32(strArray[8]) != 0 ? strArray[8] + "鏉�/24灏忔椂;" : ""); + return new JsonPageResult(true, (object)new + { + Get = gwSp, + McExpression = str + }); + } + } + + private JsonPageResult LoadChargeLogPageList(PageContext<SysUser> context) + { + string string1 = context.GetString("SpID"); + string string2 = context.GetString("ClientID"); + string string3 = context.GetString("ClientName"); + string str1 = context.GetString("sDate"); + string str2 = context.GetString("EndTime"); + int recordcount = 0; + int int1 = context.GetInt("pageSize", 20); + int int2 = context.GetInt("pageIndex", 1); + if (string.IsNullOrEmpty(str1)) + str1 = DateTime.Now.AddDays(-1.0).ToString("yyyy-MM-dd"); + if (string.IsNullOrEmpty(str2)) + str2 = DateTime.Now.ToString("yyyy-MM-dd"); + List<GwChargeLog> list = new GwChargeLogDao().LoadInfoList(string2, string3, string1, Convert.ToDateTime(str1), Convert.ToDateTime(str2).AddDays(1.0), out recordcount, int1, int2); + string str3 = ""; + if (list != null && list.Count > 0) + { + int num = 0; + UserDao userDao = new UserDao(); + foreach (GwChargeLog gwChargeLog in list) + { + ++num; + str3 = str3 + (object)"<tr class=\"row-" + (object)(num % 2) + "\" ><td>" + (object)gwChargeLog.ChargeID + "</td><td>" + gwChargeLog.ClientID + "</td><td>" + gwChargeLog.ClientName + "</td><td>" + gwChargeLog.SpID + "</td><td>" + (object)gwChargeLog.OccurTime + "</td>"; + str3 = string.Concat(new object[4] + { + (object) str3, + (object) "<td>", + (object) ((double) gwChargeLog.Amount / 1000.0), + (object) "鍏�</td>" + }); + str3 = str3 + "<td>" + gwChargeLog.OperatorID + "</td>"; + string str4 = "<font color='red'>寰呭鐞�</font>"; + if (gwChargeLog.Flag == 1) + str4 = "宸插鐞�"; + str3 = str3 + "<td>" + str4 + "</td>"; + string str5 = gwChargeLog.FlushTime.ToString("yyyy-MM-dd HH:mm:ss"); + if (str5.IndexOf("0001") > 0) + str5 = ""; + str3 = str3 + "<td>" + str5 + "</td>"; + str3 = str3 + "<td>" + gwChargeLog.Remark + "</td>"; + str3 += "</tr>"; + } + } + else + str3 += "<tr><td colspan=\"10\" style=\"padding-left:5px; text-align: center;\">鏆傛棤淇℃伅</td></tr>"; + return new JsonPageResult(true, (object)new + { + Table = str3.ToString(), + TotalCount = recordcount + }); + } + + private JsonPageResult UpdatePattern(PageContext<SysUser> context) + { + this._Dao.UpdatePattern(context.GetString("spid"), context.GetInt("enabled"), context.GetString("pattern"), context.OperatorID); + return new JsonPageResult(true, (object)"璐︽埛鍏嶅鍐呭鎶ュ鏇存柊鎴愬姛锛�"); + } + + private JsonPageResult GetPatternInfo(PageContext<SysUser> context) + { + return new JsonPageResult(true, (object)this._Dao.GetPattern(context.GetString("spid"))); + } + + private JsonPageResult UpdateSignature(PageContext<SysUser> context) + { + string string1 = context.GetString("spid"); + int @int = context.GetInt("signatureMode"); + string string2 = context.GetString("signatures"); + this._Dao.UpdateSignature(new SpSignatureInfo() + { + SpID = string1, + SignatureMode = @int, + Signatures = string2 + }); + return new JsonPageResult(true, (object)"璐︽埛绛惧悕鏇存柊鎴愬姛锛�"); + } + + private JsonPageResult GetSignatureInfo(PageContext<SysUser> context) + { + return new JsonPageResult(true, (object)this._Dao.GetSignature(context.GetString("spid"))); + } + + + /// <summary> + /// 鍔犺浇璐﹀彿椤甸潰鍒楄〃 + /// </summary> + /// <param name="context"></param> + /// <returns></returns> + private JsonPageResult LoadGwSpAccountPageList(PageContext<SysUser> context) + { + string string1 = context.GetString("apID"); + string clientId = context.GetString("clientID"); + string string2 = context.GetString("spID"); + string string3 = context.GetString("opID"); + int int1 = context.GetInt("routerType"); + string string4 = context.GetString("clientName"); + int int2 = context.GetInt("chargeType"); + int recordCount = 0; + int int3 = context.GetInt("pageSize", 20); + int int4 = context.GetInt("pageIndex", 1); + int int5 = context.GetInt("resendStatus", 1); + if (!string.IsNullOrEmpty(string3) && int1 <= 0) + throw new ArgumentException("璇烽�夋嫨閫氶亾缁勮矾鐢辨ā寮�"); + GwSpDao gwSpDao = new GwSpDao(); + string apId = "0"; + if (this.IsInt(string1)) + apId = string1; + if (string.IsNullOrEmpty(clientId) && !string.IsNullOrEmpty(string4)) + clientId = new GwClientDao().GetClientName(string4).ClientID; + //鍔犺浇璐﹀彿鍒楄〃淇℃伅 + List<GwSp> list = gwSpDao.LoadInfoList(string2, apId, clientId, int1, string3, int2, int4, int3, int5.ToString(),out recordCount); + string str1 = ""; + if (list != null && list.Count > 0) + { + foreach (GwSp gwSp in list) + { + str1 = str1 + "<tr><td rowspan=\"1\" ><input type=\"checkbox\"name=\"checkbox\" value=\"" + gwSp.SpID + "\"/></td><td rowspan=\"1\">" + gwSp.SpID + "<div class=\"text-muted\">" + this.GetAPName(gwSp.ApID) + "</div><div class=\"text-muted\">" + this.GetClientName(gwSp.ClientID) + "</div>"; + str1 += "</td>"; + if (gwSp.RouterType == 1) + { + str1 += "<td rowspan=\"1\"><div class=\"btn btn-primary btn-xs\">鐐硅矾鐢�</div>"; + str1 += string.Format("<div>绉诲姩锛歿0}</div><div>鐢典俊锛歿1}</div><div>鑱旈�氾細{2}</div>", (object)this.GetOpName(gwSp.CMOPID), (object)this.GetOpName(gwSp.CTOPID), (object)this.GetOpName(gwSp.UNOPID)); + } + else if (gwSp.RouterType == 3) + { + str1 += "<td rowspan=\"1\"><div class=\"btn btn-success btn-xs\">缁勮矾鐢�</div>"; + str1 += string.Format("<div>绉诲姩锛歿0}</div><div>鐢典俊锛歿1}</div><div>鑱旈�氾細{2}</div>", (object)this.GetGroupName(gwSp.CMGroupID), (object)this.GetGroupName(gwSp.CTGroupID), (object)this.GetGroupName(gwSp.CUGroupID)); + } + + if (gwSp.RESEND_STATUS == 1) + { + str1 += "<td rowspan=\"1\"><div class=\"btn btn-primary btn-xs\">鍚敤澶辫触琛ュ彂</div>"; + //str1 += string.Format("<div>绉诲姩锛歿0}</div><div>鐢典俊锛歿1}</div><div>鑱旈�氾細{2}</div>", (object)this.GetGroupName(gwSp.RESEND_CM_GROUPID), (object)this.GetGroupName(gwSp.RESEND_CU_GROUPID), (object)this.GetGroupName(gwSp.RESEND_CT_GROUPID)); + //璐︽埛椤甸潰鏄剧ず琛ュ彂閫氶亾鍏蜂綋鐨勯�氶亾 + } + else + { + str1 += "<td rowspan=\"1\"><div class=\"btn btn-danger btn-xs\">鍋滅敤澶辫触琛ュ彂</div>"; + } + + + string str2 = "<div class=\"text-muted\">" + gwSp.ChargerTypeText + "</div>"; + if (gwSp.ChargerTypeText == "鍚庝粯璐�") + str2 = "<div style=\"color:red\">" + gwSp.ChargerTypeText + "</div>"; + str1 = str1 + (object)"<td><div class=\"text-muted\">" + (object)(gwSp.Balance / (long)gwSp.Price) + "鏉�/" + (object)((double)gwSp.Balance / 1000.0) + "鍏�</div>"; + str1 = str1 + (object)str2 + "<div class=\"text-muted\">" + (object)((double)gwSp.Price / 1000.0) + "鍏�/鏉�</div>"; + if (context.HasRight("3021")) + str1 += string.Format(" <a class=\"btn btn-xs btn-success action-modal-charge\" data-id=\"{0}\"><i class=\"fa fa-cny\"></i> 鍏呭��</a>", (object)gwSp.SpID); + if (context.HasRight("3022")) + str1 += string.Format(" <a class=\" btn btn-success btn-xs action-modal-Acctunchargelog\" data-id=\"{0}\"><i class=\"fa fa-list-alt\"></i> 鍏呭�兼棩蹇�</a>", (object)gwSp.SpID); + if (gwSp.BalanceThreshold > 0 && !string.IsNullOrEmpty(gwSp.AlarmMobile)) + str1 = str1 + (object)"<div class=\"text-danger\">" + (object)(gwSp.BalanceThreshold / 1000) + "鍏�(" + gwSp.AlarmMobile + ")</div>"; + str1 += "</td>"; + str1 = str1 + "<td>" + this.GetDiverterName(gwSp.DiverterID); + str1 = str1 + "<div class=\"text-muted\">" + this.GetStratedyName(gwSp.StrategyID) + "</div>"; + str1 = str1 + "<div class=\"text-muted\"><font color=\"red\">" + this.GwSPAuditingName(gwSp.AuditingMode) + "</font></div>"; + str1 = str1 + "<div class=\"text-muted\">鍏ㄥ眬榛戝悕鍗�" + gwSp.BlackModeText + "</div>"; + str1 += "</td>"; + str1 = str1 + "<td>" + gwSp.AccessCode; + str1 = str1 + "<div class=\"text-muted\">" + (gwSp.ExtnoExtensionMode == 1 ? "绂佹瀹㈡埛鎵╁睍" : "鍏佽瀹㈡埛鎵╁睍") + "</div>"; + str1 = str1 + "<div>" + (gwSp.AccessCodeMode == 1 ? "閫氶亾鐩磋繛妯″紡" : "铏氭嫙鎺ュ叆妯″紡") + "</div></td>"; + str1 = str1 + "<td>" + this.FormatIpHtml(gwSp.ClientIp) + "</td>"; + // str1 = str1 + "<td>" + this.GetStatusText(gwSp.Status); + str1 = str1 + "<td>" + this.GetStatusText(gwSp.Status, gwSp.SpID); + str1 += "</td>"; + str1 += "<td rowspan=\"1\" class=\"text-right\">"; + if (context.HasRight("3023")) + str1 += string.Format(" <a class=\"btn-block btn btn-primary btn-xs action-modal-edit\" data-id=\"{0}\"><i class=\"fa fa-edit\"></i> 缂栬緫</a>", (object)gwSp.SpID); + str1 += string.Format(" <a class=\"btn-block btn btn-success btn-xs action-create-summary\" data-id=\"{0}\">璐﹀彿鎽樿</a>", (object)gwSp.SpID); + if (context.HasRight("3024")) + str1 += string.Format(" <a class=\"btn-block btn btn-xs btn-default action-delete\" data-id=\"{0}\"><i class=\"fa fa-trash\"></i> 鍒犻櫎</a>", (object)gwSp.SpID); + str1 += "</td>"; + str1 += "</tr>"; + } + } + else + str1 += "<tr><td colspan=\"14\" style=\"padding-left:5px; text-align: center;\">鏆傛棤淇℃伅</td></tr>"; + return new JsonPageResult(true, (object)new + { + Table = str1.ToString(), + TotalCount = recordCount + }); + } + + private string GwSPAuditingName(int auditingMode) + { + string str = ""; + switch (auditingMode) + { + case 0: + str = "鍏嶅妯″紡"; + break; + case 1: + str = "鎵嬪伐瀹℃牳妯″紡"; + break; + case 2: + str = "鍐呭鎶ュ浼樺厛"; + break; + case 3: + str = "鎷︽埅绛栫暐+鍐呭鎶ュ"; + break; + } + return str; + } + + public bool IsInt(string input) + { + for (int index = 0; index < input.Length; ++index) + { + if (!char.IsNumber(input, index)) + return false; + } + return true; + } + + private string GetAPName(int apID) + { + if (this.APList == null) + return string.Empty; + GwAp gwAp = this.APList.Find((Predicate<GwAp>)(op => op.ApID == apID)); + if (gwAp != null) + { + //return string.Format("{0}-{1}", (object)gwAp.ApID, (object)gwAp.ApName);//2021.2.24.wzp鍙樻洿,鍚庣画鍙互鍒犻櫎 + return string.Format("鎺ュ叆鍗忚:{0}", (object)gwAp.ApName); + } + return string.Empty; + } + + private string GetOpName(int opID) + { + if (this.OpList == null) + return string.Empty; + GwOp gwOp = this.OpList.Find((Predicate<GwOp>)(op => op.OpID == opID)); + if (gwOp != null) + return string.Format("{0}-{1}", (object)gwOp.OpID, (object)gwOp.OpName); + return string.Empty; + } + + private string GetGroupName(int groupID) + { + if (this.GroupList == null) + return string.Empty; + GwOpGroup gwOpGroup = this.GroupList.Find((Predicate<GwOpGroup>)(group => group.GroupID == groupID)); + if (gwOpGroup != null) + return string.Format("{0}-{1}", (object)gwOpGroup.GroupID, (object)gwOpGroup.GroupName); + return string.Empty; + } + + private string GetClientName(string clientID) + { + if (this.ClientList == null) + return string.Empty; + GwClient gwClient = this.ClientList.Find((Predicate<GwClient>)(client => client.ClientID == clientID)); + if (gwClient != null) + return string.Format("{0}<div class=\"text-muted\">{1}</div>", (object)gwClient.ClientID, (object)gwClient.ClientName); + return string.Format("{0}", (object)clientID); + } + + private string FormatIpHtml(string p) + { + if (string.IsNullOrEmpty(p)) + return string.Empty; + return p.Replace("|", "<br/>"); + } + + //private string GetStatusText(int status) + //{ + // return status == 0 ? "<span class=\"btn btn-xs \">宸插仠鐢�</span>" : "<span class=\"btn btn-xs btn-success\">宸插惎鐢�</span>"; + //} + + + //鏂板姞瀹㈡埛璐﹀彿鐘舵�佸紑鍚叧闂� + private string GetStatusText(int status, string spid) + { + if (status == 0) + return string.Format("<span class=\"action-updateStatus btn btn-xs btn-default\" data-status=\"1\" data-spid=\"{0}\">宸插仠鐢�</span>", (object)spid); + return string.Format("<span class=\"action-updateStatus btn btn-xs btn-success \" data-status=\"0\" data-spid=\"{0}\">宸插惎鐢�</span>", (object)spid); + } + // + + private string GetStratedyName(int strategyID) + { + GwStrategy gwStrategy = this.StrategyList.Find((Predicate<GwStrategy>)(dv => dv.StrategyId == strategyID)); + if (gwStrategy == null) + return "鏈缃嫤鎴瓥鐣�"; + return "銆�" + gwStrategy.StrategyName + "銆戞嫤鎴瓥鐣�"; + } + + protected string GetDiverterName(int diverterID) + { + GwDiverter gwDiverter = this.DiverterList.Find((Predicate<GwDiverter>)(dv => dv.DiverterID == diverterID)); + if (gwDiverter == null) + return "鏈缃娴�"; + return "銆�" + gwDiverter.DiverterName + "銆戝娴佺瓥鐣�"; + } + + private JsonPageResult LoadGwSpPageList(PageContext<SysUser> context) + { + string string1 = context.GetString("SelectedSpID"); + string string2 = context.GetString("SelectedClientID"); + int recordCount = 0; + int int1 = context.GetInt("pageSize", 20); + int int2 = context.GetInt("pageIndex", 1); + StringBuilder stringBuilder = new StringBuilder(); + using (GwSpDao gwSpDao = new GwSpDao()) + { + List<SpSignatureInfo> signatureInfoList = gwSpDao.GetSignatureInfoList(string2, string1, out recordCount, int2, int1); + List<SpCTPatternInfo> patternList = gwSpDao.GetPatternList(); + if (signatureInfoList != null && signatureInfoList.Count > 0) + { + foreach (SpSignatureInfo spSignatureInfo in signatureInfoList) + { + stringBuilder.AppendFormat("<tr><td>{0}({1})</td><td>{3}</td><td>\r\n <a href=\"javascript:;\" data-id=\"{0}\" class=\"action-modal-signature btn-xs btn btn-warning\">{2}</a>\r\n </td></tr>", (object)spSignatureInfo.SpID, (object)spSignatureInfo.ClientID, (object)SpSignatureInfo.GetSignatureModeText(spSignatureInfo.SignatureMode), (object)spSignatureInfo.Signatures); + SpCTPatternInfo pattern = this.GetPattern(patternList, spSignatureInfo.SpID); + stringBuilder.AppendFormat("<tr><td></td><td>{1}</td><td>\r\n <a href=\"javascript:;\" data-id=\"{0}\" class=\"action-modal-pattern btn-xs btn btn-primary\">{2}</a>\r\n </td></tr>", (object)spSignatureInfo.SpID, (object)pattern.Pattern, pattern.Enabled == 1 ? (object)"鍏嶅鍐呭鍚敤" : (object)"鍏嶅鍐呭鏈惎鐢�"); + } + } + else + stringBuilder.AppendFormat("<tr><td colspan=\"8\" style=\"text-align: center;\">鏆傛椂鏃犳暟鎹�</td></tr>"); + } + return new JsonPageResult(true, (object)new + { + Table = stringBuilder.ToString(), + TotalCount = recordCount + }); + } + + private SpCTPatternInfo GetPattern(List<SpCTPatternInfo> patternList, string spid) + { + return patternList.Find((Predicate<SpCTPatternInfo>)(sp => sp.SpID == spid)) ?? new SpCTPatternInfo(); + } + + + //淇濆瓨鏇存柊鍚庣殑璐﹀彿淇℃伅 + private JsonPageResult Update(PageContext<SysUser> context) + { + GwSp o = new GwSp(); + o.SpID = context.GetString("SpID"); + o.ApID = context.GetInt("ApID"); + o.CombinationMode = context.GetInt("CombinationMode"); + o.ClientID = context.GetString("ClientID"); + o.StrategyID = context.GetInt("StrategyID", 0); + o.ChannelType = context.GetString("ChannelType"); + o.Password = context.GetString("Password"); + o.ClientIp = context.GetString("ClientIp"); + o.ClientPort = context.GetInt("ClientPort", 0); + o.AccessCode = context.GetString("AccessCode"); + o.Priority = context.GetInt("Priority", 0); + o.Price = Math.Max((int)(context.GetDecimal("Price", new Decimal(4, 0, 0, false, (byte)2)) * new Decimal(1000)), 1); + o.ChargeType = context.GetInt("ChargeType", 0); + o.Threshold = Math.Max(context.GetInt("Threshold", 10), 10); + o.MaxConnCount = context.GetInt("MaxConnCount", 1); + o.Remark = context.GetString("Remark"); + o.TimePermitting = context.GetString("TimePermitting"); + o.DefishingTimeout = context.GetInt("DefishingTimeout", 0); + o.DefishingThreshold = context.GetInt("DefishingThreshold", 0); + o.RejectIfForbidden = context.GetInt("RejectIfForbidden", 0); + o.RejectIfNoSignature = context.GetInt("RejectIfNoSignature", 0); + o.RefundIfUndelivered = context.GetInt("RefundIfUndelivered", 0); + o.Signatures = context.GetString("Signatures"); + o.AuditingMode = context.GetInt("AuditingMode"); + o.DeductPercent = context.GetInt("DeductPercent"); + if (context.GetInt("RouterType", 1) == 1) + { + o.CMOPID = context.GetInt("CMOPID"); + o.CTOPID = context.GetInt("CTOPID"); + o.UNOPID = context.GetInt("UNOPID"); + } + else + { + o.CMOPID = 0; + o.CTOPID = 0; + o.UNOPID = 0; + } + o.DefishingOPID = context.GetInt("DefishingOPID"); + o.RouterType = context.GetInt("RouterType", 1); + o.CUextparams = context.GetString("CDparams"); + o.CMextparms = context.GetString("CMparams"); + o.CTextparams = context.GetString("CTparams"); + o.Status = context.GetInt("Status", 1); + o.AccessCodeMode = context.GetInt("accessCodeMode", 0); + o.ExtnoExtensionMode = context.GetInt("extnoExtensionMode", 0); + o.FeeShortLength = context.GetInt("FeeShortLength", 67); + o.FeeLongLength = context.GetInt("FeeLongLength", 67); + o.BlackMode = context.GetInt("BlackMode", 1); + o.MCPM = 10; + if (context.GetInt("MCPM1") > context.GetInt("MCPM2")) + throw new ArgumentException("鍗曞彿鐮佸綋鍓嶈缃笉鑳藉ぇ浜庡悗闈竴涓缃殑鏁板��"); + string str = context.GetInt("MCPM1") + ";" + context.GetInt("MCPM2") + ";" + context.GetInt("MCPM3") + ";" + context.GetInt("MCPM4") + ";" + context.GetInt("MCPM5") + ";" + context.GetInt("MCPM6") + ";" + context.GetInt("MCPM7") + ";" + context.GetInt("MCPM8") + ";" + context.GetInt("MCPM9"); + o.McExpression = str; + o.DiverterID = context.GetInt("DiverterID"); + if (context.GetInt("RouterType", 1) == 3) + { + o.CMGroupID = context.GetInt("CMGroupID"); + o.CUGroupID = context.GetInt("CUGroupID"); + o.CTGroupID = context.GetInt("CTGroupID"); + } + else + { + o.CMGroupID = 0; + o.CUGroupID = 0; + o.CTGroupID = 0; + } + o.BalanceThreshold = context.GetInt("BalanceThreshold") * 1000; + o.AlarmMobile = context.GetString("AlarmMobile"); + o.ForceSignFlag = context.GetInt("ForceSignFlag"); + o.ForceSign = context.GetString("ForceSign"); + o.SignatureMode = context.GetInt("signatureMode"); + o.Signatures = context.GetInt("signatureMode") == 0 ? o.Signatures : context.GetString("signatures"); + + o.VerCodeMode = context.GetInt("VerCodeMode", 0); + o.ProvincialNetworkMode = context.GetInt("ProvincialNetworkMode", 0); + + //琛ュ彂閫氶亾 + o.RESEND_STATUS = context.GetInt("resendEnabled", 0); + if (o.RESEND_STATUS == 1) + { + o.RESEND_CM_GROUPID = context.GetInt("ReSendCmGroupID", 0); + o.RESEND_CU_GROUPID = context.GetInt("ReSendCuGroupID", 0); + o.RESEND_CT_GROUPID = context.GetInt("ReSendCtGroupID", 0); + } + + //鎼哄彿杞綉閰嶇疆 + o.TransferFlag = context.GetInt("TransferFlag",0); + + SpCTPatternInfo cTPattern = new SpCTPatternInfo(); + cTPattern.SpID = context.GetString("SpID"); + cTPattern.Enabled = context.GetInt("enabled"); + cTPattern.Pattern = context.GetString("patternContent"); + if (!Regex.IsMatch(o.SpID, "^\\d{6}$")) + throw new Exception("璐﹀彿蹇呴』涓�6浣嶆暟瀛楋紒"); + if (o.AccessCodeMode == 1) + { + if (o.DiverterID != 0) + throw new Exception("閫氶亾鐩磋繛妯″紡涓嬫棤娉曡繘琛屽娴�"); + if (o.RouterType == 3) + throw new Exception("閫氶亾鐩磋繛妯″紡涓嬫棤娉曚娇鐢ㄩ�氶亾缁勮矾鐢辨ā寮�"); + } + if (!string.IsNullOrEmpty(o.AccessCode) && !Regex.IsMatch(o.AccessCode, "^[0-9]*$")) + throw new Exception("鎵╁睍鍙峰繀椤讳负鏁板瓧"); + if (o.CMOPID == 0 && o.UNOPID == 0 && (o.CTOPID == 0 && o.RouterType == 1)) + throw new ArgumentException("鑷冲皯涓鸿处鍙锋寚瀹氫竴涓�氶亾锛�"); + if (o.CMGroupID == 0 && o.CUGroupID == 0 && (o.CTGroupID == 0 && o.RouterType == 3)) + throw new ArgumentException("鑷冲皯涓鸿处鍙锋寚瀹氫竴涓�氶亾缁勶紒"); + if (!string.IsNullOrEmpty(o.AlarmMobile) && !Regex.IsMatch(o.AlarmMobile, "1\\d{10}")) + throw new Exception("鍛婅鍙风爜鏍煎紡涓嶆纭紒"); + if (string.IsNullOrEmpty(o.ClientID)) + throw new Exception("璇烽�夋嫨璐﹀彿鎵�灞炲鎴凤紒"); + if (string.IsNullOrEmpty(o.Password)) + throw new Exception("璐﹀彿瀵嗙爜涓嶈兘涓虹┖"); + this._Dao.Update(o); + this._Dao.UpdatePattern(cTPattern, context.OperatorID); //鏇存柊璐﹀彿閲岄潰鐨勬姤澶囧唴瀹� + return new JsonPageResult(true, (object)("璐︽埛" + o.SpID + "淇敼鎴愬姛锛�")); + } + + private JsonPageResult Add(PageContext<SysUser> context) + { + GwSp o = new GwSp(); + o.SpID = context.GetString("SpID"); + o.ApID = context.GetInt("ApID"); + o.CombinationMode = context.GetInt("CombinationMode"); + o.ClientID = context.GetString("ClientID"); + o.StrategyID = context.GetInt("StrategyID", 0); + o.ChannelType = context.GetString("ChannelType"); + o.Password = context.GetString("Password"); + o.ClientIp = context.GetString("ClientIp"); + o.ClientPort = context.GetInt("ClientPort", 0); + o.AccessCode = context.GetString("AccessCode"); + o.Priority = context.GetInt("Priority", 0); + o.Price = Math.Max((int)(context.GetDecimal("Price", new Decimal(4, 0, 0, false, (byte)2)) * new Decimal(1000)), 1); + o.ChargeType = context.GetInt("ChargeType", 0); + o.Threshold = Math.Max(context.GetInt("Threshold", 10), 10); + o.MaxConnCount = context.GetInt("MaxConnCount", 1); + o.Remark = context.GetString("Remark"); + o.TimePermitting = context.GetString("TimePermitting"); + o.DefishingTimeout = context.GetInt("DefishingTimeout", 0); + o.DefishingThreshold = context.GetInt("DefishingThreshold", 0); + o.RejectIfForbidden = context.GetInt("RejectIfForbidden", 0); + o.RejectIfNoSignature = context.GetInt("RejectIfNoSignature", 0); + o.RefundIfUndelivered = context.GetInt("RefundIfUndelivered", 0); + o.Signatures = context.GetString("Signatures"); + o.AuditingMode = context.GetInt("AuditingMode"); + o.DeductPercent = context.GetInt("DeductPercent"); + o.CMOPID = context.GetInt("CMOPID"); + o.CTOPID = context.GetInt("CTOPID"); + o.UNOPID = context.GetInt("UNOPID"); + o.DefishingOPID = context.GetInt("DefishingOPID"); + o.RouterType = context.GetInt("RouterType", 1); + o.CUextparams = context.GetString("CDparams"); + o.CMextparms = context.GetString("CMparams"); + o.CTextparams = context.GetString("CTparams"); + o.Status = context.GetInt("Status", 1); + o.FeeShortLength = context.GetInt("FeeShortLength", 67); + o.FeeLongLength = context.GetInt("FeeLongLength", 67); + o.BlackMode = context.GetInt("BlackMode", 1); + o.MCPM = 10; + string str = context.GetString("MCPM1") + ";" + context.GetString("MCPM2") + ";" + context.GetString("MCPM3") + ";" + context.GetString("MCPM4") + ";" + context.GetString("MCPM5") + ";" + context.GetString("MCPM6") + ";" + context.GetString("MCPM7") + ";" + context.GetString("MCPM8") + ";" + context.GetString("MCPM9"); + o.McExpression = str; + o.DiverterID = context.GetInt("DiverterID"); + o.CMGroupID = context.GetInt("CMGroupID"); + o.CUGroupID = context.GetInt("CUGroupID"); + o.CTGroupID = context.GetInt("CTGroupID"); + o.ForceSignFlag = context.GetInt("ForceSignFlag"); + o.ForceSign = context.GetString("ForceSign"); + o.SignatureMode = context.GetInt("signatureMode"); + o.Signatures = context.GetString("signatures"); + string string1 = context.GetString("SpID"); + int @int = context.GetInt("enabled"); + + o.VerCodeMode = context.GetInt("VerCodeMode"); + o.ProvincialNetworkMode = context.GetInt("ProvincialNetworkMode"); + + + //琛ュ彂閫氶亾 + o.RESEND_STATUS = context.GetInt("resendEnabled", 0); + if (o.RESEND_STATUS == 1) + { + o.RESEND_CM_GROUPID = context.GetInt("ReSendCmGroupID", 0); + o.RESEND_CM_GROUPID = context.GetInt("ReSendCuGroupID", 0); + o.RESEND_CM_GROUPID = context.GetInt("ReSendCtGroupID", 0); + } + + string string2 = context.GetString("patternContent"); + if (!Regex.IsMatch(o.SpID, "^\\d{6}$")) + throw new Exception("璐﹀彿蹇呴』涓�6浣嶆暟瀛�"); + if (!string.IsNullOrEmpty(o.AccessCode) && !Regex.IsMatch(o.AccessCode, "^[0-9]*$")) + throw new Exception("鎵╁睍鍙峰繀椤讳负鏁板瓧"); + if (string.IsNullOrEmpty(o.ClientID)) + throw new Exception("璇烽�夋嫨璐﹀彿鎵�灞炲鎴凤紒"); + if (string.IsNullOrEmpty(o.Password)) + throw new Exception("璐﹀彿瀵嗙爜涓嶈兘涓虹┖"); + if (o.CMOPID == 0 && o.UNOPID == 0 && (o.CTOPID == 0 && o.RouterType == 1)) + throw new ArgumentException("鑷冲皯涓鸿处鍙锋寚瀹氫竴涓�氶亾锛�"); + if (o.CMGroupID == 0 && o.CUGroupID == 0 && (o.CTGroupID == 0 && o.RouterType == 3)) + throw new ArgumentException("鑷冲皯涓鸿处鍙锋寚瀹氫竴涓�氶亾缁勶紒"); + if (!string.IsNullOrEmpty(o.AlarmMobile) && !Regex.IsMatch(o.AlarmMobile, "1\\d{10}")) + throw new Exception("鍛婅鍙风爜鏍煎紡涓嶆纭紒"); + if (this._Dao.IsSpIDExists(o.SpID)) + throw new Exception("SPID宸茬粡瀛樺湪锛岃閲嶆柊濉啓锛�"); + this._Dao.Add(o); + this._Dao.UpdatePattern(string1, @int, string2, context.OperatorID);//娣诲姞璐﹀彿鐨勬椂鍊欓厤缃姤澶� + return new JsonPageResult(true, (object)("璐︽埛" + o.SpID + "娣诲姞鎴愬姛锛�")); + } + + private JsonPageResult Delete(PageContext<SysUser> context) + { + string @string = context.GetString("spid"); + if (string.IsNullOrEmpty(@string)) + throw new ArgumentException("SPID鍙傛暟寮傚父锛�"); + this._Dao.Delete(@string); + return new JsonPageResult(true, (object)("璐﹀彿" + @string + "鍒犻櫎鎴愬姛锛�")); + } + + private JsonPageResult LoadChargeLog(PageContext<SysUser> context) + { + string @string = context.GetString("spid"); + int int1 = context.GetInt("payLogID"); + int recordCount = 0; + context.GetInt("pageSize"); + int int2 = context.GetInt("pageSize", 20); + int int3 = context.GetInt("pageIndex", 1); + if (string.IsNullOrEmpty(@string)) + throw new ArgumentNullException("SPID鍙傛暟寮傚父锛�"); + using (GwChargeLogDao gwChargeLogDao = new GwChargeLogDao()) + return new JsonPageResult(true, (object)new + { + Table = gwChargeLogDao.GetChargeLog(@string, int1, out recordCount, int2, int3), + TotalCount = recordCount + }); + } + + private JsonPageResult PayMentDetails(PageContext<SysUser> context) + { + string @string = context.GetString("payID"); + if (string.IsNullOrEmpty(@string)) + throw new ArgumentException("鑾峰彇璁㈠崟鍙傛暟ID鍑洪敊"); + using (GwClientPayLogDao gwClientPayLogDao = new GwClientPayLogDao()) + return new JsonPageResult(true, (object)gwClientPayLogDao.GetPay(@string)); + } + + private JsonPageResult Charge(PageContext<SysUser> context) + { + string string1 = context.GetString("spid"); + long num = Convert.ToInt64(context.GetDecimal("amount", new Decimal(0)) * new Decimal(1000)); + string string2 = context.GetString("remark"); + GwSp gwSp = this._Dao.Get(string1); + if (gwSp == null) + throw new ArgumentException("SPID涓嶅瓨鍦�"); + GwClient gwClient = new GwClient(); + using (GwClientDao gwClientDao = new GwClientDao()) + gwClient = gwClientDao.Get(gwSp.ClientID); + using (GwChargeLogDao gwChargeLogDao = new GwChargeLogDao()) + gwChargeLogDao.Add(new GwChargeLog() + { + Amount = num, + Remark = string2, + OperatorID = context.OperatorID, + SpID = string1, + ClientID = gwSp.ClientID, + ClientName = gwClient.ClientName, + Flag = 0, + OccurTime = DateTime.Now, + PayMentType = 0, + PayLogID = 0 + }); + return new JsonPageResult(true, (object)("璐︽埛" + string1 + "鍏呭�艰姹傛彁浜ゆ垚鍔燂紒")); + } + + private JsonPageResult BatchUpdateOp(PageContext<SysUser> context) + { + int int1 = context.GetInt("cmopID"); + int int2 = context.GetInt("unopID"); + int int3 = context.GetInt("ctopID"); + int int4 = context.GetInt("cmGroupID"); + int int5 = context.GetInt("cuGroupID"); + int int6 = context.GetInt("ctGroupID"); + foreach (string spid in JsonConvert.DeserializeObject<string[]>(context.GetString("idArray"))) + this._Dao.UpdateSingleOP(spid, int1, int3, int2, int4, int5, int6); + return new JsonPageResult(true, (object)"鎵归噺淇敼閫氶亾鎴愬姛锛�"); + } + + private JsonPageResult LoadPrePatternList(PageContext<SysUser> context) + { + string string1 = context.GetString("spID"); + string string2 = context.GetString("clientID"); + int recordCount = 0; + int int1 = context.GetInt("pageIndex", 1); + int int2 = context.GetInt("pageSize", 20); + StringBuilder stringBuilder = new StringBuilder(); + List<Dao.GwSpPrePattern> spPrePatternList = new GwSpPrePatternDao().GetSpPrePatternList(string1, -1, string2, out recordCount, int2, int1); + if (spPrePatternList.Count > 0) + { + foreach (Dao.GwSpPrePattern gwSpPrePattern in spPrePatternList) + { + string str1 = gwSpPrePattern.AuditStatus == 0 ? "label-default" : (gwSpPrePattern.AuditStatus == 1 ? "label-primary" : (gwSpPrePattern.AuditStatus == 2 ? "label-warning" : "label-success")); + string str2 = gwSpPrePattern.AuditStatus == 0 ? "寰呭鏍�" : (gwSpPrePattern.AuditStatus == 1 ? "宸查�氳繃" : (gwSpPrePattern.AuditStatus == 2 ? "鏈�氳繃" : "寰呴噸鏂板鏍�")); + stringBuilder.AppendFormat("<tr>"); + stringBuilder.AppendFormat(" <td><input type='checkbox' name='checkbox' value=" + (object)gwSpPrePattern.PatternID + " /></td>"); + stringBuilder.AppendFormat(" <td>" + gwSpPrePattern.ClientID + "</td>"); + stringBuilder.AppendFormat(" <td>" + gwSpPrePattern.SpID + "</td>"); + stringBuilder.AppendFormat(" <td>" + gwSpPrePattern.PatternContent + "</td>"); + stringBuilder.AppendFormat(" <td>" + (object)gwSpPrePattern.CreateTime + "</td>"); + stringBuilder.AppendFormat(" <td><span class='label " + str1 + "'>" + str2 + "</span></td>"); + stringBuilder.AppendFormat(" <td>" + (gwSpPrePattern.AuditTime.ToString() == "0001/1/1 0:00:00" ? "" : gwSpPrePattern.AuditTime.ToString()) + "</td>"); + stringBuilder.AppendFormat(" <td>" + gwSpPrePattern.AuditRemark + "</td>"); + stringBuilder.AppendFormat(" <td>" + gwSpPrePattern.OperateAccount + "</td>"); + stringBuilder.AppendFormat(" <td>"); + if (gwSpPrePattern.AuditStatus == 0 || gwSpPrePattern.AuditStatus == 3) + stringBuilder.AppendFormat(" <a href=\"javascript:;\" data-id='" + (object)gwSpPrePattern.PatternID + "' class='action-update-status btn-xs btn btn-primary'><li class='fa fa-gavel'></li> 瀹℃牳</a>"); + stringBuilder.AppendFormat(" </td>"); + stringBuilder.AppendFormat("</tr>"); + } + } + else + stringBuilder.AppendFormat("<td colspan='10' style='text-align: center;'>鏆傛棤鏁版嵁</td>"); + return new JsonPageResult(true, (object)new + { + Table = stringBuilder.ToString(), + TotalCount = recordCount + }); + } + + + /// <summary> + /// 鏇存柊鎶ュ瀹℃牳鐘舵�� + /// </summary> + /// <param name="context"></param> + /// <returns></returns> + private JsonPageResult UpdatePrePatternStatus(PageContext<SysUser> context) + { + bool flag = false; + int @int = context.GetInt("auditStatus"); + string @string = context.GetString("auditRemark"); + string[] strArray = JsonConvert.DeserializeObject<string[]>(context.GetString("idArray")); + GwSpPrePatternDao gwSpPrePatternDao = new GwSpPrePatternDao(); + foreach (string str in strArray) + { + Dao.GwSpPrePattern gwSpPrePattern1 = gwSpPrePatternDao.Get(str.ToString()); + if (gwSpPrePattern1.AuditStatus == 0 || gwSpPrePattern1.AuditStatus == 3) + flag = gwSpPrePatternDao.UpdateSpPrePatternStatus(TypeConvert.ToInt32((object)str), @int, @string, context.OperatorID); + Dao.GwSpPrePattern gwSpPrePattern2 = gwSpPrePatternDao.Get(str.ToString()); + if (flag && gwSpPrePattern2.AuditStatus == 1) + { + SpCTPatternInfo pattern = this._Dao.GetPattern(gwSpPrePattern2.SpID); + this._Dao.UpdatePattern(pattern.SpID, pattern.Enabled, pattern.Pattern + "\r\n" + gwSpPrePattern2.PatternContent, context.OperatorID); + } + flag = false; + } + return new JsonPageResult(true, (object)"璐﹀彿鎶ュ瀹℃牳澶勭悊鎴愬姛锛�"); + } + + private JsonPageResult GetPrePattern(PageContext<SysUser> context) + { + return new JsonPageResult(true, (object)new GwSpPrePatternDao().Get(context.GetString("patternID"))); + } +} -- Gitblit v1.9.1