Ejemplo n.º 1
0
        public static void Invoke(TargetAction action, CleanupOptions cleanupOptions)
        {
            try
            {
                var projects = SolutionActions.FindProjects(DteServiceProvider.Instance);

                for (var i = 0; i < projects.Count; i++)
                {
                    var currentProject = projects[i];
                    if (currentProject.ProjectItems == null)
                    {
                        continue;
                    }
                    if (currentProject.FullName.ToLower().EndsWith(".shproj"))
                    {
                        continue;
                    }

                    for (var j = 1; j < currentProject.ProjectItems.Count; j++)
                    {
                        ActionCSharpOnProjectItem.Action(currentProject.ProjectItems.Item(j), action, cleanupOptions);
                    }
                }
            }
            catch (Exception e)
            {
                ErrorNotification.EmailError(e);
                ProcessActions.GeeksProductivityToolsProcess();
            }
        }
        public static void Invoke(TargetAction action, CleanupOptions cleanupOptions)
        {
            try
            {
                var projects = SolutionActions.FindProjects(DteServiceProvider.Instance);

                for (var i = 0; i < projects.Count; i++)
                {
                    var currentProject = projects[i];
                    if (currentProject.ProjectItems == null)
                    {
                        continue;
                    }
                    if (currentProject.FullName.EndsWith(".shproj", StringComparison.OrdinalIgnoreCase))
                    {
                        continue;
                    }

                    for (var j = 1; j < currentProject.ProjectItems.Count; j++)
                    {
                        ActionCSharpOnProjectItem.Action(currentProject.ProjectItems.Item(j), action, cleanupOptions);
                    }
                }
            }
            catch (Exception e)
            {
                ErrorNotification.WriteErrorToFile(e);
                ErrorNotification.WriteErrorToOutputWindow(e);
                ProcessActions.GeeksProductivityToolsProcess();
            }
        }
