コード例 #1
0
        public void SetConflictManager(Guid scopeId, Guid sourceId, Guid conflictTypeReferenceName)
        {
            m_conflictManager = null;

            IEnumerable <ConflictManager> conflictManagers = m_appViewModel.Sync.GetConflictManagers(scopeId, sourceId);

            foreach (var manager in conflictManagers)
            {
                if (manager.RegisteredConflictTypes.ContainsKey(conflictTypeReferenceName))
                {
                    m_conflictManager = manager;
                    break;
                }
            }
            Debug.Assert(m_conflictManager != null, string.Format("Unable to find ConflictManager.  Possible resolution: register conflict type ({0}) with ConflictManager.", conflictTypeReferenceName));

            if (m_conflictManager != null)
            {
                ConflictType = m_conflictManager.RegisteredConflictTypes[conflictTypeReferenceName];
            }
            else
            {
                ConflictType = new GenericConflictType();
            }
        }
コード例 #2
0
        internal IQueryable <RTConflict> GetActiveConflicts(Guid sessionGroupUniqueId)
        {
            RuntimeEntityModel context = RuntimeEntityModel.CreateInstance();

            // hidden conflicts
            Guid chainOnBackloggedItemConflictTypeRefName = new ChainOnBackloggedItemConflictType().ReferenceName; // A7EFC8C6-A6CF-45e7-BFA6-471942A54F37
            Guid chainOnConflictConflictTypeRefName       = Constants.chainOnConflictConflictTypeRefName;          //F6BFB484-EE70-4ffc-AAB3-4F659B0CAF7F

            // runtime conflicts
            Guid witGeneralConflictTypeRefName = Constants.witGeneralConflictTypeRefName; //470F9617-FC96-4166-96EB-44CC2CF73A97
            Guid generalConflictTypeRefName    = new GenericConflictType().ReferenceName; // F6DAB314-2792-40D9-86CC-B40F5B827D86

            var conflictQuery =
                from c in context.RTConflictSet
                where (c.InCollection.SessionGroupRun.Config.SessionGroup.GroupUniqueId.Equals(sessionGroupUniqueId) ||
                       c.InCollection.SessionRun.SessionGroupRun.Config.SessionGroup.GroupUniqueId.Equals(sessionGroupUniqueId)) &&
                c.Status == 0 && // only search for active conflicts
                !c.ConflictType.ReferenceName.Equals(chainOnBackloggedItemConflictTypeRefName) &&
                !c.ConflictType.ReferenceName.Equals(chainOnConflictConflictTypeRefName) &&
                !c.ConflictType.ReferenceName.Equals(witGeneralConflictTypeRefName) &&
                !c.ConflictType.ReferenceName.Equals(generalConflictTypeRefName)
                select c;

            return(conflictQuery);
        }
コード例 #3
0
        /// <summary>
        /// Create a generic conflict.
        /// </summary>
        /// <param name="e"></param>
        /// <param name="group"></param>
        /// <returns></returns>
        private ConflictResolutionResult createGenericConflict(Exception e, ChangeGroup group)
        {
            Debug.Assert(e != null, "Exception e for creating generic conflict is NULL");
            Debug.Assert(group != null, "Conflicted change group is NULL");
            Debug.Assert(m_conflictManagementService != null, "ConflictManager is not properly initialized");

            MigrationConflict genericConflict = GenericConflictType.CreateConflict(e);

            List <MigrationAction>   retActions;
            ConflictResolutionResult resolutionResult =
                m_conflictManagementService.TryResolveNewConflict(group.SourceId, genericConflict, out retActions);

            return(resolutionResult);
        }
コード例 #4
0
        /// <summary>
        /// Try handling an exception
        /// </summary>
        /// <param name="e"></param>
        /// <param name="conflictManager"></param>
        /// <returns>The decision returned is either RoutedAsError or RaisedAsRuntimeConflict</returns>
        public ErrorHandlingResult TryHandleException(Exception e, ConflictManager conflictManager)
        {
            bool conflictManagementIsEnabled = (null != conflictManager);
            bool anErrorRouterIsFound        = false;
            bool exceptionIsRoutedAsError    = false;

            foreach (ErrorRouter errRouter in m_errRegService.RegisteredRouters)
            {
                ErrorHandlingResult rslt = errRouter.TryRouteError(e, this.m_routingChannels.AsReadOnly());
                switch (rslt.Decision)
                {
                case ErrorHandlingResult.RoutingDecision.RaisedAsRuntimeConflict:
                    anErrorRouterIsFound     = true;
                    exceptionIsRoutedAsError = true;
                    break;

                case ErrorHandlingResult.RoutingDecision.PolicyConditionIsNotMet:
                    anErrorRouterIsFound = true;
                    break;

                case ErrorHandlingResult.RoutingDecision.RoutedAsError:
                    return(rslt);

                default:
                    break;
                }

                if (anErrorRouterIsFound || exceptionIsRoutedAsError)
                {
                    break;
                }
            }

            if (exceptionIsRoutedAsError)
            {
                return(new ErrorHandlingResult(ErrorHandlingResult.RoutingDecision.RoutedAsError));
            }

            if (conflictManagementIsEnabled)
            {
                MigrationConflict      conflict = GenericConflictType.CreateConflict(e);
                List <MigrationAction> actions;
                conflictManager.TryResolveNewConflict(conflictManager.SourceId, conflict, out actions);
                return(new ErrorHandlingResult(ErrorHandlingResult.RoutingDecision.RaisedAsRuntimeConflict));
            }

            else if (anErrorRouterIsFound)
            {
                // no conflict manager to log the runtime conflict
                throw new MissingErrorRouterException(
                          "Runtime error does not meet the error routine policy and there is no conflict manager to log a conflict.",
                          e);
            }
            else
            {
                // no conflict manager is present to raise the error as a runtime conflict
                // - default to report as an error
                foreach (IErrorRoutingChannel channel in m_routingChannels)
                {
                    channel.RouteError(e);
                }
                return(new ErrorHandlingResult(ErrorHandlingResult.RoutingDecision.RoutedAsError));
            }
        }