當前位置: 首頁>>代碼示例>>C#>>正文


C# SirenOfShameSettings.GetSosOnlineContent方法代碼示例

本文整理匯總了C#中SirenOfShame.Lib.Settings.SirenOfShameSettings.GetSosOnlineContent方法的典型用法代碼示例。如果您正苦於以下問題:C# SirenOfShameSettings.GetSosOnlineContent方法的具體用法?C# SirenOfShameSettings.GetSosOnlineContent怎麽用?C# SirenOfShameSettings.GetSosOnlineContent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SirenOfShame.Lib.Settings.SirenOfShameSettings的用法示例。


在下文中一共展示了SirenOfShameSettings.GetSosOnlineContent方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: TryToGetAndSendNewSosOnlineAlerts

        public virtual void TryToGetAndSendNewSosOnlineAlerts(SirenOfShameSettings settings, DateTime now, Action<NewAlertEventArgs> invokeNewAlert)
        {
            if (!settings.GetSosOnlineContent()) return;

            bool weHaveAlreadyCheckedForAlertsToday = settings.LastCheckedForAlert != null && (now - settings.LastCheckedForAlert.Value).TotalHours < 24;
            if (weHaveAlreadyCheckedForAlertsToday) return;

            settings.LastCheckedForAlert = DateTime.Now;
            settings.Save();
            var webClient = GetWebClient();
            webClient.DownloadStringCompleted += (s, e) =>
            {
                try
                {
                    if (e.Error != null)
                    {
                        _log.Error("Error retrieving alert", e.Error);
                        return;
                    }
                    NewAlertEventArgs args = new NewAlertEventArgs();
                    var successParsing = args.Instantiate(e.Result);
                    if (successParsing)
                    {
                        if (settings.SoftwareInstanceId == null)
                        {
                            settings.SoftwareInstanceId = args.SoftwareInstanceId;
                            settings.Save();
                        }
                        if (settings.AlertClosed == null || args.AlertDate > settings.AlertClosed)
                        {
                            invokeNewAlert(args);
                        }
                    }
                }
                catch (Exception ex)
                {
                    _log.Error("Error retrieving alert", ex);
                }
            };
            string url = string.Format(SOS_URL + "/GetAlert?SirenEverConnected={0}&SoftwareInstanceId={1}&ServerType={2}&Version={3}",
                settings.SirenEverConnected,
                settings.SoftwareInstanceId,
                string.Join(",", settings.CiEntryPointSettings.Select(cip => cip.Name)),
                Application.ProductVersion
                );
            webClient.DownloadStringAsync(new Uri(url));
        }
開發者ID:greghaskins,項目名稱:SirenOfShame,代碼行數:47,代碼來源:SosOnlineService.cs

示例2: StartRealtimeConnection

 public virtual async Task<DesktopAppConnectionResult> StartRealtimeConnection(SirenOfShameSettings settings)
 {
     try
     {
         if (!settings.GetSosOnlineContent())
         {
             InvokeOnSosOnlineStatusChange("Disabled");
             return new DesktopAppConnectionResult { Success = false };
         }
         InvokeOnSosOnlineStatusChange("Connecting");
         _connection = new HubConnection(SOS_URL);
         _proxy = _connection.CreateHubProxy("SosHub");
         _proxy.On("addChatMessageToDesktopClients", InvokeOnOnNewSosOnlineNotification);
         _connection.Error += ConnectionOnError;
         _connection.StateChanged += ConnectionOnStateChanged;
         _connection.Closed += ConnectionOnClosed;
         await _connection.Start();
         var credentialApiModel = new CredentialApiModel
         {
             UserName = settings.SosOnlineUsername,
             Password = settings.SosOnlinePassword,
         };
         var result = await _proxy.Invoke<DesktopAppConnectionResult>("connectDesktopApp", credentialApiModel);
         if (!result.Success)
         {
             _connection.Stop();
         }
         return result;
     } 
     catch (Exception ex)
     {
         _log.Error("Unable to start realtime connection to SoS Online", ex);
     }
     return new DesktopAppConnectionResult { Success = false };
 }
開發者ID:greghaskins,項目名稱:SirenOfShame,代碼行數:35,代碼來源:SosOnlineService.cs

示例3: StartRealtimeConnection

 public virtual void StartRealtimeConnection(SirenOfShameSettings settings)
 {
     try
     {
         if (!settings.GetSosOnlineContent())
         {
             InvokeOnSosOnlineStatusChange("Disabled");
             return;
         }
         InvokeOnSosOnlineStatusChange("Connecting");
         _connection = new HubConnection(SOS_URL);
         _proxy = _connection.CreateProxy("SosHub");
         _proxy.On("addAppNotificationV1", InvokeOnOnNewSosOnlineNotification);
         _connection.Error += ConnectionOnError;
         _connection.StateChanged += ConnectionOnStateChanged;
         _connection.Closed += ConnectionOnClosed;
         Task result = _connection.Start();
         result.ContinueWith(ConnectionOnError, TaskContinuationOptions.OnlyOnFaulted);
     }
     catch (Exception ex)
     {
         _log.Error("Unable to start realtime connection to SoS Online", ex);
     }
 }
開發者ID:ramalama,項目名稱:SirenOfShame,代碼行數:24,代碼來源:SosOnlineService.cs


注:本文中的SirenOfShame.Lib.Settings.SirenOfShameSettings.GetSosOnlineContent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。