コード例 #1
0
        internal static CalendarEvent[] GetCalendarEvents(EmailAddress emailAddress, CalendarFolder calendarFolder, ExDateTime windowStart, ExDateTime windowEnd, FreeBusyViewType accessAllowed, bool canActAsMailboxOwner, ExchangeVersionType exchangeVersion)
        {
            CalendarEvent[] array = null;
            int             num   = 0;

            object[][] calendarView = calendarFolder.GetCalendarView(windowStart, windowEnd, InternalCalendarQuery.CalendarQueryProperties);
            InternalCalendarQuery.CalendarViewTracer.TraceDebug(0L, "{0}: Query for {1} found {2} appointment entries between {3} and {4}", new object[]
            {
                TraceContext.Get(),
                emailAddress,
                calendarView.Length,
                windowStart,
                windowEnd
            });
            num += calendarView.Length;
            if (num > Configuration.MaximumResultSetSize)
            {
                LocalizedException ex = new ResultSetTooBigException(Configuration.MaximumResultSetSize, num);
                InternalCalendarQuery.CalendarViewTracer.TraceError <object, EmailAddress, LocalizedException>(0L, "{0}: Query for {1} got exception getting Calendar Data. Exception: {2}", TraceContext.Get(), emailAddress, ex);
                throw ex;
            }
            int length = calendarView.GetLength(0);

            if (length > 0)
            {
                array = new CalendarEvent[length];
                for (int i = 0; i < length; i++)
                {
                    object[] properties = calendarView[i];
                    array[i] = CalendarEvent.CreateFromQueryData(emailAddress, properties, accessAllowed, canActAsMailboxOwner, exchangeVersion);
                }
            }
            return(array);
        }
コード例 #2
0
        /* Populates the appointments for an Exchange room in the Apps class */
        public static void GetResourceCalendarItems(ExchangeService service, string room, DateTime startDate, DateTime endDate)
        {
            try
            {
                CalendarView   cv = new CalendarView(startDate, endDate);
                String         MailboxToAccess       = room;
                FolderId       CalendarFolderId      = new FolderId(WellKnownFolderName.Calendar, MailboxToAccess);
                CalendarFolder calendar              = CalendarFolder.Bind(service, CalendarFolderId);
                FindItemsResults <Appointment> fapts = calendar.FindAppointments(cv);
                if (fapts.Items.Count > 0)
                {
                    foreach (Appointment a in fapts)
                    {
                        Appt appointment = new Appt(a.Location, a.Start, a.End, a.Subject.ToString());

                        if (!a.Subject.ToUpper().Contains("SET-UP") && !a.Subject.ToUpper().Contains("SETUP") && !a.Subject.ToUpper().Contains("SET UP") &&
                            !a.Subject.ToUpper().Contains("TEARDOWN") && !a.Subject.ToUpper().Contains("TEAR-DOWN") && !a.Subject.ToUpper().Contains("TEAR DOWN"))
                        {
                            if (!displayApps.Contains(appointment))
                            {
                                displayApps.Add(appointment);
                            }
                        }
                    }
                }
            }
            catch (Exception e) { }
        }
コード例 #3
0
        private DetailLevelEnumType?GetFreeBusyAccessLevel(PermissionSecurityPrincipal targetPrincipal)
        {
            DetailLevelEnumType?     result = null;
            CalendarFolderPermission calendarFolderPermission = null;

            using (CalendarFolder calendarFolder = (CalendarFolder)this.GetCalendarFolder())
            {
                CalendarFolderPermissionSet permissionSet = calendarFolder.GetPermissionSet();
                calendarFolderPermission = permissionSet.GetEntry(targetPrincipal);
                if (calendarFolderPermission != null)
                {
                    if ((calendarFolderPermission.MemberRights & MemberRights.ReadAny) == MemberRights.ReadAny)
                    {
                        result = new DetailLevelEnumType?(DetailLevelEnumType.FullDetails);
                    }
                    else if (calendarFolderPermission.FreeBusyAccess == FreeBusyAccess.Details)
                    {
                        result = new DetailLevelEnumType?(DetailLevelEnumType.LimitedDetails);
                    }
                    else if (calendarFolderPermission.FreeBusyAccess == FreeBusyAccess.Basic)
                    {
                        result = new DetailLevelEnumType?(DetailLevelEnumType.AvailabilityOnly);
                    }
                }
            }
            if (result == null)
            {
                ExTraceGlobals.SharingTracer.TraceDebug <SmtpAddress, string>((long)this.GetHashCode(), "ReachUser ={0}, Not authroized to view published calendar.  Permissions:{1}", targetPrincipal.ExternalUser.OriginalSmtpAddress, (calendarFolderPermission == null) ? "No permission" : calendarFolderPermission.MemberRights.ToString());
            }
            return(result);
        }
コード例 #4
0
 // Token: 0x06002FE1 RID: 12257 RVA: 0x00117704 File Offset: 0x00115904
 public static void BuildCalendarInfobar(Infobar infobar, UserContext userContext, OwaStoreObjectId folderId, int colorIndex, bool renderNotifyForOtherUser)
 {
     if (infobar == null)
     {
         throw new ArgumentNullException("infobar");
     }
     if (userContext.CalendarFolderOwaId.Equals(folderId))
     {
         return;
     }
     PropertyDefinition[] prefetchProperties = new PropertyDefinition[]
     {
         StoreObjectSchema.DisplayName,
         FolderSchema.ExtendedFolderFlags,
         StoreObjectSchema.ContainerClass
     };
     try
     {
         using (CalendarFolder folder = Utilities.GetFolder <CalendarFolder>(userContext, folderId, prefetchProperties))
         {
             SharedCalendarItemInfobar sharedCalendarItemInfobar = new SharedCalendarItemInfobar(userContext, folder, colorIndex, renderNotifyForOtherUser);
             sharedCalendarItemInfobar.Build(infobar);
         }
     }
     catch (WrongObjectTypeException)
     {
     }
 }
