This class is used for all database IO of the web data layer of profiles. Plus contains generic data base IO methods for building Command Objects, Data Readers ect...
Ejemplo n.º 1
0
        //***************************************************************************************************************************************
        /// <summary>

        /*
         *
         *  This method implements the loading of all URLs patterns that contain file extensions that need to be ignored and
         *  all URLs patterns that need to be processed:
         *
         *
         *  Example of patterns to process:
         *  routes.Add("ProfilesAliasPath2", new Route("{Param0}/{Param1}/{Param2}", new ProfilesRouteHandler()));
         *      The above example will register a URL pattern for processing by the Alias.aspx page.  When IIS makes a request,
         *      the URL pattern of http://domain.com/profile/person/32213, will trigger the .Net System.Web.Routing library to call ProfilesRouteHandler.GetHttpHandler(RequestContext requestContext){}.  This method will process the URL pattern into parameters and load the HttpContext.Current.Items hash table and then direct the request to the Alias.aspx page for processing.
         *
         */

        /// </summary>
        /// <param name="routes">RouteTable.Routes is passed as a RouteCollection by ref used to store all routes in the routing framework.</param>
        private static void RegisterRoutes(RouteCollection routes)
        {
            Framework.Utilities.DataIO d = new Framework.Utilities.DataIO();

            //The REST Paths are built based on the applications setup in the Profiles database.
            using (System.Data.SqlClient.SqlDataReader reader = d.GetRESTApplications())
            {
                int loop = 0;

                routes.RouteExistingFiles = false;

                // by UCSF
                routes.Add("RobotsTxt", new Route("robots.txt", new AspxHandler("~/RobotsTxt.aspx")));
                routes.Add("SiteMap", new Route("sitemap.xml", new AspxHandler("~/SiteMap.aspx")));

                while (reader.Read())
                {
                    routes.Add("ProfilesAliasPath0" + loop, new Route(reader[0].ToString(), new ProfilesRouteHandler()));
                    routes.Add("ProfilesAliasPath1" + loop, new Route(reader[0].ToString() + "/{Param1}", new ProfilesRouteHandler()));
                    routes.Add("ProfilesAliasPath2" + loop, new Route(reader[0].ToString() + "/{Param1}/{Param2}", new ProfilesRouteHandler()));
                    routes.Add("ProfilesAliasPath3" + loop, new Route(reader[0].ToString() + "/{Param1}/{Param2}/{Param3}", new ProfilesRouteHandler()));
                    routes.Add("ProfilesAliasPath4" + loop, new Route(reader[0].ToString() + "/{Param1}/{Param2}/{Param3}/{Param4}", new ProfilesRouteHandler()));
                    routes.Add("ProfilesAliasPath5" + loop, new Route(reader[0].ToString() + "/{Param1}/{Param2}/{Param3}/{Param4}/{Param5}", new ProfilesRouteHandler()));
                    routes.Add("ProfilesAliasPath6" + loop, new Route(reader[0].ToString() + "/{Param1}/{Param2}/{Param3}/{Param4}/{Param5}/{Param6}", new ProfilesRouteHandler()));
                    routes.Add("ProfilesAliasPath7" + loop, new Route(reader[0].ToString() + "/{Param1}/{Param2}/{Param3}/{Param4}/{Param5}/{Param6}/{Param7}", new ProfilesRouteHandler()));
                    routes.Add("ProfilesAliasPath8" + loop, new Route(reader[0].ToString() + "/{Param1}/{Param2}/{Param3}/{Param4}/{Param5}/{Param6}/{Param7}/{Param8}", new ProfilesRouteHandler()));
                    routes.Add("ProfilesAliasPath9" + loop, new Route(reader[0].ToString() + "/{Param1}/{Param2}/{Param3}/{Param4}/{Param5}/{Param6}/{Param7}/{Param8}/{Param9}", new ProfilesRouteHandler()));

                    Framework.Utilities.DebugLogging.Log("REST PATTERN(s) CREATED FOR " + reader[0].ToString());
                    loop++;
                }
            }
        }
        public void BeginProcessRequest(Site site)
        {
            string sql = "";
            int iResult = 0;
            this.Site = site;

            oDataIO = new DataIO();
            SqlConnection Conn = new SqlConnection();
            Conn = oDataIO.GetDBConnection("ProfilesDB");
            sqlCmd = new SqlCommand();
            sqlCmd.Connection = Conn;

            site.IsDone = false;
            _request = WebRequest.Create(site.URL);

            // Enter log record
            sql = "insert into [Direct.].LogOutgoing(FSID,SiteID,Details,SentDate,QueryString) "
                 + " values ('" + site.FSID.ToString() + "'," + site.SiteID.ToString() + ",0,GetDate()," + cs(site.SearchPhrase) + ")";
            sqlCmd.CommandText = sql;
            sqlCmd.CommandType = System.Data.CommandType.Text;
            iResult = sqlCmd.ExecuteNonQuery();

            if (sqlCmd.Connection.State == System.Data.ConnectionState.Open)
                sqlCmd.Connection.Close();

            _request.BeginGetResponse(new AsyncCallback(EndProcessRequest), site);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + Environment.NewLine +
                                    "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"" + Environment.NewLine +
                                    "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" + Environment.NewLine +
                                    "xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\">" + Environment.NewLine +
                                    "<url><loc>" + Root.Domain + "</loc></url>" + Environment.NewLine +
                                    "<url><loc>" + Root.Domain + "/About</loc></url>" + Environment.NewLine +
                                    "<url><loc>" + Root.Domain + "/About/AboutUCSFProfiles.aspx</loc></url>" + Environment.NewLine +
                                    "<url><loc>" + Root.Domain + "/About/ForDevelopers.aspx</loc></url>" + Environment.NewLine +
                                    "<url><loc>" + Root.Domain + "/About/GadgetLibrary.aspx</loc></url>" + Environment.NewLine +
                                    "<url><loc>" + Root.Domain + "/About/Help.aspx</loc></url>" + Environment.NewLine +
                                    "<url><loc>" + Root.Domain + "/About/HowProfilesWorks.aspx</loc></url>" + Environment.NewLine);

            System.Data.SqlClient.SqlDataReader reader = new Framework.Utilities.DataIO().GetRESTApplications();

            while (reader.Read())
            {
                // if it has a . then it's a pretty name for a user
                if (reader[0].ToString().Contains("."))
                    Response.Write("<url><loc>" + Root.Domain + "/" + reader[0].ToString() + "</loc></url>" + Environment.NewLine);

            }

            if (!reader.IsClosed)
                reader.Close();

            Response.Write("</urlset>");
            Response.End();
        }
Ejemplo n.º 4
0
        protected void chkRelationshipTypes_OnCheckedChanged(object sender, EventArgs e)
        {
            CheckBox cb = (CheckBox)sender;

            Utilities.DataIO data = new Profiles.Framework.Utilities.DataIO();
            data.SetActiveNetwork(Convert.ToInt64(HttpContext.Current.Request.QueryString["subject"]), this.FindRelationshipType(cb.Text).Value, cb.Checked);
            this.DrawProfilesModule();
        }
        protected void chkRelationshipTypes_OnCheckedChanged(object sender, EventArgs e)
        {
            CheckBox cb = (CheckBox)sender;

            Utilities.DataIO data = new Profiles.Framework.Utilities.DataIO();
            data.SetActiveNetwork(Convert.ToInt64(HttpContext.Current.Request.QueryString["subject"]), this.FindRelationshipType(cb.Text).Value, cb.Checked);
            this.DrawProfilesModule();
        }
Ejemplo n.º 6
0
        protected void btnCreateORCIDs_Click(object sender, EventArgs e)
        {
            Profiles.Framework.Utilities.DataIO data = new Profiles.Framework.Utilities.DataIO();
            if (data.GetSessionSecurityGroup() != -50)
            {
                this.AddError("Only Administrators can push records to ORCID");
            }
            else
            {
                foreach (RepeaterItem ri in this.rptSearchResults.Items)
                {
                    switch (ri.ItemType)
                    {
                    case ListItemType.Item:
                    case ListItemType.AlternatingItem:
                        CheckBox chkSelected = (CheckBox)ri.FindControl("chkSelected");
                        if (chkSelected.Checked)
                        {
                            Label lblPersonID = (Label)ri.FindControl("lblPersonID");
                            Label lblErrors   = (Label)ri.FindControl("lblErrors");
                            Label lblMessages = (Label)ri.FindControl("lblMessages");

                            try
                            {
                                Profiles.ORCID.Utilities.ProfilesRNSDLL.BO.ORCID.Person bo = new Profiles.ORCID.Utilities.ProfilesRNSDLL.BLL.ORCID.Person().GetPersonWithDBData(int.Parse(lblPersonID.Text), sm.Session().SessionID);
                                if (!bo.BiographyIsNull && !bo.Biography.Equals(string.Empty))
                                {
                                    bo.PushBiographyToORCID = true;
                                }

                                //System.Threading.Thread.Sleep(2000);

                                if (new Profiles.ORCID.Utilities.ProfilesRNSDLL.BLL.ORCID.Person().CreateNewORCID(bo, LoggedInInternalUsername, Profiles.ORCID.Utilities.ProfilesRNSDLL.BO.ORCID.REFPersonStatusType.REFPersonStatusTypes.User_Push_Failed))
                                {
                                    Edit.Utilities.DataIO dataio = new Edit.Utilities.DataIO();
                                    long subjectID = Profiles.ORCID.Utilities.DataIO.getNodeIdFromPersonID(int.Parse(lblPersonID.Text));
                                    dataio.AddLiteral(subjectID, dataio.GetStoreNode("http://vivoweb.org/ontology/core#orcidId"), dataio.GetStoreNode(bo.ORCID), this.PropertyListXML);
                                    lblMessages.Text = "Success";
                                }
                                else
                                {
                                    lblErrors.Text = bo.Error + bo.AllErrors + "<br /><br />";
                                }
                            }
                            catch (Exception ex)
                            {
                                // todo remove
                                lblErrors.Text = ex.Message;
                                //this.lblErrors.Text = "An error occurred while creating the ORCID.";
                            }
                        }
                        break;
                    }
                }
            }
        }
