Пример #1
0
        private async Task <List <string> > GetChannelClientsExceptCallerAsync(ChannelRequest request, string callerConnectionId)
        {
            // TODO: Change this code. Recommended to use Clients.Group()
            var members = await _channelMemberService.GetChannelMembersAsync(request);

            var mutedMemberIds = members.Where(x => x.IsMuted)
                                 .Select(x => x.MemberId)
                                 .ToList();

            var mutedConnectionClientIds = (await _memberService.GetClientsByMemberIds(mutedMemberIds))
                                           .Select(x => x.ConnectionClientId)
                                           .ToList();

            mutedConnectionClientIds.Add(callerConnectionId);

            var clients = new List <string>();

            foreach (var item in members)
            {
                var memberClients = (await _memberService.GetMemberClientsAsync(item.MemberId))
                                    .Select(x => x.ClientConnectionId)
                                    .Except(mutedConnectionClientIds)
                                    .ToList();

                clients.AddRange(memberClients);
            }

            // TODO: clear connectionIds in database. There are about 4000 connections for only 3 users at the moment
            return(clients);
        }
Пример #2
0
        private async Task <List <string> > GetChannelClientsAsync(ChannelRequest request)
        {
            // TODO: Change this code. Recommended to use Clients.Group()
            var members = await _channelMemberService.GetChannelMembersAsync(request);

            return(await FilterClients(members, request.ClientConnectionId));
        }
Пример #3
0
        public async Task <ActionResult <GetResult> > Get([FromQuery] ChannelRequest request)
        {
            if (!await _authManager.HasContentPermissionsAsync(request.SiteId, request.ChannelId, Types.ContentPermissions.View))
            {
                return(Unauthorized());
            }

            var site = await _siteRepository.GetAsync(request.SiteId);

            if (site == null)
            {
                return(NotFound());
            }

            var channel = await _channelRepository.GetAsync(request.ChannelId);

            if (channel == null)
            {
                return(this.Error("无法确定内容对应的栏目"));
            }

            var columnsManager = new ColumnsManager(_databaseManager, _pathManager);
            var columns        = await columnsManager.GetContentListColumnsAsync(site, channel, ColumnsManager.PageType.Contents);

            var(isChecked, checkedLevel) = await CheckManager.GetUserCheckLevelAsync(_authManager, site, request.SiteId);

            var checkedLevels = CheckManager.GetCheckedLevels(site, isChecked, checkedLevel, true);

            return(new GetResult
            {
                Value = columns,
                CheckedLevels = checkedLevels,
                CheckedLevel = checkedLevel
            });
        }
Пример #4
0
        public ConnectionManager(IPEndPoint localEP, ChannelRequest requestHandler)
        {
            try
            {
                _tcpListener = new TcpListener(localEP);
                _tcpListener.Start(10);
            }
            catch
            {
                _tcpListener = new TcpListener(new IPEndPoint(localEP.Address, 0));
                _tcpListener.Start(10);
            }

            _externalSelfEP = (IPEndPoint)_tcpListener.LocalEndpoint;
            _requestHandler = requestHandler;
            _localPeerID    = BinaryID.GenerateRandomID160();

            //start accepting connections
            _tcpListenerThread = new Thread(AcceptTcpConnectionAsync);
            _tcpListenerThread.IsBackground = true;
            _tcpListenerThread.Start();

            //start upnp process
            _upnpTimer = new Timer(UPnPTimerCallback, null, 1000, Timeout.Infinite);
        }
Пример #5
0
        public IReply <TReply> SendRequest(TRequest request)
        {
            var channelRequest = new ChannelRequest(request);

            _requestChannel.Publish(channelRequest);
            return(channelRequest);
        }
