예제 #1
0
 //
 //====================================================================================================
 /// <summary>
 /// coreClass constructor for a web request/response environment. coreClass is the primary object internally, created by cp.
 /// </summary>
 public CoreController(CPClass cp, string applicationName, System.Web.HttpContext httpContext)
 {
     try {
         this.cpParent      = cp;
         this.cpParent.core = this;
         _mockNow           = null;
         LogController.log(this, "CoreController constructor-4, enter", BaseClasses.CPLogBaseClass.LogLevel.Trace);
         //
         metaDataDictionary    = new Dictionary <string, Models.Domain.ContentMetadataModel>();
         tableSchemaDictionary = null;
         //
         // -- create default auth objects for non-user methods, or until auth is available
         session = new SessionController(this);
         //
         serverConfig = ServerConfigModel.getObject(this);
         serverConfig.defaultDataSourceType = ServerConfigBaseModel.DataSourceTypeEnum.sqlServer;
         appConfig = AppConfigModel.getObject(this, serverConfig, applicationName);
         if (appConfig != null)
         {
             webServer.initWebContext(httpContext);
             constructorInitialize(true);
         }
         LogController.log(this, "CoreController constructor-4, exit", BaseClasses.CPLogBaseClass.LogLevel.Trace);
     } catch (Exception ex) {
         LogController.logLocalOnly("CoreController constructor-4, exception [" + ex.ToString() + "]", BaseClasses.CPLogBaseClass.LogLevel.Fatal);
         throw;
     }
 }
예제 #2
0
 //
 //====================================================================================================
 /// <summary>
 /// coreClass constructor for cluster use.
 /// </summary>
 /// <param name="cp"></param>
 /// <remarks></remarks>
 public CoreController(CPClass cp)
 {
     cpParent            = cp;
     _mockNow            = null;
     deleteSessionOnExit = true;
     LogController.log(this, "CoreController constructor-0, enter", BaseClasses.CPLogBaseClass.LogLevel.Trace);
     //
     metaDataDictionary    = new Dictionary <string, ContentMetadataModel>();
     tableSchemaDictionary = null;
     //
     // -- create default auth objects for non-user methods, or until auth is available
     session = new SessionController(this);
     //
     serverConfig = ServerConfigModel.getObject(this);
     this.serverConfig.defaultDataSourceType = ServerConfigBaseModel.DataSourceTypeEnum.sqlServer;
     webServer.iisContext = null;
     constructorInitialize(false);
     LogController.log(this, "CoreController constructor-0, exit", BaseClasses.CPLogBaseClass.LogLevel.Trace);
 }