Ejemplo n.º 7
0
        protected void ibRemove_OnClick(object sender, EventArgs e)
        {
            ImageButton remove = (ImageButton)sender;

            Framework.Utilities.DataIO data = new Profiles.Framework.Utilities.DataIO();

            data.SetActiveNetwork(Convert.ToInt64(remove.CommandArgument), remove.CommandName, false);

            this.DrawProfilesModule();
        }
        protected void ibRemove_OnClick(object sender, EventArgs e)
        {
            ImageButton remove = (ImageButton)sender;

            Framework.Utilities.DataIO data = new Profiles.Framework.Utilities.DataIO();

            data.SetActiveNetwork(Convert.ToInt64(remove.CommandArgument), remove.CommandName, false);

            this.DrawProfilesModule();
        }
Ejemplo n.º 9
0
        private void DrawProfilesModule()
        {
            SqlDataReader reader;

            Framework.Utilities.DataIO data = new Profiles.Framework.Utilities.DataIO();
            List <NetworkItem>         ni   = new List <NetworkItem>();
            List <NetworkItem>         nibinder;

            reader = data.GetActiveNetwork(0, true);


            while (reader.Read())
            {
                ni.Add(new NetworkItem(reader["URI"].ToString(),
                                       reader["Name"].ToString(),
                                       Convert.ToInt64(reader["NodeID"]),
                                       reader["RelationshipType"].ToString(),
                                       reader["RelationshipName"].ToString()));
            }



            nibinder = this.GetItems("Collaborator", ni);
            litCollaborators.Text      = "<b>Collaborators</b> (" + nibinder.Count.ToString() + ")";
            gvCollaborators.DataSource = nibinder;
            gvCollaborators.DataBind();

            nibinder = this.GetItems("CurrentAdvisor", ni);
            litAdvisorsCurrent.Text      = "<b>Advisor (Current)</b> (" + nibinder.Count.ToString() + ")";
            gvAdvisorsCurrent.DataSource = nibinder;
            gvAdvisorsCurrent.DataBind();
            nibinder = new List <NetworkItem>();

            nibinder = this.GetItems("CurrentAdvisee", ni);
            litAdviseesCurrent.Text      = "<b>Advisee (Current)</b> (" + nibinder.Count.ToString() + ")";
            gvAdviseesCurrent.DataSource = nibinder;
            gvAdviseesCurrent.DataBind();
            nibinder = new List <NetworkItem>();

            nibinder                  = this.GetItems("PastAdvisor", ni);
            litAdvisorsPast.Text      = "<b>Advisor (Past)</b> (" + nibinder.Count.ToString() + ")";
            gvAdvisorsPast.DataSource = nibinder;
            gvAdvisorsPast.DataBind();
            nibinder = new List <NetworkItem>();

            nibinder                  = this.GetItems("PastAdvisee", ni);
            litAdviseesPast.Text      = "<b>Advisee (Past)</b> (" + nibinder.Count.ToString() + ")";
            gvAdviseesPast.DataSource = nibinder;
            gvAdviseesPast.DataBind();
        }
Ejemplo n.º 10
0
 // can do this via Search API but this is much faster since we know exactly what we want
 private List<string> LoadPeople()
 {
     List<string> urlNames = new List<string>();
     DataIO data = new DataIO();
     using (SqlDataReader reader = data.GetDBCommand(ConfigurationManager.ConnectionStrings["ProfilesDB"].ConnectionString,
         "select n.UrlName from [Profile.Data].Person p join [UCSF.].NameAdditions n on p.InternalUserName = n.InternalUserName where p.IsActive = 1"
         , CommandType.Text, CommandBehavior.CloseConnection, null).ExecuteReader())
     {
         while (reader.Read())
         {
             urlNames.Add(reader[0].ToString());
         }
     }
     return urlNames;
 }
Ejemplo n.º 11
0
 // can do this via Search API but this is much faster since we know exactly what we want
 private List<Int64> LoadPeople()
 {
     List<Int64> nodeIds = new List<Int64>();
     DataIO data = new DataIO();
     using (SqlDataReader reader = data.GetDBCommand(ConfigurationManager.ConnectionStrings["ProfilesDB"].ConnectionString,
         "select n.nodeId from [Profile.Data].Person p join [RDF.Stage].InternalNodeMap n on cast(p.PersonID as varchar) = n.InternalID " +
         "and Class = 'http://xmlns.com/foaf/0.1/Person' where p.IsActive = 1"
         , CommandType.Text, CommandBehavior.CloseConnection, null).ExecuteReader())
     {
         while (reader.Read())
         {
             nodeIds.Add(reader.GetInt64(0));
         }
     }
     return nodeIds;
 }
Ejemplo n.º 12
0
        public void ProcessRequest(HttpContext context)
        {
            string output;

            if (!string.IsNullOrEmpty(context.Request.QueryString["Pagetype"]))
            {
                string pageType = context.Request.QueryString["Pagetype"].ToString();
                int    offset   = 0;
                if (!string.IsNullOrEmpty(context.Request.QueryString["Offset"]))
                {
                    offset = Convert.ToInt32(context.Request.QueryString["Offset"]);
                }

                output = new Framework.Utilities.DataIO().GetSiteMap(pageType, offset);
            }
            else
            {
                output = new Framework.Utilities.DataIO().GetSiteMapIndex();
            }
            context.Response.ContentType = "text/xml";
            context.Response.Write(output);
        }
Ejemplo n.º 13
0
        public void Page_Load(object sender, EventArgs e)
        {
            masterpage = (Framework.Template)base.Master;
            this.LoadAssets();
            SessionManagement sm = new SessionManagement();

            Framework.Utilities.DataIO data = new Profiles.Framework.Utilities.DataIO();
            if (data.IsGroupAdmin(sm.Session().UserID))
            {
                masterpage.Tab     = "";
                masterpage.RDFData = null;
                XmlDocument presentationxml = new XmlDocument();
                presentationxml.LoadXml(System.IO.File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "/GroupAdmin/PresentationXML/GroupAdminPresentation.xml"));
                masterpage.PresentationXML = presentationxml;
            }
            else
            {
                masterpage.Tab     = "";
                masterpage.RDFData = null;
                XmlDocument presentationxml = new XmlDocument();
                presentationxml.LoadXml(System.IO.File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "/GroupAdmin/PresentationXML/GroupAdminAuthFailedPresentation.xml"));
                masterpage.PresentationXML = presentationxml;
            }
        }
 static SessionManagement()
 {
     using (SqlDataReader reader = new DataIO().GetSQLDataReader("ProfilesDB", "select UserAgent from [User.Session].[Bot]", CommandType.Text, CommandBehavior.CloseConnection, null))
     {
         while (reader.Read())
         {
             BotUserAgents.Add(reader[0].ToString());
         }
     }
 }
