예제 #1
0
파일: ReadFile.ascx.cs 프로젝트: SPKT/MHX2
        protected void Page_Load(object sender, EventArgs e)
        {
            //_profileRepository = new ProfileRepository();
            _fr = new FileRepository();
            _userSession = new UserSession();
            _accountRepository = new AccountRepository();
            _webContext = new WebContext();

                if (_userSession.LoggedIn && _userSession.CurrentUser != null)
                {
                    account = _userSession.CurrentUser;
                    file = _fr.GetFileByID(fileID);
                }

            //show the appropriate image

            if (file != null)
            {

                //Response.Clear();
                Response.ContentType = "jpg";
                Response.BinaryWrite(file.ContentFile.ToArray());

            }
        }
예제 #2
0
        public bool ShouldShowStatus(StatusUpdate Status, Account AccountBeingViewed, Account Account)
        {
            bool result;
            if (Account != null)
            {
                if (Account.AccountID == AccountBeingViewed.AccountID)
                    return true;
                bool isFriend = _friendService.IsFriend(Account, AccountBeingViewed);
                if (Status.VisibilityLevelID == (int)VisibilityLevel.VisibilityLevels.Private)
                    result = false;

                else if ((Status.VisibilityLevelID == (int)VisibilityLevel.VisibilityLevels.Friends) && (isFriend))
                    result = true;
                else if (Status.VisibilityLevelID == (int)VisibilityLevel.VisibilityLevels.Public)
                    result = true;
                else
                    result = false;

                return result;
            }
            else
            {
                if (Status.VisibilityLevelID == (int)VisibilityLevel.VisibilityLevels.Public)
                    result = true;
                else
                    result = false;
                return result;
            }
        }
예제 #3
0
파일: PrivacyService.cs 프로젝트: SPKT/MHX2
        public bool ShouldShow(Int32 PrivacyFlagTypeID,
        Account AccountBeingViewed,
        Account Account,
        List<PrivacyFlag> Flags)
        {
            bool result;
            if (Account != null)
            {
                if (Account.AccountID == AccountBeingViewed.AccountID)
                    return true;

                bool isFriend = _friendService.IsFriend(Account, AccountBeingViewed);
                if (Flags.Where(f => f.PrivacyFlagTypeID == PrivacyFlagTypeID && f.VisibilityLevelID == (int)VisibilityLevel.VisibilityLevels.Private).FirstOrDefault() != null)
                    result = false;

                else if (Flags.Where(f => f.PrivacyFlagTypeID == PrivacyFlagTypeID && f.VisibilityLevelID == (int)VisibilityLevel.VisibilityLevels.Friends).FirstOrDefault() != null && isFriend)
                    result = true;
                else if (Flags.Where(f => f.PrivacyFlagTypeID == PrivacyFlagTypeID && f.VisibilityLevelID == (int)VisibilityLevel.VisibilityLevels.Public).FirstOrDefault() != null)
                    result = true;
                else
                    result = false;
            }
            else
            {
                if (Flags.Where(f => f.PrivacyFlagTypeID == PrivacyFlagTypeID && f.VisibilityLevelID == (int)VisibilityLevel.VisibilityLevels.Public).FirstOrDefault() != null)
                    result = true;
                else
                    result = false;
            }
            return result;
        }
예제 #4
0
파일: InviteFriend.cs 프로젝트: SPKT/MHX2
        public void Init(IInviteFriends view)
        {
            _view = view;
            //_userSession = ObjectFactory.GetInstance<IUserSession>();
            //_email = ObjectFactory.GetInstance<IEmail>();
            //_friendInvitationRepository = ObjectFactory.GetInstance<IFriendInvitationRepository>();
            //_accountRepository = ObjectFactory.GetInstance<IAccountRepository>();
            //_webContext = ObjectFactory.GetInstance<IWebContext>();
            _userSession = new SPKTCore.Core.Impl.UserSession();
            _friendInvitationRepository = new SPKTCore.Core.DataAccess.Impl.FriendInvitationRepository();
            _email = new SPKTCore.Core.Impl.Email();
            _webContext = new SPKTCore.Core.Impl.WebContext();
            if (_userSession.LoggedIn)
            {
                _account = _userSession.CurrentUser;
                _accountRepository = new SPKTCore.Core.DataAccess.Impl.AccountRepository();
                if (_account != null)
                {
                    _view.DisplayToData(_account.UserName + " &lt;" + _account.Email + "&gt;");

                    if (_webContext.AccoundIdToInvite > 0)
                    {
                        _accountToInvite = _accountRepository.GetAccountByID(_webContext.AccoundIdToInvite);

                        if (_accountToInvite != null)
                        {
                            SendInvitation(_accountToInvite.Email,
                                           _account.UserName + " " + _account.UserName + " ");
                            _view.ShowMessage(_accountToInvite.UserName + " Đã được gửi đi!");
                            _view.TogglePnlInvite(false);
                        }
                    }
                }
            }
        }
