Ejemplo n.º 1
0
        public ControlModel()
        {
            ValueIndicators = ValueIndicatorsFactory.CreateCollection();
            SolutionItem = new SolutionItem();
            TextCurrentState = BuildMessages.GetBuildDoneMessage(null, null, null);

            ControlTemplate stateImage;
            ImageCurrentState = BuildImages.GetBuildDoneImage(null, null, out stateImage);
            ImageCurrentStateResult = stateImage;
        }
Ejemplo n.º 2
0
        public static string GetBuildBeginMajorMessage(
            SolutionItem solutionItem, 
            BuildInfo buildInfo, 
            BuildMessagesSettings labelsSettings)
        {
            var buildAction = buildInfo.BuildAction;
            var buildScope = buildInfo.BuildScope;

            if (buildAction == null || buildScope == null)
                return Resources.UnknownBuildActionOrScope_BuildBeginText;

            if (buildInfo.BuildStartTime == null)
                throw new InvalidOperationException();

            string timeString;
            try
            {
                timeString = buildInfo.BuildStartTime.Value.ToString(labelsSettings.DateTimeFormat);
            }
            catch (FormatException)
            {
                timeString = Resources.InvalidTimeStringFormat;
            }

            string unitName;
            switch (buildScope.Value)
            {
                case vsBuildScope.vsBuildScopeSolution:
                    unitName = Resources.BuildScopeSolution_UnitName;
                    if (labelsSettings.ShowSolutionName)
                        unitName += string.Format(Resources.BuildScopeSolution_SolutionNameTemplate, solutionItem.Name);
                    break;

                case vsBuildScope.vsBuildScopeBatch:
                    unitName = Resources.BuildScopeBatch_UnitName;
                    break;

                case vsBuildScope.vsBuildScopeProject:
                    unitName = Resources.BuildScopeProject_UnitName;
                    if (labelsSettings.ShowProjectName)
                    {
                        var proj = buildInfo.BuildScopeProject;
                        if (proj != null)
                        {
                            unitName += string.Format(Resources.BuildScopeProject_ProjectNameTemplate, proj.Name);
                        }
                        else
                        {
                            unitName = Resources.BuildScopeBatch_UnitName;
                            buildInfo.OverrideBuildProperties(buildScope: vsBuildScope.vsBuildScopeBatch);
                        }
                    }
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
            }

            string actionName;
            string beginAtString;
            switch (buildAction.Value)
            {
                case vsBuildAction.vsBuildActionRebuildAll:
                    actionName = Resources.BuildActionRebuildAll;
                    beginAtString = Resources.BuildActionRebuildAll_BeginAtString;
                    break;

                case vsBuildAction.vsBuildActionBuild:
                    actionName = Resources.BuildActionBuild;
                    beginAtString = Resources.BuildActionBuild_BeginAtString;
                    break;

                case vsBuildAction.vsBuildActionClean:
                    actionName = Resources.BuildActionClean;
                    beginAtString = Resources.BuildActionClean_BeginAtString;
                    break;

                case vsBuildAction.vsBuildActionDeploy:
                    return Resources.UnknownBuildActionOrScope_BuildBeginText;

                default:
                    throw new ArgumentOutOfRangeException();
            }

            string mainString;
            switch (labelsSettings.MajorMessageFormat)
            {
                case BuildMajorMessageFormat.Entire:
                    mainString = string.Format(Resources.BuildBeginStateLabelTemplate_Default, actionName, unitName, beginAtString, timeString);
                    break;

                case BuildMajorMessageFormat.Unnamed:
                    mainString = string.Format(Resources.BuildBeginStateLabelTemplate_ShortForm, actionName, beginAtString, timeString);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
            }

            string resultMainString = string.Format(labelsSettings.BuildBeginMajorMessageStringFormat, mainString);
            return resultMainString;
        }
