Hello all,
I'm using an UltraDayView to let the user add/resize/drag/schedule appointments on a daily or weekly basis. I'd like to know if there's a simplistic way to calculate what timeslots don't contain any appointments within them from the week standpoint, and then display that list to the user, asking them to account for the empty timeslots.
For example, if my "week" contains Friday through Thursday, and I have an empty timeslot on Monday at 1:00pm, I'd like to add the "1:00 - 2:00 on Monday" timeslot to a list, then pop up a message box displaying that "1:00 - 2:00 on Monday" doesn't have time accounted for it, and it needs to be filled in before any other action can be taken.
Does this functionality currently exist? If not, are there any suggestions on how I might achieve this behavior?
Thanks!
Has there been any reviewing of this forum post?
To clarify what I have so far, here it is:
For Each timeslot in udvSchedule.TimeSlots
If ucimain.GetAppointmentsInRange(weekStartDate, weekEndDate).Count > 0 Then
availableTimeslots.Add(timeslot)
End If
Next
If availableTimeslots.Count > 0 Then
Dim sb as StringBuilder = New StringBuilder()
sb.AppendLine("There are " & availableTimeslots.Count.ToString & " timeslots empty on your calendar. The following timeslots need to be accounted for before you can continue: ")
For Each ts in availableTimeslots
sb.AppendLine(ts.StartTime.Date.ToString & " " & ts.StartTime.TimeOfDay.ToString & " - " & ts.EndTime.Date.ToString & " " ts.EndTime.TimeOfDay.ToString)
MessageBox.Show(sb.ToString, "Error", MessageBoxButtons.OK)
With the above code, I'm currently getting 36 available timeslots, which I'm pretty sure isn't correct. And the .Date property of the TimeSlot isn't populated and reverts to 1/1/0001.
Hello,
Could you please review the sample attached to this post and see if it meets your requirements.Please feel free to let me know if I misunderstood you or if you have any other questions.
Boris,
Thanks for the reply. Your example is close to what I'm wanting to achieve, but I need to achieve it for a multiple day span. Instead of:
ultraCalendarInfo1.ActiveDay.Date
How would I access all the days within a range? Do I have to do this calculation on my own and then iterate through the days, or does this functionality exist somewhere else on the UltraDayView?
I think that you would have to do this manually they way you suggested.
Please feel free to let me know if a question about our toolset comes up on your mind.
I've built a list of valid dates for the week, and am trying to iterate through them. However, since the interval on my UltraDayView is 15 minutes, I'm getting four intervals shown as "available" for each hour. Is there any way that you can tell me that would allow me to combine those timeslots into a single time span?
For example, if I'm available from 1:00 to 2:00, I'd like to see "1:00 - 2:00" rather than:
1:00 - 1:151:16 - 1:301:31 - 1:451:46 - 2:00
Any suggestions?
Hi,
If I understood your scenario. maybe your could try to code below:
private void ultraButton5_Click(object sender, EventArgs e) { string Messgae = "" + Environment.NewLine; foreach (TimeSlot ts in ultraDayView1.TimeSlots) { DateTime v1 = ultraCalendarInfo1.ActiveDay.Date.AddTicks(ts.StartTime.TimeOfDay.Ticks); DateTime v2 = ultraCalendarInfo1.ActiveDay.Date.AddTicks(ts.EndTime.TimeOfDay.Ticks); if (ultraCalendarInfo1.GetAppointmentsInRange(v1, v2).Count == 0) { Messgae = Messgae + "Start time: " + v1.ToString() + " - End time " + v2.ToString() + Environment.NewLine; } } MessageBox.Show("Please, you should used these empty Time Slots: " + Messgae); }
private void ultraButton5_Click(object sender, EventArgs e)
{
string Messgae = "" + Environment.NewLine;
foreach (TimeSlot ts in ultraDayView1.TimeSlots)
DateTime v1 = ultraCalendarInfo1.ActiveDay.Date.AddTicks(ts.StartTime.TimeOfDay.Ticks);
DateTime v2 = ultraCalendarInfo1.ActiveDay.Date.AddTicks(ts.EndTime.TimeOfDay.Ticks);
if (ultraCalendarInfo1.GetAppointmentsInRange(v1, v2).Count == 0)
Messgae = Messgae + "Start time: " + v1.ToString() + " - End time " + v2.ToString() + Environment.NewLine;
}
MessageBox.Show("Please, you should used these empty Time Slots: " + Messgae);
By this way I`m able to find all empty time slots (time slots without appointments). Please take a look at the attached video for more details and mentioned behavior.
Let me know if you have any questions.
Regards
Changing the interval itself is not an option. I want the display interval to remain in 15 minutes, but based on the calculated open timeslots, return a combined list of times, rather than just a list of 15 minute intervals that are available.
If I got your requirement right I believe that setting the 'TimeSlotInterval' to 'SixtyMinutes' might help you to achieve this.
Please do not hesitate to ask if something comes up.