Ejemplo n.º 1
0
 // Token: 0x06001E26 RID: 7718 RVA: 0x000AEEC4 File Offset: 0x000AD0C4
 public void LoadFromQueryResult(FreeBusyQueryResult queryResult)
 {
     if (queryResult == null)
     {
         throw new ArgumentNullException("queryResult");
     }
     this.AssociatedCalendarType = AvailabilityDataSource.CalendarType.Unknown;
     if (queryResult.ExceptionInfo != null)
     {
         if (queryResult.ExceptionInfo is NotDefaultCalendarException)
         {
             this.AssociatedCalendarType = AvailabilityDataSource.CalendarType.Secondary;
         }
         this.userCanReadItem = false;
         return;
     }
     this.AssociatedCalendarType = AvailabilityDataSource.CalendarType.Primary;
     this.userCanReadItem        = true;
     this.workingHours           = WorkingHours.CreateFromAvailabilityWorkingHours(this.userContext, queryResult.WorkingHours);
     if (queryResult.CalendarEventArray == null && queryResult.MergedFreeBusy != null)
     {
         this.items = this.GetItemsFromMergedFreeBusy(queryResult.MergedFreeBusy);
         return;
     }
     if (queryResult.CalendarEventArray != null && queryResult.CalendarEventArray.Length > 0)
     {
         this.items = this.GetItemsFromEventArray(queryResult.CalendarEventArray);
     }
 }
Ejemplo n.º 2
0
        protected void RenderOOF(TextWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            AvailabilityQuery availabilityQuery = new AvailabilityQuery();

            if (HttpContext.Current != null)
            {
                availabilityQuery.HttpResponse = HttpContext.Current.Response;
            }
            availabilityQuery.MailboxArray                  = new MailboxData[1];
            availabilityQuery.MailboxArray[0]               = new MailboxData();
            availabilityQuery.MailboxArray[0].Email         = new EmailAddress();
            availabilityQuery.MailboxArray[0].Email.Address = base.ADRecipient.PrimarySmtpAddress.ToString();
            availabilityQuery.ClientContext                 = ClientContext.Create(base.UserContext.LogonIdentity.ClientSecurityContext, base.UserContext.ExchangePrincipal.MailboxInfo.OrganizationId, OwaContext.TryGetCurrentBudget(), base.UserContext.TimeZone, base.UserContext.UserCulture, AvailabilityQuery.CreateNewMessageId());
            ExDateTime date       = DateTimeUtilities.GetLocalTime().Date;
            ExDateTime exDateTime = date.IncrementDays(1);

            availabilityQuery.DesiredFreeBusyView = new FreeBusyViewOptions
            {
                RequestedView = FreeBusyViewType.Detailed,
                MergedFreeBusyIntervalInMinutes = 1440,
                TimeWindow = new Duration((DateTime)date, (DateTime)exDateTime.IncrementDays(1))
            };
            AvailabilityQueryResult availabilityQueryResult;

            if (Utilities.ExecuteAvailabilityQuery(base.OwaContext, availabilityQuery, true, out availabilityQueryResult))
            {
                FreeBusyQueryResult freeBusyQueryResult = availabilityQueryResult.FreeBusyResults[0];
                if (freeBusyQueryResult != null)
                {
                    string currentOofMessage = freeBusyQueryResult.CurrentOofMessage;
                    if (!string.IsNullOrEmpty(currentOofMessage))
                    {
                        writer.Write("<tr><td class=\"spcOP\"></td></tr>");
                        writer.Write("<tr><td class=\"oof oofF\">");
                        writer.Write(LocalizedStrings.GetHtmlEncoded(77678270));
                        writer.Write("</td></tr>");
                        writer.Write("<tr><td class=\"oof\">");
                        writer.Write("<textarea name=\"off\" rows=3 cols=100 readonly>");
                        writer.Write(currentOofMessage);
                        writer.Write("</textarea>");
                    }
                }
            }
        }