Ejemplo n.º 3
0
        private ComponentInstallationResult InstallComponent(int componentId, InstallationVersion version)
        {
            var thisComponent = version.InstallationComponents[componentId];
            var nextComponent = GetNextInstallationComponent(version, componentId);

            try
            {
                dataAccessDispatcher.Dispatch(thisComponent.InstallationAction);
                dataAccessDispatcher.Dispatch(thisComponent.DataChangeAction);

                if (!nextComponent.HasValue || (nextComponent.HasValue && nextComponent.Value.Value.Version.CompareTo(version.Version) > 0))
                {
                    /* The next component is part of a newer version,
                     * so at this point we update the solution to reflect that this
                     * installation version has installed. If the solution update fails,
                     * we should rollback and fail the current component too */
                    try
                    {
                        var solution = dataAccessDispatcher.Dispatch(SolutionActions.GetSolutionByName(CrmConstants.DefaultSolutionSettings.Name));
                        solution.Version = version.Version.ToString();
                        dataAccessDispatcher.Dispatch(SolutionActions.UpdateSolution(solution));
                    }
                    catch
                    {
                        dataAccessDispatcher.Dispatch(thisComponent.RollbackAction);
                        throw;
                    }
                }

                if (nextComponent.HasValue)
                {
                    var nextComponentDescription = nextComponent.Value.Value.InstallationComponents[nextComponent.Value.Key].Description;
                    var nextComponentKey         = nextComponent.Value.Key;
                    var nextComponentVersion     = nextComponent.Value.Value.Version;

                    return(ComponentInstallationResult.Success(componentId, version.Version, nextComponentKey, nextComponentVersion, nextComponentDescription));
                }
                else
                {
                    return(ComponentInstallationResult.Success(componentId, version.Version, true));
                }
            }
            catch (Exception ex)
            {
                return(ComponentInstallationResult.Fail(componentId, version.Version, ex.Message));
            }
        }
        /// <summary>
        /// Creates the solution.
        /// </summary>
        /// <param name="cube">The cube.</param>
        /// <param name="SolutionName">Name of the solution.</param>
        /// <returns>Result.</returns>
        /// <exception cref="Exception"></exception>
        private static Result CreateSolution(CubeBase cube, string SolutionName)
        {
            try
            {
                SolutionActions solAct = new SolutionActions(cube);
                solAct.Name = SolutionName;
                Result result = solAct.Create();
                if (result.isError)
                {
                    throw new Exception(result.Message);
                }

                return(new Result(false, string.Empty, solAct, cube.LogSystem));
            }
            catch (Exception ex)
            {
                return(new Result(true, ex.Message, null, cube.LogSystem));
            }
        }
        /// <summary>
        /// Executes the specified cube.
        /// </summary>
        /// <param name="cube">The cube.</param>
        /// <param name="SolutionName">Name of the solution.</param>
        /// <returns>Result.</returns>
        /// <exception cref="Exception"></exception>
        /// <exception cref="Exception"></exception>
        /// <exception cref="Exception">couldn't read Mawens solution settings</exception>
        /// <exception cref="Exception">couldn't read Mawens solution</exception>
        public static Result Execute(CubeBase cube, string SolutionName)
        {
            try
            {
                Result resultSolution = retrieveSolution(cube, SolutionName);
                if (resultSolution.isError)
                {
                    throw new Exception(resultSolution.Message);
                }

                if (resultSolution.BusinessObject != null)
                {
                    SolutionActions sa = (SolutionActions)resultSolution.BusinessObject;
                    Result          resultSolutionSettings = retrieveSolutionSettings(cube, sa.ID);
                    if (resultSolutionSettings.isError)
                    {
                        throw new Exception(resultSolutionSettings.Message);
                    }

                    if (resultSolution.BusinessObject != null)
                    {
                        return(resultSolutionSettings);
                    }
                    else
                    {
                        throw new Exception("couldn't read Mawens solution settings");
                    }
                }
                else
                {
                    throw new Exception("couldn't read Mawens solution");
                }
            }
            catch (Exception ex)
            {
                return(new Result(true, ex.Message, null, cube.LogSystem));
            }
        }
        /// <summary>
        /// Retrieves the solution.
        /// </summary>
        /// <param name="cube">The cube.</param>
        /// <param name="SolutionName">Name of the solution.</param>
        /// <returns>Result.</returns>
        /// <exception cref="Exception"></exception>
        private static Result retrieveSolution(CubeBase cube, string SolutionName)
        {
            try
            {
                SolutionActions solAct = new SolutionActions(cube);
                solAct.Name = SolutionName;
                Result resultSolution = solAct.GetItem();
                if (resultSolution.isError)
                {
                    throw new Exception(resultSolution.Message);
                }

                if (resultSolution.BusinessObject != null)
                {
                    Entity          e  = (Entity)resultSolution.BusinessObject;
                    SolutionActions sa = new SolutionActions(cube);
                    if (e.Contains("mwns_name"))
                    {
                        sa.Name = e["mwns_name"].ToString();
                    }
                    if (e.Contains("mwns_mawenssolutionid"))
                    {
                        sa.ID = new Guid(e["mwns_mawenssolutionid"].ToString());
                    }

                    return(new Result(false, string.Empty, sa, cube.LogSystem));
                }
                else
                {
                    return(CreateSolution(cube, SolutionName));
                }
            }
            catch (Exception ex)
            {
                return(new Result(true, ex.Message, null, cube.LogSystem));
            }
        }
Ejemplo n.º 7
0
        public Version GetCurrentVersion()
        {
            var solution = dataAccessDispatcher.Dispatch(SolutionActions.GetSolutionByName(CrmConstants.DefaultSolutionSettings.Name));

            return(Version.Parse(solution.Version));
        }
Ejemplo n.º 8
0
        public GlobalJsonResult <IEnumerable <Solution> > GetAll()
        {
            var result = dataAccessDispatcher.Dispatch(SolutionActions.GetAll());

            return(GlobalJsonResult <IEnumerable <Solution> > .Success(System.Net.HttpStatusCode.OK, result));
        }