コード例 #1
0
        public void Handle(ImportBugToTargetProcessCommand <BugzillaBug> message)
        {
            Data.ThirdPartyBug = message.ThirdPartyBug;

            var tpBug = ConvertToTpBug(message);

            var storedBug = _bugzillaInfoStorageRepository.GetTargetProcessBugId(message.ThirdPartyBug.bug_id);

            if (storedBug == null)
            {
                _logger.InfoFormat("Importing bug. {0}", message.ThirdPartyBug.ToString());
                Send(new CreateBugCommand(tpBug.BugDto));
                Data.CreatingBug = true;
            }
            else
            {
                _logger.InfoFormat("Updating bug. {0}", message.ThirdPartyBug.ToString());
                tpBug.BugDto.ID = storedBug.Value;
                Send(new UpdateBugCommand(tpBug.BugDto)
                {
                    ChangedFields = tpBug.ChangedFields.ToArray()
                });
                // We will not receive BugUpdatedMessage if no fields were changed. So we should process related entities immediately.
                SendLocal(new ExistingBugImportedToTargetProcessMessage <BugzillaBug> {
                    TpBugId = tpBug.BugDto.ID, ThirdPartyBug = Data.ThirdPartyBug
                });

                _bugzillaInfoStorageRepository.SaveBugzillaBugInfo(tpBug.BugDto.ID, new BugzillaBugInfo(message.ThirdPartyBug)
                {
                    TpId = tpBug.BugDto.ID
                });
            }
        }
コード例 #2
0
        private ConvertedBug ConvertToTpBug(ImportBugToTargetProcessCommand <BugzillaBug> message)
        {
            var converter = ObjectFactory.GetInstance <IBugConverter <BugzillaBug> >();
            var tpBug     = new ConvertedBug {
                BugDto = { ProjectID = StorageRepository().GetProfile <BugzillaProfile>().Project }
            };

            converter.Apply(message.ThirdPartyBug, tpBug);
            return(tpBug);
        }