예제 #1
0
        public void ProcessRequest(HttpContext context)
        {
            HttpRequest  request  = context.Request;
            HttpResponse response = context.Response;

            int    frameId   = DataAccess.IntOrZero(request.QueryString["frame"]);
            int    panelId   = DataAccess.IntOrZero(request.QueryString["panel"]);
            int    displayId = DataAccess.IntOrZero(request.QueryString["display"]);
            string culture   = DataAccess.StringOrBlank(request.QueryString["culture"]);

            string json = "";

            try
            {
                // set culture
                Outlook  outlook  = new Outlook(frameId);
                Location location = new Location(displayId);

                if (string.IsNullOrWhiteSpace(culture))
                {
                    culture = location.Culture;
                }

                if (!string.IsNullOrWhiteSpace(culture))
                {
                    System.Globalization.CultureInfo cultureInfo = new System.Globalization.CultureInfo(culture);
                    System.Threading.Thread.CurrentThread.CurrentCulture   = cultureInfo;
                    System.Threading.Thread.CurrentThread.CurrentUICulture = cultureInfo;
                }

                // EWS: get data
                OutlookData data = HttpRuntime.Cache.GetOrAddAbsolute(
                    string.Format("outlook_{0}_{1}_{2}", location.LocationId, outlook.FrameId, outlook.Version),
                    () =>
                {
                    return(new OutlookData(outlook, location));
                },
                    DateTime.Now.AddMinutes(outlook.CacheInterval)
                    );

                // ---------------------- culture-specific starts here --------------------- //
                DateTime
                    locationTime  = location.LocationTime,
                    locationToday = new DateTime(locationTime.Year, locationTime.Month, locationTime.Day)
                ;

                List <EventEntry> currentList = data.events
                                                .Where(e => e.Ends >= locationTime)
                                                .Take(Math.Max(1, outlook.ShowEvents))
                                                .ToList()
                ;

                EventEntry
                    currentEvent = null,
                    firstEvent   = currentList.FirstOrDefault()
                ;

                if (firstEvent != null && firstEvent.Starts <= locationTime)
                {
                    currentEvent = firstEvent;
                }

                string
                    strCurrentEvent  = "",
                    strCurrentStatus = string.Format(
                    Resources.Outlook_AvailableUntil,
                    new DateTime(data.endTime.Ticks).ToShortTimeString()
                    )
                ;

                if (currentEvent != null)
                {
                    DateTime tomorrow = locationToday.AddDays(1);
                    strCurrentEvent = string.Format("{0}, {1} - {2}",
                                                    currentEvent.Subject,
                                                    (currentEvent.Starts >= tomorrow ? currentEvent.Starts.ToShortDateString() + " " : "") + currentEvent.Starts.ToShortTimeString(),
                                                    (currentEvent.Ends >= tomorrow ? currentEvent.Ends.ToShortDateString() + " " : "") + currentEvent.Ends.ToShortTimeString()
                                                    );
                    TimeSpan gap = currentEvent.Ends.Subtract(locationTime);
                    if (gap.Hours > 0)
                    {
                        strCurrentStatus = string.Format(Resources.Outlook_EndsInHrsMin, (int)gap.TotalHours, gap.Minutes);
                    }
                    else
                    {
                        strCurrentStatus = string.Format(Resources.Outlook_EndsInMin, gap.Minutes);
                    }
                }

                else if (firstEvent != null)
                {
                    TimeSpan gap = firstEvent.Starts.Subtract(locationTime);
                    if (gap.Hours > 0)
                    {
                        strCurrentStatus = string.Format(Resources.Outlook_AvailableForHrsMin, (int)gap.TotalHours, gap.Minutes);
                    }
                    else
                    {
                        strCurrentStatus = string.Format(Resources.Outlook_AvailableForMin, gap.Minutes);
                    }
                }

                JavaScriptSerializer jss = new JavaScriptSerializer();
                jss.RegisterConverters(new[] { new EventEntryConverter() });
                json = jss.Serialize(new
                {
                    currentTime = new
                    {
                        year     = locationTime.Year,
                        month    = locationTime.Month,
                        day      = locationTime.Day,
                        weekDay  = locationTime.DayOfWeek,
                        hour     = locationTime.Hour,
                        minute   = locationTime.Minute,
                        second   = locationTime.Second,
                        timeZone = new
                        {
                            id             = data.timeZone.Id,
                            daylightName   = data.timeZone.DaylightName,
                            utcOffsetHours = data.timeZone.BaseUtcOffset.TotalHours,
                        },
                    },
                    mailbox   = data.DisplayName,
                    startTime = new
                    {
                        hour   = data.startTime.Hours,
                        minute = data.startTime.Minutes,
                    },
                    endTime = new
                    {
                        hour   = data.endTime.Hours,
                        minute = data.endTime.Minutes,
                    },
                    currentEvent  = strCurrentEvent,
                    currentStatus = strCurrentStatus,
                    //mode = outlook.Mode,
                    events = new
                    {
                        showEvents = outlook.ShowEvents,
                        head       = EventEntryConverter.Head(),
                        items      = currentList,
                        noEvents   = currentList.Count == 0 ? Resources.Outlook_NoEventsToday : "",
                    },
                });
            }

            catch (Exception ex)
            {
                JavaScriptSerializer s = new JavaScriptSerializer();
                json = s.Serialize(new
                {
                    Error = ex.Message,
                    //Stack = ex.StackTrace,
                    Data = new
                    {
                        FrameId   = frameId,
                        PanelId   = panelId,
                        DisplayId = displayId,
                        Culture   = culture
                    },
                });
            }

            response.Clear();
            response.Cache.SetCacheability(HttpCacheability.NoCache);
            response.Cache.SetSlidingExpiration(true);
            response.Cache.SetNoStore();
            response.ContentType = "application/json";
            response.Write(json);
            response.Flush();
        }
