Example #1
0
 public ReleaseController(VersioningService versioningService, ValidationResultRepositiory repository, ValidationResultFactory factory, CheckModeDescriptorFactory descriptorFactory)
 {
     _versioningService   = versioningService;
     _repository          = repository;
     _factory             = factory;
     _checkModeDescriptor = descriptorFactory.GetDescriptorFor(CheckMode.Release);
 }
Example #2
0
        public void Publish(DeployConfigurationModel deployConfiguration, TelemetryWrapper telemetry, string singleResourceName, string project, string projectPath, string basePath)
        {
            try
            {
                Action <string> reportAction        = (m) => { ReportProgress?.Invoke(this, m); };
                var             context             = new XrmService(deployConfiguration.DynamicsSettings, deployConfiguration.Solution, telemetry, reportAction);
                var             sourceControl       = new VersioningService(projectPath, basePath, deployConfiguration.Branch, reportAction, telemetry);
                var             sourceControlResult = sourceControl.QueryLocalRepository();

                // Must resolve conflicts or something went wrong with TFS interaction
                if (!sourceControlResult.Continue && sourceControlResult.Changes == null)
                {
                    return;
                }

                var changeList = sourceControlResult.Changes;
                if (!string.IsNullOrEmpty(singleResourceName))
                {
                    var filteredChangeList = sourceControlResult.Changes.Where(x => x.FileName.Equals(singleResourceName)).ToArray();
                    changeList = filteredChangeList;
                }

                PublishImpl(context, sourceControl, deployConfiguration, telemetry, changeList, project);
            }
            catch (Exception exception)
            {
                ReportProgress?.Invoke(this, $"[ERROR] => {exception.Message}\n");
                if (!(exception is ToolkitException))
                {
                    telemetry.TrackExceptionWithCustomMetrics(exception);
                }
            }
        }
 public ManualWithAccountController(VersioningService versioningService, ValidationResultRepositiory repositiory, ValidationResultFactory factory, CheckModeDescriptorFactory descriptorFactory)
 {
     _versioningService = versioningService;
     _repositiory = repositiory;
     _factory = factory;
     _checkModeDescriptor = descriptorFactory.GetDescriptorFor(CheckMode.ManualWithAccount);
 }
        public void Versioning_ValidateVersion_NotValid()
        {
            //Arrange
            var versioningSerivce = new VersioningService();

            //Act / Assert
            Assert.ThrowsException <ArgumentException>(() => versioningSerivce.ValidateVersion("dasd"));
        }
        public void Versioning_ValidateVersion_Valid()
        {
            //Arrange
            var versioningSerivce = new VersioningService();

            //Act
            versioningSerivce.ValidateVersion(TestConstants.CustomVersion);
        }
        public void Versioning_ChangeVersions_AssemblyVersion_Custom()
        {
            //Arrange
            IVersioningService versioningService = new VersioningService();

            //Act
            versioningService.ChangeVersions(TestConstants.PathResources(), TestConstants.CustomVersion).Wait();

            //Assert
            var changedVersion = TestConstants.RegexAssemblyVersion.Match(File.ReadAllText(TestConstants.PathResourceAssemblyInfo())).Value;

            Assert.AreEqual(TestConstants.CustomVersion, changedVersion);
        }
        public void Versioning_ChangeVersions_AssemblyFileVersion_Minor()
        {
            //Arrange
            IVersioningService versioningService = new VersioningService();
            var currentVersion = TestConstants.RegexAssemblyFileVersion.Match(File.ReadAllText(TestConstants.PathResourceAssemblyInfo())).Value;

            int.TryParse(currentVersion.Split('.')[1], out var currentMinorVersion);

            //Act
            versioningService.ChangeVersions(TestConstants.PathResources(), true, false).Wait();

            //Assert
            var changedVersion = TestConstants.RegexAssemblyFileVersion.Match(File.ReadAllText(TestConstants.PathResourceAssemblyInfo())).Value;

            int.TryParse(changedVersion.Split('.')[1], out var changedMinorVersion);

            Assert.IsTrue(changedMinorVersion == currentMinorVersion + 1);
        }
Example #8
0
 public static void CreateProductivityForm(Logger logger)
 {
     try
     {
         var productivityService       = new ProductivityService(logger);
         var twitterPersistanceService = new TwitterPersistenceService(logger);
         var leaderboardApi            = new LeaderboardApi(twitterPersistanceService);
         var versioningService         = new VersioningService(leaderboardApi);
         var tweetMessageService       = new TweetMessageService(versioningService);
         var twitterShareService       = new TwitterShareService(twitterPersistanceService, tweetMessageService);
         using (var pForm = new ProductivityForm(productivityService, twitterShareService))
         {
             pForm.ShowDialog();
         }
     }
     catch (Exception ex)
     {
         logger.Debug(ex, "Unexpected exception when opening the productivity score");
         throw;
     }
 }
