Exemplo n.º 1
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));
            }
        }
Exemplo n.º 2
0
        public Version GetCurrentVersion()
        {
            var solution = dataAccessDispatcher.Dispatch(SolutionActions.GetSolutionByName(CrmConstants.DefaultSolutionSettings.Name));

            return(Version.Parse(solution.Version));
        }