コード例 #5
0
 private void WorkWithPermissions(MailboxSession itemStore)
 {
     if (this.delegatesToAddPermission.Count > 0 || this.delegatesToRemovePermission.Count > 0 || this.policyMembersToAddPermission.Count > 0 || this.policyMembersToRemovePermission.Count > 0 || this.oldAllPolicy != this.newAllPolicy)
     {
         using (CalendarFolder calendarFolder = CalendarFolder.Bind(itemStore, DefaultFolderType.Calendar))
         {
             using (Folder folder = Folder.Create(itemStore, itemStore.GetDefaultFolderId(DefaultFolderType.Configuration), StoreObjectType.Folder, "Freebusy Data", CreateMode.OpenIfExists))
             {
                 CalendarFolderPermissionSet permissionSet = calendarFolder.GetPermissionSet();
                 PermissionSet permissionSet2 = folder.GetPermissionSet();
                 permissionSet.DefaultPermission.FreeBusyAccess = (this.newAllPolicy ? FreeBusyAccess.Details : FreeBusyAccess.Basic);
                 this.AddPermissions(permissionSet, permissionSet2);
                 this.RemovePermissions(permissionSet, permissionSet2);
                 FolderSaveResult folderSaveResult = folder.Save();
                 if (folderSaveResult != null && folderSaveResult.OperationResult != OperationResult.Succeeded)
                 {
                     base.ThrowTerminatingError(new FolderSaveException(Strings.CalendarSave, folderSaveResult), ErrorCategory.InvalidOperation, null);
                 }
                 folderSaveResult = calendarFolder.Save();
                 if (folderSaveResult != null && folderSaveResult.OperationResult != OperationResult.Succeeded)
                 {
                     base.ThrowTerminatingError(new FolderSaveException(Strings.CalendarSave, folderSaveResult), ErrorCategory.InvalidOperation, null);
                 }
             }
         }
         if (this.delegatesToAddPermission.Count > 0 || this.delegatesToRemovePermission.Count > 0)
         {
             this.DataObject.GrantSendOnBehalfTo = this.Instance.ResourceDelegates;
             base.DataSession.Save(this.DataObject);
         }
     }
 }
コード例 #6
0
        public void GetSecondaryNavigation()
        {
            ExTraceGlobals.MailCallTracer.TraceDebug((long)this.GetHashCode(), "NavigationEventHandler.GetSecondaryNavigation");
            switch ((NavigationModule)base.GetParameter("m"))
            {
            case NavigationModule.Mail:
                NavigationHost.RenderMailSecondaryNavigation(this.Writer, base.UserContext);
                return;

            case NavigationModule.Calendar:
                if (!base.UserContext.IsFeatureEnabled(Feature.Calendar))
                {
                    throw new OwaSegmentationException("The calendar is disabled");
                }
                using (CalendarFolder folder = Utilities.GetFolder <CalendarFolder>(base.UserContext, base.UserContext.CalendarFolderOwaId, new PropertyDefinition[]
                {
                    ViewStateProperties.CalendarViewType,
                    ViewStateProperties.DailyViewDays
                }))
                {
                    DailyView.RenderSecondaryNavigation(this.Writer, folder, base.UserContext);
                    return;
                }
                break;

            case NavigationModule.Contacts:
                break;

            case NavigationModule.Tasks:
                if (!base.UserContext.IsFeatureEnabled(Feature.Tasks))
                {
                    throw new OwaSegmentationException("Tasks are disabled");
                }
                TaskView.RenderSecondaryNavigation(this.Writer, base.UserContext);
                return;

            case NavigationModule.Options:
                return;

            case NavigationModule.AddressBook:
                DirectoryView.RenderSecondaryNavigation(this.Writer, base.UserContext);
                return;

            case NavigationModule.Documents:
                DocumentLibraryUtilities.RenderSecondaryNavigation(this.Writer, base.UserContext);
                return;

            case NavigationModule.PublicFolders:
                NavigationHost.RenderPublicFolderSecondaryNavigation(this.Writer, base.UserContext);
                return;

            default:
                return;
            }
            if (!base.UserContext.IsFeatureEnabled(Feature.Contacts))
            {
                throw new OwaSegmentationException("The Contacts feature is disabled");
            }
            ContactView.RenderSecondaryNavigation(this.Writer, base.UserContext, false);
        }
コード例 #7
0
        public IEnumerable <Meeting> GetMeetings(DateTime startDate, DateTime endDate)
        {
            var calendar = CalendarFolder.Bind(m_Service, WellKnownFolderName.Calendar, new PropertySet());
            var cView    = new CalendarView(startDate, endDate)
            {
                PropertySet = new PropertySet(ItemSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End, AppointmentSchema.IsMeeting, AppointmentSchema.Organizer, AppointmentSchema.MyResponseType)
            };
            FindItemsResults <Microsoft.Exchange.WebServices.Data.Appointment> appointments = calendar.FindAppointments(cView);

            foreach (Microsoft.Exchange.WebServices.Data.Appointment a in appointments)
            {
                if (!a.IsMeeting)
                {
                    continue;
                }

                var meeting = new Meeting(a.Id.ToString())
                {
                    Subject     = a.Subject,
                    Start       = a.Start,
                    End         = a.End,
                    Organizer   = a.Organizer.Name,
                    IsOrganizer = a.MyResponseType == MeetingResponseType.Organizer
                };
                yield return(meeting);
            }
        }
