Exemple #1
0
        private static LegacyReservationType ConvertReservationFlagsToLegacy(ReservationFlags flags, bool expiring)
        {
            LegacyReservationType result;

            if (flags.HasFlag(ReservationFlags.Read))
            {
                if (expiring)
                {
                    result = LegacyReservationType.ExpiredRead;
                }
                else
                {
                    result = LegacyReservationType.Read;
                }
            }
            else if (expiring)
            {
                result = LegacyReservationType.ExpiredWrite;
            }
            else
            {
                result = LegacyReservationType.Write;
            }
            return(result);
        }
Exemple #2
0
        public static IReservation CreateReservation(string serverFQDN, NetworkCredential credentials, Guid mailboxGuid, TenantPartitionHint partitionHint, Guid resourceId, ReservationFlags flags)
        {
            if (serverFQDN == null)
            {
                TestIntegration testIntegration = new TestIntegration(false);
                if ((flags.HasFlag(ReservationFlags.Read) && testIntegration.UseRemoteForSource) || (flags.HasFlag(ReservationFlags.Write) && testIntegration.UseRemoteForDestination))
                {
                    serverFQDN = CommonUtils.LocalComputerName;
                }
            }
            IReservation result = null;

            ExecutionContext.Create(new DataContext[]
            {
                new OperationDataContext("IReservationManager.ReserveResources", OperationType.None),
                new SimpleValueDataContext("MailboxGuid", mailboxGuid),
                new SimpleValueDataContext("ResourceId", resourceId),
                new SimpleValueDataContext("Flags", flags)
            }).Execute(delegate
            {
                if (serverFQDN == null)
                {
                    result = ReservationManager.CreateReservation(mailboxGuid, partitionHint, resourceId, flags, CommonUtils.LocalComputerName);
                    return;
                }
                result = RemoteReservation.Create(serverFQDN, credentials, mailboxGuid, partitionHint, resourceId, flags);
            });
            return(new ReservationWrapper(result));
        }
Exemple #3
0
        public static ReservationBase CreateReservation(Guid mailboxGuid, TenantPartitionHint partitionHint, Guid resourceId, ReservationFlags flags, string clientName)
        {
            ReservationBase result;

            using (DisposeGuard disposeGuard = default(DisposeGuard))
            {
                SettingsContextBase settingsContextBase = new MailboxSettingsContext(mailboxGuid, null);
                if (partitionHint != null)
                {
                    settingsContextBase = new OrganizationSettingsContext(OrganizationId.FromExternalDirectoryOrganizationId(partitionHint.GetExternalDirectoryOrganizationId()), settingsContextBase);
                }
                ReservationBase reservationBase;
                if (resourceId == MRSResource.Id.ObjectGuid)
                {
                    reservationBase = new MRSReservation();
                }
                else
                {
                    if (flags.HasFlag(ReservationFlags.Read))
                    {
                        reservationBase = new ReadReservation();
                    }
                    else
                    {
                        reservationBase = new WriteReservation();
                    }
                    settingsContextBase = new DatabaseSettingsContext(resourceId, settingsContextBase);
                }
                disposeGuard.Add <ReservationBase>(reservationBase);
                settingsContextBase           = new GenericSettingsContext("WorkloadType", reservationBase.WorkloadType.ToString(), settingsContextBase);
                reservationBase.MailboxGuid   = mailboxGuid;
                reservationBase.PartitionHint = partitionHint;
                reservationBase.ResourceId    = resourceId;
                reservationBase.Flags         = flags;
                reservationBase.ClientName    = clientName;
                using (settingsContextBase.Activate())
                {
                    reservationBase.ReserveResources();
                }
                disposeGuard.Success();
                result = reservationBase;
            }
            return(result);
        }