// Token: 0x0600020F RID: 527 RVA: 0x000081AC File Offset: 0x000063AC
        internal static DownloadResult SendRestRequest(string requestMethod, string requestUri, OwaIdentity identity, Stream requestStream, DataProviderCallLogEvent logEvent, string spCallName)
        {
            DownloadResult result;

            using (HttpClient httpClient = new HttpClient())
            {
                HttpSessionConfig httpSessionConfig = new HttpSessionConfig
                {
                    Method          = requestMethod,
                    Credentials     = OauthUtils.GetOauthCredential(identity.GetOWAMiniRecipient()),
                    UserAgent       = OneDriveProUtilities.UserAgentString,
                    RequestStream   = requestStream,
                    ContentType     = "application/json;odata=verbose",
                    PreAuthenticate = true
                };
                httpSessionConfig.Headers = OneDriveProUtilities.GetOAuthRequestHeaders();
                if (logEvent != null)
                {
                    logEvent.TrackSPCallBegin();
                }
                ICancelableAsyncResult cancelableAsyncResult = httpClient.BeginDownload(new Uri(requestUri), httpSessionConfig, null, null);
                cancelableAsyncResult.AsyncWaitHandle.WaitOne();
                DownloadResult downloadResult = httpClient.EndDownload(cancelableAsyncResult);
                if (logEvent != null)
                {
                    string correlationId = (downloadResult.ResponseHeaders == null) ? null : downloadResult.ResponseHeaders["SPRequestGuid"];
                    logEvent.TrackSPCallEnd(spCallName, correlationId);
                }
                result = downloadResult;
            }
            return(result);
        }
Пример #2
0
        // Token: 0x06000314 RID: 788 RVA: 0x000137EC File Offset: 0x000119EC
        private RfriStatus EndWrapper(string methodName, ICancelableAsyncResult asyncResult, Func <RfriDispatchTask, RfriStatus> endDelegate)
        {
            RfriStatus rfriStatus = RfriStatus.Success;

            RfriAsyncDispatch.ConditionalExceptionWrapper(ExTraceGlobals.ReferralTracer.IsTraceEnabled(TraceType.DebugTrace), delegate
            {
                DispatchTaskAsyncResult dispatchTaskAsyncResult = asyncResult as DispatchTaskAsyncResult;
                if (dispatchTaskAsyncResult != null)
                {
                    RfriDispatchTask rfriDispatchTask = (RfriDispatchTask)dispatchTaskAsyncResult.DispatchTask;
                    using (DisposeGuard disposeGuard = default(DisposeGuard))
                    {
                        disposeGuard.Add <RfriDispatchTask>(rfriDispatchTask);
                        rfriStatus = endDelegate(rfriDispatchTask);
                    }
                    ExTraceGlobals.ReferralTracer.TraceDebug <string, RfriStatus>(0, 0L, "{0} succeeded. RfriStatus={1}.", methodName, rfriStatus);
                    return;
                }
                FailureAsyncResult <RfriStatus> failureAsyncResult = asyncResult as FailureAsyncResult <RfriStatus>;
                if (failureAsyncResult != null)
                {
                    rfriStatus = failureAsyncResult.ErrorCode;
                    ExTraceGlobals.ReferralTracer.TraceDebug <string, RfriStatus, Exception>(0, 0L, "{0} failed. RfriStatus={1}. Exception={2}.", methodName, rfriStatus, failureAsyncResult.Exception);
                    return;
                }
                throw new InvalidOperationException(string.Format("Invalid IAsyncResult encountered; {0}", asyncResult));
            }, delegate(Exception exception)
            {
                ExTraceGlobals.ReferralTracer.TraceDebug <string, Exception>(0, 0L, "{0} failed. Exception={1}.", methodName, exception);
            });
            return(rfriStatus);
        }
        /// <summary>
        /// Enumerate the diff items found based on the query passed in as well as the filterString and version passed
        /// to InitializeForDiff.  The return type is IEnumerable<> so that adapter implementations do not need download and keep
        /// all of the IWITDiffItems in memory at once.
        /// </summary>
        /// <param name="queryCondition">A string that specifies a query used to select a subset of the work items defined by
        /// the set that the filter string identified.</param>
        /// <returns>An enumeration of IWITDiffItems each representing a work item to be compared by the WIT Diff operation</returns>
        public IEnumerable <IWITDiffItem> GetWITDiffItems(string queryCondition)
        {
            string columnList = "[System.Id], [System.Rev]";

            StringBuilder conditionBuilder = new StringBuilder(m_filterString);

            if (!string.IsNullOrEmpty(queryCondition))
            {
                if (conditionBuilder.Length > 0)
                {
                    conditionBuilder.Append(" AND ");
                }
                conditionBuilder.Append(queryCondition);
            }

            string orderBy = "[System.Id]";
            string wiql    = TfsWITQueryBuilder.BuildWiqlQuery(columnList, conditionBuilder.ToString(), orderBy);

            // Run query with date precision off
            Dictionary <string, object> context = new Dictionary <string, object>();

            context.Add("project", m_projectName);
            Query wiq = new Query(m_workItemStore, wiql, context, false);

            // Retrieve all results
            ICancelableAsyncResult car       = wiq.BeginQuery();
            WorkItemCollection     workItems = wiq.EndQuery(car);

            foreach (WorkItem workItem in workItems)
            {
                yield return((IWITDiffItem) new TfsWITDiffItem(this, workItem));
            }
        }