コード例 #8
0
        private async System.Threading.Tasks.Task DeleteAppointmentFromExchange(ClassCache oldCache)
        {
            CalendarFolder calendarFolder = null;

            for (int i = 0; i < 3; i++)
            {
                if (calendarFolder != null)
                {
                    break;
                }
                try
                {
                    calendarFolder = await CalendarFolder.Bind(Service, WellKnownFolderName.Calendar);
                }
                catch (ServiceRequestException) { }

                await System.Threading.Tasks.Task.Delay(50);
            }

            int attempt = 0;

            // Delete appointment from calendar
            CalendarView calendarView = new CalendarView(oldCache.StartOfWeek, oldCache.GetEndDayOfWeek());

            for (int i = 0; i < oldCache.ClassList.Count;)
            {
                if (attempt >= 3)
                {
#if DEBUG
                    System.Console.WriteLine("DEBUG - Too many delete attempts failed");
#endif
                    attempt = 0;
                    i++;
                    continue;
                }

                try
                {
                    Class       cls     = oldCache.ClassList[i];
                    Appointment appoint = await Appointment.Bind(Service, cls.AppointmentId);

                    appoint?.Delete(DeleteMode.SoftDelete);

                    attempt = 0;
                    i++;
#if DEBUG
                    System.Console.WriteLine("DEBUG - Deleted appointment {0}", cls.ModuleCode);
#endif
                }
                catch (ServiceRequestException)
                {
                    attempt++;
#if DEBUG
                    System.Console.WriteLine("DEBUG - Delete failed, attempt: ", attempt);
#endif
                }

                await System.Threading.Tasks.Task.Delay(50); // Avoid timeout execption
            }
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: ParagPundlik/WebSourceCode
        private static void ReadAppoitmentsInCalendar(ExchangeService service)
        {
            DateTime  startDate = DateTime.Now;
            DateTime  endDate   = startDate.AddDays(30);
            const int NUM_APPTS = 10;


            // Initialize the calendar folder object with only the folder ID.
            //CalendarFolder calendar = CalendarFolder.Bind(service, WellKnownFolderName.Calendar, new PropertySet());
            //Folder folder = new Folder(service);
            // Folder id for AcutechCalendar
            FolderId       folderID = new FolderId("AAMkADg4NTFkZTgwLTE3MGUtNGM0MC1hMjg0LWRlOTE1Yjg5YjMwOQAuAAAAAAD1wws5HI4XRpYtTLjy/6g+AQBUosiWYeNnRbdr4Mf1lS0DABMSUwA6AAA=");
            CalendarFolder calendar = CalendarFolder.Bind(service, folderID, new PropertySet());

            // Set the start and end time and number of appointments to retrieve.
            CalendarView cView = new CalendarView(startDate, endDate, NUM_APPTS);

            // Limit the properties returned to the appointment's subject, start time, and end time.
            cView.PropertySet = new PropertySet(AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End, AppointmentSchema.ICalUid);

            // Retrieve a collection of appointments by using the calendar view.
            FindItemsResults <Appointment> appointments = calendar.FindAppointments(cView);

            Console.WriteLine("\nThe first " + NUM_APPTS + " appointments on your calendar from " + startDate.Date.ToShortDateString() +
                              " to " + endDate.Date.ToShortDateString() + " are: \n");

            foreach (Appointment a in appointments)
            {
                Console.Write("Subject: " + a.Subject.ToString() + " ");
                Console.Write("Start: " + a.Start.ToString() + " ");
                Console.Write("End: " + a.End.ToString());
                //Console.Write("Calendar id: " + a.ICalUid.ToString());
                Console.WriteLine();
            }
        }
コード例 #10
0
        public void GetPublicFolderSecondaryNavigationFilter()
        {
            ExTraceGlobals.MailCallTracer.TraceDebug((long)this.GetHashCode(), "NavigationEventHandler.GetSecondaryNavigationFilter");
            string containerClass = (string)base.GetParameter("t");

            if (ObjectClass.IsCalendarFolder(containerClass))
            {
                OwaStoreObjectId folderId = (OwaStoreObjectId)base.GetParameter("fId");
                using (CalendarFolder folder = Utilities.GetFolder <CalendarFolder>(base.UserContext, folderId, new PropertyDefinition[]
                {
                    ViewStateProperties.CalendarViewType,
                    ViewStateProperties.DailyViewDays
                }))
                {
                    this.Writer.Write("<div id=divPFCalFlt style=\"display:none\">");
                    RenderingUtilities.RenderSecondaryNavigationDatePicker(folder, this.Writer, "divErrPfDp", "divPfDp", base.UserContext);
                    new MonthPicker(base.UserContext, "divPfMp").Render(this.Writer);
                    this.Writer.Write("</div>");
                    return;
                }
            }
            if (ObjectClass.IsContactsFolder(containerClass))
            {
                ContactView.RenderSecondaryNavigationFilter(this.Writer, "divPFCntFlt");
                return;
            }
            if (ObjectClass.IsTaskFolder(containerClass))
            {
                TaskView.RenderSecondaryNavigationFilter(this.Writer, "divPFTskFlt");
            }
        }
コード例 #11
0
ファイル: HomeService.cs プロジェクト: aatkuri/GDPOfficeHours
        private CalendarFolder FindNamedCalendarFolder(string name, string email, string password)
        {
            CalendarFolder calendar;

            try
            {
                FolderView view = new FolderView(100);
                view.PropertySet = new PropertySet(BasePropertySet.IdOnly);
                view.PropertySet.Add(FolderSchema.DisplayName);
                view.Traversal = FolderTraversal.Deep;

                SearchFilter sfSearchFilter = new SearchFilter.IsEqualTo(FolderSchema.FolderClass, "IPF.Appointment");

                FindFoldersResults findFolderResults = Service(email, password).FindFolders(WellKnownFolderName.Root, sfSearchFilter, view);
                calendar = findFolderResults.Where(f => f.DisplayName.ToUpper().Equals(name.ToUpper())).Cast <CalendarFolder>().FirstOrDefault();
                if (calendar != null)
                {
                    return(calendar);
                }
                else
                {
                    return(CalendarFolder.Bind(Service(email, password), WellKnownFolderName.Calendar, new PropertySet()));
                }
            }
            catch
            {
                throw;
            }
        }
コード例 #12
0
        private static FindItemsResults <Appointment> LoadResouceCallendar(CalendarFolder calendarFolder)
        {
            DateTime DateForImport = String.IsNullOrEmpty(WebConfigurationManager.AppSettings["DateForImport"]) ?
                                     DateTime.Today : DateTime.Parse(WebConfigurationManager.AppSettings["DateForImport"]);

            // Берем с часу ночи, чтобы не попадали мероприятия предидущего дня
            DateTime startDate = DateForImport.AddHours(1);
            DateTime endDate   = startDate.AddDays(1);

            const int NUM_APPTS = 25; // FindItem results should be requested in batches of 25.

            // Initialize the calendar folder object with only the folder ID.
            //CalendarFolder calendar = CalendarFolder.Bind(service, WellKnownFolderName.Calendar);

            // Set the start and end time and number of appointments to retrieve.
            CalendarView cView = new CalendarView(startDate, endDate, NUM_APPTS);

            // Limit the properties returned to the appointment's subject, start time, and end time.
            cView.PropertySet = new PropertySet(BasePropertySet.IdOnly);

            // Retrieve a collection of appointments by using the calendar view.
            // FindItemsResults<Appointment> appointments = calendar.FindAppointments(cView);
            return(calendarFolder.FindAppointments(cView));
            //service.FindAppointments(calendarFolder.Id, cView);
        }
コード例 #13
0
        internal static CalendarItemBase FindMatchingItem(MailboxSession session, CalendarFolder calendarFolder, CalendarItemType itemType, byte[] globalId, ref string errorString)
        {
            VersionedId calendarItemId = calendarFolder.GetCalendarItemId(globalId);

            if (calendarItemId == null)
            {
                errorString = string.Format("FindMatchingItem: Could not find calendar item, itemId is null. ", new object[0]);
                return(null);
            }
            CalendarItemBase result;

            try
            {
                result = CalendarItemBase.Bind(session, calendarItemId, CalendarQuery.CalendarQueryProps);
            }
            catch (ObjectNotFoundException ex)
            {
                errorString = string.Format("[{0}(UTC)] FindMatchingItem: Could not find calendar item, exception = {1}. ", ExDateTime.UtcNow, ex.GetType());
                result      = null;
            }
            catch (ArgumentException ex2)
            {
                errorString = string.Format("[{0}(UTC)] FindMatchingItem: Could not bind to item as CalendarItemBase, exception = {1}. ", ExDateTime.UtcNow, ex2.GetType());
                result      = null;
            }
            return(result);
        }
コード例 #14
0
        public async Task <string> GetAppointMentUrl(string id)
        {
            try
            {
                var calendarFolder = await CalendarFolder.Bind(this._exchangeService, WellKnownFolderName.Calendar,
                                                               new PropertySet());

                var searchFilter = new SearchFilter.IsEqualTo(ItemSchema.Id, id);
                var appointments = await calendarFolder.FindItems(searchFilter, new ItemView(1));

                var list        = new List <AppointMentDto>();
                var appointment = appointments.First() as Appointment;
                if (appointment == null)
                {
                    return("");
                }
                await appointment.Load(new PropertySet(
                                           ItemSchema.Id,
                                           AppointmentSchema.JoinOnlineMeetingUrl));

                return(appointment.JoinOnlineMeetingUrl);
            }
            catch (Exception e)
            {
                return("");
            }
        }
コード例 #15
0
ファイル: Program.cs プロジェクト: Kyuri93/RoomsLiberator
        static void Main(string[] args)
        {
            ServicePointManager.ServerCertificateValidationCallback = CertificateValidationCallBack;

            ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2016);

            service.Url          = new Uri("https://172.25.10.12/EWS/Exchange.asmx");
            service.Credentials  = new WebCredentials("*****@*****.**", "Qwerty1234");
            service.TraceEnabled = false;

            var rooms = GetAllRooms();

            var meetings = GetAllMeetings(rooms, service, new TimeWindow(DateTime.Now.AddMinutes(-30), DateTime.Now));
            //var a = meetings[0].Delete(DeleteMode.MoveToDeletedItems, SendCancellationsMode.SendToAllAndSaveCopy).Result;
            var org = service.ResolveName(meetings[0].Organizer.Name).Result;

            service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, org.FirstOrDefault().Mailbox.Address);

            var calendar = CalendarFolder.Bind(service, WellKnownFolderName.Calendar, new PropertySet()).Result;

            CalendarView cView = new CalendarView(DateTime.Now.AddMinutes(-30), DateTime.Now, 100);
            // Limit the properties returned to the appointment's subject, start time, and end time.
            //cView.PropertySet = new PropertySet(AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End);
            // Retrieve a collection of appointments by using the calendar view.
            FindItemsResults <Appointment> appointments = calendar.FindAppointments(cView).Result;
            //appointments.FirstOrDefault(x=>x.id)

            var res = appointments.Items[0].CancelMeeting("No one shoved up").Result;

            Console.ReadLine();
        }
