private async Task <CustomerList> GetCustomerSummaryAsync()
        {
            CustomerList customerList    = new CustomerList();
            String       requestTemplate = Application.Current.Resources["GetCustomers"] as String;
            String       requesturl      = String.Format(requestTemplate, BaseURLHelper.BaseURL);

            using (HttpClient client = new HttpClient())
            {
                //do
                //{
                try
                {
                    string response = await HttpHelper.GetAsync(client, requesturl);

                    CustomerList newCustomers = JsonConvert.DeserializeObject <CustomerList>(response);
                    customerList.AddRange(newCustomers.Take <Customers>(20));
                    String nextBatch = (string)JArray.Parse(response).Last["@metadata"]["next_batch"];
                    if (requesturl != null)
                    {
                        //requesturl = requesturl + "&auth=" + apiKey;
                    }
                    Debug.WriteLine("Just a break point.");
                }
                catch (Exception)
                {
                    Debug.WriteLine("Just a break point.");
                }
                //  } while (requesturl != null);
            }

            return(customerList);
        }
        private void InitializeData()
        {
            var principal = Thread.CurrentPrincipal as SystemPrincipal;
            var agentId   = principal.Identity.Id;
            var customers = _customerService.GetCustomersBy(agentId);

            Application.Current.Dispatcher.BeginInvoke(new Action(() =>
            {
                CustomerList.AddRange(customers);
                if (SelectedCustomer != null)
                {
                    SelectedCustomer = CustomerList.FirstOrDefault(c => c.Id == SelectedCustomer.Id);
                }
                else
                {
                    SelectedCustomer = CustomerList.Count == 0 ? null : CustomerList[0];
                }
            }));
        }
Exemplo n.º 3
0
    /// <summary>
    /// 交易对方
    /// </summary>
    /// <returns></returns>
    public List <string> getTradeCompany(ReorganizationRec target)
    {
        var rtn = new List <string>();

        TradeCompany.IsRequire = true;
        var Rules = new List <TableSearchTitleRule>();

        Rules.Add(TradeCompany);
        var opt = new HTMLTable.SearchOption();

        opt.IsMeger = true;
        var result = HTMLTable.GetMultiInfoByTitleRules(root, Rules, opt);

        if (result.Count == 0)
        {
            return(rtn);
        }
        //首页表格提取出交易者列表
        var tableid = result[0][0].TableId;
        //注意:由于表格检索的问题,这里只将第一个表格的内容作为依据
        //交易对方是释义表的一个项目,这里被错误识别为表头
        //TODO:这里交易对方应该只选取文章前部的表格!!
        var TableTrades = result.Where(z => !ExplainTableId.Contains(z[0].TableId))
                          .Select(x => x[0].RawData)
                          .Where(y => !y.Contains("不超过")).ToList();
        var TargetLoc = LocateProperty.LocateCustomerWord(root, new string[] { target.TargetCompanyFullName, target.TargetCompanyShortName }.ToList(), "标的");
        var HolderLoc = LocateProperty.LocateCustomerWord(root, new string[] { "持有", "所持" }.ToList(), "持有");
        var OwnerLoc  = LocateProperty.LocateCustomerWord(root, TableTrades.ToList(), "交易对手");

        CustomerList.AddRange(TargetLoc);
        CustomerList.AddRange(HolderLoc);
        CustomerList.AddRange(OwnerLoc);
        nermap.Anlayze(this);
        foreach (var nerlist in nermap.ParagraghlocateDict.Values)
        {
            //交易对手 持有 标的 这样的文字检索
            int OwnerIdx  = -1;
            int HolderIdx = -1;
            int TargetIdx = -1;
            nerlist.CustomerList.Sort((x, y) => { return(x.StartIdx.CompareTo(y.StartIdx)); });
            var OwnerName = string.Empty;
            foreach (var ner in nerlist.CustomerList)
            {
                if (ner.Description == "交易对手")
                {
                    OwnerIdx  = ner.StartIdx;
                    OwnerName = ner.Value;
                }
                if (ner.Description == "持有" && OwnerIdx != -1)
                {
                    HolderIdx = ner.StartIdx;
                }
                if (ner.Description == "标的" && OwnerIdx != -1 && HolderIdx != -1)
                {
                    TargetIdx = ner.StartIdx;
                }
                if (OwnerIdx != -1 && HolderIdx != -1 && TargetIdx != -1)
                {
                    if (TargetIdx - OwnerIdx < 20)
                    {
                        rtn.Add(OwnerName);
                    }
                    OwnerIdx  = -1;
                    HolderIdx = -1;
                    TargetIdx = -1;
                }
            }
        }
        return(rtn.Distinct().ToList());
    }