Exemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     SocialAuthUser.GetConnectedProviders().ForEach(x =>
     {
         ddlConnectedProviders.Items.Add(new ListItem(x.ToString()));
     });
 }
Exemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //Required to be done when using custom mode
        //if (!SocialAuthUser.IsLoggedIn())
        //    SocialAuthUser.RedirectToLoginPage("ManualLogin.aspx");


        foreach (PROVIDER_TYPE p in SocialAuthUser.GetConnectedProviders())
        {
            divConnections.Controls.Add(new Literal()
            {
                Text = "<br>Connected to: <b>" + p.ToString() + "</b> with identifier <b>" +
                       SocialAuthUser.GetCurrentUser().GetProfile(p).GetIdentifier() + "</b>"
            });
            LinkButton logoutBtn = new LinkButton()
            {
                Text = "[Logout from " + p.ToString() + "]", CommandArgument = p.ToString()
            };
            logoutBtn.Command += new CommandEventHandler(btnIndividualLogout_Click);
            divConnections.Controls.Add(logoutBtn);
        }

        if (SocialAuthUser.IsLoggedIn())
        {
            IsSTSaware     = HttpContext.Current.ApplicationInstance.IsSTSaware();
            Provider       = User.Identity.GetProvider();
            Pid            = User.Identity.GetProfile().ID;
            Identifier     = User.Identity.GetProfile().GetIdentifier();
            Username       = User.Identity.GetProfile().Username;
            Displayname    = User.Identity.GetProfile().DisplayName;
            Email          = User.Identity.GetProfile().Email;
            Fullname       = User.Identity.GetProfile().FullName;
            FirstName      = User.Identity.GetProfile().FirstName;
            LastName       = User.Identity.GetProfile().LastName;
            DateOfBirth    = User.Identity.GetProfile().DateOfBirth;
            Gender         = User.Identity.GetProfile().Gender.ToString();
            ProfileURL     = User.Identity.GetProfile().ProfileURL;
            ProfilePicture = User.Identity.GetProfile().ProfilePictureURL;
            Country        = User.Identity.GetProfile().Country;
            Language       = User.Identity.GetProfile().Language;
            AccessToken    = SocialAuthUser.GetCurrentUser().GetAccessToken();
            bool IsAlternate = false;

            try
            {
                User.Identity.GetContacts().ForEach(
                    x =>
                {
                    HtmlTableRow tr = new HtmlTableRow();
                    tr.Attributes.Add("class", (IsAlternate) ? "dark" : "light");
                    tr.Cells.Add(new HtmlTableCell()
                    {
                        InnerText = x.Name
                    });
                    tr.Cells.Add(new HtmlTableCell()
                    {
                        InnerText = x.Email
                    });
                    tr.Cells.Add(new HtmlTableCell()
                    {
                        InnerText = x.ProfileURL
                    });
                    tblContacts.Rows.Add(tr);
                    IsAlternate = !IsAlternate;
                }

                    );
                ContactsCount = (tblContacts.Rows.Count - 1).ToString();
            }
            catch (Exception ex)
            {
                contacts.InnerHtml = "<error>" + ex.Message + "</error>";
            }
        }
        else
        {
            Response.Write("You are not logged in..");
        }
    }