Пример #4
0
        /// <summary>
        /// Executes a query that gets a <see cref="WorkItemCollection"/> that contains <see cref="WorkItem"/> objects that satisfy the query.
        /// </summary>
        /// <param name="cancellationToken">Used to cancel the operation.</param>
        /// <returns>A list that contains <see cref="ITfsWorkItem"/> objects that satisfy the query.</returns>
        public IList <ITfsWorkItem> RunQuery(CancellationToken cancellationToken)
        {
            WorkItemCollection     workItems = null;
            ICancelableAsyncResult result    = this.query.BeginQuery();

            try
            {
                cancellationToken.Register(s => ((ICancelableAsyncResult)s).Cancel(), result);
                result.AsyncWaitHandle.WaitOne();
                cancellationToken.ThrowIfCancellationRequested();
            }
            finally
            {
                workItems = this.query.EndQuery(result);
            }

            IList <ITfsWorkItem> ans = new List <ITfsWorkItem>();

            foreach (WorkItem wi in workItems)
            {
                ans.Add(new TfsWorkItem(wi));
            }

            return(ans);
        }
Пример #5
0
        // Token: 0x06000313 RID: 787 RVA: 0x0001366C File Offset: 0x0001186C
        private ICancelableAsyncResult BeginWrapper(string methodName, CancelableAsyncCallback asyncCallback, object asyncState, ClientBinding clientBinding, string legacyDn, Func <RfriContext, RfriDispatchTask> beginDelegate)
        {
            ICancelableAsyncResult asyncResult = null;

            RfriAsyncDispatch.ConditionalExceptionWrapper(ExTraceGlobals.ReferralTracer.IsTraceEnabled(TraceType.DebugTrace), delegate
            {
                if (ExTraceGlobals.ReferralTracer.IsTraceEnabled(TraceType.DebugTrace))
                {
                    using (ClientSecurityContext clientSecurityContext = clientBinding.GetClientSecurityContext())
                    {
                        ExTraceGlobals.ReferralTracer.TraceDebug(0, 0L, "{0} started. LegacyDn={1}. ClientAddress={2}. ServerAddress={3}. ProtocolSequence={4}. EndPoint={5}. IsEncrypted={6}. ClientSecurityContext={7}.", new object[]
                        {
                            methodName,
                            legacyDn,
                            clientBinding.ClientAddress,
                            clientBinding.ServerAddress,
                            clientBinding.ProtocolSequence,
                            clientBinding.ClientEndpoint,
                            clientBinding.IsEncrypted,
                            clientSecurityContext
                        });
                    }
                }
                FailureAsyncResult <RfriStatus> failureAsyncResult = null;
                this.CheckShuttingDown();
                try
                {
                    using (DisposeGuard disposeGuard = default(DisposeGuard))
                    {
                        RfriContext rfriContext = RfriAsyncDispatch.CreateRfriContext(clientBinding);
                        disposeGuard.Add <RfriContext>(rfriContext);
                        RfriDispatchTask rfriDispatchTask = beginDelegate(rfriContext);
                        disposeGuard.Add <RfriDispatchTask>(rfriDispatchTask);
                        asyncResult = rfriDispatchTask.AsyncResult;
                        this.SubmitTask(rfriDispatchTask);
                        disposeGuard.Success();
                    }
                }
                catch (FailRpcException ex)
                {
                    failureAsyncResult = new FailureAsyncResult <RfriStatus>((RfriStatus)ex.ErrorCode, IntPtr.Zero, ex, asyncCallback, asyncState);
                    asyncResult        = failureAsyncResult;
                }
                catch (RfriException ex2)
                {
                    failureAsyncResult = new FailureAsyncResult <RfriStatus>(ex2.Status, IntPtr.Zero, ex2, asyncCallback, asyncState);
                    asyncResult        = failureAsyncResult;
                }
                if (failureAsyncResult != null && !ThreadPool.QueueUserWorkItem(RfriAsyncDispatch.FailureWaitCallback, failureAsyncResult))
                {
                    failureAsyncResult.InvokeCallback();
                }
                ExTraceGlobals.ReferralTracer.TraceDebug <string>(0, 0L, "{0} succeeded.", methodName);
            }, delegate(Exception exception)
            {
                ExTraceGlobals.ReferralTracer.TraceDebug <string, Exception>(0, 0L, "{0} failed. Exception={1}.", methodName, exception);
            });
            return(asyncResult);
        }
