public static Dictionary <string, GadgetSpec> GetAllDBGadgets(bool useCache)
        {
            // check cache first
            Dictionary <string, GadgetSpec> dbApps = useCache ? (Dictionary <string, GadgetSpec>)Cache.FetchObject(GADGET_SPEC_KEY) : null;

            if (dbApps == null)
            {
                dbApps = new Dictionary <string, GadgetSpec>();
                Profiles.ORNG.Utilities.DataIO data = new Profiles.ORNG.Utilities.DataIO();
                using (SqlDataReader dr = data.GetGadgets())
                {
                    while (dr.Read())
                    {
                        GadgetSpec spec           = new GadgetSpec(Convert.ToInt32(dr[0]), dr[1].ToString(), dr[2].ToString(), Convert.ToBoolean(dr[3]), false);
                        string     gadgetFileName = GetGadgetFileNameFromURL(dr[2].ToString());
                        dbApps.Add(gadgetFileName, spec);
                    }
                }

                // add to cache unless noCache is turned on
                if (useCache)
                {
                    // set it to not timeout
                    Cache.Set(GADGET_SPEC_KEY, dbApps, -1, null);
                }
            }

            return(dbApps);
        }
Beispiel #2
0
        // OK to cache as long as dependency is working!
        public string GetRegistryDefinedVisiblity(string ownerUri)
        {
            if (ownerUri == null || ownerUri.Trim().Length == 0)
            {
                return(null);
            }

            Dictionary <int, string> registeredApps = (Dictionary <int, string>)Framework.Utilities.Cache.FetchObject(REGISTERED_APPS_CACHE_PREFIX + ownerUri);

            if (registeredApps == null)
            {
                registeredApps = new Dictionary <int, string>();
                Profiles.ORNG.Utilities.DataIO data = new Profiles.ORNG.Utilities.DataIO();

                using (SqlDataReader dr = data.GetRegisteredApps(ownerUri))
                {
                    while (dr.Read())
                    {
                        registeredApps[dr.GetInt32(0)] = dr.GetString(1);
                    }
                }

                Framework.Utilities.Cache.Set(REGISTERED_APPS_CACHE_PREFIX + ownerUri, registeredApps, OpenSocialManager.GetNodeID(ownerUri), null);
            }

            return(registeredApps.ContainsKey(GetAppId()) ? registeredApps[GetAppId()] : null);
        }
Beispiel #3
0
        // OK to cache as long as dependency is working!
        // think about this, as this is now only set manually via DB
        public bool IsRegistered(string ownerUri)
        {
            if (ownerUri == null || ownerUri.Trim().Length == 0)
            {
                return(false);
            }

            HashSet <int> registeredApps = (HashSet <int>)Framework.Utilities.Cache.FetchObject(REGISTERED_APPS_CACHE_PREFIX + ownerUri);

            if (registeredApps == null)
            {
                registeredApps = new HashSet <int>();
                Profiles.ORNG.Utilities.DataIO data = new Profiles.ORNG.Utilities.DataIO();

                using (SqlDataReader dr = data.GetRegisteredApps(ownerUri))
                {
                    while (dr.Read())
                    {
                        registeredApps.Add(dr.GetInt32(0));
                    }
                }

                Framework.Utilities.Cache.Set(REGISTERED_APPS_CACHE_PREFIX + ownerUri, registeredApps, OpenSocialManager.GetNodeID(ownerUri), null);
            }

            return(registeredApps.Contains(GetAppId()));
        }
        public static void PostActivity(int userId, string title, string body, string xtraId1Type, string xtraId1Value)
        {
            Profiles.ORNG.Utilities.DataIO data = new Profiles.ORNG.Utilities.DataIO();

            string sql = "INSERT INTO shindig_activity (userId, activity, xtraId1Type, xtraId1Value) VALUES (" + userId +
                         ",'<activity xmlns=\"http://ns.opensocial.org/2008/opensocial\"><postedTime>" +
                         Convert.ToInt64((DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalMilliseconds) + "</postedTime><title>" + title + "</title>"
                         + (body != null ? "<body>" + body + "</body>" : "") + "</activity>','" + xtraId1Type + "','" + xtraId1Value + "');";

            data.ExecuteSQLDataCommand(sql);
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request.QueryString["person"] != null)
     {
         // need to convert personid to nodeid!!!.  Doesn't really make sense to use an ORNG DataIO to do this, but since we don't have one in Framework that is what we do
         Int64 nodeId = new Profiles.ORNG.Utilities.DataIO().GetNodeId(Convert.ToInt32(Request.QueryString["person"].ToString()));
         // send them to the new location wiht a 301, this is better for SEO than a standard Response.SendRedirect call
         Response.Status = "301 Moved Permanently";
         Response.AddHeader("Location", Root.Domain + "/display/" + nodeId);
         Response.End();
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request.QueryString["person"] != null)
     {
         // need to convert personid to nodeid!!!.  Doesn't really make sense to use an ORNG DataIO to do this, but since we don't have one in Framework that is what we do
         Int64 nodeId = new Profiles.ORNG.Utilities.DataIO().GetNodeId(Convert.ToInt32(Request.QueryString["person"].ToString()));
         // send them to the new location wiht a 301, this is better for SEO than a standard Response.SendRedirect call
         Response.Status = "301 Moved Permanently";
         Response.AddHeader("Location", Root.Domain + "/display/" + nodeId);
         Response.End();
     }
 }
