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. 贴一段demo代码,演示channel之间的同步

    package main import ( "fmt" "time" ) func deskGoRoutine(index int, userChannel c ...

  2. (转)Inno Setup入门(六)——在程序目录下创建文件夹

    本文转载自:http://blog.csdn.net/yushanddddfenghailin/article/details/17250789 创建文件夹可以使用[dirs]段实现,代码如下: [s ...

  3. 【学徒日记】Unity 动画调用事件

    http://note.youdao.com/noteshare?id=a15f965fc57a0b25c87ee09388cf0f4a 具体内容看上面的链接. 1. 在脚本里写一个函数,它的参数只能 ...

  4. Druid.io系列(六):问题总结

    原文地址: https://blog.csdn.net/njpjsoftdev/article/details/52956508 我们在生产环境中使用Druid也遇到了很多问题,通过阅读官网文档.源码 ...

  5. 修改win7远程桌面端口号

    Windows 7/Vista/XP/2003等系统中的远程终端服务是一项功能非常强大的服务,同时也成了入侵者长驻主机的通道,入侵者可以利用一些手段得到管理员账号和密码并入侵主机.下面,我们来看看如何 ...

  6. TOTAL COMMAND自定义快捷键

  7. Vue基础知识之常用属性和事件修饰符(二)

    Vue中的常用选项 1.计算属性 computed为可以计算的属性,由get方法和set方法组成,默认调用的是get方法.里面的 计算属性简单来说,就是根据数据推算出来的值,当给这个值赋值时可以影响其 ...

  8. Netty心跳之IdleStateHandler

    Netty提供了对心跳机制的天然支持,心跳可以检测远程端是否存活,或者活跃 今天我们就一起初识一下Netty4的心跳机制 Netty4.0提供了一个类,名为IdleStateHandler,这个类可以 ...

  9. Android Studio 2.3.3 调用asp.net webService实战(拒绝忽悠)

    1.路径中不能包含localhost(本来想在本机调试,就是不行,没办法发布到远程服务器) 2.必须采用异步的办法(阻塞主线程的是肯定不行了) 3.以下是全部的源代码(毫不保留) package co ...

  10. js给kindeditor添加值

    需求:在点击回复按钮时,在kindeditor中添加被回复的用户昵称 html:<textarea name="content" id="mycontent&quo ...