コード例 #1
0
        public static bool HandleTaskWritePagedResult <T>(IEnumerable <T> dataObjects, SyncCookie inputCookie, ref SyncCookie outputCookie, SyncTaskHelper.ParameterlessMethod <bool> isStopping, SyncTaskHelper.OneParameterMethod <bool, IConfigurable> shouldSkipObject, SyncTaskHelper.VoidOneParameterMethod <IConfigurable> writeResult, int pages, Task.TaskVerboseLoggingDelegate writeVerbose, Task.TaskErrorLoggingDelegate writeError, out bool hasOutput) where T : IConfigurable, new()
        {
            TaskLogger.LogEnter(new object[]
            {
                dataObjects
            });
            ADPagedReader <T> adpagedReader = dataObjects as ADPagedReader <T>;

            hasOutput = false;
            using (IEnumerator <T> enumerator = dataObjects.GetEnumerator())
            {
                bool flag = true;
                SyncTaskHelper.CookieObjectTriple <T> cookieObjectTriple = null;
                byte[] cookie = adpagedReader.Cookie;
                bool   flag2  = enumerator.MoveNext();
                if (adpagedReader.LastRetrievedCount == 0 && adpagedReader.Cookie != null && adpagedReader.Cookie.Length != 0)
                {
                    return(false);
                }
                while (!isStopping() && flag2)
                {
                    T      t             = enumerator.Current;
                    byte[] pageCookie    = adpagedReader.Cookie;
                    int    pagesReturned = adpagedReader.PagesReturned;
                    flag2 = enumerator.MoveNext();
                    if (!shouldSkipObject(t))
                    {
                        hasOutput = true;
                        if (cookieObjectTriple != null)
                        {
                            if (cookieObjectTriple.CurrentPage != pagesReturned || flag)
                            {
                                outputCookie = cookieObjectTriple.Cookie;
                            }
                            else
                            {
                                outputCookie = null;
                            }
                            writeResult(cookieObjectTriple.DataObject);
                            if (outputCookie != null)
                            {
                                pages--;
                                if (pages < 0)
                                {
                                    break;
                                }
                            }
                            flag = false;
                        }
                        else
                        {
                            pageCookie = cookie;
                        }
                        cookieObjectTriple = new SyncTaskHelper.CookieObjectTriple <T>(pagesReturned, t, new SyncCookie(inputCookie.DomainController, inputCookie.LowWatermarks, inputCookie.HighWatermarks, pageCookie));
                    }
                }
                if (!flag2 && cookieObjectTriple != null && pages >= 0)
                {
                    outputCookie = new SyncCookie(inputCookie.DomainController, inputCookie.HighWatermarks, WatermarkMap.Empty, null);
                    writeResult(cookieObjectTriple.DataObject);
                }
            }
            TaskLogger.LogExit();
            return(true);
        }