Ejemplo n.º 15
0
        private void DrawProfilesModule()
        {
            Int64 subject = 0;

            if (Request.QueryString["subject"] != null)
                subject = Convert.ToInt64(Request.QueryString["subject"]);

            Utilities.DataIO data = new Profiles.Framework.Utilities.DataIO();
            menulist.Append("<ul>");

            menulist.Append("<li><a href='" + Root.Domain + "/search'>Find People</a></li>");
            menulist.Append("<li><a href='" + Root.Domain + "/search/all'>Find Everything</a></li>");

            //-50 is the profiles Admin
            if (data.GetSessionSecurityGroup() == -50)
                menulist.Append("<li><a href='" + Root.Domain + "/SPARQL/default.aspx'>SPARQL Query</a></li>");

            menulist.Append("<li><a href='" + Root.Domain + "/about/default.aspx'>About This Site</a></li>");

            if (sm.Session().NodeID > 0)
                menulist.Append("<li><a href='" + sm.Session().PersonURI + "'>View My Profile</a></li>");

            menulist.Append("<li><a href='" + Root.Domain + "/login/default.aspx?method=login&edit=true'>Edit My Profile</a></li>");

            if (base.MasterPage.CanEdit)
            {
                menulist.Append("<li><a href='" + Root.Domain + "/edit/" + subject.ToString() + "'>Edit This Profile</a></li>");
            }

            if (sm.Session().UserID > 0)
                menulist.Append("<li><a href='" + Root.Domain + "/proxy/default.aspx?subject=" + sm.Session().NodeID.ToString() + "'>Manage Proxies</a></li>");

            if (base.BaseData.SelectSingleNode(".").OuterXml != string.Empty && !Root.AbsolutePath.ToLower().Contains("/search"))
            {
                if (base.BaseData.SelectSingleNode("//rdf:RDF/rdf:Description/@rdf:about", base.Namespaces) != null && !Root.AbsolutePath.ToLower().Contains("proxy"))
                {
                    string uri = this.BaseData.SelectSingleNode("//rdf:RDF/rdf:Description/@rdf:about", base.Namespaces).Value;

                    //IF the URI is in our system then we build the link. If not then we do not build the link for the data.
                    if (uri.Contains(Root.Domain))
                    {
                        string file = string.Empty;
                        string spostring = string.Empty;
                        string[] spoarray;

                        spostring = uri.ToLower().Replace(Root.Domain.ToLower() + "/profile/", "");
                        spoarray = spostring.Split('/');

                        for (int i = 0; i < spoarray.Length; i++)
                        {
                            file = file + spoarray[i] + "_";
                        }

                        file = file.Substring(0, file.Length - 1);

                        menulist.Append("<li><a href=\"" + uri + "/" + file + ".rdf\" target=\"_blank\">" + "Export RDF" + "</a>&nbsp;<a style='border: none;' href='" + Root.Domain + "/about/default.aspx?tab=data'><img style='border-style: none' src='" + Root.Domain + "/Framework/Images/info.png'  border='0'></a></li>");

                        if (base.MasterPage != null)
                        {
                            System.Web.UI.HtmlControls.HtmlContainerControl Head1;
                            Head1 = (System.Web.UI.HtmlControls.HtmlContainerControl)base.MasterPage.FindControl("Head1");
                            //If a masterpage exists, you need to to create an ASP.Net Literal object and pass it to the masterpage so it can process the link in the Head block.
                            string link = "<link rel=\"alternate\" type=\"application/rdf+xml\" href=\"" + uri + "/" + file + ".rdf\" />";
                            Head1.Controls.Add(new LiteralControl(link));
                        }

                    }
                }
            }

            if (sm.Session().UserID == 0)
            {
                if (!Root.AbsolutePath.Contains("login"))
                {
                    menulist.Append("<li><a href='" + Root.Domain + "/login/default.aspx?pin=send&method=login&redirectto=" + Root.Domain + Root.AbsolutePath + "'>Login to Profiles</a></li>");
                }
            }
            else
            {
                menulist.Append("<li><a href='" + Root.Domain + "/login/default.aspx?method=logout&redirectto=" + Root.Domain + Root.AbsolutePath + "'>Logout</a></li>");
            }

            menulist.Append("</ul>");

            // hide active networks DIV if not logged in
            if (sm.Session().UserID > 0)
            {
                ActiveNetworkRelationshipTypes.Visible = true;
            }
            else
            {
                ActiveNetworkRelationshipTypes.Visible = false;
            }

            UserHistory uh = new UserHistory();

            ProfileHistory.RDFData = base.BaseData;
            ProfileHistory.PresentationXML = base.MasterPage.PresentationXML;
            ProfileHistory.Namespaces = base.Namespaces;

            if (uh.GetItems() != null)
            {
                ProfileHistory.Visible = true;
            }
            else
            {
                ProfileHistory.Visible = false;
            }

            panelMenu.InnerHtml = menulist.ToString();
        }
Ejemplo n.º 16
0
        /// <summary>
        ///     Public method used to create an instance of the custom Profiles session object.
        /// </summary>
        public void SessionCreate()
        {
            string sessionid = HttpContext.Current.Request.Headers["SessionID"];

            DataIO dataio = new DataIO();
            Session session = new Session();
            string hostname = System.Net.Dns.GetHostName();

            string ipaddress = string.Empty;
            try
            {
                ipaddress = System.Net.Dns.GetHostAddresses(hostname).GetValue(1).ToString();
            }
            catch (Exception ex)
            {
                Framework.Utilities.DebugLogging.Log(ex.Message + " ++ " + ex.StackTrace);
                ipaddress = "";
            }

            session.RequestIP = ipaddress;
            session.UserAgent = HttpContext.Current.Request.UserAgent;

            if (sessionid == null)
                dataio.SessionCreate(ref session);
            else
            {
                session.SessionID = sessionid;
            }

            //Store the object in the current session of the user.
            HttpContext.Current.Session["PROFILES_SESSION"] = session;
        }
        public void DrawProfilesModule()
        {
            Framework.Utilities.DataIO data = new Profiles.Framework.Utilities.DataIO();

            if (Request.Form["hdnSelectedURI"] != string.Empty && Request.Form["hdnSelectedURI"] != null)
            {

                Edit.Utilities.DataIO editdata = new Profiles.Edit.Utilities.DataIO();

                string newentity = string.Empty;

                newentity = Request.Form["hdnSelectedURI"].Trim();

                Int64 _object = Convert.ToInt64(editdata.GetStoreNode(newentity));

                editdata.AddExistingEntity(this.SubjectID, this.PredicateID, _object);
                Session["pnlAddBySearch.Visible"] = null;
                this.LoadEntityGrid(true);

            }
            else
            {
                LoadEntityGrid(false);
            }

            XmlDocument list = data.GetPropertyRangeList(this.PredicateURI);
            List<GenericListItem> propertylist = new List<GenericListItem>();
            string space = string.Empty;

            foreach (XmlNode property in list.SelectNodes("PropertyRangeList/PropertyRange"))
            {
                for (int i = 0; i < Convert.ToInt16(property.SelectSingleNode("@Depth").Value); i++)
                {
                    space += Server.HtmlDecode("&nbsp;&nbsp;&nbsp;");
                }
                //remove PI and Co-PI in drop down list when it's investigator, remove all other relationships besides "Advising Relationship"
                if (this.PropertyLabel == "investigator on" || this.PropertyLabel == "advisees")
                {
                    if (property.SelectSingleNode("@Label").Value == "Investigator Role" || property.SelectSingleNode("@Label").Value ==  "Advising Relationship")
                    {
                        propertylist.Add(new GenericListItem(space + property.SelectSingleNode("@Label").Value, property.SelectSingleNode("@ClassURI").Value));
                    }
                }
                else
                {
                    propertylist.Add(new GenericListItem(space + property.SelectSingleNode("@Label").Value, property.SelectSingleNode("@ClassURI").Value));
                }
                space = string.Empty;
            }

            PropertyList = propertylist;

            if (ddlPropertyList.SelectedValue == string.Empty)
            {
                ddlPropertyList.DataSource = propertylist;
                ddlPropertyList.DataTextField = "Text";
                ddlPropertyList.DataValueField = "Value";
                ddlPropertyList.DataBind();
                ddlPropertyList.Items.Insert(0, new ListItem("--- Select ---", ""));
                ddlPropertyList.SelectedValue = "";
                ddlPropertyList.EnableViewState = true;

            }

            if (ddlAddNewPropertyList.SelectedValue == string.Empty)
            {
                ddlAddNewPropertyList.DataSource = propertylist;
                ddlAddNewPropertyList.DataTextField = "Text";
                ddlAddNewPropertyList.DataValueField = "Value";
                ddlAddNewPropertyList.DataBind();
                ddlAddNewPropertyList.Items.Insert(0, new ListItem("--- Select ---", ""));
                ddlAddNewPropertyList.SelectedValue = "";
                ddlAddNewPropertyList.EnableViewState = true;
            }
        }
Ejemplo n.º 18
0
        protected void btnCreateORCIDs_Click(object sender, EventArgs e)
        {
            Profiles.Framework.Utilities.DataIO data = new Profiles.Framework.Utilities.DataIO();
            if (data.GetSessionSecurityGroup() != -50)
            {
                this.AddError("Only Administrators can push records to ORCID");
            }
            else
            {
                foreach (RepeaterItem ri in this.rptSearchResults.Items)
                {
                    switch (ri.ItemType)
                    {
                        case ListItemType.Item:
                        case ListItemType.AlternatingItem:
                            CheckBox chkSelected = (CheckBox)ri.FindControl("chkSelected");
                            if (chkSelected.Checked)
                            {
                                Label lblPersonID = (Label)ri.FindControl("lblPersonID");
                                Label lblErrors = (Label)ri.FindControl("lblErrors");
                                Label lblMessages = (Label)ri.FindControl("lblMessages");

                                try
                                {
                                    Profiles.ORCID.Utilities.ProfilesRNSDLL.BO.ORCID.Person bo = new Profiles.ORCID.Utilities.ProfilesRNSDLL.BLL.ORCID.Person().GetPersonWithDBData(int.Parse(lblPersonID.Text), sm.Session().SessionID);
                                    if (!bo.BiographyIsNull && !bo.Biography.Equals(string.Empty))
                                    {
                                        bo.PushBiographyToORCID = true;
                                    }

                                    //System.Threading.Thread.Sleep(2000);

                                    if (new Profiles.ORCID.Utilities.ProfilesRNSDLL.BLL.ORCID.Person().CreateNewORCID(bo, LoggedInInternalUsername, Profiles.ORCID.Utilities.ProfilesRNSDLL.BO.ORCID.REFPersonStatusType.REFPersonStatusTypes.User_Push_Failed))
                                    {
                                        Edit.Utilities.DataIO dataio = new Edit.Utilities.DataIO();
                                        long subjectID = Profiles.ORCID.Utilities.DataIO.getNodeIdFromPersonID(int.Parse(lblPersonID.Text));
                                        dataio.AddLiteral(subjectID, dataio.GetStoreNode("http://vivoweb.org/ontology/core#orcidId"), dataio.GetStoreNode(bo.ORCID), this.PropertyListXML);
                                        lblMessages.Text = "Success";
                                    }
                                    else
                                    {
                                        lblErrors.Text = bo.Error + bo.AllErrors + "<br /><br />";
                                    }
                                }
                                catch (Exception ex)
                                {
                                    // todo remove
                                    lblErrors.Text = ex.Message;
                                    //this.lblErrors.Text = "An error occurred while creating the ORCID.";
                                }
                            }
                            break;
                    }
                }
            }
        }
