private void OnInterval(object pubobj) {
            try {
                var bugs = bugzillaReader.GetBugs();

                if (bugs.Count > 0) {
                    logger.Log(string.Format("Found {0} issues in Bugzilla to create in VersionOne.", bugs.Count));
                }

                foreach (var bug in bugs) {
                    bug.ExternalSystemName = sourceFieldValue;
                    eventManager.Publish(bug);
                }

                var source = new ClosedWorkitemsSource(sourceFieldValue);
                eventManager.Publish(source);
            } catch (Exception ex) {
                logger.Log(LogMessage.SeverityType.Error, "Error getting Issues from Bugzilla:");
                logger.Log(LogMessage.SeverityType.Error, ex.ToString());
            }
        }
コード例 #2
0
        /// <summary>
        /// Timer interval on which to poll JIRA. See app config file for time in milliseconds.
        /// </summary>
        /// <param name="pubobj">Not used</param>
        private void OnInterval(object pubobj)
        {
            for (int i = 0; i < 5; i++ )
                logger.Log(string.Empty);

            logger.Log(LogMessage.SeverityType.Info, "-------  Starting processing... -------\n\n");

            if (jiraConfig.UpdateWorkitemFilter.Enabled) {
                logger.Log(LogMessage.SeverityType.Info, "------- Synchronization -------");

                List<Workitem> workitemsForUpdate = new List<Workitem>();

                try {
                    logger.Log(LogMessage.SeverityType.Info, "Getting issues from JIRA.");

                    var lastQueryTime = profile.LastQueryForModifiedItems;
                    var issues = jiraProcessor.GetIssues<Defect>(jiraConfig.UpdateWorkitemFilter.Id);

                    if (issues.Count > 0) {
                        logger.Log(string.Format("Found {0} defects in JIRA that came from VersionOne. We will filter issues modified after {1}", issues.Count, lastQueryTime));
                    }

                    DateTime theNewestItem = lastQueryTime;
                    foreach (var issue in issues) {
                        var modificationTime = issue.Updated.Value;

                        if (modificationTime > lastQueryTime) {
                            logger.Log(LogMessage.SeverityType.Info, string.Format("\tissue {0} was modified on {1} and will be processed", issue.ExternalId, issue.Updated.Value));

                            issue.ExternalSystemName = sourceFieldValue;
                            workitemsForUpdate.Add(issue);

                            if (modificationTime > theNewestItem) {
                                logger.Log(LogMessage.SeverityType.Debug, string.Format("\tissue {0} is possibly the newsest one in this query", issue.ExternalId));
                                theNewestItem = modificationTime;
                            }
                        } else {
                            logger.Log(LogMessage.SeverityType.Debug, string.Format("\tskipping issue {0} since it was modified earlier than last query", issue.ExternalId));
                        }
                    }

                    if (theNewestItem > lastQueryTime) {
                        logger.Log(LogMessage.SeverityType.Debug, string.Format("Setting last query time to {0}", theNewestItem));
                        profile.LastQueryForModifiedItems = theNewestItem;
                    }

                    var itemsOpenInJira = new WorkitemsToUpdate(workitemsForUpdate, sourceFieldValue);
                    eventManager.Publish(itemsOpenInJira);
                } catch (Exception ex) {
                    logger.Log(LogMessage.SeverityType.Error, string.Format("Error getting Issues for update from JIRA: {0}", ex.Message));
                    return;
                }
            }

            logger.Log(LogMessage.SeverityType.Info, "------- Create New Workitems from Jira -------");

            IList<Workitem> workitems = new List<Workitem>();
            try {
                logger.Log(LogMessage.SeverityType.Info, "Getting issues from JIRA.");

                if (jiraConfig.OpenDefectFilter.Enabled) {
                    var bugs = jiraProcessor.GetIssues<Defect>(jiraConfig.OpenDefectFilter.Id);

                    if (bugs.Count > 0) {
                        logger.Log(string.Format("Found {0} defects in JIRA to create in VersionOne.", bugs.Count));
                    }

                    foreach (var bug in bugs) {
                        workitems.Add(bug);
                    }
                }

                if (jiraConfig.OpenStoryFilter.Enabled) {
                    var stories = jiraProcessor.GetIssues<Story>(jiraConfig.OpenStoryFilter.Id);

                    if (stories.Count > 0) {
                        logger.Log(string.Format("Found {0} stories in JIRA to create in VersionOne.", stories.Count));
                    }

                    foreach (var story in stories) {
                        workitems.Add(story);
                    }
                }

            } catch (Exception ex) {
                logger.Log(LogMessage.SeverityType.Error, string.Format("Error getting Issues from JIRA: {0}", ex.Message));
                return;
            }

            logger.Log(LogMessage.SeverityType.Info, "Checking JIRA issues for duplicates.");
            workitems = workitems.Distinct().ToList();

            foreach(var item in workitems) {
                item.ExternalSystemName = sourceFieldValue;
                eventManager.Publish(item);
            }

            logger.Log(LogMessage.SeverityType.Info, "------- Close JIRA bugs (that were closed in VersionOne) -------");
            var sourceClosed = new ClosedWorkitemsSource(sourceFieldValue);
            eventManager.Publish(sourceClosed);

            logger.Log(LogMessage.SeverityType.Info, "------- Push VersionOne defects to JIRA -------");
            var v1scopes = GetV1ScopesFromMappings();
            var sourceCreated = new CreatedWorkitemsSource(v1scopes);
            eventManager.Publish(sourceCreated);

            logger.Log(LogMessage.SeverityType.Info, "------- Processing finished. ------- ");
        }
        private void OnInterval(object pubobj) {
            IList<Defect> bugs;

            try {
                // Get defects from ClearQuest
                bugs = clearQuestReader.GetDefects();
            } catch(Exception ex) {
                logger.Log(LogMessage.SeverityType.Error, "Error getting Defects from ClearQuest:");
                logger.Log(LogMessage.SeverityType.Error, ex.ToString());
                return;
            }

            if(bugs.Count > 0) {
                logger.Log(string.Format("Found {0} issues in ClearQuest to create in VersionOne.", bugs.Count));
            }

            // Create Defects in V1 
            foreach(var bug in bugs) {
                eventManager.Publish(bug);
            }

            // Query VersionOne for Closed defects with a ClearQuest Source Id
            var source = new ClosedWorkitemsSource(clearQuestConfig.SourceFieldValue);
            eventManager.Publish(source);
        }
