/// <summary> /// table加载数据后刷新当前table数据的字典项(适用字典数据量比较大的情况) /// </summary> /// <param name="keyData"></param> /// <returns></returns> public object GetTableDictionary(Dictionary <string, object[]> keyData) { // 2020.08.06增加pgsql获取数据源 if (DBType.Name == DbCurrentType.PgSql.ToString()) { return(GetPgSqlTableDictionary(keyData)); } var dicInfo = Dictionaries.Where(x => keyData.ContainsKey(x.DicNo) && !string.IsNullOrEmpty(x.DbSql)) .Select(x => new { x.DicNo, x.DbSql }) .ToList(); List <object> list = new List <object>(); string keySql = DBType.Name == DbCurrentType.MySql.ToString() ? "t.key" : "t.[key]"; dicInfo.ForEach(x => { if (keyData.TryGetValue(x.DicNo, out object[] data)) { // 2020.05.01增加根据用户信息加载字典数据源sql string sql = DictionaryHandler.GetCustomDBSql(x.DicNo, x.DbSql); sql = $"SELECT * FROM ({sql}) AS t WHERE " + $"{keySql}" + $" in @data"; list.Add(new { key = x.DicNo, data = repository.DapperContext.QueryList <object>(sql, new { data }) }); } });
public void Can_Process_Generic_Dictionary() { // Arrange var sut = new DictionaryHandler(); var instance = new Dictionary <string, string> { { "k1", "a" }, { "k2", "b" }, { "k3", "c" } }; var request = TestHelpers.CreateCustomTypeHandlerRequest(instance); var typeHandlers = new[] { new StringHandler() }; var typeNameFormatters = new[] { new DefaultTypeNameFormatter() }; var callback = TestHelpers.CreateCallback(typeHandlers, typeNameFormatters); // Act var actual = sut.Process(request, callback); var code = callback.Builder.ToString(); // Assert actual.Should().BeTrue(); code.Should().Be(@"new System.Collections.Generic.Dictionary<System.String, System.String> { [@""k1""] = @""a"", [@""k2""] = @""b"", [@""k3""] = @""c"", }"); }
static void Main(string[] args) { String input = read(); List<int> key = createKey(input); String encodedText = encode(input, key); DictionaryHandler dicHandler = new DictionaryHandler(); List<String> answers = dicHandler.findAnswers(encodedText); using(StreamWriter writer = new StreamWriter("output.txt")) { writer.WriteLine(encodedText); foreach(KeyValuePair<String,List<int>> pair in answersWithKey(encodedText,answers)) { writer.Write(pair.Key+ " "); foreach(int x in pair.Value) { writer.Write(x+1); if (key.Count > 10) writer.Write(" "); } writer.WriteLine(); } foreach (int x in key) { writer.Write(x+1); if (key.Count > 10) writer.Write(" "); } } }
public object GetVueDictionary(string[] dicNos) { if (dicNos == null || dicNos.Count() == 0) { return new string[] { } } ; var dicConfig = DictionaryManager.GetDictionaries(dicNos, false).Select(s => new { dicNo = s.DicNo, config = s.Config, dbSql = s.DbSql, list = s.Sys_DictionaryList.OrderByDescending(o => o.OrderNo) .Select(list => new { key = list.DicValue, value = list.DicName }) }).ToList(); object GetSourceData(string dicNo, string dbSql, object data) { // 2020.05.01增加根据用户信息加载字典数据源sql dbSql = DictionaryHandler.GetCustomDBSql(dicNo, dbSql); if (string.IsNullOrEmpty(dbSql)) { return(data as object); } return(repository.DapperContext.QueryList <object>(dbSql, null)); } return(dicConfig.Select(item => new { item.dicNo, item.config, data = GetSourceData(item.dicNo, item.dbSql, item.list) }).ToList()); }
static void Main(string[] args) { DictionaryHandler.SplitDict(); ThreadStart[] threadStarts = new ThreadStart[DictionaryHandler.chunckCollection.Count]; for (int i = 0; i < DictionaryHandler.chunckCollection.Count; i++) { threadStarts[i] = new ThreadStart(() => CrackingHandler.RunCracking(DictionaryHandler.chunckCollection[i])); new Thread(threadStarts[i]).Start(); } Console.WriteLine(DictionaryHandler.chunckCollection[1].Count); }
protected void ReadData() { DictionaryHandler bodyindex = new DictionaryHandler( PathHelper.ResolvePath("~/App_Data/BodyIndex.Db")); BodyIndex = bodyindex.ReadInitHashSet(); DictionaryHandler titleindex = new DictionaryHandler( PathHelper.ResolvePath("~/App_Data/TitleIndex.Db")); TitleIndex = titleindex.ReadInitHashSet(); UrlSiteMapper urlSiteMapper = new UrlSiteMapper( PathHelper.ResolvePath("~/App_Data/Sites.Db")); UrlSiteMapper = urlSiteMapper.ReadInitDictionary(); }
/// <summary> /// 通过远程搜索 /// </summary> /// <param name="dicNo"></param> /// <param name="value"></param> /// <returns></returns> public async Task <object> GetSearchDictionary(string dicNo, string value) { if (string.IsNullOrEmpty(dicNo) || string.IsNullOrEmpty(value)) { return(null); } // 2020.05.01增加根据用户信息加载字典数据源sql string sql = Dictionaries.Where(x => x.DicNo == dicNo).FirstOrDefault()?.DbSql; sql = DictionaryHandler.GetCustomDBSql(dicNo, sql); if (string.IsNullOrEmpty(sql)) { return(null); } sql = $"SELECT * FROM ({sql}) AS t WHERE value LIKE @value"; return(await Task.FromResult(repository.DapperContext.QueryList <object>(sql, new { value = "%" + value + "%" }))); }
public ArrayHandler(T[] array) { this.array = array; customArray = new DictionaryHandler <int, T>(); }
public ArrayHandler(int size) { array = new T[size]; customArray = new DictionaryHandler <int, T>(); }