Example #1
0
 public override byte[] EnqueueRequest(int version, int type, byte[] inputParameterBytes)
 {
     byte[] result;
     try
     {
         using (new Timer(new TimerCallback(RpcServerWrapper.CrashOnCallTimeout), Thread.CurrentThread, RpcServerWrapper.enqueueRequestTimeout, TimeSpan.FromMilliseconds(-1.0)))
         {
             EnqueueResult enqueueResult = JobQueueManager.Enqueue((QueueType)type, inputParameterBytes);
             EnqueueRequestRpcOutParameters enqueueRequestRpcOutParameters = new EnqueueRequestRpcOutParameters(enqueueResult);
             result = enqueueRequestRpcOutParameters.Serialize();
         }
     }
     catch (Exception ex)
     {
         ExWatson.SendReport(ex, ReportOptions.None, null);
         EnqueueRequestRpcOutParameters enqueueRequestRpcOutParameters = new EnqueueRequestRpcOutParameters(new EnqueueResult(EnqueueResultType.UnexpectedServerError, ServerStrings.RpcServerUnhandledException(ex.Message)));
         result = enqueueRequestRpcOutParameters.Serialize();
     }
     return(result);
 }
        public static EnqueueResult EnqueueTeamMailboxSyncRequest(string targetServer, Guid mailboxGuid, QueueType queueType, OrganizationId orgId, string clientString, string domainController, SyncOption syncOption = SyncOption.Default)
        {
            if (mailboxGuid == Guid.Empty)
            {
                throw new ArgumentNullException("mailboxGuid");
            }
            if (orgId == null)
            {
                throw new ArgumentNullException("orgId");
            }
            if (queueType != QueueType.TeamMailboxDocumentSync && queueType != QueueType.TeamMailboxMembershipSync && queueType != QueueType.TeamMailboxMaintenanceSync)
            {
                throw new ArgumentException("queueType");
            }
            RpcClientWrapper.InitializeIfNeeded();
            if (!RpcClientWrapper.instance.initialized)
            {
                return(new EnqueueResult(EnqueueResultType.ClientInitError, ClientStrings.RpcClientInitError));
            }
            EnqueueResult result;

            try
            {
                using (JobQueueRpcClient jobQueueRpcClient = new JobQueueRpcClient(targetServer ?? RpcClientWrapper.instance.localServer.Fqdn))
                {
                    TeamMailboxSyncRpcInParameters teamMailboxSyncRpcInParameters = new TeamMailboxSyncRpcInParameters(mailboxGuid, orgId, clientString, syncOption, domainController);
                    byte[] data = jobQueueRpcClient.EnqueueRequest(1, (int)queueType, teamMailboxSyncRpcInParameters.Serialize());
                    EnqueueRequestRpcOutParameters enqueueRequestRpcOutParameters = new EnqueueRequestRpcOutParameters(data);
                    result = enqueueRequestRpcOutParameters.Result;
                }
            }
            catch (RpcException ex)
            {
                result = new EnqueueResult(EnqueueResultType.RpcError, ClientStrings.RpcClientRequestError(ex.Message));
            }
            return(result);
        }