Пример #6
0
        public async Task <ActionResult <GetResult> > Get([FromQuery] ChannelRequest request)
        {
            if (!await _authManager.HasContentPermissionsAsync(request.SiteId, request.ChannelId, Types.ContentPermissions.Add))
            {
                return(Unauthorized());
            }

            var site = await _siteRepository.GetAsync(request.SiteId);

            if (site == null)
            {
                return(NotFound());
            }

            var channel = await _channelRepository.GetAsync(request.ChannelId);

            if (channel == null)
            {
                return(NotFound());
            }

            var(isChecked, checkedLevel) = await CheckManager.GetUserCheckLevelAsync(_authManager, site, request.SiteId);

            var checkedLevels = CheckManager.GetCheckedLevels(site, isChecked, checkedLevel, true);

            return(new GetResult
            {
                CheckedLevel = checkedLevel,
                CheckedLevels = checkedLevels
            });
        }
Пример #7
0
        public async Task <ActionResult <GetResult> > Get([FromQuery] ChannelRequest request)
        {
            if (!await _authManager.HasSitePermissionsAsync(request.SiteId,
                                                            MenuUtils.SitePermissions.Contents) ||
                !await _authManager.HasContentPermissionsAsync(request.SiteId, request.ChannelId, MenuUtils.ContentPermissions.Add))
            {
                return(Unauthorized());
            }

            var site = await _siteRepository.GetAsync(request.SiteId);

            if (site == null)
            {
                return(NotFound());
            }

            var channelInfo = await _channelRepository.GetAsync(request.ChannelId);

            if (channelInfo == null)
            {
                return(this.Error("无法确定内容对应的栏目"));
            }

            var(isChecked, checkedLevel) = await CheckManager.GetUserCheckLevelAsync(_authManager, site, request.SiteId);

            var checkedLevels = CheckManager.GetCheckedLevels(site, isChecked, checkedLevel, false);

            return(new GetResult
            {
                CheckedLevels = checkedLevels,
                CheckedLevel = checkedLevel
            });
        }
Пример #8
0
        public async Task <ActionResult <GetResult> > Get([FromQuery] ChannelRequest request)
        {
            if (!await _authManager.HasChannelPermissionsAsync(request.SiteId, request.ChannelId, MenuUtils.ChannelPermissions.Edit))
            {
                return(Unauthorized());
            }

            var site = await _siteRepository.GetAsync(request.SiteId);

            if (site == null)
            {
                return(NotFound());
            }

            var channel = await _channelRepository.GetAsync(request.ChannelId);

            if (channel == null)
            {
                return(NotFound());
            }

            var columnsManager = new ColumnsManager(_databaseManager, _pathManager);
            var attributes     = await columnsManager.GetContentListColumnsAsync(site, channel, ColumnsManager.PageType.Contents);

            return(new GetResult
            {
                Attributes = attributes
            });
        }
Пример #9
0
        void MakeRequest(BackendTarget target, BackendAction action, HttpListenerContext context,
                         Dictionary <string, string> parameters, string response, int provider)
        {
            var evArgs = new ProviderRequestEventArgs();

            evArgs.Context    = context;
            evArgs.Parameters = parameters;
            evArgs.Action     = action;
            evArgs.Provider   = provider;

            switch (target)
            {
            case BackendTarget.Playlist:
                evArgs.Response = response;
                PlayListRequest?.Invoke(this, evArgs);
                break;

            case BackendTarget.Epg:
                evArgs.Response = response;
                EPGRequest?.Invoke(this, evArgs);
                break;

            case BackendTarget.Channel:
                evArgs.Response = response;
                ChannelRequest?.Invoke(this, evArgs);
                break;

            case BackendTarget.WebSite:
            case BackendTarget.Unknown:
            default:
                break;
            }
        }