예제 #5
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);
            }
        }
예제 #6
0
파일: FriendService.cs 프로젝트: SPKT/MHX2
 public void DeleteFriendFromFriendInvitation(Guid InvitationKey, Account InvitationTo)
 {
     FriendInvitation friendInvitation = _friendInvitationRepository.GetFriendInvitationByGUID(InvitationKey);
     friendInvitation.BecameAccoutnID = -1;
     _friendInvitationRepository.SaveFriendInvitation(friendInvitation);
     _friendInvitationRepository.CleanUpFriendInvitationsForThisEmail(friendInvitation);
 }
예제 #7
0
 public void DeleteAccount(Account account)
 {
     using (SPKTDataContext spktDC = conn.GetContext())
     {
         spktDC.Accounts.DeleteOnSubmit(account);
         spktDC.SubmitChanges();
     }
 }
예제 #8
0
 public void Init(IStatusControl view)
 {
     _view = view;
     if (_userSession.LoggedIn)
     {
         account = _userSession.CurrentUser;
     }
 }
예제 #9
0
파일: Share.cs 프로젝트: SPKT/MHX2
 public void Shared1(Account ac, Account acby, Folder file)
 {
     AccountFolderShare asf = new AccountFolderShare();
     asf.AccountByID = acby.AccountID;
     asf.AccountID = ac.AccountID;
     asf.FolderID = file.FolderID;
     _ac.Save(asf);
 }
예제 #10
0
파일: Share.cs 프로젝트: SPKT/MHX2
 public void Shared(Account ac, Account acby, File file)
 {
     AccountFileShare asf = new AccountFileShare();
     asf.AccountByID = acby.AccountID;
     asf.AccountID = ac.AccountID;
     asf.FileID = file.FileID;
     _af.Save(asf);
 }
예제 #11
0
 public void CreateFriendFromFriendInvitation(Guid InvitationKey, Account InvitationTo)
 {
     FriendInvitation friendInvitation = _friendInvitationRepository.GetFriendInvitationByGUID(InvitationKey);
     friendInvitation.BecameAccoutnID = InvitationTo.AccountID;
     _friendInvitationRepository.SaveFriendInvitation(friendInvitation);
     _friendInvitationRepository.CleanUpFriendInvitationsForThisEmail(friendInvitation);
     Friend friend = new Friend();
     friend.AccountID = friendInvitation.AccountID;
     friend.MyFriendAccountID = InvitationTo.AccountID;
     _friendRepository.SaveFriend(friend);
 }
예제 #12
0
 public void LoadDisplay(Account account)
 {
     _account = account;
     ibInviteFriend.Attributes.Add("FriendsID", _account.AccountID.ToString());
     ibDelete.Attributes.Add("FriendsID", _account.AccountID.ToString());
     //litAccountID.Text = account.AccountID.ToString();
     lblCreateDate.Text = account.CreateDate.ToString();
     imgAvatar.ImageUrl += "?AccountID=" + account.AccountID.ToString();
     lblUsername.Text = account.UserName;
     lblFriendID.Text = account.AccountID.ToString();
 }
예제 #13
0
 public void AddPermission(Account account, Permission permission)
 {
     using (SPKTDataContext spktDC = conn.GetContext())
     {
         AccountPermission ap = new AccountPermission();
         ap.AccountID = account.AccountID;
         ap.PermissionID = permission.PermissionID;
         spktDC.AccountPermissions.InsertOnSubmit(ap);
         spktDC.SubmitChanges();
     }
 }
예제 #14
0
 public List<Account> SearchFriend(Account account)
 {
     SPKTDataContext dc=new SPKTDataContext();
     List<Account> list = new List<Account>();
     foreach (Account a in dc.Accounts)
     {
         if (IsFriend(a, account) == true || IsFriend(account, a) == true)
             list.Add(a);
     }
     return list;
 }
