Beispiel #1
0
        internal IEnumerable <DatabaseEvent> ReadEvents(MapiSession mapiSession, Database database, long startCounter, Restriction restriction, bool includeMoveDestinationEvents, int resultSize)
        {
            if (mapiSession == null)
            {
                throw new ArgumentException("mapiSession");
            }
            if (database == null)
            {
                throw new ArgumentException("database");
            }
            int  count      = 0;
            long endCounter = (0L < startCounter) ? (startCounter - 1L) : 0L;

            MapiEvent[]      events       = null;
            DatabaseId       databaseId   = MapiTaskHelper.ConvertDatabaseADObjectToDatabaseId(database);
            MapiEventManager eventManager = MapiEventManager.Create(mapiSession.Administration, Guid.NewGuid(), databaseId.Guid);

            for (;;)
            {
                startCounter = endCounter + 1L;
                ReadEventsFlags flags = includeMoveDestinationEvents ? ReadEventsFlags.IncludeMoveDestinationEvents : ReadEventsFlags.None;
                mapiSession.InvokeWithWrappedException(delegate()
                {
                    events = eventManager.ReadEvents(startCounter, (0 < resultSize) ? resultSize : 1000, 0, restriction, flags, out endCounter);
                }, Strings.ErrorCannotReadDatabaseEvents(databaseId.ToString()), databaseId);
                foreach (MapiEvent mapiEvent in events)
                {
                    yield return(new DatabaseEvent(mapiEvent, databaseId, this.server, database.Server.ObjectGuid == this.server.Guid));

                    count++;
                    if (0 < resultSize && count == resultSize)
                    {
                        goto Block_6;
                    }
                }
                if (endCounter == startCounter)
                {
                    goto Block_8;
                }
            }
Block_6:
            yield break;
Block_8:
            yield break;
        }
        public async Task AddTagsAsync(List <string> tags)
        {
            if (File == null)
            {
                await SetStorageFileFromPathAsync(FilePath);
            }

            var props = await File.Properties.GetImagePropertiesAsync();

            foreach (var item in tags)
            {
                props.Keywords.Add(item);
                await DatabaseAccessService.InsertImageTagAsync(DatabaseId.ToString(), item);

                Tags.Add(item);
            }
            await props.SavePropertiesAsync();
        }
Beispiel #3
0
        internal IEnumerable <DatabaseEventWatermark> ReadWatermarks(MapiSession mapiSession, Database database, Guid?consumerGuid, Guid?mailboxGuid)
        {
            if (mapiSession == null)
            {
                throw new ArgumentException("mapiSession");
            }
            if (database == null)
            {
                throw new ArgumentException("database");
            }
            Watermark[] wms         = null;
            long        lastCounter = 0L;
            DatabaseId  databaseId  = MapiTaskHelper.ConvertDatabaseADObjectToDatabaseId(database);

            if (consumerGuid != null)
            {
                MapiEventManager eventManager = MapiEventManager.Create(mapiSession.Administration, consumerGuid.Value, databaseId.Guid);
                mapiSession.InvokeWithWrappedException(delegate()
                {
                    lastCounter = eventManager.ReadLastEvent().EventCounter;
                    if (mailboxGuid != null)
                    {
                        Watermark watermark = eventManager.GetWatermark(mailboxGuid.Value);
                        wms = ((watermark == null) ? new Watermark[0] : new Watermark[]
                        {
                            watermark
                        });
                        return;
                    }
                    wms = eventManager.GetWatermarks();
                }, Strings.ErrorCannotReadDatabaseWatermarks(databaseId.ToString()), databaseId);
                foreach (Watermark wm in wms)
                {
                    yield return(new DatabaseEventWatermark(wm, databaseId, lastCounter, this.server, database.Server.ObjectGuid == this.server.Guid));
                }
            }
            else
            {
                GetDatabaseEventWatermark.< > c__DisplayClass7 CS$ < > 8__locals3 = new GetDatabaseEventWatermark.< > c__DisplayClass7();
                CS$ < > 8__locals3.eventManager = MapiEventManager.Create(mapiSession.Administration, Guid.Empty, databaseId.Guid);
                if (mailboxGuid != null)
                {
                    CS$ < > 8__locals3.mailboxGuids = new Guid[]
                    {
                        mailboxGuid.Value
                    };
                }
                else if (database.IsPublicFolderDatabase)
                {
                    CS$ < > 8__locals3.mailboxGuids = new Guid[]
                    {
                        Guid.Empty
                    };
                }
                else
                {
                    PropValue[][] mailboxTable = null;
                    mapiSession.InvokeWithWrappedException(delegate()
                    {
                        mailboxTable = mapiSession.Administration.GetMailboxTable(databaseId.Guid, new PropTag[]
                        {
                            PropTag.UserGuid
                        });
                    }, Strings.ErrorCannotReadDatabaseWatermarks(databaseId.ToString()), databaseId);
                    CS$ < > 8__locals3.mailboxGuids    = new Guid[mailboxTable.Length + 1];
                    CS$ < > 8__locals3.mailboxGuids[0] = Guid.Empty;
                    for (int j = 0; j < mailboxTable.Length; j++)
                    {
                        CS$ < > 8__locals3.mailboxGuids[j + 1] = new Guid(mailboxTable[j][0].GetBytes());
                    }
                }
                CS$ < > 8__locals3.databaseVersionGuid = Guid.Empty;
                int i;
                for (i = 0; i < CS$ < > 8__locals3.mailboxGuids.Length; i++)
                {
                    mapiSession.InvokeWithWrappedException(delegate()
                    {
                        lastCounter = CS$ < > 8__locals3.eventManager.ReadLastEvent().EventCounter;
                        wms         = mapiSession.Administration.GetWatermarksForMailbox(databaseId.Guid, ref CS$ < > 8__locals3.databaseVersionGuid, CS$ < > 8__locals3.mailboxGuids[i]);
                    }, Strings.ErrorCannotReadDatabaseWatermarks(databaseId.ToString()), databaseId);
                    foreach (Watermark wm2 in wms)
                    {
                        yield return(new DatabaseEventWatermark(wm2, databaseId, lastCounter, this.server, database.Server.ObjectGuid == this.server.Guid));
                    }
                }
            }
            yield break;
        }