当前位置: 首页>>代码示例>>C#>>正文


C# ExchangeService.SubscribeToStreamingNotifications方法代码示例

本文整理汇总了C#中ExchangeService.SubscribeToStreamingNotifications方法的典型用法代码示例。如果您正苦于以下问题:C# ExchangeService.SubscribeToStreamingNotifications方法的具体用法?C# ExchangeService.SubscribeToStreamingNotifications怎么用?C# ExchangeService.SubscribeToStreamingNotifications使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ExchangeService的用法示例。


在下文中一共展示了ExchangeService.SubscribeToStreamingNotifications方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnMessage

        public override void OnMessage(string value)
        {
            try
            {
                // クライアントからメッセージが来た場合
                JsonObject jsonValue = (JsonObject)JsonValue.Parse(value);
                this.EmailAddress = (string)((JsonPrimitive)jsonValue["address"]).Value;
                this.Password = (string)((JsonPrimitive)jsonValue["password"]).Value;

                // Exchange Online に接続 (今回はデモなので、Address は決めうち !)
                ExchangeVersion ver = new ExchangeVersion();
                ver = ExchangeVersion.Exchange2010_SP1;
                sv = new ExchangeService(ver, TimeZoneInfo.FindSystemTimeZoneById("Tokyo Standard Time"));
                //sv.TraceEnabled = true; // デバッグ用
                sv.Credentials = new System.Net.NetworkCredential(
                    this.EmailAddress, this.Password);
                sv.EnableScpLookup = false;
                sv.AutodiscoverUrl(this.EmailAddress, AutodiscoverCallback);

                // Streaming Notification の開始 (今回はデモなので、15 分で終わり !)
                StreamingSubscription sub = sv.SubscribeToStreamingNotifications(
                    new FolderId[] { new FolderId(WellKnownFolderName.Calendar) }, EventType.Created, EventType.Modified, EventType.Deleted);
                subcon = new StreamingSubscriptionConnection(sv, 15); // only 15 minutes !
                subcon.AddSubscription(sub);
                subcon.OnNotificationEvent += new StreamingSubscriptionConnection.NotificationEventDelegate(subcon_OnNotificationEvent);
                subcon.Open();

                // 準備完了の送信 !
                JsonObject jsonObj = new JsonObject(
                    new KeyValuePair<string, JsonValue>("MessageType", "Ready"),
                    new KeyValuePair<string, JsonValue>("ServerUrl", sv.Url.ToString()));
                this.SendMessage(jsonObj.ToString());
            }
            catch (Exception ex)
            {
                this.SendInternalError(ex);
            }

            base.OnMessage(value);
        }
开发者ID:tsmatsuz,项目名称:20110629_ExchangeOnlineSample,代码行数:40,代码来源:MyNotifyService.cs

示例2: SetStreamingNotifications

        static void SetStreamingNotifications(ExchangeService service,IUserData ud)
        {
            // Subscribe to streaming notifications on the Inbox folder, and listen
            // for "NewMail", "Created", and "Deleted" events.
            try
            {
                StreamingSubscription streamingsubscription = service.SubscribeToStreamingNotifications(
                    new FolderId[] { WellKnownFolderName.Inbox },
                    EventType.NewMail,
                    EventType.Created,
                    EventType.Deleted);

                StreamingSubscriptionConnection connection = new StreamingSubscriptionConnection(service, 1);

                connection.AddSubscription(streamingsubscription);
                // Delegate event handlers.
                connection.OnNotificationEvent +=
                    new StreamingSubscriptionConnection.NotificationEventDelegate(OnEvent);
                connection.OnSubscriptionError +=
                    new StreamingSubscriptionConnection.SubscriptionErrorDelegate(OnError);
                connection.OnDisconnect +=
                    new StreamingSubscriptionConnection.SubscriptionErrorDelegate(OnDisconnect);
                connection.Open();

                Log(string.Format("Zasubskrybowano konto: {0}", ud.EmailAddress));

            }
            catch (Exception e)
            {
                Log("Błąd w trakcie próby podłączenia subskrypcji." + e.InnerException.ToString());

            }
        }
开发者ID:KamilZet,项目名称:zalacznikX,代码行数:33,代码来源:Sluchaj.cs


注:本文中的ExchangeService.SubscribeToStreamingNotifications方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。