Пример #6
0
        public DataBlock GetItemBlock(IEnumerable <ItemIdentity> items, IEnumerable <string> columnNames)
        {
            // Build a query for them
            string query = String.Format("SELECT [System.Id] FROM WorkItems WHERE [System.Id] IN ({0})", String.Join(", ", items.Select((ii) => ii.ID)));
            Query  q     = new Query(this.Store, query, null, false);

            // Ask for fields we'll be populating to avoid additional network requests
            q.DisplayFieldList.Clear();
            foreach (string columnName in columnNames)
            {
                if (this.Store.FieldDefinitions.Contains(columnName))
                {
                    q.DisplayFieldList.Add(this.Store.FieldDefinitions[columnName]);
                }
                else if (columnName.Equals("attachments", StringComparison.OrdinalIgnoreCase))
                {
                    // Add AttachedFileCount to greatly speed loading attachments (if this is the only collection; rare)
                    q.DisplayFieldList.Add(this.Store.FieldDefinitions[CoreField.AttachedFileCount]);
                }
            }

            // Build a list of typed column details for the columns being used
            List <ColumnDetails> selectedDetails = new List <ColumnDetails>();

            foreach (string columnName in columnNames)
            {
                selectedDetails.Add(this.Columns[columnName]);
            }

            // Run the query
            ICancelableAsyncResult car            = q.BeginQuery();
            WorkItemCollection     itemCollection = q.EndQuery(car);

            // Copy the item field values into a DataBlock and track the last cutoff per group
            DataBlock result = new DataBlock(selectedDetails, items.Count());

            for (int itemIndex = 0; itemIndex < result.RowCount; ++itemIndex)
            {
                WorkItem item = itemCollection[itemIndex];

                int fieldIndex = 0;
                foreach (string columnName in columnNames)
                {
                    try
                    {
                        result[itemIndex, fieldIndex] = ItemProviderUtilities.Canonicalize(GetFieldValue(item, columnName));
                    }
                    catch (Exception ex)
                    {
                        result[itemIndex, fieldIndex] = null;
                        Trace.WriteLine(String.Format("Error Getting '{0}' from item {1}. Skipping field. Detail: {2}", columnName, item.Id, ex.ToString()));
                    }

                    fieldIndex++;
                }
            }

            return(result);
        }
        static partial void RealInstanceFactory(ref ICancelableAsyncResult real, string callerName)
        {
            var          store = WorkItemStoreWrapper_UnitTests.GetRealInstance();
            const string wiql  = "SELECT * FROM WorkItems WHERE [System.TeamProject] = 'RestPlaypen' ORDER BY [System.Id] ";
            var          query = new Query(store, wiql);

            real = query.BeginLinkQuery();
        }
        // Token: 0x060001A5 RID: 421 RVA: 0x00008FA8 File Offset: 0x000071A8
        private ICancelableAsyncResult BeginWrapper(string methodName, CancelableAsyncCallback asyncCallback, object asyncState, bool rundownContextOnFailure, Func <NspiContext, NspiDispatchTask> beginDelegate, Func <NspiContext> contextFactory)
        {
            int contextHandle = 0;
            ICancelableAsyncResult asyncResult = null;

            NspiAsyncDispatch.ConditionalExceptionWrapper(ExTraceGlobals.NspiTracer.IsTraceEnabled(TraceType.DebugTrace), delegate
            {
                bool flag = false;
                FailureAsyncResult <NspiStatus> failureAsyncResult = null;
                try
                {
                    this.CheckShuttingDown();
                    try
                    {
                        using (DisposeGuard disposeGuard = default(DisposeGuard))
                        {
                            NspiContext nspiContext           = contextFactory();
                            contextHandle                     = ((nspiContext != null) ? nspiContext.ContextHandle : 0);
                            NspiDispatchTask nspiDispatchTask = beginDelegate(nspiContext);
                            disposeGuard.Add <NspiDispatchTask>(nspiDispatchTask);
                            asyncResult = nspiDispatchTask.AsyncResult;
                            this.SubmitTask(nspiDispatchTask);
                            disposeGuard.Success();
                        }
                        flag = true;
                    }
                    catch (FailRpcException ex)
                    {
                        failureAsyncResult = new FailureAsyncResult <NspiStatus>((NspiStatus)ex.ErrorCode, new IntPtr(contextHandle), ex, asyncCallback, asyncState);
                        asyncResult        = failureAsyncResult;
                    }
                    catch (NspiException ex2)
                    {
                        failureAsyncResult = new FailureAsyncResult <NspiStatus>(ex2.Status, new IntPtr(contextHandle), ex2, asyncCallback, asyncState);
                        asyncResult        = failureAsyncResult;
                    }
                    if (failureAsyncResult != null && !ThreadPool.QueueUserWorkItem(NspiAsyncDispatch.FailureWaitCallback, failureAsyncResult))
                    {
                        failureAsyncResult.InvokeCallback();
                    }
                    ExTraceGlobals.NspiTracer.TraceDebug <string, int>(0, 0L, "{0} succeeded. ContextHandle={1}", methodName, contextHandle);
                }
                finally
                {
                    if (!flag && rundownContextOnFailure && contextHandle != 0)
                    {
                        this.ContextHandleRundown(new IntPtr(contextHandle));
                    }
                }
            }, delegate(Exception exception)
            {
                ExTraceGlobals.NspiTracer.TraceDebug <string, int, Exception>(0, 0L, "{0} failed. ContextHandle={1}, Exception={2}.", methodName, contextHandle, exception);
            });
            return(asyncResult);
        }
