/// <summary> /// The method is working on /// </summary> private void Initialize() { try { this.dynamicPage = DynamicPageContext.Current.GetDynamicPage(QueryStringUtility.ObjectId); } catch (ConfigurationErrorsException exp) { Logger.Instance(this).Warn(exp); throw new InternalServerErrorException(exp); } this.detailPanelConfiguration = this.dynamicPage.Configuration.Panels.FirstOrDefault(p => p.PanelType == DynamicPagePanelTypes.DetailPanel) as DetailPanelConfiguration; if (this.detailPanelConfiguration == null) { Logger.Instance(this).WarnFormat("The dynamic page {0} doesn't include detail panel configuration.", QueryStringUtility.ObjectId); throw new BadRequestException(string.Format(CultureInfo.InvariantCulture, @"There is no detail panel configured in the dynamic page ""{0}"".", QueryStringUtility.ObjectId)); } this.currentEntityId = QueryStringUtility.EntityId; this.renderMode = QueryStringUtility.DetailPanelPageRenderMode; }
/// <summary> /// Construct dynamic page instance by xml element. /// </summary> /// <param name="pageElement"></param> /// <param name="xmlParser"></param> public DynamicPageConfiguration(XmlElement pageElement, XmlParser xmlParser) : this() { this.pageElement = pageElement; this.xmlParser = xmlParser; this.Title = xmlParser.ParseString(pageElement, "p:Title"); this.PermissionValue = xmlParser.ParseString(pageElement, "p:PermissionValue"); this.ObjectId = xmlParser.ParseString(pageElement, "@ObjectId"); string dynamicPageTypeName = xmlParser.ParseString(pageElement, "@Type"); Type dynamicPageType = Kit.GetType(dynamicPageTypeName); if (dynamicPageType != null) { ConstructorInfo dynamicPageObjectConstructor = dynamicPageType.GetConstructor(Type.EmptyTypes); if (!(dynamicPageObjectConstructor.Invoke(null) is IDynamicPage)) throw new ConfigurationErrorsException(string.Format(Resources.DP_ConfiguredDynamicPageTypeNotImplementIDynamicPage, dynamicPageTypeName, this.ObjectId)); this.DynamicPageType = dynamicPageType; } else throw new ConfigurationErrorsException(string.Format(Resources.DP_ConfiguredDynamicPageTypeNotExists, dynamicPageTypeName, this.ObjectId)); string callbackTypeName = xmlParser.ParseString(pageElement, "@ProcessCallbackType"); if (!string.IsNullOrEmpty(callbackTypeName)) { Type callbackType = Kit.GetType(callbackTypeName); if (callbackType == null) throw new ConfigurationErrorsException(string.Format(CultureInfo.InvariantCulture, "The callback type @ProcessCallbackType:{0} is not found.", callbackTypeName)); this.ConfigurationProcessCallback = Activator.CreateInstance(callbackType) as IDynamicPageConfigurationProcessCallback; if (this.ConfigurationProcessCallback == null) throw new ConfigurationErrorsException(string.Format(CultureInfo.InvariantCulture, "The callback type @ProcessCallbackType:{0} doesn't implement the interface IDynamicPageConfigurationProcessCallback.", callbackTypeName)); } this.JavaScriptUrls = new Collection<string>(); XmlNodeList javaScriptUrlNodes = this.pageElement.SelectNodes("p:JavaScriptUrls/p:JavaScriptUrl", xmlParser.NamespaceManager); foreach (XmlNode javaScriptUrlNode in javaScriptUrlNodes) { XmlElement javaScriptUrlElement = javaScriptUrlNode as XmlElement; if (javaScriptUrlElement != null) this.JavaScriptUrls.Add(javaScriptUrlElement.InnerText); } bool hasQueryPanel = false, hasGridViewPanel = false, hasDetailPanel = false; HashSet<string> aggregatePanelCommandArguments = new HashSet<string>(); // create panel configurations XmlElement panelElement = pageElement.SelectSingleNode("p:Panels", xmlParser.NamespaceManager) as XmlElement; foreach (XmlNode childNode in panelElement.ChildNodes) { XmlElement childElement = childNode as XmlElement; if (childElement != null) { DynamicPagePanelTypes panelType = (DynamicPagePanelTypes)Enum.Parse(typeof(DynamicPagePanelTypes), childElement.LocalName); BasePanelConfiguration basePanelConfiguration = null; switch (panelType) { case DynamicPagePanelTypes.QueryPanel: if (hasQueryPanel) throw new ConfigurationErrorsException(Resources.DP_MultipleQueryPanelConfigured); hasQueryPanel = true; basePanelConfiguration = new QueryPanelConfiguration(childElement, xmlParser); break; case DynamicPagePanelTypes.GridViewPanel: if (hasGridViewPanel) throw new ConfigurationErrorsException(Resources.DP_MultipleGridViewPanelConfigured); hasGridViewPanel = true; basePanelConfiguration = new GridViewPanelConfiguration(childElement, xmlParser); break; case DynamicPagePanelTypes.DetailPanel: if (hasDetailPanel) throw new ConfigurationErrorsException(Resources.DP_MultipleDetailPanelConfigured); hasDetailPanel = true; DetailPanelConfiguration detailPanel = new DetailPanelConfiguration(childElement, xmlParser); basePanelConfiguration = detailPanel; break; case DynamicPagePanelTypes.AggregatePanel: AggregatePanelConfiguration aggregatePanel = new AggregatePanelConfiguration(childElement, xmlParser); string lowerCasedCommandArgument = aggregatePanel.CommandArgument.ToLower(CultureInfo.InvariantCulture); if (aggregatePanelCommandArguments.Contains(lowerCasedCommandArgument)) throw new ConfigurationErrorsException(string.Format(CultureInfo.InvariantCulture, Resources.DP_DuplicateAggregatePanelCommandArgumentConfigured, aggregatePanel.CommandArgument)); aggregatePanelCommandArguments.Add(lowerCasedCommandArgument); basePanelConfiguration = aggregatePanel; break; case DynamicPagePanelTypes.ButtonPanel: basePanelConfiguration = new ButtonPanelConfiguration(childElement, xmlParser); break; } this.Panels.Add(basePanelConfiguration); } } }