コード例 #4
0
        /// <summary>
        /// Timer interval on which to poll JIRA. See app config file for time in milliseconds.
        /// </summary>
        /// <param name="pubobj">Not used</param>
        private void OnInterval(object pubobj)
        {
            logger.Log(LogMessage.SeverityType.Info, "Starting processing...");
            IList<Workitem> workitems = new List<Workitem>();

            try
            {
                logger.Log(LogMessage.SeverityType.Info, "Getting issues from JIRA.");

                if (jiraConfig.OpenDefectFilter.Enabled)
                {
                    var bugs = jiraProcessor.GetIssues<Defect>(jiraConfig.OpenDefectFilter.Id);

                    if (bugs.Count > 0)
                    {
                        logger.Log(string.Format("Found {0} defects in JIRA to create in VersionOne.", bugs.Count));
                    }

                    foreach (var bug in bugs)
                    {
                        workitems.Add(bug);
                    }
                }

                if (jiraConfig.OpenStoryFilter.Enabled)
                {
                    var stories = jiraProcessor.GetIssues<Story>(jiraConfig.OpenStoryFilter.Id);

                    if (stories.Count > 0)
                    {
                        logger.Log(string.Format("Found {0} stories in JIRA to create in VersionOne.", stories.Count));
                    }

                    foreach (var story in stories)
                    {
                        workitems.Add(story);
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Log(LogMessage.SeverityType.Error, string.Format("Error getting Issues from JIRA: {0}", ex.Message));
                return;
            }

            logger.Log(LogMessage.SeverityType.Info, "Checking JIRA issues for duplicates.");
            workitems = workitems.Distinct().ToList();

            // Create Workitem in V1 
            foreach (var item in workitems)
            {
                item.ExternalSystemName = jiraConfig.SourceFieldValue;
                eventManager.Publish(item);
            }

            // Query VersionOne for Closed defects with a JIRA Source Id
            var source = new ClosedWorkitemsSource(jiraConfig.SourceFieldValue, VersionOneProcessor.PrimaryWorkitemType);
            eventManager.Publish(source);

            logger.Log(LogMessage.SeverityType.Info, "Processing finished.");
        }