Пример #9
0
        internal static ICancelableAsyncResultWrapper GetInstance()
        {
            ICancelableAsyncResult real = default(ICancelableAsyncResult);

            RealInstanceFactory(ref real);
            var instance = (ICancelableAsyncResultWrapper)ICancelableAsyncResultWrapper.GetWrapper(real);

            InstanceFactory(ref instance);
            if (instance == null)
            {
                Assert.Inconclusive("Could not Create Test Instance");
            }
            return(instance);
        }
Пример #10
0
        private static void AcquireServerLicensingMexCallback(ICancelableAsyncResult asyncResult)
        {
            RmsServerInfoManager.Tracer.TraceDebug(0L, "AcquireServerLicensingMexCallback invoked");
            ArgumentValidator.ThrowIfNull("asyncResult", asyncResult);
            ArgumentValidator.ThrowIfNull("asyncResult.AsyncState", asyncResult.AsyncState);
            AcquireServerInfoAsyncResult acquireServerInfoAsyncResult = asyncResult.AsyncState as AcquireServerInfoAsyncResult;

            if (acquireServerInfoAsyncResult == null)
            {
                throw new InvalidOperationException("asyncResult.AsyncState has to be type of AcquireServerInfoAsyncResult.");
            }
            acquireServerInfoAsyncResult.AddBreadCrumb(Constants.State.AcquireServerLicensingMexCallback);
            Exception ex = null;

            try
            {
                DownloadResult downloadResult = acquireServerInfoAsyncResult.HttpClient.EndDownload(asyncResult);
                acquireServerInfoAsyncResult.LatencyTracker.EndTrackRmsLatency(RmsOperationType.AcquireServerLicensingMexData);
                if (downloadResult.IsSucceeded)
                {
                    Uri targetUriFromResponse = RmsClientManagerUtils.GetTargetUriFromResponse(downloadResult.ResponseStream);
                    if (targetUriFromResponse == null)
                    {
                        ex = new RightsManagementException(RightsManagementFailureCode.FailedToExtractTargetUriFromMex, ServerStrings.FailedToFindTargetUriFromMExData(acquireServerInfoAsyncResult.ServerLicensingMExUri), acquireServerInfoAsyncResult.LicenseUri.ToString());
                    }
                    else
                    {
                        acquireServerInfoAsyncResult.ServerInfo.ServerLicensingWSTargetUri = TokenTarget.Fix(targetUriFromResponse);
                        RmsServerInfoManager.serverInfoMap.Add(acquireServerInfoAsyncResult.ServerInfo);
                    }
                }
                else
                {
                    RmsClientManager.TraceFail(null, acquireServerInfoAsyncResult.Context.SystemProbeId, "Failed to download data from server licensing MEx {0}.  Exception is {1}", new object[]
                    {
                        acquireServerInfoAsyncResult.ServerLicensingMExUri,
                        downloadResult.Exception
                    });
                    ex = new RightsManagementException(RightsManagementFailureCode.FailedToDownloadMexData, ServerStrings.FailedToDownloadServerLicensingMExData(downloadResult.ResponseUri), downloadResult.Exception, acquireServerInfoAsyncResult.LicenseUri.ToString());
                    ((RightsManagementException)ex).IsPermanent = !downloadResult.IsRetryable;
                }
            }
            finally
            {
                acquireServerInfoAsyncResult.Release();
            }
            RmsServerInfoManager.Tracer.TraceDebug(0L, "AcquireServiceLocationCallback: Invoking find service location callbacks");
            RmsServerInfoManager.outstandingFindServiceLocationCalls.InvokeCallbacks(acquireServerInfoAsyncResult.LicenseUri, ex);
        }
        // Token: 0x06000198 RID: 408 RVA: 0x00008810 File Offset: 0x00006A10
        public NspiStatus EndGetIDsFromNames(ICancelableAsyncResult asyncResult, out PropertyTag[] propTags)
        {
            PropertyTag[] localPropTags = null;
            NspiStatus    result;

            try
            {
                result = this.EndContextWrapper("EndGetIDsFromNames", asyncResult, (NspiDispatchTask task) => ((NspiGetIDsFromNamesDispatchTask)task).End(out localPropTags));
            }
            finally
            {
                propTags = localPropTags;
            }
            return(result);
        }
        // Token: 0x06000194 RID: 404 RVA: 0x000085D0 File Offset: 0x000067D0
        public NspiStatus EndQueryColumns(ICancelableAsyncResult asyncResult, out PropertyTag[] columns)
        {
            PropertyTag[] localColumns = null;
            NspiStatus    result;

            try
            {
                result = this.EndContextWrapper("EndQueryColumns", asyncResult, (NspiDispatchTask task) => ((NspiQueryColumnsDispatchTask)task).End(out localColumns));
            }
            finally
            {
                columns = localColumns;
            }
            return(result);
        }
        // Token: 0x06000188 RID: 392 RVA: 0x00007FB4 File Offset: 0x000061B4
        public NspiStatus EndCompareDNTs(ICancelableAsyncResult asyncResult, out int result)
        {
            int        localResult = 0;
            NspiStatus result2;

            try
            {
                result2 = this.EndContextWrapper("EndCompareDNTs", asyncResult, (NspiDispatchTask task) => ((NspiCompareDNTsDispatchTask)task).End(out localResult));
            }
            finally
            {
                result = localResult;
            }
            return(result2);
        }
        // Token: 0x06000182 RID: 386 RVA: 0x00007C68 File Offset: 0x00005E68
        public NspiStatus EndDNToEph(ICancelableAsyncResult asyncResult, out int[] mids)
        {
            int[]      localMids = null;
            NspiStatus result;

            try
            {
                result = this.EndContextWrapper("EndDNToEph", asyncResult, (NspiDispatchTask task) => ((NspiDNToEphDispatchTask)task).End(out localMids));
            }
            finally
            {
                mids = localMids;
            }
            return(result);
        }
        // Token: 0x06000176 RID: 374 RVA: 0x000074EC File Offset: 0x000056EC
        public NspiStatus EndUnbind(ICancelableAsyncResult asyncResult, out IntPtr contextHandle)
        {
            int        localContextHandle = 0;
            NspiStatus result;

            try
            {
                result = this.EndWrapper("EndUnbind", asyncResult, true, (NspiDispatchTask task) => ((NspiUnbindDispatchTask)task).End(out localContextHandle));
            }
            finally
            {
                contextHandle = new IntPtr(localContextHandle);
            }
            return(result);
        }
