public void Page_Load()
    {
        if (!IsPostBack)
        {
            int id = RequestId;

            if (id > 0)
            {
                TransitAccountPicture tw = SessionManager.AccountService.GetAccountPictureById(SessionManager.Ticket, id);
                this.Title                = inputName.Text = Renderer.Render(tw.Name);
                inputDescription.Text     = tw.Description;
                inputPictureThumbnail.Src = string.Format("AccountPictureThumbnail.aspx?id={0}&CacheDuration=0", tw.Id);
                inputHidden.Checked       = tw.Hidden;

                discussionComments.DiscussionId = SessionManager.GetCount <TransitDiscussion, string, int>(
                    typeof(AccountPicture).Name, id, SessionManager.DiscussionService.GetOrCreateDiscussionId);
                discussionComments.DataBind();

                SiteMapDataAttribute sitemapdata = new SiteMapDataAttribute();
                sitemapdata.Add(new SiteMapDataAttributeNode("Me Me", Request, "AccountManage.aspx"));
                sitemapdata.Add(new SiteMapDataAttributeNode("Pictures", Request, "AccountPicturesManage.aspx"));
                sitemapdata.Add(new SiteMapDataAttributeNode(tw.Name, Request.Url));
                StackSiteMap(sitemapdata);
            }
        }

        SetDefaultButton(manageAdd);
    }
Example #2
0
    public void gridManage_ItemCommand(object sender, DataListCommandEventArgs e)
    {
        switch (e.CommandName)
        {
        case "Delete":
        {
            int id = int.Parse(e.CommandArgument.ToString());
            SessionManager.Delete <TransitAccountPicture>(id, SessionManager.AccountService.DeleteAccountPicture);
            ReportInfo("Picture deleted.");
            GetData(sender, e);
        }
        break;

        case "ShowHide":
        {
            int id = int.Parse(e.CommandArgument.ToString());
            TransitAccountPicture p = SessionManager.AccountService.GetAccountPictureById(
                SessionManager.Ticket, id);
            p.Hidden = !p.Hidden;
            SessionManager.CreateOrUpdate <TransitAccountPicture>(
                p, SessionManager.AccountService.CreateOrUpdateAccountPicture);
            gridManage_OnGetDataSource(sender, e);
            gridManage.DataBind();
        }
        break;

        case "Right":
        {
            int id = int.Parse(e.CommandArgument.ToString());
            SessionManager.AccountService.MoveAccountPicture(SessionManager.Ticket, id, 1);
            if (e.Item.ItemIndex + 1 == gridManage.Items.Count && gridManage.CurrentPageIndex + 1 < gridManage.PagedDataSource.PageCount)
            {
                gridManage.CurrentPageIndex++;
            }
            SessionManager.InvalidateCache <TransitAccountPicture>();
            gridManage_OnGetDataSource(sender, e);
            gridManage.DataBind();
        }
        break;

        case "Left":
        {
            int id = int.Parse(e.CommandArgument.ToString());
            SessionManager.AccountService.MoveAccountPicture(SessionManager.Ticket, id, -1);
            if (e.Item.ItemIndex == 0 && gridManage.CurrentPageIndex > 0)
            {
                gridManage.CurrentPageIndex--;
            }
            SessionManager.InvalidateCache <TransitAccountPicture>();
            gridManage_OnGetDataSource(sender, e);
            gridManage.DataBind();
        }
        break;
        }
    }
Example #3
0
 public void save_Click(object sender, EventArgs e)
 {
     TransitAccountPicture tw = new TransitAccountPicture();
     tw.Name = inputName.Text;
     tw.Description = inputDescription.Text;
     tw.Id = RequestId;
     tw.Hidden = inputHidden.Checked;
     SessionManager.CreateOrUpdate<TransitAccountPicture>(
         tw, SessionManager.AccountService.CreateOrUpdateAccountPicture);
     Redirect("AccountPicturesManage.aspx");
 }
    public void save_Click(object sender, EventArgs e)
    {
        TransitAccountPicture tw = new TransitAccountPicture();

        tw.Name        = inputName.Text;
        tw.Description = inputDescription.Text;
        tw.Id          = RequestId;
        tw.Hidden      = inputHidden.Checked;
        SessionManager.CreateOrUpdate <TransitAccountPicture>(
            tw, SessionManager.AccountService.CreateOrUpdateAccountPicture);
        Redirect("AccountPicturesManage.aspx");
    }
Example #5
0
    protected void files_FilesPosted(object sender, FilesPostedEventArgs e)
    {
        try
        {
            if (e.PostedFiles.Count == 0)
            {
                return;
            }

            ExceptionCollection exceptions = new ExceptionCollection();
            foreach (HttpPostedFile file in e.PostedFiles)
            {
                try
                {
                    TransitAccountPicture p = new TransitAccountPicture();

                    ThumbnailBitmap t = new ThumbnailBitmap(file.InputStream);
                    p.Bitmap      = t.Bitmap;
                    p.Name        = Path.GetFileName(file.FileName);
                    p.Description = string.Empty;
                    p.Hidden      = true;

                    int id = SessionManager.CreateOrUpdate <TransitAccountPicture>(
                        p, SessionManager.AccountService.CreateOrUpdateAccountPicture);

                    Size size = t.GetNewSize(new Size(200, 200));

                    inputBody.Content = string.Format("<a href=AccountPictureView.aspx?id={2}><img border=0 width={0} height={1} src=AccountPicture.aspx?id={2}></a>\n{3}",
                                                      size.Width, size.Height, id, inputBody.Content);
                }
                catch (Exception ex)
                {
                    exceptions.Add(new Exception(string.Format("Error processing {0}: {1}",
                                                               Renderer.Render(file.FileName), ex.Message), ex));
                }

                exceptions.Throw();
            }
        }
        catch (Exception ex)
        {
            ReportException(ex);
        }
    }
    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();
    }
