コード例 #1
0
        public Packets()
        {
            var servers = new Servers();

            var server = new Server
            {
                Name = "test.bitpir.at"
            };

            servers.Add(server);

            var channel = new Channel
            {
                Name = "#test"
            };

            server.AddChannel(channel);

            channel.AddBot(bot1);
            channel.AddBot(bot2);

            bot1.AddPacket(CreatePacket(1, "Under.the.Dome.s01e01.mkv", 101));
            bot1.AddPacket(CreatePacket(2, "Under.the.Dome.s01e02.mkv", 102));
            bot1.AddPacket(CreatePacket(3, "Under.the.Dome.s01e03.mkv", 103));
            bot1.AddPacket(CreatePacket(4, "Under.the.Dome.s01e04.mkv", 104));

            bot2.AddPacket(CreatePacket(1, "Under.the.Dome.s01e01.mkv", 201));
            bot2.AddPacket(CreatePacket(2, "Under.the.Dome.s01e02.mkv", 202));
            bot2.AddPacket(CreatePacket(3, "Under.the.Dome.s01e03.mkv", 203));
            bot2.AddPacket(CreatePacket(4, "Under.the.Dome.s01e04.mkv", 204));
            bot2.AddPacket(CreatePacket(5, "Ander.the.Dome.s01e05.mkv", 205));

            XG.Plugin.Webserver.Search.Packets.Servers = servers;
            XG.Plugin.Webserver.Search.Packets.Initialize();
        }
コード例 #2
0
        Bot createBot(String aName)
        {
            var bot = new Bot {
                Name = aName
            };

            for (int a = 1; a <= count; a++)
            {
                bot.AddPacket(createPacket(a));
            }
            bot.Packet(count).Id = fakeId;
            return(bot);
        }
コード例 #3
0
        void LoadPackets(Bot bot)
        {
            Log.Info("Load() packets from " + bot);
            DbCommand command = GetCommand();

            command.CommandText = "SELECT * FROM Packet WHERE ParentGuid = '" + bot.Guid + "';";
            var reader = command.ExecuteReader();

            while (reader.Read())
            {
                var packet = CreatePacket(reader);
                bot.AddPacket(packet);
            }
        }
コード例 #4
0
        protected AParser()
        {
            Server = new Server
            {
                Name = "test.bitpir.at"
            };

            Channel = new Channel
            {
                Name = "#test"
            };
            Server.AddChannel(Channel);

            Bot = new Bot
            {
                Name = "[XG]TestBot"
            };
            Channel.AddBot(Bot);

            Packet = new Packet
            {
                Name     = "Testfile.with.a.long.name.mkv",
                RealName = "Testfile.with.a.long.name.mkv",
                Id       = 1,
                Enabled  = true,
                RealSize = 975304559
            };
            Bot.AddPacket(Packet);

            Connection        = new XG.Plugin.Irc.IrcConnection();
            Connection.Server = Server;

            FileActions.Files = new Files();
            File = new File("Testfile.with.a.long.name.mkv", 975304559);
            FileActions.Files.Add(File);
        }
コード例 #5
0
ファイル: Dao.cs プロジェクト: savefromgoogle/xdcc-grabscher
        public void DaoWriteObjectsTest()
        {
            var dao = new XG.DB.Dao();

            dao.Scheduler = new StdSchedulerFactory().GetScheduler();
            dao.Start("Dao");

            var files = dao.Files;

            for (int a = 0; a < _count; a++)
            {
                var file = new File("test" + a, 1000000 * (a + 1));
                file.CurrentSize = 700000 * (a + 1);
                files.Add(file);
            }

            var servers = dao.Servers;

            for (int a = 1; a < _count; a++)
            {
                var server = new Server
                {
                    Connected = _random.Next(1, 3) == 1,
                    Name      = "irc.test.com" + a,
                    Port      = 6666 + a
                };

                for (int b = 1; b < _count; b++)
                {
                    var channel = new Channel
                    {
                        Connected = _random.Next(1, 3) == 1,
                        Name      = "#test" + a + "-" + b
                    };

                    for (int c = 1; c < _count; c++)
                    {
                        var bot = new Bot
                        {
                            Name               = "Bot " + a + "-" + b + "-" + c,
                            InfoSpeedCurrent   = _random.Next(100000, 1000000),
                            InfoSpeedMax       = _random.Next(1000000, 10000000),
                            InfoSlotCurrent    = _random.Next(1, 10),
                            InfoSlotTotal      = _random.Next(10, 100),
                            InfoQueueCurrent   = _random.Next(1, 10),
                            InfoQueueTotal     = _random.Next(10, 1000),
                            HasNetworkProblems = _random.Next(1, 10) > 7,
                            LastMessage        = "This is a test message that should be long enough for the most of the table and cell width test cases which are there for testing purposes.",
                            LastMessageTime    = DateTime.Now.AddMinutes(_random.Next(10000, 100000))
                        };

                        int rand = _random.Next(1, 4);
                        if (rand == 1)
                        {
                            bot.Connected          = true;
                            bot.State              = Bot.States.Active;
                            bot.HasNetworkProblems = false;
                        }
                        else if (rand == 2)
                        {
                            bot.Connected = _random.Next(1, 3) == 1;
                            bot.State     = Bot.States.Idle;
                        }
                        else if (rand == 3)
                        {
                            bot.Connected     = true;
                            bot.State         = Bot.States.Waiting;
                            bot.QueueTime     = _random.Next(10, 100);
                            bot.QueuePosition = _random.Next(1, 10);
                        }

                        for (int d = 1; d < _count; d++)
                        {
                            var ending = new string[] { "rar", "mkv", "mp3", "tar", "avi", "wav", "jpg", "bmp" };

                            var packet = new Packet
                            {
                                Name          = "Pack " + a + "-" + b + "-" + c + "-" + d + "." + ending[_random.Next(0, ending.Length)],
                                Id            = a + b + c + d,
                                Size          = _random.Next(1000000, 10000000),
                                LastUpdated   = DateTime.Now.AddDays(_random.Next(1, 10) * -1),
                                LastMentioned = DateTime.Now.AddDays(_random.Next(10, 100) * -1)
                            };

                            if (d == 1)
                            {
                                if (bot.State == Bot.States.Active)
                                {
                                    packet.Enabled   = true;
                                    packet.Connected = true;
                                }
                                else if (bot.State == Bot.States.Waiting)
                                {
                                    packet.Enabled = true;
                                }
                            }
                            else if (d == 2)
                            {
                                if (bot.State == Bot.States.Waiting)
                                {
                                    packet.Enabled = true;
                                }
                            }

                            bot.AddPacket(packet);
                        }

                        channel.AddBot(bot);
                    }

                    server.AddChannel(channel);
                }

                servers.Add(server);

                var channelToDrop = server.Channels.First();
                server.RemoveChannel(channelToDrop);
            }

            var searches = dao.Searches;

            for (int a = 0; a < _count; a++)
            {
                var search = new Search
                {
                    Name = "test" + _random.Next(1000, 10000)
                };

                searches.Add(search);

                search.Name = "Pack " + a;
            }
        }