Пример #16
0
        // Token: 0x06000308 RID: 776 RVA: 0x00012FDC File Offset: 0x000111DC
        public RfriStatus EndGetFQDNFromLegacyDN(ICancelableAsyncResult asyncResult, out string serverFqdn)
        {
            string     localServerFqdn = null;
            RfriStatus result;

            try
            {
                result = this.EndWrapper("EndGetFQDNFromLegacyDN", asyncResult, (RfriDispatchTask task) => ((RfriGetFQDNFromLegacyDNDispatchTask)task).End(out localServerFqdn));
            }
            finally
            {
                serverFqdn = localServerFqdn;
            }
            return(result);
        }
Пример #17
0
        // Token: 0x0600030C RID: 780 RVA: 0x0001322C File Offset: 0x0001142C
        public RfriStatus EndGetMailboxUrl(ICancelableAsyncResult asyncResult, out string serverUrl)
        {
            string     localServerUrl = null;
            RfriStatus result;

            try
            {
                result = this.EndWrapper("EndGetMailboxUrl", asyncResult, (RfriDispatchTask task) => ((RfriGetMailboxUrlDispatchTask)task).End(out localServerUrl));
            }
            finally
            {
                serverUrl = localServerUrl;
            }
            return(result);
        }
Пример #18
0
        // Token: 0x06000306 RID: 774 RVA: 0x00012EC4 File Offset: 0x000110C4
        public RfriStatus EndGetNewDSA(ICancelableAsyncResult asyncResult, out string serverDn)
        {
            string     localServerDn = null;
            RfriStatus result;

            try
            {
                result = this.EndWrapper("EndGetNewDSA", asyncResult, (RfriDispatchTask task) => ((RfriGetNewDSADispatchTask)task).End(out localServerDn));
            }
            finally
            {
                serverDn = localServerDn;
            }
            return(result);
        }
        // Token: 0x06000174 RID: 372 RVA: 0x000073A4 File Offset: 0x000055A4
        public NspiStatus EndBind(ICancelableAsyncResult asyncResult, out Guid?guid, out IntPtr contextHandle)
        {
            Guid?      localGuid          = new Guid?(default(Guid));
            int        localContextHandle = 0;
            NspiStatus result;

            try
            {
                result = this.EndWrapper("EndBind", asyncResult, true, (NspiDispatchTask task) => ((NspiBindDispatchTask)task).End(out localGuid, out localContextHandle));
            }
            finally
            {
                guid          = localGuid;
                contextHandle = new IntPtr(localContextHandle);
            }
            return(result);
        }
        // Token: 0x06000196 RID: 406 RVA: 0x000086E4 File Offset: 0x000068E4
        public NspiStatus EndGetNamesFromIDs(ICancelableAsyncResult asyncResult, out PropertyTag[] propTags, out SafeRpcMemoryHandle namesHandle)
        {
            PropertyTag[]       localPropTags    = null;
            SafeRpcMemoryHandle localNamesHandle = null;
            NspiStatus          result;

            try
            {
                result = this.EndContextWrapper("EndGetNamesFromIDs", asyncResult, (NspiDispatchTask task) => ((NspiGetNamesFromIDsDispatchTask)task).End(out localPropTags, out localNamesHandle));
            }
            finally
            {
                propTags    = localPropTags;
                namesHandle = localNamesHandle;
            }
            return(result);
        }
        // Token: 0x06000178 RID: 376 RVA: 0x00007608 File Offset: 0x00005808
        public NspiStatus EndUpdateStat(ICancelableAsyncResult asyncResult, out NspiState state, out int?delta)
        {
            NspiState  localState = null;
            int?       localDelta = null;
            NspiStatus result;

            try
            {
                result = this.EndContextWrapper("EndUpdateStat", asyncResult, (NspiDispatchTask task) => ((NspiUpdateStatDispatchTask)task).End(out localState, out localDelta));
            }
            finally
            {
                state = localState;
                delta = localDelta;
            }
            return(result);
        }
