Inheritance: IEditableObject
        public static void SendNewRequestEmail(Appointment appointment, string toEmailAddresses, string approvalUrl, string declineUrl, string loginUrl)
        {
            if (appointment == null)
            {
                throw new ArgumentNullException("appointment", "appointment must not be null");
            }

            QueueEmail(
                toEmailAddresses,
                GetLocalizedFormattedText("NewRequestSubject.Format", appointment),
                GetLocalizedFormattedText("NewRequestBody.Format", appointment, approvalUrl, declineUrl, loginUrl),
                appointment.ToICal());
        }
        /// <summary>
        /// Sends the email indicating to an appointment requestor that their request has been approved.
        /// </summary>
        /// <param name="appointment">The appointment which was approved.</param>
        public static void SendAcceptanceEmail(Appointment appointment)
        {
            if (appointment == null)
            {
                throw new ArgumentNullException("appointment", "appointment must not be null");
            }

            QueueEmail(
                    appointment.RequestorEmail,
                    GetLocalizedFormattedText("AcceptanceSubject.Format", appointment),
                    GetLocalizedFormattedText("AcceptanceBody.Format", appointment),
                    appointment.ToICal());
        }
        /// <summary>
        /// Sends the email indicating to an appointment requestor that their request has been declined.
        /// </summary>
        /// <param name="appointment">The appointment which was declined.</param>
        /// <param name="declineReason">The reason for declining the appointment, or <c>null</c>.</param>
        public static void SendDeclineEmail(Appointment appointment, string declineReason)
        {
            if (appointment == null)
            {
                throw new ArgumentNullException("appointment", "appointment must not be null");
            }

            string body = string.IsNullOrEmpty(declineReason) || string.IsNullOrEmpty(declineReason.Trim())
                                  ? GetLocalizedFormattedText("DeclineBody.Format", appointment)
                                  : GetLocalizedFormattedText("DeclineBodyWithReason.Format", appointment, declineReason);
            QueueEmail(
                appointment.RequestorEmail,
                GetLocalizedFormattedText("DeclineSubject.Format", appointment),
                body,
                string.Empty);
        }
        /// <summary>
        /// Exports the specified appointment as an iCalendar file.
        /// </summary>
        /// <param name="description">The appointment's description.</param>
        /// <param name="location">The appointment's location.</param>
        /// <param name="app">The appointment to export.</param>
        /// <param name="timeZoneOffset">The time zone offset.</param>
        /// <returns>The given appointment in an iCalendar format</returns>
        public static string Export(string description, string location, Appointment app, TimeSpan timeZoneOffset)
        {
            StringBuilder output = new StringBuilder();
            WriteFileHeader(output);

            ////if (app.RecurrenceState != RecurrenceState.Occurrence)
            ////{
            ////    if (outlookCompatibleMode)
            ////    {
            ////        ValidateOutlookCompatibility(app);
            ////    }
            ////}

            WriteTask(description, location, output, app, timeZoneOffset);

            WriteFileFooter(output);

            return output.ToString();
        }
        /// <summary>
        /// Attempts to accept the appointment
        /// </summary>
        /// <param name="revisingUserId">The revising user's id.</param>
        /// <param name="apt">The appointment to accept.</param>
        /// <returns><c>true</c> if an <see cref="Appointment"/> can be accepted. Else, <c>false</c>.</returns>
        private bool TryAcceptAppointment(int revisingUserId, Appointment apt)
        {
            var canCreate = Appointment.CanCreateAt(
                this.ModuleId, apt.StartDateTime, apt.EndDateTime, ModuleSettings.MaximumConcurrentAppointments.GetValueAsInt32For(this).Value);

            if (!canCreate)

            {
                return false;
            }

            apt.Accept(revisingUserId);
            return true;
        }