Beispiel #7
0
        // these are loaded from the DB
        public GadgetSpec(int appId, string label, string openSocialGadgetURL, bool enabled)
        {
            this.openSocialGadgetURL = openSocialGadgetURL;
            this.label        = label;
            this.appId        = appId;
            this.enabled      = enabled;
            this.unrecognized = false;

            // load view requirements
            Profiles.ORNG.Utilities.DataIO data = new Profiles.ORNG.Utilities.DataIO();
            using (SqlDataReader dr = data.GetGadgetViewRequirements(appId))
            {
                while (dr.Read())
                {
                    viewRequirements.Add(dr[0].ToString().ToLower(), new GadgetViewRequirements(dr[0].ToString().ToLower(),
                                                                                                dr[1].ToString(), dr[2].ToString(), dr[3].ToString(),
                                                                                                dr.IsDBNull(4) ? Int32.MaxValue : dr.GetInt32(4), dr[5].ToString()));
                }
            }
        }
Beispiel #8
0
        // these are loaded from the DB
        public GadgetSpec(int appId, string label, string openSocialGadgetURL, bool enabled)
        {
            this.openSocialGadgetURL = openSocialGadgetURL;
            this.label = label;
            this.appId = appId;
            this.enabled = enabled;
            this.unrecognized = false;

            // load view requirements
            Profiles.ORNG.Utilities.DataIO data = new Profiles.ORNG.Utilities.DataIO();
            using (SqlDataReader dr = data.GetGadgetViewRequirements(appId))
            {
                while (dr.Read())
                {
                    viewRequirements.Add(dr[0].ToString().ToLower(), new GadgetViewRequirements(dr[0].ToString().ToLower(),
                            dr[1].ToString(), dr[2].ToString(), dr[3].ToString(),
                            dr.IsDBNull(4) ? Int32.MaxValue : dr.GetInt32(4), dr[5].ToString()));
                }
            }
        }
 private void UpdateSecuritySetting(string securitygroup)
 {
     // maybe be able to make this more general purpose
     if (this.PredicateURI.StartsWith(Profiles.ORNG.Utilities.OpenSocialManager.ORNG_ONTOLOGY_PREFIX))
     {
         Profiles.ORNG.Utilities.DataIO data = new Profiles.ORNG.Utilities.DataIO();
         if ("0".Equals(securitygroup))
         {
             data.RemovePersonalGadget(this.Subject, this.PredicateURI);
         }
         else
         {
             data.AddPersonalGadget(this.Subject, this.PredicateURI);
         }
     }
     else if (!"0".Equals(securitygroup))
     {
         Edit.Utilities.DataIO data = new Profiles.Edit.Utilities.DataIO();
         data.UpdateSecuritySetting(this.Subject, data.GetStoreNode(this.PredicateURI), Convert.ToInt32(securitygroup));
     }
     //Framework.Utilities.Cache.AlterDependency(this.Subject.ToString());
 }
Beispiel #10
0
        public GadgetSpec(int appId, string name, string openSocialGadgetURL, bool enabled, bool sandboxOnly)
        {
            this.appId = appId;
            this.name = name;
            this.openSocialGadgetURL = openSocialGadgetURL;
            this.enabled = enabled;
            this.sandboxOnly = sandboxOnly;

            // if it's sandboxOnly, you will not find view requirements in the DB
            if (!sandboxOnly)
            {
                Profiles.ORNG.Utilities.DataIO data = new Profiles.ORNG.Utilities.DataIO();
                using (SqlDataReader dr = data.GetGadgetViewRequirements(appId))
                {
                    while (dr.Read())
                    {
                        viewRequirements.Add(dr[0].ToString().ToLower(), new GadgetViewRequirements(dr[0].ToString().ToLower(),
                                dr[1].ToString(), dr[2].ToString(), dr[3].ToString(),
                                dr.IsDBNull(4) ? Int32.MaxValue : dr.GetInt32(4), dr[5].ToString()));
                    }
                }
            }
        }
