Ejemplo n.º 1
0
 private void _getNumberByCity(string where, params MySqlParameter[] commandParameters)
 {
     Message = "查询开始。。。";
     NumberList.Clear();
     Task.Factory.StartNew(() =>
     {
         var watch = new Stopwatch();
         watch.Start();
         using (var conn = new MySqlConnection(DatabaseHelper.ConnectionString))
         {
             conn.Open();
             var command = new MySqlCommand($"SELECT n.number,m.number,m.city,m.type,m.city_code,m.postcode FROM `zd_number` n LEFT JOIN zd_mobile m ON n.mobile_id = m.id WHERE {where};", conn);
             foreach (var parm in commandParameters)
             {
                 command.Parameters.Add(parm);
             }
             var reader = command.ExecuteReader();
             while (reader.Read())
             {
                 if (reader.HasRows)
                 {
                     var item = new NumberInformation(
                         reader.GetString(0),
                         reader.GetString(1),
                         reader.GetString(2),
                         reader.GetString(3),
                         reader.GetString(4),
                         reader.GetString(5)
                         );
                     Application.Current.Dispatcher.Invoke(() =>
                     {
                         NumberList.Add(item);
                     });
                 }
             }
             reader.Close();
         }
         watch.Stop();
         _showMessage($"运行{watch.Elapsed},获得{NumberList.Count}条数据");
     });
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 获取全部结果进行正则匹配
 /// </summary>
 /// <param name="rule"></param>
 private void _getNumberByRules(string rule)
 {
     Message = "查询开始。。。";
     NumberList.Clear();
     Task.Factory.StartNew(() =>
     {
         var watch = new Stopwatch();
         watch.Start();
         using (var conn = new MySqlConnection(DatabaseHelper.ConnectionString))
         {
             conn.Open();
             var command            = new MySqlCommand("SELECT n.number,m.number,m.city,m.type,m.city_code,m.postcode FROM `zd_number` n LEFT JOIN zd_mobile m ON n.mobile_id = m.id;", conn);
             MySqlDataReader reader = command.ExecuteReader();
             while (reader.Read())
             {
                 if (reader.HasRows)
                 {
                     string number = reader.GetString(0);
                     if (Regex.IsMatch(number, rule))
                     {
                         var item = new NumberInformation(number,
                                                          reader.GetString(1),
                                                          reader.GetString(2),
                                                          reader.GetString(3),
                                                          reader.GetString(4),
                                                          reader.GetString(5)
                                                          );
                         Application.Current.Dispatcher.Invoke(() =>
                         {
                             NumberList.Add(item);
                         });
                     }
                 }
             }
             reader.Close();
         }
         watch.Stop();
         _showMessage($"运行{watch.Elapsed},获得{NumberList.Count}条数据");
     });
 }