Esempio n. 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Первое задание");
            SuperQueue <DateTime> sq = new SuperQueue <DateTime>();

            sq.Add(new DateTime());
            sq.Add(new DateTime());
            sq.Add(new DateTime());
            sq.Add(new DateTime()); ///искл
            Console.WriteLine();


            Console.WriteLine("Второе задание");
            string[] s = { "Proga", "CSIS", "IGIG", "DCP", "OSI" };
            var      c = s.Take(3).OrderBy(t => t[0]).OrderByDescending(t => t.Length);

            foreach (string z in c)
            {
                Console.WriteLine(z);
            }
            Console.WriteLine();


            Console.WriteLine("Третье задание");
            Window x = new Window();
            Window y = new Window();
            User   u = new User();

            u.move += (Window a, Window b) =>
            {
                a.Move();
                b.Move();
            };
            u.Move(x, y);
        }
        public void GetLogAnalyticsSavedSearchTest()
        {
            var config            = InitConfiguration();
            var test              = config.GetSection("SuperQueue");
            var name              = test["Myname"];
            var regionDefinitions = config.GetSection("SuperQueue:QueueClients").Get <List <RegionDefinition> >();
            var goodHam           = regionDefinitions.FirstOrDefault();
            //var terminalSections = this.Configuration.GetSection("Terminals").GetChildren();
            //foreach (var item in terminalSections)
            //{
            //    terminals.Add(new Terminal
            //    {
            //        // perform type mapping here
            //    });
            //}

            SuperQueue mySuperQueue = new SuperQueue(regionDefinitions);



            var         connectionString = GetConnectionString();
            QueueClient queue            = new QueueClient(connectionString, "mystoragequeue");


            queue.CreateIfNotExists();
            queue.SendMessage("myCoolMessage");
            Assert.IsNotNull(queue);
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            Console.WriteLine("First task\n");


            SuperQueue <int> super = new SuperQueue <int>();

            super.Enqueue(1);
            super.Enqueue(2);
            super.Enqueue(3);
            //super.Enqueue(4);
            if (super.Count >= 4)
            {
                throw new Exception("Вы добавили 4-ый элемент в коллекцию");
            }
            foreach (int var in super)
            {
                Console.WriteLine(var);
            }
            Console.WriteLine("Second task\n");
            string[] array          = { "б22", "в1", "а333", "г55555", "д4444" };
            var      sortedElements = from arrElement in array.Distinct()
                                      orderby arrElement.Length
                                      select arrElement;
            IEnumerable <string> rezult1 = sortedElements.Take(3);

            Console.WriteLine("По длине");
            foreach (object var in rezult1)
            {
                Console.WriteLine(var);
            }
            var result = from user in rezult1
                         orderby user
                         select user;

            Console.WriteLine("По алф");
            foreach (object var in result)
            {
                Console.WriteLine(var);
            }
            Console.WriteLine("Third task\n");
            User   Roman   = new User();
            Window window1 = new Window(10);
            Window window2 = new Window(7);

            Roman.move += window1.change;
            Roman.move += window1.change;
            Roman.move += window2.change;
            //Roman.eventmove();
            Console.WriteLine(window1.size);
            Console.WriteLine(window2.size);
        }
        /// <summary>
        /// Escaneia uma lista de IP's em busca de respostas SNMP.
        /// Caso obtenha resposta cria um SNMPHost representando este Host.
        /// </summary>
        /// <returns>Hosts com SNMP</returns>
        private IList<SNMPHost> SNMPGetSysName(IList<IPAddress> ipList)
        {
            List<SNMPHost> foundList = new List<SNMPHost>();

            using (var q = new SuperQueue<IPAddress>(
                ThreadCount / 2, // Reduz as threads para não sobrecarregar a rede
                delegate(IPAddress ip)
                {
                    var host = new SNMPHost() { Community = Comunidade, IP = ip, Port = Porta };
                    var request = new SNMPRequest(host, SNMP_SYSNAME)
                                    {
                                        TimeOut = PingTimeout,
                                        Retries = 4,
                                        LogRequests = false // Não loga para economizar recursos
                                    };

                    try
                    {
                        request.Send();
                        if (request.ResponseValue != null)
                        {
                            Debug.WriteLine(ip);

                            // Define o nome retornado pelo SNMP
                            host.Name = request.ResponseValue.ToString();

                            // Adiciona na lista
                            lock (foundList)
                                foundList.Add(host);
                        }
                    }
                    catch { } // Ignora erros
                }))
            {
                Debug.WriteLine("Verificando protocolo SNMP");
                foreach (var ip in ipList)
                    q.EnqueueTask(ip);
            }
            return foundList;
        }
        /// <summary>
        /// Escaneia o Range de IP's informado enviando Pings.
        /// Caso obtenha resposta adiciona à lista de possíveis Hosts com SNMP.
        /// </summary>
        /// <returns>IP's que responderam ao Ping</returns>
        private IList<IPAddress> PingRange(long cur, long fin)
        {
            List<IPAddress> ipList = new List<IPAddress>();

            using (var q = new SuperQueue<IPAddress>(
                ThreadCount,
                delegate(IPAddress ip)
                {
                    var pingExec = new Ping();
                    PingReply pingReply;
                    try
                    {
                        pingReply = pingExec.Send(ip, PingTimeout);
                        if (pingReply != null && pingReply.Status == IPStatus.Success)
                        {
                            Debug.WriteLine(ip);

                            // Adiciona na lista
                            lock (ipList)
                                ipList.Add(ip);
                        }
                    }
                    catch { } // Ignora erros
                }))
            {
                Debug.WriteLine("Pingando hosts");
                while (cur <= fin)
                {
                    q.EnqueueTask(IPAddress.Parse(cur.ToString()));
                    cur++;
                }
            }
            return ipList;
        }