Пример #22
0
        private List <ItemIdentity> ExtractOneSet(string query, List <ItemIdentity> result)
        {
            Query q = new Query(this.Store, query, null, false);

            // Ask for ID only - we don't need anything else
            q.DisplayFieldList.Clear();
            q.DisplayFieldList.Add(this.Store.FieldDefinitions[CoreField.Id]);
            q.DisplayFieldList.Add(this.Store.FieldDefinitions[CoreField.ChangedDate]);

            // Sort by ChangedDate ascending for restartability
            q.SortFieldList.Clear();
            q.SortFieldList.Add(this.Store.FieldDefinitions[CoreField.ChangedDate].Name, SortType.Ascending);

            try
            {
                // Run the query
                ICancelableAsyncResult car   = q.BeginQuery();
                WorkItemCollection     items = q.EndQuery(car);
                // Set PageSize to Maximum, since we'll be reading all of them anyway.
                items.PageSize = 200;

                // Record the IDs to load
                int count = items.Count;

                for (int i = 0; i < count; ++i)
                {
                    WorkItem item = items[i];
                    result.Add(new ItemIdentity(item.Id, ItemProviderUtilities.CanonicalizeDateTime(item.ChangedDate)));
                }
            }
            catch (VerbatimMessageException ex)
            {
                Match match = Regex.Match(ex.Message, @"VS402337: The number of work items returned exceeds the size limit of (?<BatchSize>\d+)\.");
                if (match.Success)
                {
                    return(null);
                }
                else
                {
                    throw;
                }
            }

            return(result);
        }