コード例 #16
0
 private static void BindWithRecovery(MailboxSession session, Action <CalendarFolder> folderOperationDelegate)
 {
     ExTraceGlobals.BirthdayCalendarTracer.TraceDebug <Guid>(0L, "BirthdayCalendar::BindWithRecovery. MailboxGuid:{0}", session.MailboxGuid);
     try
     {
         using (CalendarFolder calendarFolder = CalendarFolder.Bind(session, DefaultFolderType.BirthdayCalendar))
         {
             ExTraceGlobals.BirthdayCalendarTracer.TraceDebug <Guid>(0L, "BirthdayCalendar::BindWithRecovery. First bind was successful. MailboxGuid:{0}", session.MailboxGuid);
             folderOperationDelegate(calendarFolder);
         }
     }
     catch (ObjectNotFoundException)
     {
         ExTraceGlobals.BirthdayCalendarTracer.TraceDebug <Guid>(0L, "BirthdayCalendar::BindWithRecovery. ObjectNotFound. MailboxGuid:{0}", session.MailboxGuid);
         StoreObjectId folderId;
         if (!session.TryFixDefaultFolderId(DefaultFolderType.BirthdayCalendar, out folderId))
         {
             ExTraceGlobals.BirthdayCalendarTracer.TraceDebug <Guid>(0L, "BirthdayCalendar::BindWithRecovery. Fixup unsuccessful. MailboxGuid:{0}", session.MailboxGuid);
             throw;
         }
         ExTraceGlobals.BirthdayCalendarTracer.TraceDebug <Guid>(0L, "BirthdayCalendar::BindWithRecovery. Fixup successful. MailboxGuid:{0}", session.MailboxGuid);
         using (CalendarFolder calendarFolder2 = CalendarFolder.Bind(session, folderId))
         {
             folderOperationDelegate(calendarFolder2);
         }
     }
 }
