示例#1
0
        public static void install(Connector conn)
        {
            string error = null;
            string basePath = AppDomain.CurrentDomain.BaseDirectory;

            // Install SQL
            Misc.Plugins.executeSQL(basePath + "\\Installer\\Install.sql", conn);

            // Install default templates
            Misc.HtmlTemplates templates = new Misc.HtmlTemplates();
            templates.readDumpToDb(conn, basePath + "\\Installer\\Templates\\default");

            // Start the core of the CMS
            Core.cmsStart();

            // NOTE: Plugins from a zip should NOT be installed from this script because the code required for install would require the web-app to be changed;
            // instead simply unextract the zips to the App_Code\Plugins directory under a folder with the same name as the "directory" tag in the plugins'
            // Config.xml file.
            if (Core.criticalFailureError != null) throw new Exception(Core.criticalFailureError.GetBaseException().StackTrace);
            if (Core.settings == null) throw new Exception("Core settings missing; fatal error.");

            // Install common
            string commonPluginid = null;
            if ((error = Misc.Plugins.install(null, ref commonPluginid, basePath + "\\App_Code\\Plugins\\Common", false, conn)) != null)
                throw new Exception("Failed to install common plugin: " + error);
            if ((error = Misc.Plugins.enable(commonPluginid, conn)) != null)
                throw new Exception("Failed to enable common plugin: " + error);

            // Install admin panel
            string adminPluginid = null;
            if((error = Misc.Plugins.install(null, ref adminPluginid, basePath + "\\App_Code\\Plugins\\Admin Panel", false, conn)) != null)
                throw new Exception("Failed to install admin panel plugin: " + error);
            if((error = Misc.Plugins.enable(adminPluginid, conn)) != null)
                throw new Exception("Failed to enable admin panel plugin: " + error);

            // Install basic site auth
            string bsaPluginid = null;
            if((error = Misc.Plugins.install(null, ref bsaPluginid, basePath + "\\App_Code\\Plugins\\BasicSiteAuth", false, conn)) != null)
                throw new Exception("Failed to install basic site auth plugin: " + error);
            if((error = Misc.Plugins.enable(bsaPluginid, conn)) != null)
                throw new Exception("Failed to enable basic site auth plugin: " + error);
        }
示例#2
0
 public static void cmsStart()
 {
     try
     {
         // Set the base-path and check the CMS has been installed
         basePath = AppDomain.CurrentDomain.BaseDirectory;
         if (basePath.EndsWith("\\")) basePath = basePath.Remove(basePath.Length - 1, 1);
         if (!File.Exists(basePath + "\\CMS.config"))
         {
             state = State.NotInstalled;
             return;
         }
         // Load the connector settings
         XmlDocument doc = new XmlDocument();
         doc.LoadXml(File.ReadAllText(basePath + "\\CMS.config"));
         connHost = doc["settings"]["db"]["host"].InnerText;
         connPort = int.Parse(doc["settings"]["db"]["port"].InnerText);
         connDatabase = doc["settings"]["db"]["database"].InnerText;
         connUsername = doc["settings"]["db"]["username"].InnerText;
         connPassword = doc["settings"]["db"]["password"].InnerText;
         // Set the global connector
         globalConnector = connectorCreate(true);
         // Load and start e-mail queue service
         if (doc["settings"]["mail"]["host"].InnerText.Length == 0 || doc["settings"]["mail"]["port"].InnerText.Length == 0 || doc["settings"]["mail"]["username"].InnerText.Length == 0 || doc["settings"]["mail"]["address"].InnerText.Length == 0)
             // Create disabled e-mail queue
             emailQueue = new Misc.EmailQueue();
         else
             emailQueue = new Misc.EmailQueue(doc["settings"]["mail"]["host"].InnerText, int.Parse(doc["settings"]["mail"]["port"].InnerText), doc["settings"]["mail"]["username"].InnerText, doc["settings"]["mail"]["password"].InnerText, doc["settings"]["mail"]["address"].InnerText);
         emailQueue.start();
         // Wipe the cache folder
         string cachePath = basePath + "\\Cache";
         if (Directory.Exists(cachePath))
         {
             // We don't just delete the directory because something could be in-use..hence we try to delete as much as possible
             try
             {
                 foreach (string file in Directory.GetFiles(cachePath, "*", SearchOption.AllDirectories))
                     File.Delete(file);
                 foreach (string dir in Directory.GetDirectories(cachePath, "*", SearchOption.AllDirectories))
                     Directory.Delete(dir);
             }
             catch
             {
             }
         }
         // Load settings
         settings = new Misc.Settings();
         settings.reload(globalConnector);
         // Load templates
         templates = new Misc.HtmlTemplates(globalConnector);
         // Invoke plugins
         foreach (ResultRow plugin in globalConnector.Query_Read("SELECT pluginid, classpath FROM plugins WHERE state='" + (int)Plugins.Base.State.Enabled + "' ORDER BY invoke_order ASC"))
             try
             {
                 Misc.Plugins.invokeMethod(plugin["classpath"], "cmsStart", new object[]{ plugin["pluginid"], globalConnector});
             }
             catch
             { }
         // Complete
         state = State.Started;
         // Begin cycler
         cyclerStart();
     }
     catch (Exception ex)
     {
         state = State.CriticalFailure;
         criticalFailureError = ex;
     }
 }
