Inheritance: AObject
コード例 #1
0
 public Model.Domain.Result LoadByGuid(Guid aGuid, bool aShowOfflineBots, int aCount, int aPage, string aSortBy, string aSort)
 {
     XG.Model.Domain.Search search;
     if (aGuid == XG.Model.Domain.Search.SearchEnabled)
     {
         search = new XG.Model.Domain.Search {
             Guid = aGuid
         };
     }
     else if (aGuid == XG.Model.Domain.Search.SearchDownloads)
     {
         search = new XG.Model.Domain.Search {
             Guid = aGuid
         };
     }
     else
     {
         search = Helper.Searches.All.SingleOrDefault(s => s.Guid == aGuid);
     }
     if (search != null)
     {
         return(LoadBySearch(search, aShowOfflineBots, aCount, aPage, aSortBy, aSort));
     }
     return(new Model.Domain.Result {
         Total = 0, Results = new List <Packet>()
     });
 }
コード例 #2
0
ファイル: SearchHub.cs プロジェクト: scottc/xdcc-grabscher
 public void Add(string aSearch)
 {
     var obj = Helper.Searches.Named(aSearch);
     if (obj == null)
     {
         obj = new Search { Name = aSearch };
         Helper.Searches.Add(obj);
     }
 }
コード例 #3
0
ファイル: SearchHub.cs プロジェクト: lformella/xdcc-grabscher
 public void Add(string aSearch, Int64 aSize)
 {
     var obj = Helper.Searches.WithParameters(aSearch, aSize);
     if (obj == null)
     {
         obj = new XG.Model.Domain.Search { Name = aSearch, Size = aSize };
         Helper.Searches.Add(obj);
     }
 }
コード例 #4
0
        public void Add(string aSearch, Int64 aSize)
        {
            var obj = Helper.Searches.WithParameters(aSearch, aSize);

            if (obj == null)
            {
                obj = new XG.Model.Domain.Search {
                    Name = aSearch, Size = aSize
                };
                Helper.Searches.Add(obj);
            }
        }
コード例 #5
0
        Model.Domain.Result LoadBySearch(XG.Model.Domain.Search aSearch, bool aShowOfflineBots, int aCount, int aPage, string aSortBy, string aSort)
        {
            var results = Webserver.Search.Packets.GetResults(aSearch, aShowOfflineBots, (aPage - 1) * aCount, aCount, aSortBy, aSort == "desc");
            List <Model.Domain.Packet> all = new List <XG.Plugin.Webserver.SignalR.Hub.Model.Domain.Packet>();

            foreach (var term in results.Packets.Keys)
            {
                var objects = Helper.XgObjectsToHubObjects(results.Packets[term]).Cast <Model.Domain.Packet>();
                objects.ToList().ForEach(p => p.GroupBy = term);
                all.AddRange(objects);
            }
            UpdateLoadedClientObjects(Context.ConnectionId, new HashSet <Guid>(all.Select(o => o.Guid)), aCount);
            return(new Model.Domain.Result {
                Total = results.Total, Results = all
            });
        }
コード例 #6
0
ファイル: PacketHub.cs プロジェクト: scottc/xdcc-grabscher
 public Model.Domain.Result LoadByGuid(Guid aGuid, bool aShowOfflineBots, int aCount, int aPage, string aSortBy, string aSort)
 {
     var search = Helper.Searches.All.SingleOrDefault(s => s.Guid == aGuid);
     if (search == null)
     {
         if (aGuid == Search.SearchEnabled)
         {
             search = new Search { Guid = Search.SearchEnabled };
         }
         else if (aGuid == Search.SearchDownloads)
         {
             search = new Search { Guid = Search.SearchDownloads };
         }
     }
     if (search != null)
     {
         return LoadBySearch(search, aShowOfflineBots, aCount, aPage, aSortBy, aSort);
     }
     return new Model.Domain.Result { Total = 0, Results = new List<Packet>() };
 }
コード例 #7
0
ファイル: Dao.cs プロジェクト: scottc/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;
            }
        }
コード例 #8
0
ファイル: PacketHub.cs プロジェクト: scottc/xdcc-grabscher
 Model.Domain.Result LoadBySearch(Search aSearch, bool aShowOfflineBots, int aCount, int aPage, string aSortBy, string aSort)
 {
     var packets = (from server in Helper.Servers.All from channel in server.Channels from bot in channel.Bots where (aShowOfflineBots || bot.Connected) from packet in bot.Packets where aSearch.IsVisible(packet) select packet);
     int length;
     var objects = FilterAndLoadObjects<Model.Domain.Packet>(packets, aCount, aPage, aSortBy, aSort, out length);
     UpdateLoadedClientObjects(Context.ConnectionId, new HashSet<Guid>(objects.Select(o => o.Guid)), aCount);
     return new Model.Domain.Result { Total = length, Results = objects };
 }
コード例 #9
0
ファイル: Searches.cs プロジェクト: lformella/xdcc-grabscher
 public bool Remove(Search aObject)
 {
     return base.Remove(aObject);
 }
コード例 #10
0
ファイル: Searches.cs プロジェクト: lformella/xdcc-grabscher
 public bool Add(Search aObject)
 {
     return base.Add(aObject);
 }