protected void Initialize() { List <string> accounts = new List <string>(); ArticleUPager.PageIndex = PageNumber; ArticleUPager.ItemCount = AccountHelper.GetAccountCountOfRole(RoleID); ArticleUPager.UrlFormat = We7Helper.AddParamToUrl(Request.RawUrl.Replace("{", "{{").Replace("}", "}}"), Keys.QRYSTR_PAGEINDEX, "{0}"); ArticleUPager.PrefixText = "共 " + ArticleUPager.MaxPages + " 页 · 第 " + ArticleUPager.PageIndex + " 页 · "; accounts = AccountHelper.GetAccountsOfRole(RoleID, ArticleUPager.Begin - 1, ArticleUPager.Count); List <InnerItem> items = new List <InnerItem>(); foreach (string aid in accounts) { InnerItem item = new InnerItem(); item.AccountID = aid; item.RoleID = RoleID; Account a = AccountHelper.GetAccount(aid, new string[] { "LoginName", "DepartmentID", "Department" }); if (a != null) { item.AccountName = a.LoginName; item.DepartmentName = a.Department; } items.Add(item); } personalForm.DataSource = items; personalForm.DataBind(); }
public List <DeepDiveSectionInfoPageItem> GetSectionData() { return(InnerItem.GetChildren() .Where(i => i.TemplateID.ToString() == DeepDiveSectionInfoPageItem.TemplateId.ToString() && i.Parent.ID.ToString() == ID.ToString()) .Select(i => (DeepDiveSectionInfoPageItem)i).ToList()); }
protected override void DoDuplicate() { var repository = Repository as IMarketingRepository; var item = InnerItem.DeepClone(EntityFactory as IKnownSerializationTypes); item.PromotionId = item.GenerateNewKey(); item.Name = item.Name + "_1"; item.Status = PromotionStatusConverter.ValueInActive; item.Rewards.Clear(); item.Coupon = null; item.CouponId = null; if (InnerItem.Coupon != null) { var coupon = InnerItem.Coupon.DeepClone(EntityFactory as IKnownSerializationTypes); coupon.CouponId = coupon.GenerateNewKey(); item.CouponId = coupon.CouponId; repository.Add(coupon); } InnerItem.Rewards.ToList().ForEach(x => { var newReward = x.DeepClone(EntityFactory as IKnownSerializationTypes); newReward.PromotionRewardId = newReward.GenerateNewKey(); item.Rewards.Add(newReward); }); repository.Add(item); }
protected override void OnIsValidChanged() { InnerItem.Validate(false); _isValid = InnerItem.Errors.Count == 0; base.OnIsValidChanged(); }
protected override bool IsValidForSave() { bool result = false; result = InnerItem.Validate() && !string.IsNullOrEmpty(InnerItem.Body) && !string.IsNullOrEmpty(InnerItem.DefaultLanguageCode); return(result); }
protected override void OnIsValidChanged() { bool doNotifyChanges = false; InnerItem.Validate(doNotifyChanges); _isValid = InnerItem.Errors.Count == 0 && (!string.IsNullOrEmpty(InnerItem.Name) && !string.IsNullOrEmpty(InnerItem.Description)); base.OnIsValidChanged(); }
protected override bool IsValidForSave() { bool result = InnerItem.Validate() && !string.IsNullOrEmpty(InnerItem.City) && !string.IsNullOrEmpty(InnerItem.CountryCode) && !string.IsNullOrEmpty(InnerItem.DaytimePhoneNumber) && !string.IsNullOrEmpty(InnerItem.Line1) && !string.IsNullOrEmpty(InnerItem.PostalCode) && !string.IsNullOrEmpty(InnerItem.Name) && !string.IsNullOrEmpty(InnerItem.Description); return(result); }
private void ValidateDefaultCurrency(bool doNotifyChanges) { if (string.IsNullOrEmpty(InnerItem.DefaultCurrency)) { InnerItem.SetError("DefaultCurrency", "Field 'Default Currency' is required.".Localize(), doNotifyChanges); } else { InnerItem.ClearError("DefaultCurrency"); } }
private void ValidateCurrencies(bool doNotifyChanges) { if (InnerItem.Currencies.Count == 0) { InnerItem.SetError("Currencies", "external validation error".Localize(), doNotifyChanges); } else { InnerItem.ClearError("Currencies"); } }
private void ValidatePropertySet(bool doNotifyChanges) { if (InnerItem.PropertySet == null || string.IsNullOrEmpty(InnerItem.PropertySet.PropertySetId)) { InnerItem.SetError("PropertySet", "PropertySet error".Localize(), doNotifyChanges); } else { InnerItem.ClearError("PropertySet"); } }
private void ValidateDefaultLanguage(bool doNotifyChanges) { if (string.IsNullOrEmpty(InnerItem.DefaultLanguage) || InnerItem.DefaultLanguage.StartsWith("Select")) { InnerItem.SetError("DefaultLanguage", "Field 'Default Language' is required.".Localize(), doNotifyChanges); } else { InnerItem.ClearError("DefaultLanguage"); } }
public IEnumerable <DefaultArticlePageItem> GetArticles(int page, Guid?templateId, out bool hasMoreResults) { var all = InnerItem.GetChildren() .FilterByContextLanguageVersion() .Where(i => i.InheritsTemplate(DefaultArticlePageItem.TemplateId)); if (templateId.HasValue) { all = all.Where(i => i.TemplateID == Sitecore.Data.ID.Parse(templateId.Value)); } return(GetPagedResultQuery(all, page, out hasMoreResults)); }
protected override bool IsValidForSave() { if (SeoStepViewModel != null) { var isSeoValid = SeoStepViewModel.IsValid; if (!isSeoValid) { SelectedTabIndex = SeoTabIndex; } return(InnerItem.Validate() && isSeoValid); } return(InnerItem.Validate()); }
public string GetEventType() { // Webinar/chat if (InnerItem.IsOfType(ChatEventPageItem.TemplateId)) { return(DictionaryConstants.ChatLabel); } else if (InnerItem.IsOfType(WebinarEventPageItem.TemplateId)) { return(DictionaryConstants.WebinarLabel); } return(String.Empty); }
protected override void DoDuplicate() { var item = InnerItem.DeepClone(EntityFactory as IKnownSerializationTypes); item.ImportJobId = item.GenerateNewKey(); item.PropertiesMap.ToList().ForEach(mapItem => { mapItem.ImportJobId = item.ImportJobId; mapItem.MappingItemId = mapItem.GenerateNewKey(); mapItem.ImportJob = null; }); item.Name = item.Name + "_1"; Repository.Add(item); }
public void Recalculate() { var result = _orderService.ExecuteWorkflow(RecalculateWorkflowName, InnerItem); var warnings = result.WorkflowResult.Warnings; if (warnings != null) { foreach (var warning in warnings) { //TODO: generate error message } } InnerItem.InjectFrom <CloneInjection>(result.OrderGroup); }
// function almost duplicated in ItemViewModel protected override bool IsValidForSave() { var result = InnerItem.Validate(); // Code should be unique in scope of catalog var isCodeValid = true; if (InnerItem.Code != OriginalItem.Code) { var count = ItemRepository.Categories .Where(x => x.CatalogId == InnerItem.CatalogId && x.Code == InnerItem.Code && x.CategoryId != InnerItem.CategoryId) .Count(); if (count > 0) { InnerItem.SetError("Code", "A category with this Code already exists in this catalog".Localize(), true); SelectedTabIndex = TabIndexOverview; isCodeValid = false; } } var isPropertyValuesValid = PropertiesAndValues.All(x => x.IsValid); if (!isPropertyValuesValid && isCodeValid) { SelectedTabIndex = TabIndexProperties; var val = PropertiesAndValues.First(x => !x.IsValid); if (!string.IsNullOrEmpty(val.Locale) && val.Locale != FilterLanguage) { RaisePropertiesLocalesFilter(val.Locale); } } var seoIsValid = true; if (SeoStepViewModel != null) { seoIsValid = SeoStepViewModel.IsValid; if (!seoIsValid) { SelectedTabIndex = TabIndexSeo; } } return(result && isPropertyValuesValid && isCodeValid && seoIsValid); }
/// <summary> /// Archives current poll to the pollItem. /// </summary> /// <param name="pollItem">The poll item.</param> public void ArchiveTo(Item pollItem) { //copy archive folder if exists foreach (Item item in InnerItem.Children) { if (item.TemplateID == PollConstants.PollArchiveTemplateID) { item.CopyTo(pollItem, item.Name); item.Delete(); } } //or create archive folder if (pollItem.Children[PollConstants.PollArchiveFolderName] == null) { TemplateItem pollArhiveTemplate = PollConstants.DatabaseContext.Templates[PollConstants.PollArchiveTemplateID]; Assert.IsNotNull(pollArhiveTemplate, "Poll archive template"); pollItem.Add(PollConstants.PollArchiveFolderName, pollArhiveTemplate); } string itemName = string.Format("{0} {1}", InnerItem.Name, DateTime.Today.ToShortDateString().Replace('.', ' ')); string displayName = itemName; if (ItemUtil.GetItemNameError(itemName).Length > 0) { itemName = ItemUtil.ProposeValidItemName(itemName); } Item currentPollCopy = InnerItem.CopyTo(pollItem.Children[PollConstants.PollArchiveFolderName], itemName, Data.ID.NewID, false); if (displayName != itemName) { PollItem archivedPoll = new PollItem(currentPollCopy) { DisplayName = displayName }; } //copy all poll options foreach (Item item in InnerItem.Children) { item.CopyTo(currentPollCopy, item.Name); item.Delete(); } InnerItem.Delete(); }
/// <summary> /// Adds a new item as a child of this item /// </summary> /// <typeparam name="TItem">The Synthesis type of the child to add. Must be a concrete template type.</typeparam> /// <param name="name">Name of the new item</param> /// <returns>The newly added child item</returns> public TItem Add <TItem>(string name) where TItem : class, IStandardTemplateItem { var type = typeof(TItem); ID templateId; if (type.IsInterface) { var attribute = type.GetCustomAttribute <RepresentsSitecoreTemplateAttribute>(false); if (attribute == null) { throw new ArgumentException("Item interface did not have the requisite [RepresentsSitecoreTemplate] attribute."); } if (!ID.TryParse(attribute.TemplateId, out templateId)) { throw new ArgumentException("Item interface's [RepresentsSitecoreTemplate] attribute had an invalid template ID format."); } } else { var property = type.GetProperty("ItemTemplateId", BindingFlags.Static | BindingFlags.Public); if (property == null) { throw new ArgumentException(type.FullName + " does not seem to be a generated item type (no ItemTemplateId property was present)"); } var propertyValue = property.GetValue(null) as ID; if (propertyValue == (ID)null) { throw new ArgumentException("ItemTemplateId property was not of the expected Sitecore.Data.ID type"); } templateId = propertyValue; } Item newItem = InnerItem.Add(name, new TemplateID(templateId)); return(newItem.As <TItem>()); }
public MultilistToComponents(Item i, ILogger l) : base(i, l) { ExistingDataNames = GetItemField(i, "From What Field").Split(comSplitr, StringSplitOptions.RemoveEmptyEntries); Delimiter = GetItemField(i, "Delimiter"); Device = GetItemField(i, "Device"); DatasourceFolder = GetItemField(i, "Datasource Folder"); IsSXA = GetItemField(i, "Is SXA") == "1"; PresentationService = new PresentationService(l); ComponentMaps = new Dictionary <string, ComponentMap>(); MediaService = new MediaService(l); var maps = InnerItem.GetChildren(); foreach (Item m in maps) { var c = new ComponentMap { FromWhatTemplate = GetItemField(m, "From What Template"), Component = GetItemField(m, "Component"), Placeholder = GetItemField(m, "Placeholder"), DatasourcePath = GetItemField(m, "Datasource Path"), OverwriteExisting = GetItemField(m, "Overwrite Existing") == "1", Fields = new Dictionary <string, IBaseField>(), Parameters = GetItemField(m, "Parameters") }; foreach (Item f in m.GetChildren()) { var bf = FieldService.BuildBaseField(f); var a = GetItemField(f, "From What Field"); if (string.IsNullOrWhiteSpace(a) || bf == null) { continue; } c.Fields.Add(a, bf); } ComponentMaps.Add(c.FromWhatTemplate, c); } }
/// <summary> /// Adds a new item as a child of this item /// </summary> /// <typeparam name="TItem">The Synthesis type of the child to add. Must be a concrete template type.</typeparam> /// <param name="name">Name of the new item</param> /// <returns>The newly added child item</returns> public TItem Add <TItem>(string name) where TItem : class, IStandardTemplateItem { var type = typeof(TItem); var property = type.GetProperty("ItemTemplateId", BindingFlags.Static | BindingFlags.Public); if (property == null) { throw new ArgumentException(type.FullName + " does not seem to be a generated item type (no ItemTemplateId property was present)"); } var propertyValue = property.GetValue(null) as ID; if (propertyValue == (ID)null) { throw new ArgumentException("ItemTemplateId property was not of the expected Sitecore.Data.ID type"); } Item newItem = InnerItem.Add(name, new TemplateID(propertyValue)); return(newItem.As <TItem>()); }
protected void ResolveThemeAssets() { var scriptList = new List <ScriptItem>(); var stylesheetList = new List <FileItem>(); var children = InnerItem.GetChildren(); foreach (Item item in children) { if (item.TemplateIsOrBasedOn(ScriptItem.TemplateId)) { scriptList.Add(new ScriptItem(item)); } if (item.TemplateIsOrBasedOn(StylesheetItem.TemplateId)) { stylesheetList.Add(new StylesheetItem(item)); } } Scripts = scriptList; Stylesheets = stylesheetList; }
protected override bool IsValidForSave() { return(InnerItem.Validate()); }
protected override bool IsValidForSave() { InnerItem.Validate(); return(!InnerItem.Errors.Any()); }
public RecommendationQuestionsFolderItem GetRecommendationsFolder() { return((RecommendationQuestionsFolderItem)InnerItem.GetChildren().Where(i => i.IsOfType(RecommendationQuestionsFolderItem.TemplateId)).FirstOrDefault()); }
public ArticleEntryMessageFolderItem GetArticleEntryMessagesFolder() { return((ArticleEntryMessageFolderItem)InnerItem.GetChildren().Where(i => i.IsOfType(ArticleEntryMessageFolderItem.TemplateId)).FirstOrDefault()); }
/// <summary> /// Get More Explore folder Item. /// </summary> /// <returns></returns> public MoreExploreFolderItem GetMoreExploreFolder() { return((MoreExploreFolderItem)InnerItem.GetChildren().Where(i => i.IsOfType(MoreExploreFolderItem.TemplateId)).FirstOrDefault()); }
/// <summary> /// Get meta data folder Item. /// </summary> /// <returns></returns> public MetadataFolderFolderItem GetMetaDataFolder() { return((MetadataFolderFolderItem)InnerItem.GetChildren().Where(i => i.IsOfType(MetadataFolderFolderItem.TemplateId)).FirstOrDefault()); }
public StatesFolderItem GetStatesFolder() { return((StatesFolderItem)InnerItem.GetChildren().Where(i => i.IsOfType(StatesFolderItem.TemplateId)).FirstOrDefault()); }
/// <summary> /// Get Footer from global /// </summary> /// <returns></returns> public FooterFolderItem GetFooter() { return((FooterFolderItem)InnerItem.GetChildren().Where(i => i.IsOfType(FooterFolderItem.TemplateId)).FirstOrDefault()); }