示例#3
0
 public static void cmsStop()
 {
     // Stop cycler
     cyclerStop();
     // Stop e-mail queue service
     emailQueue.stop();
     // Set the state
     state = State.Stopped;
     // Inform each plugin
     foreach (ResultRow plugin in globalConnector.Query_Read("SELECT pluginid, classpath FROM plugins WHERE state='" + (int)Plugins.Base.State.Enabled + "' ORDER BY invoke_order ASC"))
         try
         {
             Misc.Plugins.invokeMethod(plugin["classpath"], "cmsStop", new object[] { plugin["pluginid"], globalConnector });
         }
         catch
         { }
     // Dispose the templates
     templates.dispose();
     templates = null;
     // Dispose settings
     settings.dispose();
     settings = null;
     // Dispose the global connector
     try
     {
         globalConnector.Disconnect();
     }
     finally
     {
         globalConnector = null;
     }
 }
示例#4
0
        public static void install(Connector conn)
        {
            string error    = null;
            string basePath = AppDomain.CurrentDomain.BaseDirectory;

            // Install SQL
            Misc.Plugins.executeSQL(basePath + "\\Installer\\Install.sql", conn);

            // Install default templates
            Misc.HtmlTemplates templates = new Misc.HtmlTemplates();
            templates.readDumpToDb(conn, basePath + "\\Installer\\Templates\\default");

            // Start the core of the CMS
            Core.cmsStart();

            // NOTE: Plugins from a zip should NOT be installed from this script because the code required for install would require the web-app to be changed;
            // instead simply unextract the zips to the App_Code\Plugins directory under a folder with the same name as the "directory" tag in the plugins'
            // Config.xml file.
            if (Core.criticalFailureError != null)
            {
                throw new Exception(Core.criticalFailureError.GetBaseException().StackTrace);
            }
            if (Core.settings == null)
            {
                throw new Exception("Core settings missing; fatal error.");
            }

            // Install common
            string commonPluginid = null;

            if ((error = Misc.Plugins.install(null, ref commonPluginid, basePath + "\\App_Code\\Plugins\\Common", false, conn)) != null)
            {
                throw new Exception("Failed to install common plugin: " + error);
            }
            if ((error = Misc.Plugins.enable(commonPluginid, conn)) != null)
            {
                throw new Exception("Failed to enable common plugin: " + error);
            }

            // Install admin panel
            string adminPluginid = null;

            if ((error = Misc.Plugins.install(null, ref adminPluginid, basePath + "\\App_Code\\Plugins\\Admin Panel", false, conn)) != null)
            {
                throw new Exception("Failed to install admin panel plugin: " + error);
            }
            if ((error = Misc.Plugins.enable(adminPluginid, conn)) != null)
            {
                throw new Exception("Failed to enable admin panel plugin: " + error);
            }

            // Install basic site auth
            string bsaPluginid = null;

            if ((error = Misc.Plugins.install(null, ref bsaPluginid, basePath + "\\App_Code\\Plugins\\BasicSiteAuth", false, conn)) != null)
            {
                throw new Exception("Failed to install basic site auth plugin: " + error);
            }
            if ((error = Misc.Plugins.enable(bsaPluginid, conn)) != null)
            {
                throw new Exception("Failed to enable basic site auth plugin: " + error);
            }
        }