示例#1
0
        /// <summary>
        /// The execute.
        /// </summary>
        /// <param name="em">
        /// The em.
        /// </param>
        public void Execute(WaitMessage em)
        {
            var am = new AnswerMessage();

            am.Echo = "Waited for 1 second";
            Thread.Sleep(1000);
            if (em.Sender is Session)
            {
                (em.Sender as Session).Reply(am);
            }
        }
示例#2
0
        private void OnWaitMessage(WaitMessage msg)
        {
            if (msg.Start)
            {
                MainWindow = Application.Current.MainWindow;

                OldCursor         = MainWindow.Cursor;
                MainWindow.Cursor = Cursors.Wait;
            }
            else
            {
                MainWindow.Cursor = OldCursor;
            }
        }
示例#3
0
		private async Task Wait( WaitMessage arg )
		{
			await Task.Delay( arg.Milisecond );
		}
        private void ExecViewHistory(Uri tfsCollectionUri, string sourceControlFolder)
        {
            // gource start arguments
            string arguments;
            string title;
            string avatarsDirectory = null;

            if (m_settigs.PlayMode == VisualizationSettings.PlayModeOption.History)
            {
                title = "History of " + sourceControlFolder;
                var logFile = Path.Combine(FileUtils.GetTempPath(), "TfsHistoryLog.tmp.txt");

                if (m_settigs.ViewAvatars)
                {
                    avatarsDirectory = Path.Combine(FileUtils.GetTempPath(), "TfsHistoryLog.tmp.Avatars");
                    if (!Directory.Exists(avatarsDirectory))
                    {
                        Directory.CreateDirectory(avatarsDirectory);
                    }
                }

                bool historyFound;
                bool hasLines;

                using (var waitMessage = new WaitMessage("Connecting to Team Foundation Server...", OnCancelByUser))
                {
                    var progress = waitMessage.CreateProgress("Loading history ({0}% done) ...");

                    hasLines =
                        TfsLogWriter.CreateGourceLogFile(
                            logFile,
                            avatarsDirectory,
                            tfsCollectionUri,
                            sourceControlFolder,
                            m_settigs,
                            ref m_canceled,
                            progress.SetValue
                            );

                    historyFound = progress.LastValue > 0;
                    progress.Done();
                }

                if (m_canceled)
                {
                    return;
                }

                if (!hasLines)
                {
                    MessageBox.Show(
                        historyFound
                                        ? "No items found.\nCheck your filters: 'User name' and 'File type'."
                                                        : "No items found.\nTry to change period of the history (From/To dates).",
                        "TFS History Visualization");
                    return;
                }

                arguments = string.Format(CultureInfo.InvariantCulture, " \"{0}\" ", logFile);

                // Setting other history settings

                arguments += " --seconds-per-day " + m_settigs.SecondsPerDay.ToString(CultureInfo.InvariantCulture);

                if (m_settigs.TimeScale != VisualizationSettings.TimeScaleOption.None)
                {
                    var optionValue = ConvertToString(m_settigs.TimeScale);
                    if (optionValue != null)
                    {
                        arguments += " --time-scale " + optionValue;
                    }
                }

                if (m_settigs.LoopPlayback)
                {
                    arguments += " --loop";
                }

                arguments += " --file-idle-time 60";                 // 60 is default in gource 0.40 and older. Since 0.41 default 0.
            }
            else
            {
                // PlayMode: Live
                title = "Live changes of " + sourceControlFolder;

                arguments  = " --realtime --log-format custom -";
                arguments += " --file-idle-time 28800"; // 8 hours (work day)
            }

            var baseDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) ??
                                "unknown";


            if (baseDirectory.Contains("Test"))
            {
                baseDirectory += @"\..\..\..\VSExtension";
            }

#if DEBUG
            // baseDirectory = @"C:\Temp\aaaa\уи³пс\";
#endif
            var gourcePath = Path.Combine(baseDirectory, @"Gource\Gource.exe");
            var dataPath   = Path.Combine(baseDirectory, @"Data");

            // ******************************************************
            // Configuring Gource command line
            // ******************************************************

            arguments +=
                string.Format(CultureInfo.InvariantCulture, " --highlight-users --title \"{0}\"", title);

            if (m_settigs.ViewLogo != CheckState.Unchecked)
            {
                var logoFile = m_settigs.ViewLogo == CheckState.Indeterminate
                                        ? Path.Combine(dataPath, "Logo.png")
                                        : m_settigs.LogoFileName;

                // fix gource unicode path problems
                logoFile = FileUtils.GetShortPath(logoFile);

                arguments += string.Format(CultureInfo.InvariantCulture, " --logo \"{0}\"", logoFile);
            }

            if (m_settigs.FullScreen)
            {
                arguments += " --fullscreen";

                // By default gource not using full area of screen width ( It's a bug. Must be fixed in gource 0.41).
                // Fixing fullscreen resolution to real full screen.
                if (!m_settigs.SetResolution)
                {
                    var screenBounds = Screen.PrimaryScreen.Bounds;
                    arguments += string.Format(CultureInfo.InvariantCulture, " --viewport {0}x{1}", screenBounds.Width,
                                               screenBounds.Height);
                }
            }

            if (m_settigs.SetResolution)
            {
                arguments += string.Format(CultureInfo.InvariantCulture, " --viewport {0}x{1}",
                                           m_settigs.ResolutionWidth, m_settigs.ResolutionHeight);
            }

            if (m_settigs.ViewFilesExtentionMap)
            {
                arguments += " --key";
            }

            if (!string.IsNullOrEmpty(avatarsDirectory))
            {
                arguments += string.Format(CultureInfo.InvariantCulture, " --user-image-dir \"{0}\"", avatarsDirectory);
            }

            // Process "--hide" option
            {
                var hideItems = string.Empty;
                if (!m_settigs.ViewDirNames)
                {
                    hideItems = "dirnames";
                }
                if (!m_settigs.ViewFileNames)
                {
                    if (hideItems.Length > 0)
                    {
                        hideItems += ",";
                    }
                    hideItems += "filenames";
                }
                if (!m_settigs.ViewUserNames)
                {
                    if (hideItems.Length > 0)
                    {
                        hideItems += ",";
                    }
                    hideItems += "usernames";
                }

                if (hideItems.Length > 0)
                {
                    arguments += " --hide " + hideItems;
                }
            }

            arguments += " --max-files " + m_settigs.MaxFiles.ToString(CultureInfo.InvariantCulture);

            if (SystemInformation.TerminalServerSession)
            {
                arguments += " --disable-bloom";
            }

            if (m_settigs.PlayMode == VisualizationSettings.PlayModeOption.History)
            {
                var si = new ProcessStartInfo(gourcePath, arguments)
                {
                    WindowStyle = ProcessWindowStyle.Maximized,
                    //                       UseShellExecute = true
                };

                Process.Start(si);
            }
            else
            {
                var logReader = new VersionControlLogReader(tfsCollectionUri, sourceControlFolder, m_settigs.UsersFilter,
                                                            m_settigs.FilesFilter);
                using (new WaitMessage("Connecting to Team Foundation Server..."))
                {
                    logReader.Connect();
                }

                System.Threading.Tasks.Task.Factory.StartNew(() => RunLiveChangesMonitor(logReader, gourcePath, arguments));
            }
        }