Beispiel #11
0
        public GadgetSpec(int appId, string name, string openSocialGadgetURL, bool enabled, bool sandboxOnly)
        {
            this.appId = appId;
            this.name  = name;
            this.openSocialGadgetURL = openSocialGadgetURL;
            this.enabled             = enabled;
            this.sandboxOnly         = sandboxOnly;

            // if it's sandboxOnly, you will not find view requirements in the DB
            if (!sandboxOnly)
            {
                Profiles.ORNG.Utilities.DataIO data = new Profiles.ORNG.Utilities.DataIO();
                using (SqlDataReader dr = data.GetGadgetViewRequirements(appId))
                {
                    while (dr.Read())
                    {
                        viewRequirements.Add(dr[0].ToString().ToLower(), new GadgetViewRequirements(dr[0].ToString().ToLower(),
                                                                                                    dr[1].ToString(), dr[2].ToString(), dr[3].ToString(),
                                                                                                    dr.IsDBNull(4) ? Int32.MaxValue : dr.GetInt32(4), dr[5].ToString()));
                    }
                }
            }
        }
 private void UpdateSecuritySetting(string securitygroup)
 {
     // maybe be able to make this more general purpose
     if (this.PredicateURI.StartsWith(Profiles.ORNG.Utilities.OpenSocialManager.ORNG_ONTOLOGY_PREFIX))
     {
         Profiles.ORNG.Utilities.DataIO dataORNG = new Profiles.ORNG.Utilities.DataIO();
         if ("0".Equals(securitygroup))
         {
             dataORNG.RemovePersonalGadget(this.Subject, this.PredicateURI);
         }
         else
         {
             dataORNG.AddPersonalGadget(this.Subject, this.PredicateURI);
         }
     }
     //            else if (!"0".Equals(securitygroup))
     //            {
         Edit.Utilities.DataIO data = new Profiles.Edit.Utilities.DataIO();
         data.UpdateSecuritySetting(this.Subject, data.GetStoreNode(this.PredicateURI), Convert.ToInt32(securitygroup));
     //            }
     Framework.Utilities.Cache.AlterDependency(this.Subject.ToString());
 }
        public static Dictionary<string, GadgetSpec> GetAllDBGadgets(bool useCache)
        {
            // check cache first
            Dictionary<string, GadgetSpec> dbApps = useCache ? (Dictionary<string, GadgetSpec>)Cache.FetchObject(GADGET_SPEC_KEY) : null;
            if (dbApps == null)
            {
                dbApps = new Dictionary<string, GadgetSpec>();
                Profiles.ORNG.Utilities.DataIO data = new Profiles.ORNG.Utilities.DataIO();
                using (SqlDataReader dr = data.GetGadgets())
                {
                    while (dr.Read())
                    {
                        String channelsStr = dr[3].ToString();
                        String[] channels = channelsStr != null && channelsStr.Length > 0 ? channelsStr.Split(' ') : new string[0];
                        GadgetSpec spec = new GadgetSpec(Convert.ToInt32(dr[0]), dr[1].ToString(), dr[2].ToString(), channels, Convert.ToBoolean(dr[4]), false);
                        string gadgetFileName = GetGadgetFileNameFromURL(dr[2].ToString());
                        dbApps.Add(gadgetFileName, spec);
                    }
                }

                // add to cache unless noCache is turned on
                if (useCache)
                {
                    // set it to not timeout
                    Cache.Set(GADGET_SPEC_KEY, dbApps, -1);
                }
            }

            return dbApps;
        }
        // Bad idea to cache this
        // -1 means anyone can see it
        // -20 means that only logged in viewers can see it
        // -50 means that only admins, proxys and the profile owner can see it
        // -60 means that no one sees it
        // 0 means that it NEVER shows up for this person, even on their edit page.
        public int GetSecurityGroup(string personId)
        {
            if (personId == null || personId.Trim().Length == 0)
            {
                return 0;
            }

            Dictionary<int, int> registeredApps = null;//(Dictionary<int, Boolean>)Framework.Utilities.Cache.FetchObject(OpenSocialManager.GADGET_SPEC_KEY + "_registeredApps_" + personId);
            if (registeredApps == null)
            {
                registeredApps = new Dictionary<int, int>();
                Profiles.ORNG.Utilities.DataIO data = new Profiles.ORNG.Utilities.DataIO();

                using (SqlDataReader dr = data.GetRegisteredApps(personId))
                {
                    while (dr.Read())
                    {
                        registeredApps[dr.GetInt32(0)] = dr.GetInt32(1);
                    }
                }

                //Framework.Utilities.Cache.Set(OpenSocialManager.GADGET_SPEC_KEY + "_registeredApps_" + personId, registeredApps);
            }

            return registeredApps.ContainsKey(GetAppId()) ? registeredApps[GetAppId()] : 0;
        }
