2014-06-17 7 views
1

Office 365 용 Exchange Online에서 일정에 약속을 만드는 응용 프로그램이 있습니다. EWS Managed API를 사용하고 있습니다.EWS 관리 API가있는 모든 사용자의 일정 약속 삭제

public void CreateAppoitment(string principalName, int taskId) { 
    ExchangeService service = createService(principalName); 

    ItemView itemView = new ItemView(1000); 
    itemView.PropertySet = new PropertySet(BasePropertySet.IdOnly); 

    List<Appointment> toCreate = new List<Appointment>(); 

    // Create the appointment. 
    Appointment appointment = new Appointment(service); 

    // Set properties on the appointment. 
    appointment.Subject = "Test Appointment"; 
    appointment.Body = "The appointment ..."; 
    appointment.Start = new DateTime(2014, 6, 18, 9, 0, 0); 
    appointment.End = appointment.Start.AddDays(2); 

    ExtendedPropertyDefinition epdTaskId = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Appointment, "TASK_Id", MapiPropertyType.Integer); 
    appointment.SetExtendedProperty(epdTaskId, taskId); 
    appointment.IsResponseRequested = false; 
    toCreate.Add(appointment); 
    ServiceResponseCollection<ServiceResponse> createResponse = service.CreateItems(toCreate, WellKnownFolderName.Calendar, MessageDisposition.SaveOnly, SendInvitationsMode.SendToNone); 
} 

주 내가하고 있어요 ExtendedPropertyDefinition "TASK_ID"나는 사용자의 일정에 약속을 만들기 위해 가장 사용하고

:

다음
private ExchangeService createService(string principalName) { 
    ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013); 
    service.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx"); 
    service.UseDefaultCredentials = false; 
    service.Credentials = new WebCredentials("XXXX", "YYYY"); 
    service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.PrincipalName, principalName); 

    return service; 
} 

하는 TaskID를 주어, 나는 모든 삭제할 이 임무를 가진 임명 :

public void DeleteAppointment(string principalName, int appointmentId) { 
    ExchangeService service = createService(principalName); 
    ItemView itemView = new ItemView(1000); 
    itemView.PropertySet = new PropertySet(BasePropertySet.IdOnly); 

    ExtendedPropertyDefinition epdTaskId = new ExtendedPropertyDefinition(
    DefaultExtendedPropertySet.Appointment, "TASK_Id", MapiPropertyType.Integer); 

    SearchFilter filterOnTaskId = new SearchFilter.IsEqualTo(epdTaskId, appointmentId); 
    FindItemsResults<Item> appointments = service.FindItems(WellKnownFolderName.Calendar, filterOnTaskId, itemView); 
    List<ItemId> toDelete = appointments.Select(item => item.Id).ToList(); 
    if (toDelete.Count > 0) { 
    ServiceResponseCollection<ServiceResponse> response = service.DeleteItems(
     toDelete, DeleteMode.MoveToDeletedItems, SendCancellationsMode.SendToNone, 
     AffectedTaskOccurrence.SpecifiedOccurrenceOnly); 

    foreach (ServiceResponse del in response) { 
     if (del.Result == ServiceResult.Error) { 
     //... 
     } 
    } 
    } 
} 

하지만 이쪽으로 service.FindItems()는 TASK_Id = taskId를 사용하여 principalName의 약속 만 반환하며 모든 사용자의 약속을 원합니다. 이 방법이 있습니까?

답변

0

Exchange 관리 API 및 Exchange 웹 서비스는 사용자의 자격 증명을 사용하여 직접 또는 간접적으로 서비스 계정에 사용자의 일정에 대한 액세스 권한을 부여하여 한 번에 한 사용자의 일정에만 액세스 할 수 있습니다 .

여러 캘린더를 한 번에 검색하려면 다른 기술이 필요합니다. 한 가지 옵션은 Exchange 2013에서 eDiscovery 작업을 사용하는 것입니다. 일반적으로 법률상의 이유로 전자 메일을 찾는 데 사용되지만 동일한 프로세스를 사용할 수도 있습니다. 안타깝게도 eDiscovery에 대한 설명서는 매우 희소하지만 여기에서 사용할 수있는 EWS 작업은 eDiscovery in EWS in Exchange이며 ExchangeService 개체에서 해당 EWS Managed API 메소드를 찾을 수 있습니다.