Example #9
0
        private void PublishImpl(XrmService context, VersioningService gitvc, DeployConfigurationModel deployConfiguration, TelemetryWrapper telemetry, RawChanges[] changes, string project)
        {
            try
            {
                ChangeManagerService container = new ChangeManagerService(changes, deployConfiguration.Prefix, context);
                telemetry.TrackCustomEventWithCustomMetrics("Deploy Started", new MetricData("Project Name", project));

                if (container.WebResources.Count > 0)
                {
                    ReportProgress?.Invoke(this, $"[DYNAMICS] => Found {container.WebResources.Count} Web Resource.");
                    ReportProgress?.Invoke(this, $"[DYNAMICS] => '{deployConfiguration.Prefix}' used as base path.");
                    ReportProgress?.Invoke(this, $"[DYNAMICS] => Fetching '{deployConfiguration.Solution}' solution from CRM.");
                    container.EnsureContinue(deployConfiguration.Solution, deployConfiguration.Prefix);

                    ReportProgress?.Invoke(this, $"[DYNAMICS] => Publishing changes to the CRM.");
                    var faultedFlushResult = context.Flush(container.BuildRequestList(deployConfiguration.Solution));

                    if (!faultedFlushResult && deployConfiguration.CheckInEnabled)
                    {
                        ReportProgress?.Invoke(this, $"[AZOPS] => Commit & Push in progress.");
                        gitvc.CommitAndPush(deployConfiguration.Password);
                    }

                    ReportProgress?.Invoke(this, $"[AZOPS] => Publish completed.");
                }

                telemetry.TrackCustomEventWithCustomMetrics("Deploy Finished", new MetricData("Project Name", project));
            }
            catch (Exception exception)
            {
                ReportProgress?.Invoke(this, $"[ERROR] => {exception.Message}\n");
                if (!(exception is ToolkitException))
                {
                    telemetry.TrackExceptionWithCustomMetrics(exception);
                }
            }
        }
Example #10
0
        public static void CreateTweetForm(Logger logger)
        {
            try
            {
                var twitterPersistenceService = new TwitterPersistenceService(logger);

                if (!ProductivityUiHelper.IsTwitterAccountConfigured(twitterPersistenceService, logger))
                {
                    MessageBox.Show(
                        PluginResources
                        .ProductivityShareViewPartAction_Execute_In_order_to_share_the_result_you_need_to_configure_your_twitter_account);
                    return;
                }
                var productivityService = new ProductivityService(logger);

                if (productivityService.TotalNumberOfCharacters < Constants.MinimumNumberOfCharacters)
                {
                    MessageBox.Show(
                        string.Format(
                            PluginResources
                            .ProductivityShareViewPartAction_Execute_In_order_to_share_your_score_you_need_to_translate_at_least__0__characters,
                            Constants.MinimumNumberOfCharacters.ToString("N0")));
                    return;
                }

                var leaderboardApi          = new LeaderboardApi(twitterPersistenceService);
                var versioningService       = new VersioningService(leaderboardApi);
                var tweetMessageService     = new TweetMessageService(versioningService);
                var leaderBoardShareService = new LeaderboardShareService(leaderboardApi, twitterPersistenceService);
                var twitterShareService     = new TwitterShareService(twitterPersistenceService, tweetMessageService);
                var shareService            = new ShareService(productivityService, twitterShareService, leaderBoardShareService,
                                                               versioningService);

                if (!leaderboardApi.IsAlive())
                {
                    MessageBox.Show(PluginResources.TweetFactory_CreateTweet_SDL_Leaderboard_could_not_be_reached__Please_check_your_internet_connectivity_and_try_again);
                    return;
                }

                if (!twitterShareService.IsAlive())
                {
                    MessageBox.Show(PluginResources.TweetFactory_CreateTweet_Twitter_could_not_be_reached__Please_check_your_internet_connectivity_and_try_again_);
                    return;
                }

                if (!versioningService.IsPluginVersionCompatibleWithLeaderboardVersion())
                {
                    MessageBox.Show(
                        string.Format(
                            "In order to share you score you need to update the plugin to the version {0}. Please download the latest version from Open Exchange.",
                            shareService.LeaderboardVersion));
                    return;
                }

                using (var tf = new TweetForm(shareService, tweetMessageService, productivityService))
                {
                    tf.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                logger.Debug(ex, "Unexpected exception when opening the share score");
                throw;
            }
        }
Example #11
0
        public void Execute()
        {
            _logger = LogManager.GetLogger("log");

            try
            {
                RavenContext.Current.Initialize();
                InitializeLoggingConfiguration();

                Application.AddMessageFilter(KeyboardTracking.Instance);
                SdlTradosStudio.Application.Closing += Application_Closing;

                _service                  = new KeyboardTrackingService(_logger);
                _editorController         = SdlTradosStudio.Application.GetController <EditorController>();
                _editorController.Opened += _editorController_Opened;
                _editorController.ActiveDocumentChanged += _editorController_ActiveDocumentChanged;
                _editorController.Closing += _editorController_Closing;

                _logger.Info(string.Format("Started productivity plugin version {0}", VersioningService.GetPluginVersion()));
            }
            catch (Exception ex)
            {
                _logger.Debug(ex, "Unexpected exception when intializing the app");
            }
        }
Example #12
0
        public void Execute()
        {
            _logger = LogManager.GetLogger("log");
            #if DEBUG
            {
                _emailService = new EmailService(true);
            }
            #else
            {
                _emailService = new EmailService(false);
            }
            #endif

            try
            {
                RavenContext.Current.Initialize();
                InitializeLoggingConfiguration();

                Application.AddMessageFilter(KeyboardTracking.Instance);
                SdlTradosStudio.Application.Closing += Application_Closing;

                _service = new KeyboardTrackingService(_logger,
                                                       _emailService);
                _editorController         = SdlTradosStudio.Application.GetController <EditorController>();
                _editorController.Opened += _editorController_Opened;
                _editorController.ActiveDocumentChanged += _editorController_ActiveDocumentChanged;
                _editorController.Closing += _editorController_Closing;

                var twitterPersistenceService = new TwitterPersistenceService(_logger);
                if (twitterPersistenceService.HasAccountConfigured)
                {
                    return;
                }
                using (var tForm = new TwitterAccountSetup(twitterPersistenceService))
                {
                    tForm.ShowDialog();
                }
                _logger.Info(string.Format("Started productivity plugin version {0}", VersioningService.GetPluginVersion()));
            }
            catch (Exception ex)
            {
                _logger.Debug(ex, "Unexpected exception when intializing the app");
                _emailService.SendLogFile();
            }
        }