示例#1
0
        public static BrandMetadataSetting RenameMetadataFieldName(int brandMetadataSettingId, string fieldName)
        {
            fieldName = fieldName.Trim();

            if (StringUtils.IsBlank(fieldName))
            {
                throw new SystemException("Field name cannot be empty");
            }

            BrandMetadataSetting setting = BrandMetadataSetting.Get(brandMetadataSettingId);

            if (setting.IsNull)
            {
                throw new SystemException("Metadata setting not found");
            }

            BrandMetadataSettingFinder finder = new BrandMetadataSettingFinder {
                BrandId = setting.BrandId, FieldName = fieldName
            };
            int count = BrandMetadataSetting.GetCount(finder);

            if (count > 0)
            {
                throw new SystemException(string.Format("Another metadata setting with the name '{0}' already exists in this brand", fieldName));
            }

            setting.FieldName = fieldName;
            BrandMetadataSetting.Update(setting);

            CacheManager.InvalidateCache("Brand", CacheType.All);

            return(setting);
        }
示例#2
0
        protected override void OnPreRender(EventArgs e)
        {
            BrandMetadataSetting setting = Brand.GetMetadataSetting(FieldName);

            if (setting.IsNull)
            {
                setting = WebsiteBrandManager.GetMasterBrand().GetMetadataSetting(FieldName);
            }

            if (setting.IsNull || StringUtils.IsBlank(setting.FieldName))
            {
                Text = GeneralUtils.SplitIntoSentence(FieldName);
                return;
            }

            Text = string.Format("<a href=\"#\" title=\"{0}\" class=\"PanelTxt Bold\">{1}:</a>", setting.ToolTip, setting.FieldName);

            if (ShowRequiredFlag && setting.IsRequired)
            {
                Text += "  <span class=\"ReqField\">*</span>";
            }

            if (!StringUtils.IsBlank(setting.AdditionalCopy))
            {
                Text += string.Format("<br /><span class=\"PanelTxt\">{0}</span>", setting.AdditionalCopy);
            }
        }
示例#3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            BrandMetadataSettingCache.Instance.InvalidateCache();
            BrandCache.Instance.InvalidateCache();

            Brand brand = BrandCache.Instance.GetById(BrandId);
            BrandMetadataSetting setting = brand.GetCustomMetadataSetting(GroupNumber);

            // Set page header and title
            PageHeader.InnerText = string.Format("Manage {0} Metadata", setting.FieldName);
            SetPageTitle(PageHeader.InnerText);

            // Setup return links
            ManageMetadataHyperlink1.NavigateUrl = ManageMetadataHyperlink2.NavigateUrl = string.Format("ManageMetadataValues.aspx?BrandId={0}", brand.BrandId);

            // Reload the cache
            CacheManager.InvalidateCache("Metadata", CacheType.Local);

            // First ensure brand has a root metadata
            MetadataManager.EnsureRootExists(BrandId, GroupNumber, setting.FieldName, CurrentUser);

            PreviewContainerDiv.Visible = false;

            if (!Page.IsPostBack)
            {
                ucEditDetails.SelectableSetting = setting.SelectableSetting;
                ucEditDetails.DataBind();
            }
        }
        /// <summary>
        /// returns all custom metadata settings for a supplied brand
        /// </summary>
        /// <param name="brandId"></param>
        /// <returns></returns>
        public static EntityList <BrandMetadataSetting> GetCustomMetadataSettings(int brandId)
        {
            var finder = new BrandMetadataSettingFinder {
                BrandId = brandId, IsCustom = true
            };
            var settings = BrandMetadataSetting.FindMany(finder);

            return(settings);
        }
示例#5
0
        private static void ValidateTextField(Asset asset, ErrorList errors, string fieldId, string val)
        {
            BrandMetadataSetting setting = asset.Brand.GetMetadataSetting(fieldId);

            if (setting.IsRequired && StringUtils.IsBlank(val))
            {
                errors.Add(setting.FieldName + " is required");
            }
        }
示例#6
0
        private void LoadMetaPreview(MetadataInputWrapper input, BrandMetadataSetting brandMetaSetting, int depth, SelectableMetadataType type)
        {
            brandMetaSetting.SelectableSetting.SelectableType = (int)type;
            brandMetaSetting.SelectableSetting.Depth          = depth;

            input.SetTempBrandMetaSetting(brandMetaSetting);
            input.IncludeJqueryReference = false;
            input.GroupNumber            = brandMetaSetting.GroupNumber;
            input.BrandId = BrandId;
            input.ResetState();
            input.InitInput(true);
            input.RefreshFromBrandAndSelet(BrandId, new int[] { }, string.Empty);
        }
