private void lbOptions_SelectedIndexChanged(object sender, EventArgs e)
        {
            SelectedOption = lbOptions.SelectedItem.ToString();

            switch (SelectedOption)
            {
            case "SendOnlyToAll":
                SelectedSendInvitationsOrCancellationsMode = SendInvitationsOrCancellationsMode.SendOnlyToAll;
                break;

            case "SendOnlyToChanged":
                SelectedSendInvitationsOrCancellationsMode = SendInvitationsOrCancellationsMode.SendOnlyToChanged;
                break;

            case "SendToAllAndSaveCopy":
                SelectedSendInvitationsOrCancellationsMode = SendInvitationsOrCancellationsMode.SendToAllAndSaveCopy;
                break;

            case "SendToChangedAndSaveCopy":
                SelectedSendInvitationsOrCancellationsMode = SendInvitationsOrCancellationsMode.SendToChangedAndSaveCopy;
                break;

            case "SendToNone":
                SelectedSendInvitationsOrCancellationsMode = SendInvitationsOrCancellationsMode.SendToNone;
                break;
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Applies the local changes that have been made to this appointment. Calling this method results in at least one call to EWS.
 /// Mutliple calls to EWS might be made if attachments have been added or removed.
 /// </summary>
 /// <param name="conflictResolutionMode">Specifies how conflicts should be resolved.</param>
 /// <param name="sendInvitationsOrCancellationsMode">Specifies if and how invitations or cancellations should be sent if this appointment is a meeting.</param>
 public Task <Item> Update(
     ConflictResolutionMode conflictResolutionMode,
     SendInvitationsOrCancellationsMode sendInvitationsOrCancellationsMode)
 {
     return(this.InternalUpdate(
                null,
                conflictResolutionMode,
                null,
                sendInvitationsOrCancellationsMode));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Applies the local changes that have been made to this appointment. Calling this method results in at least one call to EWS.
 /// Mutliple calls to EWS might be made if attachments have been added or removed.
 /// </summary>
 /// <param name="conflictResolutionMode">Specifies how conflicts should be resolved.</param>
 /// <param name="sendInvitationsOrCancellationsMode">Specifies if and how invitations or cancellations should be sent if this appointment is a meeting.</param>
 public void Update(
     ConflictResolutionMode conflictResolutionMode,
     SendInvitationsOrCancellationsMode sendInvitationsOrCancellationsMode)
 {
     this.InternalUpdate(
         null,
         conflictResolutionMode,
         null,
         sendInvitationsOrCancellationsMode);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Applies the local changes that have been made to this appointment. Calling this method results in at least one call to EWS.
 /// Mutliple calls to EWS might be made if attachments have been added or removed.
 /// </summary>
 /// <param name="conflictResolutionMode">Specifies how conflicts should be resolved.</param>
 /// <param name="sendInvitationsOrCancellationsMode">Specifies if and how invitations or cancellations should be sent if this appointment is a meeting.</param>
 public Task <Item> Update(
     ConflictResolutionMode conflictResolutionMode,
     SendInvitationsOrCancellationsMode sendInvitationsOrCancellationsMode,
     CancellationToken token = default(CancellationToken))
 {
     return(this.InternalUpdate(
                null,
                conflictResolutionMode,
                null,
                sendInvitationsOrCancellationsMode,
                token));
 }
Ejemplo n.º 5
0
        // anotações
        private void Teste(string storeId, string smtp)
        {
            var convertedId = (AlternateId)service.ConvertId(new AlternateId(IdFormat.HexEntryId, storeId, smtp), IdFormat.EwsId);

            var appointment = Appointment.Bind(service, new ItemId(convertedId.UniqueId));

            foreach (var requiredAttendee in appointment.RequiredAttendees)
            {
                Console.WriteLine(requiredAttendee.Address);
            }

            ItemId appointmentId = new ItemId(convertedId.UniqueId);
            ItemId meetingId     = new ItemId(convertedId.UniqueId);

            // Instantiate an appointment object by binding to it by using the ItemId.
            // As a best practice, limit the properties returned to only the ones you need.
            Appointment appointment2 = Appointment.Bind(this.service,
                                                        appointmentId,
                                                        new PropertySet(AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End));

            Appointment meeting = Appointment.Bind(this.service, meetingId, new PropertySet(AppointmentSchema.IsMeeting,
                                                                                            AppointmentSchema.ICalUid,
                                                                                            AppointmentSchema.Location,
                                                                                            AppointmentSchema.OptionalAttendees,
                                                                                            AppointmentSchema.RequiredAttendees,
                                                                                            AppointmentSchema.Resources));

            if (appointment == null)
            {
                appointment = new Appointment(this.service);
            }

            appointment.Load(new PropertySet(AppointmentSchema.IsMeeting,
                                             AppointmentSchema.ICalUid,
                                             AppointmentSchema.Location,
                                             AppointmentSchema.OptionalAttendees,
                                             AppointmentSchema.RequiredAttendees,
                                             AppointmentSchema.Resources));



            string oldSubject = appointment.Subject;

            // Update properties on the appointment with a new subject, start time, and end time.
            appointment.Subject = appointment.Subject + " foi cancelado por falta de pessoas na sala.";

            //appointment.Start.AddHours(25);
            //appointment.End.AddHours(25);

            // Unless explicitly specified, the default is to use SendToAllAndSaveCopy.
            // This can convert an appointment into a meeting. To avoid this,
            // explicitly set SendToNone on non-meetings.
            SendInvitationsOrCancellationsMode mode = appointment.IsMeeting ?
                                                      SendInvitationsOrCancellationsMode.SendToAllAndSaveCopy : SendInvitationsOrCancellationsMode.SendToNone;

            // Send the update request to the Exchange server.

            appointment.Update(ConflictResolutionMode.AlwaysOverwrite, mode);

            // Verify the update.
            //Console.WriteLine("Subject for the appointment was \"" + oldSubject + "\". The new subject is \"" + appointment.Subject + "\"");
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Cancela um evento a apartir de um storeId e um smtp
        /// </summary>
        /// <param name="storeId"></param>
        /// <param name="smtp"></param>
        /// <returns></returns>
        public bool CancelarEvento(string storeId, string smtp)
        {
            var convertedId = (AlternateId)service.ConvertId(new AlternateId(IdFormat.HexEntryId, storeId, smtp), IdFormat.EwsId);

            var appointment = Appointment.Bind(this.service, new ItemId(convertedId.UniqueId));

            if (appointment != null)
            {
                // Cancela o apontamento

                // PLANO A - FUROU.

                // Só pode ser feito por um "organizer".
                // Se não fosse por este impedimento do serviço, o código comentado abaixo resolveria o problema

                //var results = appointment.CancelMeeting("Evento '" + appointment.Subject + "' foi cancelado por falta de pessoas na sala.");
                //if (results.Appointment.IsCancelled)
                //{
                //    return true;
                //}

                // PLANO B
                try
                {
                    // Avisa para todo mundo da mudança
                    SendInvitationsOrCancellationsMode mode = SendInvitationsOrCancellationsMode.SendOnlyToAll;

                    // termina a reunião no minuto anterior
                    appointment.End = DateTime.Now.AddMinutes(-1);

                    // altera o assunto do apontamento
                    appointment.Subject = "[CANCELADO] " + appointment.Subject;

                    // altera o corpo da mensagem do apontamento
                    appointment.Body.Text = "Este evento foi cancelado pelo Fusion Sala de Reunião." +
                                            Environment.NewLine + Environment.NewLine + Environment.NewLine +
                                            appointment.Body.Text;

                    // obtém a lista de pessoas da reunião
                    string listaEmails = "";
                    // primeiro carrega as pessoas obrigatórias da reunião
                    foreach (var pessoa in appointment.RequiredAttendees)
                    {
                        listaEmails += pessoa.Address.ToString() + ";";
                    }
                    // depois carrega as pessoas opcionais que também precisam saber do cancelamento
                    foreach (var pessoa in appointment.OptionalAttendees)
                    {
                        listaEmails += pessoa.Address.ToString() + ";";
                    }
                    // Atualiza o apontamento
                    appointment.Update(ConflictResolutionMode.AlwaysOverwrite, mode);

                    // carrega o apontamento novamente para certificar alguma alteração
                    // appointment = Appointment.Bind(this.service, new ItemId(convertedId.UniqueId));

                    // Envia e-mail aos participantes informando o cancelamento da reunião
                    SendmailEWS(appointment.Subject, appointment.Body.Text, listaEmails);

                    // Apaga apontamento da Sala de Reunião
                    appointment.Delete(DeleteMode.MoveToDeletedItems);

                    // Se tentar usar o método abaixo, dá erro porque não existe mais
                    // mas só não existe mais nos apontamentos da entidade da sala.
                    // appointment = Appointment.Bind(this.service, new ItemId(convertedId.UniqueId));

                    return(true);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            return(false);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Applies the local changes that have been made to this appointment. Calling this method results in at least one call to EWS.
 /// Mutliple calls to EWS might be made if attachments have been added or removed.
 /// </summary>
 /// <param name="conflictResolutionMode">Specifies how conflicts should be resolved.</param>
 /// <param name="sendInvitationsOrCancellationsMode">Specifies if and how invitations or cancellations should be sent if this appointment is a meeting.</param>
 public void Update(
     ConflictResolutionMode conflictResolutionMode,
     SendInvitationsOrCancellationsMode sendInvitationsOrCancellationsMode)
 {
     this.InternalUpdate(
         null,
         conflictResolutionMode,
         null,
         sendInvitationsOrCancellationsMode);
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Update item.
        /// </summary>
        /// <param name="parentFolderId">The parent folder id.</param>
        /// <param name="conflictResolutionMode">The conflict resolution mode.</param>
        /// <param name="messageDisposition">The message disposition.</param>
        /// <param name="sendInvitationsOrCancellationsMode">The send invitations or cancellations mode.</param>
        /// <param name="suppressReadReceipts">Whether to suppress read receipts</param>
        /// <returns>Updated item.</returns>
        internal Item InternalUpdate(
            FolderId parentFolderId,
            ConflictResolutionMode conflictResolutionMode,
            MessageDisposition? messageDisposition,
            SendInvitationsOrCancellationsMode? sendInvitationsOrCancellationsMode,
            bool suppressReadReceipts)
        {
            this.ThrowIfThisIsNew();
            this.ThrowIfThisIsAttachment();

            Item returnedItem = null;

            if (this.IsDirty && this.PropertyBag.GetIsUpdateCallNecessary())
            {
                returnedItem = this.Service.UpdateItem(
                    this,
                    parentFolderId,
                    conflictResolutionMode,
                    messageDisposition,
                    sendInvitationsOrCancellationsMode.HasValue ? sendInvitationsOrCancellationsMode : this.DefaultSendInvitationsOrCancellationsMode,
                    suppressReadReceipts);
            }

            // Regardless of whether item is dirty or not, if it has unprocessed
            // attachment changes, validate them and process now.
            if (this.HasUnprocessedAttachmentChanges())
            {
                this.Attachments.Validate();
                this.Attachments.Save();
            }

            return returnedItem;
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Update item.
 /// </summary>
 /// <param name="parentFolderId">The parent folder id.</param>
 /// <param name="conflictResolutionMode">The conflict resolution mode.</param>
 /// <param name="messageDisposition">The message disposition.</param>
 /// <param name="sendInvitationsOrCancellationsMode">The send invitations or cancellations mode.</param>
 /// <returns>Updated item.</returns>
 internal Item InternalUpdate(
     FolderId parentFolderId,
     ConflictResolutionMode conflictResolutionMode,
     MessageDisposition? messageDisposition,
     SendInvitationsOrCancellationsMode? sendInvitationsOrCancellationsMode)
 {
     return this.InternalUpdate(parentFolderId, conflictResolutionMode, messageDisposition, sendInvitationsOrCancellationsMode, false);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Update item.
 /// </summary>
 /// <param name="parentFolderId">The parent folder id.</param>
 /// <param name="conflictResolutionMode">The conflict resolution mode.</param>
 /// <param name="messageDisposition">The message disposition.</param>
 /// <param name="sendInvitationsOrCancellationsMode">The send invitations or cancellations mode.</param>
 /// <returns>Updated item.</returns>
 internal async System.Threading.Tasks.Task<Item> InternalUpdateAsync(
     FolderId parentFolderId,
     ConflictResolutionMode conflictResolutionMode,
     MessageDisposition? messageDisposition,
     SendInvitationsOrCancellationsMode? sendInvitationsOrCancellationsMode)
 {
     return await this.InternalUpdateAsync(parentFolderId, conflictResolutionMode, messageDisposition, sendInvitationsOrCancellationsMode, false);
 }