/// <summary> Populates the collection of possible portals from the database </summary> /// <param name="Portals"> List of possible URL portals into this library/cms </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param> /// <returns> TRUE if successul, otherwise FALSE </returns> /// <remarks> This calls the 'SobekCM_Get_All_Portals' stored procedure </remarks> public static bool Populate_URL_Portals(Portal_List Portals, Custom_Tracer Tracer) { if (Tracer != null) { Tracer.Add_Trace("SobekCM_Database.Populate_URL_Portals", "Pull URL portal information from the database"); } try { // Build the parameter list SqlParameter[] paramList = new SqlParameter[1]; paramList[0] = new SqlParameter("@activeonly", true); // Define a temporary dataset DataSet tempSet = SqlHelper.ExecuteDataset(connectionString, CommandType.StoredProcedure, "SobekCM_Get_All_Portals", paramList); lock (Portals) { // Clear the current list Portals.Clear(); // If there was no data for this collection and entry point, return null (an ERROR occurred) if (tempSet.Tables.Count > 0) { // Add each provided portal foreach (DataRow thisRow in tempSet.Tables[0].Rows) { // Pull the basic data for this portal int portalId = Convert.ToInt16(thisRow[0]); string baseUrl = thisRow[1].ToString().Trim(); bool isDefault = Convert.ToBoolean(thisRow[3]); string abbreviation = thisRow[4].ToString().Trim(); string name = thisRow[5].ToString().Trim(); string basePurl = thisRow[6].ToString().Trim(); if (isDefault) { if ((baseUrl == "*") || (baseUrl == "default")) baseUrl = String.Empty; } // Get matching skins and aggregations DataRow[] aggrs = tempSet.Tables[1].Select("PortalID=" + portalId); DataRow[] skins = tempSet.Tables[2].Select("PortalID=" + portalId); // Find the default aggregation string defaultAggr = String.Empty; if (aggrs.Length > 0) defaultAggr = aggrs[0][1].ToString().ToLower(); // Find the default skin string defaultSkin = String.Empty; if (skins.Length > 0) defaultSkin = skins[0][1].ToString().ToLower(); // Add this portal Portal newPortal = Portals.Add_Portal(portalId, name, abbreviation, defaultAggr, defaultSkin, baseUrl, basePurl); // If this is default, set it if (isDefault) Portals.Default_Portal = newPortal; } } } if (Portals.Count == 0) { // Add the default url portal then Portals.Default_Portal = Portals.Add_Portal(-1, "Default SobekCM Library", "Sobek", "all", "sobek", "", ""); } // Return the built collection as readonly return true; } catch (Exception ee) { // Add the default url portal then Portals.Default_Portal = Portals.Add_Portal(-1, "Default SobekCM Library", "Sobek", "all", "sobek", "", ""); if (Tracer != null) { Tracer.Add_Trace("SobekCM_Database.Populate_URL_Portals", "Exception caught during database work", Custom_Trace_Type_Enum.Error); Tracer.Add_Trace("SobekCM_Database.Populate_URL_Portals", ee.Message, Custom_Trace_Type_Enum.Error); Tracer.Add_Trace("SobekCM_Database.Populate_URL_Portals", ee.StackTrace, Custom_Trace_Type_Enum.Error); } return false; } }