Example #1
0
        public bool Update(CDriver.Progress progress)
        {
            if (this.Events != null)
            {
                this.Events.Invalidate();
            }
            if (this.Tasks != null)
            {
                this.Tasks.Invalidate();
            }
            if (this.Notes != null)
            {
                this.Notes.Invalidate();
            }
            for (int i = 0; i < this.EmptyListsToPush.Length; i++)
            {
                this.EmptyListsToPush[i].Clear();
                this.EmptyLists[i].Clear();
            }
            int num  = 0;
            int num2 = 1000 / ((this.MedOrganizers.Length > 0) ? this.MedOrganizers.Length : 1);

            for (int j = 0; j < this.MedOrganizers.Length; j++)
            {
                IOrganizer organizer = this.MedOrganizers[j];
                IOperation operation = organizer.Cache() as IOperation;
                if (!CDriver.OperationToProgress(operation, progress, num, num + num2 / 2))
                {
                    return(false);
                }
                int num3;
                try
                {
                    num3 = organizer.StreamCount;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(this.ToString() + "Unable to query StreamCount property [ " + ex.Message + " ]");
                    num3 = 0;
                }
                for (int k = 1; k <= num3; k++)
                {
                    IOrganizerItem organizerItem = (IOrganizerItem)organizer.GetStream(k);
                    if (organizerItem.Type == 1)
                    {
                        this.Events.AddLast(new COrganizerEntry(this.Events, organizerItem, this.Events.EntryDescriptor));
                    }
                    else
                    {
                        if (organizerItem.Type == 3)
                        {
                            this.Notes.AddLast(new COrganizerEntry(this.Notes, organizerItem, this.Notes.EntryDescriptor));
                        }
                        else
                        {
                            if (organizerItem.Type == 2)
                            {
                                this.Tasks.AddLast(new COrganizerEntry(this.Tasks, organizerItem, this.Tasks.EntryDescriptor));
                            }
                            else
                            {
                                this.EmptyLists[j].AddLast(organizerItem);
                            }
                        }
                    }
                    if (!progress(num + num2 * k / num3 / 2 + num2 / 2))
                    {
                        return(false);
                    }
                }
                num += num2;
            }
            return(progress(1000));
        }