using Microsoft.AspNetCore.DataProtection.KeyManagement; 
 | 
using SqlSugar; 
 | 
using System; 
 | 
using System.Collections.Generic; 
 | 
using System.Linq; 
 | 
using System.Text; 
 | 
using System.Threading.Tasks; 
 | 
using WIDESEAWCS_Core.BaseRepository; 
 | 
using WIDESEAWCS_ISystemRepository; 
 | 
using WIDESEAWCS_Model.Models; 
 | 
  
 | 
namespace WIDESEAWCS_SystemRepository 
 | 
{ 
 | 
    public class Sys_DictionaryRepository : RepositoryBase<Sys_Dictionary>, ISys_DictionaryRepository 
 | 
    { 
 | 
        public Sys_DictionaryRepository(IUnitOfWorkManage unitOfWorkManage) : base(unitOfWorkManage) 
 | 
        { 
 | 
        } 
 | 
  
 | 
        /// <summary> 
 | 
        ///  
 | 
        /// </summary> 
 | 
        /// <param name="dicNos"></param> 
 | 
        /// <param name="executeSql">是否执行自定义sql</param> 
 | 
        /// <returns></returns> 
 | 
        public IEnumerable<Sys_Dictionary> GetDictionaries(IEnumerable<string> dicNos, bool executeSql = false) 
 | 
        { 
 | 
            List<Sys_Dictionary> Dictionaries = GetAllDictionary(dicNos); 
 | 
  
 | 
            //foreach (var item in Dictionaries.Where(x => dicNos.Contains(x.DicNo))) 
 | 
            //{ 
 | 
            //    if (executeSql) 
 | 
            //    { 
 | 
            //        //  2020.05.01增加根据用户信息加载字典数据源sql 
 | 
            //        string sql = item.DBSql; 
 | 
            //        if (!string.IsNullOrEmpty(sql)) 
 | 
            //        { 
 | 
            //            item.DicList = Query(sql); 
 | 
            //        } 
 | 
            //    } 
 | 
            //} 
 | 
  
 | 
            return Dictionaries; 
 | 
        } 
 | 
  
 | 
        List<Sys_DictionaryList> Query(string sql) 
 | 
        { 
 | 
            try 
 | 
            { 
 | 
                return base.QueryDynamicDataBySql(sql, null).Select(s => new Sys_DictionaryList() 
 | 
                { 
 | 
                    DicName = s.Value, 
 | 
                    DicValue = s.Key.ToString() 
 | 
                }).ToList(); 
 | 
            } 
 | 
            catch (Exception ex) 
 | 
            { 
 | 
                throw ex; 
 | 
            } 
 | 
        } 
 | 
  
 | 
        private List<Sys_Dictionary> GetAllDictionary(IEnumerable<string> dicNos) 
 | 
        { 
 | 
            //base.QueryData().ToList(); 
 | 
            List<Sys_Dictionary> _dictionaries = Db.Queryable<Sys_Dictionary>().Includes(x => x.DicList).Where(x => x.Enable == 1 && dicNos.Contains(x.DicNo)).ToList(); 
 | 
            return _dictionaries; 
 | 
        } 
 | 
    } 
 | 
  
 | 
    public class SourceKeyVaule 
 | 
    { 
 | 
        public object Key { get; set; } 
 | 
        public string Value { get; set; } 
 | 
    } 
 | 
} 
 |