using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Framework;
using HraWeb.Common;
using Trirand.Web.UI.WebControls;
using WebApp.Common;
using Contract.Domain;
using System.Collections;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Data;

namespace HraWeb
{
public partial class CcrCreditRatingReportManage : JQEntityManage<Contract.Domain.CcrCreditRatingReport>
{
protected override void Page_Load(object sender, EventArgs e)
{
jq.ClientSideEvents.RowDoubleClick = "getInfo";
//给基类服务接口复制,可不付
//base.svc = Psvc;
if (Request["_method"]=="rating")
{

}
base.Page_Load(sender, e);
}
public PropertyInfo GetProperyInfo(string Name, PropertyInfo[] ps)
{
PropertyInfo p1 = null;
ps.ToList().ForEach(p =>
{
if (p.Name == Name)
{
p1 = p;
}
});
return p1;
}
public QueryInfo getInfo(QueryInfo info)
{

List<string> strList = new List<string>() { "Industry", "Ownership", "Organization", "IsDefaultClient" };
System.Collections.Hashtable aa = new System.Collections.Hashtable();
System.Collections.Hashtable ff = new System.Collections.Hashtable();
QueryInfo CcrFundermentalInfo=new QueryInfo();
CcrFundermentalInfo.QueryObject = "CcrFundermental";
CcrFundermental c=new CcrFundermental();
var ps = typeof (CcrFundermental).GetProperties();
foreach (string key in Request.QueryString.Keys)
{
if (regEx.IsMatch(key))
{
Match m = regEx.Match(key);
string g = m.Groups["TAG"].Value;
if (string.IsNullOrEmpty(Request.QueryString[key]))
{
continue;
}
if (string.IsNullOrEmpty(g))
{
if (!aa.Contains(m.Groups["PROP"].Value))
{

if (!strList.Contains(m.Groups["PROP"].Value.Replace("_LK","")))
{

aa.Add(m.Groups["PROP"].Value, Request.QueryString[key]);
}
else
{

ff.Add(m.Groups["PROP"].Value, Request.QueryString[key]);

}

}
}
else
{
if (!aa.Contains(m.Groups["PROP"].Value + "_" + g))
{
if (!strList.Contains(m.Groups["PROP"].Value))
{
aa.Add(m.Groups["PROP"].Value, Request.QueryString[key]);
}
else
{
ff.Add(m.Groups["PROP"].Value, Request.QueryString[key]);
}

}

}

}

}
CcrFundermentalInfo.AddParam(ff);
List<CcrFundermental> ccrFundermentals =
Holworth.Utility.Utility.ListToT<CcrFundermental>(Dao.FindList(CcrFundermentalInfo)).ToList();

List<string> companyids = (from s in ccrFundermentals select s.Id).ToList();
info.AddParam(aa);
if (companyids.Count > 0)
{
info.Where.Add("where", " and CompanyId in (:companyids)");

info.Parameters.Add("companyids", companyids.ToArray());
}
else
{
info.Where.Add("where"," and 1!=1");
}
return info;
}
private static string regexCtlValObj = @"\w{3,5}?_(?<PROP>\w*)_(?<TAG>(\w\d{1,2})*)$";
public static Regex regEx = new Regex(regexCtlValObj, RegexOptions.IgnoreCase);
///// <summary>
///// 设置查询条件或者语句
///// </summary>
///// <returns></returns>
//protected override Framework.QueryInfo SetInfo()
//{

// info= new QueryInfo("CcrCreditRatingReport");
// getInfo(info);
// //info.AddParam("Purpose","rating");
// return info;
//}

public override void ChangeList(QueryInfo infoList)
{
QueryInfo dictInfo=new QueryInfo("SysDict");
dictInfo.AddParam("TypeCode", "SECTOR_TYPE");
List<SysDict> dicts =
Holworth.Utility.Utility.ListToT<SysDict>(Dao.FindList(dictInfo)).ToList();
IList<CcrRatingStand> list = Holworth.Utility.Utility.ListToT<CcrRatingStand>(Dao.FindList(new QueryInfo("CcrRatingStand")));
//通过Code来Mapping出字典对象
var dictMenu = (from s in dicts select s).Distinct(new DistinctProperty()).ToDictionary(x => x.Code);

QueryInfo info = new QueryInfo("CcrFundermental");
//if (!string.IsNullOrEmpty(Request["companyId"]))
// info.AddParam("Id", Request["companyId"]);
//CcrFundermental input = Dao.FindList(info)[0] as CcrFundermental;
List<CcrFundermental> fundermentals =
Holworth.Utility.Utility.ListToT<CcrFundermental>(Dao.FindList(info)).ToList();
var dic =
fundermentals.Select(f => new { CompanyId = f.Id, Industry = f.Industry, Organization = f.Organization, Ownership = f.Ownership, IsDefaultClient=f.IsDefaultClient }).ToDictionary(x => x.CompanyId);
List<CcrCreditRatingReport> reports=new List<CcrCreditRatingReport>();
foreach (var c in infoList.List)
{
CcrCreditRatingReport cc = c as CcrCreditRatingReport;
bool find = false;
decimal score = 0;

foreach (var ccrRatingStand in list)
{
if (string.IsNullOrEmpty(cc.Score.ToString()))
{
cc.CreditRate = "";
find = true;
break;

}
else
{
decimal.TryParse(cc.Score.ToString(), out score);
if (score >= ccrRatingStand.ScoreStart && score < ccrRatingStand.ScoreEnd &&
ccrRatingStand.Category == "MACHINE_RATING")
{

cc.CreditRate = ccrRatingStand.ScoreLevel;
find = true;
break;
}
}

}
cc.Industry1 = dictMenu[dic[cc.CompanyId.ToString()].Industry].Name;
cc.Ownership1 = dic[cc.CompanyId.ToString()].Ownership;
cc.Organization1 = dic[cc.CompanyId.ToString()].Organization;
cc.IsDefaultClient = dic[cc.CompanyId.ToString()].IsDefaultClient;
cc.State.MarkDirty();
reports.Add(cc);
if (!find)
{
cc.CreditRate = "未评级";
}

}
Dao.SaveOrUpdateAll(reports);

}

/// <summary>
/// 初始化页面控件
/// </summary>
protected override void InitPage()
{
base.InitPage();

// BindDrop(drp_Unit, "SPSW", true);
}
//private Contract.IService.ICcrCreditRatingReportService psvc;
///// <summary>
///// 初始化
///// </summary>
//Contract.IService.ICcrCreditRatingReportService Psvc
//{
// get
// {
// if (psvc == null)
// {
// psvc = ctx.GetObject("CcrCreditRatingReportService") as Contract.IService.ICcrCreditRatingReportService;
// }
// return psvc;

// }
//}
}

public class DistinctProperty : IEqualityComparer<SysDict>
{
public bool Equals(SysDict x, SysDict y)
{
return x.Code == y.Code;
}

public int GetHashCode(SysDict obj)
{
return obj.GetHashCode();
}
}
}