예제 #2
0
 public OutlookData(Outlook outlook, Location location)
 {
     OutlookData.initFromFrame(this, outlook, location);
 }
예제 #3
0
            private static void initFromFrame(OutlookData data, Outlook outlook, Location location)
            {
                DateTime
                    locationTime  = location.LocationTime,
                    locationToday = new DateTime(locationTime.Year, locationTime.Month, locationTime.Day),
                    windowBeg     = locationToday, //locationTime,
                    windowEnd     = locationToday.AddDays(1).AddMilliseconds(-1)
                ;

                // EWS: create connection point
                ServicePointManager.ServerCertificateValidationCallback = CertificateValidationCallBack;

                ExchangeService service = new ExchangeService(outlook.EwsVersion)
                {
                    Credentials = new WebCredentials(
                        outlook.Account,
                        RsaUtil.Decrypt(outlook.Password)
                        ),
                };

                // EWS: get URL
                if (!string.IsNullOrWhiteSpace(outlook.URL))
                {
                    service.Url = new Uri(outlook.URL);
                }
                else
                {
                    service.Url = HttpRuntime.Cache.GetOrAddSliding(
                        string.Format("exchange_account_{0}", outlook.Account),
                        () =>
                    {
                        service.AutodiscoverUrl(outlook.Account, RedirectionUrlValidationCallback);
                        return(service.Url);
                    },
                        TimeSpan.FromMinutes(60)
                        );
                }

                // mailbox: get display name
                data.DisplayName = outlook.Name;
                if (string.IsNullOrWhiteSpace(data.DisplayName))
                {
                    var match = service.ResolveName(outlook.Mailbox);
                    if (match.Count > 0)
                    {
                        if (match[0].Contact != null)
                        {
                            data.DisplayName =
                                match[0].Contact.CompleteName.FullName
                                ?? match[0].Contact.DisplayName
                                ?? data.DisplayName
                            ;
                        }

                        else if (match[0].Mailbox != null)
                        {
                            data.DisplayName =
                                match[0].Mailbox.Name
                                ?? data.DisplayName
                            ;
                        }
                    }
                    //else
                    //    throw new ApplicationException(string.Format("Mailbox {0} not found", mailbox));
                }

                // mailbox: get availability
                GetUserAvailabilityResults uars = service.GetUserAvailability(
                    new AttendeeInfo[] { new AttendeeInfo(outlook.Mailbox, MeetingAttendeeType.Required, true) },
                    new TimeWindow(locationToday, locationToday.AddDays(1)),
                    AvailabilityData.FreeBusy
                    );
                var u = uars.AttendeesAvailability[0];

                if (u.WorkingHours != null)
                {
                    data.startTime = u.WorkingHours.StartTime;
                    data.endTime   = u.WorkingHours.EndTime;
                    data.timeZone  = u.WorkingHours.TimeZone;
                }

                // events: prep filter
                FolderId       folderId = new FolderId(WellKnownFolderName.Calendar, new Mailbox(outlook.Mailbox));
                CalendarFolder calendar = CalendarFolder.Bind(service, folderId, new PropertySet());
                CalendarView   cView    = new CalendarView(windowBeg, windowEnd)
                {
                    PropertySet = new PropertySet(
                        AppointmentSchema.Subject,
                        AppointmentSchema.DateTimeCreated,
                        AppointmentSchema.Start,
                        AppointmentSchema.End,
                        AppointmentSchema.Duration
                        )
                };

                // events: get list
                data.events = calendar
                              .FindAppointments(cView)
                              .OrderBy(i => i.Start)
                              .ThenBy(i => i.DateTimeCreated)
                              .ThenBy(i => i.Subject)
                              //.Take(Math.Max(1, outlook.ShowEvents))
                              .Select(a => new EventEntry
                {
                    Subject   = a.Subject,
                    CreatedOn = a.DateTimeCreated,
                    Starts    = a.Start,
                    Ends      = a.End,
                    Duration  = a.Duration,
                    Today     = locationToday,
                })
                              //.ToList()
                ;
            }
