Example #1
0
        private void Dispose(bool disposing)
        {
            if (disposing)
            {
                configSet.WriteXml("Configuration.xml");
                configSet.Dispose();
                configSet = null;

                workingSet.WriteXml("Configuration.xml");
                workingSet.Dispose();
                workingSet = null;
            }
        }
Example #2
0
        private void CreateVariableGroups()
        {
            //Get concepts that are used, add the implicit ones and except for "0" create variable groups from them in the relevant variable scheme and put into the working set
            this.usedConcepts = variablesConcepts.Values.Distinct().ToList();

            //add implicit level-1 groups that are parents of level-2 groups
            var implicits = new List <string>();

            foreach (var uc in this.usedConcepts)
            {
                if (uc.Length == 1 + 2 + 2)
                {
                    if (!usedConcepts.Contains(uc.Substring(0, 3)))
                    {
                        implicits.Add(uc.Substring(0, 3));
                    }
                }
            }
            this.usedConcepts.AddRange(implicits.Distinct());

            //get the concept scheme from the repository
            //I assume there is only one
            //if there is none, get concepts from the working set
            ConceptScheme vgConceptScheme = new ConceptScheme();
            var           client          = Utility.GetClient();
            var           facet           = new SearchFacet();

            facet.ItemTypes.Add(DdiItemType.ConceptScheme);
            SearchResponse response = client.Search(facet);
            bool           fromRepo = false;

            if (response.ReturnedResults > 0)
            {
                fromRepo        = true;
                vgConceptScheme = client.GetItem(response.Results[0].CompositeId, ChildReferenceProcessing.Populate) as ConceptScheme;
            }

            var variableScheme = WorkingSet.OfType <VariableScheme>().Where(x => string.Compare(x.ItemName.Best, this.vsName, ignoreCase: true) == 0).First();

            foreach (var uc in this.usedConcepts)
            {
                if (uc != "0")
                {
                    VariableGroup vg = new VariableGroup();
                    vg.TypeOfGroup = "ConceptGroup";
                    Concept vgConcept = new Concept();
                    if (fromRepo)
                    {
                        vgConcept = vgConceptScheme.Concepts.Where(x => string.Compare(x.ItemName.Best, uc, ignoreCase: true) == 0).First();
                    }
                    else     //from working set
                    {
                        vgConcept = WorkingSet.OfType <Concept>().Where(x => string.Compare(x.ItemName.Best, uc, ignoreCase: true) == 0).First();
                    }

                    vg.Concept = vgConcept;
                    vg.ItemName.Add("en-GB", "Variable Group - " + vgConcept.Label.Best);
                    //Trace.WriteLine("   " + vg.ItemName.Best);
                    variableScheme.VariableGroups.Add(vg);
                }
            }
            WorkingSet.AddRange(variableScheme.VariableGroups);
            Trace.WriteLine("  concept groups: " + variableScheme.VariableGroups.Count().ToString() + " for " + this.vsName);
        }