public void InitializeViewState()
 {
     foreach (IUiControl tab in this.UiControls)
     {
         IWebUiControl WebUiChild = tab as IWebUiControl;
         WebUiChild.InitializeViewState();
     }
 }
Beispiel #2
0
 public TemplatedExecutionContainer(IWebUiControl form, Type templateUserControlType, string containerLabel, string containerLabelField, ResourceHandle containerIcon)
 {
     _form = form;
     _templateUserControlType = templateUserControlType;
     _containerLabel          = containerLabel;
     _containerLabelField     = containerLabelField;
     _containerIcon           = containerIcon;
 }
 public TemplatedExecutionContainer(IWebUiControl form, Type templateUserControlType, string containerLabel, string containerLabelField, ResourceHandle containerIcon)
 {
     _form = form;
     _templateUserControlType = templateUserControlType;
     _containerLabel = containerLabel;
     _containerLabelField = containerLabelField;
     _containerIcon = containerIcon;
 }
        /// <exclude />
        public static Control GetFlowUi(FlowHandle flowHandle, string elementProviderName, string consoleId, out string uiContainerName)
        {
            uiContainerName = null;

            try
            {
                Control webControl = null;
                string  viewId     = ViewTransitionHelper.MakeViewId(flowHandle.Serialize());

                FlowControllerServicesContainer flowServicesContainer = new FlowControllerServicesContainer();
                flowServicesContainer.AddService(new ActionExecutionService(elementProviderName, consoleId));
                flowServicesContainer.AddService(new ManagementConsoleMessageService(consoleId, viewId));
                flowServicesContainer.AddService(new ElementDataExchangeService(elementProviderName));

                FlowToken         flowToken        = flowHandle.FlowToken;
                IFlowUiDefinition flowUiDefinition = FlowControllerFacade.GetCurrentUiDefinition(flowToken, flowServicesContainer);

                var formFlowUiDefinition = flowUiDefinition as FormFlowUiDefinition;
                if (formFlowUiDefinition != null)
                {
                    uiContainerName = formFlowUiDefinition.UiContainerType.ContainerName;

                    IUiControl    uiForm  = FormFlowUiDefinitionRenderer.Render(consoleId, elementProviderName, flowToken, formFlowUiDefinition, WebManagementChannel.Identifier, false, flowServicesContainer);
                    IWebUiControl webForm = (IWebUiControl)uiForm;
                    webControl = webForm.BuildWebControl();

                    if (string.IsNullOrEmpty(webControl.ID))
                    {
                        webControl.ID = "FlowUI";
                    }

                    if (RuntimeInformation.TestAutomationEnabled)
                    {
                        var testAutomationLocatorInformation = formFlowUiDefinition.MarkupProvider as ITestAutomationLocatorInformation;
                        if (testAutomationLocatorInformation != null)
                        {
                            var htmlform = webControl.Controls.OfType <HtmlForm>().FirstOrDefault();
                            if (htmlform != null)
                            {
                                htmlform.Attributes.Add("data-qa", testAutomationLocatorInformation.TestAutomationLocator);
                            }
                        }
                    }
                }

                return(webControl);
            }
            catch (Exception ex)
            {
                ErrorServices.DocumentAdministrativeError(ex);
                ErrorServices.RedirectUserToErrorPage(uiContainerName, ex);
            }

            return(new LiteralControl("ERROR"));
        }
        /// <exclude />
        public static FormTreeCompiler AttachAndCompileParameterWidgets(Control attachmentControl, IEnumerable <ParameterProfile> parameterProfiles, Dictionary <string, object> bindings, string uniqueName, string panelLabel, IFormChannelIdentifier channelIdentifier, bool reset)
        {
            FormTreeCompiler compiler     = FunctionUiHelper.BuildWidgetForParameters(parameterProfiles, bindings, uniqueName, panelLabel, channelIdentifier);
            IWebUiControl    webUiControl = (IWebUiControl)compiler.UiControl;
            Control          form         = webUiControl.BuildWebControl();

            attachmentControl.Controls.Add(form);

            if (reset)
            {
                webUiControl.InitializeViewState();
            }

            return(compiler);
        }
Beispiel #6
0
        /// <exclude />
        public string GetTitleFieldControlId()
        {
            IWebUiControl container = GetContainer();

            if (_titleField.IsNullOrEmpty() || container == null)
            {
                return(string.Empty);
            }

            var mappings = new Dictionary <string, string>();

            FormFlowUiDefinitionRenderer.ResolveBindingPathToCliendIDMappings(container, mappings);

            string clientId = mappings.ContainsKey(_titleField) ? mappings[_titleField] : "";

            return(clientId);
        }
