private void UpdateStringResources(string locale) { var displayOutOfStockOnProduct = StringResourceManager.GetStringResource(AppLogic.StoreID(), locale, "OutofStock.DisplayOutOfStockOnProductPage"); if (displayOutOfStockOnProduct != null) { displayOutOfStockOnProduct.Update("OutofStock.DisplayOutOfStockOnProductPage", locale, txtProductOutOfStockMessage.Text); } var displayOutOfStockOnEntity = StringResourceManager.GetStringResource(AppLogic.StoreID(), locale, "OutofStock.DisplayOutOfStockOnEntityPage"); if (displayOutOfStockOnEntity != null) { displayOutOfStockOnEntity.Update("OutofStock.DisplayOutOfStockOnEntityPage", locale, txtEntityOutOfStockMessage.Text); } var displayInStockOnProduct = StringResourceManager.GetStringResource(AppLogic.StoreID(), locale, "OutofStock.DisplayInStockOnProductPage"); if (displayInStockOnProduct != null) { displayInStockOnProduct.Update("OutofStock.DisplayInStockOnProductPage", locale, txtProductInStockMessage.Text); } var displayInStockOnEntity = StringResourceManager.GetStringResource(AppLogic.StoreID(), locale, "OutofStock.DisplayInStockOnEntityPage"); if (displayInStockOnEntity != null) { displayInStockOnEntity.Update("OutofStock.DisplayInStockOnEntityPage", locale, txtEntityInStockMessage.Text); } }
protected void btnSubmit_Click(object sender, EventArgs e) { resetError("", false); StringBuilder sql = new StringBuilder(); if (ValidInput()) { string name = txtName.Text.Trim(); string value = txtDescription.Text.Trim(); string locale = ddLocale.SelectedValue; if (locale.Equals(string.Empty)) { locale = Localization.GetDefaultLocale(); } var storeId = Stores[0].StoreID; if (Stores.Count > 1) { storeId = cboStoreAddString.SelectedValue.ToNativeInt(); } AspDotNetStorefrontCore.StringResource sr = StringResourceManager.GetStringResource(storeId, name, locale); //Must fully qualify this for VB if (sr == null) { var stringResources = StringResourceManager.GetStringResources(storeId); string err = stringResources.Add(storeId, name, locale, value); if (err == string.Empty) { resetError("String Resource added.", false); ShowAddPanel(false); } else { resetError("String Resource was not added. The following error occured: " + err, true); ShowAddPanel(true); } } else { resetError("String Resource already exists.", true); ShowAddPanel(true); } } else { resetError("Please input all required fields.", true); } }
private void UpdateStringResource(string name, string value, string locale, int storeId) { var stringResource = StringResourceManager.GetStringResource(storeId, locale, name); if (stringResource == null) { StringResource.Create(storeId, name, locale, value.Trim()); // Reload string resources from DB. Necessary after creating a new string resource. StringResourceManager.LoadAllStrings(false); } else { stringResource.Update(storeId, name, locale, value.Trim()); } }
protected void gMain_RowUpdating(object sender, GridViewUpdateEventArgs e) { GridViewRow row = gMain.Rows[e.RowIndex]; if (row != null) { string iden = row.Cells[2].Text.ToString(); // the StringResourceId column TextBox txtName = (TextBox)row.FindControl("txtName"); TextBox txtValue = (TextBox)row.FindControl("txtValue"); DropDownList ddLocale = (DropDownList)row.FindControl("ddLocale"); StringBuilder sql = new StringBuilder(2500); int stringResourceId = iden.ToNativeInt(); string name = txtName.Text; string selectedLocale = ddLocale.SelectedValue; string value = txtValue.Text; int prevStoreId = row.FindControl <HiddenField>("hdfPrevStoreId").Value.ToNativeInt(); var defaultStore = Stores.FirstOrDefault(store => store.IsDefault); int storeId = 1; // default if (Stores.Count > 1) { var cboEditStores = row.FindControl <DropDownList>("cboEditStores"); if (cboEditStores.SelectedIndex == 0) // All means also the default store { storeId = defaultStore.StoreID; } else { storeId = cboEditStores.SelectedValue.ToNativeInt(); } } else { storeId = row.FindControl <Label>("lblStoreId").Text.ToNativeInt(); } var owningStore = Stores.FirstOrDefault(store => store.StoreID == storeId); // check if the user specified a different storeid if (storeId != prevStoreId) { // check if we have a previous string resource with that storeid+name+locale var prevStringResource = StringResourceManager.GetStringResource(prevStoreId, selectedLocale, name); var newStoreString = StringResourceManager.GetStringResource(storeId, selectedLocale, name); // check if we have a duplicate on the destination store if (newStoreString != null) { // just update that one instead newStoreString.Update(name, selectedLocale, value); string updateNotice = string.Format("Item [{0}] updated for store: {1} ({2})", name, owningStore.Name, owningStore.StoreID); resetError(updateNotice, false); gMain.EditIndex = -1; // nuke the other store string if (prevStringResource != null) { // nuke the previous one prevStringResource.Owner.Remove(prevStringResource); } } else { // create a copy of that string resource for this store newStoreString = StringResource.Create(storeId, name, selectedLocale, value); var storeStrings = StringResourceManager.GetStringResources(storeId); storeStrings.Add(newStoreString); DuplicatedStringResource = newStoreString.StringResourceID; if (prevStringResource != null) { DuplicatedFromStringResource = prevStringResource.StringResourceID; } string updateNotice = string.Format("Item [{0}] duplicated for store: {1} ({2})", name, owningStore.Name, owningStore.StoreID); resetError(updateNotice, false); gMain.EditIndex = -1; } } else { // find if there's an existing string resource with that name+locale+storeid pair var dupString = StringResourceManager.GetStringResource(storeId, selectedLocale, name); if (dupString != null && dupString.StringResourceID != stringResourceId) { // prompt for error editing duplicate in same Store Strings resetError("Another string exists with that Name and Locale combination.", true); return; } // just edit the current string resource var str = StringResourceManager.GetStringResource(storeId, stringResourceId); if (str != null) { str.Update(name, selectedLocale, value); resetError("Item updated", false); gMain.EditIndex = -1; } else { resetError("Item could not be found in collection", true); } } resultFilter("", Localization.CheckLocaleSettingForProperCase(selectedLocale)); } }