Exemplo n.º 1
0
        public void UpdateChildren(NodeUpdatingSource mode, CancellationTokenSource cancellationSource)
        {
            if (IsDisabled)
            {
                mode = NodeUpdatingSource.LocallyOnly;
            }

            Debug.Assert(this.IsInstance);

            IStorageManager vault   = this._model.GetVaultProcessor(Connection.ConnectionGroup);
            bool            updated = false;

            if (mode == NodeUpdatingSource.FromServerIfNotSavedLocally || mode == NodeUpdatingSource.LocallyOnly)
            {
                updated = vault.CurrentStorage.NodeInstances.TryLoadChildren(this);
            }

            if (updated || mode == NodeUpdatingSource.LocallyOnly)
            {
                return;
            }

            Childs.Clear();
            Childs.AddRange(InstantiateStaticNodes(this.Template.Childs, Connection, this));

            vault.CurrentStorage.NodeInstances.SaveChildren(this);

            if (MayHaveDynamicChildren && Connection.IsLiveConnection)
            {
                UpdateDynamicChildren(cancellationSource.Token);
            }
        }
Exemplo n.º 2
0
        public override string GetHTML(int deep = 0)
        {
            AddCSS("form-group " + ClassInputGroup, true);

            if (!(LabelInput is null))
            {
                Childs.Add(LabelInput);
            }

            Childs.Add(Input);

            if (Input.required)
            {
                Childs.AddRange(GetValidationAlerts(Input.Name));
            }

            if (!string.IsNullOrEmpty(InputInfoFooter))
            {
                string input_info_id = Input.Name + "Help";
                using (small info_text = new small(InputInfoFooter)
                {
                    inline = true, Id_DOM = input_info_id
                })
                {
                    info_text.AddCSS("form-text text-muted", true);
                    Childs.Add(info_text);
                }
                Input.SetAttribute("aria-describedby", input_info_id);
            }
            return(base.GetHTML(deep));
        }
Exemplo n.º 3
0
        public override string GetHTML(int deep = 0)
        {
            if (autofocus)
            {
                SetAttribute("autofocus", null);
            }

            if (disabled)
            {
                SetAttribute("disabled", null);
            }

            if (multiple)
            {
                SetAttribute("multiple", null);
            }

            if (required)
            {
                SetAttribute("required", null);
            }

            if (size > 0)
            {
                SetAttribute("size", size);
            }

            Childs.Clear();
            Childs.AddRange(Options);

            return(base.GetHTML(deep));
        }
Exemplo n.º 4
0
        public override string GetHTML(int deep = 0)
        {
            ClearNestedDom();

            if (!string.IsNullOrEmpty(PageTitle))
            {
                AddDomNode(new title(PageTitle));
            }

            Childs.AddRange(defTags);
            Childs.AddRange(dynTags);
            dynTags.Clear();

            if (!(Base is null))
            {
                Childs.Add(Base);
            }

            return(base.GetHTML(deep));
        }
Exemplo n.º 5
0
        public override string GetHTML(int deep = 0)
        {
            Childs.Clear();

            Childs.Add(Input);
            if (!(LabelInput is null))
            {
                Childs.Add(LabelInput);
            }

            if (Input.required)
            {
                Childs.AddRange(GetValidationAlerts(Input.Id_DOM, valid_feedback_text, invalid_feedback_text));
            }

            ////////////////////////////////////////////////
            // Фиксим проблему кроссбраузерности отправок формой чекбокса.
            // Разные браузеры могут по разному отправлять чекбокс. Для стандартизации этой процедуры с чекбоксом в паре держим его "тень" в виде скрытого input-а и контролируем значение теневого значения синхронизируя с основным
            Childs.Add(new input()
            {
                type = InputTypesEnum.hidden, value = Input.@checked ? "on" : "off", Name = Id_DOM
            });
            //
            script my_script = new script();

            my_script.AddDomNode(new text("jQuery(document).ready(function () {"));
            my_script.AddDomNode(new text("  jQuery('#" + Input.Id_DOM + "').change(function () {"));
            my_script.AddDomNode(new text("    if (jQuery(this).prop('checked')) {"));
            my_script.AddDomNode(new text("      jQuery('input[name=" + Input.Id_DOM + "').val('on');"));
            my_script.AddDomNode(new text("    }"));
            my_script.AddDomNode(new text("    else {"));
            my_script.AddDomNode(new text("      jQuery('input[name=" + Input.Id_DOM + "').val('off');"));
            my_script.AddDomNode(new text("    }"));
            my_script.AddDomNode(new text("  });"));
            my_script.AddDomNode(new text("});"));
            Childs.Add(my_script);
            ///////////////////////////////////////////////
            ///
            return(base.GetHTML(deep));
        }
