Ejemplo n.º 1
0
        public static void CreateJob(TransactionalRequestJob requestJob, ReservationContext reservation)
        {
            BaseJob baseJob;

            lock (MailboxSyncerJobs.syncRoot)
            {
                Guid guid = (requestJob.RequestType == MRSRequestType.Move) ? requestJob.ExchangeGuid : requestJob.RequestGuid;
                baseJob = MailboxSyncerJobs.FindJob(guid, false);
                if (baseJob != null)
                {
                    MrsTracer.Service.Error("Request {0} is already being worked on.", new object[]
                    {
                        guid
                    });
                    return;
                }
                baseJob = MailboxSyncerJobs.ConstructJob(requestJob);
                if (baseJob == null)
                {
                    MrsTracer.Service.Error("Don't know how to process '{0}' request", new object[]
                    {
                        requestJob.RequestType
                    });
                    return;
                }
                baseJob.Initialize(requestJob);
                baseJob.Reservation = reservation;
                MailboxSyncerJobs.activeJobs.Add(guid, baseJob);
                MailboxSyncerJobs.activeJobsIsEmpty.Reset();
            }
            JobScheduler.ScheduleJob(baseJob);
        }
        string IMailboxReplicationService.ValidateAndPopulateRequestJob(string requestJobXML, out string reportEntryXMLs)
        {
            string reportString = null;
            string resultString = null;

            try
            {
                this.ForwardKnownExceptions(delegate
                {
                    List <ReportEntry> list = new List <ReportEntry>();
                    try
                    {
                        RequestJobXML requestJob = XMLSerializableBase.Deserialize <RequestJobXML>(requestJobXML, true);
                        using (TransactionalRequestJob transactionalRequestJob = new TransactionalRequestJob(requestJob))
                        {
                            transactionalRequestJob.IsFake   = true;
                            transactionalRequestJob.Identity = new RequestJobObjectId((transactionalRequestJob.RequestType == MRSRequestType.Move) ? transactionalRequestJob.ExchangeGuid : transactionalRequestJob.RequestGuid, (transactionalRequestJob.WorkItemQueueMdb == null) ? Guid.Empty : transactionalRequestJob.WorkItemQueueMdb.ObjectGuid, null);
                            RequestIndexEntryProvider requestIndexEntryProvider = new RequestIndexEntryProvider();
                            using (requestIndexEntryProvider.RescopeTo(transactionalRequestJob.DomainControllerToUpdate, transactionalRequestJob.OrganizationId))
                            {
                                if (transactionalRequestJob.SourceUserId != null)
                                {
                                    transactionalRequestJob.SourceUser = requestIndexEntryProvider.ReadADUser(transactionalRequestJob.SourceUserId, transactionalRequestJob.SourceExchangeGuid);
                                }
                                if (transactionalRequestJob.TargetUserId != null)
                                {
                                    transactionalRequestJob.TargetUser = requestIndexEntryProvider.ReadADUser(transactionalRequestJob.TargetUserId, transactionalRequestJob.TargetExchangeGuid);
                                }
                            }
                            if (MailboxSyncerJobs.ContainsJob(transactionalRequestJob.IdentifyingGuid))
                            {
                                resultString = requestJobXML;
                            }
                            else
                            {
                                BaseJob baseJob = MailboxSyncerJobs.ConstructJob(transactionalRequestJob);
                                if (baseJob == null)
                                {
                                    MrsTracer.Service.Error("Don't know how to process '{0}' request", new object[]
                                    {
                                        transactionalRequestJob.RequestType
                                    });
                                    throw new RequestTypeNotUnderstoodPermanentException(CommonUtils.LocalComputerName, VersionInformation.MRS.ToString(), (int)transactionalRequestJob.RequestType);
                                }
                                using (baseJob)
                                {
                                    baseJob.Initialize(transactionalRequestJob);
                                    baseJob.ValidateAndPopulateRequestJob(list);
                                    transactionalRequestJob.Message              = baseJob.CachedRequestJob.Message;
                                    transactionalRequestJob.SourceVersion        = baseJob.CachedRequestJob.SourceVersion;
                                    transactionalRequestJob.SourceArchiveVersion = baseJob.CachedRequestJob.SourceArchiveVersion;
                                    transactionalRequestJob.SourceServer         = baseJob.CachedRequestJob.SourceServer;
                                    transactionalRequestJob.SourceArchiveServer  = baseJob.CachedRequestJob.SourceArchiveServer;
                                    transactionalRequestJob.TargetVersion        = baseJob.CachedRequestJob.TargetVersion;
                                    transactionalRequestJob.TargetArchiveVersion = baseJob.CachedRequestJob.TargetArchiveVersion;
                                    transactionalRequestJob.TargetServer         = baseJob.CachedRequestJob.TargetServer;
                                    transactionalRequestJob.TargetArchiveServer  = baseJob.CachedRequestJob.TargetArchiveServer;
                                    transactionalRequestJob.RemoteDatabaseGuid   = baseJob.CachedRequestJob.RemoteDatabaseGuid;
                                    resultString = XMLSerializableBase.Serialize(new RequestJobXML(transactionalRequestJob), false);
                                }
                            }
                        }
                    }
                    finally
                    {
                        reportString = XMLSerializableBase.Serialize(list, false);
                    }
                }, null);
            }
            finally
            {
                reportEntryXMLs = reportString;
            }
            return(resultString);
        }