.net正则查询

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();
}
}
}

时间: 2024-10-21 10:14:58

.net正则查询的相关文章

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

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

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

在查询mongo时用到了正则查询 设字符串为   str = '/ab/cd.ef?g=' 直接用正则查询没有匹配. collection.find({"re":{'$regex':str},'b':{'$nin':[False]}}).count() 原因是 /  .  ? 都是正则表达式中的特殊字符,如果要保留原义则需要用"\"来进行转义 即把字符串改成  str = '\/ab\/cd\.ef\?g=' 但是,由于"\"在python中是一

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

接口返回报文为json 格式,如下: {"body":{"businessinfo":{"c1rate":"25.00","c2rate":"0.00","c4rate":"0.00","c5rate":"0.00","c6rate":"6.00","c8ra

mysql正则查询 模糊查询

-- ==============正则查询================ /* SQL默认是忽略大小写的 正则模式使用REGEXP和NOT REGEXP操作符(或RLIKE和NOT RLIKE,它们是同义词).正则即字段值包含正则的内容即可 . 匹配任何单个的字符,表示任意单字符 [...] 匹配包含方括号内某单个字符的字符串,[0-9]匹配0到9之间的某个数字 * 匹配零个或多个在它前面的字符 {n} 匹配n个在它前面的字符 如果希望大小写都匹配上可以这样写.[aA] 匹配大小写的 a,[a

正则查询符合条件的字符串

由于对正则不熟悉..遇到问题很烦恼.. 比如我要将以下中乱码部分去掉,怎么查询出那些乱码.. `SERIALNO` varchar(60) NOT NULL COMMENT 'å?ˆå?Œæµ?æ°´å?·', `RELATIVESERIALNO` varchar(60) DEFAULT NULL COMMENT 'å…³è?”申请æµ?æ°´å?·', `ARTIFICIALNO` varchar(60) DEFAULT NULL COMMENT '人工å?ˆå?Œç¼–å?·

正则-查询

##re.findall()re.findall() 返回匹配成功的列表 注意:遇到子组的时候,返回的是子组内容列表>>> re.findall(r'a[A-Z]\S*','aBC aDE5464')['aBC', 'aDE5464'] 子组findall 返回的是子组内容列表>>>re.findall(r'(a[A-Z])\S*','aBC aDE5464')['aB', 'aD'] ##子组re.match().group() 和 re.search().group

MongoDB查询语句

看了些资料,对应只需要知道怎么查询和使用mongodb的我来说,这些足够啦. 左边是mongodb查询语句,右边是sql语句.对照着用,挺方便. db.users.find() select * from users db.users.find({"age" : 27}) select * from users where age = 27 db.users.find({"username" : "joe", "age" : 

查询出menupath字段中 出现 “- &quot;(横杆)大于3次的 记录

表明为productclass    我想查询出menupath字段中 出现 “- "(横杆)大于3次的 记录 答:1  select from productclass  where menupath  REGEXP '[[:digit:]]+-[[:digit:]]+-[[:digit:]]+-'  这样就可以 不过不建议用正则查询出menupath字段中 出现 “- "(横杆)大于3次的 记录 2 select * from productclass   where length

Neo4j的查询语法笔记(二)

cypher是neo4j官网提供的声明式查询语言,非常强大,用它可以完成任意的图谱里面的查询过滤,我们知识图谱的一期项目 基本开发完毕,后面会陆续总结学习一下neo4j相关的知识.今天接着上篇文章来看下neo4j的cpyher查询的一些基本概念和语法. 一,Node语法 在cypher里面通过用一对小括号()表示一个节点,它在cypher里面查询形式如下: 1,() 代表匹配任意一个节点 2, (node1) 代表匹配任意一个节点,并给它起了一个别名 3, (:Lable) 代表查询一个类型的数