Beispiel #6
0
 /// <summary>
 /// Sets the appointment to be displayed in the appointment tooltip.
 /// </summary>
 /// <param name="tooltipEvent">The appointment to display in the tooltip.</param>
 internal void SetAppointment(Appointment tooltipEvent)
 {
     this.currentAppointment = tooltipEvent;
 }
 /// <summary>
 /// Sets the appointment to be displayed in the appointment tooltip.
 /// </summary>
 /// <param name="tooltipEvent">The appointment to display in the tooltip.</param>
 internal void SetAppointment(Appointment tooltipEvent)
 {
     this.currentAppointment = tooltipEvent;
 }
 /// <summary>
 /// Gets the text for the given <paramref name="localizationKey"/> (from the <see cref="Utility.LocalSharedResourceFile"/>),
 /// and fills in the <see cref="string.Format(System.IFormatProvider,string,object[])"/> placeholders in that text with appointment information.
 /// </summary>
 /// <param name="localizationKey">The localization key.</param>
 /// <param name="appointment">The appointment.</param>
 /// <param name="declineReason">The reason for declining <paramref name="appointment"/>.</param>
 /// <param name="approvalUrl">The URL to use to approve the appointment.</param>
 /// <param name="declineUrl">The URL to use to decline the appointment.</param>
 /// <param name="loginUrl">The URL to use to log into the module.</param>
 /// <returns>
 /// The localized text with appointment-specific information inserted
 /// </returns>
 private static string GetLocalizedFormattedText(string localizationKey, Appointment appointment, string declineReason, string approvalUrl, string declineUrl, string loginUrl)
 {
     return string.Format(
             CultureInfo.CurrentCulture,
             Localization.GetString(localizationKey, Utility.LocalSharedResourceFile),
             appointment.Title,
             appointment.Description,
             appointment.AppointmentType.Name,
             appointment.Notes,
             appointment.Address1,
             appointment.Address2,
             appointment.City,
             appointment.RegionName,
             appointment.ContactStreet,
             appointment.ContactPhone,
             appointment.RequestorName,
             appointment.RequestorPhoneType,
             appointment.RequestorPhone,
             appointment.RequestorAltPhoneType,
             appointment.RequestorAltPhone,
             appointment.RequestorEmail,
             appointment.StartDateTime,
             appointment.EndDateTime,
             appointment.NumberOfSpecialParticipants,
             appointment.NumberOfParticipants,
             appointment.ParticipantGender,
             appointment.IsPresenterSpecial,
             appointment.ParticipantInstructions,
             appointment.Custom1,
             appointment.Custom2,
             appointment.Custom3,
             appointment.Custom4,
             appointment.Custom5,
             appointment.Custom6,
             appointment.Custom7,
             appointment.Custom8,
             appointment.Custom9,
             appointment.Custom10,
             GetCurrentUserDisplayName(),
             Globals.GetPortalSettings().PortalName,
             declineReason,
             approvalUrl,
             declineUrl,
             loginUrl);
 }
 /// <summary>
 /// Gets the text for the given <paramref name="localizationKey"/> (from the <see cref="Utility.LocalSharedResourceFile"/>),
 /// and fills in the <see cref="string.Format(System.IFormatProvider,string,object[])"/> placeholders in that text with appointment information.
 /// </summary>
 /// <param name="localizationKey">The localization key.</param>
 /// <param name="appointment">The appointment.</param>
 /// <param name="approvalUrl">The URL to use to approve the appointment.</param>
 /// <param name="declineUrl">The URL to use to decline the appointment.</param>
 /// <param name="loginUrl">The URL to use to log into the module.</param>
 /// <returns>
 /// The localized text with appointment-specific information inserted
 /// </returns>
 private static string GetLocalizedFormattedText(string localizationKey, Appointment appointment, string approvalUrl, string declineUrl, string loginUrl)
 {
     return GetLocalizedFormattedText(localizationKey, appointment, string.Empty, approvalUrl, declineUrl, loginUrl);
 }
 /// <summary>
 /// Gets the text for the given <paramref name="localizationKey"/> (from the <see cref="Utility.LocalSharedResourceFile"/>),
 /// and fills in the <see cref="string.Format(System.IFormatProvider,string,object[])"/> placeholders in that text with appointment information.
 /// </summary>
 /// <param name="localizationKey">The localization key.</param>
 /// <param name="appointment">The appointment.</param>
 /// <param name="declineReason">The reason for declining <paramref name="appointment"/>.</param>
 /// <returns>
 /// The localized text with appointment-specific information inserted
 /// </returns>
 private static string GetLocalizedFormattedText(string localizationKey, Appointment appointment, string declineReason)
 {
     return GetLocalizedFormattedText(localizationKey, appointment, declineReason, string.Empty, string.Empty, string.Empty);
 }
        /// <summary>
        /// Writes the the entry for an event.
        /// </summary>
        /// <param name="description">The event's description.</param>
        /// <param name="location">The event's location.</param>
        /// <param name="output">The <see cref="StringBuilder"/> into which the output should be appended.</param>
        /// <param name="app">The appointment to export.</param>
        /// <param name="timeZoneOffset">The time zone offset.</param>
        /// <exception cref="InvalidOperationException">Invalid recurrence rule.</exception>
        private static void WriteTask(string description, string location, StringBuilder output, Appointment app, TimeSpan timeZoneOffset)
        {
            output.AppendLine("BEGIN:VEVENT");
            output.AppendLine("DESCRIPTION:" + description.Replace("\n", "\\n").Replace("\r", "\\r"));
            output.AppendLine("LOCATION:" + location);
            output.AppendFormat("DTSTART:{0}\r\n", FormatDate(ClientToUtc(app.StartDateTime, timeZoneOffset)));
            output.AppendFormat("DTEND:{0}\r\n", FormatDate(ClientToUtc(app.EndDateTime, timeZoneOffset)));

            string title = app.Title.Replace("\r\n", "\\n");
            title = title.Replace("\n", "\\n");
            output.AppendFormat("SUMMARY:{0}\r\n", title);
            output.AppendLine("END:VEVENT");
        }