Example #7
0
    public override TransitPicture GetPictureWithThumbnail(int id)
    {
        TransitAccountPicture p = SessionManager.GetInstance <TransitAccountPicture, int>(
            id, SessionManager.AccountService.GetAccountPictureById);

        if (p == null)
        {
            return(null);
        }

        TransitPicture result = new TransitPicture();

        result.Id       = p.Id;
        result.Bitmap   = p.Thumbnail;
        result.Created  = p.Created;
        result.Modified = p.Modified;
        result.Name     = p.Name;
        return(result);
    }
Example #8
0
    public override TransitPicture GetPictureWithBitmap(int id, DateTime ifModifiedSince)
    {
        TransitAccountPicture p = SessionManager.GetInstance <TransitAccountPicture, int, DateTime>(
            id, ifModifiedSince, SessionManager.AccountService.GetAccountPictureIfModifiedSinceById);

        if (p == null)
        {
            return(null);
        }

        TransitPicture result = new TransitPicture();

        result.Id       = p.Id;
        result.Bitmap   = p.Bitmap;
        result.Created  = p.Created;
        result.Modified = p.Modified;
        result.Name     = p.Name;
        return(result);
    }
    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);
        }
    }
Example #10
0
    protected void files_FilesPosted(object sender, FilesPostedEventArgs e)
    {
        try
        {
            if (e.PostedFiles.Count == 0)
            {
                return;
            }

            ExceptionCollection exceptions = new ExceptionCollection();
            foreach (HttpPostedFile file in e.PostedFiles)
            {
                try
                {
                    TransitAccountPicture p = new TransitAccountPicture();

                    ThumbnailBitmap t = new ThumbnailBitmap(file.InputStream);
                    p.Bitmap      = t.Bitmap;
                    p.Name        = Path.GetFileName(file.FileName);
                    p.Description = string.Empty;
                    p.Hidden      = false;

                    SessionManager.CreateOrUpdate <TransitAccountPicture>(
                        p, SessionManager.AccountService.CreateOrUpdateAccountPicture);
                }
                catch (Exception ex)
                {
                    exceptions.Add(new Exception(string.Format("Error processing {0}: {1}",
                                                               Renderer.Render(file.FileName), ex.Message), ex));
                }
            }

            GetData(sender, e);
            exceptions.Throw();
        }
        catch (Exception ex)
        {
            ReportException(ex);
        }
    }
    protected void files_FilesPosted(object sender, FilesPostedEventArgs e)
    {
        try
        {
            if (e.PostedFiles.Count == 0)
                return;

            ExceptionCollection exceptions = new ExceptionCollection();
            foreach (HttpPostedFile file in e.PostedFiles)
            {
                try
                {
                    TransitAccountPicture p = new TransitAccountPicture();

                    ThumbnailBitmap t = new ThumbnailBitmap(file.InputStream);
                    p.Bitmap = t.Bitmap;
                    p.Name = Path.GetFileName(file.FileName);
                    p.Description = string.Empty;
                    p.Hidden = false;

                    SessionManager.CreateOrUpdate<TransitAccountPicture>(
                        p, SessionManager.AccountService.CreateOrUpdateAccountPicture);
                }
                catch (Exception ex)
                {
                    exceptions.Add(new Exception(string.Format("Error processing {0}: {1}",
                        Renderer.Render(file.FileName), ex.Message), ex));
                }
            }

            GetData(sender, e);
            exceptions.Throw();
        }
        catch (Exception ex)
        {
            ReportException(ex);
        }
    }
    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();
    }
Example #13
0
    protected void files_FilesPosted(object sender, FilesPostedEventArgs e)
    {
        try
        {
            if (e.PostedFiles.Count == 0)
                return;

            ExceptionCollection exceptions = new ExceptionCollection();
            foreach (HttpPostedFile file in e.PostedFiles)
            {
                try
                {
                    TransitAccountPicture p = new TransitAccountPicture();

                    ThumbnailBitmap t = new ThumbnailBitmap(file.InputStream);
                    p.Bitmap = t.Bitmap;
                    p.Name = Path.GetFileName(file.FileName);
                    p.Description = string.Empty;
                    p.Hidden = true;

                    int id = SessionManager.CreateOrUpdate<TransitAccountPicture>(
                        p, SessionManager.AccountService.CreateOrUpdateAccountPicture);

                    Size size = t.GetNewSize(new Size(200, 200));

                    inputBody.Content = string.Format("<a href=AccountPictureView.aspx?id={2}><img border=0 width={0} height={1} src=AccountPicture.aspx?id={2}></a>\n{3}",
                        size.Width, size.Height, id, inputBody.Content);
                }
                catch (Exception ex)
                {
                    exceptions.Add(new Exception(string.Format("Error processing {0}: {1}",
                        Renderer.Render(file.FileName), ex.Message), ex));
                }
            }
            exceptions.Throw();
        }
        catch (Exception ex)
        {
            ReportException(ex);
        }
    }
Example #14
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;
            }
        }
Example #15
0
 public int CreateOrUpdateAccountPicture(string ticket, TransitAccountPicture accountpicture)
 {
     return WebServiceImpl<TransitAccountPicture, ManagedAccountPicture, AccountPicture>.CreateOrUpdate(
         ticket, accountpicture);
 }