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); }
private List <GadgetSpec> GetGadgetSpecifications() { DebugLogging.Log("OpenSocialManager GetAllDBGadgets " + !noCache); Dictionary <string, GadgetSpec> allDBGadgets = GetAllDBGadgets(!noCache); List <GadgetSpec> gadgetSpecs = new List <GadgetSpec>(); // if someone used the sandbox to log in, grab those gadgets, and only those gadget. // if a gadget with the same file name is in the DB, merge it in so that we can inherit it's configuruation if (page.Session != null && (string)page.Session[ORNG_GADGETS] != null) { // Add sandbox gadgets if there are any // Note that this block of code only gets executed after someone logs in with GadgetSandbox.aspx! String openSocialGadgetURLS = (string)page.Session[ORNG_GADGETS]; String[] urls = openSocialGadgetURLS.Split(Environment.NewLine.ToCharArray()); for (int i = 0; i < urls.Length; i++) { String openSocialGadgetURL = urls[i]; if (openSocialGadgetURL.Length == 0) { continue; } GadgetSpec sandboxGadget = new GadgetSpec(openSocialGadgetURL); // see if we have a gadget with the same file name in the DB, if so use its configuration if (allDBGadgets.ContainsKey(sandboxGadget.GetFileName())) { GadgetSpec gadget = allDBGadgets[sandboxGadget.GetFileName()]; gadget.MergeWithUnrecognizedGadget(sandboxGadget); gadgetSpecs.Add(gadget); } else { gadgetSpecs.Add(sandboxGadget); } } } else { // the normal use case // just add in the db gadgets gadgetSpecs.AddRange(allDBGadgets.Values); } return(gadgetSpecs); }
internal void MergeWithUnrecognizedGadget(GadgetSpec unrecognizedGadget) { // basically just grab it's URL, but check some things first! if (this.GetFileName() == unrecognizedGadget.GetFileName() && !this.unrecognized && unrecognizedGadget.unrecognized) { this.openSocialGadgetURL = unrecognizedGadget.openSocialGadgetURL; this.enabled = true; } else { throw new Exception("This merge is not allowed!"); } }
internal void MergeWithSandboxGadget(GadgetSpec sandboxGadget) { // basically just grab it's URL, but check some things first! if (this.GetFileName() == sandboxGadget.GetFileName() && !this.fromSandbox && sandboxGadget.fromSandbox) { this.openSocialGadgetURL = sandboxGadget.openSocialGadgetURL; this.enabled = true; } else { throw new Exception("This merge is not allowed!"); } }
private List<GadgetSpec> GetGadgetSpecifications() { DebugLogging.Log("OpenSocialManager GetAllDBGadgets " + !noCache); Dictionary<string, GadgetSpec> allDBGadgets = GetAllDBGadgets(!noCache); List<GadgetSpec> gadgetSpecs = new List<GadgetSpec>(); // if someone used the sandbox to log in, grab those gadgets, and only those gadget. // if a gadget with the same file name is in the DB, merge it in so that we can inherit it's configuruation if (page.Session != null && (string)page.Session[ORNG_GADGETS] != null) { // Add sandbox gadgets if there are any // Note that this block of code only gets executed after someone logs in with GadgetSandbox.aspx! String openSocialGadgetURLS = (string)page.Session[ORNG_GADGETS]; String[] urls = openSocialGadgetURLS.Split(Environment.NewLine.ToCharArray()); for (int i = 0; i < urls.Length; i++) { String openSocialGadgetURL = urls[i]; if (openSocialGadgetURL.Length == 0) continue; GadgetSpec sandboxGadget = new GadgetSpec(openSocialGadgetURL); // see if we have a gadget with the same file name in the DB, if so use its configuration if (allDBGadgets.ContainsKey(sandboxGadget.GetFileName())) { GadgetSpec gadget = allDBGadgets[sandboxGadget.GetFileName()]; gadget.MergeWithUnrecognizedGadget(sandboxGadget); gadgetSpecs.Add(gadget); } else { gadgetSpecs.Add(sandboxGadget); } } } else { // the normal use case // just add in the db gadgets gadgetSpecs.AddRange(allDBGadgets.Values); } return gadgetSpecs; }
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; }