コード例 #17
0
        private static void InternalGetFolderViewStates(UserContext userContext, CalendarFolder folder, ref ExDateTime[] days, ref CalendarViewType viewType, out int viewWidth, out ReadingPanePosition readingPanePosition)
        {
            FolderViewStates folderViewStates = userContext.GetFolderViewStates(folder);

            CalendarUtilities.GetCalendarViewParamsFromViewStates(folderViewStates, out viewWidth, ref viewType, out readingPanePosition);
            days = CalendarUtilities.GetViewDays(userContext, days, viewType, OwaStoreObjectId.CreateFromStoreObject(folder), folderViewStates);
        }
コード例 #18
0
        public static bool?IsOrganizer(MailboxSession mailboxSession, GlobalObjectId globalObjectId, out string subject, out string organizerEmailAddress)
        {
            ExTraceGlobals.SyncTracer.TraceDebug <GlobalObjectId, bool>(0L, "[MeetingOrganizerValidatior.IsOrganizer] Search IsOrganizer GOID: {0}, IsCleanGoID: {1}", globalObjectId, globalObjectId.IsCleanGlobalObjectId);
            subject = null;
            organizerEmailAddress = null;
            if (!globalObjectId.IsCleanGlobalObjectId)
            {
                globalObjectId = new GlobalObjectId(globalObjectId.CleanGlobalObjectIdBytes);
            }
            bool value = false;
            bool flag  = MeetingOrganizerValidator.SearchForCalendarItem(mailboxSession, mailboxSession.GetDefaultFolderId(DefaultFolderType.Calendar), globalObjectId, out value, out subject, out organizerEmailAddress);

            if (!flag)
            {
                ExTraceGlobals.SyncTracer.TraceDebug(0L, "[MeetingOrganizerValidatior.IsOrganizer] Correlated CalendarItem not found in default calendar folder.  Searching in calendar sub folders...");
                using (Folder folder = Folder.Bind(mailboxSession, DefaultFolderType.Calendar))
                {
                    using (QueryResult queryResult = folder.FolderQuery(FolderQueryFlags.DeepTraversal, null, null, MeetingOrganizerValidator.FetchProperties))
                    {
                        bool flag2 = true;
                        while (flag2)
                        {
                            object[][] rows = queryResult.GetRows(10000);
                            if (rows == null || rows.Length == 0)
                            {
                                break;
                            }
                            for (int i = 0; i < rows.Length; i++)
                            {
                                VersionedId   versionedId         = rows[i][0] as VersionedId;
                                StoreObjectId storeObjectId       = (versionedId != null) ? versionedId.ObjectId : null;
                                int?          num                 = rows[i][1] as int?;
                                int           extendedFolderFlags = (num != null) ? num.Value : 0;
                                if (storeObjectId == null || CalendarFolder.IsCrossOrgShareFolder(extendedFolderFlags) || CalendarFolder.IsInternetCalendar(extendedFolderFlags))
                                {
                                    ExTraceGlobals.SyncTracer.TraceDebug <StoreObjectId>(0L, "[MeetingOrganizerValidator.IsOrganizer] Skipping Calendar '{0}' as it is either a sharing folder or iCal folder", storeObjectId);
                                }
                                else
                                {
                                    flag = MeetingOrganizerValidator.SearchForCalendarItem(mailboxSession, storeObjectId, globalObjectId, out value, out subject, out organizerEmailAddress);
                                    if (flag)
                                    {
                                        flag2 = false;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    goto IL_16D;
                }
            }
            ExTraceGlobals.SyncTracer.TraceDebug(0L, "[MeetingOrganizerValidatior.IsOrganizer] Correlated CalendarItem found in default calendar folder");
IL_16D:
            if (!flag)
            {
                return(null);
            }
            return(new bool?(value));
        }
コード例 #19
0
        private static bool SearchForCalendarItem(MailboxSession session, StoreObjectId folderId, GlobalObjectId globalObjectId, out bool isOrganizer, out string subject, out string organizerEmailAddress)
        {
            StoreId arg = null;

            isOrganizer           = false;
            subject               = null;
            organizerEmailAddress = null;
            using (CalendarFolder calendarFolder = CalendarFolder.Bind(session, folderId, null))
            {
                PropertyBag calendarItemProperties = calendarFolder.GetCalendarItemProperties(globalObjectId.Bytes, MeetingOrganizerValidator.CalendarOrganizerProperties);
                if (calendarItemProperties == null)
                {
                    ExTraceGlobals.StorageTracer.TraceDebug <string>(0L, "Related Calendar Item not found in calendar folder : '{0}'", calendarFolder.DisplayName);
                    return(false);
                }
                arg = calendarItemProperties.GetValueOrDefault <VersionedId>(InternalSchema.ItemId);
                string valueOrDefault = calendarItemProperties.GetValueOrDefault <string>(InternalSchema.ItemClass);
                AppointmentStateFlags valueOrDefault2 = calendarItemProperties.GetValueOrDefault <AppointmentStateFlags>(InternalSchema.AppointmentStateInternal);
                isOrganizer           = IsOrganizerProperty.GetForCalendarItem(valueOrDefault, valueOrDefault2);
                subject               = calendarItemProperties.GetValueOrDefault <string>(InternalSchema.MapiSubject);
                organizerEmailAddress = calendarItemProperties.GetValueOrDefault <string>(InternalSchema.SentRepresentingEmailAddress);
            }
            ExTraceGlobals.SyncTracer.TraceDebug <StoreId, bool>(0L, "Related Calendar Item found. Id: {0}.  Is Organizer? {1}", arg, isOrganizer);
            return(true);
        }
コード例 #20
0
ファイル: Program.cs プロジェクト: rtopken/CalBackup
        // If not there - then it will create it. Otherwise finds it.
        public static void GetRestoreFld()
        {
            CalendarFolder fld = new CalendarFolder(exService);

            fld.DisplayName = "CalRestore";

            bool bEmpty = false;

            try
            {
                Console.WriteLine("Accessing/Creating the CalRestore folder.");
                fld.Save(WellKnownFolderName.Calendar);
            }
            catch (ServiceResponseException ex)
            {
                if (!(ex.ErrorCode.ToString().ToUpper() == "ERRORFOLDEREXISTS"))
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("");
                    Console.WriteLine(ex.Message);
                    Console.ResetColor();
                    return;
                }
                else
                {
                    fld = FindCalFolder("CalRestore");
                    Console.WriteLine("Removing previously restored items from the CalRestore folder.");
                    bEmpty = EmptyFolder(fld);
                    Console.WriteLine("\r\nFinished removing items from the CalRestore folder.");
                }
            }
            fldCalRestore = fld;
        }
コード例 #21
0
        public void CancelAppointment(Appointment appointment)
        {
            var service = InitService();

            var organizer = service.ResolveName(appointment.Organizer.Name).Result.FirstOrDefault();

            if (organizer != null)
            {
                service.ImpersonatedUserId =
                    new ImpersonatedUserId(ConnectingIdType.SmtpAddress, organizer.Mailbox.Address);

                var calendar = CalendarFolder.Bind(service, WellKnownFolderName.Calendar, new PropertySet()).Result;

                CalendarView cView = new CalendarView(appointment.Start, appointment.End, 100);
                // Limit the properties returned to the appointment's subject, start time, and end time.
                //cView.PropertySet = new PropertySet(AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End);
                // Retrieve a collection of appointments by using the calendar view.
                FindItemsResults <Appointment> appointments = calendar.FindAppointments(cView).Result;

                var a = appointments.Items.FirstOrDefault(x => x.ICalUid == appointment.ICalUid);
                //appointments.FirstOrDefault(x=>x.id)

                var res = a.CancelMeeting("No one shoved up").Result;
            }
        }
コード例 #22
0
 protected override PerformInvitationResults InternalPerformInvitation(MailboxSession mailboxSession, SharingContext context, ValidRecipient[] recipients, IFrontEndLocator frontEndLocator)
 {
     using (CalendarFolder calendarFolder = CalendarFolder.Bind(mailboxSession, context.FolderId, CalendarFolderSchema.ConsumerCalendarProperties))
     {
         Guid a = calendarFolder.ConsumerCalendarGuid;
         Guid consumerCalendarPrivateFreeBusyId = calendarFolder.ConsumerCalendarPrivateFreeBusyId;
         Guid consumerCalendarPrivateDetailId   = calendarFolder.ConsumerCalendarPrivateDetailId;
         if (a == Guid.Empty)
         {
             a = (calendarFolder.ConsumerCalendarGuid = Guid.NewGuid());
         }
         if (consumerCalendarPrivateFreeBusyId == Guid.Empty)
         {
             Guid guid = calendarFolder.ConsumerCalendarPrivateFreeBusyId = Guid.NewGuid();
         }
         if (consumerCalendarPrivateDetailId == Guid.Empty)
         {
             Guid guid2 = calendarFolder.ConsumerCalendarPrivateDetailId = Guid.NewGuid();
         }
         if (calendarFolder.IsDirty)
         {
             FolderSaveResult folderSaveResult = calendarFolder.Save();
             if (folderSaveResult.OperationResult != OperationResult.Succeeded)
             {
                 throw folderSaveResult.ToException(new LocalizedString("TODO: LOC: Failed to share the calendar."));
             }
         }
         context.FolderEwsId = a.ToString();
         context.MailboxId   = ((IUserPrincipal)mailboxSession.MailboxOwner).NetId.ToByteArray();
         context.FolderName  = (context.IsPrimary ? string.Format("TODO: LOC: {0}'s Calendar", context.InitiatorName) : calendarFolder.DisplayName);
         context.IsPrimary   = false;
     }
     return(new PerformInvitationResults(recipients));
 }
コード例 #23
0
        public static int GetWorkingDays(CalendarAdapterBase calendarAdapter, ISessionContext sessionContext)
        {
            int result;

            if (calendarAdapter.DataSource.SharedType == SharedType.AnonymousAccess)
            {
                result = sessionContext.WorkingHours.WorkDays;
            }
            else if (calendarAdapter is CalendarAdapter)
            {
                CalendarFolder   folder   = ((CalendarAdapter)calendarAdapter).Folder;
                OwaStoreObjectId folderId = ((CalendarAdapter)calendarAdapter).FolderId;
                if (folder != null && Utilities.IsOtherMailbox(folder) && folderId.IsGSCalendar)
                {
                    result = calendarAdapter.DataSource.WorkingHours.WorkDays;
                }
                else
                {
                    result = sessionContext.WorkingHours.WorkDays;
                }
            }
            else
            {
                result = sessionContext.WorkingHours.WorkDays;
            }
            return(result);
        }
コード例 #24
0
        public object[][] GetCalendarView(ExDateTime startTime, ExDateTime endTime, params PropertyDefinition[] dataColumns)
        {
            base.CheckDisposed("GetCalendarView");
            if (startTime > endTime)
            {
                throw new ArgumentException(ServerStrings.ExInvalidDateTimeRange((DateTime)startTime, (DateTime)endTime));
            }
            ExDateTime calendarViewFromDateTime = this.GetCalendarViewFromDateTime(startTime);
            ExDateTime calendarViewToDateTime   = this.GetCalendarViewToDateTime(endTime);

            if (calendarViewFromDateTime > calendarViewToDateTime)
            {
                ExTraceGlobals.SharingTracer.TraceError <string, ExDateTime, ExDateTime>((long)this.GetHashCode(), "{0}: GetCalendarView: the request window is out of range of published window. CalendarViewFromDateTime = {1}; CalendarViewToDateTime = {2}.", base.OwnerDisplayName, calendarViewFromDateTime, calendarViewToDateTime);
                return(Array <object[]> .Empty);
            }
            ExTraceGlobals.SharingTracer.TraceDebug((long)this.GetHashCode(), "{0}: GetCalendarView: FolderId = {1}; DetailLevel = {2}; CalendarViewFromDateTime = {3}; CalendarViewToDateTime = {4}.", new object[]
            {
                base.OwnerDisplayName,
                base.FolderId,
                this.DetailLevel,
                calendarViewFromDateTime,
                calendarViewToDateTime
            });
            object[][] result;
            using (CalendarFolder calendarFolder = CalendarFolder.Bind(base.MailboxSession, base.FolderId))
            {
                result = calendarFolder.InternalGetCalendarView(calendarViewFromDateTime, calendarViewToDateTime, this.DetailLevel == DetailLevelEnumType.AvailabilityOnly, true, true, RecurrenceExpansionOption.IncludeRegularOccurrences, dataColumns);
            }
            return(result);
        }
コード例 #25
0
        // Token: 0x0600258F RID: 9615 RVA: 0x000D943C File Offset: 0x000D763C
        internal SharedCalendarItemInfobar(UserContext userContext, CalendarFolder folder, int colorIndex, bool renderNotifyForOtherUser)
        {
            if (userContext == null)
            {
                throw new ArgumentNullException("userContext");
            }
            if (folder == null)
            {
                throw new ArgumentNullException("folder");
            }
            this.userContext = userContext;
            this.folder      = folder;
            this.colorIndex  = colorIndex;
            this.renderNotifyForOtherUser = renderNotifyForOtherUser;
            this.isSharedOutFolder        = Utilities.IsFolderSharedOut(folder);
            OwaStoreObjectId owaStoreObjectId = OwaStoreObjectId.CreateFromStoreObject(folder);

            if (owaStoreObjectId.GetSession(userContext) is MailboxSession)
            {
                this.folderEncodedDisplayName = Utilities.SanitizeHtmlEncode(string.Format(LocalizedStrings.GetNonEncoded(-83764036), folder.DisplayName, Utilities.GetMailboxOwnerDisplayName((MailboxSession)owaStoreObjectId.GetSession(userContext))));
            }
            else
            {
                this.folderEncodedDisplayName = Utilities.SanitizeHtmlEncode(folder.DisplayName);
            }
            this.isSharedFolder = (owaStoreObjectId != null && owaStoreObjectId.IsOtherMailbox);
            this.isPublicFolder = owaStoreObjectId.IsPublic;
            if (this.isSharedFolder)
            {
                this.folderOwnerEncodedName = Utilities.SanitizeHtmlEncode(Utilities.GetFolderOwnerExchangePrincipal(owaStoreObjectId, userContext).MailboxInfo.DisplayName);
            }
            this.containerClass = folder.GetValueOrDefault <string>(StoreObjectSchema.ContainerClass, "IPF.Appointment");
        }
コード例 #26
0
ファイル: DailyView.cs プロジェクト: YHZX2013/exchange_diff
 internal static void RenderSecondaryNavigation(TextWriter output, CalendarFolder folder, UserContext userContext)
 {
     output.Write("<div id=\"divCalPicker\">");
     RenderingUtilities.RenderSecondaryNavigationDatePicker(folder, output, "divErrDP", "dp", userContext);
     new MonthPicker(userContext, "divMp").Render(output);
     output.Write("</div>");
     NavigationHost.RenderNavigationTreeControl(output, userContext, NavigationModule.Calendar);
 }
コード例 #27
0
        private void GetNextMeetingInfo()
        {
            ExchangeService service = new ExchangeService();

            service.Credentials        = new WebCredentials(Environment.GetEnvironmentVariable("EXCHANGE_PROXY_USERNAME"), Environment.GetEnvironmentVariable("EXCHANGE_PROXY_PASSWORD"));
            service.Url                = new Uri(ConfigurationManager.AppSettings["ExchangeWebServiceURL"]);
            service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, ConfigurationManager.AppSettings["ExchangeRoomID"]);

            CalendarFolder calendar = CalendarFolder.Bind(service, WellKnownFolderName.Calendar, new PropertySet());

            CalendarView cView = new CalendarView(DateTime.Today, DateTime.Today.AddDays(2));

            cView.PropertySet = new PropertySet(AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End, AppointmentSchema.Organizer);

            FindItemsResults <Appointment> appointments = calendar.FindAppointments(cView);
            Appointment nextAppointment = null;

            foreach (Appointment a in appointments)
            {
                if ((nextAppointment == null || a.Start < nextAppointment.Start) && a.Start > DateTime.Now.AddMinutes(-30))
                {
                    nextAppointment = a;
                }
            }

            nextAppointment.Load();

            Data.MeetingTitle        = nextAppointment.Subject;
            Data.NextMeetingStartsAt = "Next meeting at " + nextAppointment.Start.ToString("h:mm tt");

            var organizer = service.ResolveName(nextAppointment.Organizer.Address)[0];

            Data.OrganizerName = nextAppointment.Organizer.Name;

            foreach (var attend in nextAppointment.RequiredAttendees)
            {
                var attendee = service.ResolveName(attend.Address)[0];
                Data.RequiredAttendees.Add(new DataForUI.Attendee()
                {
                    Name    = attend.Name,
                    NetID   = attendee.Mailbox.Name,
                    Arrived = false
                });
            }

            foreach (var attend in nextAppointment.OptionalAttendees)
            {
                var attendee = service.ResolveName(attend.Address)[0];
                Data.OptionalAttendees.Add(new DataForUI.Attendee()
                {
                    Name    = attend.Name,
                    NetID   = attendee.Mailbox.Name,
                    Arrived = false
                });
            }
        }
コード例 #28
0
        public static data.ScheduleData LoadResouceCallendar(string ResourceName)
        {
            ExchangeService service = ExchangeHelper.GetExchangeServiceConnection();

            SetExchangeServiceHttpHeader(service, "X-AnchorMailbox", MailBoxAddress);

            PropertySet psPropset = new PropertySet(BasePropertySet.FirstClassProperties);
            ExtendedPropertyDefinition PidTagWlinkAddressBookEID = new ExtendedPropertyDefinition(0x6854, MapiPropertyType.Binary);
            ExtendedPropertyDefinition PidTagWlinkFolderType     = new ExtendedPropertyDefinition(0x684F, MapiPropertyType.Binary);

            psPropset.Add(PidTagWlinkAddressBookEID);
            psPropset.Add(PidTagWlinkFolderType);

            NameResolutionCollection resolve = service.ResolveName(ResourceName, ResolveNameSearchLocation.DirectoryOnly, false, psPropset);

            FindItemsResults <Appointment> findResults = null;

            if (resolve.Count > 0)
            {
                try
                {
                    SetExchangeServiceHttpHeader(service, "X-AnchorMailbox", resolve[0].Mailbox.Address);
                    //  service.HttpHeaders.Add("X-AnchorMailbox", resolve[0].Mailbox.Address);
                    FolderId       SharedCalendarId = new FolderId(WellKnownFolderName.Calendar, resolve[0].Mailbox.Address);
                    CalendarFolder cf = CalendarFolder.Bind(service, SharedCalendarId);
                    findResults = LoadResouceCallendar(cf);
                }
                catch (Microsoft.Exchange.WebServices.Data.ServiceResponseException ex)
                {
                    Trace.TraceError("Error reading calendar for resource {0} ErrMsg: {1}", ResourceName, ex.Message);
                    throw ex;
                }
                //Folder SharedCalendaFolder = Folder.Bind(service, SharedCalendarId);
            }
            else
            {
                throw new ApplicationException(String.Format("Error resolving resource name in GAL: {0}", ResourceName));
            }



            if (findResults != null && findResults.TotalCount > 0)
            {
                service.LoadPropertiesForItems(from Item item in findResults select item,
                                               new PropertySet(BasePropertySet.IdOnly, AppointmentSchema.Start, AppointmentSchema.End,
                                                               AppointmentSchema.Location, AppointmentSchema.Subject, AppointmentSchema.Categories, OnlineMeetingExternalLink,
                                                               AppointmentSchema.IsAllDayEvent, AppointmentSchema.Sensitivity, AppointmentSchema.Organizer));
            }

            return(new data.ScheduleData {
                RoomId = ResourceName, Schedule = ConvertToSerializable(findResults, ResourceName)
            });

            /*  PropertySet props = new PropertySet();
             * CalendarFolder.Bind(service,WellKnownFolderName.Calendar,)*/
        }
コード例 #29
0
        internal static ImportCalendarResults ImportCalendar(Stream inputStream, string charset, InboundConversionOptions options, StoreSession session, StoreObjectId folderId, Deadline deadline)
        {
            ImportCalendarResults result;

            using (CalendarFolder calendarFolder = CalendarFolder.Bind(session, folderId))
            {
                result = ICalSharingHelper.ImportCalendar(inputStream, charset, options, session, calendarFolder, deadline, ExDateTime.MinValue, ExDateTime.MaxValue);
            }
            return(result);
        }
コード例 #30
0
        private FindItemsResults <Appointment> FindAppointments(DateTime startDate, DateTime endDate)
        {
            CalendarFolder calendar = CalendarFolder.Bind(_exhcangeService, WellKnownFolderName.Calendar, new PropertySet());

            CalendarView calendarView = new CalendarView(startDate, endDate);

            calendarView.PropertySet = new PropertySet(BasePropertySet.IdOnly);

            return(calendar.FindAppointments(calendarView));
        }