Пример #10
0
        public async Task MuteChannelAsync(ChannelRequest request)
        {
            var channel = await UnitOfWork.ChannelRepository.GetChannelByIdAsync(request.ChannelId);

            Ensure.That(channel)
            .WithException(x => new NotFoundException(new ErrorDto(ErrorCode.NotFound, "Channel does not exist.")))
            .IsNotNull();
            var member = await UnitOfWork.MemberRepository.GetMemberBySaasUserIdAsync(request.SaasUserId);

            Ensure.That(member)
            .WithException(x => new ServiceException(new ErrorDto(ErrorCode.NotFound, "Member does not exist.")))
            .IsNotNull();
            var ifMemberExist = await UnitOfWork.ChannelRepository.CheckIfMemberExistInChannelAsync(member.Id, channel.Id);

            if (!ifMemberExist)
            {
                throw new ConflictException(new ErrorDto(ErrorCode.ConflictError, "You did not join to this channel."));
            }

            using (var transactionScope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
            {
                await UnitOfWork.ChannelMemberRepository.MuteChannelAsync(member.Id, channel.Id);

                transactionScope.Complete();
            }
        }
Пример #11
0
        public async Task CloseChannelAsync(ChannelRequest request)
        {
            try
            {
                var channel = await _channelService.GetChannelByIdAsync(request);

                var member = await _memberService.GetMemberSummaryBySaasUserIdAsync(request.SaasUserId);

                if (channel.CreatorId != member.Id && member.Role != UserRole.Admin)
                {
                    throw new Exception(String.Format(LanguageResources.RoomOwnerRequired, channel.Name));
                }
                if (channel.IsClosed)
                {
                    throw new Exception(String.Format(LanguageResources.RoomAlreadyClosed, channel.Name));
                }

                await _channelService.CloseChannelAsync(request);

                var channelSummary = await _channelService.GetChannelSummaryAsync(request);

                await _channelNotificationHub.OnCloseChannel(member, channelSummary);

                await _channelNotificationHub.OnUpdateChannel(member, channelSummary);
            }
            catch (ServiceException ex)
            {
                _logger.Event(PropertyNames.EventId).With.Message("Exception: Channel does not exist. ChannelId: {channelId}", request.ChannelId).Exception(ex).AsError();
                throw new Exception(String.Format(LanguageResources.RoomNotFound, request.ChannelId));
            }
        }
Пример #12
0
        public async Task LeaveChannelAsync(ChannelRequest request)
        {
            try
            {
                var member = await _memberService.GetMemberSummaryBySaasUserIdAsync(request.SaasUserId);

                var channel = await _channelService.GetChannelSummaryAsync(request);

                var isMemberExistInChannel = await _channelService.CheckIfMemberExistInChannelAsync(new InviteMemberRequest(request.SaasUserId, request.ChannelId, member.Id));

                if (!isMemberExistInChannel)
                {
                    throw new Exception(String.Format(LanguageResources.UserNotInRoom, member.UserName, channel.Name));
                }

                await _channelService.LeaveChannelAsync(request);

                await _channelNotificationHub.OnLeaveChannel(member, channel);
            }
            catch (NotFoundException ex)
            {
                _logger.Event(PropertyNames.EventId).With.Message("Exception: Channel does not exist. ChannelId: {channelId}", request.ChannelId).Exception(ex).AsError();
                throw new Exception(String.Format(LanguageResources.RoomNotFound, request.ChannelId));
            }
        }
Пример #13
0
        public Task <TReply> SendRequestAsync(TRequest request)
        {
            ChannelRequest channelRequest = new ChannelRequest(request);

            _requestChannel.Publish(channelRequest);
            return(channelRequest.Resp.Task);
        }
Пример #14
0
        //
        // GET: /Test/Create
        public ActionResult Create()
        {
            this.ViewBag.Tags = service.GetTagList(new TagRequest()
            {
                Top = 20, Orderby = Orderby.Hits
            });
            var model = new Article()
            {
                IsActive = true, IsProposed = true
            };
            //获取分类
            ChannelRequest request = new ChannelRequest()
            {
                ParentId = -1, IsActive = true
            };
            var result = service.GetChannelList(request);

            List <TreeNode> resultTree = new List <TreeNode>();

            this.GetChannelTree(result, resultTree, 0);
            foreach (var item in resultTree)
            {
                for (var i = 1; i <= item.level; i++)
                {
                    item.Name = "-" + item.Name;
                }
            }
            ViewBag.ChannelId = new SelectList(resultTree.AsEnumerable(), "ID", "Name");
            return(View("Edit", model));
        }
Пример #15
0
        //
        // GET: /Test/
        public ActionResult Index(ArticleRequest request)
        {
            //获取分类
            ChannelRequest channelRequest = new ChannelRequest()
            {
                ParentId = -1
            };
            var channelResult = service.GetChannelList(channelRequest);
            //这里可以改造成注入方式
            //var channelResult = this.CmsService.GetChannelList(channelRequest);

            //获取分类树
            List <TreeNode> resultTree = new List <TreeNode>();

            this.GetChannelTree(channelResult, resultTree, 0);
            if (resultTree.Count > 0)
            {
                request.ChannelIds = resultTree.Select(t => t.ID).ToList();
            }

            foreach (var item in resultTree)
            {
                for (var i = 1; i <= item.level; i++)
                {
                    item.Name = "-" + item.Name;
                }
            }

            ViewBag.ChannelId = new SelectList(resultTree.AsEnumerable(), "ID", "Name");
            var result = service.GetArticleList(request);

            return(View(result));
        }
Пример #16
0
        public async Task Step4_ShouldCloseChannel()
        {
            // Arrange
            var channelRequest = new ChannelRequest
            {
                RequestId = "623AE57B-9917-4DED-BFFC-44F09C906F10",
                ChannelId = _testChannel.Id
            };

            // Subscribe event
            ChannelSummaryResponse channelSummaryResponse = null;

            void OnChannelClosed(ChannelSummaryResponse response)
            {
                channelSummaryResponse = response;
            }

            _userSignalRClient.ChannelClosed += OnChannelClosed;

            // Act
            await _adminSignalRClient.CloseChannelAsync(channelRequest);

            // Unsubscribe events
            _userSignalRClient.ChannelClosed -= OnChannelClosed;

            // Assert
            channelSummaryResponse.IsClosed.Should().BeTrue();
        }
Пример #17
0
        private void HandleSpecificPacket(ChannelRequest packet)
        {
            logger.LogDebug("Processing ChannelRequest packet, channel {Channel}, request type '{Type}', want reply {Want}.", packet.RecipientChannel,
                            packet.RequestType, packet.WantReply);

            DispatchToChannel(packet, packet.RecipientChannel);
        }
Пример #18
0
        internal void CurrentPubnubInstance(Pubnub instance)
        {
            PubnubInstance = instance;

            if (!MultiChannelSubscribe.ContainsKey(instance.InstanceId))
            {
                MultiChannelSubscribe.GetOrAdd(instance.InstanceId, new ConcurrentDictionary <string, long>());
            }
            if (!MultiChannelGroupSubscribe.ContainsKey(instance.InstanceId))
            {
                MultiChannelGroupSubscribe.GetOrAdd(instance.InstanceId, new ConcurrentDictionary <string, long>());
            }
            if (!ChannelRequest.ContainsKey(instance.InstanceId))
            {
                ChannelRequest.GetOrAdd(instance.InstanceId, new ConcurrentDictionary <string, HttpWebRequest>());
            }
            if (!ChannelInternetStatus.ContainsKey(instance.InstanceId))
            {
                ChannelInternetStatus.GetOrAdd(instance.InstanceId, new ConcurrentDictionary <string, bool>());
            }
            if (!ChannelGroupInternetStatus.ContainsKey(instance.InstanceId))
            {
                ChannelGroupInternetStatus.GetOrAdd(instance.InstanceId, new ConcurrentDictionary <string, bool>());
            }
        }
Пример #19
0
        public async Task <ActionResult <NameTitle> > Upload([FromQuery] ChannelRequest request, [FromForm] IFormFile file)
        {
            if (!await _authManager.HasSitePermissionsAsync(request.SiteId,
                                                            Types.SitePermissions.Contents) ||
                !await _authManager.HasContentPermissionsAsync(request.SiteId, request.ChannelId, Types.ContentPermissions.Add))
            {
                return(Unauthorized());
            }

            if (file == null)
            {
                return(this.Error("请选择有效的文件上传"));
            }

            var title      = PathUtils.GetFileNameWithoutExtension(file.FileName);
            var fileName   = PathUtils.GetUploadFileName(file.FileName, true);
            var extendName = PathUtils.GetExtension(fileName);

            if (!FileUtils.IsWord(extendName))
            {
                return(this.Error("文件只能是 Word 格式,请选择有效的文件上传!"));
            }

            var filePath = _pathManager.GetTemporaryFilesPath(fileName);
            await _pathManager.UploadAsync(file, filePath);

            return(new NameTitle
            {
                FileName = fileName,
                Title = title
            });
        }
Пример #20
0
 internal void CurrentPubnubInstance(Pubnub instance)
 {
     PubnubInstance = instance;
     if (!MultiChannelSubscribe.ContainsKey(instance.InstanceId))
     {
         MultiChannelSubscribe.GetOrAdd(instance.InstanceId, new ConcurrentDictionary <string, long>());
     }
     if (!MultiChannelGroupSubscribe.ContainsKey(instance.InstanceId))
     {
         MultiChannelGroupSubscribe.GetOrAdd(instance.InstanceId, new ConcurrentDictionary <string, long>());
     }
     if (!ChannelRequest.ContainsKey(instance.InstanceId))
     {
         ChannelRequest.GetOrAdd(instance.InstanceId, new ConcurrentDictionary <string, HttpWebRequest>());
     }
     if (!ChannelInternetStatus.ContainsKey(instance.InstanceId))
     {
         ChannelInternetStatus.GetOrAdd(instance.InstanceId, new ConcurrentDictionary <string, bool>());
     }
     if (!ChannelGroupInternetStatus.ContainsKey(instance.InstanceId))
     {
         ChannelGroupInternetStatus.GetOrAdd(instance.InstanceId, new ConcurrentDictionary <string, bool>());
     }
     if (!ChannelLocalUserState.ContainsKey(instance.InstanceId))
     {
         ChannelLocalUserState.GetOrAdd(instance.InstanceId, new ConcurrentDictionary <string, Dictionary <string, object> >());
     }
     if (!ChannelGroupLocalUserState.ContainsKey(instance.InstanceId))
     {
         ChannelGroupLocalUserState.GetOrAdd(instance.InstanceId, new ConcurrentDictionary <string, Dictionary <string, object> >());
     }
     if (!ChannelUserState.ContainsKey(instance.InstanceId))
     {
         ChannelUserState.GetOrAdd(instance.InstanceId, new ConcurrentDictionary <string, Dictionary <string, object> >());
     }
     if (!ChannelGroupUserState.ContainsKey(instance.InstanceId))
     {
         ChannelGroupUserState.GetOrAdd(instance.InstanceId, new ConcurrentDictionary <string, Dictionary <string, object> >());
     }
     if (!ChannelReconnectTimer.ContainsKey(instance.InstanceId))
     {
         ChannelReconnectTimer.GetOrAdd(instance.InstanceId, new ConcurrentDictionary <string, Timer>());
     }
     if (!ChannelGroupReconnectTimer.ContainsKey(instance.InstanceId))
     {
         ChannelGroupReconnectTimer.GetOrAdd(instance.InstanceId, new ConcurrentDictionary <string, Timer>());
     }
     if (!SubscribeDisconnected.ContainsKey(instance.InstanceId))
     {
         SubscribeDisconnected.GetOrAdd(instance.InstanceId, false);
     }
     if (!LastSubscribeTimetoken.ContainsKey(instance.InstanceId))
     {
         LastSubscribeTimetoken.GetOrAdd(instance.InstanceId, 0);
     }
     if (!SubscribeRequestTracker.ContainsKey(instance.InstanceId))
     {
         SubscribeRequestTracker.GetOrAdd(instance.InstanceId, DateTime.Now);
     }
 }
Пример #21
0
        public async Task <ActionResult <GetResult> > Get([FromQuery] ChannelRequest request)
        {
            if (!await _authManager.HasSitePermissionsAsync(request.SiteId,
                                                            MenuUtils.SitePermissions.Contents) ||
                !await _authManager.HasContentPermissionsAsync(request.SiteId, request.ChannelId,
                                                               MenuUtils.ContentPermissions.Add, MenuUtils.ContentPermissions.Edit))
            {
                return(Unauthorized());
            }

            var site = await _siteRepository.GetAsync(request.SiteId);

            if (site == null)
            {
                return(NotFound());
            }

            var siteIdList = await _authManager.GetSiteIdsAsync();

            var transSites = await _siteRepository.GetSelectsAsync(siteIdList);

            return(new GetResult
            {
                TransSites = transSites
            });
        }
Пример #22
0
        public IEnumerable <Channel> GetChannelList(ChannelRequest request = null)
        {
            request = request ?? new ChannelRequest();
            using (var dbContext = new CmsDbContext())
            {
                IQueryable <Channel> channels = dbContext.Channels;
                //频道名称
                if (!string.IsNullOrWhiteSpace(request.Name))
                {
                    channels = channels.Where(u => u.Name.Contains(request.Name));
                }
                //频道ID
                if (request.ID > 0)
                {
                    channels = channels.Where(t => t.ID == request.ID);
                }
                //父类ID
                if (request.ParentId >= 0)
                {
                    channels = channels.Where(t => t.ParentId == request.ParentId);
                }
                //状态
                if (request.IsActive != null)
                {
                    channels = channels.Where(u => u.IsActive == request.IsActive);
                }

                return(channels.OrderBy(u => u.Flag).ToList());
            }
        }
        public async Task <ActionResult <StringResult> > Export([FromBody] ChannelRequest request)
        {
            if (!await _authManager.HasSitePermissionsAsync(request.SiteId,
                                                            Types.SitePermissions.SettingsStyleContent))
            {
                return(Unauthorized());
            }

            var site = await _siteRepository.GetAsync(request.SiteId);

            if (site == null)
            {
                return(NotFound());
            }

            var channel = await _channelRepository.GetAsync(request.ChannelId);

            var tableName = _channelRepository.GetTableName(site, channel);

            var fileName =
                await ExportObject.ExportRootSingleTableStyleAsync(_pathManager, _databaseManager, request.SiteId, tableName,
                                                                   _tableStyleRepository.GetRelatedIdentities(channel));

            var filePath    = _pathManager.GetTemporaryFilesPath(fileName);
            var downloadUrl = _pathManager.GetRootUrlByPath(filePath);

            return(new StringResult
            {
                Value = downloadUrl
            });
        }
Пример #24
0
        internal void CurrentPubnubInstance(Pubnub instance)
        {
            PubnubInstance = instance;

            if (!ChannelRequest.ContainsKey(instance.InstanceId))
            {
                ChannelRequest.GetOrAdd(instance.InstanceId, new ConcurrentDictionary <string, HttpWebRequest>());
            }
            if (!ChannelInternetStatus.ContainsKey(instance.InstanceId))
            {
                ChannelInternetStatus.GetOrAdd(instance.InstanceId, new ConcurrentDictionary <string, bool>());
            }
            if (!ChannelGroupInternetStatus.ContainsKey(instance.InstanceId))
            {
                ChannelGroupInternetStatus.GetOrAdd(instance.InstanceId, new ConcurrentDictionary <string, bool>());
            }
            if (!ChannelUserState.ContainsKey(instance.InstanceId))
            {
                ChannelUserState.GetOrAdd(instance.InstanceId, new ConcurrentDictionary <string, Dictionary <string, object> >());
            }
            if (!ChannelGroupUserState.ContainsKey(instance.InstanceId))
            {
                ChannelGroupUserState.GetOrAdd(instance.InstanceId, new ConcurrentDictionary <string, Dictionary <string, object> >());
            }
            if (!ChannelLocalUserState.ContainsKey(instance.InstanceId))
            {
                ChannelLocalUserState.GetOrAdd(instance.InstanceId, new ConcurrentDictionary <string, Dictionary <string, object> >());
            }
            if (!ChannelGroupLocalUserState.ContainsKey(instance.InstanceId))
            {
                ChannelGroupLocalUserState.GetOrAdd(instance.InstanceId, new ConcurrentDictionary <string, Dictionary <string, object> >());
            }
        }
        public override SignalStatus SendToChannel(ChannelDbRecord channel, SignalDbRecord signal)
        {
            SignalStatus status = new SignalStatus
            {
                ChannelType = channel.Type,
                Code        = StatusCode.Success,
                Message     = "Success"
            };

            try
            {
                String lambdaName = $"{Config.ChannelPublisherPrefix}-{channel.Type}";
                Logger.Info($"Sending Signal To {channel.Type} - {channel.Name} ({lambdaName})");

                ChannelRequest request = new ChannelRequest
                {
                    Id      = signal.Id,
                    Signal  = signal.Signal,
                    Channel = channel
                };
                string requestStr = JsonTools.Serialize(request);
                Logger.Info(requestStr);
                InvokeResponse response = AWSUtilities.CallLambdaMethod(Client, lambdaName, requestStr);
            }
            catch (Exception e)
            {
                status.Code    = StatusCode.Failure;
                status.Message = e.Message;
            }

            return(status);
        }
Пример #26
0
        public async Task <ActionResult <GetResult> > Get([FromQuery] ChannelRequest request)
        {
            if (!await _authManager.HasContentPermissionsAsync(request.SiteId, request.ChannelId, Types.ContentPermissions.Delete))
            {
                return(Unauthorized());
            }

            var site = await _siteRepository.GetAsync(request.SiteId);

            if (site == null)
            {
                return(NotFound());
            }

            var channel = await _channelRepository.GetAsync(request.ChannelId);

            if (channel == null)
            {
                return(NotFound());
            }

            var contentGroupNameList = await _contentGroupRepository.GetGroupNamesAsync(request.SiteId);

            return(new GetResult
            {
                GroupNames = contentGroupNameList
            });
        }
Пример #27
0
        public ConnectionManager(IPEndPoint localEP, ChannelRequest requestHandler)
        {
            try
            {
                _tcpListener = new TcpListener(localEP);
                _tcpListener.Start(10);
            }
            catch
            {
                _tcpListener = new TcpListener(new IPEndPoint(localEP.Address, 0));
                _tcpListener.Start(10);
            }

            _externalSelfEP = (IPEndPoint)_tcpListener.LocalEndpoint;
            _requestHandler = requestHandler;
            _localPeerID = BinaryID.GenerateRandomID160();

            //start accepting connections
            _tcpListenerThread = new Thread(AcceptTcpConnectionAsync);
            _tcpListenerThread.IsBackground = true;
            _tcpListenerThread.Start();

            //start upnp process
            _upnpTimer = new Timer(UPnPTimerCallback, null, 1000, Timeout.Infinite);
        }
Пример #28
0
        //
        // GET: /Test/Edit/5
        public ActionResult Edit(int id)
        {
            var model  = service.GetArticle(id);
            var cmodel = service.GetChannel(model.ChannelId);
            //获取分类
            ChannelRequest request = new ChannelRequest()
            {
                ParentId = -1
            };
            var result = service.GetChannelList(request);

            List <TreeNode> resultTree = new List <TreeNode>();

            this.GetChannelTree(result, resultTree, 0);
            foreach (var item in resultTree)
            {
                for (var i = 1; i <= item.level; i++)
                {
                    item.Name = "-" + item.Name;
                }
            }
            ViewBag.ChannelId = new SelectList(resultTree.AsEnumerable(), "ID", "Name", cmodel.ID.ToString());
            this.ViewBag.Tags = service.GetTagList(new TagRequest()
            {
                Top = 20, Orderby = Orderby.Hits
            });

            return(View(model));
        }
Пример #29
0
        public void CanCreateKnownSubsystem(string name, bool known)
        {
            // Arrange
            var request = new ChannelRequest
            {
                RequestType   = "subsystem",
                SubsystemName = name,
                WantReply     = true    // TODO - add test for WantReply = false; RFC only recommends true
            };

            // Act
            channel.HandlePacket(request);

            // Assert
            packets.Should().HaveCount(1);

            if (known)
            {
                channel.SubsystemName.Should().Be(name);

                packets[0].Should().BeOfType <ChannelSuccess>();
            }
            else
            {
                channel.SubsystemName.Should().BeNull();

                packets[0].Should().BeOfType <ChannelFailure>();
            }
        }
Пример #30
0
 public Connection(Stream baseStream, BinaryID remotePeerID, IPEndPoint remotePeerEP, ConnectionManager connectionManager, ChannelRequest requestHandler)
 {
     _baseStream        = baseStream;
     _remotePeerID      = remotePeerID;
     _remotePeerEP      = remotePeerEP;
     _connectionManager = connectionManager;
     _requestHandler    = requestHandler;
 }
Пример #31
0
 public async Task LeaveChannelAsync(ChannelRequest request)
 {
     await ValidateAndExecuteAsync(request, new ChannelRequestValidator(), new TaskReference(async() =>
     {
         var closeChannelRequest = new DomainRequest.Channel.ChannelRequest(Context.GetSaasUserId(), request.ChannelId);
         await _channelSocketService.LeaveChannelAsync(closeChannelRequest);
     }),
                                   request.RequestId);
 }
Пример #32
0
        //
        // GET: /Cms/Channel/

        public ActionResult Index(ChannelRequest request)
        {
            var result = this.CmsService.GetChannelList(request);
            return View(result);
        }
Пример #33
0
 public void RetrieveStatusOfHost(string nick, Channel channel, string source)
 {
     lock (requests)
     {
         ChannelRequest rq = new ChannelRequest(nick, source, channel, false) {hostname_check = true};
         requests.Add(rq);
     }
 }
Пример #34
0
        public IEnumerable<Channel> GetChannelList(ChannelRequest request = null)
        {
            request = request ?? new ChannelRequest();
            using (var dbContext = new CmsDbContext())
            {
                IQueryable<Channel> channels = dbContext.Channels;

                if (!string.IsNullOrEmpty(request.Name))
                    channels = channels.Where(u => u.Name.Contains(request.Name));

                if (request.IsActive != null)
                    channels = channels.Where(u => u.IsActive == request.IsActive);

                return channels.OrderByDescending(u => u.ID).ToPagedList(request.PageIndex, request.PageSize);
            }
        }
Пример #35
0
 public Connection(Stream baseStream, BinaryID remotePeerID, IPEndPoint remotePeerEP, ConnectionManager connectionManager, ChannelRequest requestHandler)
 {
     _baseStream = baseStream;
     _remotePeerID = remotePeerID;
     _remotePeerEP = remotePeerEP;
     _connectionManager = connectionManager;
     _requestHandler = requestHandler;
 }