Ejemplo n.º 19
0
        private void DrawProfilesModule()
        {
            this.first = true;
            Utilities.DataIO   data        = new Profiles.Framework.Utilities.DataIO();
            List <NetworkItem> networkitem = new List <NetworkItem>();

            if (HttpContext.Current.Request.QueryString["subject"] != null)
            {
                this.Subject = Convert.ToInt64(HttpContext.Current.Request.QueryString["subject"]);
            }

            hdSubject.Value = this.Subject.ToString();

            using (SqlDataReader reader = data.GetActiveNetwork(0, false))
            {
                while (reader.Read())
                {
                    networkitem.Add(new NetworkItem(reader[1].ToString(), Convert.ToInt64(reader[2]), reader[3].ToString()));
                }

                if (!reader.IsClosed)
                {
                    reader.Close();
                }
            }


            if (networkitem.Count > 0)
            {
                gvActiveNetwork.DataSource = networkitem;
                gvActiveNetwork.DataBind();
                this.Count = networkitem.Count;
                string seeall = string.Empty;
                if (this.Count > 1)
                {
                    seeall = "See all " + networkitem.Count.ToString() + " people";
                }
                else
                {
                    seeall = "See all people";
                }
                litActiveNetworkDetails.Text = "<li  style='height: 25px !important'><a style='border-left:1px solid #383737;border-right:1px solid #383737;border-bottom:1px solid #383737;border-top:2px solid #383737;' href='" + Root.Domain + "/activenetwork/default.aspx'>" + seeall + "</a></li>";
            }
            else
            {
                gvActiveNetwork.Visible         = false;
                litActiveNetworkDetails.Visible = false;
            }


            if (sm.Session().UserID != 0 && Subject > 0)
            {
                if (this.Subject != sm.Session().NodeID&& (Root.AbsolutePath.Contains("/display/")))
                {
                    int count = RelationshipTypeUtils.GetRelationshipTypes(Convert.ToInt64(Subject)).Count;

                    if (count > 0)
                    {
                        rptRelationshipTypes.DataSource = RelationshipTypeUtils.GetRelationshipTypes(Convert.ToInt64(Subject));
                        rptRelationshipTypes.DataBind();
                        this.Count = count;
                        rptRelationshipTypes.Visible = true;
                    }
                    else
                    {
                        rptRelationshipTypes.Visible = false;
                    }
                }
            }
        }
Ejemplo n.º 20
0
        //***************************************************************************************************************************************
        private void ProcessRequest()
        {
            Framework.Utilities.DebugLogging.Log("{REST.aspx.cs} ProcessRequest() start ");

            string param0 = string.Empty; //Application Name {default for this install is profile}
            string param1 = string.Empty;
            string param2 = string.Empty;
            string param3 = string.Empty;
            string param4 = string.Empty;
            string param5 = string.Empty;
            string param6 = string.Empty;
            string param7 = string.Empty;
            string param8 = string.Empty;
            string param9 = string.Empty;

            XmlDocument frameworkurl = new XmlDocument();

            if (HttpContext.Current.Items["Param0"] != null)
            {
                param0 = HttpContext.Current.Items["Param0"].ToString();
            }
            else { }

            if (HttpContext.Current.Items["Param1"] != null)
            {
                param1 = HttpContext.Current.Items["Param1"].ToString();
            }
            else { }

            if (HttpContext.Current.Items["Param2"] != null)
            {
                param2 = HttpContext.Current.Items["Param2"].ToString();
            }
            else { }

            if (HttpContext.Current.Items["Param3"] != null)
            {
                param3 = HttpContext.Current.Items["Param3"].ToString();
            }
            else { }

            if (HttpContext.Current.Items["Param4"] != null)
            {
                param4 = HttpContext.Current.Items["Param4"].ToString();
            }
            else { }

            if (HttpContext.Current.Items["Param5"] != null)
            {
                param5 = HttpContext.Current.Items["Param5"].ToString();
            }
            else { }

            if (HttpContext.Current.Items["Param6"] != null)
            {
                param6 = HttpContext.Current.Items["Param6"].ToString();
            }
            else { }

            if (HttpContext.Current.Items["Param7"] != null)
            {
                param7 = HttpContext.Current.Items["Param7"].ToString();
            }
            else { }

            if (HttpContext.Current.Items["Param8"] != null)
            {
                param8 = HttpContext.Current.Items["Param8"].ToString();
            }
            else { }

            if (HttpContext.Current.Items["Param9"] != null)
            {
                param9 = HttpContext.Current.Items["Param9"].ToString();
            }
            else { }

            DataIO data = new DataIO();

            //Alias.aspx is the hub for maintaining session state. With the exception of a log in Function.
            //the Framework.Session is created and loaded into memory at the point a user session is created in the Global.asax file.
            //When a session has expired the Framework.Session.SessionLogout() method is called.
            SessionManagement sessionmanagement = new SessionManagement();
            Session session = sessionmanagement.Session();

            URLResolve resolve = data.GetResolvedURL(param0,
                                   param1,
                                   param2,
                                   param3,
                                   param4,
                                   param5,
                                   param6,
                                   param7,
                                   param8,
                                   param9,
                                   session.SessionID,
                                   Root.Domain + Root.AbsolutePath,
                                   session.UserAgent,
                                   getBestAcceptType(HttpContext.Current.Request.AcceptTypes));

            Framework.Utilities.DebugLogging.Log("{REST.aspx.cs} ProcessRequest() redirect=" + resolve.Redirect.ToString() + " to=>" + resolve.ResponseURL);

            if (resolve.Resolved && !resolve.Redirect)
            {
                string URL = resolve.ResponseURL;
                Server.Execute(HttpUtility.HtmlDecode(URL));
            }
            else if (resolve.Resolved && resolve.Redirect)
            {
                Response.Redirect(resolve.ResponseURL, true);
            }
            else
            {
                Response.Redirect(Root.Domain + "/search", true);

                //Response.Write("<b>Debug 404-- Your URL does not match a known Profiles RESTful pattern ---</b><br/><br/> ");

                //Response.Write("<br/>0: ");
                //Response.Write(param0);

                //Response.Write("<br/>1: ");
                //Response.Write(param1);

                //Response.Write("<br/>2: ");
                //Response.Write(param2);

                //Response.Write("<br/>3: ");
                //Response.Write(param3);

                //Response.Write("<br/>4: ");
                //Response.Write(param4);

                //Response.Write("<br/>5: ");
                //Response.Write(param5);

                //Response.Write("<br/>6: ");
                //Response.Write(param6);

                //Response.Write("<br/>7: ");
                //Response.Write(param7);

                //Response.Write("<br/>8: ");
                //Response.Write(param8);

                //Response.Write("<br/>9: ");
                //Response.Write(param9);

                //Response.Write("<br/><br/>Domain: ");
                //Response.Write(Root.Domain);

                //throw new Exception("custom 404 needed here");
            }

            Framework.Utilities.DebugLogging.Log("{REST.aspx.cs} ProcessRequest() end ");
        }
