Esempio n. 1
0
 /// <summary>
 /// Method to set the project id
 /// </summary>
 /// <param name="item">
 /// The appointment item.
 /// </param>
 /// <param name="projectId">
 /// The id to set
 /// </param>
 public static void SetProjectId(this AppointmentItem item, int projectId)
 {
     if (item != null)
     {
         item.SetAppointmentCustomId(Constants.FieldRedmineProjectId, projectId);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Method to set the time entry id
 /// </summary>
 /// <param name="item">
 /// The appointment item.
 /// </param>
 /// <param name="id">
 /// The id to set
 /// </param>
 public static void SetTimeEntryId(this AppointmentItem item, int?id)
 {
     if (item != null)
     {
         item.SetAppointmentCustomId(Constants.FieldRedmineTimeEntryId, id);
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Method to clear the is imported flag.
 /// </summary>
 /// <param name="item">
 /// The item.
 /// </param>
 public static void ClearIsImported(this AppointmentItem item)
 {
     if (item != null)
     {
         item.SetAppointmentCustomId(Constants.FieldImportedFromRedmine, null);
     }
 }
Esempio n. 4
0
 /// <summary>
 /// The method to set the is imported.
 /// </summary>
 /// <param name="item">
 /// The item.
 /// </param>
 /// <param name="isImported">
 /// The is imported to set.
 /// </param>
 public static void SetIsImported(this AppointmentItem item, bool isImported)
 {
     if (item != null)
     {
         var value = isImported ? 1 : 0;
         item.SetAppointmentCustomId(Constants.FieldImportedFromRedmine, value);
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Method to set the issue id
 /// </summary>
 /// <param name="item">
 /// The appointment item.
 /// </param>
 /// <param name="issueId">
 /// The id to set
 /// </param>
 public static void SetIssueId(this AppointmentItem item, int?issueId)
 {
     if (item != null)
     {
         var itemEntryID = item.EntryID;
         if (itemEntryID != null)
         {
             issueIdCache[itemEntryID] = issueId;
         }
         item.SetAppointmentCustomId(Constants.FieldRedmineIssueId, issueId);
     }
 }
Esempio n. 6
0
        /// <summary>
        /// Updates the custom fields of an appointment
        /// </summary>
        /// <param name="appointment">
        /// The appointment
        /// </param>
        /// <param name="timeEntryId">
        /// The redmine time entry id
        /// </param>
        /// <param name="projectId">
        /// The redmine project id
        /// </param>
        /// <param name="issueId">
        /// The redmine issue id
        /// </param>
        /// <param name="activityId">
        /// The activity Id.
        /// </param>
        /// <param name="lastRedmineUpdate">
        /// The date/time when the item was updated in redmine the last time
        /// </param>
        public static void UpdateAppointmentFields(
            this AppointmentItem appointment,
            int?timeEntryId,
            int projectId,
            int issueId,
            int activityId,
            DateTime lastRedmineUpdate)
        {
            // create user properties
            if (timeEntryId.HasValue)
            {
                appointment.SetAppointmentCustomId(Constants.FieldRedmineTimeEntryId, timeEntryId);
            }
            appointment.SetAppointmentCustomId(Constants.FieldRedmineProjectId, projectId);
            appointment.SetIssueId(issueId);
            appointment.SetAppointmentCustomId(Constants.FieldRedmineActivityId, activityId);

            // create last update field
            var propLastUpdate = OutlookHelper.CreateOrGetProperty(appointment, Constants.FieldLastUpdate, OlUserPropertyType.olDateTime);

            propLastUpdate.Value = lastRedmineUpdate;
        }
Esempio n. 7
0
        /// <summary>
        /// Sets the appointment category to give the appointment the correct color
        /// </summary>
        /// <param name="item">The item to set</param>
        /// <param name="state">The appointment state to set to the appointment</param>
        public static void SetAppointmentState(this AppointmentItem item, AppointmentState state)
        {
            var newCategories = new List <string>();

            // get the previous categories and remove our categories
            if (!string.IsNullOrEmpty(item.Categories))
            {
                foreach (var itm in item.Categories.Split(';'))
                {
                    // Preserve other categories.
                    if (!AppointmentState.IsValidAppointmentStateName(itm))
                    {
                        newCategories.Add(itm);
                    }
                }
            }

            // set our new categories
            newCategories.Insert(0, state.Name);

            if (state == AppointmentState.Modified)
            {
                item.SetAppointmentModificationDate(DateTime.Now);
            }

            item.Categories = string.Join(";", newCategories);

            // Update the previous sate of the appointment, if the current state is not syncerror.
            var previousState = item.GetAppointmentCustomId(Constants.FieldAppointmentState);

            if (previousState.HasValue && previousState.Value != AppointmentState.SyncError.Value)
            {
                item.SetAppointmentCustomId(Constants.FieldAppointmentPreviousState, previousState);
            }

            item.SetAppointmentCustomId(Constants.FieldAppointmentState, state.Value);
        }
Esempio n. 8
0
 /// <summary>
 /// Method to set the activity id
 /// </summary>
 /// <param name="item">
 /// The appointment item.
 /// </param>
 /// <param name="id">
 /// The id to set
 /// </param>
 public static void SetActivityId(this AppointmentItem item, int?id)
 {
     item.SetAppointmentCustomId(Constants.FieldRedmineActivityId, id);
 }