Example #1
0
        public List <Network> GetByUser(int userId, NetworkFilter filter = null)
        {
            var userNetworks = _mongo.UserNetworks.Find(Query <UserNetwork> .EQ(e => e.UserID, userId));
            var networkIds   = userNetworks.Select(e => e.NetworkID).Distinct().ToArray();

            return(_mongo.Networks.AsQueryable().Where(e => networkIds.Contains(e.ID)).Filter(filter).ToList());
        }
Example #2
0
 public List <Network> GetAll(NetworkFilter filter = null)
 {
     using (var context = new DeviceHiveContext())
     {
         return(context.Networks.Filter(filter).ToList());
     }
 }
Example #3
0
 public List <Network> GetByUser(int userId, NetworkFilter filter = null)
 {
     using (var context = new DeviceHiveContext())
     {
         return(context.Networks.Where(n => context.UserNetworks
                                       .Where(un => un.UserID == userId).Select(un => un.NetworkID).Contains(n.ID))
                .Filter(filter).ToList());
     }
 }
Example #4
0
        public static IQueryable <Network> Filter(this IQueryable <Network> query, NetworkFilter filter)
        {
            if (filter == null)
            {
                return(query);
            }

            if (filter.Name != null)
            {
                query = query.Where(e => e.Name == filter.Name);
            }

            if (filter.NamePattern != null)
            {
                query = query.Where(e => e.Name.Contains(filter.NamePattern));
            }

            if (filter.SortField != NetworkSortField.None)
            {
                switch (filter.SortField)
                {
                case NetworkSortField.ID:
                    query = query.OrderBy(e => e.ID, filter.SortOrder);
                    break;

                case NetworkSortField.Name:
                    query = query.OrderBy(e => e.Name, filter.SortOrder);
                    break;
                }
            }

            if (filter.Skip != null)
            {
                query = query.Skip(filter.Skip.Value);
            }

            if (filter.Take != null)
            {
                query = query.Take(filter.Take.Value);
            }

            return(query);
        }
Example #5
0
 public List <Network> GetAll(NetworkFilter filter = null)
 {
     return(_mongo.Networks.AsQueryable().Filter(filter).ToList());
 }
    /// <summary>
    /// Sends the message to all clients that meet the filters criteria.
    /// Messages sent in this way cannot be buffered into a queue
    /// </summary>
    /// <param name="_writer"></param>
    /// <param name="channelType"></param>
    /// <param name="addToBuffer"> add this message to the buffer</param>
    /// <returns>The Buffered Message if one was added.</returns>
    public static void SendMessageToFilteredClients(NetWriter _writer, int channelType, NetworkFilter filter)
    {
        writer.StopWriting();
        if (!NetworkCore.isServer)
        {
            Debug.LogError("Tried to send message to filtered clients, but we are not a server!");
            return;
        }
        int writtenSize = _writer.GetWrittenBytes();

        byte[] rawData = _writer.GetRawData();
        NetworkCore.singleton.SendRawToFilteredClients(channelType, rawData, writtenSize, filter);
    }
Example #7
0
    internal void SendRawToFilteredClients(int channelType, byte[] buffer, int bufferSize, NetworkFilter filter)
    {
        if (!isServer)
        {
            Debug.LogWarning("Tried to send to a client, but no server socket exists!");
            return;
        }
        for (int i = 0; i < connections.Length; i++)
        {
            if (connections[i] == null)
            {
                continue;       // skip null clients
            }
            if (!connections[i].active)
            {
                continue;       // skip inactive connections
            }
            if (!filter.CheckConnection(connections[i].connectionId))
            {
                continue;       // filter out bad connections
            }

            NetworkTransport.Send(serverHostId, connections[i].connectionId, channelType, buffer, bufferSize, out err);
        }
        CheckNetworkError();
    }