Exemplo n.º 3
0
        void UpdateTableByRows()
        {
            List <PROVIDER_TYPE> providers = SocialAuthUser.GetConnectedProviders();

            //var result = SocialAuthUser.GetCurrentUser().ExecuteFeed(
            //    "http://api.linkedin.com/v1/people/~/connections:(headline,first-name,last-name,educations)",
            //    TRANSPORT_METHOD.GET, PROVIDER_TYPE.LINKEDIN);

            foreach (var provider in providers)
            {
                profiles.Add(SocialAuthUser.GetCurrentUser().GetProfile(provider));
            }

            foreach (UserProfile p in profiles)
            {
                HtmlGenericControl tableContainer = new HtmlGenericControl("div");
                tableContainer.Attributes.Add("style", "float:left;padding:10px 10px 10px 10px;width:400px;height:210px;");

                Table tbl = new Table()
                {
                    CellSpacing = 0
                };
                tbl.Attributes.Add("style", "width:100%");
                //Header Row
                TableHeaderRow trHeader = new TableHeaderRow();
                TableCell      tc       = new TableHeaderCell()
                {
                    Text = p.Provider.ToString()
                };
                tc.ColumnSpan = 2;
                trHeader.Cells.Add(tc);
                tbl.Rows.Add(trHeader);



                //Start adding Values
                TableRow tr = new TableRow();

                ////Provider
                //tr.Cells.Add(new TableCell() { Text = "Provider" });
                //tr.Cells.Add(new TableCell() { Text = p.Provider.ToString() });

                //tbl.Rows.Add(tr);
                //tr = new TableRow();

                //Best Possible Identifier
                tr.Cells.Add(new TableCell()
                {
                    Text = "Best Possible Identifier", CssClass = "altTr"
                });
                tr.Cells.Add(new TableCell()
                {
                    Text = p.GetIdentifier()
                });

                tbl.Rows.Add(tr);
                tr = new TableRow();

                //ID
                tr.Cells.Add(new TableCell()
                {
                    Text = "ID"
                });
                tr.Cells.Add(new TableCell()
                {
                    Text = p.ID
                });

                tbl.Rows.Add(tr);
                tr = new TableRow();

                ////FirstName
                //tr.Cells.Add(new TableCell() { Text = "FirstName", CssClass = "altTr" });
                //tr.Cells.Add(new TableCell() { Text = p.FirstName });
                //tbl.Rows.Add(tr);
                //tr = new TableRow();

                ////LastName
                //tr.Cells.Add(new TableCell() { Text = "LastName" });
                //tr.Cells.Add(new TableCell() { Text = p.LastName });
                //tbl.Rows.Add(tr);
                //tr = new TableRow();

                //FullName
                tr.Cells.Add(new TableCell()
                {
                    Text = "FullName", CssClass = "altTr"
                });
                tr.Cells.Add(new TableCell()
                {
                    Text = p.FullName
                });
                tbl.Rows.Add(tr);
                tr = new TableRow();

                ////DisplayName
                //tr.Cells.Add(new TableCell() { Text = "DisplayName" });
                //tr.Cells.Add(new TableCell() { Text = p.DisplayName });
                //tbl.Rows.Add(tr);
                //tr = new TableRow();

                //Email
                tr.Cells.Add(new TableCell()
                {
                    Text = "Email"
                });
                tr.Cells.Add(new TableCell()
                {
                    Text = p.Email
                });

                tbl.Rows.Add(tr);
                tr = new TableRow();

                ////Gender
                //tr.Cells.Add(new TableCell() { Text = "Gender" });
                //tr.Cells.Add(new TableCell() { Text = p.Gender });

                //tbl.Rows.Add(tr);
                //tr = new TableRow();


                ////ProfileURL
                //tr.Cells.Add(new TableCell() { Text = "ProfileURL", CssClass = "altTr" });
                //tr.Cells.Add(new TableCell() { Text = p.ProfileURL });

                //tbl.Rows.Add(tr);
                //tr = new TableRow();


                //ProfilePictureURL

                tr.Cells.Add(new TableCell()
                {
                    Text = "ProfilePictureURL", CssClass = "altTr"
                });
                TableCell profilePicCell = new TableCell();
                if (!string.IsNullOrEmpty(p.ProfilePictureURL))
                {
                    profilePicCell.Text = "<img src=\"" + p.ProfilePictureURL + "\" height=\"100\" width=\"100\">";
                }
                else
                {
                    profilePicCell.Text = "<img src=\"images/notavailable.png\" />";
                }
                tr.Cells.Add(profilePicCell);

                tbl.Rows.Add(tr);
                //tr = new TableRow();


                ////Country
                //tr.Cells.Add(new TableCell() { Text = "Country", CssClass = "altTr" });
                //tr.Cells.Add(new TableCell() { Text = p.Country });

                //tbl.Rows.Add(tr);
                //tr = new TableRow();


                ////Language
                //tr.Cells.Add(new TableCell() { Text = "Language" });
                //tr.Cells.Add(new TableCell() { Text = p.Language });

                //tbl.Rows.Add(tr);
                tableContainer.Controls.Add(tbl);
                divContent.Controls.Add(tableContainer);
            }



            //StringBuilder sb = new StringBuilder();
            //StringWriter sw = new StringWriter(sb);
            //HtmlTextWriter hw = new HtmlTextWriter(sw);
            //tbl.RenderControl(hw);
            //this.profileTable.InnerHtml = sb.ToString();
        }