示例#7
0
        protected override void OnPreRender(EventArgs e)
        {
            BrandMetadataSetting setting = Brand.GetMetadataSetting(FieldName);

            if (setting.IsNull)
            {
                setting = WebsiteBrandManager.GetMasterBrand().GetMetadataSetting(FieldName);
            }

            if (setting.IsNull || StringUtils.IsBlank(setting.FieldName))
            {
                Text = GeneralUtils.SplitIntoSentence(FieldName);
                return;
            }

            Text = setting.FieldName;
        }
        /// <summary>
        /// deletes the setting, all stored possible selection values and all selected values for all assets
        /// </summary>
        /// <param name="brandMetadataSettingId">the setting to be deleted</param>
        public static void DeleteSettingAndValues(int brandMetadataSettingId)
        {
            var setting = BrandMetadataSetting.Get(brandMetadataSettingId);

            if (setting == null)
            {
                return;
            }

            var group = setting.GroupNumber;

            var metaValuesFinder = new MetadataFinder()
            {
                GroupNumber = group
            };

            var vals = Metadata.FindMany(metaValuesFinder);

            var assetMetaFinder = new AssetMetadataFinder()
            {
            };

            //iterate through all values, delete existing assetmetadata selection and then delete values themselves as well
            foreach (var metaValue in vals)
            {
                assetMetaFinder.MetadataId = metaValue.MetadataId.GetValueOrDefault();

                var assetMetaSelections = AssetMetadata.FindMany(assetMetaFinder);

                foreach (var assetMeta in assetMetaSelections)
                {
                    AssetMetadata.Delete(assetMeta.AssetMetadataId);
                }

                Metadata.Delete(metaValue.MetadataId);
            }

            //delete selectable setting if one exists
            if (!setting.SelectableSetting.IsNull && !setting.SelectableSetting.IsNew)
            {
                BrandMetadataSelectableSetting.Delete(setting.SelectableSetting.BrandMetadataSelectableSettingId);
            }

            //delete the setting itself
            BrandMetadataSetting.Delete(brandMetadataSettingId);
        }
        protected override void OnPreRender(EventArgs e)
        {
            // Assume not visible
            bool visible = false;

            // Get the brand setting
            BrandMetadataSetting setting = Brand.GetMetadataSetting(FieldName);

            // Display if we need to use the Asset Form setting and it's enabled
            if (Section == Sections.AssetForm && setting.OnAssetForm)
            {
                visible = true;
            }

            // Display if we need to use the Asset Detail setting and it's enabled
            if (Section == Sections.AssetDetail && setting.OnAssetDetail)
            {
                visible = true;
            }

            // Update visibility
            Visible = visible;
        }
 public void RetrieveData(ref BrandMetadataSetting setting)
 {
     setting.FieldName      = FieldNameTextBox.Text.Trim();
     setting.AdditionalCopy = AdditionalCopyTextBox.Text.Trim();
     setting.ToolTip        = ToolTipTextBox.Text.Trim();
 }
 public void LoadData(BrandMetadataSetting setting)
 {
     FieldNameTextBox.Text      = setting.FieldName;
     AdditionalCopyTextBox.Text = setting.AdditionalCopy;
     ToolTipTextBox.Text        = setting.ToolTip;
 }
示例#12
0
        private static List <BrandMetadataSetting> GetMetadataSettings(int brandId)
        {
            // Get all of the metadata settings for this brand
            BrandMetadataSettingFinder finder = new BrandMetadataSettingFinder {
                BrandId = brandId
            };
            List <BrandMetadataSetting> settings = BrandMetadataSetting.FindMany(finder);

            // Return settings if found
            if (settings.Count == 0)
            {
                // Otherwise, we need to get the default settings
                List <int> brandIdList = new List <int>();

                // Check the master brand first
                if (brandId != WebsiteBrandManager.GetMasterBrand().BrandId)
                {
                    brandIdList.Add(WebsiteBrandManager.GetMasterBrand().BrandId.GetValueOrDefault());
                }

                // Then all subsequent brands
                foreach (Brand brand in BrandCache.Instance.GetList())
                {
                    if (!brandIdList.Contains(brand.BrandId.GetValueOrDefault()))
                    {
                        brandIdList.Add(brand.BrandId.GetValueOrDefault());
                    }
                }

                // Now check each brand
                foreach (int id in brandIdList)
                {
                    // Get the metadata settings in this brand
                    finder = new BrandMetadataSettingFinder {
                        BrandId = id, IsCustom = false
                    };
                    settings = BrandMetadataSetting.FindMany(finder);

                    if (settings.Count > 0)
                    {
                        // Settings found.  Copy all of them to the brand
                        // being edited and drop out of the loop as we've
                        // found what we're looking for.

                        foreach (BrandMetadataSetting setting in settings)
                        {
                            setting.BrandMetadataSettingId = null;
                            setting.BrandId = brandId;
                            BrandMetadataSetting.Update(setting);
                        }

                        break;
                    }
                }
            }

            // Still no settings, so copy them from the default metadata options
//			if (settings.Count == 0)
//			{
            // Still no settings so try and add these using our configuration settings
//				foreach (MetadataOption option in m_MetadataOptions)
//					AddMetadataSettingToDatabase(brandId, option, settings);
//			}
//
            // There should be the same number of settings in the database as there are default metadata
            // options or this means that these are out of sync. In this case, add the new setting to the list.
//
//			if (settings.Count < m_MetadataOptions.Count)
//			{
            // First get the missing settings.  These are items that exist in the metadata options list
            // but not in the list we got from the database.
//				var missingSettings = (from o in m_MetadataOptions
//				                       where !settings.Any(s => s.FieldId == o.FieldId)
//				                       select o);
//
            // Now add them to the database and the settings list
//				foreach (var setting in missingSettings)
//					AddMetadataSettingToDatabase(brandId, setting, settings);
//			}

            return(settings);
        }
 public void SetTempBrandMetaSetting(BrandMetadataSetting setting)
 {
     brandMetaSetting = setting;
 }