Пример #23
0
        /// <summary>
        /// Executes a query that gets an array of <see cref="WorkItemLinkInfo"/> objects.
        /// </summary>
        /// <param name="cancellationToken">Used to cancel the operation.</param>
        /// <returns>The array of <see cref="WorkItemLinkInfo"/> objects that satisfied the query.</returns>
        public WorkItemLinkInfo[] RunLinkQuery(CancellationToken cancellationToken)
        {
            WorkItemLinkInfo[]     ans    = null;
            ICancelableAsyncResult result = this.query.BeginLinkQuery();

            try
            {
                cancellationToken.Register(s => ((ICancelableAsyncResult)s).Cancel(), result);
                result.AsyncWaitHandle.WaitOne();
                cancellationToken.ThrowIfCancellationRequested();
            }
            finally
            {
                ans = this.query.EndLinkQuery(result);
            }

            return(ans);
        }
        // Token: 0x06000180 RID: 384 RVA: 0x00007B58 File Offset: 0x00005D58
        public NspiStatus EndResortRestriction(ICancelableAsyncResult asyncResult, out NspiState state, out int[] mids)
        {
            NspiState localState = null;

            int[]      localMids = null;
            NspiStatus result;

            try
            {
                result = this.EndContextWrapper("EndResortRestriction", asyncResult, (NspiDispatchTask task) => ((NspiResortRestrictionDispatchTask)task).End(out localState, out localMids));
            }
            finally
            {
                state = localState;
                mids  = localMids;
            }
            return(result);
        }
        // Token: 0x0600018E RID: 398 RVA: 0x0000830C File Offset: 0x0000650C
        public NspiStatus EndGetTemplateInfo(ICancelableAsyncResult asyncResult, out int codePage, out PropertyValue[] row)
        {
            int localCodePage = 0;

            PropertyValue[] localRow = null;
            NspiStatus      result;

            try
            {
                result = this.EndContextWrapper("EndGetTemplateInfo", asyncResult, (NspiDispatchTask task) => ((NspiGetTemplateInfoDispatchTask)task).End(out localCodePage, out localRow));
            }
            finally
            {
                codePage = localCodePage;
                row      = localRow;
            }
            return(result);
        }
        // Token: 0x0600017A RID: 378 RVA: 0x0000775C File Offset: 0x0000595C
        public NspiStatus EndQueryRows(ICancelableAsyncResult asyncResult, out NspiState state, out PropertyValue[][] rowset)
        {
            NspiState localState = null;

            PropertyValue[][] localRowset = null;
            NspiStatus        result;

            try
            {
                result = this.EndContextWrapper("EndQueryRows", asyncResult, (NspiDispatchTask task) => ((NspiQueryRowsDispatchTask)task).End(out localState, out localRowset));
            }
            finally
            {
                state  = localState;
                rowset = localRowset;
            }
            return(result);
        }
        // Token: 0x0600018C RID: 396 RVA: 0x000081B0 File Offset: 0x000063B0
        public NspiStatus EndGetHierarchyInfo(ICancelableAsyncResult asyncResult, out int codePage, out int returnedVersion, out PropertyValue[][] rowset)
        {
            int localCodePage        = 0;
            int localReturnedVersion = 0;

            PropertyValue[][] localRowset = null;
            NspiStatus        result;

            try
            {
                result = this.EndContextWrapper("EndGetHierarchyInfo", asyncResult, (NspiDispatchTask task) => ((NspiGetHierarchyInfoDispatchTask)task).End(out localCodePage, out localReturnedVersion, out localRowset));
            }
            finally
            {
                codePage        = localCodePage;
                returnedVersion = localReturnedVersion;
                rowset          = localRowset;
            }
            return(result);
        }
        // Token: 0x0600019C RID: 412 RVA: 0x00008A80 File Offset: 0x00006C80
        public NspiStatus EndResolveNamesW(ICancelableAsyncResult asyncResult, out int codePage, out int[] mids, out PropertyValue[][] rowset)
        {
            int localCodePage = 0;

            int[]             localMids   = null;
            PropertyValue[][] localRowset = null;
            NspiStatus        result;

            try
            {
                result = this.EndContextWrapper("EndResolveNamesW", asyncResult, (NspiDispatchTask task) => ((NspiResolveNamesWDispatchTask)task).End(out localCodePage, out localMids, out localRowset));
            }
            finally
            {
                codePage = localCodePage;
                mids     = localMids;
                rowset   = localRowset;
            }
            return(result);
        }
