コード例 #1
0
        } // end of GetUniqueInstallationId

        /// <summary>
        /// Returns the set of internal field maps which has to be imposed for all the entities..
        /// Used for internal purpose.. in case user already defines some field maps, this will be superseeded
        /// with that
        /// </summary>
        /// <param name="fldMaps"></param>
        /// <returns></returns>
        private static FieldMapsFieldMap[] GetInternalFieldMaps(FieldMaps fldMaps)
        {
            // add the pre defined field mappings for history items
            FieldMapsFieldMap[] newFldMaps = new FieldMapsFieldMap[fldMaps.FieldMap.Length + CQConstants.InternalMap.Count];
            int currindex = 0;

            foreach (KeyValuePair <string, string> map in CQConstants.InternalMap)
            {
                FieldMapsFieldMap newMap = new FieldMapsFieldMap();
                newMap.from = map.Key;
                newMap.to   = map.Value;

                if (currindex < CQConstants.NoOfUserFldsInInternalMap)
                {
                    // add the User Map section
                    newMap.ValueMaps              = new FieldMapsFieldMapValueMaps();
                    newMap.ValueMaps.refer        = CQConstants.UserMapXMLValue;
                    newMap.ValueMaps.defaultValue = Environment.UserName;
                }

                // add from the end
                newFldMaps[newFldMaps.Length - currindex - 1] = newMap;
                currindex++;
            }

            return(newFldMaps);
        }
コード例 #2
0
        public ProcessingStatus Run()
        {
            Telemetry.TrackEvent("EngineStart",
                                 new Dictionary <string, string> {
                { "Engine", "Migration" }
            },
                                 new Dictionary <string, double> {
                { "Processors", Processors.Count },
                { "Mappings", FieldMaps.Count }
            });
            Stopwatch engineTimer = Stopwatch.StartNew();

            LoggingLevelSwitch logLevel = _services.GetRequiredService <LoggingLevelSwitch>();

            logLevel.MinimumLevel = Config.LogLevel;
            Log.Information("Logging has been configured and is set to: {LogLevel}. ", Config.LogLevel.ToString());
            Log.Information("                              Max Logfile: {FileLogLevel}. ", "Verbose");
            Log.Information("                              Max Console: {ConsoleLogLevel}. ", "Debug");
            Log.Information("                 Max Application Insights: {AILogLevel}. ", "Error");
            Log.Information("The Max log levels above show where to go look for extra info. e.g. Even if you set the log level to Verbose you will only see that info in the Log File, however everything up to Debug will be in the Console.");

            ProcessingStatus ps = ProcessingStatus.Running;

            Processors.EnsureConfigured();
            TypeDefinitionMaps.EnsureConfigured();
            GitRepoMaps.EnsureConfigured();
            ChangeSetMapps.EnsureConfigured();
            FieldMaps.EnsureConfigured();

            Log.Information("Beginning run of {ProcessorCount} processors", Processors.Count.ToString());
            foreach (_EngineV1.Containers.IProcessor process in Processors.Items)
            {
                Log.Information("Processor: {ProcessorName}", process.Name);
                Stopwatch processorTimer = Stopwatch.StartNew();
                process.Execute();
                processorTimer.Stop();
                Telemetry.TrackEvent("ProcessorComplete", new Dictionary <string, string> {
                    { "Processor", process.Name }, { "Status", process.Status.ToString() }
                }, new Dictionary <string, double> {
                    { "ProcessingTime", processorTimer.ElapsedMilliseconds }
                });

                if (process.Status == ProcessingStatus.Failed)
                {
                    ps = ProcessingStatus.Failed;
                    Log.Error("{Context} The Processor {ProcessorName} entered the failed state...stopping run", process.Name, "MigrationEngine");
                    break;
                }
            }
            engineTimer.Stop();
            Telemetry.TrackEvent("EngineComplete",
                                 new Dictionary <string, string> {
                { "Engine", "Migration" }
            },
                                 new Dictionary <string, double> {
                { "EngineTime", engineTimer.ElapsedMilliseconds }
            });
            return(ps);
        }