.net正则查询的更多相关文章

  1. 使用locate 的正则查询 查找所有main.c

    locate支持正则查询的功能, 只需输入locate -r 正则表达式     即可. 现在我想查找所有main.c怎么做? 打开终端,输入shell: locate -r main.c$ PS:' ...

  2. mysql正则查询 模糊查询

    -- ==============正则查询================ /* SQL默认是忽略大小写的 正则模式使用REGEXP和NOT REGEXP操作符(或RLIKE和NOT RLIKE,它们 ...

  3. 【python】pymongo中正则查询时的转义问题

    在查询mongo时用到了正则查询 设字符串为   str = '/ab/cd.ef?g=' 直接用正则查询没有匹配. collection.find({"re":{'$regex' ...

  4. oracle 正则查询json返回报文中某个字段的值

    接口返回报文为json 格式,如下: {"body":{"businessinfo":{"c1rate":"25.00" ...

  5. 正则表达式 第六篇:调用CLR函数执行正则查询

    在SQL Server数据库中可以执行模糊查询,像like子句,和全文查询(Fulltext search),但是无法直接执行正则查找,SQL Server没有执行正则表达式的内置函数,但是我们可以创 ...

  6. Python Elasticsearch api,组合过滤器,term过滤器,正则查询 ,match查询,获取最近一小时的数据

    Python Elasticsearch api   描述:ElasticSearch是一个基于Lucene的搜索服务器.它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口.下 ...

  7. MySQL的ALTER变更、正则查询、分组查询、排序查询以及事务查询的概

    MySQL的表和字段信息的变更 ALTER TABLE table-name DROP column-name; #删除某个字段 ALTER TABLE table-name ADD column-n ...

  8. sql中使用正则查询

  9. PHPStorm 使用正则批量查询替换并自动转换大小写的方法

    PHPStorm 的项目查询替换功能那是非常非常强大的, 速度也很快, 配合正则更加灵活强大. 一般的正则查询替换没什么太多好说的, 这里主要说说比较少用的 大小写自动转换的问题, 也是比较少用但很有 ...

随机推荐

  1. 小峰Hibernate简介与HelloWorld

    一.Hibernate简介: 二.Hibernate4 版Hello World 实现 工程结构: com.cy.model.Student: package com.cy.model; public ...

  2. 【转】利用 Apache JMeter 测试 WebSphere 性能

    如果您预算紧张并且时间紧迫 —— 或者即使您不是这样 —— 那么,您可能希望考虑使用 JMeter 来对 Web 和其他应用程序进行压力测试.IBM 的 Greg Herringer 详细描述他使用这 ...

  3. 编写hibernateDao,使dao层都实现hibernateDao

    package com.wiseweb.core.dao; import java.io.Serializable; import java.util.ArrayList; import java.u ...

  4. 手机页面开发的meta

    <meta name="viewport" content="width=device-width, initial-scale=1"> 手机环境. ...

  5. Apache 的编译安装

    直接看步骤: 1.安装必备环境:gcc.pcre .................................. 2.安装apr.apr-util 3.解压编译安装Apache: ./confi ...

  6. ubuntu 解决“无法获得锁 /var/lib/dpkg/lock -open”的方法

      在ubuntu系统终端下,用apt-get install 安装软件的时候,如果在未完成下载的情况下将终端中断,此时 apt-get进程可能没有结束.结果,如果再次运行apt-get instal ...

  7. 温故而知新-WebSocket 教程

    一.为什么需要 WebSocket? 初次接触 WebSocket 的人,都会问同样的问题:我们已经有了 HTTP 协议,为什么还需要另一个协议?它能带来什么好处? 答案很简单,因为 HTTP 协议有 ...

  8. leetcode357

    public class Solution { public int CountNumbersWithUniqueDigits(int n) { ) { ; } ; ; ; && av ...

  9. Django 实现用户认证set_Cookie

    当用户通过认证时,set_Cookie(key, value) request.Cookie.get(key) 如果key不为空,就说明验证通过,否者重新跳转回login登录页面 对于URL urlp ...

  10. JAVA压缩 解压缩zip 并解决linux下中文乱码

    1. [代码][Java]代码   1:再压缩前,要设置linux模式, 需要使用第三方ant-1.6.5.jar  如果是文件目录,则ZipEntry zipEntry=new ZipEntry(b ...