コード例 #1
0
ファイル: SocialController.cs プロジェクト: jrocket/MOG
        private List<VMNotification> getNoticiationsFromCache()
        {
            List<Notification> data = null;

            if (CurrentUser != null)
            {
                data = this.serviceActivity.GetNotificationByUserId(CurrentUser.Id, 10);
            }
            //Todo : use automapper
            List<VMNotification> model = new Mapper().MapActivities(data);
            return model;
        }
コード例 #2
0
ファイル: SocialController.cs プロジェクト: jrocket/MOG
 public ActionResult TheFridge()
 {
     ViewBag.Title = Resources.Resource.PROFILE_TheFridge;
     List<Activity> data = null;
     data = this.serviceActivity.GetLatest(Visibility.Public, 1, 50);
     List<VMActivity> model = new Mapper().MapActivities(data);
     return View(model);
 }
コード例 #3
0
ファイル: ProjectController.cs プロジェクト: jrocket/MOG
        public JsonResult GetActivities(int id)
        {
            Project project = serviceProject.GetById(id);
            if (!this.serviceSecurity.HasRight(SecureActivity.ProjectView, CurrentUser, project))
            {
                return JsonHelper.ResultError(null, null, Resources.Resource.COMMON_PermissionDenied, JsonRequestBehavior.AllowGet);
            }

            IList<Activity> activities = serviceProject.GetProjectActivity(id);
            //todo : use automapper
            Root data = new Root();
            data.timeline = new Timeline();
            data.timeline.headline = String.Format(Resources.Resource.ACTIViTY_HereIsWhatHappened, project.Name);
            data.timeline.type = "default";
            data.timeline.text = String.Format("<p>{0}</p>",Resources.Resource.ACTIVITY_ClickOnTheLeftOrRigthArrow);
            data.timeline.asset = new Asset()
            {
                credit = "Credit Name Goes Here",
                caption = "Caption text goes here"
            };
            data.timeline.date = new List<Date>();

            List<VMActivity> model = new Mapper().MapActivities(activities);

            foreach (var activity in model)
            {
                Date theEvent = new Date()
               {
                   StartDate = activity.When,
                   EndDate = activity.When,
                   headline = activity.Who.DisplayName,
                   tag = activity.Type.ToString(),
                   text = String.Format("<a href='{0}'>{1}</a>",
                   activity.Url,
                   activity.Description)
               };

                data.timeline.date.Add(theEvent);
            }

            return new JsonResult() { Data = data, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
        }
コード例 #4
0
ファイル: SocialController.cs プロジェクト: jrocket/MOG
        public ActionResult GetActivity(int id = -1)
        {
            ViewBag.Title = Resources.Resource.PROFILE_ActivityFeed;
            List<Activity> data = null;
            if (id > 0)
            {
                data = this.serviceActivity.GetByUserId(id, 20);
            }
            //Todo : use automapper
            List<VMActivity> model = new Mapper().MapActivities(data);

            return PartialView("_activityPartial", model);
        }
コード例 #5
0
ファイル: ScheduledTaskService.cs プロジェクト: jrocket/MOG
        private void TaskBroadcastNotifications()
        {
            var now = DateTime.Now;
            DateTime lastRunTime = (DateTime)cache[CRON_BROADCAST_NOTIFICATIONS_LRT];
            if (signalRConnections.Instance.Count < 2)
                return;
            var connectedPeople = signalRConnections.Instance.GetNames();
            foreach (var user in connectedPeople)
            {
                var userProfile = this.serviceUser.GetByLogin(user);
                if (userProfile != null)
                {
                    var rawData = this.serviceActivity.GetActivitiesByUserId(userProfile.Id, 5);
                    var notifications = new Mapper().MapActivities(rawData);
                    foreach (var notification in notifications)
                    {
                        if (notification.When >lastRunTime)
                        {
                            MoG.Code.NotificationSignal._instance.Value.NotifySomeone(user, notification.Description);
                        }
                    }

                }
            }
            cache[CRON_BROADCAST_NOTIFICATIONS_LRT] = now;
        }