本文整理汇总了C#中IResource.GetSnapshot方法的典型用法代码示例。如果您正苦于以下问题:C# IResource.GetSnapshot方法的具体用法?C# IResource.GetSnapshot怎么用?C# IResource.GetSnapshot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IResource
的用法示例。
在下文中一共展示了IResource.GetSnapshot方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessFixture
private void ProcessFixture(IResource fixture, string sport)
{
if (!_activeFixtures.ContainsKey(fixture.Id) && !_listeners.ContainsKey(fixture.Id))
{
try
{
_activeFixtures.TryAdd(fixture.Id, true);
var matchStatus = 0;
var matchSequence = 0;
if (fixture.Content != null)
{
matchStatus = fixture.Content.MatchStatus;
//Get the sequence number, if you store this to file you can check if you need to process a snapshot between restarts
//this can save pushing unnesasary snapshots
matchSequence = fixture.Content.Sequence;
}
//if not match over
if (matchStatus != (int)SSMatchStatus.MatchOver)
{
_logger.InfoFormat("Get UDAPI Snapshot for {0} id {1}", fixture.Name, fixture.Id);
var snapshotString = fixture.GetSnapshot();
_logger.InfoFormat("Successfully retrieved UDAPI Snapshot for {0} id {1}", fixture.Name, fixture.Id);
var fixtureSnapshot =
(Fixture)
JsonConvert.DeserializeObject(snapshotString, typeof(Fixture),
new JsonSerializerSettings
{
Converters =
new List<JsonConverter> { new IsoDateTimeConverter() },
NullValueHandling = NullValueHandling.Ignore
});
var epoch = fixtureSnapshot.Epoch;
//process the snapshot here and push it into the client system
var streamListener = new StreamListener(fixture, epoch, sport);
_listeners.TryAdd(fixture.Id, streamListener);
}
else
{
_logger.InfoFormat("Fixture {0} id {1} has finished. Will not process", fixture.Name, fixture.Id);
}
}
catch (Exception ex)
{
_logger.Error(string.Format("Fixture {0} id {1} There is a problem processing this fixture", fixture.Name, fixture.Id), ex);
}
bool y;
_activeFixtures.TryRemove(fixture.Id, out y);
}
else
{
_logger.InfoFormat("Fixture {0} id {1} is currently being processed", fixture.Name, fixture.Id);
if (_listeners.ContainsKey(fixture.Id))
{
if (_listeners[fixture.Id].FixtureEnded)
{
StreamListener theListener;
if (_listeners.TryRemove(fixture.Id, out theListener))
{
_logger.InfoFormat("Fixture {0} id {1} is over.", fixture.Name, fixture.Id);
}
bool activeFixture;
_activeFixtures.TryRemove(fixture.Id, out activeFixture);
}
}
}
}
示例2: ProcessFixture
private void ProcessFixture(IResource fixture, string sport)
{
if (fixture.Id == "cHr2GRRjCB9D7yXi4FoEQ2bt-KI")
return;
if (!FixtureController.Contains(fixture.Id))
{
try
{
var matchStatus = 0;
if (fixture.Content != null)
matchStatus = fixture.Content.MatchStatus;
//if not match over
if (matchStatus != (int)SSMatchStatus.MatchOver)
{
_logger.InfoFormat("Get UDAPI Snapshot for {0} id {1}", fixture.Name, fixture.Id);
var snapshotString = fixture.GetSnapshot();
_logger.InfoFormat("Successfully retrieved UDAPI Snapshot for {0} id {1}", fixture.Name, fixture.Id);
var fixtureSnapshot = snapshotString.FromJson<Fixture>();
var epoch = fixtureSnapshot.Epoch;
//process the snapshot here and push it into the client system
try
{
FixtureController.AddListener(fixture.Id, () => new StreamListener(fixture, epoch));
}
catch (Exception)
{
_logger.ErrorFormat("sport=\"{0}\" : fixtureName=\"{1}\" - Unable to stream fixture", sport, fixture.Name);
throw;
}
}
else
{
_logger.InfoFormat("Fixture {0} id {1} has finished. Will not process", fixture.Name, fixture.Id);
}
}
catch (Exception ex)
{
_logger.Error(string.Format("Fixture {0} id {1} There is a problem processing this fixture", fixture.Name, fixture.Id), ex);
}
}
else
{
bool isMatchOver = FixtureController.Contains(fixture.Id) && FixtureController.GetItem(fixture.Id).FixtureEnded;
if (isMatchOver)
{
if (FixtureController.Contains(fixture.Id))
{
FixtureController.RemoveFixture(fixture.Id);
_logger.InfoFormat("fixtureName=\"{0}\" fixtureId={1} is over.", fixture.Name, fixture.Id);
}
}
else
{
_logger.InfoFormat("fixtureName=\"{0}\" fixtureId={1} is currently being processed", fixture.Name, fixture.Id);
}
_logger.InfoFormat("Fixture {0} id {1} is currently being processed", fixture.Name, fixture.Id);
if (_listeners.ContainsKey(fixture.Id))
{
if (_listeners[fixture.Id].FixtureEnded)
{
StreamListener theListener;
if (_listeners.TryRemove(fixture.Id, out theListener))
{
_logger.InfoFormat("Fixture {0} id {1} is over.", fixture.Name, fixture.Id);
}
bool activeFixture;
_activeFixtures.TryRemove(fixture.Id, out activeFixture);
}
}
}
}