Beispiel #12
0
        /// <summary>
        /// Writes the the entry for an event.
        /// </summary>
        /// <param name="description">The event's description.</param>
        /// <param name="location">The event's location.</param>
        /// <param name="output">The <see cref="StringBuilder"/> into which the output should be appended.</param>
        /// <param name="app">The appointment to export.</param>
        /// <param name="timeZoneOffset">The time zone offset.</param>
        /// <exception cref="InvalidOperationException">Invalid recurrence rule.</exception>
        private static void WriteTask(string description, string location, StringBuilder output, Appointment app, TimeSpan timeZoneOffset)
        {
            output.AppendLine("BEGIN:VEVENT");
            output.AppendLine("DESCRIPTION:" + description.Replace("\n", "\\n").Replace("\r", "\\r"));
            output.AppendLine("LOCATION:" + location);
            output.AppendFormat("DTSTART:{0}\r\n", FormatDate(ClientToUtc(app.StartDateTime, timeZoneOffset)));
            output.AppendFormat("DTEND:{0}\r\n", FormatDate(ClientToUtc(app.EndDateTime, timeZoneOffset)));

            string title = app.Title.Replace("\r\n", "\\n");

            title = title.Replace("\n", "\\n");
            output.AppendFormat("SUMMARY:{0}\r\n", title);
            output.AppendLine("END:VEVENT");
        }
        /// <summary>
        /// Updates the given <paramref name="appointment"/>'s record.
        /// </summary>
        /// <param name="appointment">The appointment to update.</param>
        /// <param name="revisingUserId">The ID of the user making this update.</param>
        public static void UpdateAppointment(Appointment appointment, int revisingUserId)
        {
            if (appointment == null)
            {
                throw new ArgumentNullException("appointment", "appointment must not be null");
            }

            SqlDataProvider.Instance.ExecuteNonQuery(
                    "UpdateAppointment",
                    Engage.Utility.CreateIntegerParam("@appointmentId", appointment.AppointmentId),
                    Engage.Utility.CreateIntegerParam("@appointmentTypeId", appointment.AppointmentTypeId),
                    Engage.Utility.CreateVarcharParam("@title", appointment.Title),
                    Engage.Utility.CreateTextParam("@description", appointment.Description),
                    Engage.Utility.CreateTextParam("@notes", appointment.Notes),
                    Engage.Utility.CreateVarcharParam("@address1", appointment.Address1),
                    Engage.Utility.CreateVarcharParam("@address2", appointment.Address2),
                    Engage.Utility.CreateVarcharParam("@city", appointment.City),
                    Engage.Utility.CreateIntegerParam("@regionId", appointment.RegionId),
                    Engage.Utility.CreateVarcharParam("@postalCode", appointment.PostalCode),
                    Engage.Utility.CreateVarcharParam("@phone", appointment.Phone),
                    Engage.Utility.CreateVarcharParam("@additionalAddressInfo", appointment.AdditionalAddressInfo),
                    Engage.Utility.CreateVarcharParam("@contactStreet", appointment.ContactStreet),
                    Engage.Utility.CreateVarcharParam("@contactPhone", appointment.ContactPhone),
                    Engage.Utility.CreateVarcharParam("@requestorName", appointment.RequestorName),
                    Engage.Utility.CreateVarcharParam("@requestorPhoneType", appointment.RequestorPhoneType.ToString()),
                    Engage.Utility.CreateVarcharParam("@requestorPhone", appointment.RequestorPhone),
                    Engage.Utility.CreateVarcharParam("@requestorEmail", appointment.RequestorEmail),
                    Engage.Utility.CreateVarcharParam("@requestorAltPhoneType", appointment.RequestorAltPhoneType.ToString()),
                    Engage.Utility.CreateVarcharParam("@requestorAltPhone", appointment.RequestorAltPhone),
                    Engage.Utility.CreateDateTimeParam("@startDateTime", appointment.StartDateTime),
                    Engage.Utility.CreateDateTimeParam("@endDateTime", appointment.EndDateTime),
                    Engage.Utility.CreateIntegerParam("@timeZoneOffset", (int)appointment.TimeZoneOffset.TotalMinutes),
                    Engage.Utility.CreateIntegerParam("@numberOfParticipants", appointment.NumberOfParticipants),
                    Engage.Utility.CreateVarcharParam("@participantGender", appointment.ParticipantGender.ToString()),
                    Engage.Utility.CreateCharParam("@participantFlag", appointment.IsPresenterSpecial ? "Y" : "N"),
                    Engage.Utility.CreateTextParam("@participantInstructions", appointment.ParticipantInstructions),
                    Engage.Utility.CreateTextParam("@custom1", appointment.Custom1),
                    Engage.Utility.CreateTextParam("@custom2", appointment.Custom2),
                    Engage.Utility.CreateTextParam("@custom3", appointment.Custom3),
                    Engage.Utility.CreateTextParam("@custom4", appointment.Custom4),
                    Engage.Utility.CreateTextParam("@custom5", appointment.Custom5),
                    Engage.Utility.CreateTextParam("@custom6", appointment.Custom6),
                    Engage.Utility.CreateTextParam("@custom7", appointment.Custom7),
                    Engage.Utility.CreateTextParam("@custom8", appointment.Custom8),
                    Engage.Utility.CreateTextParam("@custom9", appointment.Custom9),
                    Engage.Utility.CreateTextParam("@custom10", appointment.Custom10),
                    Engage.Utility.CreateIntegerParam("@numberOfSpecialParticipants", appointment.NumberOfSpecialParticipants),
                    Engage.Utility.CreateBitParam("@isAccepted", appointment.IsAccepted),
                    Engage.Utility.CreateIntegerParam("@revisingUser", revisingUserId));
        }