Exemplo n.º 4
0
        void UpdateTableByColumns()
        {
            List <PROVIDER_TYPE> providers = SocialAuthUser.GetConnectedProviders();


            foreach (var provider in providers)
            {
                profiles.Add(SocialAuthUser.GetCurrentUser().GetProfile(provider));
            }

            Table tbl = new Table()
            {
                CellSpacing = 0
            };
            //Header Row
            TableHeaderRow trHeader = new TableHeaderRow();

            trHeader.Cells.Add(new TableHeaderCell()
            {
                Text = "Provider/Feature"
            });
            providers.ForEach(x => trHeader.Cells.Add(new TableCell()
            {
                Text = x.ToString()
            }));
            tbl.Rows.Add(trHeader);



            //Start adding Values
            TableRow tr = new TableRow();

            //Provider
            tr.Cells.Add(new TableCell()
            {
                Text = "Provider"
            });
            foreach (var p in profiles)
            {
                tr.Cells.Add(new TableCell()
                {
                    Text = p.Provider.ToString()
                });
            }

            tbl.Rows.Add(tr);
            tr = new TableRow();

            //Best Possible Identifier
            tr.Cells.Add(new TableCell()
            {
                Text = "Best Possible Identifier", CssClass = "altTr"
            });
            foreach (var p in profiles)
            {
                tr.Cells.Add(new TableCell()
                {
                    Text = p.GetIdentifier()
                });
            }

            tbl.Rows.Add(tr);
            tr = new TableRow();

            //ID
            tr.Cells.Add(new TableCell()
            {
                Text = "ID"
            });
            foreach (var p in profiles)
            {
                tr.Cells.Add(new TableCell()
                {
                    Text = p.ID
                });
            }

            tbl.Rows.Add(tr);
            tr = new TableRow();


            //FirstName
            tr.Cells.Add(new TableCell()
            {
                Text = "FirstName", CssClass = "altTr"
            });
            foreach (var p in profiles)
            {
                tr.Cells.Add(new TableCell()
                {
                    Text = p.FirstName
                });
            }

            tbl.Rows.Add(tr);
            tr = new TableRow();

            //LastName
            tr.Cells.Add(new TableCell()
            {
                Text = "LastName"
            });
            foreach (var p in profiles)
            {
                tr.Cells.Add(new TableCell()
                {
                    Text = p.LastName
                });
            }

            tbl.Rows.Add(tr);
            tr = new TableRow();

            //FullName
            tr.Cells.Add(new TableCell()
            {
                Text = "FullName", CssClass = "altTr"
            });
            foreach (var p in profiles)
            {
                tr.Cells.Add(new TableCell()
                {
                    Text = p.FullName
                });
            }

            tbl.Rows.Add(tr);
            tr = new TableRow();

            //DisplayName
            tr.Cells.Add(new TableCell()
            {
                Text = "DisplayName"
            });
            foreach (var p in profiles)
            {
                tr.Cells.Add(new TableCell()
                {
                    Text = p.DisplayName
                });
            }

            tbl.Rows.Add(tr);
            tr = new TableRow();

            //Email
            tr.Cells.Add(new TableCell()
            {
                Text = "Email", CssClass = "altTr"
            });
            foreach (var p in profiles)
            {
                tr.Cells.Add(new TableCell()
                {
                    Text = p.Email
                });
            }

            tbl.Rows.Add(tr);
            tr = new TableRow();

            //Gender
            tr.Cells.Add(new TableCell()
            {
                Text = "Gender"
            });
            foreach (var p in profiles)
            {
                tr.Cells.Add(new TableCell()
                {
                    Text = p.Gender
                });
            }

            tbl.Rows.Add(tr);
            tr = new TableRow();


            //ProfileURL
            tr.Cells.Add(new TableCell()
            {
                Text = "ProfileURL", CssClass = "altTr"
            });
            foreach (var p in profiles)
            {
                tr.Cells.Add(new TableCell()
                {
                    Text = p.ProfileURL
                });
            }

            tbl.Rows.Add(tr);
            tr = new TableRow();


            //ProfilePictureURL
            tr.Cells.Add(new TableCell()
            {
                Text = "ProfilePictureURL"
            });
            foreach (var p in profiles)
            {
                tr.Cells.Add(new TableCell()
                {
                    Text = p.ProfilePictureURL
                });
            }

            tbl.Rows.Add(tr);
            tr = new TableRow();


            //Country
            tr.Cells.Add(new TableCell()
            {
                Text = "Country", CssClass = "altTr"
            });
            foreach (var p in profiles)
            {
                tr.Cells.Add(new TableCell()
                {
                    Text = p.Country
                });
            }

            tbl.Rows.Add(tr);
            tr = new TableRow();


            //Language
            tr.Cells.Add(new TableCell()
            {
                Text = "Language"
            });
            foreach (var p in profiles)
            {
                tr.Cells.Add(new TableCell()
                {
                    Text = p.Language
                });
            }

            tbl.Rows.Add(tr);

            //StringBuilder sb = new StringBuilder();
            //StringWriter sw = new StringWriter(sb);
            //HtmlTextWriter hw = new HtmlTextWriter(sw);
            //tbl.RenderControl(hw);
            //this.profileTable.InnerHtml = sb.ToString();
        }