private bool PushToSftp(FeedSettings account, byte[] xmlfile)
        {
            try
            {
                var authMethod = new PasswordAuthenticationMethod(account.UserName, account.Password);

                var connectionInfo = new ConnectionInfo(account.Url, 22, account.UserName, authMethod);
                using (var bazaarVoiceSftp = new SftpClient(connectionInfo))
                {
                    using (var stream = new MemoryStream(xmlfile, 0, xmlfile.Length))
                    {
                        _log.Info("Export -- XML Document -- Saving -- SFTP -- Connecting");
                        bazaarVoiceSftp.Connect();
                        _log.Info("Export -- XML Document -- Saving -- SFTP -- Uploading");
                        bazaarVoiceSftp.UploadFile(stream, account.FolderPath + account.FileName);
                        bazaarVoiceSftp.Disconnect();
                        return(true);
                    }
                }
            }

            catch (Exception ex)
            {
                _log.Info("Export -- XML Document -- Saving -- SFTP -- Connection Failed with exception message of -- " + ex.Message);
                return(false);
            }
        }
        private RabbitMqSubscriber <TMessage> CreateSubscriber <TMessage>(FeedSettings settings, Func <TMessage, Task> handler)
        {
            if (settings.RabbitMqConnectionString == null || settings.RabbitMqConnectionString == "" || settings.RabbitMqConnectionString == "null")
            {
                return(null);
            }

            var subscriptionSettings = new RabbitMqSubscriptionSettings
            {
                ConnectionString = settings.RabbitMqConnectionString,
                ExchangeName     = settings.RabbitMqExchangeName,
                QueueName        = settings.RabbitMqQueueName,
                IsDurable        = false
            };

            var subscriber = new RabbitMqSubscriber <TMessage>(subscriptionSettings,
                                                               new DefaultErrorHandlingStrategy(_logger, subscriptionSettings))
                             .SetMessageDeserializer(new ErrorLoggingJsonMessageDeserializer <TMessage>(_logger))
                             .SetMessageReadStrategy(new MessageReadWithTemporaryQueueStrategy())
                             .SetLogger(_logger)
                             .Subscribe(handler)
                             .Start();

            return(subscriber);
        }
Beispiel #3
0
        void btnSettings_Click(object sender, EventArgs e)
        {
            btnSettings_MouseUp(sender, null);
            FeedSettings settings = new FeedSettings();

            settings.setDetectorSettings(_motionDetector.detectionMethod, _motionDetector.detectionType,
                                         _motionDetector.detecionSpeed, _motionDetector.detectionSensitivity);
            settings.setFeedSettings(feedName, sourceAddress, isEntrance, robustChecking);
            settings.background   = (Bitmap)curFrame.Clone();
            settings.resultRegion = _motionDetector.detectionArea;

            if (settings.ShowDialog() == DialogResult.OK)
            {
                this.feedName = settings.feedName;
                setFeedName(feedName);
                this.isEntrance     = settings.isEntrance;
                this.robustChecking = settings.robustChecking;
                _motionDetector.updateMotionDetectorDetails(settings.resultRegion, settings.processor, settings.detector, settings.speed, settings.sensitivity);
                //loadVideo(sourceAddress);
                //startVideo();
                if (!sourceAddress.Equals(settings.feedURL))
                {
                    //must restart camera
                    this.sourceAddress = settings.feedURL;
                    loadVideo(sourceAddress);
                    startVideo();
                }
            }
        }
Beispiel #4
0
 public ApiKeysModel(ILogger <ApiKeysModel> logger, FeedContext dbContext, FeedSettings settings)
 {
     _logger    = logger;
     _dbContext = dbContext;
     _siteName  = settings.ServerName;
     AuthKeys   = Array.Empty <AuthToken>();
 }
