wzp
2022-11-11 2f74eb23c0d2d4a246bc612c5c34bdfa8dea5603
web/web/GwSp.ashx
@@ -22,7 +22,7 @@
    private List<GwProduct> _ProductList;
    private int _userId = -1;
    private int _userType = -1;
    private string _userType = "";
    private string _account = "";
    private List<GwOp> OpList
@@ -57,8 +57,10 @@
        {
            if (this._ClientList == null)
            {
                using (GwClientDao gwClientDao = new GwClientDao())
                    this._ClientList = gwClientDao.LoadInfoList("", "", "", "");
                using (GwClientDao gwClientDao = new GwClientDao()) {
                    string permissionsSQL = gwClientDao.GetClientPermissions(_userId, _userType, null);
                    this._ClientList = gwClientDao.LoadInfoList("", "", "", "", permissionsSQL);
                }
            }
            return this._ClientList;
        }
@@ -99,9 +101,9 @@
                using (GwProductDao gwProductDao = new GwProductDao())
                {
                    GwProduct gwProduct = new GwProduct();
                        gwProduct.Classes = -1;
                        gwProduct.IsDefault = -1;
                        gwProduct.IsEnable = -1;
                    gwProduct.Classes = -1;
                    gwProduct.IsDefault = -1;
                    gwProduct.IsEnable = -1;
                    this._ProductList = gwProductDao.getAllList(gwProduct);
                }
            }
@@ -322,7 +324,7 @@
            apId = string1;
        //if (string.IsNullOrEmpty(clientId) && !string.IsNullOrEmpty(string4))
        //    clientId = new GwClientDao().GetClientName(string4).ClientID;
        string permissionsSQL = new GwClientDao().GetClientPermissions(_userId, _userType, null);
        //加载账号列表信息
@@ -332,63 +334,71 @@
        {
            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>";
                str1 = str1 + "<td>" + (object)this.GetProductToName(gwSp.ProductId) + "</td>";
                //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 += "<tr><td  rowspan=\"1\" ><input type=\"checkbox\"name=\"checkbox\" value=\"" + gwSp.SpID + "\"/></td><td rowspan=\"1\">" + gwSp.SpID + "</td>";
                str1 += "<td>" + (object)this.GetProductToName(gwSp.ProductId) + "</td>";
                str1 += "<td>" + (object)gwSp.ClientID + "</td>";
                str1 += "<td>" + (object)this.GetClientName(gwSp.ClientID) + "</td>";
                str1 += "<td>" + (object)this.GetAPName(gwSp.ApID) + "</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));
                    str1 += "<td rowspan=\"1\"><span class='label label-primary'>通道</span>";
                    str1 += string.Format("<div style='margin-top:10px;'>移动:{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));
                    str1 += "<td rowspan=\"1\"><span class='label label-success'>通道组</span>";
                    str1 += string.Format("<div style='margin-top:10px;'>移动:{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 += "<td rowspan=\"1\"><span class='label label-success'>启用失败补发</span>";
                    //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>";
                }
                    str1 += "<td rowspan=\"1\"><span class='label label-danger'>停用失败补发</span>";
                }**/
                string str2 = "<div class=\"text-muted\">" + gwSp.ChargerTypeText + "</div>";
                string str2 = gwSp.ChargerTypeText ;
                if (gwSp.ChargerTypeText == "后付费")
                    str2 = "<div  style=\"color:red\">" + gwSp.ChargerTypeText + "</div>";
                str1 += "<td>" + str2 + "</td>";
                str1 += "<td>" + (object)((double)gwSp.Price / 1000.0) + "</td>";
                //add: yangzh by 2022-03-14 start
                //str1 = str1 + (object)"<td><div class=\"text-muted\">" + (object)(gwSp.Balance / (long)gwSp.Price) + "条/" + (object)((double)gwSp.Balance / 1000.0) + "元</div>";
                str1 = str1 + (object)"<td><div class=\"text-muted\">" + (object)(gwSp.BasicNum + (long)gwSp.GivingNum) + "条 / " + (object)(gwSp.BasicNum) + "条 / " + (object)(gwSp.GivingNum) + "条</div>";
                str1 = str1 + (object)"<td>" + (object)(gwSp.BasicNum + (long)gwSp.GivingNum) + "条 / " + (object)(gwSp.BasicNum) + "条 / " + (object)(gwSp.GivingNum) + "条";
                //add: yangzh by 2022-03-14 end
                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 = str1 + "<div class=\"text-danger\">" + gwSp.BalanceThreshold + "条(" + 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.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>";//去掉IP
                // 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\">";
                str1 += "<td>" + gwSp.CreateTime + "</td>";
                str1 += "<td rowspan=\"1\" class=\"text-center\" >";
                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);
                    str1 += string.Format(" <a style='margin-top:5px;' class=\"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);
                str1 = gwSp.Status != 0 ? str1 + string.Format(" <a style='margin-top:5px;' href=\"javascript:;\" data-spid=\"{0}\" data-status=\"0\" class=\"action-updateStatus btn btn-primary btn-xs\"><i class=\"fa fa-toggle-off\"></i>&nbsp;停用</a><br> ", (object) gwSp.SpID ) : str1 + string.Format("<a href=\"javascript:;\" data-spid=\"{0}\" data-status=\"1\" class=\"action-updateStatus btn  btn-default btn-xs\"><i class=\"fa fa-toggle-on\"/></i>&nbsp;启用</a><br> ", (object) gwSp.SpID );
                if (context.HasRight("3021"))
                    str1 += string.Format(" <a style='margin-top:5px;' 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 style='margin-top:5px;' class=\" btn btn-success btn-xs action-modal-Acctunchargelog\"  data-id=\"{0}\"><i class=\"fa fa-list-alt\"></i> 充值日志</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);
@@ -444,7 +454,7 @@
        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.Format("{0}", (object)gwAp.ApName);
        }
        return string.Empty;
    }