Ejemplo n.º 21
0
        //public void SessionAddHistory(string pagename, string pagetype, string pageid, bool isvisible, bool isstackstart)
        //{
        //    SessionHistory sessionhistory = new SessionHistory();
        //    DataIO dataio = new DataIO();
        //    sessionhistory.SessionID = this.SessionGetInfo().SessionID;
        //    sessionhistory.PageURL = Root.AbsolutePath;
        //    sessionhistory.PageName = pagename;
        //    sessionhistory.PageType = pagetype;
        //    sessionhistory.PageID = pageid;
        //    sessionhistory.IsVisible = isvisible;
        //    dataio.SessionAddHistory(sessionhistory);
        //    dataio = null;
        //}
        public void SessionLogin(int userid, int personid)
        {
            DataIO dataio = new DataIO();
            Session session = this.Session();

            session.UserID = userid;
            session.PersonID = personid;

            dataio.SessionUpdate(ref session);
            dataio = null;

            HttpContext.Current.Session["PROFILES_SESSION"] = session;
        }
        private void DrawProfilesModule()
        {
            Int64 subject = 0;

            if (Request.QueryString["subject"] != null)
                subject = Convert.ToInt64(Request.QueryString["subject"]);

            Utilities.DataIO data = new Profiles.Framework.Utilities.DataIO();
            menulist.Append("<ul>");

            menulist.Append("<li><a href='" + Root.Domain + "/search'>New Search</a></li>");

            //-50 is the profiles Admin
            if (data.GetSessionSecurityGroup() == -50)
                menulist.Append("<li><a href='" + Root.Domain + "/SPARQL/default.aspx'>SPARQL Query</a></li>");

            menulist.Append("<li><a href='" + Root.Domain + "/about/default.aspx'>About Profiles</a></li>");

            // UCSF
            //if (sm.Session().NodeID != subject && sm.Session().NodeID > 0)
            //    menulist.Append("<li><a href='" + sm.Session().PersonURI + "'>View My Profile</a></li>");
            if (sm.Session().NodeID > 0)
            {
                menulist.Append("<li><img src='" + Root.Domain + "/profile/Modules/CustomViewPersonGeneralInfo/PhotoHandler.ashx?NodeID=" + sm.Session().NodeID + "&ShowSilhouetteAsDefault=True'></li>");
                menulist.Append("<li><a href='" + sm.Session().PersonURI + "'>" + sm.Session().ShortDisplayName + "</a></li>");
            }

            if (!Root.AbsolutePath.ToLower().Contains("/edit/"))
            {
                if ((sm.Session().UserID > 0 && sm.Session().PersonID > 0) || (sm.Session().UserID == 0 && sm.Session().PersonID == 0))
                {
                    menulist.Append("<li><a href='" + Root.Domain + "/login/default.aspx?method=login&edit=true'>Edit My Profile</a></li>");
                }
            }

            if (base.PresentationXML.SelectSingleNode("Presentation/PageOptions[@CanEdit='true']") != null && !Root.AbsolutePath.ToLower().Contains("/edit/"))
            {
                if (sm.Session().NodeID != subject)
                    menulist.Append("<li><a href='" + Root.Domain + "/edit/" + subject.ToString() + "'>Edit This Profile</a></li>");

            }

            if (sm.Session().NodeID > 0)
                menulist.Append("<li><a href='" + Root.Domain + "/proxy/default.aspx?subject=" + sm.Session().NodeID.ToString() + "'>Manage Proxies</a></li>");

            if (base.BaseData.SelectSingleNode(".").OuterXml != string.Empty && !Root.AbsolutePath.ToLower().Contains("/search/"))
            {
                if (base.BaseData.SelectSingleNode("//rdf:RDF/rdf:Description/@rdf:about", base.Namespaces) != null)
                {
                    string uri = this.BaseData.SelectSingleNode("//rdf:RDF/rdf:Description/@rdf:about", base.Namespaces).Value;

                    //IF the URI is in our system then we build the link. If not then we do not build the link for the data.
                    if (uri.Contains(Root.Domain))
                    {
                        string file = string.Empty;
                        string spostring = string.Empty;
                        string[] spoarray;

                        spostring = uri.ToLower().Replace(Root.Domain.ToLower() + "/profile/", "");
                        spoarray = spostring.Split('/');

                        for (int i = 0; i < spoarray.Length; i++)
                        {
                            file = file + spoarray[i] + "_";
                        }

                        file = file.Substring(0, file.Length - 1);

                        menulist.Append("<li><a href=\"" + uri + "/" + file + ".rdf\" target=\"_blank\">" + "Export RDF" + "</a></li>");

                        if (base.MasterPage != null)
                        {
                            System.Web.UI.HtmlControls.HtmlContainerControl Head1;
                            Head1 = (System.Web.UI.HtmlControls.HtmlContainerControl)base.MasterPage.FindControl("Head1");
                            //If a masterpage exists, you need to to create an ASP.Net Literal object and pass it to the masterpage so it can process the link in the Head block.
                            string link = "<link rel=\"alternate\" type=\"application/rdf+xml\" href=\"" + uri + "/" + file + ".rdf\" />";
                            Head1.Controls.Add(new LiteralControl(link));
                        }

                    }
                }
            }

            if (sm.Session().UserID == 0)
            {
                if (!Root.AbsolutePath.Contains("login"))
                {
                    menulist.Append("<li><a href='" + Root.Domain + "/login/default.aspx?method=login&redirectto=" + Root.Domain + Root.AbsolutePath + "'>Login to Profiles</a></li>");
                }

            }
            else
            {
                menulist.Append("<li><a href='" + Root.Domain + "/login/default.aspx?method=logout&redirectto=" + Root.Domain + "/About/CloseBrowser.aspx" + "'>Sign out</a></li>");
            }

            menulist.Append("</ul>");

            // hide active networks DIV if not logged in
            if (sm.Session().UserID > 0)
            {
                ActiveNetworkRelationshipTypes.Visible = true;
            }
            else
            {
                ActiveNetworkRelationshipTypes.Visible = false;
            }

            panelMenu.InnerHtml = menulist.ToString();
        }
        private void DrawProfilesModule()
        {
            SqlDataReader reader;
            Framework.Utilities.DataIO data = new Profiles.Framework.Utilities.DataIO();
            List<NetworkItem> ni = new List<NetworkItem>();
            List<NetworkItem> nibinder;

            reader = data.GetActiveNetwork(0, true);

            while (reader.Read())
            {
                ni.Add(new NetworkItem(reader["URI"].ToString(),
                    reader["Name"].ToString(),
                    Convert.ToInt64(reader["NodeID"]),
                    reader["RelationshipType"].ToString(),
                    reader["RelationshipName"].ToString()));
            }

            nibinder = this.GetItems("Collaborator", ni);
            litCollaborators.Text = "<b>Collaborators</b> (" + nibinder.Count.ToString() + ")";
            gvCollaborators.DataSource = nibinder;
            gvCollaborators.DataBind();

            nibinder = this.GetItems("CurrentAdvisor", ni);
            litAdvisorsCurrent.Text = "<b>Advisor (Current)</b> (" + nibinder.Count.ToString() + ")";
            gvAdvisorsCurrent.DataSource = nibinder;
            gvAdvisorsCurrent.DataBind();
            nibinder = new List<NetworkItem>();

            nibinder = this.GetItems("CurrentAdvisee", ni);
            litAdviseesCurrent.Text = "<b>Advisee (Current)</b> (" + nibinder.Count.ToString() + ")";
            gvAdviseesCurrent.DataSource = nibinder;
            gvAdviseesCurrent.DataBind();
            nibinder = new List<NetworkItem>();

            nibinder = this.GetItems("PastAdvisor", ni);
            litAdvisorsPast.Text = "<b>Advisor (Past)</b> (" + nibinder.Count.ToString() + ")";
            gvAdvisorsPast.DataSource = nibinder;
            gvAdvisorsPast.DataBind();
            nibinder = new List<NetworkItem>();

            nibinder = this.GetItems("PastAdvisee", ni);
            litAdviseesPast.Text = "<b>Advisee (Past)</b> (" + nibinder.Count.ToString() + ")";
            gvAdviseesPast.DataSource = nibinder;
            gvAdviseesPast.DataBind();
        }
        public void DrawProfilesModule()
        {
            Framework.Utilities.DataIO data = new Profiles.Framework.Utilities.DataIO();

            if (Request.Form["hdnSelectedURI"] != string.Empty && Request.Form["hdnSelectedURI"] != null)
            {
                Edit.Utilities.DataIO editdata = new Profiles.Edit.Utilities.DataIO();

                string newentity = string.Empty;

                newentity = Request.Form["hdnSelectedURI"].Trim();

                Int64 _object = Convert.ToInt64(editdata.GetStoreNode(newentity));

                editdata.AddExistingEntity(this.SubjectID, this.PredicateID, _object);
                Session["pnlAddBySearch.Visible"] = null;
                this.LoadEntityGrid(true);
            }
            else
            {
                LoadEntityGrid(false);
            }

            XmlDocument            list         = data.GetPropertyRangeList(this.PredicateURI);
            List <GenericListItem> propertylist = new List <GenericListItem>();
            string space = string.Empty;


            foreach (XmlNode property in list.SelectNodes("PropertyRangeList/PropertyRange"))
            {
                for (int i = 0; i < Convert.ToInt16(property.SelectSingleNode("@Depth").Value); i++)
                {
                    space += Server.HtmlDecode("&nbsp;&nbsp;&nbsp;");
                }
                propertylist.Add(new GenericListItem(space + property.SelectSingleNode("@Label").Value, property.SelectSingleNode("@ClassURI").Value));
                space = string.Empty;
            }

            PropertyList = propertylist;

            if (ddlPropertyList.SelectedValue == string.Empty)
            {
                ddlPropertyList.DataSource     = propertylist;
                ddlPropertyList.DataTextField  = "Text";
                ddlPropertyList.DataValueField = "Value";
                ddlPropertyList.DataBind();
                ddlPropertyList.Items.Insert(0, new ListItem("--- Select ---", ""));
                ddlPropertyList.SelectedValue   = "";
                ddlPropertyList.EnableViewState = true;
            }

            if (ddlAddNewPropertyList.SelectedValue == string.Empty)
            {
                ddlAddNewPropertyList.DataSource     = propertylist;
                ddlAddNewPropertyList.DataTextField  = "Text";
                ddlAddNewPropertyList.DataValueField = "Value";
                ddlAddNewPropertyList.DataBind();
                ddlAddNewPropertyList.Items.Insert(0, new ListItem("--- Select ---", ""));
                ddlAddNewPropertyList.SelectedValue   = "";
                ddlAddNewPropertyList.EnableViewState = true;
            }
        }
        //***************************************************************************************************************************************
        /// <summary>
        /*

            This method implements the loading of all URLs patterns that contain file extensions that need to be ignored and
            all URLs patterns that need to be processed:

            Example of patterns to process:
            routes.Add("ProfilesAliasPath2", new Route("{Param0}/{Param1}/{Param2}", new ProfilesRouteHandler()));
                The above example will register a URL pattern for processing by the Alias.aspx page.  When IIS makes a request,
                the URL pattern of http://domain.com/profile/person/32213, will trigger the .Net System.Web.Routing library to call ProfilesRouteHandler.GetHttpHandler(RequestContext requestContext){}.  This method will process the URL pattern into parameters and load the HttpContext.Current.Items hash table and then direct the request to the Alias.aspx page for processing.

         */
        /// </summary>
        /// <param name="routes">RouteTable.Routes is passed as a RouteCollection by ref used to store all routes in the routing framework.</param>
        private static void RegisterRoutes(RouteCollection routes)
        {
            Framework.Utilities.DataIO d = new Framework.Utilities.DataIO();

            System.Data.SqlClient.SqlDataReader reader;

            //The REST Paths are built based on the applicaitons setup in the Profiles database.
            reader = d.GetRESTApplications();
            int loop = 0;

            routes.RouteExistingFiles = false;

            // by UCSF
            routes.Add("RobotsTxt", new Route("robots.txt", new RobotsTxtHandler()));
            routes.Add("SiteMap", new Route("sitemap.xml", new SiteMapHandler()));

            while (reader.Read())
            {
                routes.Add("ProfilesAliasPath0" + loop, new Route(reader[0].ToString(), new ProfilesRouteHandler()));

                // do not want to add these others for non pretty names
                if (!reader[0].ToString().Contains("."))
                {
                    routes.Add("ProfilesAliasPath1" + loop, new Route(reader[0].ToString() + "/{Param1}", new ProfilesRouteHandler()));
                    routes.Add("ProfilesAliasPath2" + loop, new Route(reader[0].ToString() + "/{Param1}/{Param2}", new ProfilesRouteHandler()));
                    routes.Add("ProfilesAliasPath3" + loop, new Route(reader[0].ToString() + "/{Param1}/{Param2}/{Param3}", new ProfilesRouteHandler()));
                    routes.Add("ProfilesAliasPath4" + loop, new Route(reader[0].ToString() + "/{Param1}/{Param2}/{Param3}/{Param4}", new ProfilesRouteHandler()));
                    routes.Add("ProfilesAliasPath5" + loop, new Route(reader[0].ToString() + "/{Param1}/{Param2}/{Param3}/{Param4}/{Param5}", new ProfilesRouteHandler()));
                    routes.Add("ProfilesAliasPath6" + loop, new Route(reader[0].ToString() + "/{Param1}/{Param2}/{Param3}/{Param4}/{Param5}/{Param6}", new ProfilesRouteHandler()));
                    routes.Add("ProfilesAliasPath7" + loop, new Route(reader[0].ToString() + "/{Param1}/{Param2}/{Param3}/{Param4}/{Param5}/{Param6}/{Param7}", new ProfilesRouteHandler()));
                    routes.Add("ProfilesAliasPath8" + loop, new Route(reader[0].ToString() + "/{Param1}/{Param2}/{Param3}/{Param4}/{Param5}/{Param6}/{Param7}/{Param8}", new ProfilesRouteHandler()));
                    routes.Add("ProfilesAliasPath9" + loop, new Route(reader[0].ToString() + "/{Param1}/{Param2}/{Param3}/{Param4}/{Param5}/{Param6}/{Param7}/{Param8}/{Param9}", new ProfilesRouteHandler()));
                }

                Framework.Utilities.DebugLogging.Log("REST PATTERN(s) CREATED FOR " + reader[0].ToString());
                loop++;
            }

            if (!reader.IsClosed)
                reader.Close();
        }
