public void AddRedisFeed(Activity activity)
        {
            FeedType type;

            if (activity is Post)
            {
                type = FeedType.POST;
            }
            else if (activity is Share)
            {
                type = FeedType.SHARE;
            }
            else if (activity is Photo)
            {
                type = FeedType.PHOTO;
            }
            else
            {
                log.Error("Unable to recognize FeedType: " + activity.GetType() + ". Skipping this activity...");
                throw new ArgumentException();
            }

            Feed feed = new Feed
            {
                ReferenceId = activity.Id,
                Type = type,
                CreatedDate = activity.Created
            };

            redisDataManager.AddFeed(feed, activity.Author.Id);
        }
示例#2
0
        public void SaveActivity(Activity activity)
        {
            if (activity == null)
            {
                throw new ArgumentNullException();
            }

            log.Info("Saving " + activity.GetType().Name + ":" + activity.googleId);

            try
            {
                dataAdapter.SaveActivity(activity);
            }
            catch (Exception ex)
            {
                log.Error(ex.Message, ex);
                throw;
            }
        }
示例#3
0
        private int SaveActivity(Activity activity)
        {
            var currentUserId = Membership.GetUserId(User);

            activity.Author = DataAdapter.GetUserById(currentUserId);
            activity.Created = DateTime.Now;
            DataAdapter.SaveActivity(activity);

            //save to Redis
            var importer = (UserImportDataProcessor)SpringContext.Resolve("IUserImportDataProcessor");
            importer.AddRedisFeed(activity);

            log.Debug("Activity saved to Redis feed");

            return currentUserId;
        }