Exemple #1
0
        private DatabaseConfigInfo GetDatabasConfigInfo()
        {
            DatabaseConfigInfo databaseConfigInfo = new DatabaseConfigInfo();

            var databaseType = ((IDictionary <string, object>)_context.DynamicContext).ContainsKey("DatabaseType") ? _context.DynamicContext.DatabaseType as List <Answer> : new List <Answer>();

            databaseConfigInfo.Type = (databaseType != null && databaseType.Count > 0) ? databaseType.FirstOrDefault().Value : "mysql";

            var databaseName = ((IDictionary <string, object>)_context.DynamicContext).ContainsKey("DatabaseName") ? _context.DynamicContext.DatabaseName as List <Answer> : new List <Answer>();

            databaseConfigInfo.Name = (databaseName != null && databaseName.Count > 0) ? databaseName.FirstOrDefault().Value : "phpDatabase";

            var databaseHost = ((IDictionary <string, object>)_context.DynamicContext).ContainsKey("DatabaseHost") ? _context.DynamicContext.DatabaseHost as List <Answer> : new List <Answer>();

            databaseConfigInfo.Host = (databaseHost != null && databaseHost.Count > 0) ? databaseHost.FirstOrDefault().Value : "127.0.0.1";

            var databasePort = ((IDictionary <string, object>)_context.DynamicContext).ContainsKey("DatabasePort") ? _context.DynamicContext.DatabasePort as List <Answer> : new List <Answer>();

            databaseConfigInfo.Port = (databasePort != null && databasePort.Count > 0) ? databasePort.FirstOrDefault().Value : "3306";

            var databaseUsername = ((IDictionary <string, object>)_context.DynamicContext).ContainsKey("DatabaseUsername") ? _context.DynamicContext.DatabaseUsername as List <Answer> : new List <Answer>();

            databaseConfigInfo.Username = (databaseUsername != null && databaseUsername.Count > 0) ? databaseUsername.FirstOrDefault().Value : "root";

            var databasePassword = ((IDictionary <string, object>)_context.DynamicContext).ContainsKey("DatabasePassword") ? _context.DynamicContext.DatabasePassword as List <Answer> : new List <Answer>();

            databaseConfigInfo.Password = (databasePassword != null && databasePassword.Count > 0) ? databasePassword.FirstOrDefault().Value : "password";

            return(databaseConfigInfo);
        }
Exemple #2
0
        public EnvTemplate(string applicationId, DatabaseConfigInfo databaseConfigInfo,
                           RedisConfigInfo redisConfigInfo, MailConfigInfo mailConfigInfo,
                           SessionConfigInfo sessionConfigInfo, CockieConfigInfo cockieConfigInfo,
                           MemCachedConfigInfo memCachedConfigInfo) : base(null, applicationId)
        {
            _databaseConfigInfo  = databaseConfigInfo;
            _redisConfigInfo     = redisConfigInfo;
            _mailConfigInfo      = mailConfigInfo;
            _sessionConfigInfo   = sessionConfigInfo;
            _cockieConfigInfo    = cockieConfigInfo;
            _memCachedConfigInfo = memCachedConfigInfo;

            _appKey = System.Guid.NewGuid().ToString("N");
        }
Exemple #3
0
        private void TransformEnvTemplate(SmartAppInfo smartApp)
        {
            if (smartApp != null)
            {
                DatabaseConfigInfo  databaseConfigInfo  = GetDatabasConfigInfo();
                RedisConfigInfo     redisConfigInfo     = GetRedisConfigInfo();
                MailConfigInfo      mailConfigInfo      = GetMailConfigInfo();
                SessionConfigInfo   sessionConfigInfo   = GetSessionConfigInfo();
                CockieConfigInfo    cockieConfigInfo    = GetCockieConfigInfo();
                MemCachedConfigInfo memCachedConfigInfo = GetMemCachedConfigInfo();

                EnvTemplate envTemplate = new EnvTemplate(smartApp.Id, databaseConfigInfo, redisConfigInfo, mailConfigInfo, sessionConfigInfo, cockieConfigInfo, memCachedConfigInfo);

                _writingService.WriteFile(Path.Combine(_context.BasePath, envTemplate.OutputPath), envTemplate.TransformText());
            }
        }