public DataSetModel GetItems(DataSetModel model, string agency, Guid id)
        {
            MultilingualString.CurrentCulture = "en-US";

            var  client  = ClientHelper.GetClient();
            long version = client.GetLatestVersionNumber(id, agency);

            IdentifierTriple variable1           = new IdentifierTriple(id, version, agency);
            Collection <IdentifierTriple> items  = client.GetLatestSet(variable1);
            Collection <DataSetItem>      ditems = new Collection <DataSetItem>();

            foreach (var item in items)
            {
                long        version1 = client.GetLatestVersionNumber(item.Identifier, item.AgencyId);
                DataSetItem ditem    = new DataSetItem();
                ditem.Agency     = item.AgencyId;
                ditem.Identifier = item.Identifier;
                ditem.Version    = item.Version;
                Item newItem = new Item();
                newItem        = GetDetail(agency, item.Identifier);
                ditem.ItemType = newItem.Id;
                List <RepositoryItemMetadata> test = GetConcept(item.AgencyId, item.Identifier).OrderByDescending(a => a.IsDeprecated).ToList();
                // if (test.Count > 1) { test = GetConcept(item.AgencyId, item.Identifier).Where(a => a.IsDeprecated == true).ToList(); }
                ditem.IsDeprecated = test.FirstOrDefault().IsDeprecated;
                ditem.Referencing  = test.FirstOrDefault().ItemType.ToString();
                // ditem.Version = test.Count;
                ditem.Version = test.FirstOrDefault().Version;

                // if (newItem.QuestionValue != null) { model.DisplayLabel =GetRepository(new Guid(newItem.QuestionValue)).Where(a => a.Identifier == id).FirstOrDefault().DisplayLabel; }
                ditems.Add(ditem);
            }
            model.DataSet = ditems;
            return(model);
        }
예제 #2
0
        void GetReferencingItems(RepositoryClientBase client, IdentifierTriple variableId, out PhysicalInstance physicalInstance, out DataRelationship dataRelationship, out VariableStatistic variableStatistic)
        {
            dataRelationship  = null;
            variableStatistic = null;

            physicalInstance = VariableMapper.GetPhysicalInstanceWithVariable(variableId, client);

            foreach (var dr in physicalInstance.DataRelationships)
            {
                client.PopulateItem(dr, false, ChildReferenceProcessing.Populate);

                if (dr.LogicalRecords
                    .SelectMany(x => x.VariablesInRecord)
                    .Any(x => x.CompositeId == variableId))
                {
                    dataRelationship = dr;
                }
            }


            foreach (var stats in physicalInstance.Statistics)
            {
                client.PopulateItem(stats);

                if (stats.AgencyId == variableId.AgencyId &
                    stats.VariableReference.Identifier == variableId.Identifier)
                {
                    variableStatistic = stats;
                    break;
                }
            }
        }
        public Collection <IdentifierTriple> GetSet(IdentifierTriple identifier)
        {
            Collection <IdentifierTriple> identifiers = new Collection <IdentifierTriple>();

            var client = ClientHelper.GetClient();

            identifiers = client.GetSet(identifier);
            return(identifiers);
        }
        /// <summary>
        /// Reads a text file with one mapping per line:
        ///   [VariableName]|[QuestionName]
        ///
        /// </summary>
        /// <remarks>
        /// See below for a method that automatically maps variables and questions based on matching names,
        /// without the need for an extra file to specify the mapping.
        /// </remarks>
        /// <param name="filePath"></param>
        /// <param name="variableSchemeId"></param>
        /// <param name="questionSchemeId"></param>
        /// <param name="onlyTest"></param>
        static void MapVariablesToQuestions(string filePath, IdentifierTriple variableSchemeId, IdentifierTriple questionSchemeId, bool onlyTest)
        {
            var client = RepositoryIntro.GetClient();

            VariableScheme vs = client.GetItem(variableSchemeId, ChildReferenceProcessing.Populate) as VariableScheme;
            QuestionScheme qs = client.GetItem(questionSchemeId, ChildReferenceProcessing.Populate) as QuestionScheme;

            // Read each line of the mapping file.
            int matches = 0;

            foreach (string line in File.ReadLines(filePath))
            {
                // Grab the variable name and question name.
                string[] parts = line.Split(new char[] { '|' });
                if (parts.Length != 2)
                {
                    Console.WriteLine("Invalid line: " + line);
                    continue;
                }

                string variableName = parts[0];
                string questionName = parts[1];

                // Grab the corresponding variable and question objects.
                Variable variable = vs.Variables.SingleOrDefault(v => v.ItemName.Current == variableName);
                Question question = qs.Questions.SingleOrDefault(q => q.ItemName.Current == questionName);
                if (variable != null && question != null)
                {
                    // Add the question as SourceQuestion of the variable.
                    variable.SourceQuestions.Add(question);
                    variable.Version++;

                    Console.WriteLine(string.Format("Assigning {0} to {1}", question.ItemName.Current, variable.ItemName.Current));

                    if (!onlyTest)
                    {
                        client.RegisterItem(variable, new CommitOptions());
                    }

                    matches++;
                }
                else
                {
                    Console.WriteLine(string.Format("No match for {0} or {1}", variableName, questionName));
                }
            }

            vs.Version++;
            if (!onlyTest)
            {
                client.RegisterItem(vs, new CommitOptions());
            }

            Console.WriteLine("Done. Found " + matches.ToString() + " matches.");
        }