예제 #4
0
        public static Frame GetNextFrame(int panelId, int displayId, int previousFrameId)
        {
            Frame nci = new Frame()
            {
                PanelId   = panelId,
                DisplayId = displayId
            };

            using (SqlCommand cmd = new SqlCommand("sp_GetNextFrame"))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@panelId", SqlDbType.Int).Value     = panelId;
                cmd.Parameters.Add("@displayId", SqlDbType.Int).Value   = displayId;
                cmd.Parameters.Add("@lastFrameId", SqlDbType.Int).Value = previousFrameId;

                using (DataSet ds = DataAccess.RunSql(cmd))
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        DataRow r = ds.Tables[0].Rows[0];
                        nci._initfromRow(r);
                    }
                }
            }

            if (nci.FrameId > 0)
            {
                switch (nci.FrameType)
                {
                case FrameTypes.Clock:
                    nci = new Clock(nci);
                    break;

                case FrameTypes.Html:
                    nci = new Html(nci);
                    break;

                case FrameTypes.Memo:
                    nci = new Memo(nci);
                    break;

                //case FrameTypes.News:
                case FrameTypes.Outlook:
                    nci = new Outlook(nci);
                    break;

                case FrameTypes.Picture:
                    nci = new Picture(nci);
                    break;

                case FrameTypes.Report:
                    nci = new Report(nci);
                    break;

                case FrameTypes.Video:
                    nci = new Video(nci);
                    break;

                case FrameTypes.Weather:
                    nci = new Weather(nci);
                    break;

                case FrameTypes.YouTube:
                    nci = new YouTube(nci);
                    break;

                default:
                    break;
                }
            }

            return(nci);
        }
