-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
176 lines (159 loc) · 5.51 KB
/
Copy pathProgram.cs
File metadata and controls
176 lines (159 loc) · 5.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Data;
using System.IO;
using System.Text;
using System.Windows;
using static System.Reflection.Metadata.BlobBuilder;
namespace MusicTrax
{
internal class Program
{
string filePath = @"C:\scripts\";
string inFile = "";
string script = "";
DateTime logDate = DateTime.Now;
List<string> Tracks = new List<string>();
string tag2 = "The City of Sunshine's official radio station: Sunny 107; ";
string tag1 = "Today's hits. Yesterday's favorites. Sunny 107; ";
string tag3 = "Sunny 107: the Basin's soft rock station; ";
string tag4 = "Today's hits; Timeless favorites. Sunny 107;";
[STAThread]
private static void Main(string[] args)
{
Program VoiceTrack = new Program();
VoiceTrack.RunMe();
}
private void RunMe()
{
bool keepTrying = true;
string userResponse = "";
while (keepTrying)
{
keepTrying = false;
userResponse = GetLogDate();
if (!DateTime.TryParse(userResponse, out logDate) ||
userResponse == "" ||
userResponse == null)
{
keepTrying = true;
_ = GetLogDate();
}
else
{
keepTrying = false;
inFile = filePath + logDate.ToString("yyMMdd") + ".ASC";
script = filePath + "__Script_" + logDate.ToString("M-d-yy") + ".txt";
}
}
ProcessText();
}
private string GetLogDate()
{
Console.WriteLine("Log date = ");
return Console.ReadLine()!;
}
public void ProcessText()
{
Random rando = new Random();
StreamWriter trackWriter = new StreamWriter(script, false);
trackWriter.WriteLine($"KKRB Script for {logDate.ToString("ddd")}, {logDate.ToString("M-d-yy")}");
string whichTag = "";
int iHour;
// To read a text file line by line
if (File.Exists(inFile))
{
// Store each line in array of strings
string[] lines = File.ReadAllLines(inFile);
for (int i = 0; i < lines.Length; i++)
{
string[] fields = lines[i].Split(',');
iHour = GetHour(lines[i]);
for (int j = 0; j < fields.Count(); j++)
{
fields[j] = fields[j].Replace('"', ' ');
}
if (!lines[i].Contains("SWEEPER") &&
(iHour >= 6 && iHour < 18))
{
if (fields[1] == "*")
{
trackWriter.WriteLine($"");
trackWriter.WriteLine($"***************** {fields[0]} HOUR *****************");
}
if (lines[i].Contains("VOICETRACK") ||
lines[i].Contains("Voice Track"))
{
whichTag = SelectTag(rando.Next(7, 2501));
trackWriter.WriteLine($"");
trackWriter.WriteLine($"{fields[3]}");
trackWriter.WriteLine($"----------------");
trackWriter.WriteLine(whichTag);
trackWriter.WriteLine();
}
else if (lines[i].Contains("STOPSET"))
{
trackWriter.WriteLine($"STOPSET");
}
else
{
if (!lines[i].Contains("Legal ID"))
{
trackWriter.WriteLine($"{fields[0]} {fields[3]} {fields[4]} {fields[5]} {fields[6]} {fields[7]}");
}
}
}
}
}
trackWriter.Flush();
trackWriter.Close();
trackWriter.Dispose();
// Console.ReadLine();
/*
if (File.Exists(inFile))
{
File.Delete(inFile);
}
*/
} // Process Text
private string SelectTag(int randomTag)
{
bool lIsPrime = IsPrime(randomTag);
if (lIsPrime)
{
return tag4;
}
else if (randomTag % 2 == 0)
{
return tag2;
}
else if (randomTag % 3 == 0)
{
return tag3;
}
return tag1;
} // Select Tag
private bool IsPrime(int whatNumber)
{
for (int i = 8; i < whatNumber; i++)
if (whatNumber % i == 0) return false;
return true;
} // IsPrime
private int GetHour(string line)
{
int hour = 0;
string subst = "";
if (line != null &&
line.Length > 0)
{
subst = line.Substring(0, 2);
}
if (int.TryParse(subst, out hour))
{
return hour;
}
return 0;
} // GetHour
} // class
} // namespace