0
我想保存在Kentico設置和我得到這個錯誤:與代號「XX」的設置鍵已經存在
The settings key with code name 'AvalaraOrderStatus' already exists.
我已經創建的設置,我已保存的值給它。代碼在Kentico 8中運行良好,但我被要求沒有SiteInfiIdentifer。
這裏是我創建進行設置代碼:
//if the setting does not exist, then create it
if (SettingsKeyInfoProvider.GetSettingsKeyInfo(siteName + ".AvalaraOrderStatus", siteID) == null)
{
// Create and set up new SettingsKey
SettingsKeyInfo si = new SettingsKeyInfo();
si.KeyName = "AvalaraOrderStatus";
si.KeyDisplayName = "Avalara Order Status";
si.KeyDescription = "Avalara order status for this site";
si.KeyType = "string";
si.KeyValue = string.Empty;
si.KeyCategoryID = category.CategoryID;
SettingsKeyInfoProvider.SetSettingsKeyInfo(si);
}
的代碼拋出的最後一行的錯誤。這裏是我的代碼:
int currentSiteID = CMS.SiteProvider.SiteContext.CurrentSiteID;
SiteInfoIdentifier siteId = new SiteInfoIdentifier(currentSiteID);
//update settings in system
SettingsKeyInfoProvider.SetValue(siteName + ".AvalaraOrderStatus", siteId, orderStatus.Trim());