Пример #1
0
        private void QueryLpGroup()
        {
            StringBuilder sb     = new StringBuilder();
            List <string> idStrs = new List <string>();

            for (int i = 0; i < _ids.Count; i++)
            {
                sb.Append($"{_ids[i]},");
                if (i != 0 && i % 199 == 0)
                {
                    sb.RemoveLast(1);
                    idStrs.Add(sb.ToString());
                    sb.Clear();
                }
            }
            sb.RemoveLast(1);
            idStrs.Add(sb.ToString());
            // 设置批次查询计数器与查询状态,使用多线程查询时,禁止对同一个功能的后续查询
            // 等待批次处理完毕再进行下面的
            counter  = 0;
            times    = idStrs.Count;
            querying = true;
            _dictLpItemRequestData.Clear();
            foreach (var str in idStrs)
            {
                if (string.IsNullOrEmpty(str))
                {
                    times--;
                    if (times <= 0)
                    {
                        querying = false;
                        StatusManager.GetManager()?.ShowMsg("没有匹配到请求的数据,本次请求取消,检查物品类型.....");
                        return;
                    }
                    continue;
                }

                new Thread(new ThreadStart(() => {
                    // HttpRequestManager.SetQueryPost(str, RegionGalaxyID.MarketGroupRegionID, RegionGalaxyID.MarketGroupGalaxyID);
                    HttpRequestManager.SetQueryPost(str, RegionGalaxyID.LpQueryRegionID, RegionGalaxyID.LpQueryGalaxyID);
                    HttpRequestManager.Post("NULL", QueryLpGroupCompleteMuti);
                })).Start();
                // 休眠0.1s,否则会有线程不安全,线程准备需要时间,这里赋值可能造成引用错乱
                Thread.Sleep(100);
            }
        }
Пример #2
0
 public override void QueryStart(object parameter)
 {
     _groupNode = parameter as MarketGroupNode;
     if (_groupNode != null && !querying)
     {
         try
         {
             var ids = GetIDs();
             StatusManager.GetManager()?.ShowMsg("获取服务器数据中.....");
             counter  = 0;
             times    = ids.Count;
             querying = true;
             _queryMarketGroupResults = new List <MarketGroupTypeShow>();
             foreach (var idStr in ids)
             {
                 if (string.IsNullOrEmpty(idStr))
                 {
                     times--;
                     if (times <= 0)
                     {
                         StatusManager.GetManager()?.ShowMsg("没有匹配到请求的数据,本次请求取消,检查物品类型.....");
                         querying = false;
                         return;
                     }
                     continue;
                 }
                 new Thread(new ThreadStart(() => {
                     HttpRequestManager.SetQueryPost(idStr, RegionGalaxyID.MarketGroupRegionID, RegionGalaxyID.MarketGroupGalaxyID);
                     HttpRequestManager.Post("NULL", QueryMarketGroupCompleteMuti);
                 })).Start();
                 Thread.Sleep(100);
             }
         }
         catch { }
     }
 }
Пример #3
0
        private void ThreadSearchQueryIDs()
        {
            List <string> ids     = new List <string>();
            int           index   = 0;
            int           counter = 0;
            StringBuilder sb      = new StringBuilder();

            try
            {
                StatusManager.GetManager()?.ShowMsg("解析数据中.....");
                var typeIDs          = LocalConfigLoadManager.GetConfigClass <TypeIDDBClass>().TypeIDs;
                var marketGroupDB    = LocalConfigLoadManager.GetConfigClass <MarketGroupDBClass>().MarketGroupDB;
                var itemTypeFilterVM = XamlComponentsManager.GetManager().Get <Grid>(XamlComponentsType.RootGrid).Resources["itemTypeFilterVM"] as ItemTypeFilterVM;
                foreach (var no in typeIDs.Values)
                {
                    // 这里需要处理一下,因为服务端只支持单次处理200个
                    if (no != null && no.name != null && no.name.Contains(_mgSearchStr))
                    {
                        // 获取所在组,找到最上层的组
                        marketGroupDB.TryGetValue(no.marketGroupID, out var group);
                        if (group == null)
                        {
                            continue;
                        }
                        var resultGroup = GetRoot(group, marketGroupDB);
                        Filter.ItemTypeFilterDict.TryGetValue(itemTypeFilterVM.SelectedItem, out var rootID);
                        if (rootID == resultGroup.ID)
                        {
                            // 如果是所在组类型,则查询
                            sb.Append($"{no.ID},");
                            index++;
                        }
                    }
                    if (index > 199)
                    {
                        counter++;
                        index = 0;
                        ids.Add(sb.RemoveLast(1).ToString());
                        sb.Clear();
                    }
                }
            }
            catch (Exception e) { MessageBox.Show(e.Message); }

            // 处理最后一段数据
            ids.Add(sb.RemoveLast(1).ToString());

            StatusManager.GetManager()?.ShowMsg("获取远端服务器数据.....");
            // 设置批次查询计数器与查询状态,使用多线程查询时,禁止对同一个功能的后续查询
            // 等待批次处理完毕再进行下面的
            counter = 0;
            times   = ids.Count;
            // 清空数据缓存
            _queryMarketGroupResults = new List <MarketGroupTypeShow>();
            foreach (var str in ids)
            {
                if (string.IsNullOrEmpty(str))
                {
                    times--;
                    if (times <= 0)
                    {
                        StatusManager.GetManager()?.ShowMsg("没有匹配到请求的数据,本次请求取消,检查物品类型.....");
                        querying = false;
                        return;
                    }
                    continue;
                }


                new Thread(new ThreadStart(() => {
                    HttpRequestManager.SetQueryPost(str, RegionGalaxyID.MarketGroupRegionID, RegionGalaxyID.MarketGroupGalaxyID);
                    HttpRequestManager.Post("NULL", QueryMarketGroupCompleteMuti);
                })).Start();
                Thread.Sleep(100);
            }
        }