Ejemplo n.º 1
0
        public void Initialize(ProductivityService productivityService, TwitterShareService twitterShareService)
        {
            _productivityService = productivityService;
            _twitterShareService = twitterShareService;

            _initialized = true;
        }
Ejemplo n.º 2
0
 public TweetForm(ShareService shareService, TweetMessageService tweetMessageService, ProductivityService productivityService)
     : this()
 {
     _shareService = shareService;
     _tweetMessageService = tweetMessageService;
     _productivityService = productivityService;
 }
Ejemplo n.º 3
0
 public ShareService(ProductivityService productivityService,
     TwitterShareService twitterShareService,
     LeaderboardShareService leaderboardShareService,
     VersioningService versioningService)
 {
     _productivityService = productivityService;
     _twitterShareService = twitterShareService;
     _leaderboardShareService = leaderboardShareService;
     _twitterShareService = twitterShareService;
     _versioningService = versioningService;
 }
        private void Initialize()
        {
            _productivityService = new ProductivityService();

            _trackingInfoVews =
                _productivityService.TrackInfoViews.Where(
                    x => !string.IsNullOrEmpty(x.Text)).ToList();

            lblProductivityScore.Text = string.Format("Productivity score: {0}%", _productivityService.ProductivityScore);
            lblScore.Text = _productivityService.Score.ToString(CultureInfo.InvariantCulture);

            InitializeListView();
        }
Ejemplo n.º 5
0
        public ShareService(ProductivityService productivityService,
            TwitterPersistenceService twitterPersistenceService,
            TweetMessageService tweetMessageService,
            LeaderboardApi leaderboardApi,
            Logger logger)
        {
            _productivityService = productivityService;
            _twitterPersistenceService = twitterPersistenceService;
            _tweetMessageService = tweetMessageService;
            _leaderboardApi = leaderboardApi;
            _logger = logger;

            Initialize();
        }
Ejemplo n.º 6
0
        public ShareService(ProductivityService productivityService,
                            TwitterPersistenceService twitterPersistenceService,
                            TweetMessageService tweetMessageService,
                            LeaderboardApi leaderboardApi,
                            Logger logger)
        {
            _productivityService       = productivityService;
            _twitterPersistenceService = twitterPersistenceService;
            _tweetMessageService       = tweetMessageService;
            _leaderboardApi            = leaderboardApi;
            _logger = logger;

            Initialize();
        }
Ejemplo n.º 7
0
        protected override void Execute()
        {
            Application.EnableVisualStyles();
            var logger = LogManager.GetLogger("log");
            try
            {
                var twitterPersistenceService = new TwitterPersistenceService(logger);
                var leaderboardApi = new LeaderboardApi(twitterPersistenceService);
                var tweetMessageService = new TweetMessageService();
                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 shareService = new ShareService(productivityService, twitterPersistenceService, tweetMessageService,
                    leaderboardApi, logger);
                using (var tf = new TweetForm(shareService))
                {
                    tf.ShowDialog();
                }

            }
            catch (Exception ex)
            {
                logger.Debug(ex, "Unexpected exception when opening the share score");
                throw;
            }
        }
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 9
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;
            }
        }
Ejemplo n.º 10
0
 public ProductivityForm(ProductivityService productivityService, TwitterShareService twitterShare)
 {
     InitializeComponent();
     productivityControl.Initialize(productivityService, twitterShare);
 }