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. jq form表单自动赋值

    (function ($) { $.fn.extend({ initForm: function (options) { //默认参数 var defaults = { formdata: " ...

  2. MySQL5.7.18,初始化完成登录,提示密码过

    初始化完成登录,提示密码过期 原因: 安装CentOs的时候,默认安装了mysql,并且版本与自己安装的mysql版本不一致,直接使用mysql -uroot -p'password'连接,默认调用的 ...

  3. CentOS 7 需要安装的常用工具,及centos安装fcitx 搜狗输入法的坑旅

    https://blog.csdn.net/tham_/article/details/41868831 Centos常用设置 1.当最大化时隐藏标题栏 或者使用tweak tool 在字体中将标题栏 ...

  4. java后台获取URL带参demo

    URL:http://aos.wall.youmi.net/v2/check_fb_sig?order=YM130402cygr_UTb42&app=30996ced018a2a5e& ...

  5. Linux无法登录,显示module is unknown,一闪而过

    1.使用单用户模式登录系统(不作介绍) 2.查看日志:vim /var/log/secure 3.记忆起曾经配置oracle添加过该参数 vim/etc/pam.d/login中加入了: sessio ...

  6. 11.solr学习速成之MoreLikeThis

    Solr相似匹配    在网页搜索或电商产品搜索结果页面,很多时候会看到一个相似文档.相似产品或找相似的链接.Solr 使用 MoreLikeThisComponent(MLT)和 MoreLikeT ...

  7. python开发_python中的list操作

    对python中list的操作,大家可以参考: Python list 操作 以下是我个人的笔记: ============================================ Add b ...

  8. VMware虚拟机如何设置从U盘启动

    要给虚拟机重新安装win7系统,想使用U盘重装系统的方式,就需要让虚拟机从U盘启动,以下内容就是虚拟机从U盘启动的全操作过程. 前期准备: 1.u盘启动盘 2.VMware虚拟机 具体操作步骤: 1. ...

  9. jvm的happens-before原则

    提到并发,通常首先想到是锁,其实对共享资源的互斥操作是一方面,在Java中还有一方面是内存的可见性和顺序化,了解JMM的同学可能会更清楚些,内存可见性和顺序性同样非常重要,在这里简单提一下JMM模型, ...

  10. Linux服务管理 systemctl命令详解

    Linux服务器,服务管理--systemctl命令详解,设置开机自启动 syetemclt就是service和chkconfig这两个命令的整合     任务 旧指令 新指令 使某服务自动启动 ch ...