예제 #5
0
        public static async Task <Frame> GetNextFrameAsync(int panelId, int displayId, int previousFrameId)
        {
            Frame nci = new Frame()
            {
                PanelId   = panelId,
                DisplayId = displayId
            };

            using (SqlCommand cmd = new SqlCommand("sp_GetNextFrame"))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@panelId", SqlDbType.Int).Value     = panelId;
                cmd.Parameters.Add("@displayId", SqlDbType.Int).Value   = displayId;
                cmd.Parameters.Add("@lastFrameId", SqlDbType.Int).Value = previousFrameId;

                await cmd.ExecuteReaderExtAsync((dr) =>
                {
                    nci._initfromRow(dr);
                    return(false);
                });
            }

            if (nci.FrameId > 0)
            {
                switch (nci.FrameType)
                {
                case FrameTypes.Clock:
                    nci = new Clock(nci);
                    break;

                case FrameTypes.Html:
                    nci = new Html(nci);
                    break;

                case FrameTypes.Memo:
                    nci = new Memo(nci);
                    break;

                //case FrameTypes.News:

                case FrameTypes.Outlook:
                    nci = new Outlook(nci);
                    break;

                case FrameTypes.Picture:
                    nci = new Picture(nci);
                    break;

                case FrameTypes.Powerbi:
                    nci = new Powerbi(nci);
                    break;

                case FrameTypes.Report:
                    nci = new Report(nci);
                    break;

                case FrameTypes.Video:
                    nci = new Video(nci);
                    break;

                case FrameTypes.Weather:
                    nci = new Weather(nci);
                    break;

                case FrameTypes.YouTube:
                    nci = new YouTube(nci);
                    break;

                default:
                    break;
                }
            }

            return(nci);
        }