예제 #5
0
        public static IdentifierTriple GetSet(IdentifierTriple identifier, Guid variableidentifier, RepositoryClientBase client)
        {
            Collection <IdentifierTriple> identifiers = new Collection <IdentifierTriple>();

            // Collection<IdentifierTriple> selected = new Collection<IdentifierTriple>();
            // var clientitem = ClientHelper.GetClient();
            identifiers = client.GetSet(identifier);
            IdentifierTriple selected = identifiers.Where(a => a.Identifier == variableidentifier).FirstOrDefault();

            return(selected);
        }
예제 #6
0
        public static PhysicalInstance GetPhysicalInstanceWithVariable(IdentifierTriple variableId, RepositoryClientBase client)
        {
            var piID = GetContainingPhysicalInstance(variableId, client);

            if (piID != null)
            {
                return(client.GetItem(piID) as PhysicalInstance);
            }

            return(null);
        }
        /// <summary>
        /// Reads a text file with one mapping per line:
        ///   [VariableName]|[QuestionName]
        /// 
        /// </summary>
        /// <remarks>
        /// See below for a method that automatically maps variables and questions based on matching names, 
        /// without the need for an extra file to specify the mapping.
        /// </remarks>
        /// <param name="filePath"></param>
        /// <param name="variableSchemeId"></param>
        /// <param name="questionSchemeId"></param>
        /// <param name="onlyTest"></param>
        static void MapVariablesToQuestions(string filePath, IdentifierTriple variableSchemeId, IdentifierTriple questionSchemeId, bool onlyTest)
        {
            var client = RepositoryIntro.GetClient();

            VariableScheme vs = client.GetItem(variableSchemeId, ChildReferenceProcessing.Populate) as VariableScheme;
            QuestionScheme qs = client.GetItem(questionSchemeId, ChildReferenceProcessing.Populate) as QuestionScheme;

            // Read each line of the mapping file.
            int matches = 0;
            foreach (string line in File.ReadLines(filePath))
            {
                // Grab the variable name and question name.
                string[] parts = line.Split(new char[] { '|' });
                if (parts.Length != 2)
                {
                    Console.WriteLine("Invalid line: " + line);
                    continue;
                }

                string variableName = parts[0];
                string questionName = parts[1];

                // Grab the corresponding variable and question objects.
                Variable variable = vs.Variables.SingleOrDefault(v => v.ItemName.Current == variableName);
                Question question = qs.Questions.SingleOrDefault(q => q.ItemName.Current == questionName);
                if (variable != null && question != null)
                {
                    // Add the question as SourceQuestion of the variable.
                    variable.SourceQuestions.Add(question);
                    variable.Version++;

                    Console.WriteLine(string.Format("Assigning {0} to {1}", question.ItemName.Current, variable.ItemName.Current));

                    if (!onlyTest)
                    {
                        client.RegisterItem(variable, new CommitOptions());
                    }

                    matches++;
                }
                else
                {
                    Console.WriteLine(string.Format("No match for {0} or {1}", variableName, questionName));
                }
            }

            vs.Version++;
            if (!onlyTest)
            {
                client.RegisterItem(vs, new CommitOptions());
            }

            Console.WriteLine("Done. Found " + matches.ToString() + " matches.");
        }
        /// <summary>
        /// Maps Variables to Questions where the name of the Variable matches the name of
        /// the Question.
        /// </summary>
        /// <param name="variableSchemeId"></param>
        /// <param name="questionSchemeId"></param>
        /// <param name="onlyTest"></param>
        static void MapVariablesToQuestionsAuto(IdentifierTriple variableSchemeId, IdentifierTriple questionSchemeId, bool onlyTest)
        {
            var client = RepositoryIntro.GetClient();

            CommitOptions commitOptions = new CommitOptions();

            VariableScheme vs = client.GetItem(variableSchemeId, ChildReferenceProcessing.Populate) as VariableScheme;
            QuestionScheme qs = client.GetItem(questionSchemeId, ChildReferenceProcessing.Populate) as QuestionScheme;

            // Grab all variable names and question names.
            var variableNameList = vs.Variables.Select(v => v.ItemName.Current.Substring(2)).ToList();
            var questionNameList = qs.Questions.Select(q => q.ItemName.Current).ToList();

            int matches = 0;

            foreach (string varName in variableNameList)
            {
                string foundQuestionName = questionNameList.Where(q => string.Compare(q, varName, true) == 0).FirstOrDefault();
                if (foundQuestionName != null)
                {
                    // If there is a question with the same name as this variable,
                    // grab the Question and Variable objects, and assign the question
                    // as a SourceQuestion.
                    Variable variable = vs.Variables.SingleOrDefault(v => v.ItemName.Current == varName);
                    Question question = qs.Questions.SingleOrDefault(q => q.ItemName.Current == foundQuestionName);

                    if (variable != null && question != null)
                    {
                        variable.SourceQuestions.Add(question);
                        variable.Version++;
                        Console.WriteLine(string.Format("Assigning {0} to {1}", question.ItemName.Current, variable.ItemName.Current));

                        if (!onlyTest)
                        {
                            client.RegisterItem(variable, commitOptions);
                        }

                        matches++;
                    }
                    else
                    {
                        Console.WriteLine(string.Format("No match for {0} or {1}", varName, foundQuestionName));
                    }
                }
            }

            vs.Version++;
            if (!onlyTest)
            {
                client.RegisterItem(vs, commitOptions);
            }

            Console.WriteLine("Done. Found " + matches.ToString() + " matches.");
        }
        public Collection <IdentifierTriple> GetCurrentItems(DataSetModel model, string agency, Guid id)
        {
            MultilingualString.CurrentCulture = "en-US";

            var  client  = ClientHelper.GetClient();
            long version = client.GetLatestVersionNumber(id, agency);

            IdentifierTriple variable1          = new IdentifierTriple(id, version, agency);
            Collection <IdentifierTriple> items = client.GetLatestSet(variable1);

            return(items);
        }
        private List <TreeViewNode> BuildChildrenTree(IdentifierTriple identifier, List <TreeViewNode> nodes)
        {
            List <RepositoryItemMetadata> children = new List <RepositoryItemMetadata>();

            children = GetConcept(identifier.AgencyId, identifier.Identifier);
            int i = 1;

            foreach (var child in children)
            {
                var newItem = GetDetail(child.AgencyId, child.Identifier);
                nodes.Add(new TreeViewNode {
                    id = identifier.Identifier.ToString() + " " + child.Identifier.ToString(), parent = identifier.Identifier.ToString(), text = newItem.Id + " - " + child.Identifier.ToString() + " - " + child.IsDeprecated
                });
                i++;
            }
            return(nodes);
        }
 public ActionResult Tree(DataSetModel model, string command, HttpPostedFileBase postedFile)
 {
     switch (command)
     {
     case "Search":
         var identifier = model.Urn.Substring(model.Urn.IndexOf("/") + 1, model.Urn.Length - model.Urn.IndexOf("/") - 1);
         var agency     = model.Urn.Substring(0, model.Urn.IndexOf("/"));
         model      = ProcessDataSet(model, agency, new Guid(identifier));
         model.Urns = new List <string>();
         var identifiertriple      = new IdentifierTriple(new Guid(identifier), 1, agency);
         List <TreeViewNode> nodes = new List <TreeViewNode>();
         nodes        = BuildTree(identifiertriple, nodes);
         ViewBag.Json = (new JavaScriptSerializer()).Serialize(nodes);
         return(View(model));
     }
     return(View(model));
 }
        private List <TreeViewNode> BuildTree(IdentifierTriple identifier, List <TreeViewNode> nodes)
        {
            List <RepositoryItemMetadata> children    = new List <RepositoryItemMetadata>();
            Collection <IdentifierTriple> identifiers = GetSet(identifier);
            var client = ClientHelper.GetClient();
            int i      = 1;

            identifiers = GetSet(identifier);
            foreach (var result in identifiers)
            {
                IdentifierTriple it = new IdentifierTriple(result.Identifier, 1, result.AgencyId);
                IVersionable     item = client.GetLatestItem(result.Identifier, result.AgencyId);
                var    item2 = client.GetLatestRepositoryItem(result.Identifier, result.AgencyId);
                var    test = client.GetRepositoryItemDescription(result.Identifier, result.AgencyId, 1);
                var    newItem = GetDetail(result.AgencyId, result.Identifier);
                string itemname, label;
                if (test.ItemName.Count != 0)
                {
                    itemname = test.ItemName.FirstOrDefault().Value.ToString();
                }
                else
                {
                    itemname = "No Question Name";
                }
                if (test.Label.Count != 0)
                {
                    label = test.Label.FirstOrDefault().Value.ToString();
                }
                else
                {
                    label = "No Question Text";
                }

                if (newItem.Id == "Variable")
                {
                    nodes.Add(new TreeViewNode {
                        id = result.Identifier.ToString(), parent = "#", text = newItem.Id + " - " + result.AgencyId + " - " + result.Identifier.ToString() + " - " + "Name: " + itemname + " - " + "Question: " + label + " -  Deprecated = " + item2.IsDeprecated
                    });
                    // nodes = BuildChildrenTree(result, nodes);
                    i++;
                }
            }
            nodes = nodes.OrderBy(a => a.text).ToList();
            return(nodes);
        }
