public static Dictionary <int, Session> GetSessionForEvent(int eventId, SqlConnection sqlConnection, Speakers eventSpeakers) { int totalSessionCount = GetNumberOfSessions(); int counter = 0; using ProgressBar progressBar = new ProgressBar(totalSessionCount, "Retrieving session"); var sessions = new Dictionary <int, Session>(); using SqlCommand sqlCommand = new SqlCommand { Connection = sqlConnection, CommandType = CommandType.StoredProcedure, CommandText = "uspRetrieveSessions" }; sqlCommand.Parameters.AddWithValue("@EventId", eventId); const int sessionIdIndex = 0; const int titleIndex = 1; const int abstractIndex = 2; const int summaryIndex = 3; const int sessionPeriodIdIndex = 4; const int youTubeIdIndex = 5; const int sessionLevelIndex = 6; const int sessionTypeIndex = 7; using SqlDataReader reader = sqlCommand.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { var session = new Session() { Id = reader.GetInt32(sessionIdIndex), Title = reader.GetString(titleIndex), Abstract = reader.GetString(abstractIndex), Summary = reader.GetString(summaryIndex), YouTubeId = reader.IsDBNull(youTubeIdIndex) ? string.Empty : reader.GetString(youTubeIdIndex), SessionLevel = reader.GetString(sessionLevelIndex), SessionType = reader.GetString(sessionTypeIndex), SessionPeriodId = reader.GetInt32(sessionPeriodIdIndex) }; if (session.SessionPeriodId == 106 || session.SessionPeriodId == 107 || session.SessionPeriodId == 120) { session.SessionPeriodId = 105; } foreach (var speakerId in Speakers.GetSpeakerIdsForSession(session.Id, sqlConnection)) { session.SessionSpeakers.Add(eventSpeakers[speakerId]); } session.Topics.GetSessionTopics(reader.GetInt32(sessionIdIndex), sqlConnection); session.Tags.GetSessionTags(reader.GetInt32(sessionIdIndex), sqlConnection); sessions.Add(session.Id, session); counter++; progressBar.Tick($"Retrieved {counter} of {totalSessionCount} sessions"); } } return(sessions); }
public static Speakers GetSpeakersForEvent(int eventId, SqlConnection sqlConnection) { var speakers = new Speakers(); int numberOfSpeakers = GetNumberOfSpeakers(); int counter = 0; using ProgressBar progressBar = new ProgressBar(numberOfSpeakers, "Retrieving Speakers..."); using SqlCommand sqlCommand = new SqlCommand { Connection = sqlConnection, CommandType = CommandType.StoredProcedure, CommandText = "uspRetrieveSpeakersForEvent" }; sqlCommand.Parameters.AddWithValue("@EventId", eventId); const int speakerIdIndex = 0; const int firstNameIndex = 1; const int lastNameIndex = 2; const int biographyIndex = 3; using SqlDataReader reader = sqlCommand.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { var speaker = new Speaker() { Id = reader.GetString(speakerIdIndex), FirstName = reader.GetString(firstNameIndex), LastName = reader.GetString(lastNameIndex), Biography = reader.GetString(biographyIndex) }; speaker.SocialMediaAccounts.AddRange(SocialMedia.GetSocialMediaForSpeaker(speaker.Id, sqlConnection)); speaker.Websites.AddRange(Speaker.GetWebsitesForSpeaker(speaker.Id, sqlConnection)); speakers.Add(speaker.Id, speaker); counter++; progressBar.Tick($"Retrieved {counter} of {numberOfSpeakers} speakers"); } } return(speakers); }
public static async Task Main() { using SqlConnection sqlConnection = new SqlConnection(Settings.DatabaseConnectionString); sqlConnection.Open(); var blobServiceClient = new BlobServiceClient(Settings.StorageConnectionString); var blobContainerClient = blobServiceClient.GetBlobContainerClient("cpl20"); var logFileLocation = @"D:\Temp\CPL20Uploads.txt"; var alreadyUploadedVideos = new List<string>(); if (File.Exists(logFileLocation)) { string line; using StreamReader file = new StreamReader(logFileLocation); while ((line = file.ReadLine()) != null) if (int.TryParse(line, out var uploadedSessionId)) alreadyUploadedVideos.Add(line); } var speakers = Speakers.GetSpeakersForEvent(10, sqlConnection); var sessions = Session.GetSessionForEvent(10, sqlConnection, speakers); var sessionTags = SessionTags.GetTags(sqlConnection); sqlConnection.Close(); Console.Clear(); Console.WriteLine("Building session pages..."); var rootDirectory = @"C:\Code PaLOUsa 2020 Videos\"; var pagesPath = @"D:\Repros\TaleLearnCode\CPL20ArchiveSite\src\CPL20Archive\Pages\"; var wwwRootPath = @"D:\Repros\TaleLearnCode\CPL20ArchiveSite\src\CPL20Archive\wwwroot\"; //foreach (string sessionPeriodPath in Directory.GetDirectories(rootDirectory)) //{ // foreach (string sessionPath in Directory.GetDirectories(sessionPeriodPath)) // { // var sessionPathComponents = sessionPath.Split('\\'); // if (sessions.ContainsKey(Convert.ToInt32(sessionPathComponents[sessionPathComponents.Length - 1]))) // { // var session = sessions[Convert.ToInt32(sessionPathComponents[sessionPathComponents.Length - 1])]; // Console.WriteLine($"Uploading MP4 for Session {session.Id}"); // //if (!alreadyUploadedVideos.Contains(session.Id.ToString()) && (session.Id != 1779 || session.Id != 1721)) // //{ // // await UploadVideoAsync(session.Id.ToString(), sessionPath, blobContainerClient); // // alreadyUploadedVideos.Add(session.Id.ToString()); // //} // if (session.Id != 1779 || session.Id != 1721) // sessions[session.Id].VideoUploaded = true; // var path = $@"{pagesPath}sessions\{session.Id}\"; // Directory.CreateDirectory(path); // Console.WriteLine($"Writing session pages for Session {session.Id}"); // var cshtmlPath = @$"{pagesPath}Sessions\{session.Id}\"; // Directory.CreateDirectory(cshtmlPath); // File.WriteAllText($"{cshtmlPath}Index.cshtml", BuildIndexPage(session, sessionTags)); // File.WriteAllText($"{cshtmlPath}Index.cshtml.cs", BuildIndexCSFile(session.Id)); // var sessionEmbedPath = @$"{wwwRootPath}sessions\{session.Id}\"; // Directory.CreateDirectory(sessionEmbedPath); // File.WriteAllText($"{sessionEmbedPath}player.html", BuildPlayerPage(session)); // File.WriteAllText($"{sessionEmbedPath}config.xml", BuildConfigXML(session)); // File.WriteAllText($"{sessionEmbedPath}config_xml.js", BuildConfigXMLJs(session)); // Console.WriteLine(); // } // } //} foreach (var session in sessions.Values) { var cshtmlPath = @$"{pagesPath}Sessions\{session.Id}\"; Directory.CreateDirectory(cshtmlPath); File.WriteAllText($"{cshtmlPath}Index.cshtml", BuildIndexPage(session, sessionTags)); File.WriteAllText($"{cshtmlPath}Index.cshtml.cs", BuildIndexCSFile(session.Id)); if (!string.IsNullOrWhiteSpace(session.YouTubeId)) sessions[session.Id].VideoUploaded = true; } BuildSchedulePages(sessions.Values.ToList(), pagesPath); BuildTagPages(sessions.Values.ToList(), sessionTags, pagesPath); BuildTopicPages(sessions.Values.ToList(), pagesPath); File.WriteAllLines(logFileLocation, alreadyUploadedVideos.ToArray()); Console.WriteLine("Done"); }