コード例 #3
0
        /// <summary>
        /// Constructor for VSTS work Item Helper
        /// </summary>
        /// <param name="conn">Team Foundation Connection</param>
        /// <param name="witName">Work Item Type Name</param>
        /// <param name="maps">Field Maps reference</param>
        /// <param name="userMap">User Maps refernce</param>
        /// <param name="sourceConvIndex">Source Converter Index</param>
        public VSTSWorkItemHelper(VSTSConnection conn,
                                  string witName,
                                  FieldMaps maps,
                                  UserMappings userMap,
                                  int sourceConvIndex,
                                  string fieldMapFile)
        {
            m_vstsConnection = conn;
            m_maps           = maps;
            m_witName        = witName;
            m_userMappings   = userMap;
            m_fieldMapFile   = fieldMapFile;

            // validate the field mappings
            ValidateFieldMaps();

            // build the field mappings
            BuildFieldMappings();

            CurClient.WorkItemType witType = m_vstsConnection.GetWorkItemType(m_witName);

            m_convSourceIndex = sourceConvIndex;

            // Check if the Duplicate WI ID is used by CQ!
            if (witType.FieldDefinitions.Contains(m_duplicateWiId) &&
                !m_fieldMappings.Contains(m_duplicateWiId))
            {
                m_canSetDuplicateWiId = true;
            }

            m_wi = CreateNewWorkItem();

            // prepare intial work item snapshot with all required and available field values
            foreach (string reqField in m_requiredFieldsForCreatingWI)
            {
                Field fld = m_wi.Fields[reqField];
                Debug.Assert(fld != null, "Null handle for core field while preparing initial snapshot");
                if (fld != null)
                {
                    Logger.Write(LogSource.WorkItemTracking, TraceLevel.Verbose, "Base WI Snapshot - Field [{0}], Value [{1}]", fld.ReferenceName, fld.Value);
                    m_baseWiSnapShot.Add(fld.ReferenceName, fld.Value);
                }
            }

            m_baseWiSnapShot.Add(VSTSConstants.CreatedDateFieldRefName, VSTSConstants.CurrentDate);
            m_baseWiSnapShot.Add(VSTSConstants.CreatedByFieldRefName, "Converter");

            m_MigStatusField = m_wi.Fields[m_migrationStatusFieldName];
            VSTSConstants.MigrationStatusField = m_MigStatusField.ReferenceName;

            // initialize web service URI's
            WSHelper.SetupProxy(conn.Tfs.Name);
        }
コード例 #4
0
        public ProcessingStatus Run()
        {
            Telemetry.TrackEvent("EngineStart",
                                 new Dictionary <string, string> {
                { "Engine", "Migration" }
            },
                                 new Dictionary <string, double> {
                { "Processors", Processors.Count },
                { "Mappings", FieldMaps.Count }
            });
            Stopwatch engineTimer = Stopwatch.StartNew();

            ProcessingStatus ps = ProcessingStatus.Running;

            Processors.EnsureConfigured();
            TypeDefinitionMaps.EnsureConfigured();
            GitRepoMaps.EnsureConfigured();
            ChangeSetMapps.EnsureConfigured();
            FieldMaps.EnsureConfigured();

            Log.Information("Beginning run of {ProcessorCount} processors", Processors.Count.ToString());
            foreach (IProcessor process in Processors.Items)
            {
                Log.Information("Processor: {ProcessorName}", process.Name);
                Stopwatch processorTimer = Stopwatch.StartNew();
                process.Execute();
                processorTimer.Stop();
                Telemetry.TrackEvent("ProcessorComplete", new Dictionary <string, string> {
                    { "Processor", process.Name }, { "Status", process.Status.ToString() }
                }, new Dictionary <string, double> {
                    { "ProcessingTime", processorTimer.ElapsedMilliseconds }
                });

                if (process.Status == ProcessingStatus.Failed)
                {
                    ps = ProcessingStatus.Failed;
                    Log.Error("{Context} The Processor {ProcessorName} entered the failed state...stopping run", process.Name, "MigrationEngine");
                    break;
                }
            }
            engineTimer.Stop();
            Telemetry.TrackEvent("EngineComplete",
                                 new Dictionary <string, string> {
                { "Engine", "Migration" }
            },
                                 new Dictionary <string, double> {
                { "EngineTime", engineTimer.ElapsedMilliseconds }
            });
            return(ps);
        }