@@ -475,7 +485,7 @@
            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)gwClient.Company);
        return string.Format("{0}", (object)clientID);
    }
@@ -496,8 +506,10 @@
    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);
            return string.Format("<span class='label label-default'>已停用</span>");
        //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);
        return string.Format("<span class='label label-success'>已启用</span>");
    }
    //
@@ -523,10 +535,9 @@
        GwProduct gwProduct = this.ProductList.Find((Predicate<GwProduct>)(bean => productId.Equals(bean.Id) ));
        if (gwProduct != null)
        {
            //return string.Format("{0}-{1}", (object)gwAp.ApID, (object)gwAp.ApName);//2021.2.24.wzp变更,后续可以删除
            return string.Format("{0}", (object)gwProduct.Name);
        }
        return string.Empty;
        return productId;
    }
    private JsonPageResult LoadGwSpPageList(PageContext<SysUser> context)
@@ -582,7 +593,7 @@
        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.ChargeType = context.GetInt("ChargeType", 0);
        o.IsAutoReturn = context.GetInt("IsAutoReturn", 0);
        o.Threshold = Math.Max(context.GetInt("Threshold", 10), 10);
        o.MaxConnCount = context.GetInt("MaxConnCount", 1);
@@ -596,6 +607,21 @@
        o.Signatures = context.GetString("Signatures");
        o.AuditingMode = context.GetInt("AuditingMode");
        o.DeductPercent = context.GetInt("DeductPercent");
        o.SubPackageNum = context.GetInt("SubPackageNum");
        o.SingleSubmitMinRestrict = context.GetInt("SingleSubmitMinRestrict");
        o.IsDispalyPrice = context.GetInt("IsDispalyPrice");
        o.DeductionMode = context.GetInt("DeductionMode");
        o.IsSendAudit = context.GetInt("IsSendAudit");
        o.BelowNumAudit = context.GetInt("BelowNumAudit");
        o.AboveNumAudit = context.GetInt("AboveNumAudit");
        o.IsCumulativeAudit = context.GetInt("IsCumulativeAudit");
        o.CumulativeAuditNum = context.GetInt("CumulativeAuditNum");
        o.CumulativeAuditTime = context.GetInt("CumulativeAuditTime");
        o.IsSyncChildSendAudit = context.GetInt("IsSyncChildSendAudit");
        o.ProductId = context.GetString("ProductId","");//产品ID
        if (context.GetInt("RouterType", 1) == 1)
        {
            o.CMOPID = context.GetInt("CMOPID");
@@ -637,8 +663,8 @@
            o.CUGroupID = 0;
            o.CTGroupID = 0;
        }
        o.BalanceThreshold = context.GetInt("BalanceThreshold") * 1000;
        o.AlarmMobile = context.GetString("AlarmMobile");
        o.BalanceThreshold = context.GetInt("BalanceThreshold");//告警条数
        o.AlarmMobile = context.GetString("AlarmMobile");//告警号码
        o.ForceSignFlag = context.GetInt("ForceSignFlag");
        o.ForceSign = context.GetString("ForceSign");
        o.SignatureMode = context.GetInt("signatureMode");
@@ -663,7 +689,7 @@
        cTPattern.SpID = context.GetString("SpID");
        cTPattern.Enabled = context.GetInt("enabled");
        cTPattern.Pattern = context.GetString("patternContent");
            string pattern = @"^[A-Za-z0-9]+$"; //判断是字符或数字
        string pattern = @"^[A-Za-z0-9]+$"; //判断是字符或数字
        //if (!Regex.IsMatch(o.SpID, "^\\d{6}$"))
        //    throw new Exception("账号必须为6位数字!");
        if (!Regex.IsMatch(o.SpID, "^[A-Za-z0-9]{6}$"))