예제 #13
0
        public static IdentifierTriple GetContainingPhysicalInstance(IdentifierTriple id, RepositoryClientBase client)
        {
            var facet = new SetSearchFacet();

            facet.ItemTypes.Add(DdiItemType.PhysicalInstance);
            facet.ReverseTraversal = true;
            facet.LeafItemTypes.Add(DdiItemType.VariableScheme);
            facet.LeafItemTypes.Add(DdiItemType.VariableGroup);

            var response = client.SearchTypedSet(id, facet);

            var piID = response.OrderByDescending(x => x.Version).FirstOrDefault();

            if (piID == null)
            {
                return(null);
            }

            return(piID.CompositeId);
        }
        public void DeprecateItems(DataSetModel model)
        {
            Collection <IdentifierTriple> identifiers = new Collection <IdentifierTriple>();

            foreach (var item in model.DataSet)
            {
                IdentifierTriple identifier = new IdentifierTriple(item.Identifier, item.Version, item.Agency);
                identifiers.Add(identifier);
            }
            var client = ClientHelper.GetClient();

            client.UpdateDeprecatedState(identifiers, true, false);
            CreatePowerShellScript(model);

            // this procedure is for when it is possible to remove items using C#
            //foreach (var item in model.DataSet)
            //{
            //    RemoveItemAsync(item.Identifier, item.Agency, item.Version);
            //}
        }
        public Item GetDetail(string agency, Guid id)
        {
            MultilingualString.CurrentCulture = "en-US";

            var  client  = ClientHelper.GetClient();
            long version = client.GetLatestVersionNumber(id, agency);

            Item             newitem   = new Item();
            IdentifierTriple variable1 = new IdentifierTriple(id, version, agency);
            IVersionable     item      = client.GetLatestItem(id, agency);
            string           itemtype  = null;

            if (item is PhysicalInstance)
            {
                newitem.QuestionValue = item.ItemType.ToString();
            }
            itemtype   = DataItem(item);
            newitem.Id = itemtype;
            return(newitem);
        }
