Exemplo n.º 1
0
 static void Main(string[] args)
 {
     BaseJob.Initialize(new List <BaseJob> {
     });
     BaseJob.Run();
     Console.ReadKey();
 }
        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);
        }