Ejemplo n.º 26
0
        //***************************************************************************************************************************************
        /// <summary>
        /*

            This method implements the loading of all URLs patterns that contain file extensions that need to be ignored and
            all URLs patterns that need to be processed:

            Example of patterns to process:
            routes.Add("ProfilesAliasPath2", new Route("{Param0}/{Param1}/{Param2}", new ProfilesRouteHandler()));
                The above example will register a URL pattern for processing by the Alias.aspx page.  When IIS makes a request,
                the URL pattern of http://domain.com/profile/person/32213, will trigger the .Net System.Web.Routing library to call ProfilesRouteHandler.GetHttpHandler(RequestContext requestContext){}.  This method will process the URL pattern into parameters and load the HttpContext.Current.Items hash table and then direct the request to the Alias.aspx page for processing.

         */
        /// </summary>
        /// <param name="routes">RouteTable.Routes is passed as a RouteCollection by ref used to store all routes in the routing framework.</param>
        private static void RegisterRoutes(RouteCollection routes)
        {
            Framework.Utilities.DataIO d = new Framework.Utilities.DataIO();

            //The REST Paths are built based on the applications setup in the Profiles database.
            using (System.Data.SqlClient.SqlDataReader reader = d.GetRESTApplications())
            {
                int loop = 0;

                routes.RouteExistingFiles = false;

                // by UCSF
                routes.Add("RobotsTxt", new Route("robots.txt", new AspxHandler("~/RobotsTxt.aspx")));
                routes.Add("SiteMap", new Route("sitemap.xml", new AspxHandler("~/SiteMap.aspx")));

                while (reader.Read())
                {
                    routes.Add("ProfilesAliasPath0" + loop, new Route(reader[0].ToString(), new ProfilesRouteHandler()));
                    routes.Add("ProfilesAliasPath1" + loop, new Route(reader[0].ToString() + "/{Param1}", new ProfilesRouteHandler()));
                    routes.Add("ProfilesAliasPath2" + loop, new Route(reader[0].ToString() + "/{Param1}/{Param2}", new ProfilesRouteHandler()));
                    routes.Add("ProfilesAliasPath3" + loop, new Route(reader[0].ToString() + "/{Param1}/{Param2}/{Param3}", new ProfilesRouteHandler()));
                    routes.Add("ProfilesAliasPath4" + loop, new Route(reader[0].ToString() + "/{Param1}/{Param2}/{Param3}/{Param4}", new ProfilesRouteHandler()));
                    routes.Add("ProfilesAliasPath5" + loop, new Route(reader[0].ToString() + "/{Param1}/{Param2}/{Param3}/{Param4}/{Param5}", new ProfilesRouteHandler()));
                    routes.Add("ProfilesAliasPath6" + loop, new Route(reader[0].ToString() + "/{Param1}/{Param2}/{Param3}/{Param4}/{Param5}/{Param6}", new ProfilesRouteHandler()));
                    routes.Add("ProfilesAliasPath7" + loop, new Route(reader[0].ToString() + "/{Param1}/{Param2}/{Param3}/{Param4}/{Param5}/{Param6}/{Param7}", new ProfilesRouteHandler()));
                    routes.Add("ProfilesAliasPath8" + loop, new Route(reader[0].ToString() + "/{Param1}/{Param2}/{Param3}/{Param4}/{Param5}/{Param6}/{Param7}/{Param8}", new ProfilesRouteHandler()));
                    routes.Add("ProfilesAliasPath9" + loop, new Route(reader[0].ToString() + "/{Param1}/{Param2}/{Param3}/{Param4}/{Param5}/{Param6}/{Param7}/{Param8}/{Param9}", new ProfilesRouteHandler()));

                    Framework.Utilities.DebugLogging.Log("REST PATTERN(s) CREATED FOR " + reader[0].ToString());
                    loop++;
                }
            }
        }
        /// <summary>
        ///     Public method used to create an instance of the custom Profiles session object.
        /// </summary>
        public void SessionCreate()
        {
            string sessionid = string.Empty;
            string ORNGViewer = null;

            if (HttpContext.Current.Request["ContainerSessionID"] != null)
            {
                // ORNG this means it is from shindigorng. Grab the associated session and user
                sessionid = HttpContext.Current.Request["ContainerSessionID"];
                ORNGViewer = HttpContext.Current.Request["Viewer"];
            }
            else if (HttpContext.Current.Request.Headers["SessionID"] != null)
                sessionid = HttpContext.Current.Request.Headers["SessionID"];

            DataIO dataio = new DataIO();
            Session session = new Session();
            string hostname = System.Net.Dns.GetHostName();

            string ipaddress = string.Empty;
            try
            {
                ipaddress = System.Net.Dns.GetHostAddresses(hostname).GetValue(1).ToString();
            }
            catch (Exception ex)
            {
                Framework.Utilities.DebugLogging.Log(ex.Message + " ++ " + ex.StackTrace);
                ipaddress = "";
            }

            session.RequestIP = ipaddress;
            session.UserAgent = HttpContext.Current.Request.UserAgent;
            session.IsBot = IsBot(session.UserAgent);

            if (sessionid == string.Empty)
                dataio.SessionCreate(ref session);
            else
            {
                session.SessionID = sessionid;
                if (ORNGViewer != null && ORNGViewer.LastIndexOf('/') > 0)
                {
                    session.UserID = Convert.ToInt32(ORNGViewer.Substring(ORNGViewer.LastIndexOf('/') + 1));
                }
            }

            //Store the object in the current session of the user.
            HttpContext.Current.Session["PROFILES_SESSION"] = session;
        }
        //public void SessionAddHistory(string pagename, string pagetype, string pageid, bool isvisible, bool isstackstart)
        //{
        //    SessionHistory sessionhistory = new SessionHistory();
        //    DataIO dataio = new DataIO();
        //    sessionhistory.SessionID = this.SessionGetInfo().SessionID;
        //    sessionhistory.PageURL = Root.AbsolutePath;
        //    sessionhistory.PageName = pagename;
        //    sessionhistory.PageType = pagetype;
        //    sessionhistory.PageID = pageid;
        //    sessionhistory.IsVisible = isvisible;
        //    dataio.SessionAddHistory(sessionhistory);
        //    dataio = null;
        //}
        public void SessionLogout()
        {
            DataIO dataio = new DataIO();
            Session session = this.Session();
            session.LogoutDate = DateTime.Now;
            dataio.SessionUpdate(ref session);

            session = null;
            dataio = null;
        }