Ejemplo n.º 3
0
        private static void GetBuildDoneActionAndResultStrings(
            SolutionItem solutionItem,
            BuildInfo buildInfo,
            out string actionName,
            out string resultName)
        {
            vsBuildAction? buildAction = buildInfo.BuildAction;

            if (buildAction == null)
                throw new InvalidOperationException();

            switch (buildAction.Value)
            {
                case vsBuildAction.vsBuildActionBuild:
                    actionName = Resources.BuildActionBuild;
                    break;

                case vsBuildAction.vsBuildActionRebuildAll:
                    actionName = Resources.BuildActionRebuildAll;
                    break;

                case vsBuildAction.vsBuildActionClean:
                    actionName = Resources.BuildActionClean;
                    break;

                case vsBuildAction.vsBuildActionDeploy:
                    throw new InvalidOperationException();

                default:
                    throw new ArgumentOutOfRangeException();
            }

            bool buildWithoutErrors = buildInfo.BuildedProjects.BuildWithoutErrors;
            int errorStateProjectsCount = solutionItem.Projects.Count(item => item.State.IsErrorState());

            if (buildInfo.BuildIsCancelled)
                resultName = buildAction.Value == vsBuildAction.vsBuildActionClean ? Resources.BuildActionCancelled_Clean : Resources.BuildActionCancelled;
            else if (!buildWithoutErrors)
                resultName = buildAction.Value == vsBuildAction.vsBuildActionClean ? Resources.BuildActionFailed_Clean : Resources.BuildActionFailed;
            else if (/*buildWithoutErrors &&*/ errorStateProjectsCount == 0)
                resultName = buildAction.Value == vsBuildAction.vsBuildActionClean ? Resources.BuildActionFinishedSuccessfully_Clean : Resources.BuildActionFinishedSuccessfully;
            else
                resultName = buildAction.Value == vsBuildAction.vsBuildActionClean ? Resources.BuildActionFinished_Clean : Resources.BuildActionFinished;
        }
Ejemplo n.º 4
0
        private static string GetBuildDoneMajorMessage(
            SolutionItem solutionItem,
            BuildInfo buildInfo,
            BuildMessagesSettings labelsSettings)
        {
            if (buildInfo == null)
                return Resources.BuildDoneText_BuildNotStarted;

            var buildAction = buildInfo.BuildAction;
            var buildScope = buildInfo.BuildScope;

            if (buildInfo.BuildFinishTime == null)
                throw new InvalidOperationException();

            string timeString;
            try
            {
                timeString = buildInfo.BuildFinishTime.Value.ToString(labelsSettings.DateTimeFormat);
            }
            catch (FormatException)
            {
                timeString = Resources.InvalidTimeStringFormat;
            }

            if (buildAction == null || buildScope == null)
                return string.Format(Resources.BuildDoneText_NotSupported_BuildActionOrScopeIsNull_CompletedAtTemplate, timeString); //? WTF???

            string unitName;
            switch (buildScope.Value)
            {
                case vsBuildScope.vsBuildScopeSolution:
                    unitName = Resources.BuildScopeSolution_UnitName;
                    if (labelsSettings.ShowSolutionName)
                        unitName += string.Format(Resources.BuildScopeSolution_SolutionNameTemplate, solutionItem.Name);
                    break;

                case vsBuildScope.vsBuildScopeBatch:
                    unitName = Resources.BuildScopeBatch_UnitName;
                    break;

                case vsBuildScope.vsBuildScopeProject:
                    unitName = Resources.BuildScopeProject_UnitName;
                    if (labelsSettings.ShowProjectName)
                    {
                        // Skip dependent projects. The last project in the list is the target project.
                        string uniqProjName = buildInfo.BuildedProjects[buildInfo.BuildedProjects.Count - 1].UniqueName;
                        ProjectItem projItem = solutionItem.Projects.FirstOrDefault(item => item.UniqueName == uniqProjName);
                        Debug.Assert(projItem != null);

                        unitName += string.Format(Resources.BuildScopeProject_ProjectNameTemplate, projItem.Name);
                    }
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
            }

            string actionName;
            string resultName;
            GetBuildDoneActionAndResultStrings(solutionItem, buildInfo, out actionName, out resultName);

            string mainString;
            switch (labelsSettings.MajorMessageFormat)
            {
                case BuildMajorMessageFormat.Entire:
                    mainString = string.Format(Resources.BuildDoneStateLabelTemplate_Default, actionName, unitName, resultName, timeString);
                    break;

                case BuildMajorMessageFormat.Unnamed:
                    mainString = string.Format(Resources.BuildDoneStateLabelTemplate_ShortForm, actionName, resultName, timeString);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
            }

            string resultMainString = string.Format(labelsSettings.BuildDoneMajorMessageStringFormat, mainString);
            return resultMainString;
        }
Ejemplo n.º 5
0
 public static string GetBuildDoneMessage(
     SolutionItem solutionItem,
     BuildInfo buildInfo,
     BuildMessagesSettings labelsSettings)
 {
     return GetBuildDoneMajorMessage(solutionItem, buildInfo, labelsSettings)
         + GetBuildDoneExtraMessage(buildInfo, labelsSettings);
 }