public override int Export()
        {
            IAssetType assetType = _metaAPI.GetAssetType("Schedule");
            Query      query     = new Query(assetType);

            IAttributeDefinition assetStateAttribute = assetType.GetAttributeDefinition("AssetState");

            query.Selection.Add(assetStateAttribute);

            IAttributeDefinition descriptionAttribute = assetType.GetAttributeDefinition("Description");

            query.Selection.Add(descriptionAttribute);

            IAttributeDefinition nameAttribute = assetType.GetAttributeDefinition("Name");

            query.Selection.Add(nameAttribute);

            IAttributeDefinition timeboxGapAttribute = assetType.GetAttributeDefinition("TimeboxGap");

            query.Selection.Add(timeboxGapAttribute);

            IAttributeDefinition timeboxLengthAttribute = assetType.GetAttributeDefinition("TimeboxLength");

            query.Selection.Add(timeboxLengthAttribute);

            string SQL = BuildScheduleInsertStatement();

            if (_config.V1Configurations.PageSize != 0)
            {
                query.Paging.Start    = 0;
                query.Paging.PageSize = _config.V1Configurations.PageSize;
            }

            int assetCounter = 0;
            int assetTotal   = 0;

            do
            {
                QueryResult result = _dataAPI.Retrieve(query);
                assetTotal = result.TotalAvaliable;

                foreach (Asset asset in result.Assets)
                {
                    using (SqlCommand cmd = new SqlCommand())
                    {
                        //NAME NPI MASK:
                        object name = GetScalerValue(asset.GetAttribute(nameAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && name != DBNull.Value)
                        {
                            name = ExportUtils.RemoveNPI(name.ToString());
                        }

                        //DESCRIPTION NPI MASK:
                        object description = GetScalerValue(asset.GetAttribute(descriptionAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && description != DBNull.Value)
                        {
                            description = ExportUtils.RemoveNPI(description.ToString());
                        }

                        cmd.Connection  = _sqlConn;
                        cmd.CommandText = SQL;
                        cmd.CommandType = System.Data.CommandType.Text;
                        cmd.Parameters.AddWithValue("@AssetOID", asset.Oid.ToString());
                        cmd.Parameters.AddWithValue("@AssetState", asset.GetAttribute(assetStateAttribute).Value.ToString());
                        cmd.Parameters.AddWithValue("@Description", description);
                        cmd.Parameters.AddWithValue("@Name", name);
                        cmd.Parameters.AddWithValue("@TimeboxGap", GetScalerValue(asset.GetAttribute(timeboxGapAttribute)));
                        cmd.Parameters.AddWithValue("@TimeboxLength", asset.GetAttribute(timeboxLengthAttribute).Value.ToString());
                        cmd.ExecuteNonQuery();
                    }
                    assetCounter++;
                }
                query.Paging.Start = assetCounter;
            } while (assetCounter != assetTotal);
            return(assetCounter);;
        }
Beispiel #2
0
        public override int Export()
        {
            IAssetType assetType = _metaAPI.GetAssetType("Test");
            Query      query     = new Query(assetType);

            IAttributeDefinition assetStateAttribute = assetType.GetAttributeDefinition("AssetState");

            query.Selection.Add(assetStateAttribute);

            IAttributeDefinition assetNumberAttribute = assetType.GetAttributeDefinition("Number");

            query.Selection.Add(assetNumberAttribute);

            IAttributeDefinition ownersAttribute = assetType.GetAttributeDefinition("Owners.ID");

            query.Selection.Add(ownersAttribute);

            IAttributeDefinition goalsAttribute = assetType.GetAttributeDefinition("Goals.ID");

            query.Selection.Add(goalsAttribute);

            IAttributeDefinition descriptionAttribute = assetType.GetAttributeDefinition("Description");

            query.Selection.Add(descriptionAttribute);

            IAttributeDefinition nameAttribute = assetType.GetAttributeDefinition("Name");

            query.Selection.Add(nameAttribute);

            IAttributeDefinition referenceAttribute = assetType.GetAttributeDefinition("Reference");

            query.Selection.Add(referenceAttribute);

            IAttributeDefinition toDoAttribute = assetType.GetAttributeDefinition("ToDo");

            query.Selection.Add(toDoAttribute);

            IAttributeDefinition detailEstimateAttribute = assetType.GetAttributeDefinition("DetailEstimate");

            query.Selection.Add(detailEstimateAttribute);

            IAttributeDefinition stepsAttribute = assetType.GetAttributeDefinition("Steps");

            query.Selection.Add(stepsAttribute);

            IAttributeDefinition inputsAttribute = assetType.GetAttributeDefinition("Inputs");

            query.Selection.Add(inputsAttribute);

            IAttributeDefinition setupAttribute = assetType.GetAttributeDefinition("Setup");

            query.Selection.Add(setupAttribute);

            IAttributeDefinition orderAttribute = assetType.GetAttributeDefinition("Order");

            query.Selection.Add(orderAttribute);

            IAttributeDefinition estimateAttribute = assetType.GetAttributeDefinition("Estimate");

            query.Selection.Add(estimateAttribute);

            IAttributeDefinition versionTestedAttribute = assetType.GetAttributeDefinition("VersionTested");

            query.Selection.Add(versionTestedAttribute);

            IAttributeDefinition actualResultsAttribute = assetType.GetAttributeDefinition("ActualResults");

            query.Selection.Add(actualResultsAttribute);

            IAttributeDefinition expectedResultsAttribute = assetType.GetAttributeDefinition("ExpectedResults");

            query.Selection.Add(expectedResultsAttribute);

            IAttributeDefinition statusAttribute = assetType.GetAttributeDefinition("Status");

            query.Selection.Add(statusAttribute);

            IAttributeDefinition categoryAttribute = assetType.GetAttributeDefinition("Category");

            query.Selection.Add(categoryAttribute);

            IAttributeDefinition parentAttribute = assetType.GetAttributeDefinition("Parent");

            query.Selection.Add(parentAttribute);

            IAttributeDefinition generatedFromAttribute = assetType.GetAttributeDefinition("GeneratedFrom");

            query.Selection.Add(generatedFromAttribute);

            //Filter on parent scope.
            IAttributeDefinition parentScopeAttribute = assetType.GetAttributeDefinition("Scope.ParentMeAndUp");
            FilterTerm           term = new FilterTerm(parentScopeAttribute);

            term.Equal(_config.V1SourceConnection.Project);
            query.Filter = term;

            string SQL = BuildTestInsertStatement();

            if (_config.V1Configurations.PageSize != 0)
            {
                query.Paging.Start    = 0;
                query.Paging.PageSize = _config.V1Configurations.PageSize;
            }

            int assetCounter = 0;
            int assetTotal   = 0;

            do
            {
                QueryResult result = _dataAPI.Retrieve(query);
                assetTotal = result.TotalAvaliable;

                foreach (Asset asset in result.Assets)
                {
                    using (SqlCommand cmd = new SqlCommand())
                    {
                        //NAME NPI MASK:
                        object name = GetScalerValue(asset.GetAttribute(nameAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && name != DBNull.Value)
                        {
                            name = ExportUtils.RemoveNPI(name.ToString());
                        }

                        //DESCRIPTION NPI MASK:
                        object description = GetScalerValue(asset.GetAttribute(descriptionAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && description != DBNull.Value)
                        {
                            description = ExportUtils.RemoveNPI(description.ToString());
                        }

                        //REFERENCE NPI MASK:
                        object reference = GetScalerValue(asset.GetAttribute(referenceAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && reference != DBNull.Value)
                        {
                            reference = ExportUtils.RemoveNPI(reference.ToString());
                        }

                        //STEPS NPI MASK:
                        object steps = GetScalerValue(asset.GetAttribute(stepsAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && steps != DBNull.Value)
                        {
                            steps = ExportUtils.RemoveNPI(steps.ToString());
                        }

                        //INPUTS NPI MASK:
                        object inputs = GetScalerValue(asset.GetAttribute(inputsAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && inputs != DBNull.Value)
                        {
                            inputs = ExportUtils.RemoveNPI(inputs.ToString());
                        }

                        //SETUP NPI MASK:
                        object setup = GetScalerValue(asset.GetAttribute(setupAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && setup != DBNull.Value)
                        {
                            setup = ExportUtils.RemoveNPI(setup.ToString());
                        }

                        //VERSION TESTED NPI MASK:
                        object versionTested = GetScalerValue(asset.GetAttribute(versionTestedAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && versionTested != DBNull.Value)
                        {
                            versionTested = ExportUtils.RemoveNPI(versionTested.ToString());
                        }

                        //ACTUAL RESULTS NPI MASK:
                        object actualResults = GetScalerValue(asset.GetAttribute(actualResultsAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && actualResults != DBNull.Value)
                        {
                            actualResults = ExportUtils.RemoveNPI(actualResults.ToString());
                        }

                        //EXPECTED RESULTS NPI MASK:
                        object expectedResults = GetScalerValue(asset.GetAttribute(expectedResultsAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && expectedResults != DBNull.Value)
                        {
                            expectedResults = ExportUtils.RemoveNPI(expectedResults.ToString());
                        }

                        cmd.Connection  = _sqlConn;
                        cmd.CommandText = SQL;
                        cmd.CommandType = System.Data.CommandType.Text;
                        cmd.Parameters.AddWithValue("@AssetOID", asset.Oid.ToString());
                        cmd.Parameters.AddWithValue("@AssetState", GetScalerValue(asset.GetAttribute(assetStateAttribute)));
                        cmd.Parameters.AddWithValue("@AssetNumber", GetScalerValue(asset.GetAttribute(assetNumberAttribute)));
                        cmd.Parameters.AddWithValue("@Owners", GetMultiRelationValues(asset.GetAttribute(ownersAttribute)));
                        cmd.Parameters.AddWithValue("@Goals", GetMultiRelationValues(asset.GetAttribute(goalsAttribute)));
                        cmd.Parameters.AddWithValue("@Description", description);
                        cmd.Parameters.AddWithValue("@Name", name);
                        cmd.Parameters.AddWithValue("@Reference", reference);
                        cmd.Parameters.AddWithValue("@ToDo", GetScalerValue(asset.GetAttribute(toDoAttribute)));
                        cmd.Parameters.AddWithValue("@DetailEstimate", GetScalerValue(asset.GetAttribute(detailEstimateAttribute)));
                        cmd.Parameters.AddWithValue("@Steps", steps);
                        cmd.Parameters.AddWithValue("@Inputs", inputs);
                        cmd.Parameters.AddWithValue("@Setup", setup);
                        cmd.Parameters.AddWithValue("@Order", GetScalerValue(asset.GetAttribute(orderAttribute)));
                        cmd.Parameters.AddWithValue("@Estimate", GetScalerValue(asset.GetAttribute(estimateAttribute)));
                        cmd.Parameters.AddWithValue("@VersionTested", versionTested);
                        cmd.Parameters.AddWithValue("@ActualResults", actualResults);
                        cmd.Parameters.AddWithValue("@ExpectedResults", expectedResults);
                        cmd.Parameters.AddWithValue("@Status", GetSingleRelationValue(asset.GetAttribute(statusAttribute)));
                        cmd.Parameters.AddWithValue("@Category", GetSingleRelationValue(asset.GetAttribute(categoryAttribute)));
                        cmd.Parameters.AddWithValue("@Parent", GetSingleRelationValue(asset.GetAttribute(parentAttribute)));
                        cmd.Parameters.AddWithValue("@GeneratedFrom", GetSingleRelationValue(asset.GetAttribute(generatedFromAttribute)));
                        cmd.ExecuteNonQuery();
                    }
                    assetCounter++;
                }
                query.Paging.Start = assetCounter;
            } while (assetCounter != assetTotal);
            DeleteEpicTests();
            return(assetCounter);
        }
        private int ExportEpicsFromEpics()
        {
            IAssetType assetType = _metaAPI.GetAssetType("Epic");
            Query      query     = new Query(assetType);

            IAttributeDefinition assetStateAttribute = assetType.GetAttributeDefinition("AssetState");

            query.Selection.Add(assetStateAttribute);

            IAttributeDefinition assetNumberAttribute = assetType.GetAttributeDefinition("Number");

            query.Selection.Add(assetNumberAttribute);

            IAttributeDefinition ownersAttribute = assetType.GetAttributeDefinition("Owners.ID");

            query.Selection.Add(ownersAttribute);

            IAttributeDefinition goalsAttribute = assetType.GetAttributeDefinition("Goals.ID");

            query.Selection.Add(goalsAttribute);

            IAttributeDefinition superAttribute = assetType.GetAttributeDefinition("Super");

            query.Selection.Add(superAttribute);

            IAttributeDefinition riskAttribute = assetType.GetAttributeDefinition("Risk");

            query.Selection.Add(riskAttribute);

            IAttributeDefinition requestsAttribute = assetType.GetAttributeDefinition("Requests.ID");

            query.Selection.Add(requestsAttribute);

            IAttributeDefinition descriptionAttribute = assetType.GetAttributeDefinition("Description");

            query.Selection.Add(descriptionAttribute);

            IAttributeDefinition nameAttribute = assetType.GetAttributeDefinition("Name");

            query.Selection.Add(nameAttribute);

            IAttributeDefinition referenceAttribute = assetType.GetAttributeDefinition("Reference");

            query.Selection.Add(referenceAttribute);

            IAttributeDefinition scopeAttribute = assetType.GetAttributeDefinition("Scope");

            query.Selection.Add(scopeAttribute);

            IAttributeDefinition statusAttribute = assetType.GetAttributeDefinition("Status");

            query.Selection.Add(statusAttribute);

            IAttributeDefinition swagAttribute = assetType.GetAttributeDefinition("Swag");

            query.Selection.Add(swagAttribute);

            IAttributeDefinition requestedByAttribute = assetType.GetAttributeDefinition("RequestedBy");

            query.Selection.Add(requestedByAttribute);

            IAttributeDefinition valueAttribute = assetType.GetAttributeDefinition("Value");

            query.Selection.Add(valueAttribute);

            IAttributeDefinition orderAttribute = assetType.GetAttributeDefinition("Order");

            query.Selection.Add(orderAttribute);

            IAttributeDefinition blockingIssuesAttribute = assetType.GetAttributeDefinition("BlockingIssues.ID");

            query.Selection.Add(blockingIssuesAttribute);

            IAttributeDefinition issuesAttribute = assetType.GetAttributeDefinition("Issues.ID");

            query.Selection.Add(issuesAttribute);

            IAttributeDefinition categoryAttribute = assetType.GetAttributeDefinition("Category");

            query.Selection.Add(categoryAttribute);

            IAttributeDefinition sourceAttribute = assetType.GetAttributeDefinition("Source");

            query.Selection.Add(sourceAttribute);

            IAttributeDefinition plannedStartAttribute = assetType.GetAttributeDefinition("PlannedStart");

            query.Selection.Add(plannedStartAttribute);

            IAttributeDefinition plannedEndAttribute = assetType.GetAttributeDefinition("PlannedEnd");

            query.Selection.Add(plannedEndAttribute);

            IAttributeDefinition priorityAttribute = assetType.GetAttributeDefinition("Priority");

            query.Selection.Add(priorityAttribute);

            IAttributeDefinition parentScopeAttribute = assetType.GetAttributeDefinition("Scope.ParentMeAndUp");
            FilterTerm           term = new FilterTerm(parentScopeAttribute);

            term.Equal(_config.V1SourceConnection.Project);
            query.Filter = term;

            string SQL = BuildEpicInsertStatement();

            if (_config.V1Configurations.PageSize != 0)
            {
                query.Paging.Start    = 0;
                query.Paging.PageSize = _config.V1Configurations.PageSize;
            }

            int assetCounter = 0;
            int assetTotal   = 0;

            do
            {
                QueryResult result = _dataAPI.Retrieve(query);
                assetTotal = result.TotalAvaliable;

                foreach (Asset asset in result.Assets)
                {
                    //NAME NPI MASK:
                    object name = GetScalerValue(asset.GetAttribute(nameAttribute));
                    if (_config.V1Configurations.UseNPIMasking == true && name != DBNull.Value)
                    {
                        name = ExportUtils.RemoveNPI(name.ToString());
                    }

                    //DESCRIPTION NPI MASK:
                    object description = GetScalerValue(asset.GetAttribute(descriptionAttribute));
                    if (_config.V1Configurations.UseNPIMasking == true && description != DBNull.Value)
                    {
                        description = ExportUtils.RemoveNPI(description.ToString());
                    }

                    //REFERENCE NPI MASK:
                    object reference = GetScalerValue(asset.GetAttribute(referenceAttribute));
                    if (_config.V1Configurations.UseNPIMasking == true && reference != DBNull.Value)
                    {
                        reference = ExportUtils.RemoveNPI(reference.ToString());
                    }

                    //REQUESTED BY NPI MASK:
                    object requestedBy = GetScalerValue(asset.GetAttribute(requestedByAttribute));
                    if (_config.V1Configurations.UseNPIMasking == true && requestedBy != DBNull.Value)
                    {
                        requestedBy = ExportUtils.RemoveNPI(requestedBy.ToString());
                    }

                    using (SqlCommand cmd = new SqlCommand())
                    {
                        cmd.Connection  = _sqlConn;
                        cmd.CommandText = SQL;
                        cmd.CommandType = System.Data.CommandType.Text;
                        cmd.Parameters.AddWithValue("@AssetOID", asset.Oid.ToString());
                        cmd.Parameters.AddWithValue("@AssetState", GetScalerValue(asset.GetAttribute(assetStateAttribute)));
                        cmd.Parameters.AddWithValue("@AssetNumber", GetScalerValue(asset.GetAttribute(assetNumberAttribute)));
                        cmd.Parameters.AddWithValue("@Owners", GetMultiRelationValues(asset.GetAttribute(ownersAttribute)));
                        cmd.Parameters.AddWithValue("@Goals", GetMultiRelationValues(asset.GetAttribute(goalsAttribute)));
                        cmd.Parameters.AddWithValue("@Super", GetSingleRelationValue(asset.GetAttribute(superAttribute)));
                        cmd.Parameters.AddWithValue("@Risk", GetScalerValue(asset.GetAttribute(riskAttribute)));
                        cmd.Parameters.AddWithValue("@Requests", GetMultiRelationValues(asset.GetAttribute(requestsAttribute)));
                        cmd.Parameters.AddWithValue("@Description", description);
                        cmd.Parameters.AddWithValue("@Name", name);
                        cmd.Parameters.AddWithValue("@Reference", reference);
                        cmd.Parameters.AddWithValue("@Scope", GetSingleRelationValue(asset.GetAttribute(scopeAttribute)));
                        cmd.Parameters.AddWithValue("@Status", GetSingleRelationValue(asset.GetAttribute(statusAttribute)));
                        cmd.Parameters.AddWithValue("@Swag", GetScalerValue(asset.GetAttribute(swagAttribute)));
                        cmd.Parameters.AddWithValue("@RequestedBy", requestedBy);
                        cmd.Parameters.AddWithValue("@Value", GetScalerValue(asset.GetAttribute(valueAttribute)));
                        cmd.Parameters.AddWithValue("@Order", GetScalerValue(asset.GetAttribute(orderAttribute)));
                        cmd.Parameters.AddWithValue("@BlockingIssues", GetMultiRelationValues(asset.GetAttribute(blockingIssuesAttribute)));
                        cmd.Parameters.AddWithValue("@Issues", GetMultiRelationValues(asset.GetAttribute(issuesAttribute)));
                        cmd.Parameters.AddWithValue("@Category", GetSingleRelationValue(asset.GetAttribute(categoryAttribute)));
                        cmd.Parameters.AddWithValue("@Source", GetSingleRelationValue(asset.GetAttribute(sourceAttribute)));
                        cmd.Parameters.AddWithValue("@PlannedStart", GetScalerValue(asset.GetAttribute(plannedStartAttribute)));
                        cmd.Parameters.AddWithValue("@PlannedEnd", GetScalerValue(asset.GetAttribute(plannedEndAttribute)));
                        cmd.Parameters.AddWithValue("@Priority", GetSingleRelationValue(asset.GetAttribute(priorityAttribute)));
                        cmd.ExecuteNonQuery();
                    }
                    assetCounter++;
                }
                query.Paging.Start = assetCounter;
            } while (assetCounter != assetTotal);
            //This is not needed for Versions greater than 11
            //DeleteEpicStories();
            return(assetCounter);
        }
Beispiel #4
0
        public override int Export()
        {
            IAssetType assetType = _metaAPI.GetAssetType("Scope");
            Query      query     = new Query(assetType);

            IAttributeDefinition assetStateAttribute = assetType.GetAttributeDefinition("AssetState");

            query.Selection.Add(assetStateAttribute);

            IAttributeDefinition scheduleAttribute = assetType.GetAttributeDefinition("Schedule");

            query.Selection.Add(scheduleAttribute);

            IAttributeDefinition parentAttribute = assetType.GetAttributeDefinition("Parent");

            query.Selection.Add(parentAttribute);

            IAttributeDefinition ownerAttribute = assetType.GetAttributeDefinition("Owner");

            query.Selection.Add(ownerAttribute);

            IAttributeDefinition descriptionAttribute = assetType.GetAttributeDefinition("Description");

            query.Selection.Add(descriptionAttribute);

            IAttributeDefinition nameAttribute = assetType.GetAttributeDefinition("Name");

            query.Selection.Add(nameAttribute);

            IAttributeDefinition endDateAttribute = assetType.GetAttributeDefinition("EndDate");

            query.Selection.Add(endDateAttribute);

            IAttributeDefinition beginDateAttribute = assetType.GetAttributeDefinition("BeginDate");

            query.Selection.Add(beginDateAttribute);

            IAttributeDefinition statusAttribute = assetType.GetAttributeDefinition("Status");

            query.Selection.Add(statusAttribute);

            IAttributeDefinition membersAttribute = null;

            if (_config.V1Configurations.MigrateProjectMembership == true)
            {
                membersAttribute = assetType.GetAttributeDefinition("Members.ID");
                query.Selection.Add(membersAttribute);
            }

            IAttributeDefinition schemeAttribute = assetType.GetAttributeDefinition("Scheme");

            query.Selection.Add(schemeAttribute);

            //SPECIAL CASE: Reference attribute only exists in V1 12 and later.
            IAttributeDefinition referenceAttribute = null;

            if (_metaAPI.Version.Major > 11)
            {
                referenceAttribute = assetType.GetAttributeDefinition("Reference");
                query.Selection.Add(referenceAttribute);
            }

            //Filter on parent scope.
            IAttributeDefinition parentScopeAttribute = assetType.GetAttributeDefinition("ParentMeAndUp");
            FilterTerm           term = new FilterTerm(parentScopeAttribute);

            term.Equal(_config.V1SourceConnection.Project);
            query.Filter = term;

            string SQL = BuildProjectInsertStatement();

            if (_config.V1Configurations.PageSize != 0)
            {
                query.Paging.Start    = 0;
                query.Paging.PageSize = _config.V1Configurations.PageSize;
            }

            int assetCounter = 0;
            int assetTotal   = 0;

            do
            {
                QueryResult result = _dataAPI.Retrieve(query);
                assetTotal = result.TotalAvaliable;

                _logger.Info("assetTotal is {0} ", assetTotal);

                foreach (Asset asset in result.Assets)
                {
                    using (SqlCommand cmd = new SqlCommand())
                    {
                        //NAME NPI MASK:
                        object name = GetScalerValue(asset.GetAttribute(nameAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && name != DBNull.Value)
                        {
                            name = ExportUtils.RemoveNPI(name.ToString());
                        }

                        //DESCRIPTION NPI MASK:
                        object description = GetScalerValue(asset.GetAttribute(descriptionAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && description != DBNull.Value)
                        {
                            description = ExportUtils.RemoveNPI(description.ToString());
                        }

                        cmd.Connection  = _sqlConn;
                        cmd.CommandText = SQL;
                        cmd.CommandType = System.Data.CommandType.Text;
                        cmd.Parameters.AddWithValue("@AssetOID", asset.Oid.ToString());
                        cmd.Parameters.AddWithValue("@AssetState", GetScalerValue(asset.GetAttribute(assetStateAttribute)));
                        cmd.Parameters.AddWithValue("@Schedule", GetSingleRelationValue(asset.GetAttribute(scheduleAttribute)));
                        cmd.Parameters.AddWithValue("@Parent", GetSingleRelationValue(asset.GetAttribute(parentAttribute)));
                        cmd.Parameters.AddWithValue("@Owner", GetSingleRelationValue(asset.GetAttribute(ownerAttribute)));
                        cmd.Parameters.AddWithValue("@Description", description);
                        cmd.Parameters.AddWithValue("@Name", name);
                        cmd.Parameters.AddWithValue("@EndDate", GetScalerValue(asset.GetAttribute(endDateAttribute)));
                        cmd.Parameters.AddWithValue("@BeginDate", GetScalerValue(asset.GetAttribute(beginDateAttribute)));
                        cmd.Parameters.AddWithValue("@Status", GetSingleRelationValue(asset.GetAttribute(statusAttribute)));
                        cmd.Parameters.AddWithValue("@Members", membersAttribute == null ? DBNull.Value : GetMultiRelationValues(asset.GetAttribute(membersAttribute)));
                        cmd.Parameters.AddWithValue("@Reference", referenceAttribute == null ? DBNull.Value : GetScalerValue(asset.GetAttribute(referenceAttribute)));
                        cmd.ExecuteNonQuery();
                    }
                    assetCounter++;
                }
                query.Paging.Start = assetCounter;
            } while (assetCounter != assetTotal);
            return(assetCounter);
        }
        public override int Export()
        {
            IAssetType assetType = _metaAPI.GetAssetType("Request");
            Query      query     = new Query(assetType);

            IAttributeDefinition assetStateAttribute = assetType.GetAttributeDefinition("AssetState");

            query.Selection.Add(assetStateAttribute);

            IAttributeDefinition assetNumberAttribute = assetType.GetAttributeDefinition("Number");

            query.Selection.Add(assetNumberAttribute);

            IAttributeDefinition ownerAttribute = assetType.GetAttributeDefinition("Owner");

            query.Selection.Add(ownerAttribute);

            IAttributeDefinition scopeAttribute = assetType.GetAttributeDefinition("Scope");

            query.Selection.Add(scopeAttribute);

            IAttributeDefinition epicsAttribute = null;

            if (_metaAPI.Version.Major > 11)
            {
                epicsAttribute = assetType.GetAttributeDefinition("Epics.ID");
                query.Selection.Add(epicsAttribute);
            }

            IAttributeDefinition descriptionAttribute = assetType.GetAttributeDefinition("Description");

            query.Selection.Add(descriptionAttribute);

            IAttributeDefinition nameAttribute = assetType.GetAttributeDefinition("Name");

            query.Selection.Add(nameAttribute);

            IAttributeDefinition orderAttribute = assetType.GetAttributeDefinition("Order");

            query.Selection.Add(orderAttribute);

            IAttributeDefinition resolutionAttribute = assetType.GetAttributeDefinition("Resolution");

            query.Selection.Add(resolutionAttribute);

            IAttributeDefinition referenceAttribute = assetType.GetAttributeDefinition("Reference");

            query.Selection.Add(referenceAttribute);

            IAttributeDefinition requestedByAttribute = assetType.GetAttributeDefinition("RequestedBy");

            query.Selection.Add(requestedByAttribute);

            IAttributeDefinition resolutionReasonAttribute = assetType.GetAttributeDefinition("ResolutionReason");

            query.Selection.Add(resolutionReasonAttribute);

            IAttributeDefinition sourceAttribute = assetType.GetAttributeDefinition("Source");

            query.Selection.Add(sourceAttribute);

            IAttributeDefinition priorityAttribute = assetType.GetAttributeDefinition("Priority");

            query.Selection.Add(priorityAttribute);

            IAttributeDefinition statusAttribute = assetType.GetAttributeDefinition("Status");

            query.Selection.Add(statusAttribute);

            IAttributeDefinition categoryAttribute = assetType.GetAttributeDefinition("Category");

            query.Selection.Add(categoryAttribute);

            //Filter on parent scope.
            IAttributeDefinition parentScopeAttribute = assetType.GetAttributeDefinition("Scope.ParentMeAndUp");
            FilterTerm           term = new FilterTerm(parentScopeAttribute);

            term.Equal(_config.V1SourceConnection.Project);
            query.Filter = term;

            string SQL = BuildRequestInsertStatement();

            if (_config.V1Configurations.PageSize != 0)
            {
                query.Paging.Start    = 0;
                query.Paging.PageSize = _config.V1Configurations.PageSize;
            }

            int assetCounter = 0;
            int assetTotal   = 0;

            do
            {
                QueryResult result = _dataAPI.Retrieve(query);
                assetTotal = result.TotalAvaliable;

                foreach (Asset asset in result.Assets)
                {
                    using (SqlCommand cmd = new SqlCommand())
                    {
                        //NAME NPI MASK:
                        object name = GetScalerValue(asset.GetAttribute(nameAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && name != DBNull.Value)
                        {
                            name = ExportUtils.RemoveNPI(name.ToString());
                        }

                        //DESCRIPTION NPI MASK:
                        object description = GetScalerValue(asset.GetAttribute(descriptionAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && description != DBNull.Value)
                        {
                            description = ExportUtils.RemoveNPI(description.ToString());
                        }

                        //REFERENCE NPI MASK:
                        object reference = GetScalerValue(asset.GetAttribute(referenceAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && reference != DBNull.Value)
                        {
                            reference = ExportUtils.RemoveNPI(reference.ToString());
                        }

                        //REQUESTED BY NPI MASK:
                        object requestedBy = GetScalerValue(asset.GetAttribute(requestedByAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && requestedBy != DBNull.Value)
                        {
                            requestedBy = ExportUtils.RemoveNPI(requestedBy.ToString());
                        }

                        //RESOLUTION NPI MASK:
                        object resolution = GetScalerValue(asset.GetAttribute(resolutionAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && resolution != DBNull.Value)
                        {
                            resolution = ExportUtils.RemoveNPI(resolution.ToString());
                        }

                        cmd.Connection  = _sqlConn;
                        cmd.CommandText = SQL;
                        cmd.CommandType = System.Data.CommandType.Text;
                        cmd.Parameters.AddWithValue("@AssetOID", asset.Oid.ToString());
                        cmd.Parameters.AddWithValue("@AssetState", GetScalerValue(asset.GetAttribute(assetStateAttribute)));
                        cmd.Parameters.AddWithValue("@AssetNumber", GetScalerValue(asset.GetAttribute(assetNumberAttribute)));
                        cmd.Parameters.AddWithValue("@Owner", GetSingleRelationValue(asset.GetAttribute(ownerAttribute)));
                        cmd.Parameters.AddWithValue("@Scope", GetSingleRelationValue(asset.GetAttribute(scopeAttribute)));
                        cmd.Parameters.AddWithValue("@Epics", epicsAttribute == null ? DBNull.Value : GetMultiRelationValues(asset.GetAttribute(epicsAttribute)));
                        cmd.Parameters.AddWithValue("@Description", description);
                        cmd.Parameters.AddWithValue("@Name", name);
                        cmd.Parameters.AddWithValue("@Order", GetScalerValue(asset.GetAttribute(orderAttribute)));
                        cmd.Parameters.AddWithValue("@Resolution", resolution);
                        cmd.Parameters.AddWithValue("@Reference", reference);
                        cmd.Parameters.AddWithValue("@RequestedBy", requestedBy);
                        cmd.Parameters.AddWithValue("@ResolutionReason", GetSingleRelationValue(asset.GetAttribute(resolutionReasonAttribute)));
                        cmd.Parameters.AddWithValue("@Source", GetSingleRelationValue(asset.GetAttribute(sourceAttribute)));
                        cmd.Parameters.AddWithValue("@Priority", GetSingleRelationValue(asset.GetAttribute(priorityAttribute)));
                        cmd.Parameters.AddWithValue("@Status", GetSingleRelationValue(asset.GetAttribute(statusAttribute)));
                        cmd.Parameters.AddWithValue("@Category", GetSingleRelationValue(asset.GetAttribute(categoryAttribute)));
                        cmd.ExecuteNonQuery();
                    }
                    assetCounter++;
                }
                query.Paging.Start = assetCounter;
            } while (assetCounter != assetTotal);
            return(assetCounter);
        }
Beispiel #6
0
        public override int Export()
        {
            IAssetType assetType = _metaAPI.GetAssetType("Expression");
            Query      query     = new Query(assetType);

            IAttributeDefinition assetStateAttribute = assetType.GetAttributeDefinition("AssetState");

            query.Selection.Add(assetStateAttribute);

            IAttributeDefinition authoredAtAttribute = assetType.GetAttributeDefinition("AuthoredAt");

            query.Selection.Add(authoredAtAttribute);

            IAttributeDefinition contentAttribute = assetType.GetAttributeDefinition("Content");

            query.Selection.Add(contentAttribute);

            IAttributeDefinition mentionsAttribute = assetType.GetAttributeDefinition("Mentions");

            query.Selection.Add(mentionsAttribute);

            //SPECIAL CASE: BaseAssets attribute only exists in V1 11.3 and earlier.
            IAttributeDefinition baseAssetsAttribute = null;

            if (_metaAPI.Version.Major < 12)
            {
                baseAssetsAttribute = assetType.GetAttributeDefinition("BaseAssets.ID");
                query.Selection.Add(baseAssetsAttribute);
            }

            IAttributeDefinition authorAttribute = assetType.GetAttributeDefinition("Author");

            query.Selection.Add(authorAttribute);

            IAttributeDefinition conversationAttribute = null;
            IAttributeDefinition beLongsToAttribute    = null;

            if (_metaAPI.Version.Major < 12)
            {
                conversationAttribute = assetType.GetAttributeDefinition("Conversation");
                query.Selection.Add(conversationAttribute);
            }
            else
            {
                beLongsToAttribute = assetType.GetAttributeDefinition("BelongsTo");
                query.Selection.Add(beLongsToAttribute);
            }

            IAttributeDefinition inReplyToAttribute = assetType.GetAttributeDefinition("InReplyTo");

            query.Selection.Add(inReplyToAttribute);

            string SQL = BuildConversationInsertStatement();

            if (_config.V1Configurations.PageSize != 0)
            {
                query.Paging.Start    = 0;
                query.Paging.PageSize = _config.V1Configurations.PageSize;
            }

            int assetCounter = 0;
            int assetTotal   = 0;

            do
            {
                QueryResult result = _dataAPI.Retrieve(query);
                assetTotal = result.TotalAvaliable;

                foreach (Asset asset in result.Assets)
                {
                    using (SqlCommand cmd = new SqlCommand())
                    {
                        //CONTENT NPI MASK:
                        object content = GetScalerValue(asset.GetAttribute(contentAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && content != DBNull.Value)
                        {
                            content = ExportUtils.RemoveNPI(content.ToString());
                        }

                        cmd.Connection  = _sqlConn;
                        cmd.CommandText = SQL;
                        cmd.CommandType = System.Data.CommandType.Text;
                        cmd.Parameters.AddWithValue("@AssetOID", asset.Oid.ToString());
                        cmd.Parameters.AddWithValue("@AssetState", GetScalerValue(asset.GetAttribute(assetStateAttribute)));
                        cmd.Parameters.AddWithValue("@AuthoredAt", GetScalerValue(asset.GetAttribute(authoredAtAttribute)));
                        cmd.Parameters.AddWithValue("@Content", content);
                        cmd.Parameters.AddWithValue("@Mentions", GetMultiRelationValues(asset.GetAttribute(mentionsAttribute)));

                        if (_metaAPI.Version.Major < 12)
                        {
                            cmd.Parameters.AddWithValue("@BaseAssets", GetMultiRelationValues(asset.GetAttribute(baseAssetsAttribute)));
                        }

                        if (_metaAPI.Version.Major < 12)
                        {
                            cmd.Parameters.AddWithValue("@Conversation", GetMultiRelationValues(asset.GetAttribute(conversationAttribute)));
                        }
                        else
                        {
                            cmd.Parameters.AddWithValue("@BelongsTo", GetSingleRelationValue(asset.GetAttribute(beLongsToAttribute)));
                        }

                        cmd.Parameters.AddWithValue("@Author", GetSingleRelationValue(asset.GetAttribute(authorAttribute)));
                        cmd.Parameters.AddWithValue("@InReplyTo", GetSingleRelationValue(asset.GetAttribute(inReplyToAttribute)));
                        cmd.ExecuteNonQuery();
                    }
                    assetCounter++;
                }
                query.Paging.Start = assetCounter;
            } while (assetCounter != assetTotal);
            return(assetCounter);
        }
        public override int Export()
        {
            IAssetType assetType = _metaAPI.GetAssetType("Goal");
            Query      query     = new Query(assetType);

            IAttributeDefinition assetStateAttribute = assetType.GetAttributeDefinition("AssetState");

            query.Selection.Add(assetStateAttribute);

            IAttributeDefinition assetNumberAttribute = assetType.GetAttributeDefinition("Number");

            query.Selection.Add(assetNumberAttribute);

            IAttributeDefinition targetedByAttribute = assetType.GetAttributeDefinition("TargetedBy.ID");

            query.Selection.Add(targetedByAttribute);

            IAttributeDefinition scopeAttribute = assetType.GetAttributeDefinition("Scope");

            query.Selection.Add(scopeAttribute);

            IAttributeDefinition descriptionAttribute = assetType.GetAttributeDefinition("Description");

            query.Selection.Add(descriptionAttribute);

            IAttributeDefinition nameAttribute = assetType.GetAttributeDefinition("Name");

            query.Selection.Add(nameAttribute);

            IAttributeDefinition priorityAttribute = assetType.GetAttributeDefinition("Priority");

            query.Selection.Add(priorityAttribute);

            IAttributeDefinition categoryAttribute = assetType.GetAttributeDefinition("Category");

            query.Selection.Add(categoryAttribute);

            //Filter on parent scope.
            IAttributeDefinition parentScopeAttribute = assetType.GetAttributeDefinition("Scope.ParentMeAndUp");
            FilterTerm           term = new FilterTerm(parentScopeAttribute);

            term.Equal(_config.V1SourceConnection.Project);
            query.Filter = term;

            string SQL = BuildGoalInsertStatement();

            if (_config.V1Configurations.PageSize != 0)
            {
                query.Paging.Start    = 0;
                query.Paging.PageSize = _config.V1Configurations.PageSize;
            }

            int assetCounter = 0;
            int assetTotal   = 0;

            do
            {
                QueryResult result = _dataAPI.Retrieve(query);
                assetTotal = result.TotalAvaliable;

                foreach (Asset asset in result.Assets)
                {
                    using (SqlCommand cmd = new SqlCommand())
                    {
                        //NAME NPI MASK:
                        object name = GetScalerValue(asset.GetAttribute(nameAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && name != DBNull.Value)
                        {
                            name = ExportUtils.RemoveNPI(name.ToString());
                        }

                        //DESCRIPTION NPI MASK:
                        object description = GetScalerValue(asset.GetAttribute(descriptionAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && description != DBNull.Value)
                        {
                            description = ExportUtils.RemoveNPI(description.ToString());
                        }

                        cmd.Connection  = _sqlConn;
                        cmd.CommandText = SQL;
                        cmd.CommandType = System.Data.CommandType.Text;
                        cmd.Parameters.AddWithValue("@AssetOID", asset.Oid.ToString());
                        cmd.Parameters.AddWithValue("@AssetState", GetScalerValue(asset.GetAttribute(assetStateAttribute)));
                        cmd.Parameters.AddWithValue("@AssetNumber", GetScalerValue(asset.GetAttribute(assetNumberAttribute)));
                        cmd.Parameters.AddWithValue("@TargetedBy", GetMultiRelationValues(asset.GetAttribute(targetedByAttribute)));
                        cmd.Parameters.AddWithValue("@Scope", GetSingleRelationValue(asset.GetAttribute(scopeAttribute)));
                        cmd.Parameters.AddWithValue("@Description", description);
                        cmd.Parameters.AddWithValue("@Name", name);
                        cmd.Parameters.AddWithValue("@Priority", GetSingleRelationValue(asset.GetAttribute(priorityAttribute)));
                        cmd.Parameters.AddWithValue("@Category", GetSingleRelationValue(asset.GetAttribute(categoryAttribute)));
                        cmd.ExecuteNonQuery();
                    }
                    assetCounter++;
                }
                query.Paging.Start = assetCounter;
            } while (assetCounter != assetTotal);
            return(assetCounter);
        }
Beispiel #8
0
        public override int Export()
        {
            IAssetType assetType = _metaAPI.GetAssetType("Theme");
            Query      query     = new Query(assetType);

            IAttributeDefinition assetStateAttribute = assetType.GetAttributeDefinition("AssetState");

            query.Selection.Add(assetStateAttribute);

            IAttributeDefinition assetNumberAttribute = assetType.GetAttributeDefinition("Number");

            query.Selection.Add(assetNumberAttribute);

            IAttributeDefinition customerAttribute = assetType.GetAttributeDefinition("Customer");

            query.Selection.Add(customerAttribute);

            IAttributeDefinition ownersAttribute = assetType.GetAttributeDefinition("Owners.ID");

            query.Selection.Add(ownersAttribute);

            IAttributeDefinition goalsAttribute = assetType.GetAttributeDefinition("Goals.ID");

            query.Selection.Add(goalsAttribute);

            IAttributeDefinition descriptionAttribute = assetType.GetAttributeDefinition("Description");

            query.Selection.Add(descriptionAttribute);

            IAttributeDefinition nameAttribute = assetType.GetAttributeDefinition("Name");

            query.Selection.Add(nameAttribute);

            IAttributeDefinition referenceAttribute = assetType.GetAttributeDefinition("Reference");

            query.Selection.Add(referenceAttribute);

            IAttributeDefinition orderAttribute = assetType.GetAttributeDefinition("Order");

            query.Selection.Add(orderAttribute);

            IAttributeDefinition valueAttribute = assetType.GetAttributeDefinition("Value");

            query.Selection.Add(valueAttribute);

            IAttributeDefinition estimateAttribute = assetType.GetAttributeDefinition("Estimate");

            query.Selection.Add(estimateAttribute);

            IAttributeDefinition lastVersionAttribute = assetType.GetAttributeDefinition("LastVersion");

            query.Selection.Add(lastVersionAttribute);

            IAttributeDefinition scopeAttribute = assetType.GetAttributeDefinition("Scope");

            query.Selection.Add(scopeAttribute);

            IAttributeDefinition riskAttribute = assetType.GetAttributeDefinition("Risk");

            query.Selection.Add(riskAttribute);

            IAttributeDefinition priorityAttribute = assetType.GetAttributeDefinition("Priority");

            query.Selection.Add(priorityAttribute);

            IAttributeDefinition statusAttribute = assetType.GetAttributeDefinition("Status");

            query.Selection.Add(statusAttribute);

            IAttributeDefinition categoryAttribute = assetType.GetAttributeDefinition("Category");

            query.Selection.Add(categoryAttribute);

            IAttributeDefinition sourceAttribute = assetType.GetAttributeDefinition("Source");

            query.Selection.Add(sourceAttribute);

            IAttributeDefinition parentAttribute = assetType.GetAttributeDefinition("Parent");

            query.Selection.Add(parentAttribute);

            IAttributeDefinition areaAttribute = assetType.GetAttributeDefinition("Area");

            query.Selection.Add(areaAttribute);

            //Filter on parent scope.
            IAttributeDefinition parentScopeAttribute = assetType.GetAttributeDefinition("Scope.ParentMeAndUp");
            FilterTerm           term = new FilterTerm(parentScopeAttribute);

            term.Equal(_config.V1SourceConnection.Project);
            query.Filter = term;

            string SQL = BuildFeatureGroupInsertStatement();

            if (_config.V1Configurations.PageSize != 0)
            {
                query.Paging.Start    = 0;
                query.Paging.PageSize = _config.V1Configurations.PageSize;
            }

            int assetCounter = 0;
            int assetTotal   = 0;

            do
            {
                QueryResult result = _dataAPI.Retrieve(query);
                assetTotal = result.TotalAvaliable;

                foreach (Asset asset in result.Assets)
                {
                    using (SqlCommand cmd = new SqlCommand())
                    {
                        //NAME NPI MASK:
                        object name = GetScalerValue(asset.GetAttribute(nameAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && name != DBNull.Value)
                        {
                            name = ExportUtils.RemoveNPI(name.ToString());
                        }

                        //DESCRIPTION NPI MASK:
                        object description = GetScalerValue(asset.GetAttribute(descriptionAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && description != DBNull.Value)
                        {
                            description = ExportUtils.RemoveNPI(description.ToString());
                        }

                        //REFERENCE NPI MASK:
                        object reference = GetScalerValue(asset.GetAttribute(referenceAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && reference != DBNull.Value)
                        {
                            reference = ExportUtils.RemoveNPI(reference.ToString());
                        }

                        //LAST VERSION (BUILD) NPI MASK:
                        object lastVersion = GetScalerValue(asset.GetAttribute(lastVersionAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && lastVersion != DBNull.Value)
                        {
                            lastVersion = ExportUtils.RemoveNPI(lastVersion.ToString());
                        }

                        cmd.Connection  = _sqlConn;
                        cmd.CommandText = SQL;
                        cmd.CommandType = System.Data.CommandType.Text;
                        cmd.Parameters.AddWithValue("@AssetOID", asset.Oid.ToString());
                        cmd.Parameters.AddWithValue("@AssetState", GetScalerValue(asset.GetAttribute(assetStateAttribute)));
                        cmd.Parameters.AddWithValue("@AssetNumber", GetScalerValue(asset.GetAttribute(assetNumberAttribute)));
                        cmd.Parameters.AddWithValue("@Customer", GetSingleRelationValue(asset.GetAttribute(customerAttribute)));
                        cmd.Parameters.AddWithValue("@Owners", GetMultiRelationValues(asset.GetAttribute(ownersAttribute)));
                        cmd.Parameters.AddWithValue("@Goals", GetMultiRelationValues(asset.GetAttribute(goalsAttribute)));
                        cmd.Parameters.AddWithValue("@Description", description);
                        cmd.Parameters.AddWithValue("@Name", name);
                        cmd.Parameters.AddWithValue("@Reference", reference);
                        cmd.Parameters.AddWithValue("@Order", GetScalerValue(asset.GetAttribute(orderAttribute)));
                        cmd.Parameters.AddWithValue("@Value", GetScalerValue(asset.GetAttribute(valueAttribute)));
                        cmd.Parameters.AddWithValue("@Estimate", GetScalerValue(asset.GetAttribute(estimateAttribute)));
                        cmd.Parameters.AddWithValue("@LastVersion", lastVersion);
                        cmd.Parameters.AddWithValue("@Scope", GetSingleRelationValue(asset.GetAttribute(scopeAttribute)));
                        cmd.Parameters.AddWithValue("@Risk", GetSingleRelationValue(asset.GetAttribute(riskAttribute)));
                        cmd.Parameters.AddWithValue("@Priority", GetSingleRelationValue(asset.GetAttribute(priorityAttribute)));
                        cmd.Parameters.AddWithValue("@Status", GetSingleRelationValue(asset.GetAttribute(statusAttribute)));
                        cmd.Parameters.AddWithValue("@Category", GetSingleRelationValue(asset.GetAttribute(categoryAttribute)));
                        cmd.Parameters.AddWithValue("@Source", GetSingleRelationValue(asset.GetAttribute(sourceAttribute)));
                        cmd.Parameters.AddWithValue("@Parent", GetSingleRelationValue(asset.GetAttribute(parentAttribute)));
                        cmd.Parameters.AddWithValue("@Area", GetSingleRelationValue(asset.GetAttribute(areaAttribute)));
                        cmd.ExecuteNonQuery();
                    }
                    assetCounter++;
                }
                query.Paging.Start = assetCounter;
            } while (assetCounter != assetTotal);
            return(assetCounter);
        }
        public override int Export()
        {
            IAssetType assetType = _metaAPI.GetAssetType("Story");
            Query      query     = new Query(assetType);

            IAttributeDefinition assetStateAttribute = assetType.GetAttributeDefinition("AssetState");

            query.Selection.Add(assetStateAttribute);

            IAttributeDefinition assetNumberAttribute = assetType.GetAttributeDefinition("Number");

            query.Selection.Add(assetNumberAttribute);

            IAttributeDefinition timeboxAttribute = assetType.GetAttributeDefinition("Timebox");

            query.Selection.Add(timeboxAttribute);

            IAttributeDefinition customerAttribute = assetType.GetAttributeDefinition("Customer");

            query.Selection.Add(customerAttribute);

            IAttributeDefinition ownersAttribute = assetType.GetAttributeDefinition("Owners.ID");

            query.Selection.Add(ownersAttribute);

            IAttributeDefinition identifiedInAttribute = assetType.GetAttributeDefinition("IdentifiedIn");

            query.Selection.Add(identifiedInAttribute);

            IAttributeDefinition teamAttribute = assetType.GetAttributeDefinition("Team");

            query.Selection.Add(teamAttribute);

            IAttributeDefinition goalsAttribute = assetType.GetAttributeDefinition("Goals.ID");

            query.Selection.Add(goalsAttribute);

            IAttributeDefinition affectedByDefectsAttribute = assetType.GetAttributeDefinition("AffectedByDefects.ID");

            query.Selection.Add(affectedByDefectsAttribute);

            IAttributeDefinition superAttribute = assetType.GetAttributeDefinition("Super");

            query.Selection.Add(superAttribute);

            IAttributeDefinition descriptionAttribute = assetType.GetAttributeDefinition("Description");

            query.Selection.Add(descriptionAttribute);

            IAttributeDefinition nameAttribute = assetType.GetAttributeDefinition("Name");

            query.Selection.Add(nameAttribute);

            IAttributeDefinition referenceAttribute = assetType.GetAttributeDefinition("Reference");

            query.Selection.Add(referenceAttribute);

            IAttributeDefinition toDoAttribute = assetType.GetAttributeDefinition("ToDo");

            query.Selection.Add(toDoAttribute);

            IAttributeDefinition detailEstimateAttribute = assetType.GetAttributeDefinition("DetailEstimate");

            query.Selection.Add(detailEstimateAttribute);

            IAttributeDefinition orderAttribute = assetType.GetAttributeDefinition("Order");

            query.Selection.Add(orderAttribute);

            IAttributeDefinition estimateAttribute = assetType.GetAttributeDefinition("Estimate");

            query.Selection.Add(estimateAttribute);

            IAttributeDefinition lastVersionAttribute = assetType.GetAttributeDefinition("LastVersion");

            query.Selection.Add(lastVersionAttribute);

            IAttributeDefinition originalEstimateAttribute = assetType.GetAttributeDefinition("OriginalEstimate");

            query.Selection.Add(originalEstimateAttribute);

            IAttributeDefinition requestedByAttribute = assetType.GetAttributeDefinition("RequestedBy");

            query.Selection.Add(requestedByAttribute);

            IAttributeDefinition valueAttribute = assetType.GetAttributeDefinition("Value");

            query.Selection.Add(valueAttribute);

            IAttributeDefinition scopeAttribute = assetType.GetAttributeDefinition("Scope");

            query.Selection.Add(scopeAttribute);

            IAttributeDefinition statusAttribute = assetType.GetAttributeDefinition("Status");

            query.Selection.Add(statusAttribute);

            IAttributeDefinition categoryAttribute = assetType.GetAttributeDefinition("Category");

            query.Selection.Add(categoryAttribute);

            IAttributeDefinition riskAttribute = assetType.GetAttributeDefinition("Risk");

            query.Selection.Add(riskAttribute);

            IAttributeDefinition sourceAttribute = assetType.GetAttributeDefinition("Source");

            query.Selection.Add(sourceAttribute);

            IAttributeDefinition priorityAttribute = assetType.GetAttributeDefinition("Priority");

            query.Selection.Add(priorityAttribute);

            IAttributeDefinition dependenciesAttribute = assetType.GetAttributeDefinition("Dependencies.ID");

            query.Selection.Add(dependenciesAttribute);

            IAttributeDefinition dependantsAttribute = assetType.GetAttributeDefinition("Dependants.ID");

            query.Selection.Add(dependantsAttribute);

            IAttributeDefinition parentAttribute = assetType.GetAttributeDefinition("Parent");

            query.Selection.Add(parentAttribute);

            IAttributeDefinition requestsAttribute = assetType.GetAttributeDefinition("Requests.ID");

            query.Selection.Add(requestsAttribute);

            IAttributeDefinition blockingIssuesAttribute = assetType.GetAttributeDefinition("BlockingIssues.ID");

            query.Selection.Add(blockingIssuesAttribute);

            IAttributeDefinition issuesAttribute = assetType.GetAttributeDefinition("Issues.ID");

            query.Selection.Add(issuesAttribute);

            IAttributeDefinition benefitsAttribute = assetType.GetAttributeDefinition("Benefits");

            query.Selection.Add(benefitsAttribute);

            IAttributeDefinition subStateAttribute = null;

            if (_metaAPI.Version.Major < 12)
            {
                subStateAttribute = assetType.GetAttributeDefinition("SubState");
                query.Selection.Add(subStateAttribute);
            }

            //Filter on parent scope.
            IAttributeDefinition parentScopeAttribute = assetType.GetAttributeDefinition("Scope.ParentMeAndUp");
            FilterTerm           term = new FilterTerm(parentScopeAttribute);

            term.Equal(_config.V1SourceConnection.Project);
            query.Filter = term;

            string SQL = BuildStoryInsertStatement();

            if (_config.V1Configurations.PageSize != 0)
            {
                query.Paging.Start    = 0;
                query.Paging.PageSize = _config.V1Configurations.PageSize;
            }

            int assetCounter = 0;
            int assetTotal   = 0;

            do
            {
                QueryResult result = _dataAPI.Retrieve(query);
                assetTotal = result.TotalAvaliable;

                foreach (Asset asset in result.Assets)
                {
                    using (SqlCommand cmd = new SqlCommand())
                    {
                        //NAME NPI MASK:
                        object name = GetScalerValue(asset.GetAttribute(nameAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && name != DBNull.Value)
                        {
                            name = ExportUtils.RemoveNPI(name.ToString());
                        }

                        //DESCRIPTION NPI MASK:
                        object description = GetScalerValue(asset.GetAttribute(descriptionAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && description != DBNull.Value)
                        {
                            description = ExportUtils.RemoveNPI(description.ToString());
                        }

                        //REFERENCE NPI MASK:
                        object reference = GetScalerValue(asset.GetAttribute(referenceAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && reference != DBNull.Value)
                        {
                            reference = ExportUtils.RemoveNPI(reference.ToString());
                        }

                        //REQUESTED BY NPI MASK:
                        object requestedBy = GetScalerValue(asset.GetAttribute(requestedByAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && requestedBy != DBNull.Value)
                        {
                            requestedBy = ExportUtils.RemoveNPI(requestedBy.ToString());
                        }

                        //LAST VERSION NPI MASK:
                        object lastVersion = GetScalerValue(asset.GetAttribute(lastVersionAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && lastVersion != DBNull.Value)
                        {
                            lastVersion = ExportUtils.RemoveNPI(lastVersion.ToString());
                        }

                        //BENEFITS NPI MASK:
                        object benefits = GetScalerValue(asset.GetAttribute(lastVersionAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && benefits != DBNull.Value)
                        {
                            benefits = ExportUtils.RemoveNPI(benefits.ToString());
                        }


                        cmd.Connection  = _sqlConn;
                        cmd.CommandText = SQL;
                        cmd.CommandType = System.Data.CommandType.Text;
                        cmd.Parameters.AddWithValue("@AssetOID", asset.Oid.ToString());
                        cmd.Parameters.AddWithValue("@AssetState", CheckStoryState(asset.GetAttribute(assetStateAttribute)));
                        cmd.Parameters.AddWithValue("@AssetNumber", GetScalerValue(asset.GetAttribute(assetNumberAttribute)));

                        if (_metaAPI.Version.Major < 12)
                        {
                            cmd.Parameters.AddWithValue("@SubState", GetScalerValue(asset.GetAttribute(subStateAttribute)));
                        }

                        cmd.Parameters.AddWithValue("@Timebox", GetSingleRelationValue(asset.GetAttribute(timeboxAttribute)));
                        cmd.Parameters.AddWithValue("@Customer", GetSingleRelationValue(asset.GetAttribute(customerAttribute)));
                        cmd.Parameters.AddWithValue("@Owners", GetMultiRelationValues(asset.GetAttribute(ownersAttribute)));
                        cmd.Parameters.AddWithValue("@IdentifiedIn", GetSingleRelationValue(asset.GetAttribute(identifiedInAttribute)));
                        cmd.Parameters.AddWithValue("@Team", GetSingleRelationValue(asset.GetAttribute(teamAttribute)));
                        cmd.Parameters.AddWithValue("@Goals", GetMultiRelationValues(asset.GetAttribute(goalsAttribute)));
                        cmd.Parameters.AddWithValue("@AffectedByDefects", GetMultiRelationValues(asset.GetAttribute(affectedByDefectsAttribute)));
                        cmd.Parameters.AddWithValue("@Super", GetSingleRelationValue(asset.GetAttribute(superAttribute)));
                        cmd.Parameters.AddWithValue("@Description", description);
                        cmd.Parameters.AddWithValue("@Name", name);
                        cmd.Parameters.AddWithValue("@Reference", reference);
                        cmd.Parameters.AddWithValue("@ToDo", GetScalerValue(asset.GetAttribute(toDoAttribute)));
                        cmd.Parameters.AddWithValue("@DetailEstimate", GetScalerValue(asset.GetAttribute(detailEstimateAttribute)));
                        cmd.Parameters.AddWithValue("@Order", GetScalerValue(asset.GetAttribute(orderAttribute)));
                        cmd.Parameters.AddWithValue("@Estimate", GetScalerValue(asset.GetAttribute(estimateAttribute)));
                        cmd.Parameters.AddWithValue("@LastVersion", lastVersion);
                        cmd.Parameters.AddWithValue("@OriginalEstimate", GetScalerValue(asset.GetAttribute(originalEstimateAttribute)));
                        cmd.Parameters.AddWithValue("@RequestedBy", requestedBy);
                        cmd.Parameters.AddWithValue("@Value", GetScalerValue(asset.GetAttribute(valueAttribute)));
                        cmd.Parameters.AddWithValue("@Scope", GetSingleRelationValue(asset.GetAttribute(scopeAttribute)));
                        cmd.Parameters.AddWithValue("@Status", GetSingleRelationValue(asset.GetAttribute(statusAttribute)));
                        cmd.Parameters.AddWithValue("@Category", GetSingleRelationValue(asset.GetAttribute(categoryAttribute)));
                        cmd.Parameters.AddWithValue("@Risk", GetSingleRelationValue(asset.GetAttribute(riskAttribute)));
                        cmd.Parameters.AddWithValue("@Source", GetSingleRelationValue(asset.GetAttribute(sourceAttribute)));
                        cmd.Parameters.AddWithValue("@Priority", GetSingleRelationValue(asset.GetAttribute(priorityAttribute)));
                        cmd.Parameters.AddWithValue("@Dependencies", GetMultiRelationValues(asset.GetAttribute(dependenciesAttribute)));
                        cmd.Parameters.AddWithValue("@Dependants", GetMultiRelationValues(asset.GetAttribute(dependantsAttribute)));
                        cmd.Parameters.AddWithValue("@Parent", GetSingleRelationValue(asset.GetAttribute(parentAttribute)));
                        cmd.Parameters.AddWithValue("@Requests", GetMultiRelationValues(asset.GetAttribute(requestsAttribute)));
                        cmd.Parameters.AddWithValue("@BlockingIssues", GetMultiRelationValues(asset.GetAttribute(blockingIssuesAttribute)));
                        cmd.Parameters.AddWithValue("@Issues", GetMultiRelationValues(asset.GetAttribute(issuesAttribute)));
                        cmd.Parameters.AddWithValue("@Benefits", benefits);
                        cmd.ExecuteNonQuery();
                    }
                    assetCounter++;
                }
                query.Paging.Start = assetCounter;
            } while (assetCounter != assetTotal);

            if (_config.V1Configurations.MigrateTemplates == false)
            {
                DeleteStoryTemplates();
            }

            //Check for Epics as Stories from V1 Major < 12
            //ExportEpics epicStory = new ExportEpics(_sqlConn, _metaAPI, _dataAPI, _config);
            //epicStory.Export();
            int rc = ExportEpicsFromStories();

            return(assetCounter);
        }
Beispiel #10
0
        public override int Export()
        {
            IAssetType assetType = _metaAPI.GetAssetType("Member");
            Query      query     = new Query(assetType);

            IAttributeDefinition assetStateAttribute = assetType.GetAttributeDefinition("AssetState");

            query.Selection.Add(assetStateAttribute);

            IAttributeDefinition emailAttribute = assetType.GetAttributeDefinition("Email");

            query.Selection.Add(emailAttribute);

            IAttributeDefinition nicknameAttribute = assetType.GetAttributeDefinition("Nickname");

            query.Selection.Add(nicknameAttribute);

            IAttributeDefinition descriptionAttribute = assetType.GetAttributeDefinition("Description");

            query.Selection.Add(descriptionAttribute);

            IAttributeDefinition nameAttribute = assetType.GetAttributeDefinition("Name");

            query.Selection.Add(nameAttribute);

            IAttributeDefinition phoneAttribute = assetType.GetAttributeDefinition("Phone");

            query.Selection.Add(phoneAttribute);

            IAttributeDefinition defaultRoleAttribute = assetType.GetAttributeDefinition("DefaultRole");

            query.Selection.Add(defaultRoleAttribute);

            IAttributeDefinition usernameAttribute = assetType.GetAttributeDefinition("Username");

            query.Selection.Add(usernameAttribute);

            IAttributeDefinition memberLabelsAttribute = assetType.GetAttributeDefinition("MemberLabels.ID");

            query.Selection.Add(memberLabelsAttribute);

            IAttributeDefinition notifyViaEmailAttribute = assetType.GetAttributeDefinition("NotifyViaEmail");

            query.Selection.Add(notifyViaEmailAttribute);

            //SPECIAL CASE: sendConversationEmailsAttribute attribute only exists in V1 12 and later.
            IAttributeDefinition sendConversationEmailsAttribute = null;
            IAttributeDefinition IsCollaboratorAttribute         = null;

            if (_metaAPI.Version.Major > 11)
            {
                sendConversationEmailsAttribute = assetType.GetAttributeDefinition("SendConversationEmails");
                query.Selection.Add(sendConversationEmailsAttribute);

                IsCollaboratorAttribute = assetType.GetAttributeDefinition("IsCollaborator");
                query.Selection.Add(IsCollaboratorAttribute);
            }

            string SQL = BuildMemberInsertStatement();

            if (_config.V1Configurations.PageSize != 0)
            {
                query.Paging.Start    = 0;
                query.Paging.PageSize = _config.V1Configurations.PageSize;
            }

            int assetCounter = 0;
            int assetTotal   = 0;

            do
            {
                QueryResult result = _dataAPI.Retrieve(query);
                assetTotal = result.TotalAvaliable;
                _logger.Info("The TotalAvailable Members is {0} ", assetTotal);


                foreach (Asset asset in result.Assets)
                {
                    using (SqlCommand cmd = new SqlCommand())
                    {
                        //NAME NPI MASK:
                        object name = GetScalerValue(asset.GetAttribute(nameAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && name != DBNull.Value)
                        {
                            name = ExportUtils.RemoveNPI(name.ToString());
                        }

                        //DESCRIPTION NPI MASK:
                        object description = GetScalerValue(asset.GetAttribute(descriptionAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && description != DBNull.Value)
                        {
                            description = ExportUtils.RemoveNPI(description.ToString());
                        }

                        cmd.Connection  = _sqlConn;
                        cmd.CommandText = SQL;
                        cmd.CommandType = System.Data.CommandType.Text;
                        cmd.Parameters.AddWithValue("@AssetOID", asset.Oid.ToString());
                        cmd.Parameters.AddWithValue("@AssetState", GetScalerValue(asset.GetAttribute(assetStateAttribute)));
                        cmd.Parameters.AddWithValue("@Email", GetScalerValue(asset.GetAttribute(emailAttribute)));
                        cmd.Parameters.AddWithValue("@Nickname", GetScalerValue(asset.GetAttribute(nicknameAttribute)));
                        cmd.Parameters.AddWithValue("@Description", description);
                        cmd.Parameters.AddWithValue("@Name", name);
                        cmd.Parameters.AddWithValue("@Phone", GetScalerValue(asset.GetAttribute(phoneAttribute)));
                        cmd.Parameters.AddWithValue("@DefaultRole", GetSingleRelationValue(asset.GetAttribute(defaultRoleAttribute)));
                        cmd.Parameters.AddWithValue("@Username", GetScalerValue(asset.GetAttribute(usernameAttribute)));
                        cmd.Parameters.AddWithValue("@MemberLabels", GetMultiRelationValues(asset.GetAttribute(memberLabelsAttribute)));
                        cmd.Parameters.AddWithValue("@NotifyViaEmail", GetScalerValue(asset.GetAttribute(notifyViaEmailAttribute)));
                        //cmd.Parameters.AddWithValue("@IsCollaborator", IsCollaboratorAttribute == null ? "True" : GetScalerValue(asset.GetAttribute(IsCollaboratorAttribute)));
                        cmd.Parameters.AddWithValue("@SendConversationEmails", sendConversationEmailsAttribute == null ? "True" : GetScalerValue(asset.GetAttribute(sendConversationEmailsAttribute)));
                        cmd.ExecuteNonQuery();
                    }
                    assetCounter++;
                }
                query.Paging.Start = assetCounter;
            } while (assetCounter != assetTotal);
            return(assetCounter);
        }
Beispiel #11
0
        public override int Export()
        {
            IAssetType assetType = _metaAPI.GetAssetType("Link");
            Query      query     = new Query(assetType);

            IAttributeDefinition assetStateAttribute = assetType.GetAttributeDefinition("AssetState");

            query.Selection.Add(assetStateAttribute);

            IAttributeDefinition onMenuAttribute = assetType.GetAttributeDefinition("OnMenu");

            query.Selection.Add(onMenuAttribute);

            IAttributeDefinition urlAttribute = assetType.GetAttributeDefinition("URL");

            query.Selection.Add(urlAttribute);

            IAttributeDefinition nameAttribute = assetType.GetAttributeDefinition("Name");

            query.Selection.Add(nameAttribute);

            IAttributeDefinition assetAttribute = assetType.GetAttributeDefinition("Asset");

            query.Selection.Add(assetAttribute);

            string SQL = BuildLinkInsertStatement();

            if (_config.V1Configurations.PageSize != 0)
            {
                query.Paging.Start    = 0;
                query.Paging.PageSize = _config.V1Configurations.PageSize;
            }

            int assetCounter = 0;
            int assetTotal   = 0;

            do
            {
                QueryResult result = _dataAPI.Retrieve(query);
                assetTotal = result.TotalAvaliable;

                foreach (Asset asset in result.Assets)
                {
                    using (SqlCommand cmd = new SqlCommand())
                    {
                        //NAME NPI MASK:
                        object name = GetScalerValue(asset.GetAttribute(nameAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && name != DBNull.Value)
                        {
                            name = ExportUtils.RemoveNPI(name.ToString());
                        }

                        cmd.Connection  = _sqlConn;
                        cmd.CommandText = SQL;
                        cmd.CommandType = System.Data.CommandType.Text;
                        cmd.Parameters.AddWithValue("@AssetOID", asset.Oid.ToString());
                        cmd.Parameters.AddWithValue("@AssetState", GetScalerValue(asset.GetAttribute(assetStateAttribute)));
                        cmd.Parameters.AddWithValue("@OnMenu", GetScalerValue(asset.GetAttribute(onMenuAttribute)));
                        cmd.Parameters.AddWithValue("@URL", GetScalerValue(asset.GetAttribute(urlAttribute)));
                        cmd.Parameters.AddWithValue("@Name", name);
                        cmd.Parameters.AddWithValue("@Asset", GetSingleRelationValue(asset.GetAttribute(assetAttribute)));
                        cmd.ExecuteNonQuery();
                    }
                    assetCounter++;
                }
                query.Paging.Start = assetCounter;
            } while (assetCounter != assetTotal);
            return(assetCounter);
        }
        public override int Export()
        {
            IAssetType assetType = _metaAPI.GetAssetType("Defect");
            Query      query     = new Query(assetType);

            IAttributeDefinition assetStateAttribute = assetType.GetAttributeDefinition("AssetState");

            query.Selection.Add(assetStateAttribute);

            IAttributeDefinition assetNumberAttribute = assetType.GetAttributeDefinition("Number");

            query.Selection.Add(assetNumberAttribute);

            IAttributeDefinition timeboxAttribute = assetType.GetAttributeDefinition("Timebox");

            query.Selection.Add(timeboxAttribute);

            IAttributeDefinition verifiedByAttribute = assetType.GetAttributeDefinition("VerifiedBy");

            query.Selection.Add(verifiedByAttribute);

            IAttributeDefinition ownersAttribute = assetType.GetAttributeDefinition("Owners.ID");

            query.Selection.Add(ownersAttribute);

            IAttributeDefinition duplicateOfAttribute = assetType.GetAttributeDefinition("DuplicateOf");

            query.Selection.Add(duplicateOfAttribute);

            IAttributeDefinition teamAttribute = assetType.GetAttributeDefinition("Team");

            query.Selection.Add(teamAttribute);

            IAttributeDefinition versionsAttribute = assetType.GetAttributeDefinition("Versions.ID");

            query.Selection.Add(versionsAttribute);

            IAttributeDefinition goalsAttribute = assetType.GetAttributeDefinition("Goals.ID");

            query.Selection.Add(goalsAttribute);

            IAttributeDefinition affectedPrimaryWorkitemsAttribute = assetType.GetAttributeDefinition("AffectedPrimaryWorkitems.ID");

            query.Selection.Add(affectedPrimaryWorkitemsAttribute);

            IAttributeDefinition affectedByDefectsAttribute = assetType.GetAttributeDefinition("AffectedByDefects.ID");

            query.Selection.Add(affectedByDefectsAttribute);

            IAttributeDefinition superAttribute = assetType.GetAttributeDefinition("Super");

            query.Selection.Add(superAttribute);

            IAttributeDefinition descriptionAttribute = assetType.GetAttributeDefinition("Description");

            query.Selection.Add(descriptionAttribute);

            IAttributeDefinition nameAttribute = assetType.GetAttributeDefinition("Name");

            query.Selection.Add(nameAttribute);

            IAttributeDefinition referenceAttribute = assetType.GetAttributeDefinition("Reference");

            query.Selection.Add(referenceAttribute);

            IAttributeDefinition toDoAttribute = assetType.GetAttributeDefinition("ToDo");

            query.Selection.Add(toDoAttribute);

            IAttributeDefinition detailEstimateAttribute = assetType.GetAttributeDefinition("DetailEstimate");

            query.Selection.Add(detailEstimateAttribute);

            IAttributeDefinition orderAttribute = assetType.GetAttributeDefinition("Order");

            query.Selection.Add(orderAttribute);

            IAttributeDefinition estimateAttribute = assetType.GetAttributeDefinition("Estimate");

            query.Selection.Add(estimateAttribute);

            IAttributeDefinition foundInBuildAttribute = assetType.GetAttributeDefinition("FoundInBuild");

            query.Selection.Add(foundInBuildAttribute);

            IAttributeDefinition environmentAttribute = assetType.GetAttributeDefinition("Environment");

            query.Selection.Add(environmentAttribute);

            IAttributeDefinition resolutionAttribute = assetType.GetAttributeDefinition("Resolution");

            query.Selection.Add(resolutionAttribute);

            IAttributeDefinition versionAffectedAttribute = assetType.GetAttributeDefinition("VersionAffected");

            query.Selection.Add(versionAffectedAttribute);

            IAttributeDefinition fixedInBuildAttribute = assetType.GetAttributeDefinition("FixedInBuild");

            query.Selection.Add(fixedInBuildAttribute);

            IAttributeDefinition foundByAttribute = assetType.GetAttributeDefinition("FoundBy");

            query.Selection.Add(foundByAttribute);

            IAttributeDefinition scopeAttribute = assetType.GetAttributeDefinition("Scope");

            query.Selection.Add(scopeAttribute);

            IAttributeDefinition statusAttribute = assetType.GetAttributeDefinition("Status");

            query.Selection.Add(statusAttribute);

            IAttributeDefinition typeAttribute = assetType.GetAttributeDefinition("Type");

            query.Selection.Add(typeAttribute);

            IAttributeDefinition resolutionReasonAttribute = assetType.GetAttributeDefinition("ResolutionReason");

            query.Selection.Add(resolutionReasonAttribute);

            IAttributeDefinition sourceAttribute = assetType.GetAttributeDefinition("Source");

            query.Selection.Add(sourceAttribute);

            IAttributeDefinition priorityAttribute = assetType.GetAttributeDefinition("Priority");

            query.Selection.Add(priorityAttribute);

            IAttributeDefinition parentAttribute = assetType.GetAttributeDefinition("Parent");

            query.Selection.Add(parentAttribute);

            IAttributeDefinition requestsAttribute = assetType.GetAttributeDefinition("Requests.ID");

            query.Selection.Add(requestsAttribute);

            IAttributeDefinition blockingIssuesAttribute = assetType.GetAttributeDefinition("BlockingIssues.ID");

            query.Selection.Add(blockingIssuesAttribute);

            IAttributeDefinition issuesAttribute = assetType.GetAttributeDefinition("Issues.ID");

            query.Selection.Add(issuesAttribute);

            //Filter on parent scope.
            IAttributeDefinition parentScopeAttribute = assetType.GetAttributeDefinition("Scope.ParentMeAndUp");
            FilterTerm           term = new FilterTerm(parentScopeAttribute);

            term.Equal(_config.V1SourceConnection.Project);
            query.Filter = term;

            string SQL = BuildDefectInsertStatement();

            if (_config.V1Configurations.PageSize != 0)
            {
                query.Paging.Start    = 0;
                query.Paging.PageSize = _config.V1Configurations.PageSize;
            }

            int assetCounter = 0;
            int assetTotal   = 0;

            do
            {
                QueryResult result = _dataAPI.Retrieve(query);
                assetTotal = result.TotalAvaliable;

                foreach (Asset asset in result.Assets)
                {
                    using (SqlCommand cmd = new SqlCommand())
                    {
                        //NAME NPI MASK:
                        object name = GetScalerValue(asset.GetAttribute(nameAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && name != DBNull.Value)
                        {
                            name = ExportUtils.RemoveNPI(name.ToString());
                        }

                        //DESCRIPTION NPI MASK:
                        object description = GetScalerValue(asset.GetAttribute(descriptionAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && description != DBNull.Value)
                        {
                            description = ExportUtils.RemoveNPI(description.ToString());
                        }

                        //REFERENCE NPI MASK:
                        object reference = GetScalerValue(asset.GetAttribute(referenceAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && reference != DBNull.Value)
                        {
                            reference = ExportUtils.RemoveNPI(reference.ToString());
                        }

                        //FOUND IN BUILD NPI MASK:
                        object foundInBuild = GetScalerValue(asset.GetAttribute(foundInBuildAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && foundInBuild != DBNull.Value)
                        {
                            foundInBuild = ExportUtils.RemoveNPI(foundInBuild.ToString());
                        }

                        //ENVIRONMENT NPI MASK:
                        object environment = GetScalerValue(asset.GetAttribute(environmentAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && environment != DBNull.Value)
                        {
                            environment = ExportUtils.RemoveNPI(environment.ToString());
                        }

                        //RESOLUTION NPI MASK:
                        object resolution = GetScalerValue(asset.GetAttribute(resolutionAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && resolution != DBNull.Value)
                        {
                            resolution = ExportUtils.RemoveNPI(resolution.ToString());
                        }

                        //VERSION AFFECTED NPI MASK:
                        object versionAffected = GetScalerValue(asset.GetAttribute(versionAffectedAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && versionAffected != DBNull.Value)
                        {
                            versionAffected = ExportUtils.RemoveNPI(versionAffected.ToString());
                        }

                        //FIXED IN BUILD NPI MASK:
                        object fixedInBuild = GetScalerValue(asset.GetAttribute(fixedInBuildAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && fixedInBuild != DBNull.Value)
                        {
                            fixedInBuild = ExportUtils.RemoveNPI(fixedInBuild.ToString());
                        }

                        //FOUND BY NPI MASK:
                        object foundBy = GetScalerValue(asset.GetAttribute(foundByAttribute));
                        if (_config.V1Configurations.UseNPIMasking == true && foundBy != DBNull.Value)
                        {
                            foundBy = ExportUtils.RemoveNPI(foundBy.ToString());
                        }

                        cmd.Connection  = _sqlConn;
                        cmd.CommandText = SQL;
                        cmd.CommandType = System.Data.CommandType.Text;
                        cmd.Parameters.AddWithValue("@AssetOID", asset.Oid.ToString());
                        cmd.Parameters.AddWithValue("@AssetState", CheckDefectState(asset.GetAttribute(assetStateAttribute)));
                        cmd.Parameters.AddWithValue("@AssetNumber", GetScalerValue(asset.GetAttribute(assetNumberAttribute)));
                        cmd.Parameters.AddWithValue("@Timebox", GetSingleRelationValue(asset.GetAttribute(timeboxAttribute)));
                        cmd.Parameters.AddWithValue("@VerifiedBy", GetSingleRelationValue(asset.GetAttribute(verifiedByAttribute)));
                        cmd.Parameters.AddWithValue("@Owners", GetMultiRelationValues(asset.GetAttribute(ownersAttribute)));
                        cmd.Parameters.AddWithValue("@DuplicateOf", GetSingleRelationValue(asset.GetAttribute(duplicateOfAttribute)));
                        cmd.Parameters.AddWithValue("@Team", GetSingleRelationValue(asset.GetAttribute(teamAttribute)));
                        cmd.Parameters.AddWithValue("@Versions", GetMultiRelationValues(asset.GetAttribute(versionsAttribute)));
                        cmd.Parameters.AddWithValue("@Goals", GetMultiRelationValues(asset.GetAttribute(goalsAttribute)));
                        cmd.Parameters.AddWithValue("@AffectedPrimaryWorkitems", GetMultiRelationValues(asset.GetAttribute(affectedPrimaryWorkitemsAttribute)));
                        cmd.Parameters.AddWithValue("@AffectedByDefects", GetMultiRelationValues(asset.GetAttribute(affectedByDefectsAttribute)));
                        cmd.Parameters.AddWithValue("@Super", GetSingleRelationValue(asset.GetAttribute(superAttribute)));
                        cmd.Parameters.AddWithValue("@Description", description);
                        cmd.Parameters.AddWithValue("@Name", name);
                        cmd.Parameters.AddWithValue("@Reference", reference);
                        cmd.Parameters.AddWithValue("@ToDo", GetScalerValue(asset.GetAttribute(toDoAttribute)));
                        cmd.Parameters.AddWithValue("@DetailEstimate", GetScalerValue(asset.GetAttribute(detailEstimateAttribute)));
                        cmd.Parameters.AddWithValue("@Order", GetScalerValue(asset.GetAttribute(orderAttribute)));
                        cmd.Parameters.AddWithValue("@Estimate", GetScalerValue(asset.GetAttribute(estimateAttribute)));
                        cmd.Parameters.AddWithValue("@FoundInBuild", foundInBuild);
                        cmd.Parameters.AddWithValue("@Environment", environment);
                        cmd.Parameters.AddWithValue("@Resolution", resolution);
                        cmd.Parameters.AddWithValue("@VersionAffected", versionAffected);
                        cmd.Parameters.AddWithValue("@FixedInBuild", fixedInBuild);
                        cmd.Parameters.AddWithValue("@FoundBy", foundBy);
                        cmd.Parameters.AddWithValue("@Scope", GetSingleRelationValue(asset.GetAttribute(scopeAttribute)));
                        cmd.Parameters.AddWithValue("@Status", GetSingleRelationValue(asset.GetAttribute(statusAttribute)));
                        cmd.Parameters.AddWithValue("@Type", GetSingleRelationValue(asset.GetAttribute(typeAttribute)));
                        cmd.Parameters.AddWithValue("@ResolutionReason", GetSingleRelationValue(asset.GetAttribute(resolutionReasonAttribute)));
                        cmd.Parameters.AddWithValue("@Source", GetSingleRelationValue(asset.GetAttribute(sourceAttribute)));
                        cmd.Parameters.AddWithValue("@Priority", GetSingleRelationValue(asset.GetAttribute(priorityAttribute)));
                        cmd.Parameters.AddWithValue("@Parent", GetSingleRelationValue(asset.GetAttribute(parentAttribute)));
                        cmd.Parameters.AddWithValue("@Requests", GetMultiRelationValues(asset.GetAttribute(requestsAttribute)));
                        cmd.Parameters.AddWithValue("@BlockingIssues", GetMultiRelationValues(asset.GetAttribute(blockingIssuesAttribute)));
                        cmd.Parameters.AddWithValue("@Issues", GetMultiRelationValues(asset.GetAttribute(issuesAttribute)));
                        cmd.ExecuteNonQuery();
                    }
                    assetCounter++;
                }
                query.Paging.Start = assetCounter;
            } while (assetCounter != assetTotal);

            if (_config.V1Configurations.MigrateTemplates == false)
            {
                DeleteDefectTemplates();
            }

            return(assetCounter);
        }