コード例 #5
0
        private void CompareFieldMappings(Guid sessionUniqueId, FieldMaps newFieldMaps, FieldMaps currFieldMaps)
        {
            if (newFieldMaps.FieldMap.Count != currFieldMaps.FieldMap.Count)
            {
                SetImpactForSessionChange(sessionUniqueId);
                return;
            }

            bool fieldMappingFound = true;

            foreach (var fieldMap in newFieldMaps.FieldMap)
            {
                var query = currFieldMaps.FieldMap.Where(f =>
                                                         f.name == fieldMap.name &&
                                                         f.AggregatedFields.FieldsAggregationGroup.Count == fieldMap.AggregatedFields.FieldsAggregationGroup.Count &&
                                                         f.MappedFields.MappedField.Count == fieldMap.MappedFields.MappedField.Count);

                if (query.Count() == 0)
                {
                    fieldMappingFound = false;
                    break;
                }

                if (!CompareAggregatedFields(fieldMap.AggregatedFields, query.First().AggregatedFields) ||
                    !CompareMappedFields(fieldMap.MappedFields, query.First().MappedFields))
                {
                    fieldMappingFound = false;
                    break;
                }
            }

            if (!fieldMappingFound)
            {
                SetImpactForSessionChange(sessionUniqueId);
            }
        }
コード例 #6
0
ファイル: FieldMapBase.cs プロジェクト: shekar348/1PointOne
        /// <summary>
        /// Populates the fields for multiple objects from the columns found in an open reader.
        /// </summary>
        ///
        /// <param name="rdr" type="IDataReader">An object that implements the IDataReader interface</param>
        ///
        /// <returns>Object of FieldMaps</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			11/21/2009 4:19:24 PM		Created function
        /// 
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        internal static FieldMaps PopulateObjectsFromReaderWithCheckingReader(IDataReader rdr, DatabaseHelper oDatabaseHelper, string ConnectionString)
        {
            FieldMaps list = new FieldMaps();

            if (rdr.Read())
            {
                FieldMap obj = new FieldMap(ConnectionString);
                PopulateObjectFromReader(obj, rdr);
                list.Add(obj);
                while (rdr.Read())
                {
                    obj = new FieldMap(ConnectionString);
                    PopulateObjectFromReader(obj, rdr);
                    list.Add(obj);
                }
                oDatabaseHelper.Dispose();
                return list;
            }
            else
            {
                oDatabaseHelper.Dispose();
                return null;
            }
        }
コード例 #7
0
ファイル: FieldMapBase.cs プロジェクト: shekar348/1PointOne
        /// <summary>
        /// Populates the fields for multiple objects from the columns found in an open reader.
        /// </summary>
        ///
        /// <param name="rdr" type="IDataReader">An object that implements the IDataReader interface</param>
        ///
        /// <returns>Object of FieldMaps</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			11/21/2009 4:19:24 PM		Created function
        /// 
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        internal static FieldMaps PopulateObjectsFromReader(IDataReader rdr, string ConnectionString)
        {
            FieldMaps list = new FieldMaps();

            while (rdr.Read())
            {
                FieldMap obj = new FieldMap(ConnectionString);
                PopulateObjectFromReader(obj,rdr);
                list.Add(obj);
            }
            return list;
        }
