Exemplo n.º 1
0
        private string Serialize(IEnumerable <Activity> activities, ulong forSource, string sourceType)
        {
            var feed = activities.Select(a => FeedWrapper.Create(a, forSource, sourceType)).Where(w => w != null).ToArray();

            return(JsonConvert.SerializeObject(new ResponseBody(feed), Newtonsoft.Json.Formatting.None,
                                               new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            }));
        }
Exemplo n.º 2
0
        public override void Execute()
        {
            //Logger.Instance.Debug($"action id is {activity.ActivityId}");
            ActivityCache.Instance.Remove(activity.ActivityId);
            activity.Source.ActivityFeed.AdvanceActivity(activity);
            SetLinkParent();

            //we create the feedwrapper for the activity. this will put all needed resources of DB in cache
            FeedWrapper.Create(activity, activity.SubjectId, activity.SubjectType, false);
        }
Exemplo n.º 3
0
        public string GetClientFeedAsJson(ulong userId, int minutesBack = 0, int maxCount = -1)
        {
            var feed = GetCombinedActivityFeed(userId, minutesBack, maxCount)
                       .Select(a => FeedWrapper.Create(a.Activities[a.FirstReactor], userId, "user")).Where(f => f != null);

            return(JsonConvert.SerializeObject(new ResponseBody(feed.ToArray()), Newtonsoft.Json.Formatting.None,
                                               new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            }));
        }
Exemplo n.º 4
0
        private LikesCommentsBody(Activity activity, ulong userId, bool viewComments, ulong comment_id, int ios)
        {
            this.activity  = activity;
            this.commentId = comment_id;

            if (viewComments)
            {
                viewAllComments = GetComments(userId, commentId, out getTotalComments, ios);
            }
            // else
            //  {
            viewAllLikesBy = GetLikes();
            // }

            var wrapper = FeedWrapper.Create(activity, userId, "user", false);

            isLike            = wrapper.is_like;
            canComment        = wrapper.canComment;
            canDelete         = canComment;
            getTotalItemCount = viewAllComments == null ? 0 : viewAllComments.Length;
            getTotalLikes     = viewAllLikesBy == null ? 0 : viewAllLikesBy.Length;
        }
Exemplo n.º 5
0
        private string Serialize(IEnumerable <CombinedActivity> activities)
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();
            var activityList = activities.Where(a => a.HasActivities).ToList();

            sw.Stop();
            Logger.Instance.Debug($"Getting combined activity list of {activityList.Count()} took {sw.ElapsedMilliseconds} ms");
            sw.Reset();
            sw.Start();
            var feed = activityList.Select(a => FeedWrapper.Create(a, viewerId, "user", IsIOS)).Where(w => w != null).ToArray();

            sw.Stop();
            Logger.Instance.Debug($"creating feedwrappers took {sw.ElapsedMilliseconds} ms");
            ulong minId = 0;
            ulong maxId = 0;

            if (activityList.Count > 0)
            {
                minId = GetMinId(activityList);
                maxId = GetMaxId(activityList);
                Logger.Instance.Debug($"minid is:{minId} maxid is:{maxId}");
                if ((maxId - minId) > 1000)
                {
                    //too big gap
                    activityList.ForEach(ca => ca.PrintAll());
                }

                viewer.LastMinimalIdInFeed = minId; // update it for the next fetch
            }

            return(JsonConvert.SerializeObject(new ResponseBody(feed, minId, maxId, feedSizeLimit), Newtonsoft.Json.Formatting.None,
                                               new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore
            }));
        }
Exemplo n.º 6
0
        private static void GetActivitiesFromServer()
        {
            // var ccc = Comments.GetForComment(861);
            // LikesCommentsHandler lch = new LikesCommentsHandler(3, new RequestParams() { action_id = 37409 });
            // lch.Execute();
            //    LikesHandler ulike = new LikesHandler(3, new RequestParams() { action_id = 37072 });
            //    ulike.Execute();

            var cl = Likes.GetByResourceId(29846);

            //LikesCommentsHandler lch = new LikesCommentsHandler(3, new RequestParams() { action_id = 28869 , viewAllComments = "1" });
            //lch.Execute();
            // var u = Users.GetById(3);
            //var s = Storages.GetByFileId(u.photo_id);
            // Dictionary<string, object> apar = new Dictionary<string, object>();
            // apar["action_id"] = "18021";// "17998";
            // ViewHandler vh = new ViewHandler(3, new RequestParams(), apar);
            // vh.Execute();
            //RemoveActivityHandler rh = new RemoveActivityHandler(3, new RequestParams() { action_id = 20811 });
            //rh.Execute();
            //  PostHandler ph = new PostHandler(339, new RequestParams() { action_id = 31633 });
            // ph.Execute();

            //var x = CoreSettings.Get("core.iframely.secretIframelyKey");//All().Where(s => s.Key.Contains("iframe")).ToArray();
            using (var wc = new WebClient())
            {
                //var photo = AlbumPhotos.GetById(2410);
                //var link = CoreLinks.GetById(12095);
                // var video = Videos.GetById(748);
                //var refs = ActivityActions.GetByObjectId(8005, "activity_action").ToArray();
                //SourceData han = SourcesMap.Instance.GetSource(368, "user");
                // var hanFeed = han.ActivityFeed.Feed;



                uint aid      = 29846;// 26864;// 26843;
                var  activity = ActivityActions.GetById(aid);
                var  a        = new KoobecaFeedController.BL.Activity(activity);
                var  wrapper  = new FeedWrapper(a, 3, "user", false);
                var  res      = JsonConvert.SerializeObject(wrapper, Newtonsoft.Json.Formatting.None,
                                                            new JsonSerializerSettings
                {
                    NullValueHandling = NullValueHandling.Ignore
                });
                var ourFeeds = new List <FeedWrapper>();

                //FeedController.Instance.AddLike(3, activity.action_id);
                //FeedController.Instance.RemoveLike(3, activity.action_id);
                var sb = new StringBuilder();
                //foreach (var feed in json.body.data)
                //{
                //    uint action_id = feed.feed.action_id;
                //    sb.AppendLine(action_id.ToString());
                //    var rawActivity = ActivityActions.GetByID(action_id);
                //    if (action_id == aid) {
                //        if (rawActivity != null)
                //        {
                //            sb.AppendLine(action_id.ToString());
                //            ourFeeds.Add(new FeedWrapper(new KoobecaFeedController.BL.Activity(rawActivity)));
                //        }
                //    }
                //}
                var str    = sb.ToString();
                var result = JsonConvert.SerializeObject(new ResponseBody(ourFeeds.ToArray(), 0, 0, 50), Newtonsoft.Json.Formatting.None,
                                                         new JsonSerializerSettings
                {
                    NullValueHandling = NullValueHandling.Ignore
                });
            }
        }