예제 #6
0
            public static async System.Threading.Tasks.Task <OutlookData> FromFrameAsync(Outlook outlook, Location location, int reserveMinutes)
            {
                OutlookData data = new OutlookData();
                DateTime
                    locationTime  = location.LocationTime,
                    locationToday = new DateTime(locationTime.Year, locationTime.Month, locationTime.Day),
                    windowBeg     = locationToday, //locationTime,
                    windowEnd     = locationToday.AddDays(1).AddMilliseconds(-1)
                ;

                // EWS: create connection point
                ServicePointManager.ServerCertificateValidationCallback = CertificateValidationCallBack;

                ExchangeService service = new ExchangeService(outlook.EwsVersion)
                {
                    Credentials = new WebCredentials(
                        outlook.Account,
                        Encryptor.Current.Decrypt(outlook.Password) // 1.4.0
                        ),
                };

                // https://msdn.microsoft.com/en-us/library/office/dn458789%28v=exchg.150%29.aspx?f=255&MSPPError=-2147217396#bk_howmaintained
                // https://social.msdn.microsoft.com/Forums/lync/en-US/bd032e3d-2501-40ba-a2b0-29a404685c35/error-exchange-web-services-are-not-currently-available?forum=exchangesvrdevelopment
                service.HttpHeaders.Add("X-AnchorMailbox", outlook.Account);

                // EWS: get URL
                if (!string.IsNullOrWhiteSpace(outlook.URL))
                {
                    service.Url = new Uri(outlook.URL);
                }
                else
                {
                    service.Url = await HttpRuntime.Cache.GetOrAddSlidingAsync(
                        string.Format("exchange_account_{0}", outlook.Account),
                        async (expire) =>
                    {
                        expire.After = TimeSpan.FromMinutes(60);
                        return(await System.Threading.Tasks.Task.Run(() =>
                        {
                            service.AutodiscoverUrl(outlook.Account, RedirectionUrlValidationCallback);
                            return service.Url;
                        }));
                    });
                }

                // mailbox: get display name
                data.DisplayName = outlook.Name;
                if (string.IsNullOrWhiteSpace(data.DisplayName))
                {
                    var match = await System.Threading.Tasks.Task.Run(() => service.ResolveName(outlook.Mailbox));

                    if (match.Count > 0)
                    {
                        if (match[0].Contact != null)
                        {
                            data.DisplayName =
                                match[0].Contact.CompleteName.FullName
                                ?? match[0].Contact.DisplayName
                                ?? data.DisplayName
                            ;
                        }

                        else if (match[0].Mailbox != null)
                        {
                            data.DisplayName =
                                match[0].Mailbox.Name
                                ?? data.DisplayName
                            ;
                        }
                    }
                    //else
                    //    throw new ApplicationException(string.Format("Mailbox {0} not found", mailbox));
                }

                // mailbox: get availability
                GetUserAvailabilityResults uars = await System.Threading.Tasks.Task.Run(() =>
                {
                    return(service.GetUserAvailability(
                               new AttendeeInfo[] { new AttendeeInfo(outlook.Mailbox, MeetingAttendeeType.Required, true) },
                               new TimeWindow(locationToday, locationToday.AddDays(1)),
                               AvailabilityData.FreeBusy
                               ));
                });

                var u = uars.AttendeesAvailability[0];

                if (u.WorkingHours != null)
                {
                    data.startTime = u.WorkingHours.StartTime;
                    data.endTime   = u.WorkingHours.EndTime;
                    data.timeZone  = u.WorkingHours.TimeZone;
                }

                if (reserveMinutes > 0)
                {
                    Appointment appointment = new Appointment(service)
                    {
                        Subject = outlook.BookingSubject,
                        Body    = string.Format("{0} | {1}", Resources.Outlook_BookingOnDemand, Resources.DisplayMonkey),
                        Start   = DateTime.Now,
                        End     = DateTime.Now.AddMinutes(reserveMinutes),
                    };

                    if (outlook.Mailbox == outlook.Account)
                    {
                        await System.Threading.Tasks.Task.Run(() =>
                        {
                            appointment.Save(SendInvitationsMode.SendToNone);
                            return(true);
                        });
                    }
                    else
                    {
                        appointment.Resources.Add(outlook.Mailbox);
                        await System.Threading.Tasks.Task.Run(() =>
                        {
                            appointment.Save(SendInvitationsMode.SendOnlyToAll);
                            return(true);
                        });
                    }
                }

                // events: prep filter
                FolderId       folderId = new FolderId(WellKnownFolderName.Calendar, new Mailbox(outlook.Mailbox));
                CalendarFolder calendar = await System.Threading.Tasks.Task.Run(() => CalendarFolder.Bind(service, folderId, new PropertySet()));

                CalendarView cView = new CalendarView(windowBeg, windowEnd)
                {
                    PropertySet = new PropertySet(
                        //BasePropertySet.FirstClassProperties,
                        AppointmentSchema.Subject,
                        AppointmentSchema.DateTimeCreated,
                        AppointmentSchema.Start,
                        AppointmentSchema.End,
                        AppointmentSchema.Duration,
                        AppointmentSchema.Sensitivity,
                        AppointmentSchema.LegacyFreeBusyStatus
                        )
                };

                // events: get list
                var appointments = await System.Threading.Tasks.Task.Run(() => calendar.FindAppointments(cView));

                data.events = appointments
                              //.FindAppointments(cView)
                              .Where(a =>
                                     (outlook.Privacy != Models.OutlookPrivacy.OutlookPrivacy_NoClassified || a.Sensitivity == Sensitivity.Normal) &&
                                     (outlook.IsShowAsAllowed(a.LegacyFreeBusyStatus))
                                     )
                              .OrderBy(i => i.Start)
                              .ThenBy(i => i.DateTimeCreated)
                              .ThenBy(i => i.Subject)
                              //.Take(Math.Max(1, outlook.ShowEvents))
                              .Select(a => new EventEntry
                {
                    Subject =
                        outlook.Privacy == Models.OutlookPrivacy.OutlookPrivacy_All || a.Sensitivity == Sensitivity.Normal ? a.Subject :
                        DataAccess.StringResource(string.Format("EWS_Sensitivity_{0}", a.Sensitivity.ToString())),
                    CreatedOn   = a.DateTimeCreated,
                    Starts      = a.Start,
                    Ends        = a.End,
                    Duration    = a.Duration,
                    Sensitivity = a.Sensitivity,
                    Today       = locationToday,
                    ShowAs      = a.LegacyFreeBusyStatus,
                })
                              .ToList()
                ;

                return(data);
            }