Ejemplo n.º 3
0
        // Token: 0x06002A98 RID: 10904 RVA: 0x000EEC44 File Offset: 0x000ECE44
        public static string GetFreeBusy(OwaContext owaContext, string recipientPrimarySmtpAddress, ExDateTime startDate, ExDateTime endDate, HttpContext httpContext, out string allDayFreeBusy, out string workingHoursFreeBusy, out string oofMessage)
        {
            UserContext userContext = owaContext.UserContext;

            ExTraceGlobals.CalendarCallTracer.TraceDebug(0L, "DatePickerEventHandler.GetFreeBusy");
            allDayFreeBusy       = null;
            workingHoursFreeBusy = null;
            oofMessage           = null;
            AvailabilityQuery availabilityQuery = new AvailabilityQuery();

            if (HttpContext.Current != null)
            {
                availabilityQuery.HttpResponse = HttpContext.Current.Response;
            }
            availabilityQuery.DesiredFreeBusyView = new FreeBusyViewOptions
            {
                RequestedView = FreeBusyViewType.FreeBusyMerged,
                MergedFreeBusyIntervalInMinutes = 30,
                TimeWindow = new Duration((DateTime)startDate, (DateTime)endDate)
            };
            availabilityQuery.ClientContext                 = ClientContext.Create(owaContext.LogonIdentity.ClientSecurityContext, userContext.ExchangePrincipal.MailboxInfo.OrganizationId, owaContext.Budget, userContext.TimeZone, userContext.UserCulture, AvailabilityQuery.CreateNewMessageId());
            availabilityQuery.MailboxArray                  = new MailboxData[1];
            availabilityQuery.MailboxArray[0]               = new MailboxData();
            availabilityQuery.MailboxArray[0].Email         = new EmailAddress();
            availabilityQuery.MailboxArray[0].Email.Address = recipientPrimarySmtpAddress.ToString();
            ExTraceGlobals.CalendarTracer.TraceDebug <ExDateTime, ExDateTime>(0L, "Getting free/busy data from {0} to {1}", startDate, endDate);
            Stopwatch watch = Utilities.StartWatch();
            AvailabilityQueryResult availabilityQueryResult;
            bool flag = Utilities.ExecuteAvailabilityQuery(owaContext, availabilityQuery, true, true, out availabilityQueryResult);

            Utilities.StopWatch(watch, "ReadADOrgPerson.GetFreeBusy (Execute Availability Query)");
            if (flag)
            {
                FreeBusyQueryResult freeBusyQueryResult = availabilityQueryResult.FreeBusyResults[0];
                if (freeBusyQueryResult != null)
                {
                    allDayFreeBusy = freeBusyQueryResult.MergedFreeBusy;
                }
                if (userContext.WorkingHours.IsTimeZoneDifferent)
                {
                    workingHoursFreeBusy = string.Empty;
                }
                else
                {
                    int           workDayStartHour = SchedulingTabRenderingUtilities.GetWorkDayStartHour(userContext.WorkingHours, startDate);
                    int           workDayEndHour   = SchedulingTabRenderingUtilities.GetWorkDayEndHour(userContext.WorkingHours, endDate);
                    int           num           = workDayEndHour - workDayStartHour;
                    int           num2          = 24 - workDayEndHour;
                    StringBuilder stringBuilder = new StringBuilder(num * 24);
                    int           i             = 0;
                    SchedulingTabRenderingUtilities.SetFreeBusyDayLightBasedValue(startDate, endDate, userContext.TimeZone, ref allDayFreeBusy);
                    while (i < allDayFreeBusy.Length)
                    {
                        i += workDayStartHour * 2;
                        int num3;
                        if (i + num * 2 >= allDayFreeBusy.Length)
                        {
                            num3 = allDayFreeBusy.Length - i;
                        }
                        else
                        {
                            num3 = num * 2;
                        }
                        stringBuilder.Append(allDayFreeBusy.Substring(i, num3));
                        i += num3;
                        i += num2 * 2;
                    }
                    workingHoursFreeBusy = stringBuilder.ToString();
                }
                if (freeBusyQueryResult != null && !string.IsNullOrEmpty(freeBusyQueryResult.CurrentOofMessage))
                {
                    oofMessage = freeBusyQueryResult.CurrentOofMessage;
                }
            }
            else if (availabilityQueryResult != null && availabilityQueryResult.FreeBusyResults != null && availabilityQueryResult.FreeBusyResults.Length > 0)
            {
                FreeBusyQueryResult freeBusyQueryResult2 = availabilityQueryResult.FreeBusyResults[0];
                if (freeBusyQueryResult2 != null)
                {
                    if (Utilities.IsFatalFreeBusyError(freeBusyQueryResult2.ExceptionInfo))
                    {
                        ExTraceGlobals.CalendarTracer.TraceDebug <LocalizedException>(0L, "An error happened trying to get free/busy info for this recipient. Exception: {0}", freeBusyQueryResult2.ExceptionInfo);
                        ErrorInformation exceptionHandlingInformation = Utilities.GetExceptionHandlingInformation(freeBusyQueryResult2.ExceptionInfo, userContext.MailboxIdentity);
                        return(exceptionHandlingInformation.Message);
                    }
                }
                else
                {
                    ExTraceGlobals.CalendarTracer.TraceDebug(0L, "An error happened trying to get free/busy info for this recipient. FreeBusyResult is null.");
                }
            }
            return(null);
        }
        // Token: 0x0600310D RID: 12557 RVA: 0x00120F14 File Offset: 0x0011F114
        public static void RenderRecipientFreeBusyData(TextWriter output, SchedulingRecipientInfo[] schedulingRecipientInfos, FreeBusyQueryResult[] freeBusyQueryResults, ExDateTime startDateFreeBusyWindow, ExDateTime endDateFreeBusyWindow, bool show24Hours, bool renderDataForAllRecipients, ExTimeZone timeZone, Microsoft.Exchange.Clients.Owa.Core.WorkingHours workingHours)
        {
            ExTraceGlobals.CalendarCallTracer.TraceDebug(0L, "SchedulingTabRenderingUtilities.RenderRecipientFreeBusyData");
            int days = ((DateTime)endDateFreeBusyWindow - (DateTime)startDateFreeBusyWindow).Days;
            int num  = 0;
            int num2 = 48;

            if (!show24Hours)
            {
                num  = SchedulingTabRenderingUtilities.GetWorkDayStartHour(workingHours, startDateFreeBusyWindow) * 60 / 30;
                num2 = SchedulingTabRenderingUtilities.GetWorkDayEndHour(workingHours, startDateFreeBusyWindow) * 60 / 30;
            }
            int num3 = 48;
            int num4 = num2 - num;

            output.Write("<div id=fbd>");
            output.Write("var rgUFB = new Array();");
            int num5 = 0;

            for (int i = 0; i < schedulingRecipientInfos.Length; i++)
            {
                FreeBusyQueryResult     freeBusyQueryResult     = (freeBusyQueryResults == null) ? null : freeBusyQueryResults[i];
                SchedulingRecipientInfo schedulingRecipientInfo = schedulingRecipientInfos[i];
                if (renderDataForAllRecipients || schedulingRecipientInfo.GetFreeBusyData)
                {
                    output.Write("rgUFB[");
                    output.Write(num5++);
                    output.Write("] = new RecipientFreeBusyData(\"");
                    output.Write(schedulingRecipientInfo.ID);
                    output.Write("\",\"");
                    if (freeBusyQueryResult == null || Utilities.IsFatalFreeBusyError(freeBusyQueryResult.ExceptionInfo) || string.IsNullOrEmpty(freeBusyQueryResult.MergedFreeBusy))
                    {
                        ExTraceGlobals.CalendarDataTracer.TraceDebug <string, string, object>(0L, "Unable to get free/busy data for user '{0} ({1})' Exception: {2}", schedulingRecipientInfo.DisplayName, schedulingRecipientInfo.EmailAddress, (freeBusyQueryResult != null) ? freeBusyQueryResult.ExceptionInfo : "<recipientQueryResult is null>");
                        int num6 = num4 * days;
                        for (int j = 0; j < num6; j++)
                        {
                            output.Write('4');
                        }
                        if (freeBusyQueryResult != null)
                        {
                            output.Write("\",\"{0}", freeBusyQueryResult.ExceptionInfo.ErrorCode);
                        }
                    }
                    else
                    {
                        string mergedFreeBusy = freeBusyQueryResult.MergedFreeBusy;
                        SchedulingTabRenderingUtilities.SetFreeBusyDayLightBasedValue(startDateFreeBusyWindow, endDateFreeBusyWindow, timeZone, ref mergedFreeBusy);
                        for (int k = 0; k < days; k++)
                        {
                            int num7 = k * num3 + num;
                            for (int l = 0; l < num4; l++)
                            {
                                output.Write(mergedFreeBusy[num7 + l]);
                            }
                        }
                    }
                    output.Write("\");");
                }
            }
            output.Write("</div>");
        }