예제 #15
0
        public void Init(IEditAccount View, bool IsPostBack)
        {
            _view = View;

            if (_userSession.CurrentUser != null)
                account = _userSession.CurrentUser;
            else
                _redirector.GoToAccountLoginPage();

            if(!IsPostBack)
                LoadCurrentUser();
        }
예제 #16
0
파일: HomePresenter.cs 프로젝트: SPKT/MHX2
        public List<Alert> GetAlertToShow(Account account)
        {
            List<Account> listFriend = new List<Account>();
            List<Alert> list = new List<Alert>();
            listFriend = _friendService.SearchFriend(account);
            foreach (Account friend in listFriend)
            {
                list = _alertService.GetAlertsByAccountID(friend.AccountID);
            }

            return list;
        }
예제 #17
0
 public List<PrivacyFlagType> GetListPrivacyFlagType(Account Account, Account AccountBeingViewed)
 {
     List<PrivacyFlagType> listPrivacyFlagTypeSelect = new List<PrivacyFlagType>();
     List<PrivacyFlagType> listPrivacyFlagType = _privacyRepository.GetPrivacyFlagTypes();
     List<PrivacyFlag> listPrivacyFlag=_privacyRepository.GetPrivacyFlagsByProfileID(_profileRepository.GetProfileByAccountID(AccountBeingViewed.AccountID).ProfileID);
     foreach (PrivacyFlagType priFlagType in listPrivacyFlagType)
     {
         if (ShouldShow(priFlagType.PrivacyFlagTypeID, AccountBeingViewed, Account, listPrivacyFlag))
             listPrivacyFlagType.Add(priFlagType);
     }
     return listPrivacyFlagType;
 }
예제 #18
0
파일: Home.aspx.cs 프로젝트: ngocpq/MHX2
 public void DisplayCurrentAccount(SPKTCore.Core.Domain.Account account)
 {
     if (account != null)
     {
         lblXinChao.Text     = "Xin chào: ";
         lbtnProfile.Visible = false;
         lbtnProfile.Text    = account.UserName;
     }
     else
     {
         lblXinChao.Text = "Chưa Đăng Nhập";
     }
 }
예제 #19
0
파일: FriendService.cs 프로젝트: SPKT/MHX2
 //moi
 public int CountFiendMutual(Account account, Account accountview)
 {
     int dem=0;
        foreach (Account a in SearchFriend(account))
        {
        foreach (Account ac in SearchFriend(accountview))
        {
            if (a.AccountID == ac.AccountID)
                dem++;
        }
        }
        return dem;
 }
예제 #20
0
        public void Init(IHome View)
        {
            _view = View;

            if(_userSession.LoggedIn==true)
            {
                account=_userSession.CurrentUser;

            }
            else
                account=null;
            _view.DisplayCurrentAccount(account);
        }
예제 #21
0
 public void LoadDisplay(Account account)
 {
     _ac = new SPKTCore.Core.DataAccess.Impl.AccountRepository();
     _account = account;
     lblName.Text = account.DisplayName;
     lblUsername.Text = account.UserName;
     lblCreateDate.Text = account.CreateDate.ToString();
     lblFriendID.Text = account.AccountID.ToString();
     if (_ac.fullname(account.AccountID) == null)
     {
         lblName.Text = account.UserName;
     }
     lblemail.Text = account.Email;
 }
예제 #22
0
 public List<StatusUpdate> GetStatusUpdateByID(Account Account, Account AccountBeingViewer, bool IsSender)
 {
     List<StatusUpdate> listStatus = new List<StatusUpdate>();
     List<StatusUpdate> Status=new List<StatusUpdate>();
     if(IsSender)
         Status=_statusRepository.GetStatusUpdatesBySenderID(AccountBeingViewer.AccountID);
     else
         Status = _statusRepository.GetStatusUpdatesByAccountID(AccountBeingViewer.AccountID);
     foreach(StatusUpdate status in Status)
     {
         if(_privacyService.ShouldShowStatus(status,AccountBeingViewer, Account))
             listStatus.Add(status);
     }
     return listStatus;
 }
예제 #23
0
파일: FileShare.cs 프로젝트: SPKT/MHX2
 public void LoadFile()
 {
     account = _userSession.CurrentUser;
     if (_userSession.CurrentUser != null)
     {
         if (_webContext.AccountID > 0 && _webContext.AccountID != _userSession.CurrentUser.AccountID)
         {
             _view.LoadFileShare(_af.GetFolderByAccountShared(_webContext.AccountID));
         }
         else
             _view.LoadFileShare(_af.GetFolderByAccountShared(account.AccountID));
     }
     else
         _view.LoadFileShare(_af.GetFolderByAccountShared(_webContext.AccountID));
 }