@@ -689,6 +715,27 @@
            throw new Exception("账号密码不能为空");
        this._Dao.Update(o);
        this._Dao.UpdatePattern(cTPattern, context.OperatorID); //更新账号里面的报备内容
        //同时修改客户-产品表记录,若存在,则更新,否则新建
        bool flag = GwClientProductDao.Instance.FindBySp(o.SpID);
        GwClientProduct clientProduct = new GwClientProduct()
        {
            ClientId = o.ClientID,
            ProductId = o.ProductId,
            SpId = o.SpID,
            ActivateStatus = 1,
            Id=Guid.NewGuid().ToString()
        };
        if (flag)//存在,更新
        {
            GwClientProductDao.Instance.Update(clientProduct);
        }
        else
        {
            GwClientProductDao.Instance.Add(clientProduct);
        }
        return new JsonPageResult(true, (object)("账户" + o.SpID + "修改成功!"));
    }
@@ -707,7 +754,7 @@
        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.ChargeType = context.GetInt("ChargeType", 0);
        o.IsAutoReturn = context.GetInt("IsAutoReturn", 0);
        o.Threshold = Math.Max(context.GetInt("Threshold", 10), 10);
        o.MaxConnCount = context.GetInt("MaxConnCount", 1);
@@ -747,6 +794,18 @@
        string string1 = context.GetString("SpID");
        int @int = context.GetInt("enabled");
        o.SubPackageNum = context.GetInt("SubPackageNum");
        o.SingleSubmitMinRestrict = context.GetInt("SingleSubmitMinRestrict");
        o.IsDispalyPrice = context.GetInt("IsDispalyPrice");
        o.DeductionMode = context.GetInt("DeductionMode");
        o.IsSendAudit = context.GetInt("IsSendAudit");
        o.BelowNumAudit = context.GetInt("BelowNumAudit");
        o.AboveNumAudit = context.GetInt("AboveNumAudit");
        o.IsCumulativeAudit = context.GetInt("IsCumulativeAudit");
        o.CumulativeAuditNum = context.GetInt("CumulativeAuditNum");
        o.CumulativeAuditTime = context.GetInt("CumulativeAuditTime");
        o.IsSyncChildSendAudit = context.GetInt("IsSyncChildSendAudit");
        o.VerCodeMode = context.GetInt("VerCodeMode");
        o.ProvincialNetworkMode = context.GetInt("ProvincialNetworkMode");
@@ -761,8 +820,8 @@
        }
        string string2 = context.GetString("patternContent");
        if (!Regex.IsMatch(o.SpID, "^\\d{6}$"))
            throw new Exception("账号必须为6位数字");
        if (!Regex.IsMatch(o.SpID, "^[0-9a-zA-Z]{6}$"))
            throw new Exception("账号必须为6位数字和字母");
        if (!string.IsNullOrEmpty(o.AccessCode) && !Regex.IsMatch(o.AccessCode, "^[0-9]*$"))
            throw new Exception("扩展号必须为数字");
        if (string.IsNullOrEmpty(o.ClientID))
@@ -779,6 +838,33 @@
            throw new Exception("SPID已经存在,请重新填写!");
        this._Dao.Add(o);
        this._Dao.UpdatePattern(string1, @int, string2, context.OperatorID);//添加账号的时候配置报备
        //如果选择了产品,表示创建的时候就激活。后台创建无赠送
        if (!string.IsNullOrEmpty(o.ProductId))
        {
            //同时修改客户-产品表记录,若存在,则更新,否则新建
            bool flag = GwClientProductDao.Instance.FindBySp(o.SpID);
            GwClientProduct clientProduct = new GwClientProduct()
            {
                ClientId = o.ClientID,
                ProductId = o.ProductId,
                SpId = o.SpID,
                ActivateStatus = 1,
                Id = Guid.NewGuid().ToString()
            };
            if (flag)//存在,更新
            {
                GwClientProductDao.Instance.Update(clientProduct);
            }
            else
            {
                GwClientProductDao.Instance.Add(clientProduct);
            }
        }
        return new JsonPageResult(true, (object)("账户" + o.SpID + "添加成功!"));
    }
@@ -848,14 +934,20 @@
    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");
        int cmOpId = context.GetInt("cmopID");
        int cuOpId = context.GetInt("unopID");
        int ctOpId = context.GetInt("ctopID");
        int cmGroupId = context.GetInt("cmGroupID");
        int cuGroupId = context.GetInt("cuGroupID");
        int ctGroupId = context.GetInt("ctGroupID");
        if (cmOpId == 0 && cuOpId == 0 && ctOpId == 0 && cmGroupId ==0 && cuGroupId==0 &&ctGroupId==0)
        {
            throw new ArgumentException("选项不允许全部为空,请至少选择一项!");
        }
        foreach (string spid in JsonConvert.DeserializeObject<string[]>(context.GetString("idArray")))
            this._Dao.UpdateSingleOP(spid, int1, int3, int2, int4, int5, int6);
            this._Dao.UpdateSingleOP(spid, cmOpId, ctOpId, cuOpId, cmGroupId, cuGroupId, ctGroupId);
        return new JsonPageResult(true, (object)"批量修改通道成功!");
    }