예제 #1
0
파일: AlertService.cs 프로젝트: SPKT/MHX2
        public void AddComment(Comment c)
        {
            alert = new Alert();
            alert.CreateDate = c.CreateDate;
            if (c.SystemObjectID == 1)
            {
                _statusUpdateRepository = new StatusUpdateRepository();
                StatusUpdate st = _statusUpdateRepository.GetStatusUpdateByID((int)c.SystemObjectRecordID);
                account=_accountRepository.GetAccountByID(st.SenderID);
                alertMessage = GetProfileUrl(c.CommentByUsername)+" bình luận status của "+ GetProfileUrl(account.UserName)+":" + c.Body;
                alert.Message = alertMessage;
                alert.AccountID = c.CommentByAccountID;
                alert.AlertTypeID = (int)AlertType.AlertTypes.Comment;
                SaveAlert(alert);

                Notification notification = new Notification();
                string notify = "<a href=\"/UserProfile2.aspx?AccountID=" + c.CommentByAccountID.ToString() + "\">" +
                c.CommentByUsername + "</a>" +
                 "vừa mới bình luận status của bạn: " + c.Body;
                notification.AccountID = st.SenderID;
                notification.CreateDate = c.CreateDate;
                notification.IsRead =false;
                notification.Body = notify;
                _notifycationRepository.SaveNotification(notification);
            }
        }
예제 #2
0
 public AlertService()
 {
     _userSession = new UserSession();
     _alertRepository = new AlertRepository();
     _webContext = new WebContext();
     alert = new Alert();
 }
예제 #3
0
 public void DeleteAlert(Alert alert)
 {
     using (SPKTDataContext spktDC = conn.GetContext())
     {
         spktDC.Alerts.DeleteOnSubmit(alert);
         spktDC.SubmitChanges();
     }
 }
예제 #4
0
파일: AlertService.cs 프로젝트: ngocpq/MHX2
 public AlertService()
 {
     _userSession = new UserSession();
     _alertRepository = new AlertRepository();
     _webContext = new WebContext();
     _friendRepository = new FriendRepository();
     alert = new Alert();
     _accountRepository = new AccountRepository();
     _groupMemberRepository = new GroupMemberRepository();
     _notifycationRepository = new NotificationRepository();
 }
예제 #5
0
파일: AlertService.cs 프로젝트: ngocpq/MHX2
 public void AddNewBlogPostAlert(Blog blog)
 {
     alert = new Alert();
     alert.CreateDate = DateTime.Now;
     alert.AccountID = _userSession.CurrentUser.AccountID;
     alert.AlertTypeID = (int)AlertType.AlertTypes.NewBlogPost;
     alertMessage = "<div class=\"AlertHeader\">" + GetProfileImage(_userSession.CurrentUser.AccountID) +
                    GetProfileUrl(_userSession.CurrentUser.UserName) + " has just added a new blog post: <b>" +
                    blog.Title + "</b></div>";
     alert.Message = alertMessage;
     SaveAlert(alert);
     SendAlertToFriends(alert);
 }
예제 #6
0
 public void SaveAlert(Alert alert)
 {
     using (SPKTDataContext spktDC = conn.GetContext())
     {
         if (alert.AlertID > 0)
         {
             spktDC.Alerts.Attach(alert, true);
         }
         else
         {
             alert.CreateDate = DateTime.Now;
             spktDC.Alerts.InsertOnSubmit(alert);
         }
         spktDC.SubmitChanges();
     }
 }
예제 #7
0
파일: AlertService.cs 프로젝트: ngocpq/MHX2
 private void SendAlertToGroup(Alert alert, Group group)
 {
     List<int> groupMembers = _groupMemberRepository.GetMemberAccountIDsByGroupID(group.GroupID);
     foreach (int id in groupMembers)
     {
         alert.AlertID = 0;
         alert.AccountID = id;
         SaveAlert(alert);
         notify.AccountID = alert.AccountID;
         notify.Body = alert.Message;
         notify.IsRead = false;
         _notifycationRepository.SaveNotification(notify);
     }
 }
예제 #8
0
파일: AlertService.cs 프로젝트: ngocpq/MHX2
 private void SendAlertToFriends(Alert alert)
 {
     List<Friend> friends = _friendRepository.GetFriendsByAccountID(alert.AccountID);
     foreach (Friend friend in friends)
     {
         alert.AlertID = 0;
         alert.AccountID = friend.MyFriendAccountID;
         SaveAlert(alert);
     }
 }
예제 #9
0
파일: AlertService.cs 프로젝트: ngocpq/MHX2
 private void SaveAlert(Alert alert)
 {
     _alertRepository.SaveAlert(alert);
 }
예제 #10
0
파일: AlertService.cs 프로젝트: ngocpq/MHX2
 private void Init()
 {
     account = _userSession.CurrentUser;
     alert = new Alert();
     alert.AccountID = account.AccountID;
     alert.CreateDate = DateTime.Now;
     notify = new Notification();
 }
예제 #11
0
		private void detach_Alerts(Alert entity)
		{
			this.SendPropertyChanging();
			entity.Account = null;
		}
예제 #12
0
		private void attach_Alerts(Alert entity)
		{
			this.SendPropertyChanging();
			entity.Account = this;
		}
예제 #13
0
 partial void DeleteAlert(Alert instance);
예제 #14
0
 partial void UpdateAlert(Alert instance);
예제 #15
0
 partial void InsertAlert(Alert instance);
예제 #16
0
파일: AlertService.cs 프로젝트: SPKT/MHX2
 public void AddUpdatedBlogPostAlert(Blog blog)
 {
     Init();
     alert = new Alert();
     alert.CreateDate = DateTime.Now;
     alert.AccountID = _userSession.CurrentUser.AccountID;
     alert.AlertTypeID = (int)AlertType.AlertTypes.NewBlogPost;
     alertMessage = "<div >" + GetProfileImage(_userSession.CurrentUser.AccountID) +
                    GetProfileUrl(_userSession.CurrentUser.UserName) + " vừa mới cập nhật <b>" + "<a href=\"" + _webContext.RootUrl + "Blogs/ViewBlog" + ".aspx?BlogID=" + blog.BlogID + "\">" +
                    blog.Title + "</a>" +
                    "!</div>";
     alert.Message = alertMessage;
     SaveAlert(alert);
     SendAlertToFriends(alert);
 }