Beispiel #5
0
        public async Task SubFeed_InitTwoFeedsDestroyOneVerifyFirst()
        {
            using (var target = new TestFolder())
                using (var cache = new LocalCache())
                    using (var cache2 = new LocalCache())
                    {
                        var log          = new TestLogger();
                        var settings     = new LocalSettings();
                        var feedSettings = new FeedSettings();
                        var rootFeedA    = UriUtility.CreateUri(target.Root, "feedA");
                        var rootFeedB    = UriUtility.CreateUri(target.Root, "feedB");
                        var fileSystem   = new PhysicalFileSystem(cache, rootFeedA, rootFeedA, feedSubPath: "feedA");
                        var fileSystem2  = new PhysicalFileSystem(cache2, rootFeedB, rootFeedB, feedSubPath: "feedB");

                        // Init feeds
                        var success = await InitCommand.InitAsync(settings, fileSystem, feedSettings, log, CancellationToken.None);

                        success &= await InitCommand.InitAsync(settings, fileSystem2, feedSettings, log, CancellationToken.None);

                        // Destroy feed 2
                        success &= await DestroyCommand.Destroy(settings, fileSystem2, log, CancellationToken.None);

                        // Validate feed 1
                        success &= await ValidateCommand.Validate(settings, fileSystem, log, CancellationToken.None);

                        success.Should().BeTrue();
                        target.RootDirectory.GetFiles().Should().BeEmpty();
                        target.RootDirectory.GetDirectories().Select(e => e.Name).ShouldBeEquivalentTo(new[] { "feedA" });
                    }
        }
        public List <FeedClimbingPost> GetPostsBySettings(FeedSettings settings, FeedView order, int number)
        {
            if (order == FeedView.Movies)
            {
                return(new List <FeedClimbingPost>());
            }

            if (settings.CurrentChannelType == (byte)FeedChannel.Area)
            {
                return(new FeedClimbingPostDA().GetLatestAreaPosts(number, settings.AreaID.Value, settings.TagID, order));
            }
            else if (settings.CurrentChannelType == (byte)FeedChannel.Place)
            {
                return(new FeedClimbingPostDA().GetLatestPlacePosts(number, settings.PlaceID.Value, settings.TagID, order));
            }
            else if (settings.CurrentChannelType == (byte)FeedChannel.Climbers)
            {
                List <Guid> userIDsBeingWatched = (from c in settings.WatchedClimbers select c.WatchedUserID).ToList();
                return(new FeedClimbingPostDA().GetLatestWatchedClimberPosts(number, userIDsBeingWatched, settings.TagID, order));
            }
            else
            {
                return(new FeedClimbingPostDA().GetLatestPosts(number, settings.TagID, order));
            }
        }
Beispiel #7
0
        //ADDING OF VIDEO FEEDS

        #region add video feed

        private void btnAddFeed_Click(object sender, EventArgs e)
        {
            FeedSettings settings = new FeedSettings();

            //have some default settings
            settings.setDetectorSettings(MotionDetectorInstance.MOTION.MOTION_BORDER_HIGHLIGHTING, MotionDetectorInstance.DETECTIONTYPE.TWO_FRAMES_DIFFERENCE,
                                         MotionDetectorInstance.DETECTIONSPEED.SLOW, MotionDetectorInstance.DETECTIONSENSITIVITY.HIGH);
            settings.setFeedSettings("", @"C:\Users\s212227122\Desktop\VehicleSystem\My Movie.wmv", true, true);
            settings.background = Resources.preview_frame;

            if (settings.ShowDialog() == DialogResult.OK)
            {
                //VideoControl newControl = new VideoControl(settings.feedName, @"C:\Users\Matthew\Desktop\Front Edited.wmv", true, this) { Margin = new Padding(0) };
                //C:\Users\Matthew\Desktop\Front Edited.wmv
                VideoControl newControl = new VideoControl(settings.feedName, settings.feedURL, settings.isEntrance,
                                                           this)
                {
                    Margin = new Padding(0), robustChecking = settings.robustChecking
                };
                newControl.updateMotionDetectorDetails(settings.resultRegion, settings.processor, settings.detector, settings.speed, settings.sensitivity);
                _videoControls.Add(newControl);
                pnlVideoFeed.Controls.Add(newControl);
            }

            Console.WriteLine("Stream added");
        }
        public FeedPostComment SaveFeedPostComment(FeedPostComment comment)
        {
            comment.PostedDateTime = DateTime.Now;
            FeedPostComment  newComment = new FeedPostCommentDA().Insert(comment);
            FeedClimbingPost post       = new FeedClimbingPostDA().GetByID(comment.FeedPostID);

            //-- Send notification to the poster
            FeedSettings postersFeedSettings = GetUsersFeedViewSettings(post.UserID);

            if (postersFeedSettings.NotifyOnPostComment && comment.UserID != post.UserID)
            {
                MailMan.SendCommentOnMyFeedPostNotification(post.ID, comment.User, post.User, comment.Message);
            }

            List <Guid> uniqueCommentingUserIDs = (from c in post.Comments where c.UserID != post.UserID select c.UserID).Distinct().ToList();

            //-- Send notifications to other commentors
            foreach (Guid userID in uniqueCommentingUserIDs)
            {
                FeedSettings commentorsFeedSettings = GetUsersFeedViewSettings(userID);
                if (commentorsFeedSettings.NotifyOnPostsICommentedOn && comment.UserID != userID)
                {
                    MailMan.SendCommentOnAFeedPostICommentedOnNotification(post.ID, comment.User, post.User,
                                                                           CFDataCache.GetClimberFromCache(userID), comment.Message);
                }
            }

            return(newComment);
        }
