zoukankan      html  css  js  c++  java
  • .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>(wd{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();
    }
    }
    }

  • 相关阅读:
    jqGrid详解及高级应用(十四)
    ERP存储过程的调用和树形菜单的加载(四)
    IDisposable接口
    SQL调用系统存储过程整理
    Net作业调度-----Quartz.Net
    C#泛型(二)
    ERP通用存储过程封装(三)
    ERP PowerDesigner工具使用(二)
    ERP简介(一)
    jQuery.TreeView插件实现树状导航(十三)
  • 原文地址:https://www.cnblogs.com/kexb/p/4716490.html
Copyright © 2011-2022 走看看