예제 #16
0
        public void RelationshipSearch()
        {
            var physicalInstanceIdentifier = new IdentifierTriple(new Guid(), 1, "int.example");

            // Search for all VariableStatistics related to the PhysicalInstance.
            var facet = new GraphSearchFacet();
            facet.TargetItem = physicalInstanceIdentifier;
            facet.UseDistinctTargetItem = true;
            facet.UseDistinctResultItem = true;
            facet.ItemTypes.Add(DdiItemType.VariableStatistic);

            // Perform the search.
            var results = client.GetRepositoryItemDescriptionsBySubject(facet);

            // Write a line for each result.
            foreach (var result in results)
            {
                Console.WriteLine(result.Label["en-US"]);
            }
        }
예제 #17
0
        public void RelationshipSearch()
        {
            var physicalInstanceIdentifier = new IdentifierTriple(new Guid(), 1, "int.example");

            // Search for all VariableStatistics related to the PhysicalInstance.
            var facet = new GraphSearchFacet();

            facet.TargetItem            = physicalInstanceIdentifier;
            facet.UseDistinctTargetItem = true;
            facet.UseDistinctResultItem = true;
            facet.ItemTypes.Add(DdiItemType.VariableStatistic);

            // Perform the search.
            var results = client.GetRepositoryItemDescriptionsBySubject(facet);

            // Write a line for each result.
            foreach (var result in results)
            {
                Console.WriteLine(result.Label["en-US"]);
            }
        }