Beispiel #9
0
 public XmlDocument(ExportSettings item)
 {
     _item      = item;
     Bv         = item.XNamespace;
     Brands     = new List <XElement>();
     Products   = new List <XElement>();
     Categories = new List <XElement>();
 }
Beispiel #10
0
 public SyndicationController(IPostService postService, IPageService pageService, ICategoryService categoryService, BasicSettings basicSettings, AdvancedSettings advancedSettings, FeedSettings feedSettings)
 {
     _postService      = postService;
     _pageService      = pageService;
     _categoryService  = categoryService;
     _basicSettings    = basicSettings;
     _advancedSettings = advancedSettings;
     _feedSettings     = feedSettings;
 }
Beispiel #11
0
        public void GivenThatIReadSettingsFromAnEmptyJsonFileVerifyEmptySettings()
        {
            var json = JsonUtility.Create(new Uri("http://tempuri.org/settings.json"), "Settings");

            var actual = FeedSettingsUtility.LoadSettings(FeedSettingsUtility.GetSettings(json));

            var expected = new FeedSettings();

            actual.ShouldBeEquivalentTo(expected);
        }
        public SyndicationController(PageManager pageManager, PostManager postManager, CategoryManager categoryManager, BasicSettings basicSettings, AdvancedSettings advancedSettings, FeedSettings feedSettings)
        {
            this._postManager     = postManager;
            this._pageManager     = pageManager;
            this._categoryManager = categoryManager;

            this._basicSettings    = basicSettings;
            this._advancedSettings = advancedSettings;
            this._feedSettings     = feedSettings;
        }
Beispiel #13
0
        public Task StartAsync(CancellationToken cancellationToken)
        {
            var cfg = FeedSettings.GetInstance(Configuration);

            isStopped = false;

            aggregateTimer = new Timer(AggregateFeeds, cfg.AggregateInterval, TimeSpan.Zero, cfg.AggregatePeriod);
            removeTimer    = new Timer(RemoveFeeds, cfg.AggregateInterval, cfg.RemovePeriod, cfg.RemovePeriod);

            return(Task.CompletedTask);
        }
 public PackageAuthenticationService(
     FeedContext dbContext,
     FeedSettings settings,
     IHttpContextAccessor contextAccessor,
     ILogger <PackageAuthenticationService> logger)
 {
     _dbContext  = dbContext;
     _settings   = settings;
     _logger     = logger;
     HttpContext = contextAccessor.HttpContext;
 }
 private void SaveLocally(FeedSettings account, byte[] xmlfile)
 {
     using (var fileStream = new FileStream(account.FullLocalPath, FileMode.Create, FileAccess.Write))
     {
         using (var memoryStream = new MemoryStream(xmlfile, 0, xmlfile.Length))
         {
             memoryStream.CopyTo(fileStream);
             memoryStream.Flush();
             memoryStream.Close();
             _log.Info("Export -- XML Document -- Saving -- To Local path complete");
         }
     }
 }