예제 #24
0
파일: FileList.cs 프로젝트: SPKT/MHX2
 public void LoadFile()
 {
     account = _userSession.CurrentUser;
     if (_userSession.CurrentUser != null)
     {
         if (_webContext.AccountID > 0 && _webContext.AccountID != _userSession.CurrentUser.AccountID)
         {
             _view.LoadFile(_fr.GetFilesByAccountID(_webContext.AccountID));
         }
         else
             _view.LoadFile(_fr.GetFilesByAccountID(account.AccountID));
     }
     else
         _view.LoadFile(_fr.GetFilesByAccountID(_webContext.AccountID));
 }
예제 #25
0
        //moi
        public List<Account> FriendInv(Account account)
        {
            _accountRepository = new AccountRepository();
            List<Account> list = new List<Account>();
            using (SPKTDataContext dc = conn.GetContext())
            {
                IEnumerable<Account> ac = (from a in dc.FriendInvitations
                                           join b in dc.Accounts on a.AccountID equals b.AccountID
                                           where (a.Email == account.Email && a.BecameAccoutnID == 0)
                                           select _accountRepository.GetAccountByID(a.AccountID)).Distinct();
                list = ac.ToList();
            }

            return list;
        }
예제 #26
0
        public void RecoverPassword(string Email)
        {
            SPKTCore.Core.Domain.Account account = _accountRepository.GetAccountByEmail(Email);

            if (account != null)
            {
                _email.SendPasswordReminderEmail(account.Email, account.Password, account.UserName);
                _view.ShowRecoverPasswordPanel(false);
                _view.ShowMessage("An email was sent to your account!");
            }
            else
            {
                _view.ShowRecoverPasswordPanel(true);
                _view.ShowMessage("We couldn't find the account you requested.");
            }
        }
예제 #27
0
        protected void Page_Load(object sender, EventArgs e)
        {
            _profileRepository = new ProfileRepository();
            _userSession =new UserSession();
            _accountRepository = new AccountRepository();
            _webContext = new WebContext();

            //load an image by passed in accountid
            //if (_webContext.AccoundIdToInvite> 0)
            //{
            //    accountID = _webContext.AccoundIdToInvite;
            //    profile = _profileRepository.GetProfileByAccountID(accountID);
            //    account = _accountRepository.GetAccountByID(accountID);
            //}

            if (_webContext.AccountID> 0)
            {
                accountID = _webContext.AccountID;
                profile = _profileRepository.GetProfileByAccountID(accountID);
                account = _accountRepository.GetAccountByID(accountID);
            }
            //get an image for the current user
            else
            {
                if (_userSession.LoggedIn && _userSession.CurrentUser != null)
                {
                    account = _userSession.CurrentUser;
                    profile = _profileRepository.GetProfileByAccountID(account.AccountID);
                }
            }

            //show the appropriate image
            if (_webContext.ShowGravatar || (profile != null &&  profile.UseGrAvatar == 1))
            {
                Response.Redirect(GetGravatarURL());
            }
            else if (profile != null && profile.Avatar != null)
            {
                Response.Clear();
                Response.ContentType = profile.AvatarMimeType;
                Response.BinaryWrite(profile.Avatar.ToArray());
            }
            else
            {
                Response.Redirect("~/Image/ALIEN_01_01.jpg");
            }
        }
예제 #28
0
 public void LoadDisplay(Account account)
 {
     IRedirector r = new Redirector();
     _ac = new SPKTCore.Core.DataAccess.Impl.AccountRepository();
     _account = account;
     lblName.Text = account.DisplayName;
     linkAvatar.HRef = r.GetProfileURL(account.UserName);
     lblUsername.Text = account.UserName;
     linkUsername.HRef = r.GetProfileURL(account.UserName);
     lblCreateDate.Text = account.CreateDate.ToString();
     lblFriendID.Text = account.AccountID.ToString();
     if (_ac.fullname(account.AccountID) == null)
     {
         lblName.Text = account.UserName;
     }
     lblemail.Text = account.Email;
 }