예제 #18
0
        public void SetSearch()
        {
            var dataRelationshipIdentifier = new IdentifierTriple(new Guid(), 1, "int.example");

            // Search for all Categories in the DataRelationship's set.
            var facet = new SetSearchFacet();
            facet.ItemTypes.Add(DdiItemType.Category);

            var resultIdentifiers = client.SearchTypedSet(
                dataRelationshipIdentifier,
                facet);

            // The set search only returns the identifiers of items.
            // Request the description of each result here.
            var results = client.GetRepositoryItemDescriptions(
                resultIdentifiers.ToIdentifierCollection());

            // Write a line for each result.
            foreach (var result in results)
            {
                Console.WriteLine(result.Label["en-US"]);
            }
        }
예제 #19
0
        public void SetSearch()
        {
            var dataRelationshipIdentifier = new IdentifierTriple(new Guid(), 1, "int.example");

            // Search for all Categories in the DataRelationship's set.
            var facet = new SetSearchFacet();

            facet.ItemTypes.Add(DdiItemType.Category);

            var resultIdentifiers = client.SearchTypedSet(
                dataRelationshipIdentifier,
                facet);

            // The set search only returns the identifiers of items.
            // Request the description of each result here.
            var results = client.GetRepositoryItemDescriptions(
                resultIdentifiers.ToIdentifierCollection());

            // Write a line for each result.
            foreach (var result in results)
            {
                Console.WriteLine(result.Label["en-US"]);
            }
        }