Beispiel #7
0
        internal static void ResolveBindingPathToCliendIDMappings(IWebUiControl webUiControl, Dictionary <string, string> resolvedMappings)
        {
            if (webUiControl is ContainerUiControlBase)
            {
                ContainerUiControlBase container = (ContainerUiControlBase)webUiControl;
                foreach (IUiControl child in container.UiControls)
                {
                    ResolveBindingPathToCliendIDMappings((IWebUiControl)child, resolvedMappings);
                }
            }

            if (webUiControl.SourceBindingPaths != null && webUiControl.ClientName != null && webUiControl.SourceBindingPaths.Count > 0)
            {
                foreach (string sourceBindingPath in webUiControl.SourceBindingPaths)
                {
                    resolvedMappings.Add(sourceBindingPath, webUiControl.ClientName);
                }
            }
        }
        public override void BindStateToControlProperties()
        {
            int childIndex = 0;

            foreach (IUiControl childControl in this.UiControls)
            {
                if (ControlIsActive(childIndex))
                {
                    childControl.BindStateToControlProperties();
                }
                else
                {
                    IWebUiControl childWebUIControl = (childControl as IWebUiControl);
                    Verify.IsNotNull(childWebUIControl, "Child control has to inherit '{0}' interface", typeof(IWebUiControl).FullName);

                    childWebUIControl.InitializeViewState();
                }

                childIndex++;
            }
        }
        private static void ShowFieldMessages(IWebUiControl webUiControlTreeRoot, Dictionary <string, string> bindingPathedMessages, IWebUiContainer container, FlowControllerServicesContainer servicesContainer)
        {
            var pathToClientIDMappings = new Dictionary <string, string>();

            ResolveBindingPathToClientIDMappings(webUiControlTreeRoot, pathToClientIDMappings);

            var cliendIDPathedMessages = new Dictionary <string, string>();
            var homelessMessages       = new Dictionary <string, string>();

            foreach (var msgElement in bindingPathedMessages)
            {
                string clientId = null;

                if (pathToClientIDMappings.TryGetValue(msgElement.Key, out clientId))
                {
                    cliendIDPathedMessages.Add(clientId, msgElement.Value);
                }
                else
                {
                    homelessMessages.Add(msgElement.Key, msgElement.Value);
                }
            }

            container.ShowFieldMessages(cliendIDPathedMessages);

            if (homelessMessages.Count > 0)
            {
                StringBuilder sb = new StringBuilder();

                foreach (var msgElement in homelessMessages)
                {
                    sb.AppendFormat("{0}: {1}\n", msgElement.Key, msgElement.Value);
                }

                var consoleMsgService = servicesContainer.GetService <IManagementConsoleMessageService>();
                consoleMsgService.ShowMessage(DialogType.Warning, "Field messages", sb.ToString());
            }
        }
        public override void InitializeLazyBindedControls()
        {
            int childIndex = 0;

            foreach (IUiControl childControl in this.UiControls)
            {
                if (ControlIsActive(childIndex))
                {
                    if (childControl is TemplatedContainerUiControl)
                    {
                        (childControl as TemplatedContainerUiControl).InitializeLazyBindedControls();
                    }
                }
                else
                {
                    IWebUiControl childWebUIControl = (childControl as IWebUiControl);
                    Verify.IsNotNull(childWebUIControl, "Child control has to inherit '{0}' interface", typeof(IWebUiControl).FullName);

                    childWebUIControl.InitializeViewState();
                }

                childIndex++;
            }
        }
        public Control BuildWebControl()
        {
            _userControl       = _userControlType.ActivateAsUserControl <ContainerTemplateUserControlBase>(this.UiControlID);
            _userControl.Label = this.Label;
            _userControl.Help  = this.Help;

            if (this is ITabbedContainerUiControl)
            {
                _userControl.PreSelectedIndex = ((ITabbedContainerUiControl)this).PreSelectedIndex;
            }
            else
            {
                _userControl.PreSelectedIndex = -1;
            }

            foreach (IUiControl tab in this.UiControls)
            {
                IWebUiControl WebUiChild = tab as IWebUiControl;
                Control       WebChild   = WebUiChild.BuildWebControl();
                _userControl.AddFormControlDefinition(tab.Label, WebChild, tab.Help, WebUiChild.IsFullWidthControl);
            }

            return(_userControl);
        }
        public static void InsertForm(Control control, ParameterList parameters)
        {
            Page currentPageHandler = HttpContext.Current.Handler as Page;


            if (currentPageHandler == null)
            {
                throw new InvalidOperationException("The Current HttpContext Handler must be a System.Web.Ui.Page");
            }

            Type dataType = null;
            DataTypeDescriptor dataTypeDescriptor = null;

            string dataTypeName = parameters.GetParameter <string>("DataType");

            dataType           = TypeManager.GetType(dataTypeName);
            dataTypeDescriptor = DynamicTypeManager.GetDataTypeDescriptor(dataType);

            IFormChannelIdentifier channelIdentifier = FormsRendererChannel.Identifier;

            formHelper = new DataTypeDescriptorFormsHelper(dataTypeDescriptor);

            newData = DataFacade.BuildNew(dataType);
            GeneratedTypesHelper.SetNewIdFieldValue(newData);

            //Hide not editable fields, fox example - PageId
            GeneratedTypesHelper generatedTypesHelper = new GeneratedTypesHelper(dataTypeDescriptor);

            formHelper.AddReadOnlyFields(generatedTypesHelper.NotEditableDataFieldDescriptorNames);


            //If is Page Datatype
            if (PageFolderFacade.GetAllFolderTypes().Contains(dataType))
            {
                IPage currentPage = PageRenderer.CurrentPage;

                if (currentPage.GetDefinedFolderTypes().Contains(dataType) == false)
                {
                    currentPage.AddFolderDefinition(dataType.GetImmutableTypeId());
                }
                PageFolderFacade.AssignFolderDataSpecificValues(newData, currentPage);
            }

            _compiler = new FormTreeCompiler();

            //bindings = formHelper.GetBindings(newData);
            bindings = new Dictionary <string, object>();
            formHelper.UpdateWithNewBindings(bindings);
            formHelper.ObjectToBindings(newData, bindings);


            using (XmlReader reader = XDocument.Parse(formHelper.GetForm()).CreateReader())
            {
                try
                {
                    _compiler.Compile(reader, channelIdentifier, bindings, formHelper.GetBindingsValidationRules(newData));

                    #region ClientValidationRules
                    clientValidationRules = new Dictionary <string, List <ClientValidationRule> >();
                    foreach (var item in _compiler.GetField <object>("_context").GetProperty <IEnumerable>("Rebindings"))
                    {
                        var SourceProducer = item.GetProperty <object>("SourceProducer");
                        var uiControl      = SourceProducer as IWebUiControl;
                        if (uiControl != null)
                        {
                            clientValidationRules[uiControl.UiControlID] = uiControl.ClientValidationRules;
                        }
                    }
                    #endregion
                }
                catch (ConfigurationErrorsException e)
                {
                    if (e.Message.Contains("Failed to load the configuration for IUiControlFactory"))
                    {
                        throw new ConfigurationErrorsException("Composite.Forms.Renderer does not support widget. " + e.Message);
                    }
                    else
                    {
                        throw new ConfigurationErrorsException(e.Message);
                    }
                }
            }
            webUiControl = (IWebUiControl)_compiler.UiControl;

            Control form = webUiControl.BuildWebControl();
            control.Controls.Add(form);

            /*if (currentPageHandler.IsPostBack)
             *  try
             *  {
             *      compiler.SaveControlProperties();
             *  }
             *  catch { }*/

            if (!currentPageHandler.IsPostBack)
            {
                webUiControl.InitializeViewState();
            }



            return;
        }
        internal static void ResolveBindingPathToCliendIDMappings(IWebUiControl webUiControl, Dictionary<string, string> resolvedMappings)
        {
            if (webUiControl is ContainerUiControlBase)
            {
                ContainerUiControlBase container = (ContainerUiControlBase)webUiControl;
                foreach (IUiControl child in container.UiControls)
                {
                    ResolveBindingPathToCliendIDMappings((IWebUiControl)child, resolvedMappings);
                }
            }

            if (webUiControl.SourceBindingPaths != null && webUiControl.ClientName != null && webUiControl.SourceBindingPaths.Count > 0)
            {
                foreach (string sourceBindingPath in webUiControl.SourceBindingPaths)
                {
                    resolvedMappings.Add(sourceBindingPath, webUiControl.ClientName);
                }
            }
        }
        private static void ShowFieldMessages(IWebUiControl webUiControlTreeRoot, Dictionary<string, string> bindingPathedMessages, IWebUiContainer container, FlowControllerServicesContainer servicesContainer)
        {
            Dictionary<string, string> pathToClientIDMappings = new Dictionary<string, string>();
            ResolveBindingPathToCliendIDMappings(webUiControlTreeRoot, pathToClientIDMappings);

            Dictionary<string, string> cliendIDPathedMessages = new Dictionary<string, string>();
            Dictionary<string, string> homelessMessages = new Dictionary<string, string>();

            foreach (var msgElement in bindingPathedMessages)
            {
                string clientId = null;

                if (pathToClientIDMappings.TryGetValue(msgElement.Key, out clientId))
                {
                    cliendIDPathedMessages.Add(clientId, msgElement.Value);
                }
                else
                {
                    homelessMessages.Add(msgElement.Key, msgElement.Value);
                }
            }

            container.ShowFieldMessages(cliendIDPathedMessages);

            if (homelessMessages.Count > 0)
            {
                StringBuilder sb = new StringBuilder();

                foreach (var msgElement in homelessMessages)
                {
                    sb.AppendFormat("{0}: {1}\n", msgElement.Key, msgElement.Value);
                }

                var consoleMsgService = servicesContainer.GetService<IManagementConsoleMessageService>();
                consoleMsgService.ShowMessage(DialogType.Warning, "Field messages", sb.ToString());
            }
        }
 internal void SetWebUiControlRef(IWebUiControl webUiControl)
 {
     _webUiControl = webUiControl;
 }
Beispiel #16
0
 internal void SetWebUiControlRef(IWebUiControl webUiControl)
 {
     _webUiControl = webUiControl;
 }