Beispiel #16
0
        public void GivenThatICallLoadFeedSettingsVerifyValues()
        {
            var settings = new FeedSettings()
            {
                CatalogEnabled  = false,
                CatalogPageSize = 5,
                SymbolsEnabled  = false
            };

            var values = FeedSettingsUtility.LoadSettings(settings);

            var expected = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase)
            {
                { "catalogenabled", "false" },
                { "symbolsfeedenabled", "false" },
                { "catalogpagesize", "5" },
            };

            values.ShouldBeEquivalentTo(expected);
        }
 public List <FeedPartnerCallPost> GetFeedPartnerCallPostsBySettings(FeedSettings settings, int count)
 {
     if (settings.CurrentChannelType == (byte)FeedChannel.Place)
     {
         return(new PartnerCallDA().GetLatestFeedPartnerCallPostsForPlace(settings.PlaceID.Value, count));
     }
     if (settings.CurrentChannelType == (byte)FeedChannel.Area)
     {
         List <PartnerCall> calls = new PartnerCallDA().GetPartnerCallsForAreaTag(settings.AreaID.Value, count, null);
         return((from c in calls select new FeedPartnerCallPost {
             Call = c
         }).ToList());
     }
     else
     {
         List <PartnerCall> calls = new PartnerCallDA().GetLatestPartnerCalls(count, PartnerCallPlaceType.Both);
         return((from c in calls select new FeedPartnerCallPost {
             Call = c
         }).ToList());
     }
 }
        public void SaveDocument(FeedSettings account, MemoryStream xmlfile, StorageLocation storage)
        {
            var result = false;

            if (storage == StorageLocation.Ftp)
            {
                _log.Info("Export -- XML Document -- Saving -- To FTP path -- " + string.Format("{0}{1}{2}", account.Url, account.FolderPath, account.FileName));
                result = PushToFtp(account, xmlfile.ToArray());
            }
            else if (storage == StorageLocation.Sftp)
            {
                _log.Info("Export -- XML Document -- Saving -- To SFTP path -- " + string.Format("{0}{1}{2}", account.Url, account.FolderPath, account.FileName));
                result = PushToSftp(account, xmlfile.ToArray());
            }

            if (!result)
            {
                _log.Info("Export -- XML Document -- Saving -- To Local path -- " + string.Format("{0}", account.FullLocalPath));
                SaveLocally(account, xmlfile.ToArray());
            }
        }
        protected void Page_Init(object sender, EventArgs e)
        {
            //partnerCallSettings = cfController.GetUsersHomepagePartnerCallSettings(UserID);
            feedSettings = cfController.GetUsersFeedViewSettings(UserID);

            if (!Page.IsPostBack)
            {
                //if (partnerCallSettings.PlaceType == PartnerCallPlaceType.Both)
                //{
                //    TypeBothRB.Checked = true;
                //}
                //else if (partnerCallSettings.PlaceType == PartnerCallPlaceType.Indoor)
                //{
                //    TypeIndoorRB.Checked = true;
                //}
                //else if (partnerCallSettings.PlaceType == PartnerCallPlaceType.Outdoor)
                //{
                //    TypeOutdoorRB.Checked = true;
                //}

                //if (partnerCallSettings.DisplayMode == PartnerCallDisplayMode.All)
                //{
                //    ShowAllRB.Checked = true;
                //}
                //else if (partnerCallSettings.DisplayMode == PartnerCallDisplayMode.Area)
                //{
                //    ShowAreaRB.Checked = true;
                //    if (!feedSettings.AreaID.HasValue) { feedSettings.AreaID = 38; }
                //    AreaTag currentArea = CFDataCache.GetAreaTag(feedSettings.AreaID.Value);
                //    TxB.Text = currentArea.Name;
                //    ResultsHD.Value = currentArea.ID.ToString();
                //}

                NotifyOnPostCommentCB.Checked       = feedSettings.NotifyOnPostComment;
                NotifyOnPostsICommentedOnCB.Checked = feedSettings.NotifyOnPostsICommentedOn;

                PrivacyVisibleToAll.Checked      = (feedSettings.PostPrivacySettings == (short)FeedPostPrivacy.PostsVisibleToEveryone);
                PrivacyVisibleToWatchers.Checked = (feedSettings.PostPrivacySettings == (short)FeedPostPrivacy.PostsVisibleToWatchingMe);
            }
        }
        private bool PushToFtp(FeedSettings account, byte[] xmlfile)
        {
            try
            {
                _log.Info("Export -- XML Document -- Saving -- FTP -- Connecting");
                var request = (FtpWebRequest)WebRequest.Create(account.Url + account.FolderPath + account.FileName);
                request.Method      = WebRequestMethods.Ftp.UploadFile;
                request.Credentials = new NetworkCredential(account.UserName, account.Password);

                using (var ftpStream = request.GetRequestStream())
                {
                    _log.Info("Export -- XML Document -- Saving -- FTP -- Uploading");
                    ftpStream.Write(xmlfile, 0, xmlfile.Length);
                    ftpStream.Close();
                    ftpStream.Flush();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                _log.Error("Export -- XML Document -- Saving -- FTP -- Connection Failed with exception message of -- " + ex.Message);
                return(false);
            }
        }
        public List <FeedMoviePost> GetFeedMoviesBySettings(FeedSettings settings, int count)
        {
            List <FeedMoviePost> posts;

            if (settings.CurrentChannelType == (byte)FeedChannel.Place)
            {
                posts = msDA.GetLatestFeedMoviePostsForPlace(settings.PlaceID.Value, count);
            }
            else if (settings.CurrentChannelType == (byte)FeedChannel.Area)
            {
                posts = msDA.GetLatestFeedMoviePostsForArea(settings.AreaID.Value, count);
            }
            else if (settings.CurrentChannelType == (byte)FeedChannel.Climbers)
            {
                List <Guid> watchedUserIDs = (from c in settings.WatchedClimbers select c.WatchedUserID).ToList();
                if (watchedUserIDs.Count == 0)
                {
                    return(new List <FeedMoviePost>());
                }
                else
                {
                    posts = msDA.GetLatestFeedMoviePostsByClimbers(watchedUserIDs, count);
                }
            }
            else
            {
                posts = msDA.GetLatestFeedMoviePosts(count);
            }

            foreach (FeedMoviePost p in posts)
            {
                p.Comments = GetCommentsForMedia(p.PlaceMedia.MessageBoardID);
            }

            return(posts);
        }
        private List <IFeedItem> GetFeedItemsForViewSettings(FeedChannel channel, FeedView view,
                                                             int?areaID, int?placeID, byte?tagID)
        {
            int numberOfPostsToDisplay = 40;
            int displayClimbingCount = 0, displayPartnerCallCount = 0, displayMovieCount = 0;

            FeedSettings settings = controller.UpdateFeedSettingsIfNecessary(UserID, channel, areaID, placeID);

            settings.TagID = tagID; // decided not to persist the tag in the db at this point in time.

            //-- Need to do on client side
            //if (Settings.HasPlace) { CurrentPlaceLkB.Text = CurrentFeedPlace.ShortName.Take(12); }
            //if (Settings.HasArea) { CurrentAreaLkB.Text = CurrentFeedArea.Name.Take(12); }
            //if (Settings.TagID.HasValue) { CurrentTagLB.Text = GetTagsString(Settings.TagID.Value); }

            if (view == FeedView.Posted)
            {
                //SelectLkB(PLkB);

                if (settings.TagID.HasValue)
                {
                    displayClimbingCount = numberOfPostsToDisplay;
                }
                else
                {
                    displayClimbingCount    = 12;
                    displayPartnerCallCount = 5;
                    displayMovieCount       = 3;
                }
            }
            else if (view == FeedView.Movies)
            {
                //SelectLkB(MLkB);
                settings.TagID    = null;
                displayMovieCount = 15;
            }
            else if (view == FeedView.Climbing)
            {
                //SelectLkB(DCLkb);
                displayClimbingCount = numberOfPostsToDisplay;
            }
            else if (view == FeedView.PartnerCalls)
            {
                //SelectLkB(PCLkB);
                settings.TagID          = null;
                displayPartnerCallCount = 17;
            }

            if (channel == FeedChannel.All)
            {
                //SelectLkB(AllLkB);
            }
            else if (channel == FeedChannel.Area)
            {
                //SelectLkB(CurrentAreaLkB);
                //FeedFocus = CurrentFeedArea.Name;
            }
            else if (channel == FeedChannel.Place)
            {
                //SelectLkB(CurrentPlaceLkB);
                //FeedFocus = CurrentFeedPlace.Name;
            }
            //else if (channel == FeedChannel.Climbers)
            //{
            //SelectLkB(ClLkB);
            //    settings.WatchedClimbers = controller.GetClimbersUserIsWatching(UserID);
            //FeedFocus = "climbers you're watching";
            //}

            List <IFeedItem>           FeedItems        = new List <IFeedItem>();
            List <FeedMoviePost>       MoviePosts       = new List <FeedMoviePost>();
            List <FeedPartnerCallPost> PartnerCallPosts = new List <FeedPartnerCallPost>();
            List <FeedClimbingPost>    ClimbingPosts    = new List <FeedClimbingPost>();

            if (displayClimbingCount > 0)
            {
                ClimbingPosts = controller.GetPostsBySettings(settings, view, numberOfPostsToDisplay);
            }

            //-- Fill the feed if we don't have enough posts
            if (view == FeedView.Posted && !settings.TagID.HasValue)
            {
                if (ClimbingPosts.Count < numberOfPostsToDisplay)
                {
                    byte numberToFill = (byte)(numberOfPostsToDisplay - ClimbingPosts.Count);
                    displayMovieCount++;
                    displayPartnerCallCount = (byte)(numberToFill - 1);
                }
            }

            if (displayMovieCount > 0 && !settings.TagID.HasValue)
            {
                MoviePosts = controller.GetFeedMoviesBySettings(settings, displayMovieCount);
            }

            if (displayPartnerCallCount > 0 &&
                (!settings.TagID.HasValue || settings.TagID.Value != 1) &&
                channel != FeedChannel.Climbers)
            {
                PartnerCallPosts = controller.GetFeedPartnerCallPostsBySettings(settings, displayPartnerCallCount);
            }

            foreach (FeedClimbingPost cp in ClimbingPosts)
            {
                FeedItems.Add(cp);
            }
            foreach (FeedMoviePost mp in MoviePosts)
            {
                FeedItems.Add(mp);
            }
            foreach (FeedPartnerCallPost pcp in PartnerCallPosts)
            {
                FeedItems.Add(pcp);
            }
            if (view == FeedView.Posted)
            {
                FeedItems = (from c in FeedItems orderby c.PostedDateTime descending select c).ToList();
            }
            return(FeedItems);
        }
 public FeedSettings UpdateUsersFeedViewSettings(FeedSettings settings)
 {
     return(new FeedSettingsDA().Update(settings));
 }
Beispiel #24
0
 public void OnGet()
 {
     ViewModel = _blogConfig.FeedSettings;
 }
Beispiel #25
0
 public ShieldController(IContext dbContext, FeedSettings settings)
 {
     _db         = dbContext;
     _serverName = settings.ServerName;
 }
Beispiel #26
0
        private void AggregateFeeds(object interval)
        {
            if (!Monitor.TryEnter(aggregateLock))
            {
                return;
            }

            try
            {
                var cfg = FeedSettings.GetInstance(Configuration);
                using var scope = ServiceProvider.CreateScope();
                var scopeClass = scope.ServiceProvider.GetService <FeedAggregatorServiceScope>();
                var cache      = scope.ServiceProvider.GetService <ICache>();
                var(baseCommonLinkUtility, tenantManager, feedAggregateDataProvider, userManager, securityContext, authManager) = scopeClass;
                baseCommonLinkUtility.Initialize(cfg.ServerRoot);

                var start = DateTime.UtcNow;
                Log.DebugFormat("Start of collecting feeds...");

                var unreadUsers = new Dictionary <int, Dictionary <Guid, int> >();
                var modules     = scope.ServiceProvider.GetService <IEnumerable <IFeedModule> >();

                foreach (var module in modules)
                {
                    var result   = new List <FeedRow>();
                    var fromTime = feedAggregateDataProvider.GetLastTimeAggregate(module.GetType().Name);
                    if (fromTime == default)
                    {
                        fromTime = DateTime.UtcNow.Subtract((TimeSpan)interval);
                    }
                    var toTime = DateTime.UtcNow;

                    var tenants = Attempt(10, () => module.GetTenantsWithFeeds(fromTime)).ToList();
                    Log.DebugFormat("Find {1} tenants for module {0}.", module.GetType().Name, tenants.Count());

                    foreach (var tenant in tenants)
                    {
                        // Warning! There is hack here!
                        // clearing the cache to get the correct acl
                        cache.Remove("acl" + tenant);
                        cache.Remove("/webitemsecurity/" + tenant);
                        //cache.Remove(string.Format("sub/{0}/{1}/{2}", tenant, "6045b68c-2c2e-42db-9e53-c272e814c4ad", NotifyConstants.Event_NewCommentForMessage.ID));

                        try
                        {
                            if (tenantManager.GetTenant(tenant) == null)
                            {
                                continue;
                            }

                            tenantManager.SetCurrentTenant(tenant);
                            var users = userManager.GetUsers();

                            var feeds = Attempt(10, () => module.GetFeeds(new FeedFilter(fromTime, toTime)
                            {
                                Tenant = tenant
                            }).Where(r => r.Item1 != null).ToList());
                            Log.DebugFormat("{0} feeds in {1} tenant.", feeds.Count, tenant);

                            var tenant1  = tenant;
                            var module1  = module;
                            var feedsRow = feeds
                                           .Select(tuple => new Tuple <FeedRow, object>(new FeedRow(tuple.Item1)
                            {
                                Tenant    = tenant1,
                                ProductId = module1.Product
                            }, tuple.Item2))
                                           .ToList();

                            foreach (var u in users)
                            {
                                if (isStopped)
                                {
                                    return;
                                }
                                if (!TryAuthenticate(securityContext, authManager, tenant1, u.ID))
                                {
                                    continue;
                                }

                                module.VisibleFor(feedsRow, u.ID);
                            }

                            result.AddRange(feedsRow.Select(r => r.Item1));
                        }
                        catch (Exception ex)
                        {
                            Log.ErrorFormat("Tenant: {0}, {1}", tenant, ex);
                        }
                    }

                    feedAggregateDataProvider.SaveFeeds(result, module.GetType().Name, toTime);

                    foreach (var res in result)
                    {
                        foreach (var userGuid in res.Users.Where(userGuid => !userGuid.Equals(res.ModifiedById)))
                        {
                            if (!unreadUsers.TryGetValue(res.Tenant, out var dictionary))
                            {
                                dictionary = new Dictionary <Guid, int>();
                            }
                            if (dictionary.ContainsKey(userGuid))
                            {
                                ++dictionary[userGuid];
                            }
                            else
                            {
                                dictionary.Add(userGuid, 1);
                            }

                            unreadUsers[res.Tenant] = dictionary;
                        }
                    }
                }

                SignalrServiceClient.SendUnreadUsers(unreadUsers);

                Log.DebugFormat("Time of collecting news: {0}", DateTime.UtcNow - start);
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
            finally
            {
                Monitor.Exit(aggregateLock);
            }
        }
        public virtual IEnumerable <IFeedItem> ApplyFilters(IEnumerable <IFeedItem> items, FeedFilterStateModel filterState, FeedSettings settings)
        {
            if (filterState.ShowSubscribed.GetValueOrDefault() && settings.HasSubscribersFilter)
            {
                items = items.Where(i =>
                                    i is ISubscribable subscribable &&
                                    _subscribeService.IsSubscribed(_intranetMemberService.GetCurrentMember().Id, subscribable));
            }

            if (filterState.ShowPinned.GetValueOrDefault() && settings.HasPinnedFilter)
            {
                items = items.Where(i => i.IsPinned);
            }

            items = ApplyAdditionalFilters(items);
            return(items);
        }
Beispiel #28
0
 protected void Page_Init(Object o, EventArgs e)
 {
     Settings = cf.GetUsersFeedViewSettings(UserID);
 }
Beispiel #29
0
 protected void Page_Init(Object o, EventArgs e)
 {
     Settings = new FeedSettings {
         AreaID = 9, CurrentChannelType = (byte)FeedChannel.All
     };
 }