コード例 #8
0
ファイル: FieldMapBase.cs プロジェクト: shekar348/1PointOne
        /// <summary>
        /// This method will get row(s) from the database using the value of the field specified 
        /// along with the details of the child table.
        /// </summary>
        ///
        /// <param name="pk" type="ImportJobPrimaryKey">Primary Key information based on which data is to be fetched.</param>
        ///
        /// <returns>object of class FieldMaps</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			11/21/2009 4:19:24 PM				Created function
        /// 
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        public static FieldMaps SelectAllByForeignKeyFromImportJob(ImportJobPrimaryKey pk, String ConnectionString)
        {
            DatabaseHelper oDatabaseHelper = new DatabaseHelper(ConnectionString);
            bool ExecutionState = false;
            FieldMaps obj = null;

            // Pass the values of all key parameters to the stored procedure.
            System.Collections.Specialized.NameValueCollection nvc = pk.GetKeysAndValues();
            foreach (string key in nvc.Keys)
            {
                oDatabaseHelper.AddParameter("@" + key,nvc[key] );
            }

            // The parameter '@ErrorCode' will contain the status after execution of the stored procedure.
            oDatabaseHelper.AddParameter("@ErrorCode", -1, System.Data.ParameterDirection.Output);

            IDataReader dr=oDatabaseHelper.ExecuteReader("sp_FieldMap_SelectAllByForeignKeyImportJob", ref ExecutionState);
            obj = new FieldMaps();
            obj = FieldMap.PopulateObjectsFromReaderWithCheckingReader(dr, oDatabaseHelper,ConnectionString);

            dr.Close();
            oDatabaseHelper.Dispose();
            return obj;
        }
コード例 #9
0
        } // end of FindAllowedEntitiesToMigrate

        /// <summary>
        /// Validate all the Entity Types on Clear Quest
        /// Followed by the respective Field Mappings
        /// </summary>
        /// <returns>true if successful, false in case of some error</returns>
        private void ValidateSchemaMapOnCQ()
        {
            Session cqSession = m_cqConnection.GetUserSession();

            object[] cqEntities = (object[])CQWrapper.GetSubmitEntityDefNames(cqSession);
            Display.NewLine();

            foreach (SchemaMapping schMap in m_convParams.SchemaMaps)
            {
                string infoMsg = UtilityMethods.Format(CQResource.SchemaValidation, schMap.WITDFile);
                Logger.Write(LogSource.CQ, TraceLevel.Verbose, infoMsg);

                bool entityFoundInCQ = false;
                foreach (object obj in cqEntities)
                {
                    if (schMap.entity.Equals(obj.ToString(), StringComparison.OrdinalIgnoreCase))
                    {
                        entityFoundInCQ = true;
                        break;
                    }
                }

                if (!entityFoundInCQ)
                {
                    try
                    {
                        Display.StartProgressDisplay(infoMsg);
                        string errMsg = UtilityMethods.Format(CQResource.CQ_ENTITY_NOT_EXIST,
                                                              CurConResource.Analysis,
                                                              schMap.entity,
                                                              Path.GetFileName(m_convParams.SchemaMapFile));

                        PostMigrationReport.WriteIssue(null, null, RepStatus.Failed,
                                                       ReportIssueType.Critical, String.Empty,
                                                       schMap.entity, IssueGroup.Witd, errMsg);

                        throw new ConverterException(errMsg);
                    }
                    finally
                    {
                        Display.StopProgressDisplay();
                    }
                }
                else
                {
                    OAdEntityDef currEntityDef = CQWrapper.GetEntityDef(cqSession, schMap.entity);
                    // can validate the fields at CQ also, for this entity
                    string fieldMapFile = schMap.fieldMapFile;
                    if (fieldMapFile != null)
                    {
                        UtilityMethods.ValidateFile(fieldMapFile, schMap.schemaMapFile);
                        FieldMaps fldMaps = WITFieldMappings.CreateFromFile(fieldMapFile);
                        ValidateFieldMapOnCQ(currEntityDef, fldMaps.FieldMap, fieldMapFile);

                        // add the predefined/internal field maps
                        FieldMapsFieldMap[] internalFldMaps = GetInternalFieldMaps(fldMaps);

                        fldMaps.FieldMap.CopyTo(internalFldMaps, 0);
                        fldMaps.FieldMap = internalFldMaps;

                        // add the loaded field map in Schema Field Map for future use
                        m_schemaFieldMap.Add(schMap.entity, fldMaps);
                    }
                }
            } // end of foreach SchemaMappings
        }     // end of ValidateSchemaMapOnCQ