예제 #3
0
 //
 //====================================================================================================
 /// <summary>
 /// create a new app. Must run in in task-service with elevated permissions
 /// </summary>
 /// <param name="cp"></param>
 /// <returns></returns>
 public override object Execute(Contensive.BaseClasses.CPBaseClass cpRootApp)
 {
     try {
         string appName    = cpRootApp.Doc.GetText("appName");
         string domainName = cpRootApp.Doc.GetText("domainName");
         //
         using (CPClass cpServer = new CPClass()) {
             AppConfigModel appConfig = new AppConfigModel {
                 //
                 // -- enable it
                 enabled = true,
                 //
                 // -- private key
                 privateKey = Processor.Controllers.GenericController.getGUIDNaked(),
                 //
                 // -- allow site monitor
                 allowSiteMonitor = false,
                 name             = appName,
                 //
                 // -- admin route
                 adminRoute = "admin"
             };
             //
             // -- domain
             domainName = "www." + appConfig.name + ".com";
             appConfig.domainList.Add(domainName);
             //
             // -- file architectur
             appConfig.localWwwPath     = cpServer.core.serverConfig.localDataDriveLetter + ":\\inetpub\\" + appConfig.name + "\\www\\";
             appConfig.localFilesPath   = cpServer.core.serverConfig.localDataDriveLetter + ":\\inetpub\\" + appConfig.name + "\\files\\";
             appConfig.localPrivatePath = cpServer.core.serverConfig.localDataDriveLetter + ":\\inetpub\\" + appConfig.name + "\\private\\";
             appConfig.localTempPath    = cpServer.core.serverConfig.localDataDriveLetter + ":\\inetpub\\" + appConfig.name + "\\temp\\";
             if (cpServer.core.serverConfig.isLocalFileSystem)
             {
                 //
                 // -- no prompts, local file system
                 appConfig.remoteWwwPath     = "";
                 appConfig.remoteFilePath    = "";
                 appConfig.remotePrivatePath = "";
                 appConfig.cdnFileUrl        = "/" + appConfig.name + "/files/";
             }
             else
             {
                 //
                 // -- no prompts, remote file system
                 appConfig.remoteWwwPath     = "/" + appConfig.name + "/www/";
                 appConfig.remoteFilePath    = "/" + appConfig.name + "/files/";
                 appConfig.remotePrivatePath = "/" + appConfig.name + "/private/";
                 appConfig.cdnFileUrl        = "https://s3.amazonaws.com/" + cpServer.core.serverConfig.awsBucketName + "/" + appConfig.name + "/files/";
             }
             Contensive.Processor.Controllers.LogController.logInfo(cpServer.core, "Create local folders.");
             setupDirectory(appConfig.localWwwPath);
             setupDirectory(appConfig.localFilesPath);
             setupDirectory(appConfig.localPrivatePath);
             setupDirectory(appConfig.localTempPath);
             //
             // -- save the app configuration and reload the server using this app
             Contensive.Processor.Controllers.LogController.logInfo(cpServer.core, "Save app configuration.");
             appConfig.appStatus = AppConfigModel.AppStatusEnum.maintenance;
             cpServer.core.serverConfig.apps.Add(appConfig.name, appConfig);
             cpServer.core.serverConfig.save(cpServer.core);
             cpServer.core.serverConfig = ServerConfigModel.getObject(cpServer.core);
             cpServer.core.appConfig    = AppConfigModel.getObject(cpServer.core, cpServer.core.serverConfig, appConfig.name);
             //
             // update local host file
             //
             try {
                 LogController.logInfo(cpServer.core, "Update host file to add domain [127.0.0.1 " + appConfig.name + "].");
                 File.AppendAllText("c:\\windows\\system32\\drivers\\etc\\hosts", System.Environment.NewLine + "127.0.0.1\t" + appConfig.name);
             } catch (Exception ex) {
                 LogController.logWarn(cpServer.core, "Error attempting to update local host file:" + ex);
                 LogController.logWarn(cpServer.core, "Please manually add the following line to your host file (c:\\windows\\system32\\drivers\\etc\\hosts):" + "127.0.0.1\t" + appConfig.name);
             }
             //
             // create the database on the server
             //
             LogController.logInfo(cpServer.core, "Create database.");
             cpServer.core.dbServer.createCatalog(appConfig.name);
         }
         //
         // initialize the new app, use the save authentication that was used to authorize this object
         //
         using (CPClass cp = new CPClass(appName)) {
             LogController.logInfo(cp.core, "Verify website.");
             //
             const string iisDefaultDoc = "default.aspx";
             cp.core.webServer.verifySite(appName, domainName, cp.core.appConfig.localWwwPath, iisDefaultDoc);
             //
             LogController.logInfo(cp.core, "Run db upgrade.");
             BuildController.upgrade(cp.core, true, true);
             //
             // -- set the application back to normal mode
             cp.core.serverConfig.save(cp.core);
             cp.core.siteProperties.setProperty(Constants.siteproperty_serverPageDefault_name, iisDefaultDoc);
             //
             LogController.logInfo(cp.core, "Upgrade complete.");
             LogController.logInfo(cp.core, "Use IIS Import Application to install either you web application, or the Contensive IISDefault.zip application.");
         }
         //
         return(string.Empty);
     } catch (Exception ex) {
         cpRootApp.Site.ErrorReport(ex);
         return("ERROR, unexpected exception during NewApp");
     }
 }