Пример #1
0
    public void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            NotifyBounces(sender, e);

            accountName.Text = string.Format("Hello, {0}!", Renderer.Render(SessionManager.Account.Name));
            accountImage.Src = string.Format("AccountPictureThumbnail.aspx?id={0}", SessionManager.Account.PictureId);

            groupsView.AccountId    = SessionManager.AccountId;
            friendsView.AccountId   = SessionManager.AccountId;
            broadcastView.AccountId = SessionManager.AccountId;

            TransitAccountNumbers numbers = SessionManager.GetInstance <TransitAccountNumbers, int>(
                SessionManager.AccountId, SessionManager.AccountService.GetAccountNumbersByAccountId);

            accountFirstDegree.Visible = (numbers.FirstDegreeCount > 0);
            accountFirstDegree.Text    = string.Format("{0} friend{1} in your personal network",
                                                       numbers.FirstDegreeCount,
                                                       numbers.FirstDegreeCount != 1 ? "s" : string.Empty);

            accountSecondDegree.Visible = (numbers.SecondDegreeCount > 0);
            accountSecondDegree.Text    = string.Format("{0} friend{1} in your extended network",
                                                        numbers.SecondDegreeCount,
                                                        numbers.SecondDegreeCount != 1 ? "s" : string.Empty);

            accountAllDegrees.Text = string.Format("{0} {1} to make new friends with",
                                                   numbers.NewCount > 0 ? numbers.NewCount.ToString() : "no",
                                                   numbers.NewCount != 1 ? "people" : "person");

            accountDiscussionThreads.Visible = (numbers.PostsCount > 0);
            accountDiscussionThreads.Text    = string.Format("{0} discussion post{1}",
                                                             numbers.PostsCount, numbers.PostsCount != 1 ? "s" : string.Empty);
        }
    }
Пример #2
0
 public TransitAccountNumbers GetAccountNumbersByAccountId(string ticket, int id)
 {
     using (SnCore.Data.Hibernate.Session.OpenConnection())
     {
         TransitAccountNumbers t_result = new TransitAccountNumbers();
         ISession session = SnCore.Data.Hibernate.Session.Current;
         ManagedSecurityContext sec = new ManagedSecurityContext(session, ticket);
         
         ManagedAccount acct = new ManagedAccount(session, id);
         
         // second degree count
         t_result.SecondDegreeCount = acct.GetNDegreeCount(sec, 2);
         // first degree count
         t_result.FirstDegreeCount = session.CreateQuery(
             string.Format("SELECT COUNT(*) FROM AccountFriend AccountFriend" +
                 " WHERE (AccountFriend.Account.Id = {0} OR AccountFriend.Keen.Id = {0})",
                 id)).UniqueResult<int>();
         // all accounts count
         t_result.AllCount = session.CreateQuery(
             "SELECT COUNT(*) FROM Account Account").UniqueResult<int>();
         // discussion posts count
         DiscussionQueryOptions qopt = new DiscussionQueryOptions();
         qopt.AccountId = id;
         t_result.PostsCount = session.CreateQuery(
             string.Format("SELECT COUNT(*) FROM DiscussionPost DiscussionPost {0}", 
                 qopt.CountQuery)).UniqueResult<int>();
         return t_result;
     }
 }