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. 最近遇到的几个纯C编程的陷阱

    首先是一个不容易看出来的语法上的陷阱 经过调试得出的错误是对非socket的socket操作出错,sockfd在调试过程中发现是0,不是一个合理的文件描述符. 仔细一看原来是括号忘记加了,该运算是先用 ...

  2. 汇编_压缩BCD码和非压缩BCD码

    BCD码是表示十进制数的,非压缩BCD码是用8位表示的,其实只用低4位,高4位全为0. 例如,十进制数36,用非压缩BCD码表示为:0000 0011 0000 0110 ,这是两个字节. 压缩BCD ...

  3. 杂项:WWW

    ylbtech-杂项:WWW WWW是环球信息网的缩写,(亦作“Web”.“WWW”.“'W3'”,英文全称为“World Wide Web”),中文名字为“万维网”,"环球网"等 ...

  4. 业务SQL优化

    1,个人开户报表统计 优化前语句,执行时间80多秒 SELECT a.DA AS f_da, a.account_name AS f_account_name, a.sex AS f_sex, a.n ...

  5. document.getElementById/Name/TagName

    document.getElementById 1.getElementById 作用:一般页面里ID是唯一的,用于准备定位一个元素 语法: document.getElementById(id) 参 ...

  6. SVN更新或提交时出现冲突该如何解决

    解决版本冲突的命令.在冲突解决之后,需要使用svnresolved来告诉subversion冲突解决,这样才能提交更新.冲突发生时,subversion会在WorkCopy中保存所有的目标文件版本(上 ...

  7. maven引入源码

    选中要添加的源码的项目右键-->debug--->debugs-configurations-->source-->java project

  8. jquery制作滚动条到一定位置触发

    $(function(){ var nav=$(".nav"); //得到导航对象 var win=$(window); //得到窗口对象 var sc=$(document);/ ...

  9. ubuntu安装Percona Server

    Percona Server是mysql数据库的一个衍生版本,在性能,稳定性和可管理性上都有很大的提升,目前淘宝的mysql数据库就是基于Percona Server,请原谅我这么喜欢研究淘宝的技术. ...

  10. 跟着太白老师学python day10 名称空间,作用域和取值顺序,变量的加载顺序

    名称空间分为3种: 1. 全局名称空间 2. 内置名称空间 3. 局部名称空间(临时) 作用域 全局作用域              1全局名称空间 2 内置名称空间 局部作用域           ...