Exemplo n.º 6
0
        public override string GetHTML(int deep = 0)
        {
            Childs.Clear();
            div input_group_prepend = new div();

            input_group_prepend.AddCSS("input-group-prepend");
            using (div input_group_text = new div()
            {
                InnerText = LabelText
            })
            {
                input_group_text.AddCSS("input-group-text");
                input_group_prepend.Childs.Add(input_group_text);
            }
            Childs.Add(input_group_prepend);
            Childs.Add(Input);

            if (Input.required)
            {
                Childs.AddRange(GetValidationAlerts(Input.Name));
            }

            return(base.GetHTML(deep));
        }
Exemplo n.º 7
0
 public override string GetHTML(int deep = 0)
 {
     Childs.AddRange(Columns);
     return(base.GetHTML(deep));
 }
        internal void Parse()
        {
            if (ParentCount > 30)
            {
                return;
            }
            config.SkipEmpty();
            if (config.Peek() == '(')
            {
                config.Next();
                Name = config.NextString();
                config.Next();
                Value = config.NextString();
                config.Next();
                return;
            }

            Name = config.NextString();
            config.SkipEmpty();
            if (config.Peek() == '=')
            {
                config.Next();
                config.SkipEmpty();
                Value = config.NextString();
            }
            else if (config.Peek() == ',')
            {
                config.Next();
                Childs.Add(new ADLElement {
                    Name = this.Name, Parent = this
                });
                Name = null;

                while (config.HasChar)
                {
                    config.SkipEmpty();
                    Childs.Add(new ADLElement {
                        Value = config.NextString(), Parent = this
                    });
                    config.SkipEmpty();
                    if (config.Peek() == ',')
                    {
                        config.Next();
                        config.SkipEmpty();
                    }
                    if (config.Peek() == '}')
                    {
                        break;
                    }
                }
                //config.Next();
            }
            else if (config.Peek() == '{')
            {
                config.Next();
                while (config.HasChar)
                {
                    config.SkipEmpty();
                    Childs.Add(new ADLElement(config, this));
                    config.SkipEmpty();
                    if (config.Peek() == '}')
                    {
                        break;
                    }
                }
                config.Next();
                if (Childs.Count() == 1 && Childs[0].Name == null)
                {
                    var c = Childs[0];
                    Childs.Clear();
                    Childs.AddRange(c.Childs);
                }
            }
        }
Exemplo n.º 9
0
        private void UpdateDynamicChildren(CancellationToken cancellationToken)
        {
            ChildrenAreLoadingNow = true;

            try
            {
                List <TemplateNodeInfo> newNodes = new List <TemplateNodeInfo>();

                using (SqlProcessor sqlProcessor = this._model.GetNewSqlProcessor(cancellationToken))
                {
                    foreach (TemplateNodeQueryInfo query in GroupQueries)
                    {
                        List <TemplateNodeInfo> templateNodesToBeReplicated = GetSubnodesFor(query).ToList();
                        List <QueryInfo>        queryInfos = this._model.GetQueryByTemplateNodeQueryInfo(query);

                        foreach (InstanceInfo serverInstance in Connection.ConnectionGroup.Connections.Where(c => c.IsEnabled))
                        {
                            cancellationToken.ThrowIfCancellationRequested();

                            QueryInfo queryInfo = queryInfos.FirstOrDefault(x =>
                                                                            x.Source == serverInstance.Type || x.Source == QuerySource.SQLite
                                                                            );

                            DataTable[] tables = GetGroupSelectResultsFromServer(sqlProcessor, serverInstance, queryInfo, query);

                            cancellationToken.ThrowIfCancellationRequested();

                            foreach (DataTable t in tables)
                            {
                                for (int rowIndex = 0; rowIndex < t.Rows.Count; rowIndex++)
                                {
                                    List <TemplateNodeInfo> replicants =
                                        templateNodesToBeReplicated.Select(
                                            tn => tn.Instantiate(
                                                Connection,
                                                t.Rows[rowIndex],
                                                query,
                                                this
                                                )
                                            ).ToList();
                                    newNodes.AddRange(replicants);
                                }
                            }
                        }
                    }
                }

                cancellationToken.ThrowIfCancellationRequested();

                if (newNodes.Count == 0)
                {
                    return;
                }

                lock (Childs)
                {
                    Childs.AddRange(newNodes);

                    this._model.GetVaultProcessor(Connection.ConnectionGroup).CurrentStorage.NodeInstances.SaveChildren(this);
                }
            }
            catch (Exception ex)
            {
                log.Error("private Task CreateAddDynamicChildrenTask(Action done)", ex);
            }
            finally
            {
                ChildrenAreLoadingNow = false;
            }
        }
Exemplo n.º 10
0
 public void AddChildRange(IEnumerable <IDOMElement> childs)
 {
     Childs.AddRange(childs);
 }