예제 #7
0
        public override async System.Threading.Tasks.Task ProcessRequestAsync(HttpContext context)
        {
            HttpRequest  request  = context.Request;
            HttpResponse response = context.Response;

            int    frameId        = request.IntOrZero("frame");
            int    panelId        = request.IntOrZero("panel");
            int    displayId      = request.IntOrZero("display");
            string culture        = request.StringOrBlank("culture");
            int    reserveMinutes = request.IntOrZero("reserveMinutes");
            int    trace          = request.IntOrZero("trace");

            string json = "";

            try
            {
                // set culture
                Outlook  outlook  = new Outlook(frameId);
                Location location = new Location(displayId);

                if (string.IsNullOrWhiteSpace(culture))
                {
                    culture = location.Culture;
                }

                if (!string.IsNullOrWhiteSpace(culture))
                {
                    System.Globalization.CultureInfo cultureInfo = new System.Globalization.CultureInfo(culture);
                    System.Threading.Thread.CurrentThread.CurrentCulture   = cultureInfo;
                    System.Threading.Thread.CurrentThread.CurrentUICulture = cultureInfo;
                }

                // EWS: get data
                OutlookData data = await HttpRuntime.Cache.GetOrAddAbsoluteAsync(
                    string.Format("outlook_{0}_{1}_{2}", location.LocationId, outlook.FrameId, outlook.Version),
                    async (expire) =>
                {
                    expire.When = DateTime.Now.AddMinutes(outlook.CacheInterval);
                    return(await OutlookData.FromFrameAsync(outlook, location, reserveMinutes));
                });

                // ---------------------- culture-specific starts here --------------------- //
                DateTime
                    locationTime  = location.LocationTime,
                    locationToday = new DateTime(locationTime.Year, locationTime.Month, locationTime.Day)
                ;

                //int showEvents = outlook.ShowEvents;
                List <EventEntry> currentList = data.events
                                                .Where(e => e.Ends >= locationTime)
                                                .Take(Math.Max(1, outlook.ShowEvents))
                                                .ToList()
                ;

                EventEntry
                    currentEvent = null,
                    firstEvent   = currentList.FirstOrDefault()
                ;

                if (firstEvent != null && firstEvent.Starts <= locationTime)
                {
                    currentEvent = firstEvent;
                }

                DateTime endTime = locationToday.Add(data.endTime);
                string
                    strCurrentEvent  = "",
                    strCurrentStatus = string.Format(
                    Resources.Outlook_AvailableUntil,
                    endTime.ToShortTimeString()
                    )
                ;
                TimeSpan availableTime = new TimeSpan(0);

                if (currentEvent != null)
                {
                    DateTime tomorrow = locationToday.AddDays(1);
                    strCurrentEvent = string.Format("{0}, {1} - {2}",
                                                    currentEvent.Subject,
                                                    (currentEvent.Starts >= tomorrow ? currentEvent.Starts.ToShortDateString() + " " : "") + currentEvent.Starts.ToShortTimeString(),
                                                    (currentEvent.Ends >= tomorrow ? currentEvent.Ends.ToShortDateString() + " " : "") + currentEvent.Ends.ToShortTimeString()
                                                    );
                    TimeSpan gap = currentEvent.Ends.Subtract(locationTime);
                    if (gap.Hours > 0)
                    {
                        strCurrentStatus = string.Format(Resources.Outlook_EndsInHrsMin, (int)gap.TotalHours, gap.Minutes);
                    }
                    else
                    {
                        strCurrentStatus = string.Format(Resources.Outlook_EndsInMin, gap.Minutes);
                    }
                }
                else if (firstEvent != null)
                {
                    availableTime = firstEvent.Starts.Subtract(locationTime);
                    if (availableTime.Hours > 0)
                    {
                        strCurrentStatus = string.Format(Resources.Outlook_AvailableForHrsMin, (int)availableTime.TotalHours, availableTime.Minutes);
                    }
                    else
                    {
                        strCurrentStatus = string.Format(Resources.Outlook_AvailableForMin, availableTime.Minutes);
                    }
                }
                else if (locationTime < endTime)
                {
                    availableTime = endTime.Subtract(locationTime);
                }

                JavaScriptSerializer jss = new JavaScriptSerializer();
                jss.RegisterConverters(new[] { new EventEntryConverter() });
                json = jss.Serialize(new
                {
                    currentTime = new
                    {
                        year     = locationTime.Year,
                        month    = locationTime.Month,
                        day      = locationTime.Day,
                        weekDay  = locationTime.DayOfWeek,
                        hour     = locationTime.Hour,
                        minute   = locationTime.Minute,
                        second   = locationTime.Second,
                        timeZone = new
                        {
                            id             = data.timeZone.Id,
                            daylightName   = data.timeZone.DaylightName,
                            utcOffsetHours = data.timeZone.BaseUtcOffset.TotalHours,
                        },
                    },
                    mailbox   = data.DisplayName,
                    startTime = new
                    {
                        hour   = data.startTime.Hours,
                        minute = data.startTime.Minutes,
                    },
                    endTime = new
                    {
                        hour   = data.endTime.Hours,
                        minute = data.endTime.Minutes,
                    },
                    currentEvent  = strCurrentEvent,
                    currentStatus = strCurrentStatus,
                    available     = new
                    {
                        days    = (int)availableTime.TotalDays,
                        hours   = (int)availableTime.TotalHours,
                        minutes = (int)availableTime.TotalMinutes,
                    },
                    events = new
                    {
                        items = currentList,
                    },
                    labels = new[]
                    {
                        new { key = "subject", value = Resources.Outlook_Event },
                        new { key = "starts", value = Resources.Outlook_Starts },
                        new { key = "ends", value = Resources.Outlook_Ends },
                        new { key = "duration", value = Resources.Outlook_Duration },
                        new { key = "sensitivity", value = Resources.Outlook_Sensitivity },
                        new { key = "showAs", value = Resources.OutlookShowAs },
                        new { key = "noEvents", value = Resources.Outlook_NoEventsToday },
                        new { key = "bookingImpossible", value = Resources.Outlook_BookingImpossible },
                        new { key = "bookingSent", value = Resources.Outlook_BookingSent },
                    },
                });
            }

            catch (Exception ex)
            {
                JavaScriptSerializer s = new JavaScriptSerializer();
                if (trace == 0)
                {
                    json = s.Serialize(new
                    {
                        Error = ex.Message,
                        Data  = new
                        {
                            FrameId   = frameId,
                            PanelId   = panelId,
                            DisplayId = displayId,
                            Culture   = culture
                        },
                    });
                }
                else
                {
                    json = s.Serialize(new
                    {
                        Error = ex.Message,
                        Stack = ex.StackTrace,
                        Data  = new
                        {
                            FrameId   = frameId,
                            PanelId   = panelId,
                            DisplayId = displayId,
                            Culture   = culture
                        },
                    });
                }
            }

            response.Clear();
            response.Cache.SetCacheability(HttpCacheability.NoCache);
            response.Cache.SetSlidingExpiration(true);
            response.Cache.SetNoStore();
            response.ContentType = "application/json";
            response.Write(json);
            response.Flush();
        }
예제 #8
0
 public OutlookData(Outlook outlook, Location location, int reserveMinutes)
 {
     //OutlookData.initFromFrame(this, outlook, location, reserveMinutes);
 }