Exemplo n.º 1
0
        public IEnumerable <MWLog> SelectLog(LookupCondition lookupCondition)
        {
            List <MWLog> retList = new List <MWLog>();

            using (var conn = new MySqlConnection(connString))
            {
                conn.Open();
                using (var cmd = new MySqlCommand())
                {
                    string sql = "select * from log_info limt 10;";
                    cmd.Connection = conn;
                    //cmd.CommandText = EmbeddedResource.GetString("SelectLogInfoWithLogProperty.sql");
                    cmd.CommandText = sql;
                    cmd.Parameters.AddWithValue("begin_date", lookupCondition.BeginDate.ToString("yyyy-MM-dd"));
                    cmd.Parameters.AddWithValue("end_date", lookupCondition.EndDate.ToString("yyyy-MM-dd"));
                    cmd.Parameters.AddWithValue("routing_key", "%" + lookupCondition.RoutingKey + "%");
                    cmd.Parameters.AddWithValue("limit", lookupCondition.Limit);
                    cmd.Prepare();
                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            retList.Add(ModelConverter.ToMWLog(reader));
                        }
                    }
                }
            }
            return(retList);
        }
Exemplo n.º 2
0
        public async Task <IEnumerable <MWLog> > SelectLogAsync(LookupCondition lookupCondition)
        {
            List <MWLog> retList = new List <MWLog>();

            using (var conn = new MySqlConnection(connString))
            {
                await conn.OpenAsync();

                using (var cmd = new MySqlCommand())
                {
                    cmd.Connection = conn;
                    //string sql = "select info.*, prop.* from log_info info join log_property prop on info.property_seq = prop.seq order by info.seq desc limit 10;";
                    //cmd.CommandText = sql;
                    cmd.CommandText = EmbeddedResource.GetString("SelectLogInfoWithLogProperty.sql");
                    cmd.Parameters.AddWithValue("begin_date", lookupCondition.BeginDate.ToString("yyyy-MM-dd"));
                    cmd.Parameters.AddWithValue("end_date", lookupCondition.EndDate.ToString("yyyy-MM-dd"));
                    cmd.Parameters.AddWithValue("routing_key", "%" + lookupCondition.RoutingKey + "%");
                    cmd.Parameters.AddWithValue("limit", lookupCondition.Limit);
                    cmd.Prepare();
                    using (var reader = await cmd.ExecuteReaderAsync())
                    {
                        while (await reader.ReadAsync())
                        {
                            retList.Add(ModelConverter.ToMWLog(reader));
                        }
                    }
                }
            }
            return(retList);
        }
Exemplo n.º 3
0
 public async Task <IEnumerable <MWLog> > GetLogsAsync(LookupCondition lookupCondition)
 {
     if (lookupCondition.Seq > 0)
     {
         return(await new MWLogData().SelectLogAsync(lookupCondition.Seq));
     }
     return(await new MWLogData().SelectLogAsync(lookupCondition));
 }
Exemplo n.º 4
0
 public IEnumerable <MWLog> GetLogs(LookupCondition lookupCondition)
 {
     if (lookupCondition.Seq > 0)
     {
         return(new MWLogData().SelectLog(lookupCondition.Seq));
     }
     return(new MWLogData().SelectLog(lookupCondition));
 }
Exemplo n.º 5
0
        private void GetLogs()
        {
            var lookupCondition = new LookupCondition
            {
                BeginDate  = dtBeginDate.SelectedDate.Value,
                EndDate    = dtEndDate.SelectedDate.Value.AddDays(1),
                Seq        = (!string.IsNullOrEmpty(txtSeq.Text)) ? Convert.ToInt32(txtSeq.Text.ToString()) : 0,
                RoutingKey = txtRoutingKey.Text,
                Limit      = Convert.ToInt32(txtLimit.Text.ToString())
            };

            vm.MWLogCollection      = new ObservableCollection <MWLog>(new MWLogService().GetLogs(lookupCondition));
            LogListView.ItemsSource = vm.MWLogCollection;
        }
Exemplo n.º 6
0
        private async void GetLogsAsync()
        {
            try
            {
                var lookupCondition = new LookupCondition
                {
                    BeginDate  = dtBeginDate.SelectedDate.Value,
                    EndDate    = dtEndDate.SelectedDate.Value.AddDays(1),
                    Seq        = (!string.IsNullOrEmpty(txtSeq.Text)) ? Convert.ToInt32(txtSeq.Text.ToString()) : 0,
                    RoutingKey = txtRoutingKey.Text,
                    Limit      = Convert.ToInt32(txtLimit.Text.ToString())
                };
                vm.MWLogCollection = new ObservableCollection <MWLog>(await new MWLogService().GetLogsAsync(lookupCondition));

                LogListView.ItemsSource = vm.MWLogCollection;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }