public string RenderAccounts(TransitAccount[] accounts)
    {
        HtmlTable table = new HtmlTable();
        table.Border = 0;
        table.BorderColor = "White";
        HtmlTableRow row = new HtmlTableRow();
        table.Rows.Add(row);
        foreach (TransitAccount ta in accounts)
        {
            HtmlTableCell cell = new HtmlTableCell();
            cell.Controls.Add(new LiteralControl(string.Format(
                "<div><a href='AccountView.aspx?id={0}'>" +
                "<img border=0 style='width: 50%;' src='AccountPictureThumbnail.aspx?id={1}'></a></div>" +
                "<div class=sncore_link><a href='AccountView.aspx?id={0}'>{2}</a>", ta.Id, ta.PictureId, Render(ta.Name))));
            row.Cells.Add(cell);
            if (row.Cells.Count % 4 == 0)
            {
                row = new HtmlTableRow();
                table.Rows.Add(row);
            }
        }

        StringBuilder sb = new StringBuilder();
        StringWriter sw = new StringWriter(sb);
        table.RenderControl(new HtmlTextWriter(sw));
        return sb.ToString();
    }
Esempio n. 2
0
    public void Page_Load(object sender, EventArgs e)
    {
        accountSurveyAnswers.OnGetDataSource += new EventHandler(accountSurveyAnswers_OnGetDataSource);
        if (!IsPostBack)
        {
            SiteMapDataAttribute sitemapdata = new SiteMapDataAttribute();
            TransitSurvey        s           = Survey;

            if (AccountId > 0)
            {
                TransitAccount a = Account;
                accountName.Text = Renderer.Render(a.Name);
                accountImage.Src = string.Format("AccountPictureThumbnail.aspx?id={0}", a.PictureId);
                accountLink.HRef = string.Format("AccountView.aspx?id={0}", a.Id);
                this.Title       = string.Format("{0}'s {1}", Renderer.Render(a.Name), Renderer.Render(s.Name));

                sitemapdata.Add(new SiteMapDataAttributeNode("People", Request, "AccountsView.aspx"));
                sitemapdata.Add(new SiteMapDataAttributeNode(a.Name, Request, string.Format("AccountView.aspx?id={0}", a.Id)));
            }
            else
            {
                accountcolumn.Visible = false;
                this.Title            = string.Format("{0}", Renderer.Render(s.Name));
            }

            sitemapdata.Add(new SiteMapDataAttributeNode(s.Name, Request.Url));
            StackSiteMap(sitemapdata);

            surveyName.Text = Renderer.Render(s.Name);
            accountSurveyAnswers_OnGetDataSource(sender, e);
            accountSurveyAnswers.DataBind();
        }
    }
        public void TestNoVerifiedEmail()
        {
            ManagedAccount account = new ManagedAccount(Session);

            try
            {
                string         email      = GetNewEmailAddress();
                TransitAccount t_instance = new TransitAccount();
                t_instance.Password = GetNewString();
                t_instance.Name     = GetNewString();
                t_instance.Birthday = DateTime.UtcNow;
                int account_id = account.Create(email, t_instance, GetSecurityContext());

                account.AddDefaultPicture();

                TransitDiscussionPost t_post = GetTransitInstance();
                t_post.AccountId = account.Id;
                ManagedDiscussionPost m_post = new ManagedDiscussionPost(Session);
                m_post.CreateOrUpdate(t_post, account.GetSecurityContext());
            }
            finally
            {
                account.Delete(GetSecurityContext());
            }
        }
        [Test] // foodcandy bug #421 : Discuss: edit button not visible for author
        public void TestCanEdit()
        {
            ManagedAccount        account = new ManagedAccount(Session);
            ManagedDiscussionPost m_post  = new ManagedDiscussionPost(Session);

            try
            {
                string         email      = GetNewEmailAddress();
                TransitAccount t_instance = new TransitAccount();
                t_instance.Password = GetNewString();
                t_instance.Name     = GetNewString();
                t_instance.Birthday = DateTime.UtcNow;
                int account_id = account.Create(email, t_instance, GetSecurityContext());

                TransitDiscussionPost t_post = GetTransitInstance();
                t_post.AccountId = GetSecurityContext().Account.Id;
                m_post.CreateOrUpdate(t_post, GetSecurityContext());
                Session.Flush();

                ManagedDiscussionPost m_post1 = new ManagedDiscussionPost(Session, m_post.Id);

                TransitDiscussionPost t_post1 = m_post1.GetTransitInstance(GetSecurityContext());
                Assert.IsTrue(t_post1.CanDelete, "Owner should be able to delete his own message.");
                Assert.IsTrue(t_post1.CanEdit, "Owner should be able to edit his own message.");

                TransitDiscussionPost t_post2 = m_post1.GetTransitInstance(account.GetSecurityContext());
                Assert.IsFalse(t_post2.CanDelete, "User shouldn't be able to delete someone else's message.");
                Assert.IsFalse(t_post2.CanEdit, "User shouldn't be able to edit someone else's message.");
            }
            finally
            {
                account.Delete(GetSecurityContext());
                m_post.Delete(GetSecurityContext());
            }
        }
Esempio n. 5
0
    public void save_Click(object sender, EventArgs e)
    {
        TransitAccount ta = SessionManager.Account;

        ta.Birthday  = inputBirthday.SelectedDate;
        ta.Name      = inputName.Text;
        ta.City      = inputCity.Text;
        ta.Country   = inputCountry.SelectedValue;
        ta.State     = inputState.SelectedValue;
        ta.TimeZone  = inputTimeZone.SelectedTzIndex;
        ta.Signature = inputSignature.Text;
        ta.LCID      = int.Parse(inputLocale.SelectedValue);

        // overwrite the culture cookie
        Response.Cookies.Add(new HttpCookie(SessionManager.sSnCoreCulture, inputLocale.SelectedValue));

        if (ta.Signature.Length > inputSignature.MaxLength)
        {
            throw new Exception(string.Format("Signature may not exceed {0} characters.", inputSignature.MaxLength));
        }

        SessionManager.CreateOrUpdate <TransitAccount>(
            ta, SessionManager.AccountService.CreateOrUpdateAccount);
        Cache.Remove(string.Format("account:{0}", SessionManager.Ticket));
        Redirect("AccountManage.aspx");
    }
Esempio n. 6
0
    public void Page_Load(object sender, EventArgs e)
    {
        gridFriends.OnGetDataSource += new EventHandler(gridFriends_OnGetDataSource);

        if (!IsPostBack)
        {
            if (RequestId == 0)
            {
                RedirectToLogin();
                return;
            }

            TransitAccount ta = SessionManager.GetInstance <TransitAccount, int>(
                RequestAccountId, SessionManager.AccountService.GetAccountById);

            labelName.Text = string.Format("{0}'s Friends Activity", Render(ta.Name));

            GetData();

            SiteMapDataAttribute sitemapdata = new SiteMapDataAttribute();
            sitemapdata.Add(new SiteMapDataAttributeNode("Me Me", Request, "AccountManage.aspx"));
            sitemapdata.Add(new SiteMapDataAttributeNode("Friends Activity", Request.Url));
            StackSiteMap(sitemapdata);
        }
    }
    public void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (ParentId != 0)
            {
                TransitAccount account = SessionManager.AccountService.GetAccountById(
                    SessionManager.Ticket, ParentId);
                linkKeen.NavigateUrl = string.Format("AccountView.aspx?id={0}", account.Id.ToString());
                linkBack.NavigateUrl = (string.IsNullOrEmpty(ReturnUrl)) ? linkKeen.NavigateUrl : ReturnUrl;
                linkKeen.Text        = Renderer.Render(account.Name);
                imageKeen.ImageUrl   = string.Format("AccountPictureThumbnail.aspx?id={0}", account.PictureId);
                inputMessage.Text    = "Dear " + account.Name + "\n\nI would like to be your friend.\n\nThanks!\n";

                SiteMapDataAttribute sitemapdata = new SiteMapDataAttribute();
                sitemapdata.Add(new SiteMapDataAttributeNode("People", Request, "AccountsView.aspx"));
                sitemapdata.Add(new SiteMapDataAttributeNode(account.Name, Request, string.Format("AccountView.aspx?id={0}", account.Id)));
                sitemapdata.Add(new SiteMapDataAttributeNode("Friend Request", Request.Url));
                StackSiteMap(sitemapdata);
            }
        }

        SetDefaultButton(manageAdd);

        if (!SessionManager.HasVerified())
        {
            ReportWarning("You don't have any verified e-mail addresses and/or profile photos.\n" +
                          "You must add/confirm a valid e-mail address and upload a profile photo before making friends.");

            manageAdd.Enabled = false;
        }
    }
    protected void create_Click(object sender, EventArgs e)
    {
        if (inputPassword.Text.Trim() != inputPassword2.Text.Trim())
        {
            throw new ArgumentException("Passwords don't match.");
        }

        TransitAccount ta = new TransitAccount();

        ta.Name     = inputName.Text;
        ta.Birthday = inputBirthday.SelectedDate;
        ta.Password = inputPassword.Text.Trim();


        SessionManager.AccountService.CreateAccountWithInvitation(
            RequestId,
            Code,
            ta);

        panelCreate.Visible = false;

        string ticket = SessionManager.AccountService.Login(inputEmailAddress.Text.Trim(), inputPassword.Text.Trim());

        SessionManager.Login(ticket, false);
        Redirect("AccountCreateInvitationWelcome.aspx");
    }
    public void Page_Load(object sender, EventArgs e)
    {
        if (RequestId == 0)
        {
            throw new Exception("Missing account.");
        }

        gridManage.OnGetDataSource += new EventHandler(gridManage_OnGetDataSource);

        if (!IsPostBack)
        {
            TransitAccount a = SessionManager.GetInstance <TransitAccount, AccountService.ServiceQueryOptions, int>(
                RequestId, SessionManager.AccountService.GetAccountById);

            this.Title = string.Format("{0}'s Pictures", Renderer.Render(a.Name));

            GetData(sender, e);

            SiteMapDataAttribute sitemapdata = new SiteMapDataAttribute();
            sitemapdata.Add(new SiteMapDataAttributeNode("People", Request, "AccountsView.aspx"));
            sitemapdata.Add(new SiteMapDataAttributeNode(a.Name, Request, string.Format("AccountView.aspx?id={0}", a.Id)));
            sitemapdata.Add(new SiteMapDataAttributeNode("Pictures", Request.Url));
            StackSiteMap(sitemapdata);
        }
    }
Esempio n. 10
0
    public void Page_Load(object sender, EventArgs e)
    {
        SetDefaultButton(inputCreateOpenId);

        if (!IsPostBack)
        {
            if (!string.IsNullOrEmpty(Request["betapassword"]))
            {
                inputBetaPassword.Attributes["value"] = Request["betapassword"];
            }

            if (!string.IsNullOrEmpty(Request["ConsumerUrl"]))
            {
                inputOpenId.Text    = Request["ConsumerUrl"];
                inputOpenId.Enabled = false;
            }

            panelBeta.Visible = SessionManager.AccountService.IsBetaPasswordSet();

            linkAdministrator.OnClientClick =
                string.Format("location.href='mailto:{0}';",
                              SessionManager.GetCachedConfiguration(
                                  "SnCore.Admin.EmailAddress", "*****@*****.**"));

            TrySetControlValueFromCookie("SnCore.AccountCreate.Name", inputName);
            TrySetControlValueFromCookie("SnCore.AccountCreate.BetaPassword", inputBetaPassword);
            TrySetControlValueFromCookie("SnCore.AccountCreate.Birthday", inputBirthday);
            TrySetControlValueFromCookie("SnCore.AccountCreate.Email", inputEmailAddress);

            string openidmode = Request["openid.mode"];
            if (!string.IsNullOrEmpty(openidmode))
            {
                NameValueCollectionSerializer serializer = new NameValueCollectionSerializer(Request.Params);

                TransitAccount ta = new TransitAccount();
                ta.Name     = inputName.Text;
                ta.Birthday = inputBirthday.SelectedDate;

                int id = SessionManager.AccountService.CreateAccountWithOpenId(
                    inputBetaPassword.Text.Trim(),
                    SessionManager.OpenIdToken,
                    serializer.Names,
                    serializer.Values,
                    inputEmailAddress.Text.Trim(),
                    ta);

                string ticket = ManagedAccount.GetTicketFromAccountId(id);
                SessionManager.Login(ticket, false);
                Redirect("AccountCreateWelcome.aspx");
            }

            if (SessionManager.IsLoggedIn)
            {
                ReportInfo("You're already logged-in. Click <a href='AccountManage.aspx'>here</a> to continue.");
                panelCreateOpenId.Enabled = false;
                return;
            }
        }
    }
Esempio n. 11
0
    public void invite_Click(object sender, EventArgs e)
    {
        List <string>       invitations = new List <string>();
        List <string>       failures    = new List <string>();
        ExceptionCollection exceptions  = new ExceptionCollection();

        foreach (string email in inputEmailAddress.Text.Split(";,\n\r".ToCharArray()))
        {
            if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(email.Trim()))
            {
                continue;
            }

            try
            {
                TransitAccount existing = SessionManager.AccountService.FindByEmail(
                    SessionManager.Ticket, email);

                exceptions.Add(new Exception(string.Format(
                                                 "<a href='AccountView.aspx?id={0}'>{2} &lt;{3}&gt;</a> is a member! " +
                                                 "<a href='AccountFriendRequestEdit.aspx?pid={0}&ReturnUrl={1}'>&#187; Add to Friends</a>",
                                                 existing.Id, Request.Url.PathAndQuery, existing.Name, email)));

                continue;
            }
            catch
            {
            }

            try
            {
                MailAddress address = new MailAddress(email);
                TransitAccountInvitation invitation = new TransitAccountInvitation();
                invitation.Code      = Guid.NewGuid().ToString();
                invitation.Email     = email;
                invitation.Message   = inputMessage.Text;
                invitation.AccountId = SessionManager.AccountId;
                SessionManager.CreateOrUpdate <TransitAccountInvitation>(
                    invitation, SessionManager.AccountService.CreateOrUpdateAccountInvitation);
                invitations.Add(email);
            }
            catch (Exception ex)
            {
                failures.Add(email);
                exceptions.Add(new Exception(string.Format("Error inviting {0}: {1}", email, ex.Message), ex));
            }
        }

        if (invitations.Count > 0)
        {
            noticeManage.Info = string.Format("{0} invitation{1} sent",
                                              invitations.Count, invitations.Count == 1 ? string.Empty : "s");
        }

        GetData(sender, e);
        inputEmailAddress.Text = string.Join("\n", failures.ToArray());
        exceptions.Throw();
    }
Esempio n. 12
0
    public void Page_Load(object sender, EventArgs e)
    {
        SetDefaultButton(inputCreateOpenId);

        if (!IsPostBack)
        {
            if (!string.IsNullOrEmpty(Request["betapassword"]))
                inputBetaPassword.Attributes["value"] = Request["betapassword"];

            if (!string.IsNullOrEmpty(Request["ConsumerUrl"]))
            {
                inputOpenId.Text = Request["ConsumerUrl"];
                inputOpenId.Enabled = false;
            }

            panelBeta.Visible = SessionManager.AccountService.IsBetaPasswordSet();

            linkAdministrator.OnClientClick =
                string.Format("location.href='mailto:{0}';",
                   SessionManager.GetCachedConfiguration(
                        "SnCore.Admin.EmailAddress", "*****@*****.**"));

            TrySetControlValueFromCookie("SnCore.AccountCreate.Name", inputName);
            TrySetControlValueFromCookie("SnCore.AccountCreate.BetaPassword", inputBetaPassword);
            TrySetControlValueFromCookie("SnCore.AccountCreate.Birthday", inputBirthday);
            TrySetControlValueFromCookie("SnCore.AccountCreate.Email", inputEmailAddress);

            string openidmode = Request["openid.mode"];
            if (!string.IsNullOrEmpty(openidmode))
            {
                NameValueCollectionSerializer serializer = new NameValueCollectionSerializer(Request.Params);
                
                TransitAccount ta = new TransitAccount();
                ta.Name = inputName.Text;
                ta.Birthday = inputBirthday.SelectedDate;
 
                int id = SessionManager.AccountService.CreateAccountWithOpenId(
                    inputBetaPassword.Text.Trim(),
                    SessionManager.OpenIdToken,
                    serializer.Names,
                    serializer.Values,
                    inputEmailAddress.Text.Trim(),
                    ta);

                string ticket = ManagedAccount.GetTicketFromAccountId(id);
                SessionManager.Login(ticket, false);
                Redirect("AccountCreateWelcome.aspx");
            }

            if (SessionManager.IsLoggedIn)
            {
                ReportInfo("You're already logged-in. Click <a href='AccountManage.aspx'>here</a> to continue.");
                panelCreateOpenId.Enabled = false;
                return;
            }
        }
    }
 public override void SetInstance(CampaignAccountRecepient value)
 {
     CampaignId = value.Campaign.Id;
     AccountId  = value.Account.Id;
     Sent       = value.Sent;
     Created    = value.Created;
     Modified   = value.Modified;
     LastError  = value.LastError;
     mAccount   = new TransitAccount(value.Account);
     base.SetInstance(value);
 }
Esempio n. 14
0
    public void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            TransitAccount ta = SessionManager.AccountService.GetAccountById(
                SessionManager.Ticket, AccountId);

            SiteMapDataAttribute sitemapdata = new SiteMapDataAttribute();
            sitemapdata.Add(new SiteMapDataAttributeNode("People", Request, "AccountsView.aspx"));
            sitemapdata.Add(new SiteMapDataAttributeNode(ta.Name, Request, string.Format("AccountView.aspx?id={0}", ta.Id)));
            sitemapdata.Add(new SiteMapDataAttributeNode("Attributes", Request, string.Format("AccountAttributesManage.aspx?id={0}", ta.Id)));

            DomainClass cs = SessionManager.GetDomainClass("AccountAttribute");
            inputUrl.MaxLength = cs["Url"].MaxLengthInChars;

            linkBack.NavigateUrl = string.Format("AccountAttributesManage.aspx?id={0}", AccountId);

            List <TransitAttribute> attributes = SessionManager.ObjectService.GetAttributes(
                SessionManager.Ticket, null);

            if (RequestId == 0)
            {
                attributes.Insert(0, new TransitAttribute());
            }

            listAttributes.DataSource = attributes;
            listAttributes.DataBind();

            if (RequestId > 0)
            {
                TransitAccountAttribute attribute = SessionManager.AccountService.GetAccountAttributeById(
                    SessionManager.Ticket, RequestId);
                inputValue.Text        = Renderer.Render(attribute.Value);
                inputUrl.Text          = Renderer.Render(attribute.Url);
                inputDefaultUrl.Text   = Renderer.Render(attribute.Attribute.DefaultUrl);
                inputDefaultValue.Text = Renderer.Render(attribute.Attribute.DefaultValue);
                ListItemManager.SelectAdd(listAttributes, attribute.AttributeId);
                listAttributes.Enabled = false;
                previewImage.ImageUrl  = string.Format("SystemAttribute.aspx?id={0}", attribute.AttributeId);
                previewImage.Visible   = true;
                sitemapdata.Add(new SiteMapDataAttributeNode(attribute.Attribute.Name, Request.Url));
            }
            else
            {
                sitemapdata.Add(new SiteMapDataAttributeNode("New Attribute", Request.Url));
            }

            StackSiteMap(sitemapdata);
        }

        SetDefaultButton(manageAdd);
    }
Esempio n. 15
0
    public string GetDataObjectName()
    {
        switch (Feature.DataObjectName)
        {
        case "AccountFeed":
        {
            TransitAccountFeed t_instance = SessionManager.GetInstance <TransitAccountFeed, int>(
                Feature.DataRowId, SessionManager.SyndicationService.GetAccountFeedById);
            return(t_instance.Name);
        }

        case "AccountFeedItem":
        {
            TransitAccountFeedItem t_instance = SessionManager.GetInstance <TransitAccountFeedItem, int>(
                Feature.DataRowId, SessionManager.SyndicationService.GetAccountFeedItemById);
            return(t_instance.Title);
        }

        case "Account":
        {
            TransitAccount t_instance = SessionManager.GetInstance <TransitAccount, int>(
                Feature.DataRowId, SessionManager.AccountService.GetAccountById);
            return(t_instance.Name);
        }

        case "AccountEvent":
        {
            TransitAccountEvent t_instance = SessionManager.GetInstance <TransitAccountEvent, int, long>(
                Feature.DataRowId, 0, SessionManager.EventService.GetAccountEventById);
            return(t_instance.Name);
        }

        case "AccountGroup":
        {
            TransitAccountGroup t_instance = SessionManager.GetInstance <TransitAccountGroup, int>(
                Feature.DataRowId, SessionManager.GroupService.GetAccountGroupById);
            return(t_instance.Name);
        }

        case "Place":
        {
            TransitPlace t_instance = SessionManager.GetInstance <TransitPlace, int>(
                Feature.DataRowId, SessionManager.PlaceService.GetPlaceById);
            return(t_instance.Name);
        }
        }

        return(string.Empty);
    }
Esempio n. 16
0
    public void Page_Load(object sender, EventArgs e)
    {
        gridManage.OnGetDataSource += new EventHandler(gridManage_OnGetDataSource);
        if (!IsPostBack)
        {
            TransitAccountBlog blog = AccountBlog;

            if (blog == null)
            {
                Response.StatusCode = 404;
                Response.End();
                return;
            }

            labelBlog.Text            = Renderer.Render(blog.Name);
            labelBlogDescription.Text = Renderer.Render(blog.Description);

            TransitAccount a = SessionManager.GetInstance <TransitAccount, int>(
                blog.AccountId, SessionManager.AccountService.GetAccountById);

            labelAccountName.Text = Renderer.Render(a.Name);
            linkAccount.HRef      = string.Format("AccountView.aspx?id={0}", a.Id);
            imageAccount.Src      = string.Format("AccountPictureThumbnail.aspx?id={0}", a.PictureId);

            licenseView.AccountId = a.Id;

            linkRelRss.Title = this.Title = string.Format("{0}'s {1}", Renderer.Render(a.Name), Renderer.Render(blog.Name));

            GetData(sender, e);

            if (SessionManager.IsAdministrator)
            {
                linkFeature.Text = (LatestAccountBlogFeature != null)
                    ? string.Format("Feature &#187; Last on {0}", Adjust(LatestAccountBlogFeature.Created).ToString("d"))
                    : "Feature &#187; Never Featured";
            }

            linkRelRss.NavigateUrl  = string.Format("AccountBlogRss.aspx?id={0}", RequestId);
            linkEdit.NavigateUrl    = string.Format("AccountBlogEdit.aspx?id={0}", RequestId);
            linkPostNew.NavigateUrl = string.Format("AccountBlogPost.aspx?bid={0}", RequestId);

            SiteMapDataAttribute sitemapdata = new SiteMapDataAttribute();
            sitemapdata.Add(new SiteMapDataAttributeNode("Blogs", Request, "AccountFeedItemsView.aspx"));
            sitemapdata.Add(new SiteMapDataAttributeNode(blog.Name, Request.Url));
            StackSiteMap(sitemapdata);
        }
    }
Esempio n. 17
0
    public void Page_Load(object sender, EventArgs e)
    {
        gridManage.OnGetDataSource += new EventHandler(gridManage_OnGetDataSource);
        if (!IsPostBack)
        {
            TransitAccountFeed f = AccountFeed;
            labelFeed.Text            = Renderer.Render(f.Name);
            labelFeed.NavigateUrl     = f.LinkUrl;
            labelFeedDescription.Text = Renderer.Render(f.Description);

            licenseView.AccountId = f.AccountId;

            GetDataPublish(sender, e);

            TransitFeedType t = SessionManager.GetInstance <TransitFeedType, string>(
                f.FeedType, SessionManager.SyndicationService.GetFeedTypeByName);

            gridManage.RepeatColumns = t.SpanColumns;
            gridManage.RepeatRows    = t.SpanRows;

            TransitAccount a = SessionManager.GetInstance <TransitAccount, int>(
                f.AccountId, SessionManager.AccountService.GetAccountById);

            labelAccountName.Text = Renderer.Render(a.Name);
            linkAccount.HRef      = string.Format("AccountView.aspx?id={0}", a.Id);
            imageAccount.Src      = string.Format("AccountPictureThumbnail.aspx?id={0}", a.PictureId);

            this.Title = string.Format("{0}'s {1}", Renderer.Render(a.Name), Renderer.Render(f.Name));

            gridManage.VirtualItemCount = SessionManager.GetCount <TransitAccountFeedItem, int>(
                RequestId, SessionManager.SyndicationService.GetAccountFeedItemsCount);
            gridManage_OnGetDataSource(sender, e);
            gridManage.DataBind();

            GetDataFeature(sender, e);

            redirect.AccountId     = f.AccountId;
            redirect.TargetUri     = string.Format("AccountFeedView.aspx?id={0}", f.Id);
            linkRelRss.NavigateUrl = string.Format("AccountFeedRss.aspx?id={0}", f.Id);

            SiteMapDataAttribute sitemapdata = new SiteMapDataAttribute();
            sitemapdata.Add(new SiteMapDataAttributeNode("Blogs", Request, "AccountFeedItemsView.aspx"));
            sitemapdata.Add(new SiteMapDataAttributeNode(f.Name, Request.Url));
            StackSiteMap(sitemapdata);
        }
    }
Esempio n. 18
0
        public Facebook.Schema.user GetUser(string[] cookieNames, string[] cookieValues)
        {
            using (SnCore.Data.Hibernate.Session.OpenConnection())
            {
                ISession session = SnCore.Data.Hibernate.Session.Current;
                Facebook.Session.ConnectSession facebookSession = new Facebook.Session.ConnectSession(
                    ManagedConfiguration.GetValue(session, "Facebook.APIKey", ""),
                    ManagedConfiguration.GetValue(session, "Facebook.Secret", ""));

                TransitAccount ta = new TransitAccount();
                NameValueCollectionSerializer facebookCookies = new NameValueCollectionSerializer(cookieNames, cookieValues);
                facebookSession.SessionKey = facebookCookies.Collection["session_key"];
                facebookSession.UserId = long.Parse(facebookCookies.Collection["user"]);
                
                Facebook.Rest.Api facebookAPI = new Facebook.Rest.Api(facebookSession);
                return facebookAPI.Users.GetInfo();
            }
        }
Esempio n. 19
0
        public Facebook.Schema.user GetUser(string[] cookieNames, string[] cookieValues)
        {
            using (SnCore.Data.Hibernate.Session.OpenConnection())
            {
                ISession session = SnCore.Data.Hibernate.Session.Current;
                Facebook.Session.ConnectSession facebookSession = new Facebook.Session.ConnectSession(
                    ManagedConfiguration.GetValue(session, "Facebook.APIKey", ""),
                    ManagedConfiguration.GetValue(session, "Facebook.Secret", ""));

                TransitAccount ta = new TransitAccount();
                NameValueCollectionSerializer facebookCookies = new NameValueCollectionSerializer(cookieNames, cookieValues);
                facebookSession.SessionKey = facebookCookies.Collection["session_key"];
                facebookSession.UserId     = long.Parse(facebookCookies.Collection["user"]);

                Facebook.Rest.Api facebookAPI = new Facebook.Rest.Api(facebookSession);
                return(facebookAPI.Users.GetInfo());
            }
        }
Esempio n. 20
0
 public void listCultures_ItemCommand(object source, CommandEventArgs e)
 {
     switch (e.CommandName)
     {
     case "SelectCulture":
         // update account culture
         if (SessionManager.IsLoggedIn)
         {
             TransitAccount t_account = SessionManager.Account;
             t_account.LCID = int.Parse(e.CommandArgument.ToString());
             SessionManager.CreateOrUpdate <TransitAccount>(
                 t_account, SessionManager.AccountService.CreateOrUpdateAccount);
         }
         // overwrite the cookie
         Response.Cookies.Add(new HttpCookie(SessionManager.sSnCoreCulture, e.CommandArgument.ToString()));
         Response.Redirect(Request.Url.PathAndQuery);
         break;
     }
 }
Esempio n. 21
0
    public void Page_Load(object sender, EventArgs e)
    {
        picturesView.OnGetDataSource += new EventHandler(picturesView_OnGetDataSource);
        if (!IsPostBack)
        {
            mPictureId = RequestId;
            GetPictureData(sender, e);
            GetPicturesData(sender, e);

            TransitAccountPicture p           = AccountPicture;
            TransitAccount        a           = Account;
            SiteMapDataAttribute  sitemapdata = new SiteMapDataAttribute();
            sitemapdata.Add(new SiteMapDataAttributeNode("People", Request, "AccountsView.aspx"));
            sitemapdata.Add(new SiteMapDataAttributeNode(a.Name, Request, string.Format("AccountView.aspx?id={0}", a.Id)));
            sitemapdata.Add(new SiteMapDataAttributeNode("Pictures", Request, string.Format("AccountPicturesView.aspx?id={0}", a.Id)));
            sitemapdata.Add(new SiteMapDataAttributeNode(p.Name, Request.Url));
            StackSiteMap(sitemapdata);
        }
    }
Esempio n. 22
0
    void GetPictureData(object sender, EventArgs e)
    {
        TransitAccountPicture p = GetAccountPicture();

        inputPicture.Src = string.Format("AccountPictureThumbnail.aspx?id={0}",
                                         p.Id);

        inputName.Text        = Renderer.Render(p.Name);
        inputDescription.Text = Renderer.Render(p.Description);
        inputCreated.Text     = SessionManager.Adjust(p.Created).ToString("d");
        inputCounter.Text     = p.Counter.Total.ToString();

        TransitAccount l = GetAccount();

        //discussionComments.ReturnUrl = string.Format("AccountPictureView.aspx?id={0}", PictureId);
        //discussionComments.DiscussionId = SessionManager.GetCount<TransitDiscussion, string, int>(
        //    typeof(AccountPicture).Name, PictureId, SessionManager.DiscussionService.GetOrCreateDiscussionId);
        //discussionComments.DataBind();
    }
Esempio n. 23
0
    public void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            SiteMapDataAttribute sitemapdata = new SiteMapDataAttribute();
            sitemapdata.Add(new SiteMapDataAttributeNode("Me Me", Request, "AccountManage.aspx"));
            sitemapdata.Add(new SiteMapDataAttributeNode("Flags", Request, "AccountFlagsManage.aspx"));

            inputType.DataSource = SessionManager.AccountService.GetAccountFlagTypes(
                SessionManager.Ticket, null);
            inputType.DataBind();

            string type = Request["type"];
            ListItemManager.TrySelect(inputType, type);

            TransitAccount account = SessionManager.AccountService.GetAccountById(
                SessionManager.Ticket, GetId("aid"));

            if (account == null)
            {
                ReportWarning("Account has already been deleted.");
                panelMessage.Visible = false;
                return;
            }

            linkKeen.NavigateUrl = string.Format("AccountView.aspx?id={0}", account.Id.ToString());
            linkKeen.Text        = Renderer.Render(account.Name);
            imageKeen.ImageUrl   = string.Format("AccountPictureThumbnail.aspx?id={0}&width=75&height=75", account.PictureId);

            inputDescription.Text = string.Format("Dear Administrator,\n\nI would like to report {0} from {1}. Please take a look at {2}.\n\nThx\n{3}",
                                                  Renderer.Render(Request["type"]), Renderer.Render(account.Name), Renderer.Render(Request["url"]), Renderer.Render(SessionManager.Account.Name));

            sitemapdata.Add(new SiteMapDataAttributeNode(string.Format("Report {0}",
                                                                       Renderer.Render(Request["type"])), Request.Url));

            linkBack.NavigateUrl = ReturnUrl;

            StackSiteMap(sitemapdata);
        }

        SetDefaultButton(manageAdd);
    }
Esempio n. 24
0
    public void Page_Load(object sender, EventArgs e)
    {
        gridManage.OnGetDataSource += new EventHandler(gridManage_OnGetDataSource);
        if (!IsPostBack)
        {
            TransitAccount ta = SessionManager.GetInstance <TransitAccount, int>(
                RequestAccountId, SessionManager.AccountService.GetAccountById);

            labelName.Text          = string.Format("{0}'s Favorite Places", Render(ta.Name));
            linkAccount.Text        = string.Format("&#187; Back to {0}", Render(ta.Name));
            linkAccount.NavigateUrl = string.Format("AccountView.aspx?id={0}", ta.Id);
            linkRelRss.NavigateUrl  = string.Format("AccountPlaceFavoritesRss.aspx?id={0}", ta.Id);
            GetData(sender, e);

            SiteMapDataAttribute sitemapdata = new SiteMapDataAttribute();
            sitemapdata.Add(new SiteMapDataAttributeNode("People", Request, "AccountsView.aspx"));
            sitemapdata.Add(new SiteMapDataAttributeNode(ta.Name, Request, string.Format("AccountView.aspx?id={0}", ta.Id)));
            sitemapdata.Add(new SiteMapDataAttributeNode("Favorite Places", Request.Url));
            StackSiteMap(sitemapdata);
        }
    }
Esempio n. 25
0
    protected void loginLogin_Click(object sender, EventArgs e)
    {
        try
        {
            string ticket;
            if (!string.IsNullOrEmpty(loginEmailAddress.Text))
            {
                ticket = SessionManager.AccountService.Login(loginEmailAddress.Text, loginPassword.Text.Trim());
                SessionManager.Login(ticket, loginRememberMe.Checked);

                TransitAccount ta = SessionManager.AccountService.GetAccount(ticket, true);
                if (ta != null && ta.IsPasswordExpired)
                {
                    Redirect(string.Format("AccountChangePassword.aspx?ReturnUrl={0}&PasswordHash={1}",
                                           Renderer.UrlEncode(ReturnUrl), Renderer.UrlEncode(ManagedAccount.GetPasswordHash(loginPassword.Text))));
                }
                else
                {
                    Redirect(ReturnUrl);
                }
            }
            else if (!string.IsNullOrEmpty(loginOpenId.Text))
            {
                // url root needs to be a case-sensitive match for the openid server trust
                TransitOpenIdRedirect redirect = SessionManager.AccountService.GetOpenIdRedirect(loginOpenId.Text, Request.Url.ToString());
                SessionManager.OpenIdToken   = redirect.Token;
                SessionManager.RememberLogin = loginRememberMe.Checked;
                Redirect(redirect.Url);
            }
            else
            {
                throw new ManagedAccount.AccessDeniedException();
            }
        }
        catch
        {
            SessionManager.Logout();
            throw;
        }
    }
Esempio n. 26
0
    public void loginLogin_Click(object sender, EventArgs e)
    {
        try
        {
            string ticket;
            if (!string.IsNullOrEmpty(loginEmailAddress.Text))
            {
                ticket = SessionManager.AccountService.Login(loginEmailAddress.Text.Trim(), loginPassword.Text.Trim());
                SessionManager.Login(ticket, loginRememberMe.Checked);

                TransitAccount ta = SessionManager.AccountService.GetAccount(ticket, true);
                if (ta != null && ta.IsPasswordExpired)
                {
                    throw new Exception("Password expired. You cannot reset it on the mobile site.");
                }
                else
                {
                    Redirect(ReturnUrl);
                }
            }
            else if (!string.IsNullOrEmpty(loginOpenId.Text))
            {
                // url root needs to be a case-sensitive match for the openid server trust
                TransitOpenIdRedirect redirect = SessionManager.AccountService.GetOpenIdRedirect(loginOpenId.Text, Request.Url.ToString());
                SessionManager.OpenIdToken   = redirect.Token;
                SessionManager.RememberLogin = loginRememberMe.Checked;
                Redirect(redirect.Url);
            }
            else
            {
                throw new Exception("Access Denied"); // todo: typed access denied exception
            }
        }
        catch
        {
            SessionManager.Logout();
            throw;
        }
    }
    public void Page_Load(object sender, EventArgs e)
    {
        discussionThreadView.OnGetDataSource += new EventHandler(gridManage_OnGetDataSource);

        if (!IsPostBack)
        {
            TopOfThreads = false;

            TransitAccount ta = SessionManager.GetInstance <TransitAccount, int>(
                AccountId, SessionManager.AccountService.GetAccountById);

            linkRelRss.Title       = this.Title = labelHeader.Text = string.Format("{0}'s Discussion Posts", Renderer.Render(ta.Name));
            linkRelRss.NavigateUrl = string.Format("AccountDiscussionThreadsRss.aspx?id={0}&toplevel={1}", ta.Id, TopOfThreads);
            GetData(sender, e);

            SiteMapDataAttribute sitemapdata = new SiteMapDataAttribute();
            sitemapdata.Add(new SiteMapDataAttributeNode("People", Request, "AccountsView.aspx"));
            sitemapdata.Add(new SiteMapDataAttributeNode(ta.Name, Request, string.Format("AccountView.aspx?id={0}", ta.Id)));
            sitemapdata.Add(new SiteMapDataAttributeNode("Discussion Posts", Request.Url));
            StackSiteMap(sitemapdata);
        }
    }
Esempio n. 28
0
    void GetPictureData(object sender, EventArgs e)
    {
        TransitAccountPicture p = AccountPicture;

        downloadPicture.HRef  = inputPicture.Src = string.Format("AccountPicture.aspx?id={0}", p.Id);
        inputName.Text        = Renderer.Render(p.Name);
        inputDescription.Text = Renderer.Render(p.Description);
        inputCreated.Text     = Adjust(p.Created).ToString("d");
        inputCounter.Text     = p.Counter.Total.ToString();

        TransitAccount l = Account;

        labelAccountName.Text = this.Title = string.Format("{0}: {1}",
                                                           Renderer.Render(l.Name), string.IsNullOrEmpty(p.Name) ? "Untitled" : Renderer.Render(p.Name));

        labelAccountName.Text = this.Title = string.Format("{0}: {1}",
                                                           Renderer.Render(l.Name), string.IsNullOrEmpty(p.Name) ? "Untitled" : Renderer.Render(p.Name));

        linkBack.NavigateUrl = string.Format("AccountView.aspx?id={0}", l.Id);
        linkBack.Text        = string.Format("&#187; Back to {0}", Renderer.Render(l.Name));
        linkComments.Visible = p.CommentCount > 0;
        linkComments.Text    = string.Format("&#187; {0} comment{1}",
                                             (p.CommentCount > 0) ? p.CommentCount.ToString() : "no",
                                             (p.CommentCount == 1) ? "" : "s");

        linkPrev.Enabled         = p.PrevId > 0;
        linkPrev.CommandArgument = p.PrevId.ToString();
        linkNext.Enabled         = p.NextId > 0;
        linkNext.CommandArgument = p.NextId.ToString();
        labelIndex.Text          = string.Format("{0} / {1}", p.Index + 1, p.Count);

        panelNavigator.Visible = (p.Index >= 0);

        discussionComments.ReturnUrl    = string.Format("AccountPictureView.aspx?id={0}", PictureId);
        discussionComments.DiscussionId = SessionManager.GetCount <TransitDiscussion, string, int>(
            typeof(AccountPicture).Name, PictureId, SessionManager.DiscussionService.GetOrCreateDiscussionId);
        discussionComments.DataBind();
    }
Esempio n. 29
0
    public void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            TransitAccountStory ts = SessionManager.GetInstance <TransitAccountStory, int>(
                RequestId, SessionManager.StoryService.GetAccountStoryById);

            TransitAccount acct = SessionManager.GetInstance <TransitAccount, int>(
                ts.AccountId, SessionManager.AccountService.GetAccountById);

            licenseView.AccountId       = acct.Id;
            picturesView.AccountStoryId = ts.Id;

            this.Title = string.Format("{0}'s {1}", Renderer.Render(acct.Name), Renderer.Render(ts.Name));

            storyName.Text    = Renderer.Render(ts.Name);
            storySummary.Text = RenderEx(ts.Summary);

            storyComments.DiscussionId = SessionManager.GetCount <TransitDiscussion, string, int>(
                typeof(AccountStory).Name, RequestId, SessionManager.DiscussionService.GetOrCreateDiscussionId);

            storyComments.DataBind();

            linkEdit.NavigateUrl      = string.Format("AccountStoryEdit.aspx?id={0}", ts.Id);
            linkAddPhotos.NavigateUrl = string.Format("AccountStoryPicturesManage.aspx?id={0}", ts.Id);

            panelOwner.Visible = SessionManager.IsLoggedIn &&
                                 (SessionManager.IsAdministrator || ts.AccountId == SessionManager.Account.Id);

            linkAuthor.NavigateUrl = string.Format("AccountView.aspx?id={0}", ts.AccountId);
            linkAuthor.Text        = string.Format("written by &#187; {0}", Renderer.Render(ts.AccountName));

            SiteMapDataAttribute sitemapdata = new SiteMapDataAttribute();
            sitemapdata.Add(new SiteMapDataAttributeNode("Stories", Request, "AccountStoriesView.aspx"));
            sitemapdata.Add(new SiteMapDataAttributeNode(ts.Name, Request.Url));
            StackSiteMap(sitemapdata);
        }
    }
Esempio n. 30
0
    public void Logout()
    {
        HttpCookie impersonateCookie = Request.Cookies[sSnCoreImpersonateCookieName];

        if (impersonateCookie != null)
        {
            Login(impersonateCookie.Value, false);
            Response.Cookies[sSnCoreImpersonateCookieName].Value   = string.Empty;
            Response.Cookies[sSnCoreImpersonateCookieName].Expires = new DateTime(1970, 1, 1);
            return;
        }

        if (IsLoggedIn)
        {
            Cache.Remove(string.Format("ticket:{0}", Ticket));
            Cache.Remove(string.Format("account:{0}", Ticket));
            Cache.Remove(string.Format("accountpermissions:{0}", Ticket));
            Response.Cookies[sSnCoreAuthCookieName].Value   = string.Empty;
            Response.Cookies[sSnCoreAuthCookieName].Expires = new DateTime(1970, 1, 1);
            mTicket  = string.Empty;
            mAccount = null;
        }
    }
    protected void create_Click(object sender, EventArgs e)
    {
        if (inputPassword.Text.Trim() != inputPassword2.Text.Trim())
        {
            throw new ArgumentException("Passwords don't match.");
        }

        TransitAccount ta = new TransitAccount();
        ta.Name = inputName.Text;
        ta.Birthday = inputBirthday.SelectedDate;
        ta.Password = inputPassword.Text.Trim();


        SessionManager.AccountService.CreateAccountWithInvitation(
            RequestId,
            Code,
            ta);

        panelCreate.Visible = false;

        string ticket = SessionManager.AccountService.Login(inputEmailAddress.Text.Trim(), inputPassword.Text.Trim());
        SessionManager.Login(ticket, false);
        Redirect("AccountCreateInvitationWelcome.aspx");
    }
Esempio n. 32
0
        public int CreateAccountWithFacebookAndEmail(string betapassword, string signature, string[] names, string[] values, string email, TransitAccount ta)
        {
            TransitFacebookLogin t_facebook = TryLoginFacebook(signature, names, values);
            using (SnCore.Data.Hibernate.Session.OpenConnection())
            {
                ISession session = SnCore.Data.Hibernate.Session.Current;

                string s = ManagedConfiguration.GetValue(session, "SnCore.Beta.Password", string.Empty);
                if (s != betapassword)
                {
                    throw new ManagedAccount.AccessDeniedException();
                }

                ManagedAccount acct = new ManagedAccount(session);
                acct.CreateWithFacebook(t_facebook.FacebookAccountId, email, ta, ManagedAccount.GetAdminSecurityContext(session));
                SnCore.Data.Hibernate.Session.Flush();
                return acct.Id;
            }
        }
Esempio n. 33
0
    public void invite_Click(object sender, EventArgs e)
    {
        List <string>       invitations = new List <string>();
        List <string>       failures    = new List <string>();
        ExceptionCollection exceptions  = new ExceptionCollection();

        foreach (string email in inputEmailAddress.Text.Split(";,\n\r".ToCharArray()))
        {
            if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(email.Trim()))
            {
                continue;
            }

            try
            {
                // account is a member

                TransitAccount existing = SessionManager.AccountService.FindByEmail(
                    SessionManager.Ticket, email);

                TransitAccountGroupAccountInvitation t_instance = new TransitAccountGroupAccountInvitation();
                t_instance.AccountId      = existing.Id;
                t_instance.AccountGroupId = GroupId;
                t_instance.Message        = inputMessage.Text;
                t_instance.RequesterId    = SessionManager.Account.Id;
                SessionManager.GroupService.CreateOrUpdateAccountGroupAccountInvitation(
                    SessionManager.Ticket, t_instance);
                continue;
            }
            catch
            {
            }

            try
            {
                MailAddress address = new MailAddress(email);
                TransitAccountInvitation invitation = new TransitAccountInvitation();
                invitation.Code           = Guid.NewGuid().ToString();
                invitation.Email          = email;
                invitation.Message        = inputMessage.Text;
                invitation.AccountId      = SessionManager.AccountId;
                invitation.AccountGroupId = GroupId;
                SessionManager.CreateOrUpdate <TransitAccountInvitation>(
                    invitation, SessionManager.AccountService.CreateOrUpdateAccountInvitation);
                invitations.Add(email);
            }
            catch (Exception ex)
            {
                failures.Add(email);
                exceptions.Add(new Exception(string.Format("Error inviting {0}: {1}", email, ex.Message), ex));
            }
        }

        if (invitations.Count > 0)
        {
            ReportInfo(string.Format("{0} invitation{1} sent",
                                     invitations.Count, invitations.Count == 1 ? string.Empty : "s"));
        }

        inputEmailAddress.Text = string.Join("\n", failures.ToArray());
        exceptions.Throw();
    }
Esempio n. 34
0
    public LocationEventArgs(TransitAccount account)
        : this(account.Country, account.State, account.City, string.Empty /* TODO */)
    {

    }
Esempio n. 35
0
 public static int CompareByLastLogin(TransitAccountActivity left, TransitAccountActivity right)
 {
     return(TransitAccount.CompareByLastLogin(left, right));
 }
Esempio n. 36
0
 public LocationWithOptionsEventArgs(TransitAccount account)
     : base(account)
 {
 }
Esempio n. 37
0
        public int CreateAccount(string betapassword, string emailaddress, TransitAccount ta)
        {
            using (SnCore.Data.Hibernate.Session.OpenConnection())
            {
                ISession session = SnCore.Data.Hibernate.Session.Current;

                string s = ManagedConfiguration.GetValue(session, "SnCore.Beta.Password", string.Empty);
                if (s != betapassword)
                {
                    throw new ManagedAccount.AccessDeniedException();
                }

                ManagedAccount acct = new ManagedAccount(session);
                acct.Create(emailaddress, ta, ManagedAccount.GetAdminSecurityContext(session));
                SnCore.Data.Hibernate.Session.Flush();
                return acct.Id;
            }
        }
Esempio n. 38
0
        public int CreateAccountWithOpenId(string betapassword, 
            string token, string[] names, string[] values,
            string email, TransitAccount ta)
        {
            string consumerurl = VerifyOpenId(token, names, values);
            using (SnCore.Data.Hibernate.Session.OpenConnection())
            {
                ISession session = SnCore.Data.Hibernate.Session.Current;

                string s = ManagedConfiguration.GetValue(session, "SnCore.Beta.Password", string.Empty);
                if (s != betapassword)
                {
                    throw new ManagedAccount.AccessDeniedException();
                }

                ManagedAccount acct = new ManagedAccount(session);
                acct.CreateWithOpenId(consumerurl, email, ta, ManagedAccount.GetAdminSecurityContext(session));
                SnCore.Data.Hibernate.Session.Flush();
                return acct.Id;
            }
        }
Esempio n. 39
0
        public int CreateAccountWithFacebook(string betapassword, string signature, string[] names, string[] values)
        {
            TransitFacebookLogin t_facebook = TryLoginFacebook(signature, names, values);
            using (SnCore.Data.Hibernate.Session.OpenConnection())
            {
                ISession session = SnCore.Data.Hibernate.Session.Current;

                string s = ManagedConfiguration.GetValue(session, "SnCore.Beta.Password", string.Empty);
                if (s != betapassword)
                {
                    throw new ManagedAccount.AccessDeniedException();
                }

                ManagedAccount acct = new ManagedAccount(session);

                // fetch account information
                Facebook.Session.ConnectSession facebookSession = new Facebook.Session.ConnectSession(
                    ManagedConfiguration.GetValue(session, "Facebook.APIKey", ""),
                    ManagedConfiguration.GetValue(session, "Facebook.Secret", ""));

                TransitAccount ta = new TransitAccount();
                NameValueCollectionSerializer facebookCookies = new NameValueCollectionSerializer(names, values);
                facebookSession.SessionKey = facebookCookies.Collection["session_key"];
                facebookSession.UserId = t_facebook.FacebookAccountId;
                Facebook.Rest.Api facebookAPI = new Facebook.Rest.Api(facebookSession);
                Facebook.Schema.user user = facebookAPI.Users.GetInfo();
                ta.Name = user.name;
                DateTime birthday = DateTime.Today;
                DateTime.TryParse(user.birthday_date, out birthday);
                ta.Birthday = birthday;
                acct.CreateWithFacebook(t_facebook.FacebookAccountId, user.proxied_email, 
                    ta, ManagedAccount.GetAdminSecurityContext(session));

                if (user.current_location != null)
                {
                    ta.City = user.current_location.city;

                    int country_id;
                    if (ManagedCountry.TryGetCountryId(session, user.current_location.country, out country_id))
                        ta.Country = user.current_location.country;
                    
                    int state_id;
                    if (ManagedState.TryGetStateId(session, user.current_location.state, user.current_location.country, out state_id))
                        ta.State = user.current_location.state;
                }

                if (user.picture_big != null)
                {
                    TransitAccountPicture t_picture = new TransitAccountPicture();
                    t_picture.AccountId = acct.Id;
                    ThumbnailBitmap bitmap = new ThumbnailBitmap(new Bitmap(user.picture_big));
                    t_picture.Bitmap = bitmap.Bitmap;
                    t_picture.Thumbnail = bitmap.Thumbnail;
                    t_picture.Name = user.pic;
                    ManagedAccountPicture m_picture = new ManagedAccountPicture(session);
                    m_picture.CreateOrUpdate(t_picture, ManagedAccount.GetAdminSecurityContext(session));
                }

                SnCore.Data.Hibernate.Session.Flush();
                return acct.Id;
            }
        }
Esempio n. 40
0
 public int CreateOrUpdateAccount(string ticket, TransitAccount t_instance)
 {
     return WebServiceImpl<TransitAccount, ManagedAccount, Account>.CreateOrUpdate(
         ticket, t_instance);
 }
Esempio n. 41
0
        public string CreateAccountWithInvitationAndLogin(int invitationid, string code, TransitAccount ta)
        {
            int id = CreateAccountWithInvitation(invitationid, code, ta);

            using (SnCore.Data.Hibernate.Session.OpenConnection())
            {
                ISession session = SnCore.Data.Hibernate.Session.Current;
                ManagedAccount acct = new ManagedAccount(session, id);
                string ticket = ManagedAccount.GetTicketFromAccountId(acct.Id);
                return ticket;
            }
        }
Esempio n. 42
0
        public int CreateAccountWithInvitation(int invitationid, string code, TransitAccount ta)
        {
            using (SnCore.Data.Hibernate.Session.OpenConnection())
            {
                ISession session = SnCore.Data.Hibernate.Session.Current;

                ManagedAccountInvitation invitation = new ManagedAccountInvitation(session, invitationid);
                if (invitation.Code != code)
                {
                    throw new ManagedAccount.AccessDeniedException();
                }

                ManagedAccount acct = new ManagedAccount(session);
                int id = acct.Create(invitation.Instance.Email, ta, true, ManagedAccount.GetAdminSecurityContext(session));

                // become friends with the person who invited you
                TransitAccountFriend t_friend = new TransitAccountFriend();
                AccountFriend friend = new AccountFriend();
                friend.Account = session.Load<Account>(invitation.AccountId);
                friend.Keen = session.Load<Account>(id);
                friend.Created = DateTime.UtcNow;
                session.Save(friend);
                SnCore.Data.Hibernate.Session.Flush();

                // notify that a friend has joined
                ManagedAccount recepient = new ManagedAccount(session, invitation.AccountId);
                ManagedSiteConnector.TrySendAccountEmailMessageUriAsAdmin(session, recepient,
                    string.Format("EmailAccountInvitationAccept.aspx?id={0}&aid={1}", invitation.Id, id));

                // if this is a group invitation, join the group
                if (invitation.Instance.AccountGroup != null)
                {
                    AccountGroupAccountInvitation groupInvitation = new AccountGroupAccountInvitation();
                    groupInvitation.Account = session.Load<Account>(id);
                    groupInvitation.AccountGroup = invitation.Instance.AccountGroup;
                    groupInvitation.Created = invitation.Instance.Created;
                    groupInvitation.Modified = invitation.Instance.Modified;
                    groupInvitation.Requester = session.Load<Account>(invitation.AccountId);
                    ManagedAccountGroupAccountInvitation mGroupInvitation = new ManagedAccountGroupAccountInvitation(
                        session, groupInvitation);
                    mGroupInvitation.JoinGroup(ManagedAccount.GetAdminSecurityContext(session), string.Empty);
                }

                invitation.Delete(ManagedAccount.GetAdminSecurityContext(session));

                SnCore.Data.Hibernate.Session.Flush();
                return acct.Id;
            }
        }
Esempio n. 43
0
    public void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DomainClass cs = SessionManager.GetDomainClass("AccountMessage");
            inputSubject.MaxLength = cs["Subject"].MaxLengthInChars;

            TransitAccount ta = SessionManager.AccountService.GetAccountById(SessionManager.Ticket, RequestId);

            if (ta == null)
            {
                ReportWarning("Account does not exist.");
                panelMessage.Visible = false;
                return;
            }

            imageAccountTo.ImageUrl = string.Format("AccountPictureThumbnail.aspx?id={0}&width=75&height=75", ta.PictureId);
            linkAccountTo.Text = Renderer.Render(ta.Name);
            linkAccountTo.NavigateUrl = linkAccountTo2.HRef = "AccountView.aspx?id=" + ta.Id.ToString();
            linkBack.NavigateUrl = ReturnUrl;

            StringBuilder body = new StringBuilder();

            if (ParentId != 0)
            {
                TransitAccountMessage rp = SessionManager.AccountService.GetAccountMessageById(
                    SessionManager.Ticket, ParentId);
                panelReplyTo.Visible = true;

                messageFrom.NavigateUrl = accountlink.HRef = "AccountView.aspx?id=" + rp.SenderAccountId.ToString();

                messageFrom.Visible = labelMessageFrom.Visible = (rp.SenderAccountId != SessionManager.Account.Id);
                messageTo.Visible = labelMessageTo.Visible = (rp.RecepientAccountId != SessionManager.Account.Id);

                messageFrom.Text = Renderer.Render(rp.SenderAccountName);
                messageBody.Text = RenderEx(rp.Body);
                messageSent.Text = SessionManager.ToAdjustedString(rp.Sent);
                replytoImage.ImageUrl = string.Format("AccountPictureThumbnail.aspx?id={0}&width=75&height=75", rp.SenderAccountPictureId);
                messageSubject.Text = Renderer.Render(rp.Subject);
                inputSubject.Text = rp.Subject.StartsWith("Re:") ? rp.Subject : "Re: " + rp.Subject;

                body.AppendFormat("<P>[quote]<DIV>on {0} {1} wrote:</DIV><DIV>{2}</DIV>[/quote]</P>",
                        rp.Sent.ToString("d"), rp.SenderAccountName, rp.Body);
            }

            if (!string.IsNullOrEmpty(SessionManager.Account.Signature))
            {
                body.Append("<BR /><BR />");
                body.Append("<P>");
                body.Append(Renderer.RenderEx(SessionManager.Account.Signature));
                body.Append("</P>");
            }

            inputBody.Content = body.ToString();

            if (!SessionManager.HasVerified())
            {
                ReportWarning("You don't have any verified e-mail addresses and/or profile photos.\n" +
                    "You must add/confirm a valid e-mail address and upload a profile photo before sending messages.");

                manageAdd.Enabled = false;
            }

            SiteMapDataAttribute sitemapdata = new SiteMapDataAttribute();
            sitemapdata.Add(new SiteMapDataAttributeNode("People", Request, "AccountsView.aspx"));
            sitemapdata.Add(new SiteMapDataAttributeNode(ta.Name, Request, string.Format("AccountView.aspx?id={0}", ta.Id)));
            sitemapdata.Add(new SiteMapDataAttributeNode("Compose Message", Request.Url));
            StackSiteMap(sitemapdata);
        }

        SetDefaultButton(manageAdd);
    }
Esempio n. 44
0
    protected void create_Click(object sender, EventArgs e)
    {
        inputBetaPassword.Attributes["value"] = inputBetaPassword.Text.Trim();
        inputPassword.Attributes["value"] = inputPassword.Text.Trim();
        inputPassword2.Attributes["value"] = inputPassword2.Text.Trim();

        if (string.IsNullOrEmpty(inputName.Text))
        {
            throw new ArgumentException("Please enter a name.");
        }

        if (inputPassword.Text.Trim() != inputPassword2.Text.Trim())
        {
            throw new ArgumentException("Passwords don't match.");
        }

        if (!inputBirthday.HasDate)
        {
            throw new ArgumentException("Please select a valid date.");
        }

        if (string.IsNullOrEmpty(inputPassword.Text.Trim()))
        {
            throw new ArgumentException("Please enter a password.");
        }

        TransitAccount ta = new TransitAccount();
        ta.Name = inputName.Text;
        ta.Birthday = inputBirthday.SelectedDate;
        ta.Password = inputPassword.Text.Trim();

        try
        {
            // check whether there's already an account with the same e-mail and password
            string ticket = SessionManager.AccountService.Login(inputEmailAddress.Text.Trim(), inputPassword.Text.Trim());
            ReportWarning("There's already an account with the same e-mail address and password.");
            return;
        }
        catch
        {
        }

        try
        {
            SessionManager.AccountService.CreateAccount(
                inputBetaPassword.Text.Trim(),
                inputEmailAddress.Text.Trim(),
                ta);

            string ticket = SessionManager.AccountService.Login(inputEmailAddress.Text.Trim(), inputPassword.Text.Trim());
            SessionManager.Login(ticket, false);
            Redirect("AccountCreateWelcome.aspx");
        }
        catch
        {
            // there's a confirmed e-mail address, this one cannot be used to login immediately

            ReportInfo(
                string.Format(
                    "Account created. An e-mail was sent to '{0}' for confirmation. " +
                    "You must confirm this e-mail address before you log-in.",
                    inputEmailAddress.Text.Trim()));

            panelCreate.Visible = false;
        }
    }