public async Task <IActionResult> GetLogfileSelect()
        {
            var response = await _client.GetFromJsonAsync <UserNameFromApiModel[]>("http://portalapi.hvnet.vn/api/basedata/getusertelelogs");

            ListColumnSelectModel listColumnSelectModel = new ListColumnSelectModel();

            listColumnSelectModel = await _logfileService.GetSelectList();

            listColumnSelectModel.ListProject = listColumnSelectModel.ListProject.Where(y => !string.IsNullOrEmpty(y)).ToList();
            listColumnSelectModel.ListType    = listColumnSelectModel.ListType.Where(y => !string.IsNullOrEmpty(y.ToString()) && y != 0 && y != 4 && y != 5 && y != 6).ToList();
            var dataNew = response.Where(y => y != null).ToList();

            listColumnSelectModel.ListStaff = new List <string>();
            dataNew.ForEach(m => listColumnSelectModel.ListStaff.Add(m.UserName));
            return(Ok(listColumnSelectModel));
            //var response = await _client.GetFromJsonAsync<UserNameFromApiModel[]>("http://portalapi.hvnet.vn/api/basedata/getusertelelogs");
            //var dataNew = response.Where(y => y != null).ToList();
            //ListColumnSelectModel listColumnSelectModel = new ListColumnSelectModel();
            //listColumnSelectModel.ListStaff = new List<string>();
            //listColumnSelectModel.ListStaff.Add("Anh Thu");
            //listColumnSelectModel.ListProject = new List<string>();
            //listColumnSelectModel.ListProject.Add("portal.hvnet.vn");
            //listColumnSelectModel.ListType = new List<int>();
            //listColumnSelectModel.ListType.Add(2);
            //dataNew.ForEach(m => listColumnSelectModel.ListStaff.Add(m.UserName));

            //return Ok(listColumnSelectModel);
        }
Пример #2
0
        public async Task <ListColumnSelectModel> GetSelectList()
        {
            ListColumnSelectModel logfiles = new ListColumnSelectModel();
            List <string>         Project;
            List <int>            Type;
            List <string>         Staff;
            var sql =
                @"
                SELECT Name FROM Project
                SELECT DISTINCT Type FROM Logfile";

            try
            {
                using (var conn = new SqlConnection(_configuration.Value))
                {
                    if (conn.State == ConnectionState.Closed)
                    {
                        conn.Open();
                    }
                    var logfilesNew = await conn.QueryMultipleAsync(sql);

                    Project = logfilesNew.Read <string>().ToList();
                    Type    = logfilesNew.Read <int>().ToList();

                    if (conn.State == ConnectionState.Open)
                    {
                        conn.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            logfiles.ListProject = Project;
            logfiles.ListType    = Type;
            return(logfiles);
        }