public ServiceResult ImportWebConfigToDatabase(User user, string encryptionKey, bool overwrite, bool appInstalling = false) { if (user == null) { return(ServiceResponse.Error("Inavlid use passed in ImportWebConfigToDatabase.")); } ServiceResult res = ServiceResponse.OK(); NameValueCollection settings = ConfigurationManager.AppSettings; AppManager appManager = new AppManager(Globals.DBConnectionKey, "web", ""); appManager.Installing = appInstalling; foreach (string key in settings.Keys) { Setting setting = appManager.GetSetting(key); bool settingExists = false; if (setting != null) { settingExists = true; if (overwrite == false) { continue; //if exists and no overwrite continue. } } string type = StringEx.GetValueType(settings[key].ToString()); Setting s = new Setting() { UUID = settingExists ? setting.UUID : Guid.NewGuid().ToString("N"), CreatedBy = user.UUID, Type = type, Name = key, Value = settings[key].ToString(), AccountUUID = user.AccountUUID, Active = true, AppType = "web", DateCreated = DateTime.UtcNow, Deleted = false, Private = true, RoleOperation = ">=", RoleWeight = 4, UUIDType = "Setting" }; ServiceResult r = null; if (settingExists) { r = appManager.Update(s, encryptionKey); } else { r = appManager.Insert(s, encryptionKey); } if (r.Code != 200) { res.Message += r.Message; res.Code = r.Code; res.Status = r.Status; } } int connectionCount = ConfigurationManager.ConnectionStrings.Count; for (int i = 0; i < connectionCount; i++) { Setting setting = appManager.GetSetting(ConfigurationManager.ConnectionStrings[i].Name); if (setting != null && overwrite == false) { continue; //if exists and no overwrite continue. } Setting s = new Setting() { CreatedBy = user.UUID, Type = SettingFlags.Types.EncryptedString, Name = ConfigurationManager.ConnectionStrings[i].Name, Value = ConfigurationManager.ConnectionStrings[i].ConnectionString, AccountUUID = user.AccountUUID, Active = true, AppType = "web", DateCreated = DateTime.UtcNow, Deleted = false, Private = true, RoleOperation = ">=", RoleWeight = 4, UUIDType = "Setting" }; ServiceResult r = null; if (setting != null) { r = appManager.Update(s, encryptionKey); } else { r = appManager.Insert(s, encryptionKey); } if (r.Code != 200) { res.Message += r.Message; res.Code = r.Code; res.Status = r.Status; } } return(res); }