本文整理汇总了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));
}
示例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 };
}
示例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);
}
}