예제 #1
0
        //
        //====================================================================================================
        /// <summary>
        /// get configuration and assign an application
        /// </summary>
        /// <param name="cp"></param>
        /// <param name="recordId"></param>
        public static AppConfigModel getObject(CoreController core, ServerConfigModel serverConfig, string appName)
        {
            AppConfigModel returnModel = null;

            try {
                if (!string.IsNullOrEmpty(appName))
                {
                    if (!serverConfig.apps.ContainsKey(appName.ToLowerInvariant()))
                    {
                        //
                        // -- application not configured
                        returnModel = null;
                        throw new GenericException("application [" + appName + "] was not found in this server group.");
                    }
                    else
                    {
                        //
                        // -- return config object from serverConfig
                        returnModel = (AppConfigModel)serverConfig.apps[appName.ToLowerInvariant()];
                    }
                }
            } catch (Exception ex) {
                LogController.logFatal(core, ex, "exception in serverConfigModel.getObject");
                throw;
            }
            return(returnModel);
        }
예제 #2
0
        //
        //====================================================================================================
        /// <summary>
        /// get ServerConfig, returning only the server data section without specific serverConfig.app
        /// </summary>
        /// <param name="cp"></param>
        /// <param name="recordId"></param>
        public static ServerConfigModel getObject(CoreController core)
        {
            ServerConfigModel returnModel = null;

            try {
                //
                // ----- read/create serverConfig
                string JSONTemp = core.programDataFiles.readFileText("config.json");
                if (string.IsNullOrEmpty(JSONTemp))
                {
                    //
                    // for now it fails, maybe later let it autobuild a local cluster
                    //
                    returnModel = new ServerConfigModel();
                    core.programDataFiles.saveFile("config.json", SerializeObject(returnModel));
                }
                else
                {
                    returnModel = DeserializeObject <ServerConfigModel>(JSONTemp);
                }
            } catch (Exception ex) {
                LogController.logError(core, ex, "exception in serverConfigModel.getObject");
            }
            return(returnModel);
        }