コード例 #2
0
        public static bool HandleTaskWritePagedResult <T>(IEnumerable <T> dataObjects, IEnumerable <T> dataObjects2, SyncCookie inputCookie, ref SyncCookie outputCookie, SyncTaskHelper.ParameterlessMethod <bool> isStopping, SyncTaskHelper.OneParameterMethod <bool, IConfigurable> shouldSkipObject, SyncTaskHelper.VoidOneParameterMethod <IConfigurable> writeResult, int pages, Task.TaskVerboseLoggingDelegate writeVerbose, Task.TaskErrorLoggingDelegate writeError, out bool hasOutput) where T : IConfigurable, new()
        {
            TaskLogger.LogEnter(new object[]
            {
                dataObjects
            });
            int  num   = 1000;
            int  num2  = 0;
            bool flag  = true;
            bool flag2 = true;

            SyncTaskHelper.CookieObjectTriple <T> cookieObjectTriple = null;
            int num3 = 1;
            ADPagedReader <T> adpagedReader  = dataObjects as ADPagedReader <T>;
            ADPagedReader <T> adpagedReader2 = dataObjects2 as ADPagedReader <T>;

            byte[] pageCookie = null;
            byte[] array      = null;
            byte[] cookie     = adpagedReader.Cookie;
            byte[] cookie2    = adpagedReader2.Cookie;
            byte[] array2     = cookie2;
            hasOutput = false;
            for (;;)
            {
                using (IEnumerator <T> enumerator = flag ? dataObjects.GetEnumerator() : dataObjects2.GetEnumerator())
                {
                    bool flag3 = enumerator.MoveNext();
                    bool flag4 = !flag && ((cookieObjectTriple == null && num2 == 0) || (cookieObjectTriple != null && num2 == num - 1));
                    if ((adpagedReader.LastRetrievedCount == 0 && adpagedReader.Cookie != null && adpagedReader.Cookie.Length != 0) || (adpagedReader2.LastRetrievedCount == 0 && adpagedReader2.Cookie != null && adpagedReader2.Cookie.Length != 0))
                    {
                        return(false);
                    }
                    while (!isStopping() && flag3)
                    {
                        T t = enumerator.Current;
                        if (flag)
                        {
                            pageCookie = adpagedReader.Cookie;
                        }
                        else if (array != adpagedReader2.Cookie)
                        {
                            array2 = array;
                            array  = adpagedReader2.Cookie;
                        }
                        flag3 = enumerator.MoveNext();
                        if (!shouldSkipObject(t))
                        {
                            hasOutput = true;
                            if (cookieObjectTriple != null)
                            {
                                if (num2 == num - 1 || flag2)
                                {
                                    outputCookie = cookieObjectTriple.Cookie;
                                }
                                else
                                {
                                    outputCookie = null;
                                }
                                writeResult(cookieObjectTriple.DataObject);
                                flag2 = false;
                                if (num2 == num - 1)
                                {
                                    num2 = 0;
                                    num3++;
                                }
                                else
                                {
                                    num2++;
                                }
                                if (outputCookie != null)
                                {
                                    pages--;
                                    if (pages < 0)
                                    {
                                        break;
                                    }
                                }
                            }
                            else
                            {
                                pageCookie = cookie;
                                array      = cookie2;
                                array2     = cookie2;
                            }
                            cookieObjectTriple = new SyncTaskHelper.CookieObjectTriple <T>(num3, t, new SyncCookie(inputCookie.DomainController, inputCookie.LowWatermarks, inputCookie.HighWatermarks, pageCookie, flag4 ? array : array2));
                        }
                    }
                    if (pages >= 0)
                    {
                        if (!flag && !flag3 && cookieObjectTriple != null && pages >= 0)
                        {
                            outputCookie = new SyncCookie(inputCookie.DomainController, inputCookie.HighWatermarks, WatermarkMap.Empty, null, null);
                            writeResult(cookieObjectTriple.DataObject);
                        }
                        else if (flag)
                        {
                            flag = false;
                            continue;
                        }
                    }
                }
                break;
            }
            TaskLogger.LogExit();
            return(true);
        }
コード例 #3
0
        public static bool HandleTaskWritePagedResult <T>(IEnumerable <T> dataObjects, SyncCookie inputCookie, ref SyncCookie outputCookie, SyncTaskHelper.ParameterlessMethod <bool> isStopping, SyncTaskHelper.OneParameterMethod <bool, IConfigurable> shouldSkipObject, SyncTaskHelper.VoidOneParameterMethod <IConfigurable> writeResult, int pages, Task.TaskVerboseLoggingDelegate writeVerbose, Task.TaskErrorLoggingDelegate writeError) where T : IConfigurable, new()
        {
            bool flag;

            return(SyncTaskHelper.HandleTaskWritePagedResult <T>(dataObjects, inputCookie, ref outputCookie, isStopping, shouldSkipObject, writeResult, pages, writeVerbose, writeError, out flag));
        }