예제 #29
0
        public bool IsFriend(Account account, Account accountBeingViewed)
        {
            if (account == null)
                return false;

            if (accountBeingViewed == null)
                return false;

            if (account.AccountID == accountBeingViewed.AccountID && account.AccountID!=_userSession.CurrentUser.AccountID)
                return true;
            else
            {
                Friend friend = _friendRepository.GetFriendsByAccountID(accountBeingViewed.AccountID).Where(f => f.MyFriendAccountID == account.AccountID).FirstOrDefault();
                if (friend != null)
                    return true;
            }
            return false;
        }
예제 #30
0
파일: HomePresenter.cs 프로젝트: SPKT/MHX2
 public List<StatusUpdate> GetStatusToShow(Account Account)
 {
     LogUtil.Logger.Writeln("GetStatusToShow: ");
     List<Account> listFriend = new List<Account>();
     List<StatusUpdate> list = new List<StatusUpdate>();
     listFriend = _friendService.SearchFriend(account);
     List<StatusUpdate> listStatus = new List<StatusUpdate>();
     foreach (Account friend in listFriend)
     {
         list= _StatusUpdateService.GetStatusUpdateByID(Account, friend, true);
         listStatus.AddRange(list);
     }
     list = _StatusUpdateService.GetStatusUpdateByID(Account, Account, true);
     listStatus.AddRange(list);
     listStatus.Sort(new Comparison<StatusUpdate>((st1, st2) => st2.CreateDate.CompareTo(st1.CreateDate)));
     LogUtil.Logger.Writeln(".  - GetStatusToShow return count: "+listStatus.Count.ToString());
     return listStatus;
 }
예제 #31
0
        public void LoadDisplay(Account account)
        {
            _ac = new SPKTCore.Core.DataAccess.Impl.AccountRepository();
            _account = account;
            //_profile = profile;
            //ibInviteFriend.Attributes.Add("FriendsID", _account.AccountID.ToString());
            //ibDelete.Attributes.Add("FriendsID", _account.AccountID.ToString());
            //litAccountID.Text = account.AccountID.ToString();
               // if (_profile.FullName == null)

            lblName.Text = account.UserName;
            //lblUsername.Text = account.UserName;
            lblCreateDate.Text = account.CreateDate.ToString();
            //lblName.Text = account.Email;
            //lblCreateDate.Text = account.CreateDate.ToString();
            //imgAvatar.ImageUrl += "?AccountID=" + account.AccountID.ToString();
            //lblUsername.Text = account.UserName;
            lblFriendID.Text = account.AccountID.ToString();
        }
예제 #32
0
        public void Register(string Username, string Password, string Email, EnumObject Object,
                             string Captcha)
        {
            if (Captcha == _webContext.CaptchaImageText)
            {
                SPKTCore.Core.Domain.Account a =
                    new SPKTCore.Core.Domain.Account();
                a.Email       = Email;
                a.UserName    = Username;
                a.DisplayName = a.UserName;
                a.CreateDate  = DateTime.Now;
                a.Password    = Password.Encrypt(Username);
                a.UseAuthenticationService = false;

                if (_accountService.EmailInUse(Email))
                {
                    _view.ShowErrorMessage("Mail đã được sử dụng");
                }
                else if (_accountService.UsernameInUse(Username))
                {
                    _view.ShowErrorMessage("Tên đăng nhập này đã được sử dụng");
                }
                else
                {
                    string permission = Object.ToString();
                    _accountRepository.SaveAccount(a);
                    if (friendInvitation != null)
                    {
                        _friendService.CreateFriendFromFriendInvitation(new Guid(_webContext.FriendshipRequest), a);
                    }
                    _accountService.Register(a, permission);
                    _redirector.GoToAccountLoginPage();
                }
            }
            else
            {
                _view.ShowErrorMessage("CAPTCHA bạn nhập không đúng! Vui lòng nhập lại");
            }
        }
예제 #33
0
        public void Init(IEditAccount View, bool IsPostBack)
        {
            _view = View;
            if (_userSession.LoggedIn)
            {
                if (_userSession.CurrentUser != null)
                {
                    account = _userSession.CurrentUser;
                    List<Permission> permissions = _permissionRepository.GetPermissionsByAccountID(_userSession.CurrentUser.AccountID);
                    foreach (Permission p in permissions)
                    {
                        if (_permissionRepository.GetPermissionByName("OutSider").PermissionID == p.PermissionID)
                            _view.DisplayAuthentical(false);
                    }
                }
                else
                    _redirector.GoToAccountLoginPage();

                if (!IsPostBack)
                    LoadCurrentUser();
            }
            else
            _redirector.GoToAccountLoginPage();
        }