zoukankan      html  css  js  c++  java
  • 数据字典根据组别再分类

    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Linq;
    using System.Text.RegularExpressions;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using BaseService;
    using Framework;
    using HraWeb.Common;
    using Utility;
    using WebApp.Common;
    using Contract.Domain;
    using System.Collections;

    namespace HraWeb
    {
    public partial class SysDictManage : JQEntityManage<Contract.Domain.SysDict>
    {
    protected override void Page_Load(object sender, EventArgs e)
    {
    //给基类服务接口复制,可不付
    //base.svc = Psvc;
    if (!IsPostBack)
    {
    if (Request["_method"]=="LoadDictType")
    {
    LoadDictType();
    }
    if (!string.IsNullOrEmpty(Request["_method"]) && Request["_method"] == "MemoDictTypeCode")
    {
    string TypeCode = Request["TypeCode"] ?? "";
    if (!string.IsNullOrEmpty(TypeCode))
    {
    Session["TypeCode"] = TypeCode;
    }
    HttpContext.Current.Response.End();
    }
    else if (Request["_method"] == "entity")
    {
    string entityType = Request["entityType"] ?? "";
    if (!string.IsNullOrEmpty(entityType))
    {
    info = new QueryInfo();
    info.QueryObject = "SysDictType";
    IList list1 = Dao.FindList(info);
    //IList<SysDictType> list = Holworth.Utility.Utility.ListToT<SysDictType>(list1);
    HttpContext.Current.Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(list1));
    HttpContext.Current.Response.End();

    }
    }
    //if (string.IsNullOrEmpty(Request["_method"]))
    //{
    // Framework.QueryInfo info = new Framework.QueryInfo();
    // info.QueryObject = "SysDictType";
    // IList dictList = Dao.FindList(info);
    // prm_TypeCode_.DataSource = dictList;
    // prm_TypeCode_.DataTextField = "Name";
    // prm_TypeCode_.DataValueField = "Code";
    // prm_TypeCode_.DataBind();
    // prm_TypeCode_.Items.Insert(0, new ListItem());
    //}
    }
    base.Page_Load(sender, e);
    }


    private void LoadDictType()
    {
    Session["TypeCode"] = Request["TypeCode"];
    List<SysDictTypeGroupExt> groupExts =
    Holworth.Utility.Utility.ListToT<SysDictTypeGroupExt>(Dao.FindList(new QueryInfo("SysDictTypeGroupExt")))
    .ToList();
    var groupExtDics = groupExts.Select(x => x).ToDictionary(x => x.Id);

    IList<EasyUiTree> trees = new List<EasyUiTree>();
    EasyUiTree node = new EasyUiTree();
    node.id = "-1";
    node.text = "字典类型分组";
    try
    {
    List<SysDictType> dictTypes =
    Holworth.Utility.Utility.ListToT<SysDictType>(Dao.FindList(new QueryInfo("SysDictType"))).ToList();
    var types1 = ((from s in dictTypes select s).ToList().Distinct(new DictTypeDistinct())).ToList();
    var types =
    (from s2 in
    types1
    select
    new
    {
    CatagroyTree =
    new EasyUiTree { state = "", id = s2.ParentId.ToString(), text = groupExtDics.ContainsKey(s2.ParentId.ToString()) ? (groupExtDics[s2.ParentId.ToString()].CatagoryName) : "未分类" }
    })
    .ToDictionary(x => x.CatagroyTree.id);
    if (types.Keys.Count > 0)
    {
    node.children = new List<EasyUiTree>();
    }
    foreach (var key in types.Keys)
    {
    node.children.Add(types[key].CatagroyTree);
    }
    foreach (SysDictType sysDictType in dictTypes)
    {

    if (types.ContainsKey(sysDictType.ParentId.ToString()))
    {
    EasyUiTree ei =
    types[sysDictType.ParentId == null ? "" : sysDictType.ParentId.ToString()].CatagroyTree;
    if (ei.children == null)
    {
    ei.children = new List<EasyUiTree>();
    }
    EasyUiTree child = new EasyUiTree();
    child.id = sysDictType.Code;
    child.text = sysDictType.Name;
    child.attributes = new { parentNode = sysDictType.ParentId };
    if (ei.children != null)
    {
    ei.children.Add(child);
    }
    }

    }


    trees.Add(node);
    var json = Newtonsoft.Json.JsonConvert.SerializeObject(trees);
    HttpContext.Current.Response.Write(json);
    HttpContext.Current.Response.End();
    }

    catch (Exception ex)
    {

    JSUtil.log(ex.Message);
    }

    }
    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 = base.SetInfo();
    List<SysDict> dicts =
    Holworth.Utility.Utility.ListToT<SysDict>(Dao.FindList(new QueryInfo("SysDict")))
    .ToList();
    List<SysDictType> groupExts =
    Holworth.Utility.Utility.ListToT<SysDictType>(Dao.FindList(new QueryInfo("SysDictType")))
    .ToList();

    var groupExtDics = groupExts.Select(x => x).ToDictionary(x => x.Code);
    string typeCode =info.Parameters!=null&& info.Parameters.Count > 0 ?info.Parameters["TypeCode"].ToString():"";
    List<string> codes=new List<string>();
    if (!groupExtDics.ContainsKey(typeCode))
    {
    dicts.ForEach(d =>
    {

    try
    {
    if (d.TypeCode != null &&groupExtDics[d.TypeCode.ToUpper()]!=null&& groupExtDics[d.TypeCode.ToUpper()].ParentId != null && groupExtDics[d.TypeCode.ToUpper()].ParentId.ToString() == typeCode)
    {
    codes.Add(d.TypeCode);
    }
    }
    catch (Exception ex)
    {

    ;
    }
    });
    info.Parameters.Remove("TypeCode");
    info.Where.Remove("TypeCode");
    if (codes.Count > 0)
    {
    info.Where.Add("where", " and TypeCode in (:TypeCodes)");
    info.Parameters.Add("TypeCodes",codes.ToArray());
    }

    }


    string ParentName = string.Empty;



    //if (!string.IsNullOrEmpty(Request["ParentId"]))
    {
    //Session["ParentName"] = Request["ParentName"].ToString();

    //if (Request["ParentId"] != "-1")
    //{
    // info.Parameters.Clear();
    // info.AddParam("TypeCode", Request["ParentId"]);
    //}
    }
    return info;
    }
    /// <summary>
    /// 初始化页面控件
    /// </summary>
    protected override void InitPage()
    {
    base.InitPage();

    // BindDrop(drp_Unit, "SPSW", true);
    }
    //private Contract.IService.ISysDictService psvc;
    ///// <summary>
    ///// 初始化
    ///// </summary>
    //Contract.IService.ISysDictService Psvc
    //{
    // get
    // {
    // if (psvc == null)
    // {
    // psvc = ctx.GetObject("SysDictService") as Contract.IService.ISysDictService;
    // }
    // return psvc;

    // }
    //}
    }
    }

  • 相关阅读:
    第7 章 : 应用编排与管理:Job & DaemonSet
    第6 章 : 应用编排与管理:Deployment
    第5 章 : 应用编排与管理:核心原理
    第4 章 : 理解 Pod 和容器设计模式
    第3 章 : Kubernetes 核心概念
    第2 章 : 容器基本概念
    第1 章 : 第一堂“云原生”课
    阿里云原生技术公开课程-讲师记录及视频链接
    Shell中的(),{}几种语法用法-单独总结
    折腾kubernetes各种问题汇总-<1>
  • 原文地址:https://www.cnblogs.com/kexb/p/4759109.html
Copyright © 2011-2022 走看看