Beispiel #15
0
        // OK to cache as long as dependency is working!
        public string GetRegistryDefinedVisiblity(string ownerUri)
        {
            if (ownerUri == null || ownerUri.Trim().Length == 0)
            {
                return null;
            }

            Dictionary<int, string> registeredApps = (Dictionary<int, string>)Framework.Utilities.Cache.FetchObject(REGISTERED_APPS_CACHE_PREFIX + ownerUri);
            if (registeredApps == null)
            {
                registeredApps = new Dictionary<int, string>();
                Profiles.ORNG.Utilities.DataIO data = new Profiles.ORNG.Utilities.DataIO();

                using (SqlDataReader dr = data.GetRegisteredApps(ownerUri))
                {
                    while (dr.Read())
                    {
                        registeredApps[dr.GetInt32(0)] = dr.GetString(1);
                    }
                }

                Framework.Utilities.Cache.Set(REGISTERED_APPS_CACHE_PREFIX + ownerUri, registeredApps, OpenSocialManager.GetNodeID(ownerUri), null);
            }

            return registeredApps.ContainsKey(GetAppId()) ? registeredApps[GetAppId()] : null;
        }
        public static Dictionary<string, GadgetSpec> GetAllDBGadgets(bool useCache)
        {
            // check cache first
            Dictionary<string, GadgetSpec> dbApps = useCache ? (Dictionary<string, GadgetSpec>)Cache.FetchObject(ORNG_GADGET_SPEC_KEY) : null;
            if (dbApps == null)
            {
                dbApps = new Dictionary<string, GadgetSpec>();
                Profiles.ORNG.Utilities.DataIO data = new Profiles.ORNG.Utilities.DataIO();
                using (SqlDataReader dr = data.GetGadgets())
                {
                    while (dr.Read())
                    {
                        GadgetSpec spec = new GadgetSpec(Convert.ToInt32(dr[0]), dr[1].ToString(), dr[2].ToString(), Convert.ToBoolean(dr[3]));
                        dbApps.Add(spec.GetFileName(), spec);
                    }
                }

                // add to cache unless noCache is turned on
                if (useCache)
                {
                    // set it to not timeout
                    Cache.Set(ORNG_GADGET_SPEC_KEY, dbApps, -1, null);
                }
            }

            return dbApps;
        }
        // OK to cache as long as dependency is working!
        // think about this, as this is now only set manually via DB
        public bool IsRegistered(string ownerUri)
        {
            if (ownerUri == null || ownerUri.Trim().Length == 0)
            {
                return false;
            }

            HashSet<int> registeredApps = (HashSet<int>)Framework.Utilities.Cache.FetchObject(REGISTERED_APPS_CACHE_PREFIX + ownerUri);
            if (registeredApps == null)
            {
                registeredApps = new HashSet<int>();
                Profiles.ORNG.Utilities.DataIO data = new Profiles.ORNG.Utilities.DataIO();

                using (SqlDataReader dr = data.GetRegisteredApps(ownerUri))
                {
                    while (dr.Read())
                    {
                        registeredApps.Add(dr.GetInt32(0));
                    }
                }

                Framework.Utilities.Cache.Set(REGISTERED_APPS_CACHE_PREFIX + ownerUri, registeredApps, OpenSocialManager.GetNodeID(ownerUri), null);
            }

            return registeredApps.Contains(GetAppId());
        }
        public static void PostActivity(int userId, string title, string body, string xtraId1Type, string xtraId1Value)
        {
            Profiles.ORNG.Utilities.DataIO data = new Profiles.ORNG.Utilities.DataIO();

            string sql = "INSERT INTO shindig_activity (userId, activity, xtraId1Type, xtraId1Value) VALUES (" + userId +
                ",'<activity xmlns=\"http://ns.opensocial.org/2008/opensocial\"><postedTime>" +
                Convert.ToInt64((DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalMilliseconds) + "</postedTime><title>" + title + "</title>"
                + (body != null ? "<body>" + body + "</body>" : "") + "</activity>','" + xtraId1Type + "','" + xtraId1Value + "');";

            data.ExecuteSQLDataCommand(sql);
        }