Ejemplo n.º 29
0
        private void DrawProfilesModule()
        {

            Utilities.DataIO data = new Profiles.Framework.Utilities.DataIO();
            SqlDataReader reader;

            List<NetworkItem> networkitem = new List<NetworkItem>();

            this.RelationshipTypes = new List<RelationshipType>();

            Int64 subject = 0;

            if (HttpContext.Current.Request.QueryString["subject"] != null)
            {
                subject = Convert.ToInt64(HttpContext.Current.Request.QueryString["subject"]);
            }

            if (sm.Session().UserID != 0)
            {
                if (subject != sm.Session().NodeID && subject != 0 && (!Root.AbsolutePath.Contains("/proxy") && !Root.AbsolutePath.Contains("/edit")))
                {
                    reader = data.GetActiveNetwork(subject, true);

                    while (reader.Read())
                    {
                        this.RelationshipTypes.Add(new RelationshipType(reader["RelationshipName"].ToString(), reader["RelationshipType"].ToString(), Convert.ToBoolean(reader["DoesExist"])));

                    }
                    if (RelationshipTypes.Count > 0)
                    {
                        rptRelationshipTypes.DataSource = this.RelationshipTypes;
                        rptRelationshipTypes.DataBind();
                        pnlSetActiveNetworks.Visible = true;
                    }
                    else
                    {
                        pnlSetActiveNetworks.Visible = false;
                    }
                }
                else
                {
                    pnlSetActiveNetworks.Visible = false;
                }
            }

            reader = data.GetActiveNetwork(0, false);

            while (reader.Read())
            {
                networkitem.Add(new NetworkItem(reader[1].ToString(), Convert.ToInt64(reader[2]), reader[3].ToString()));
            }

            if (!reader.IsClosed)
                reader.Close();

            if (networkitem.Count > 0)
            {
                gvActiveNetwork.DataSource = networkitem;
                gvActiveNetwork.DataBind();

                pnlMyNetwork.Visible = true;

                litActiveNetworkDetails.Text = "<a class='activeSectionDetails' href='" + Root.Domain + "/activenetwork/default.aspx'><font style='font-size:10px'>View Details</font></a>";
            }
            else
            {
                pnlMyNetwork.Visible = false;
            }


        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns>Current Framework.Session object from the database.</returns>
        private Session SessionGetInfo()
        {
            //I commented out the SessionGetInfo(ref.... code for now

            if (HttpContext.Current.Session["PROFILES_SESSION"] == null)
            {
                SessionCreate();
            }
            else
            {
                DataIO dataio = new DataIO();
                Session session = (Session)(HttpContext.Current.Session["PROFILES_SESSION"]);

                //  dataio.SessionGetInfo(ref session);

                (HttpContext.Current.Session["PROFILES_SESSION"]) = session;

            }

            return (Session)HttpContext.Current.Session["PROFILES_SESSION"];
        }
        private void DrawProfilesModule()
        {
            Utilities.DataIO data = new Profiles.Framework.Utilities.DataIO();
            SqlDataReader reader;

            List<NetworkItem> networkitem = new List<NetworkItem>();

            this.RelationshipTypes = new List<RelationshipType>();

            if (sm.Session().NodeID != null)
                try
                {
                    this.Subject = sm.Session().NodeID;
                }
                catch (Exception ex)
                {
                    this.Subject = 0;
                }
            else
                this.Subject = 0;

            if (sm.Session().NodeID != 0)
            {
                if ((Convert.ToInt64(HttpContext.Current.Request.QueryString["subject"]) != sm.Session().NodeID) && (HttpContext.Current.Request.QueryString["subject"] != null))
                {
                    reader = data.GetActiveNetwork(Convert.ToInt64(HttpContext.Current.Request.QueryString["subject"]), true);
                    while (reader.Read())
                    {
                        this.RelationshipTypes.Add(new RelationshipType(reader["RelationshipName"].ToString(), reader["RelationshipType"].ToString(), Convert.ToBoolean(reader["DoesExist"])));
                    }
                    if (RelationshipTypes.Count > 0)
                    {
                        rptRelationshipTypes.DataSource = this.RelationshipTypes;
                        rptRelationshipTypes.DataBind();
                        pnlSetActiveNetworks.Visible = true;

                    }
                    else
                    {
                        pnlSetActiveNetworks.Visible = false;
                    }
                }
                else
                {
                    pnlSetActiveNetworks.Visible = false;
                }

            }

            /** UCSF
            reader = data.GetActiveNetwork(0, false);

            while (reader.Read())
            {
                networkitem.Add(new NetworkItem(reader[1].ToString(), Convert.ToInt64(reader[2]), reader[3].ToString()));
            }

            if (!reader.IsClosed)
                reader.Close();

            if (networkitem.Count > 0)
            {
                gvActiveNetwork.DataSource = networkitem;
                gvActiveNetwork.DataBind();

                pnlMyNetwork.Visible = true;

                litActiveNetworkDetails.Text = "<a class='activeSectionDetails' href='" + Root.Domain + "/activenetwork/default.aspx'>View Details</a>";
            }
            else
            {
                pnlMyNetwork.Visible = false;
            }

            */
        }
        private void DrawProfilesModule()
        {
            Int64 subject = 0;

            HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
            HttpContext.Current.Response.Cache.SetExpires(DateTime.Now);
            HttpContext.Current.Response.Cache.SetNoServerCaching();
            HttpContext.Current.Response.Cache.SetNoStore();

            if (Request.QueryString["subject"] != null)
            {
                subject = Convert.ToInt64(Request.QueryString["subject"]);
            }

            Utilities.DataIO data = new Profiles.Framework.Utilities.DataIO();

            //litSearchOptions.Text = "<li class='first'><a class='search-drop' href='" + Root.Domain + "/search'>Find People</a></li><li class='last'><a class='search-drop' style='border-bottom:1px solid #383737;' href='" + Root.Domain + "/search/all'>Find Everything</a></li>";
            litJs.Text = "";
            if (sm.Session().NodeID > 0)
            {
                litViewMyProfile.Text = "<li><a href='" + sm.Session().PersonURI + "'>View My Profile</a></li>";
            }


            litEditThisProfile.Text = "<li><a href='" + Root.Domain + "/login/default.aspx?pin=send&method=login&edit=true'>Edit My Profile</a></li>";

            if (base.MasterPage.CanEdit)
            {
                litEditThisProfile.Text += "<li><div class=\"divider\"></div></li><li><a href='" + Root.Domain + "/edit/default.aspx?subject=" + subject.ToString() + "'>Edit This Profile</a></li>";
            }

            if (sm.Session().UserID > 0)
            {
                litProxy.Text = "<li>Manage Proxies</li>";
                litProxy.Text = "<li><a href='" + Root.Domain + "/proxy/default.aspx?subject=" + sm.Session().NodeID.ToString() + "'>Manage Proxies</a></li>";
            }

            if (base.BaseData.SelectSingleNode(".").OuterXml != string.Empty && !Root.AbsolutePath.ToLower().Contains("/search"))
            {
                if (base.BaseData.SelectSingleNode("//rdf:RDF/rdf:Description/@rdf:about", base.Namespaces) != null && !Root.AbsolutePath.ToLower().Contains("proxy"))
                {
                    string uri = this.BaseData.SelectSingleNode("//rdf:RDF/rdf:Description/@rdf:about", base.Namespaces).Value;

                    string   file      = string.Empty;
                    string   spostring = string.Empty;
                    string[] spoarray;

                    spostring = uri.ToLower().Replace(Root.Domain.ToLower() + "/profile/", "");
                    spoarray  = spostring.Split('/');

                    for (int i = 0; i < spoarray.Length; i++)
                    {
                        file = file + spoarray[i] + "_";
                    }

                    file = file.Substring(0, file.Length - 1);

                    //litExportRDF.Text = "<li ><a style='border-bottom:1px solid #383737;border-left:1px solid #383737;border-right:1px solid  #383737;width:200px !important' href=\"" + uri + "/" + file + ".rdf\" target=\"_blank\">" + "Export This Page as RDF" + "</a></li>";

                    if (base.MasterPage != null)
                    {
                        System.Web.UI.HtmlControls.HtmlContainerControl Head1;
                        Head1 = (System.Web.UI.HtmlControls.HtmlContainerControl)base.MasterPage.FindControl("Head1");
                        //If a masterpage exists, you need to to create an ASP.Net Literal object and pass it to the masterpage so it can process the link in the Head block.
                        string link = "<link rel=\"alternate\" type=\"application/rdf+xml\" href=\"" + uri + "/" + file + ".rdf\" />";
                        Head1.Controls.Add(new LiteralControl(link));
                        litJs.Text += "<script type='text/javascript'>$('#useourdata').css('border-bottom','');</script>";
                    }
                }
            }
            //else
            //  litExportRDF.Visible = false;

            if (sm.Session().UserID > 0)
            {
                if (data.IsGroupAdmin(sm.Session().UserID))
                {
                    litGroups.Text           = "<li><a href='" + Root.Domain + "/groupAdmin/default.aspx'>Manage Groups</a></li>";
                    groupListDivider.Visible = true;
                }
            }

            string loginclass = string.Empty;

            if (sm.Session().UserID == 0)
            {
                if (!Root.AbsolutePath.Contains("login") && System.Configuration.ConfigurationManager.AppSettings["Login.PresentationXML"].ToString() != "NoLoginPresentation")
                {
                    litLogin.Text = "<a href='" + Root.Domain + "/login/default.aspx?method=login&redirectto=" + Root.Domain + Root.AbsolutePath + "'>Login</a> to edit your profile (add a photo, awards, links to other websites, etc.)";
                }
                loginclass = "pub";
            }
            else
            {
                litLogOut.Text = "<li><a href='" + Root.Domain + "/login/default.aspx?method=logout&redirectto=" + Root.Domain + "/search'>Logout</a></li>";
                loginclass     = "user";
            }

            if (sm.Session().UserID > 0)
            {
                // litDashboard.Text = "<a href ='" + ResolveUrl("~/dashboard/default.aspx?subject=" + sm.Session().NodeID.ToString()) + "'>My Dashboard </a>";
            }

            litJs.Text += "<script type='text/javascript'> var NAME = document.getElementById('prns-usrnav'); NAME.className = '" + loginclass + "';";


            if (sm.Session().UserID > 0)
            {
                //Change this to show two drop down items based on the count.
                MyLists.Visible = true;
                if (base.GetModuleParamString("pageType") != null)
                {
                    string pt = base.GetModuleParamString("PageType");
                    if (pt.Equals("Person"))
                    {
                        MyLists.pageType = MyLists.pageTypes.Person;
                    }
                    else if (pt.Equals("SearchResults"))
                    {
                        MyLists.pageType = MyLists.pageTypes.SearchResults;
                    }
                }
            }
            else if (sm.Session().UserID == 0)
            {
                MyLists.Visible = false;
                litJs.Text     += " $('#navMyLists').remove(); $('#ListDivider').remove();";
            }


            litJs.Text += "</script>";

            UserHistory uh = new UserHistory();

            ProfileHistory.RDFData         = base.BaseData;
            ProfileHistory.PresentationXML = base.MasterPage.PresentationXML;
            ProfileHistory.Namespaces      = base.Namespaces;
        }
Ejemplo n.º 33
0
        private void DrawProfilesModule()
        {
            Int64 subject = 0;

            if (Request.QueryString["subject"] != null)
            {
                subject = Convert.ToInt64(Request.QueryString["subject"]);
            }

            Utilities.DataIO data = new Profiles.Framework.Utilities.DataIO();
            menulist.Append("<ul>");

            menulist.Append("<li><a href='" + Root.Domain + "/search'>Find People</a></li>");
            menulist.Append("<li><a href='" + Root.Domain + "/search/all'>Find Everything</a></li>");

            //-50 is the profiles Admin
            if (data.GetSessionSecurityGroup() == -50)
            {
                menulist.Append("<li><a href='" + Root.Domain + "/SPARQL/default.aspx'>SPARQL Query</a></li>");
            }

            menulist.Append("<li><a href='" + Root.Domain + "/about/default.aspx'>About This Site</a></li>");

            if (sm.Session().NodeID > 0)
            {
                menulist.Append("<li><a href='" + sm.Session().PersonURI + "'>View My Profile</a></li>");
            }

            menulist.Append("<li><a href='" + Root.Domain + "/login/default.aspx?method=login&edit=true'>Edit My Profile</a></li>");


            if (base.MasterPage.CanEdit)
            {
                menulist.Append("<li><a href='" + Root.Domain + "/edit/" + subject.ToString() + "'>Edit This Profile</a></li>");
            }

            if (sm.Session().UserID > 0)
            {
                menulist.Append("<li><a href='" + Root.Domain + "/proxy/default.aspx?subject=" + sm.Session().NodeID.ToString() + "'>Manage Proxies</a></li>");
            }

            if (base.BaseData.SelectSingleNode(".").OuterXml != string.Empty && !Root.AbsolutePath.ToLower().Contains("/search"))
            {
                if (base.BaseData.SelectSingleNode("//rdf:RDF/rdf:Description/@rdf:about", base.Namespaces) != null && !Root.AbsolutePath.ToLower().Contains("proxy"))
                {
                    string uri = this.BaseData.SelectSingleNode("//rdf:RDF/rdf:Description/@rdf:about", base.Namespaces).Value;

                    //IF the URI is in our system then we build the link. If not then we do not build the link for the data.
                    if (uri.Contains(Root.Domain))
                    {
                        string   file      = string.Empty;
                        string   spostring = string.Empty;
                        string[] spoarray;

                        spostring = uri.ToLower().Replace(Root.Domain.ToLower() + "/profile/", "");
                        spoarray  = spostring.Split('/');

                        for (int i = 0; i < spoarray.Length; i++)
                        {
                            file = file + spoarray[i] + "_";
                        }

                        file = file.Substring(0, file.Length - 1);

                        menulist.Append("<li><a href=\"" + uri + "/" + file + ".rdf\" target=\"_blank\">" + "Export RDF" + "</a>&nbsp;<a style='border: none;' href='" + Root.Domain + "/about/default.aspx?tab=data'><img style='border-style: none' src='" + Root.Domain + "/Framework/Images/info.png'  border='0' alt='Help with RDF'></a></li>");

                        if (base.MasterPage != null)
                        {
                            System.Web.UI.HtmlControls.HtmlContainerControl Head1;
                            Head1 = (System.Web.UI.HtmlControls.HtmlContainerControl)base.MasterPage.FindControl("Head1");
                            //If a masterpage exists, you need to to create an ASP.Net Literal object and pass it to the masterpage so it can process the link in the Head block.
                            string link = "<link rel=\"alternate\" type=\"application/rdf+xml\" href=\"" + uri + "/" + file + ".rdf\" />";
                            Head1.Controls.Add(new LiteralControl(link));
                        }
                    }
                }
            }


            if (sm.Session().UserID == 0)
            {
                if (!Root.AbsolutePath.Contains("login"))
                {
                    menulist.Append("<li><a href='" + Root.Domain + "/login/default.aspx?pin=send&method=login&redirectto=" + Root.Domain + Root.AbsolutePath + "'>Login to Profiles</a></li>");
                }
            }
            else
            {
                menulist.Append("<li><a href='" + Root.Domain + "/login/default.aspx?method=logout&redirectto=" + Root.Domain + Root.AbsolutePath + "'>Logout</a></li>");
            }

            menulist.Append("</ul>");

            // hide active networks DIV if not logged in
            if (sm.Session().UserID > 0)
            {
                ActiveNetworkRelationshipTypes.Visible = true;
            }
            else
            {
                ActiveNetworkRelationshipTypes.Visible = false;
            }

            UserHistory uh = new UserHistory();

            ProfileHistory.RDFData         = base.BaseData;
            ProfileHistory.PresentationXML = base.MasterPage.PresentationXML;
            ProfileHistory.Namespaces      = base.Namespaces;


            if (uh.GetItems() != null)
            {
                ProfileHistory.Visible = true;
            }
            else
            {
                ProfileHistory.Visible = false;
            }



            panelMenu.InnerHtml = menulist.ToString();
        }
        private void DrawProfilesModule()
        {
            Utilities.DataIO data = new Profiles.Framework.Utilities.DataIO();
            SqlDataReader reader;

            List<NetworkItem> networkitem = new List<NetworkItem>();

            this.RelationshipTypes = new List<RelationshipType>();

            Int64 subject = 0;

            if (HttpContext.Current.Request.QueryString["subject"] != null)
            {
                subject = Convert.ToInt64(HttpContext.Current.Request.QueryString["subject"]);
            }

            if (sm.Session().UserID != 0)
            {
                if (subject != sm.Session().NodeID && subject != 0 && (!Root.AbsolutePath.Contains("/proxy") && !Root.AbsolutePath.Contains("/edit")))
                {
                    reader = data.GetActiveNetwork(subject, true);

                    while (reader.Read())
                    {
                        this.RelationshipTypes.Add(new RelationshipType(reader["RelationshipName"].ToString(), reader["RelationshipType"].ToString(), Convert.ToBoolean(reader["DoesExist"])));

                    }
                    if (RelationshipTypes.Count > 0)
                    {
                        rptRelationshipTypes.DataSource = this.RelationshipTypes;
                        rptRelationshipTypes.DataBind();
                        pnlSetActiveNetworks.Visible = true;
                    }
                    else
                    {
                        pnlSetActiveNetworks.Visible = false;
                    }
                }
                else
                {
                    pnlSetActiveNetworks.Visible = false;
                }
            }

            reader = data.GetActiveNetwork(0, false);

            while (reader.Read())
            {
                networkitem.Add(new NetworkItem(reader[1].ToString(), Convert.ToInt64(reader[2]), reader[3].ToString()));
            }

            if (!reader.IsClosed)
                reader.Close();

            if (networkitem.Count > 0)
            {
                gvActiveNetwork.DataSource = networkitem;
                gvActiveNetwork.DataBind();

                pnlMyNetwork.Visible = true;

                litActiveNetworkDetails.Text = "<a class='activeSectionDetails' href='" + Root.Domain + "/activenetwork/default.aspx'><font style='font-size:10px'>View Details</font></a>";
            }
            else
            {
                pnlMyNetwork.Visible = false;
            }
        }