Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
Getting ready for v0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
dnas2 committed Dec 13, 2017
1 parent 39571f0 commit 012b130
Showing 1 changed file with 29 additions and 16 deletions.
45 changes: 29 additions & 16 deletions ad-automation/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,24 @@ public partial class adForm : Form
string advertPath = "";
string promoPath = "";
string targetPath = "";
DateTime nextMonday;
public static List<advert> allAdverts = new List<advert>();
public static List<advert> adsToPlayPerDay = new List<advert>(); // List of adverts by number of plays needed
public static List<promo> allPromos = new List<promo>();
public static List<promo> allPromosWeighted = new List<promo>();
List<adBreak> allBreaksList = new List<adBreak>();
public static List<audioFile> thisBreak = new List<audioFile>();
public static List<audioFile> lastBreak = new List<audioFile>();
public static List<string> thisBreakKeywords = new List<string>();
public bool advertDateHasBeenSet = false;

public static string jingleStudioPathValue { get; private set; }

public adForm()
{
InitializeComponent();
DateTime tomorrow = DateTime.Today.AddDays(1);
createBreaksForPicker.Value = tomorrow;
loadAdvertBreaksFromDate();
}

private void button1_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -107,7 +108,7 @@ private void canGenerateButtonBeDisabled()

private void generateBreaksButton_Click(object sender, EventArgs e)
{
createTargetDirectory();
createTargetDirectory(createBreaksForPicker.Value);
createBreaks();
jingleStudioPathValue = jinglesStudioPath.Text;
progressBar1.Minimum = 0;
Expand All @@ -124,6 +125,7 @@ private void generateBreaksButton_Click(object sender, EventArgs e)
outputLog();
fileBeingGeneratedLabel.Text = "Done";
Process.Start(targetPath); // Opens Windows Explorer to output directory
Application.Exit();
}

private void outputLog()
Expand Down Expand Up @@ -188,8 +190,8 @@ public static promo selectPromo(DateTime breakTargetTime)
private static promo choosePromoAtRandom()
{
Random rnd = new Random();
int numericRnd = rnd.Next(0, allPromos.Count);
return allPromos[numericRnd];
int numericRnd = rnd.Next(0, allPromosWeighted.Count);
return allPromosWeighted[numericRnd];
}

private static advert chooseAdvertAtRandom()
Expand All @@ -201,13 +203,11 @@ private static advert chooseAdvertAtRandom()
}


private void createTargetDirectory()
private void createTargetDirectory(DateTime breakDate)
{
string dateTime = DateTime.Now.ToString();
dateTime = dateTime.Replace("/", "");
dateTime = dateTime.Replace(" ", "");
dateTime = dateTime.Replace(":", "");
targetPath = targetPath + "\\" + dateTime;
string dateTime = DateTime.Now.ToString("yyyyMMddHHmmss");
string breakDateStr = breakDate.ToString("dd-MMM-yyyy");
targetPath = targetPath + "\\Adverts for " + breakDateStr + " - Created " + dateTime;
Directory.CreateDirectory(targetPath);
}

Expand Down Expand Up @@ -252,16 +252,22 @@ private void getPromosInFolder(string folderPath)
tmpPromo.addToPromoTablePanel(promoTableLayoutPanel);
// Add promo mulitple times depending on priorities to weight the probabilityu of it being chosen
allPromos.Add(tmpPromo);
allPromosWeighted.Add(tmpPromo);
if (tmpPromo.priority < 3)
{
allPromos.Add(tmpPromo);
allPromos.Add(tmpPromo);
allPromosWeighted.Add(tmpPromo);
allPromosWeighted.Add(tmpPromo);
allPromosWeighted.Add(tmpPromo);
}
if (tmpPromo.priority < 2)
{
allPromos.Add(tmpPromo);
allPromos.Add(tmpPromo);
allPromos.Add(tmpPromo);
allPromosWeighted.Add(tmpPromo);
allPromosWeighted.Add(tmpPromo);
allPromosWeighted.Add(tmpPromo);
allPromosWeighted.Add(tmpPromo);
allPromosWeighted.Add(tmpPromo);
allPromosWeighted.Add(tmpPromo);
allPromosWeighted.Add(tmpPromo);
}
}
}
Expand All @@ -275,6 +281,12 @@ private void adForm_Load(object sender, EventArgs e)
}

private void createBreaksForPicker_ValueChanged(object sender, EventArgs e)
{
loadAdvertBreaksFromDate();
}


private void loadAdvertBreaksFromDate()
{
DateTime breakDate = createBreaksForPicker.Value.Date;
string[] breaksOnDay = new string[] { "Select the day to set advert times" };
Expand All @@ -292,6 +304,7 @@ private void createBreaksForPicker_ValueChanged(object sender, EventArgs e)
advertDateHasBeenSet = true;
canGenerateButtonBeDisabled();
}

}
}

Expand Down

0 comments on commit 012b130

Please sign in to comment.