Пример #1
0
        private void Parse()
        {
            // Create a new workflow selector for the variable.
            this.Selector = new WorkflowSelector(this);

            // Run through all studies of the client.
            foreach (Study study in this.Owner.Owner.Core.Studies.Get())
            {
                // Create a new workflow selector item for the category.
                WorkflowSelectorItem selectorItem = new WorkflowSelectorItem(this.Selector);
                selectorItem.Id   = study.Id;
                selectorItem.Text = study.Name;

                // Add the workflow selector item to the workflow selector's items.
                this.Selector.Items.Add(selectorItem);
            }

            // Run through all selected category xml nodes.
            foreach (XmlNode xmlNodeSelected in this.XmlNode.ChildNodes)
            {
                Guid idStudy = Guid.Parse(
                    xmlNodeSelected.Attributes["Id"].Value
                    );

                this.Selector.SelectedItems.Add(idStudy);
            }
        }
        private void RenderHierarchyItem(object[] hierarchy, int level)
        {
            WorkflowSelectorItem item = new WorkflowSelectorItem(this.Selector);

            item.Id   = (Guid)hierarchy[0];
            item.Text = (string)hierarchy[1];
            item.Style.Add("margin-left", (level * 10) + "px");

            this.Selector.Items.Add(item);

            // Get all hierarchies of the workgroups where the user
            // is assigned to where the hierarchy is the parent.
            List <object[]> childHierarchies = base.Core.Hierarchies.ExecuteReader(string.Format(
                                                                                       "SELECT Id, Name FROM [Hierarchies] WHERE IdHierarchy='{1}' AND Id IN (SELECT IdHierarchy FROM WorkgroupHierarchies " +
                                                                                       "WHERE IdWorkgroup IN (SELECT IdWorkgroup FROM UserWorkgroups WHERE IdUser='******'))",
                                                                                       (Guid)HttpContext.Current.Session["User"],
                                                                                       hierarchy[0]
                                                                                       ));

            // Run through all child hierarchy items of the hierarchy.
            foreach (object[] childHierarchy in childHierarchies)
            {
                RenderHierarchyItem(childHierarchy, level + 1);
            }
        }
        private void Parse()
        {
            // Create a new workflow selector for the variable.
            this.Selector = new WorkflowSelector(this);

            List <object[]> categories;

            if (!this.IsTaxonomy)
            {
                categories = this.Owner.Owner.Core.Categories.GetValues(
                    new string[] { "Id" },
                    new string[] { "IdVariable" },
                    new object[] { this.IdVariable },
                    "Value"
                    );
            }
            else
            {
                categories = this.Owner.Owner.Core.TaxonomyCategories.GetValues(
                    new string[] { "Id" },
                    new string[] { "IdTaxonomyVariable" },
                    new object[] { this.IdVariable },
                    "Value"
                    );
            }

            // Run through all categories of the variable.
            foreach (object[] category in categories)
            {
                string categoryLabel;

                if (!this.IsTaxonomy)
                {
                    categoryLabel = (string)this.Owner.Owner.Core.CategoryLabels.GetValue(
                        "Label",
                        "IdCategory",
                        category[0]
                        );
                }
                else
                {
                    if (!this.Owner.Owner.HierarchyFilter.TaxonomyCategories.ContainsKey((Guid)category[0]))
                    {
                        continue;
                    }

                    categoryLabel = (string)this.Owner.Owner.Core.TaxonomyCategoryLabels.GetValue(
                        "Label",
                        "IdTaxonomyCategory",
                        category[0]
                        );
                }

                // Create a new workflow selector item for the category.
                WorkflowSelectorItem selectorItem = new WorkflowSelectorItem(this.Selector);
                selectorItem.Id   = (Guid)category[0];
                selectorItem.Text = categoryLabel;

                // Add the workflow selector item to the workflow selector's items.
                this.Selector.Items.Add(selectorItem);
            }

            // Run through all selected category xml nodes.
            foreach (XmlNode xmlNodeSelected in this.XmlNode.ChildNodes)
            {
                Guid idCategory = Guid.Parse(
                    xmlNodeSelected.Attributes["Id"].Value
                    );

                if (this.IsTaxonomy && this.Owner.Owner.HierarchyFilter.TaxonomyCategories.ContainsKey(idCategory) == false)
                {
                    continue;
                }

                this.Selector.SelectedItems.Add(idCategory);
            }
        }