/// <summary>
        /// Get concrete data type from query string of current http request and save "ConcreteDataCategory" into TempVariables of IApplicationContext.
        /// </summary>
        /// <param name="requestHandler">Request handler.</param>
        /// <param name="e"></param>
        /// <param name="rediectToPageNotFoundUrlIfCategoryNotFound"></param>
        public static void SetupConcreteDataType(IRequestHandler requestHandler, SetupApplicationContextVariablesEventArgs e, bool rediectToPageNotFoundUrlIfCategoryNotFound)
        {
            string concreteDataType = requestHandler.Parameters["ConcreteDataType"];
            if (string.IsNullOrEmpty(concreteDataType) && rediectToPageNotFoundUrlIfCategoryNotFound)
                throw new ResourceNotFoundException(string.Format(CultureInfo.InvariantCulture, Resources.InvalidConcreteDataType, concreteDataType));

            if (!string.IsNullOrEmpty(concreteDataType))
                e.TempVariables["ConcreteDataType"] = concreteDataType;
        }
        /// <summary>
        /// Get hierarchy type from query string of current http request and save "HierarchyType" into TempVariables of IApplicationContext.
        /// </summary>
        /// <param name="requestHandler">Request handler.</param>
        /// <param name="e"></param>
        /// <param name="rediectToPageNotFoundUrlIfHierarchyTypeNotFound"></param>
        public static void SetupHierarchyType(IRequestHandler requestHandler, SetupApplicationContextVariablesEventArgs e, bool rediectToPageNotFoundUrlIfHierarchyTypeNotFound)
        {
            IPlatformConfiguration platformConfiguration = SpringContext.Current.GetObject<IPlatformConfiguration>();
            string hierarchyType = requestHandler.Parameters["HierarchyType"];
            if (string.IsNullOrEmpty(hierarchyType) && rediectToPageNotFoundUrlIfHierarchyTypeNotFound)
                throw new ResourceNotFoundException(string.Format(CultureInfo.InvariantCulture, Resources.InvalidHierarchyType, hierarchyType));

            e.TempVariables["HierarchyType"] = hierarchyType;
        }
        /// <summary>
        /// Validate query string "MetadataDataTypeName" and setup metadata data type name to IAuthenticationContext.TempVariables.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public override void SetupContextTempVariables(IRequestHandler sender, SetupApplicationContextVariablesEventArgs e)
        {
            string metadataDataTypeName = QueryStringUtility.MetadataDataTypeName(sender);
            IObjectMetadata metadata = metadataApi.GetType(metadataDataTypeName);
            if (metadata == null)
                throw new ResourceNotFoundException(string.Format(CultureInfo.InvariantCulture, Resources.InvalidMetadataTypeName, metadataDataTypeName));

            e.TempVariables["MetadataDataTypeId"] = metadata.Id;
            e.TempVariables["MetadataDataTypeName"] = metadata.Name;
        }
 public void SetupContextTempVariables(IRequestHandler sender, SetupApplicationContextVariablesEventArgs e)
 {
 }
        /// <summary>
        /// Get domain from query string of current http request and save "Domain.Text" and "Domain.Value" into TempVariables of IApplicationContext.
        /// </summary>
        /// <param name="requestHandler">Request handler.</param>
        /// <param name="e">Callback event argument.</param>
        /// <param name="rediectToPageNotFoundUrlIfDomainNotFound">Whether to redirect the request to PageNotFound Url if query string "domain" is invalid</param>
        public static void SetupOrganizationDomain(IRequestHandler requestHandler, SetupApplicationContextVariablesEventArgs e, bool rediectToPageNotFoundUrlIfDomainNotFound)
        {
            IPlatformConfiguration platformConfiguration = SpringContext.Current.GetObject<IPlatformConfiguration>();
            string domain = requestHandler.Parameters["Domain"];
            OrganizationDomain organizationDomain = platformConfiguration.Domains.FirstOrDefault(d => d.Value == domain);
            if (organizationDomain == null && rediectToPageNotFoundUrlIfDomainNotFound)
                throw new ResourceNotFoundException(string.Format(CultureInfo.InvariantCulture, Resources.InvalidDomain, domain));

            if (organizationDomain != null)
            {
                e.TempVariables["Domain.Text"] = organizationDomain.Text;
                e.TempVariables["Domain.Value"] = organizationDomain.Value;
            }
        }
 /// <summary>
 /// Get domain from query string of current http request and save "Domain.Text" and "Domain.Value" into TempVariables of IApplicationContext.
 /// It redirects the request to PageNotFound Url if query string "domain" is invalid.
 /// </summary>
 /// <param name="requestHandler">Request handler.</param>
 /// <param name="e">Callback event argument.</param>
 public static void SetupOrganizationDomain(IRequestHandler requestHandler, SetupApplicationContextVariablesEventArgs e)
 {
     SetupOrganizationDomain(requestHandler, e, true);
 }
 /// <summary>
 /// Setup context temporary variables for formatting configured text-typed properties.
 /// Set domain into http context when web page is initializing.
 /// </summary>
 /// <param name="sender">The sender which invokes the method.</param>
 /// <param name="e">Callback event argument.</param>
 public override void SetupContextTempVariables(IRequestHandler sender, SetupApplicationContextVariablesEventArgs e)
 {
     SetupContextTempVariablesUtility.SetupOrganizationDomain(sender, e);
 }
 /// <summary>
 /// Setup context temporary variables for formatting configured text-typed properties.
 /// Set domain into http context when web page is initializing.
 /// </summary>
 /// <param name="sender">The sender which invokes the method.</param>
 /// <param name="e">Callback event argument.</param>
 public override void SetupContextTempVariables(IRequestHandler sender, SetupApplicationContextVariablesEventArgs e)
 {
     SetupContextTempVariablesUtility.SetupHierarchyType(sender, e, true);
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public QueryResults Query(QueryParameter parameter)
        {
            IDynamicPage actualPage = this.actual as IDynamicPage;
            setupArgs = new SetupApplicationContextVariablesEventArgs();
            sender = new RequestHandlerMock();
            dynamicPageArgs = new EventArgs();

            actualPage.SetupContextTempVariables(sender, setupArgs);
            actualPage.OnInit(sender, dynamicPageArgs);
            actualPage.OnLoad(sender, dynamicPageArgs);

            return actualPage.Query(parameter);
        }
        /// <summary>
        /// When User call Save method in IAggregatePanelPage,
        /// This method will be invoked, and help user do the pre-required conditions, setup parameters
        /// </summary>
        /// <param name="commandArgument"></param>
        /// <param name="entityIdEnumerable"></param>
        public void Save(string commandArgument, IEnumerable<string> entityIdEnumerable)
        {
            setupArgs = new SetupApplicationContextVariablesEventArgs();
            aggregatePanelPageArgs = new AggregatePanelPageEventArgs("Save", entityIdEnumerable);
            sender = new RequestHandlerMock();

            IAggregatePanelPage actualPanel = actual as IAggregatePanelPage;

            actualPanel.SetupContextTempVariables(sender, setupArgs);
            actualPanel.OnInit(sender, aggregatePanelPageArgs);
            actualPanel.OnLoad(sender, aggregatePanelPageArgs);

            actualPanel.Save(commandArgument, entityIdEnumerable);
        }
        /// <summary>
        /// When User call Create method in IDetailPanelPage,
        /// This method will be invoked, and help user do the pre-required conditions, setup parameters
        /// </summary>
        /// <returns></returns>
        public string Create()
        {
            Validate();
            setupArgs = new SetupApplicationContextVariablesEventArgs();
            detailPanelArgs = new DetailPanelPageEventArgs("", DetailPanelPageRenderModes.New);
            sender = new RequestHandlerMock();
            sender.isPostBack = true;
            IDetailPanelPage actualPanel = actual as IDetailPanelPage;
            actualPanel.SetupContextTempVariables(sender, setupArgs);
            actualPanel.OnInit(sender, detailPanelArgs);
            actualPanel.OnLoad(sender, detailPanelArgs);

            return actualPanel.Create();
        }
        /// <summary>
        /// When User call Update method in IDetailPanelPage,
        /// This method will be invoked, and help user do the pre-required conditions, setup parameters
        /// </summary>
        /// <param name="entityId"></param>
        public void Update(string entityId)
        {
            Validate();
            setupArgs = new SetupApplicationContextVariablesEventArgs();
            detailPanelArgs = new DetailPanelPageEventArgs(entityId, DetailPanelPageRenderModes.Update);
            sender = new RequestHandlerMock();
            sender.isPostBack = true;
            IDetailPanelPage actualPanel = actual as IDetailPanelPage;

            actualPanel.SetupContextTempVariables(sender, setupArgs);
            actualPanel.OnInit(sender, detailPanelArgs);
            actualPanel.OnLoad(sender, detailPanelArgs);

            actualPanel.Update(entityId);
        }