Beispiel #1
0
        private TaxonomyItemExistence DetermineExistence()
        {
            TaxonomyItemExistence existence = TaxonomyItemExistence.Unknown;

            if (this.exceptionHandlingScope != null && this.exceptionHandlingScope.HasException)
            {
                if (this.exceptionHandlingScope.ServerErrorTypeName != "System.ArgumentOutOfRangeException")
                {
                    throw new InvalidOperationException("Server error: " + this.exceptionHandlingScope.ErrorMessage);
                }

                existence = TaxonomyItemExistence.Missing;
            }
            else if (this.ClientTaxonomyItem.ServerObjectIsNull.Value == true) // nullable comparison
            {
                existence = TaxonomyItemExistence.Missing;
            }
            else
            {
                if (this.FindByName)
                {
                    existence = TaxonomyItemExistence.Present;
                }
                else if (this.IsPlacedCorrectly())
                {
                    existence = TaxonomyItemExistence.Present;
                }
                else
                {
                    existence = TaxonomyItemExistence.Elsewhere;
                }
            }
            return(existence);
        }
Beispiel #2
0
        public virtual void NotifyQueryExecuted()
        {
            // Don't forget to update CheckForUnimplementedSyncActions() if this changes
            switch (this.state)
            {
            case State.CheckExistence:
                this.existence = this.DetermineExistence();

                if (this.existence == TaxonomyItemExistence.Missing)
                {
                    this.AssignClientChildItems();
                    this.NotifyWaiters();

                    switch (this.SyncAction.IfMissing)
                    {
                    case SyncActionIfMissing.Create:
                        this.state = State.Create;
                        break;

                    case SyncActionIfMissing.Error:
                        throw new InvalidOperationException("The item is missing, and IfMissing=Error was specified:\r\n"
                                                            + this.LocalTaxonomyItem.ToString());

                    case SyncActionIfMissing.DoNothing:
                    default:
                        throw new NotImplementedException("Not implemented yet: IfMissing=" +
                                                          this.SyncAction.IfMissing);
                    }
                }
                else if (this.existence == TaxonomyItemExistence.Present)
                {
                    this.AssignClientChildItems();
                    this.NotifyWaiters();

                    switch (this.SyncAction.IfPresent)
                    {
                    case SyncActionIfPresent.Update:
                        this.state = State.UpdateProperties;
                        break;

                    case SyncActionIfPresent.OnlyUpdateChildItems:
                        this.state = State.Finished;
                        break;

                    case SyncActionIfPresent.Error:
                        throw new InvalidOperationException("The item is present, and IfPresent=Error was specified:\r\n"
                                                            + this.LocalTaxonomyItem.ToString());

                    case SyncActionIfPresent.DeleteAndRecreate:
                    case SyncActionIfPresent.DoNothing:
                    default:
                        throw new NotImplementedException("Not implemented yet: IfPresent=" +
                                                          this.SyncAction.IfPresent);
                    }
                }
                else
                {
                    Debug.Assert(this.existence == TaxonomyItemExistence.Elsewhere);

                    switch (this.SyncAction.IfElsewhere)
                    {
                    case SyncActionIfElsewhere.Error:
                        throw new InvalidOperationException("The item was found in the wrong location,"
                                                            + " and IfElsewhere=Error was specified:\r\n"
                                                            + this.LocalTaxonomyItem.ToString());

                    case SyncActionIfElsewhere.MoveAndUpdate:
                    case SyncActionIfElsewhere.DeleteAndRecreate:
                    case SyncActionIfElsewhere.DoNothing:
                    default:
                        throw new NotImplementedException("Not implemented yet: IfElsewhere=" +
                                                          this.SyncAction.IfElsewhere);
                    }
                }
                break;

            case State.Create:
                if (this.exceptionHandlingScope != null && this.exceptionHandlingScope.HasException)
                {
                    throw new InvalidOperationException("Failed to create object "
                                                        + this.LocalTaxonomyItem.ToString() + ":\r\n"
                                                        + this.exceptionHandlingScope.ServerErrorTypeName
                                                        + ": " + this.exceptionHandlingScope.ErrorMessage);
                }

                this.NotifyWaiters();
                this.state = State.AssignProperties;
                break;

            case State.AssignProperties:
                this.state = State.Finished;
                break;

            case State.UpdateProperties:
                this.state = State.Finished;
                break;

            default:
                throw new NotImplementedException();
            }
        }