Пример #29
0
 private XmlTextReader EndGetUsers(ICancelableAsyncResult asyncResult, out Exception exception)
 {
     try
     {
         exception = null;
         DownloadResult downloadResult = this.httpClient.EndDownload(asyncResult);
         if (!downloadResult.IsSucceeded)
         {
             WebException ex = downloadResult.Exception as WebException;
             if (ex != null)
             {
                 exception = new SharePointException((this.httpClient.LastKnownRequestedUri != null) ? this.httpClient.LastKnownRequestedUri.AbsoluteUri : string.Empty, ex, true);
             }
             else
             {
                 exception = downloadResult.Exception;
             }
         }
         else
         {
             if (downloadResult.ResponseStream == null)
             {
                 exception = new SharePointException((this.httpClient.LastKnownRequestedUri != null) ? this.httpClient.LastKnownRequestedUri.AbsoluteUri : string.Empty, ServerStrings.ErrorTeamMailboxGetUsersNullResponse);
                 return(null);
             }
             downloadResult.ResponseStream.Position = 0L;
             return(SafeXmlFactory.CreateSafeXmlTextReader(downloadResult.ResponseStream));
         }
     }
     finally
     {
         if (this.httpSessionConfig.RequestStream != null)
         {
             this.httpSessionConfig.RequestStream.Flush();
             this.httpSessionConfig.RequestStream.Dispose();
             this.httpSessionConfig.RequestStream = null;
         }
     }
     return(null);
 }
        // Token: 0x06000215 RID: 533 RVA: 0x00008674 File Offset: 0x00006874
        private static DownloadResult TryTwice(HttpClient httpClient, HttpSessionConfig sessionConfig, string url)
        {
            ICancelableAsyncResult cancelableAsyncResult = httpClient.BeginDownload(new Uri(url), sessionConfig, null, null);

            cancelableAsyncResult.AsyncWaitHandle.WaitOne();
            DownloadResult result = httpClient.EndDownload(cancelableAsyncResult);

            if (result.Exception != null)
            {
                if (!result.IsRetryable)
                {
                    throw result.Exception;
                }
                cancelableAsyncResult = httpClient.BeginDownload(new Uri(url), sessionConfig, null, null);
                cancelableAsyncResult.AsyncWaitHandle.WaitOne();
                result = httpClient.EndDownload(cancelableAsyncResult);
                if (result.Exception != null)
                {
                    throw result.Exception;
                }
            }
            return(result);
        }