Skip to content

Commit

Permalink
Merge pull request #270 from dasgarner/develop
Browse files Browse the repository at this point in the history
v3 R306
  • Loading branch information
dasgarner authored Nov 15, 2022
2 parents 1add602 + f9ab999 commit 292bb44
Show file tree
Hide file tree
Showing 12 changed files with 612 additions and 78 deletions.
47 changes: 41 additions & 6 deletions Adspace/Ad.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (C) 2021 Xibo Signage Ltd
* Copyright (C) 2022 Xibo Signage Ltd
*
* Xibo - Digital Signage - http://www.xibo.org.uk
*
Expand Down Expand Up @@ -29,6 +29,7 @@
using System.Collections.Generic;
using System.Device.Location;
using System.Diagnostics;
using System.Linq;

namespace XiboClient.Adspace
{
Expand All @@ -39,20 +40,32 @@ public class Ad
public string Title;
public string CreativeId;
public string Duration;
public string File;
public string Type;
public string XiboType;
public int Width;
public int Height;

public string AdTagUri;
public string Url;
public List<string> ImpressionUrls = new List<string>();
public List<string> ErrorUrls = new List<string>();

// Wrapper settings
// many of these come from Xibo specific extensions.
public bool IsWrapper;
public bool IsWrapperResolved = false;
public bool IsWrapperOpenImmediately = false;
public bool IsWrapperResolving = false;
public int CountWraps = 0;
public List<string> AllowedWrapperTypes = new List<string>();
public string AllowedWrapperDuration;

public List<string> WrapperAllowedTypes = new List<string>();
public string WrapperAllowedDuration;
public string WrapperPartner;
public string WrapperFileScheme = "creativeId";
public string WrapperExtendUrl = "";
public string WrapperHttpMethod = "GET";
public int WrapperMaxDuration = 0;
public int WrapperRateLimit = 0;

public bool IsGeoAware = false;
public string GeoLocation = "";
Expand All @@ -75,15 +88,37 @@ public int GetDuration()
return (int)TimeSpan.Parse(Duration).TotalSeconds;
}

/// <summary>
/// Get the duration in seconds
/// </summary>
/// <returns></returns>
public int GetWrapperAllowedDuration()
{
return (int)TimeSpan.Parse(WrapperAllowedDuration).TotalSeconds;
}

public string GetFileName()
{
if (WrapperFileScheme == "fileName")
{
return "axe_" + Url.Split('/').Last();
}
else
{
return "axe_" + CreativeId;
}
}

/// <summary>
/// Download this ad
/// </summary>
public void Download()
{
// We should download it.
new Url(Url).DownloadFileAsync(ApplicationSettings.Default.LibraryPath, File).ContinueWith(t =>
string fileName = GetFileName();
new Url(Url).DownloadFileAsync(ApplicationSettings.Default.LibraryPath, fileName).ContinueWith(t =>
{
CacheManager.Instance.Add(File, CacheManager.Instance.GetMD5(File));
CacheManager.Instance.Add(fileName, CacheManager.Instance.GetMD5(fileName));
}, System.Threading.Tasks.TaskContinuationOptions.OnlyOnRanToCompletion);
}

Expand Down
Loading

0 comments on commit 292bb44

Please sign in to comment.