Пример #1
0
        private static List <AplicationDomain> GetAllProcesses()
        {
            var aplicationlistmachine = new List <AplicationDomain>();

            foreach (ServiceController service in ServiceController.GetServices())
            {
                var aplicationmachine = new AplicationDomain
                {
                    ServiceDisplayName = service.DisplayName,
                    ServiceName        = service.DisplayName,
                    ServiceType        = service.ServiceType,
                    Status             = service.Status,
                    MachiName          = Environment.MachineName,
                    DateTimeUtc        = DateTime.UtcNow
                };
                aplicationlistmachine.Add(aplicationmachine);
            }
            return(aplicationlistmachine);
        }
Пример #2
0
        private static void LambdaTest()
        {
//1   Servi? o de Roteador AllJoyn Servi?o de Roteador AllJoyn 32  1   LAPTOP - 45V304UA 22 / 05 / 2019 23:58:09
//2   Servi? o Gateway de Camada de Aplicativo Servi?o Gateway de Camada de Aplicativo 16  1   LAPTOP - 45V304UA 22 / 05 / 2019 23:58:09
//3   Servi? o Auxiliar de Host do Aplicativo Servi?o Auxiliar de Host do Aplicativo  48  4   LAPTOP - 45V304UA 22 / 05 / 2019 23:58:09
//4   Identidade do Aplicativo Identidade do Aplicativo    32  1   LAPTOP - 45V304UA 22 / 05 / 2019 23:58:09
//5   Informa ?? es sobre Aplicativos   Informa ?? es sobre Aplicativos   48  4   LAPTOP - 45V304UA 22 / 05 / 2019 23:58:09
//6   Gerenciamento de aplicativo Gerenciamento de aplicativo 32  1   LAPTOP - 45V304UA 22 / 05 / 2019 23:58:09
//7   Prepara ?? o de Aplicativos   Prepara ?? o de Aplicativos   48  1   LAPTOP - 45V304UA 22 / 05 / 2019 23:58:09

            Repository <AplicationDomain> repository = new Repository <AplicationDomain>();

            var aplication1 = new AplicationDomain {
                DateTimeUtc        = DateTime.UtcNow.AddMinutes(-30),
                MachiName          = "Teste0",
                ServiceDisplayName = "tes",
                ServiceName        = "Identidade do Aplicativo Identidade do Aplicativo",
                ServiceType        = System.ServiceProcess.ServiceType.Adapter,
                Status             = 0
            };



            var aplication2 = new AplicationDomain
            {
                DateTimeUtc        = DateTime.UtcNow.AddMinutes(-30),
                MachiName          = "Teste0",
                Id                 = 1,
                ServiceDisplayName = "tes",
                ServiceName        = "Gerenciamento de aplicativo Gerenciamento de aplicativo",
                ServiceType        = System.ServiceProcess.ServiceType.Adapter,
                Status             = 0
            };

            var aplication3 = new AplicationDomain
            {
                DateTimeUtc        = DateTime.UtcNow,
                MachiName          = "Teste0",
                Id                 = 1,
                ServiceDisplayName = "tes",
                ServiceName        = "tests",
                ServiceType        = System.ServiceProcess.ServiceType.Adapter,
                Status             = 0
            };

            var aplication4 = new AplicationDomain
            {
                DateTimeUtc        = DateTime.UtcNow.AddMinutes(-50),
                MachiName          = "Teste1",
                Id                 = 1,
                ServiceDisplayName = "tes",
                ServiceName        = "Identidade do Aplicativo Identidade do Aplicativo",
                ServiceType        = System.ServiceProcess.ServiceType.Adapter,
                Status             = 0
            };

            var aplication5 = new AplicationDomain
            {
                DateTimeUtc        = DateTime.UtcNow,
                MachiName          = "Teste1",
                Id                 = 1,
                ServiceDisplayName = "tes",
                ServiceName        = "tests",
                ServiceType        = System.ServiceProcess.ServiceType.Adapter,
                Status             = 0
            };

            var aplication6 = new AplicationDomain
            {
                DateTimeUtc        = DateTime.UtcNow.AddMinutes(-30),
                MachiName          = "Teste2",
                Id                 = 1,
                ServiceDisplayName = "tes",
                ServiceName        = "Identidade do Aplicativo Identidade do Aplicativo",
                ServiceType        = System.ServiceProcess.ServiceType.Adapter,
                Status             = 0
            };

            repository.Insert(aplication1);
            repository.Insert(aplication2);
            repository.Insert(aplication3);
            repository.Insert(aplication4);
            repository.Insert(aplication5);
            repository.Insert(aplication6);


            var ret = repository.SelectAll();


            var lambdaBreedsCount = ret.GroupBy(x => x.ServiceName).Select(grp =>
                                                                           new {
                ServiceName = grp.Key,
                Count       = grp.Count()
            }).ToList()
                                    .OrderBy(e => e.Count)
                                    .Take(10);



            var dta = DateTime.UtcNow.AddMinutes(-30);

            var dta1 = DateTime.UtcNow.AddMinutes(-30 * 1.5);

            var resultado = repository.Query(a => (a.DateTimeUtc) <= dta)
                            .Select(i => new { Machine = i.MachiName })
                            .ToList().GroupBy(grp => grp.Machine).Distinct();

            //var resultado = repository.Query(a => DbFunctions.TruncateTime(a.DataCadastro) == dta)
            //              .Select(i => new { i.MachiName })
            //              .ToList();
        }