예제 #20
0
        public static Item GetDetail(string agency, Guid id, WcfRepositoryClient client)
        {
            MultilingualString.CurrentCulture = "en-GB";

            long             version   = client.GetLatestVersionNumber(id, agency);
            Item             newitem   = new Item();
            IdentifierTriple variable1 = new IdentifierTriple(id, version, agency);

            try
            {
                IVersionable item = client.GetLatestItem(id, agency);

                string itemtype = null;
                if (item is PhysicalInstance)
                {
                    newitem.QuestionValue = item.ItemType.ToString();
                }
                itemtype   = DataItem(item);
                newitem.Id = itemtype;
            }
            catch
            {
                IVersionable item = client.GetItem(id, agency, version - 1);

                string itemtype = null;
                if (item is PhysicalInstance)
                {
                    newitem.QuestionValue = item.ItemType.ToString();
                }
                itemtype   = DataItem(item);
                newitem.Id = itemtype;

                // newitem.Id = "Error";
            }
            return(newitem);
        }
        public ActionResult Index(DataSetModel model, string command, HttpPostedFileBase postedFile)
        {
            if (postedFile != null)
            {
                try
                {
                    string fileExtension = Path.GetExtension(postedFile.FileName);
                    if (fileExtension != ".csv")
                    {
                        return(View(model));
                    }
                    model.Urns = new List <string>();
                    using (var sreader = new StreamReader(postedFile.InputStream))
                    {
                        while (!sreader.EndOfStream)
                        {
                            // string[] rows = sreader.ReadLine().Split(',');
                            string row = sreader.ReadLine();
                            model.Urns.Add(row.ToString());

                            // model.Urns.Add(rows[0].ToString());
                        }
                    }
                    return(View(model));
                }
                catch (Exception ex)
                {
                    ViewBag.Message = ex.Message;
                }
            }
            switch (command)
            {
            case "Search":
                var identifier = model.Urn.Substring(model.Urn.IndexOf("/") + 1, model.Urn.Length - model.Urn.IndexOf("/") - 1);
                var agency     = model.Urn.Substring(0, model.Urn.IndexOf("/"));
                model      = ProcessDataSet(model, agency, new Guid(identifier));
                model.Urns = new List <string>();
                var identifiertriple      = new IdentifierTriple(new Guid(identifier), 1, agency);
                List <TreeViewNode> nodes = new List <TreeViewNode>();
                nodes        = BuildTree(identifiertriple, nodes);
                ViewBag.Json = (new JavaScriptSerializer()).Serialize(nodes);
                return(View(model));

            case "Deprecate":
                DeprecateItems(model);
                model.DataSet   = new Collection <DataSetItem>();
                model.ItemTypes = new List <Item>();
                break;

            case "Deprecate All":
                model = ProcessAllData(model);
                break;

            case "Get Set":
                var identifier1       = model.Urn.Substring(model.Urn.IndexOf("/") + 1, model.Urn.Length - model.Urn.IndexOf("/") - 1);
                var agency1           = model.Urn.Substring(0, model.Urn.IndexOf("/"));
                var identifiertriple1 = new IdentifierTriple(new Guid(identifier1), 1, agency1);
                GetSet(identifiertriple1);
                if (model.DataSet == null)
                {
                    model.DataSet = new Collection <DataSetItem>();
                }
                if (model.ItemTypes == null)
                {
                    model.ItemTypes = new List <Item>();
                }
                model.Urns = new List <string>();
                break;

            case "Display Tree":
                var identifier2            = model.Urn.Substring(model.Urn.IndexOf("/") + 1, model.Urn.Length - model.Urn.IndexOf("/") - 1);
                var agency2                = model.Urn.Substring(0, model.Urn.IndexOf("/"));
                var identifiertriple2      = new IdentifierTriple(new Guid(identifier2), 1, agency2);
                List <TreeViewNode> nodes2 = new List <TreeViewNode>();
                nodes        = BuildTree(identifiertriple2, nodes2);
                ViewBag.Json = (new JavaScriptSerializer()).Serialize(nodes);
                return(View("Tree"));
            }
            return(View(model));
        }
        /// <summary>
        /// Maps Variables to Questions where the name of the Variable matches the name of 
        /// the Question.
        /// </summary>
        /// <param name="variableSchemeId"></param>
        /// <param name="questionSchemeId"></param>
        /// <param name="onlyTest"></param>
        static void MapVariablesToQuestionsAuto(IdentifierTriple variableSchemeId, IdentifierTriple questionSchemeId, bool onlyTest)
        {
            var client = RepositoryIntro.GetClient();

            CommitOptions commitOptions = new CommitOptions();

            VariableScheme vs = client.GetItem(variableSchemeId, ChildReferenceProcessing.Populate) as VariableScheme;
            QuestionScheme qs = client.GetItem(questionSchemeId, ChildReferenceProcessing.Populate) as QuestionScheme;

            // Grab all variable names and question names.
            var variableNameList = vs.Variables.Select(v => v.ItemName.Current.Substring(2)).ToList();
            var questionNameList = qs.Questions.Select(q => q.ItemName.Current).ToList();

            int matches = 0;
            foreach (string varName in variableNameList)
            {
                string foundQuestionName = questionNameList.Where(q => string.Compare(q, varName, true) == 0).FirstOrDefault();
                if (foundQuestionName != null)
                {
                    // If there is a question with the same name as this variable,
                    // grab the Question and Variable objects, and assign the question
                    // as a SourceQuestion.
                    Variable variable = vs.Variables.SingleOrDefault(v => v.ItemName.Current == varName);
                    Question question = qs.Questions.SingleOrDefault(q => q.ItemName.Current == foundQuestionName);

                    if (variable != null && question != null)
                    {
                        variable.SourceQuestions.Add(question);
                        variable.Version++;
                        Console.WriteLine(string.Format("Assigning {0} to {1}", question.ItemName.Current, variable.ItemName.Current));

                        if (!onlyTest)
                        {
                            client.RegisterItem(variable, commitOptions);
                        }

                        matches++;
                    }
                    else
                    {
                        Console.WriteLine(string.Format("No match for {0} or {1}", varName, foundQuestionName));
                    }
                }
            }

            vs.Version++;
            if (!onlyTest)
            {
                client.RegisterItem(vs, commitOptions);
            }

            Console.WriteLine("Done. Found " + matches.ToString() + " matches.");
        }