コード例 #10
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            expanderGrid.Visibility = Visibility.Collapsed;
            errorMessage.Content    = "";
            var credential = CredentialManager.Instance.Credentials.FirstOrDefault(x => x?.BaseURL == Config.BaseURL);

            if (credential == null)
            {
                errorMessage.Content = $"No credentials exists for that URL";
                return;
            }
            var jira         = new Jira(Config.BaseURL, credential.Username, credential.Password);
            var issueService = jira.GetIssueService();
            var fieldService = jira.GetFieldService();

            try
            {
                errorMessage.Content = $"Attempting connection...";
                issues = issueService.Search(Config.JQLFilter);
                var fields = fieldService.GetFields();
                Dictionary <string, FieldMapViewModel> fieldMaps = new Dictionary <string, FieldMapViewModel>();
                foreach (var issue in issues)
                {
                    var properties      = ((JObject)issue.InternalObject.SelectTokens("$").First()).Properties().Where(x => x.Value is JValue);
                    var fieldsContainer = issue.InternalObject.SelectToken("$.fields") as JObject;
                    var issueFields     = fieldsContainer.Properties();
                    foreach (var prop in properties)
                    {
                        if (!fieldMaps.ContainsKey(prop.Path))
                        {
                            fieldMaps.Add(prop.Path, new FieldMapViewModel {
                                DisplayedName = prop.Name, JiraJSONPath = prop.Path, Map = false, ToscaFields = toscaFields, ExampleValues = new HashSet <string>()
                            });
                        }
                        fieldMaps[prop.Path].ExampleValues.Add(prop.Value.ToString());
                    }
                    foreach (var issueField in issueFields)
                    {
                        var    field     = fields.FirstOrDefault(x => x.id == issueField.Name);
                        string fieldName = (field != null ? field.name : issueField.Name);
                        if (issueField.Value is JValue)
                        {
                            if (!fieldMaps.ContainsKey(issueField.Path))
                            {
                                fieldMaps.Add(issueField.Path, new FieldMapViewModel
                                {
                                    DisplayedName = fieldName,
                                    ExampleValues = new HashSet <string>(),
                                    JiraJSONPath  = issueField.Path,
                                    Map           = false,
                                    ToscaFields   = toscaFields
                                });
                            }
                            fieldMaps[issueField.Path].ExampleValues.Add(issueField.Value.ToString());
                        }
                        else
                        {
                            JObject fieldValue = issueField.Value as JObject;
                            if (fieldValue == null || fieldValue.Properties() == null)
                            {
                                continue;
                            }
                            var fieldValueProps = fieldValue.Properties().Where(x => x.Value is JValue);
                            foreach (var fieldValueProp in fieldValueProps)
                            {
                                if (!fieldMaps.ContainsKey(fieldValueProp.Path))
                                {
                                    fieldMaps.Add(fieldValueProp.Path, new FieldMapViewModel
                                    {
                                        DisplayedName = $"{fieldName} -> {fieldValueProp.Name}",
                                        ExampleValues = new HashSet <string>(),
                                        JiraJSONPath  = fieldValueProp.Path,
                                        Map           = false,
                                        ToscaFields   = toscaFields
                                    });
                                }
                                fieldMaps[fieldValueProp.Path].ExampleValues.Add(fieldValueProp.Value.ToString());
                            }
                        }
                    }
                }
                foreach (var map in fieldMaps.OrderBy(x => x.Value.DisplayedName))
                {
                    if (Config.Config.parentLocatorPropertyOverride == map.Value.JiraJSONPath)
                    {
                        map.Value.ParentLocator = true;
                    }
                    FieldMaps.Add(map.Value);
                }
                foreach (var configMap in Config.Config.fieldMaps)
                {
                    if (FieldMaps.Any(x => x.JiraJSONPath == configMap.jiraJsonPath))
                    {
                        var matchingFM = FieldMaps.First(x => x.JiraJSONPath == configMap.jiraJsonPath);
                        matchingFM.Map        = true;
                        matchingFM.ToscaField = configMap.toscaField;
                    }
                }
                errorMessage.Content    = $"Success - {issues.Length} issues match";
                expanderGrid.Visibility = Visibility.Visible;
            }
            catch (Exception ex)
            {
                errorMessage.Content = $"Error: {ex.Message}";
            }
        }