/// <summary> /// Initialize lesson controller /// </summary> /// <param name="classCalendarRepo">Class calendar repository</param> /// <param name="userprofileRepo">UserProfile repository</param> /// <param name="classRoomRepo">Class room repository</param> /// <param name="likeLessonRepo">Like lesson repository</param> /// <param name="lessonCatalogRepo">Lesson catalog repository</param> /// <param name="commentRepo">Comment repository</param> /// <param name="friendRequestRepo">Friend request repository</param> /// <param name="userActivityRepo">User activity repository</param> /// <param name="notificationCtrl">Notificaotion API</param> /// <param name="config">App configuration option</param> public LessonController(IClassCalendarRepository classCalendarRepo, IUserProfileRepository userprofileRepo, IClassRoomRepository classRoomRepo, ILikeLessonRepository likeLessonRepo, ILessonCatalogRepository lessonCatalogRepo, ICommentRepository commentRepo, IFriendRequestRepository friendRequestRepo, IUserActivityRepository userActivityRepo, NotificationController notificationCtrl, IOptions <AppConfigOptions> options, ILessonTestResultRepository lessonTestResultRepo, IDateTime dateTime) { _classCalendarRepo = classCalendarRepo; _userprofileRepo = userprofileRepo; _classRoomRepo = classRoomRepo; _likeLessonRepo = likeLessonRepo; _lessonCatalogRepo = lessonCatalogRepo; _commentRepo = commentRepo; _friendRequestRepo = friendRequestRepo; _userActivityRepo = userActivityRepo; _notificationCtrl = notificationCtrl; _appConfig = options.Value; _dateTime = dateTime; _lessonTestResultRepo = lessonTestResultRepo; }
/// <summary> /// Initialize purchase controller /// </summary> /// <param name="courseCtrl">Course API</param> /// <param name="myCourseCtrl">MyCourse API</param> /// <param name="userProfileRepo">User profile repository</param> /// <param name="classRoomRepo">Class room repository</param> /// <param name="classCalendarRepo">Class calendar repository</param> /// <param name="lessonCatalogRepo">Lesson catalog repository</param> /// <param name="userActivityRepo">User activity repository</param> /// <param name="paymentRepo">Payment repository</param> public PurchaseController(CourseController courseCtrl, MyCourseController myCourseCtrl, IUserProfileRepository userProfileRepo, IClassRoomRepository classRoomRepo, IClassCalendarRepository classCalendarRepo, ILessonCatalogRepository lessonCatalogRepo, IUserActivityRepository userActivityRepo, IPaymentRepository paymentRepo, IOptions<AppConfigOptions> appConfig, IOptions<ErrorMessageOptions> errorMsgs, ILoggerFactory loggerFactory, IPayment payment, IDateTime dateTime) { _courseCtrl = courseCtrl; _myCourseCtrl = myCourseCtrl; _userprofileRepo = userProfileRepo; _classRoomRepo = classRoomRepo; _classCalendarRepo = classCalendarRepo; _lessonCatalogRepo = lessonCatalogRepo; _userActivityRepo = userActivityRepo; _paymentRepo = paymentRepo; _dateTime = dateTime; _appConfig = appConfig.Value; _errorMsgs = errorMsgs.Value; _logger = loggerFactory.CreateLogger<PurchaseController>(); _payment = payment; }
/// <summary> /// Initialize purchase controller /// </summary> /// <param name="courseCtrl">Course API</param> /// <param name="myCourseCtrl">MyCourse API</param> /// <param name="userProfileRepo">User profile repository</param> /// <param name="classRoomRepo">Class room repository</param> /// <param name="classCalendarRepo">Class calendar repository</param> /// <param name="lessonCatalogRepo">Lesson catalog repository</param> /// <param name="userActivityRepo">User activity repository</param> /// <param name="paymentRepo">Payment repository</param> public PurchaseController(CourseController courseCtrl, MyCourseController myCourseCtrl, IUserProfileRepository userProfileRepo, IClassRoomRepository classRoomRepo, IClassCalendarRepository classCalendarRepo, ILessonCatalogRepository lessonCatalogRepo, IUserActivityRepository userActivityRepo, IPaymentRepository paymentRepo, IOptions <AppConfigOptions> appConfig, IOptions <ErrorMessageOptions> errorMsgs, ILoggerFactory loggerFactory, IPayment payment, IDateTime dateTime) { _courseCtrl = courseCtrl; _myCourseCtrl = myCourseCtrl; _userprofileRepo = userProfileRepo; _classRoomRepo = classRoomRepo; _classCalendarRepo = classCalendarRepo; _lessonCatalogRepo = lessonCatalogRepo; _userActivityRepo = userActivityRepo; _paymentRepo = paymentRepo; _dateTime = dateTime; _appConfig = appConfig.Value; _errorMsgs = errorMsgs.Value; _logger = loggerFactory.CreateLogger <PurchaseController>(); _payment = payment; }
/// <summary> /// Initialize lesson controller /// </summary> /// <param name="classCalendarRepo">Class calendar repository</param> /// <param name="userprofileRepo">UserProfile repository</param> /// <param name="classRoomRepo">Class room repository</param> /// <param name="likeLessonRepo">Like lesson repository</param> /// <param name="lessonCatalogRepo">Lesson catalog repository</param> /// <param name="commentRepo">Comment repository</param> /// <param name="friendRequestRepo">Friend request repository</param> /// <param name="userActivityRepo">User activity repository</param> /// <param name="notificationCtrl">Notificaotion API</param> /// <param name="config">App configuration option</param> public LessonController(IClassCalendarRepository classCalendarRepo, IUserProfileRepository userprofileRepo, IClassRoomRepository classRoomRepo, ILikeLessonRepository likeLessonRepo, ILessonCatalogRepository lessonCatalogRepo, ICommentRepository commentRepo, IFriendRequestRepository friendRequestRepo, IUserActivityRepository userActivityRepo, NotificationController notificationCtrl, IOptions<AppConfigOptions> options, ILessonTestResultRepository lessonTestResultRepo, IDateTime dateTime) { _classCalendarRepo = classCalendarRepo; _userprofileRepo = userprofileRepo; _classRoomRepo = classRoomRepo; _likeLessonRepo = likeLessonRepo; _lessonCatalogRepo = lessonCatalogRepo; _commentRepo = commentRepo; _friendRequestRepo = friendRequestRepo; _userActivityRepo = userActivityRepo; _notificationCtrl = notificationCtrl; _appConfig = options.Value; _dateTime = dateTime; _lessonTestResultRepo = lessonTestResultRepo; }
public ExchangeRatesApiConnector(IHttpClientFactory httpClient, ILoggerFactory logger, IOptions <AppConfigOptions> appConfigOptions, IOptions <EndPointConnectorsOptions> endPointConnectorsOptions) : base(httpClient, logger.CreateLogger <ExchangeRatesApiConnector>(), endPointConnectorsOptions.Value.ExchangeRatesApiConnector) { _appConfigOptions = appConfigOptions.Value; }
/// <summary> /// Initialize database's connection /// </summary> /// <param name="appConfig">App configuration</param> public void Initialize(AppConfigOptions appConfig) { var connectionString = appConfig.PrimaryDBConnectionString; var dbName = appConfig.PrimaryDBName; _client = new MongoClient(connectionString); _database = _client.GetDatabase(dbName); }
public HomeController(CourseController courseCtrl, MyCourseController myCourseCtrl, IOptions <AppConfigOptions> options, IOptions <ErrorMessageOptions> errorMgs, ILoggerFactory loggerFactory, Engines.IEmailSender mindsageEmailSender) { _courseCtrl = courseCtrl; _myCourseCtrl = myCourseCtrl; _appConfig = options.Value; _errorMsgs = errorMgs.Value; _logger = loggerFactory.CreateLogger <CourseController>(); _mindsageEmailSender = mindsageEmailSender; }
public HomeController(CourseController courseCtrl, MyCourseController myCourseCtrl, IOptions<AppConfigOptions> options, IOptions<ErrorMessageOptions> errorMgs, ILoggerFactory loggerFactory, Engines.IEmailSender mindsageEmailSender) { _courseCtrl = courseCtrl; _myCourseCtrl = myCourseCtrl; _appConfig = options.Value; _errorMsgs = errorMgs.Value; _logger = loggerFactory.CreateLogger<CourseController>(); _mindsageEmailSender = mindsageEmailSender; }
public void LoadEmptyAppConfigOptions() { IConfiguration cfg = new ConfigurationBuilder().Build(); AppConfigOptions actualAppConfig = new(); cfg.Bind("AppConfig", actualAppConfig); var expectedAppConfig = new AppConfigOptions { Endpoint = "", IdentityClientId = "", UseFeatureFlags = false, RefreshInterval = TimeSpan.Zero, SentinelKey = "" }; actualAppConfig.Should().BeEquivalentTo(expectedAppConfig); }
public void LoadAppConfigOptions() { IConfiguration cfg = GetConfiguration(); AppConfigOptions actualAppConfig = new(); cfg.Bind("AppConfig", actualAppConfig); var expectedAppConfig = new AppConfigOptions { Endpoint = "https://example.azconfig.io", IdentityClientId = "Ipsum", UseFeatureFlags = true, RefreshInterval = TimeSpan.FromSeconds(75), SentinelKey = "Lorem" }; expectedAppConfig.Settings.AddRange(new[] { "Example1", "Example2" }); actualAppConfig.Should().BeEquivalentTo(expectedAppConfig); }
public void PrivacyReturnsView() { // arrange var appConfig = new AppConfigOptions { MapApiKey = "someKey" }; var optionsMock = Substitute.For <IOptionsSnapshot <AppConfigOptions> >(); optionsMock.Value.Returns(appConfig); var loggerMock = Substitute.For <ILogger <HomeController> >(); // act var controller = new HomeController(optionsMock, loggerMock); var result = controller.Privacy(); var viewResult = result as ViewResult; // assert Assert.IsNotNull(viewResult); }
public void ResultHasKey() { // arrange var appConfig = new AppConfigOptions { MapApiKey = "someKey" }; var optionsMock = Substitute.For <IOptionsSnapshot <AppConfigOptions> >(); optionsMock.Value.Returns(appConfig); var loggerMock = Substitute.For <ILogger <HomeController> >(); // act var controller = new HomeController(optionsMock, loggerMock); var result = controller.Index(); var viewResult = result as ViewResult; // assert Assert.IsNotNull(viewResult); Assert.AreEqual("someKey", viewResult.ViewData["key"]); }
/// <summary> /// Initialize Paypal payment /// </summary> public PaypalPayment(IOptions <AppConfigOptions> appConfig) { _appConfig = appConfig.Value; }
private static void Main(string[] args) { ProgramOptions options = new ProgramOptions(); // Parse command line options any errors and you get Usage if (options.ParseArgs(args) == false) ProgramOptions.Usage(); // We must have at least 1 path to process files, else Usage and exit if (options.PathList.Count < 1) ProgramOptions.Usage("You must specify at least one TVShowFolder."); List<String> validPaths = new List<string>(); foreach (string p in options.PathList) { Console.WriteLine("Processing: {0}", p); TVShowFolder f = new TVShowFolder(p); if (f.IsValid) { validPaths.Add(p); } else { Console.WriteLine("INGNORED! NOT A VALID PATH: {0}", p); } } // Read program options from the App.Config AppConfigOptions AppConfig = new AppConfigOptions(); // Setup new search object TVSearcher tvSearcher = new TVSearcher(AppConfig.ApiKey); foreach (string p in validPaths) { int TotalEpisodes = 0; int RenamedEpisodes = 0; int ErrorsEpisodes = 0; TVShowFolder myShow = new TVShowFolder(p); if (myShow.HasError()) { Console.WriteLine("Error parsing show name: {0}", myShow.ErrorMessage); continue; } Console.WriteLine("Looking for show: {0}", myShow.ShowName); string outputFile = String.Empty; if (String.IsNullOrEmpty(options.OutputPath)) { outputFile = Platform.IsWindows() ? Path.Combine(myShow.Location, ".rename.bat") : Path.Combine(myShow.Location, ".rename.sh"); } else { outputFile = Path.Combine(options.OutputPath, Path.ChangeExtension(myShow.ShowName, Platform.IsWindows() ? "bat" : "sh")); } TextWriter tw = new StreamWriter(outputFile); string showID; if (myShow.HasAssignedID) { showID = myShow.AssignedID; Console.WriteLine("Has Assigned ID: {0}", showID); } else { TVSeries tvSearch = new TVSeries(); tvSearch = tvSearcher.GetSeries(myShow.ShowName); if (tvSearch.IsSearchResult()) { foreach (DataSeries s in tvSearch.Shows) { Console.WriteLine("Located: {0} {1} {2}", s.id, s.FirstAired, s.SeriesName); } } if (tvSearch.Shows.Count > 1) { Console.WriteLine("Ambigious search for: {0}", myShow.ShowName); Console.WriteLine("Create a .thetvdb.id file wiht the show ID as the 1st line."); continue; } if (tvSearch.Shows.Count == 0) { Console.WriteLine("Unable to locate: {0}", myShow.ShowName); continue; } showID = tvSearch.Series.id; } Console.WriteLine("Located show Number: {0}", showID); TVSeries tvShow = new TVSeries(); tvShow = tvSearcher.GetShow(showID); if (!tvShow.HasEpisodes()) { Console.WriteLine("Unable to locate any episode data!"); continue; } DirectoryInfo dir = new DirectoryInfo(myShow.Location); foreach (FileInfo f in dir.GetFiles("*.*")) { // Ignore any . files if (f.Name.StartsWith(".")) continue; TotalEpisodes++; TVShowNameParser myNameParser = new TVShowNameParser(f.Name); if (myNameParser.Matched()) { DataEpisode thisShow = tvShow.GetEpisode(myNameParser.Season, myNameParser.Episode); tvShow.nameMaskS99E99 = AppConfig.namemasks99e99; tvShow.nameMask99x99 = AppConfig.namemask99x99; if (thisShow != null) { string newName = String.Empty; if (myNameParser.wasSENaming) { newName = tvShow.SEFileName(myNameParser.Season, myNameParser.Episode, Path.GetExtension(f.Name)); } if (myNameParser.wasXNaming) { newName = tvShow.XFileName(myNameParser.Season, myNameParser.Episode, Path.GetExtension(f.Name)); } if (myNameParser.wasSMNaming) { newName = tvShow.SMFileName(myNameParser.Season, myNameParser.Episode, Path.GetExtension(f.Name)); } if (options.ForceXNaming) { newName = tvShow.XFileName(myNameParser.Season, myNameParser.Episode, Path.GetExtension(f.Name)); } if (options.ForceENaming) { newName = tvShow.SEFileName(myNameParser.Season, myNameParser.Episode, Path.GetExtension(f.Name)); } if (newName != f.Name) { RenamedEpisodes++; string sourcePath; string destpath; if (options.UseRelativeNaming) { sourcePath = f.Name; destpath = newName; } else { sourcePath = Path.Combine(myShow.Location, f.Name); destpath = Path.Combine(myShow.Location, newName); } if (File.Exists(destpath)) { Console.WriteLine("WARNING! {0} already exists!"); } if (Platform.IsWindows()) { tw.WriteLine(@"ren ""{0}"" ""{1}"" ", sourcePath, destpath); } else { tw.WriteLine(@"mv ""{0}"" ""{1}"" ", sourcePath, destpath); } Console.WriteLine("RENAME: {0}", newName); } else { Console.WriteLine("GOOD: {0}", f.Name); } } else { ErrorsEpisodes++; Console.WriteLine("ERROR: {0} (Can't Locate)", f.Name); } } else { if (myNameParser.AmbigiousNaming) { ErrorsEpisodes++; Console.WriteLine("ERROR: {0} (AMBIGIOUS NAMING)", f.Name); } else { ErrorsEpisodes++; Console.WriteLine("ERROR: {0} (CAN'T MATCH)", f.Name); } } } Console.WriteLine(""); Console.WriteLine("Total Episodes : {0}", TotalEpisodes); Console.WriteLine("Renamed Episodes: {0}", RenamedEpisodes); Console.WriteLine("Episode Errors : {0}", ErrorsEpisodes); if (RenamedEpisodes > 0) { Console.WriteLine(""); Console.WriteLine("Created {0} for renaming.", outputFile); Console.WriteLine("Please inspect and execute CAREFULLY!"); Console.WriteLine(""); } tw.Close(); // If we didn't rename anything, remove the empty outputFile if (RenamedEpisodes == 0) { File.Delete(outputFile); } } Misc.PauseIfInIDE(); }
private static void Main(string[] args) { ProgramOptions options = new ProgramOptions(); // Parse command line options any errors and you get Usage if (options.ParseArgs(args) == false) { ProgramOptions.Usage(); } // We must have at least 1 path to process files, else Usage and exit if (options.PathList.Count < 1) { ProgramOptions.Usage("You must specify at least one TVShowFolder."); } List <String> validPaths = new List <string>(); foreach (string p in options.PathList) { Console.WriteLine("Processing: {0}", p); TVShowFolder f = new TVShowFolder(p); if (f.IsValid) { validPaths.Add(p); } else { Console.WriteLine("INGNORED! NOT A VALID PATH: {0}", p); } } // Read program options from the App.Config AppConfigOptions AppConfig = new AppConfigOptions(); // Setup new search object TVSearcher tvSearcher = new TVSearcher(AppConfig.ApiKey); // Search each path foreach (string p in validPaths) { TVShowFolder myShow = new TVShowFolder(p); Console.WriteLine("Looking for show: {0}", myShow.ShowName); string showID; if (myShow.HasAssignedID) { showID = myShow.AssignedID; Console.WriteLine("Has Assigned ID: {0}", showID); } else { TVSeries tvSearch = tvSearcher.GetSeries(myShow.ShowName); if (tvSearch.IsSearchResult()) { foreach (DataSeries s in tvSearch.Shows) { Console.WriteLine("Located: {0} {1} {2}", s.id, s.FirstAired, s.SeriesName); } } if (tvSearch.Shows.Count > 1) { Console.WriteLine("Ambigious search for: {0}", myShow.ShowName); Console.WriteLine("Create a .thetvdb.id file with the show ID as the 1st line."); continue; } if (tvSearch.Shows.Count == 0) { Console.WriteLine("Unable to locate: {0}", myShow.ShowName); continue; } showID = tvSearch.Series.id; } TVSeries tvShow = tvSearcher.GetShow(showID); if (!tvShow.HasEpisodes()) { Console.WriteLine("Unable to locate any episode data!"); continue; } if (tvShow.Series.Status == "Ended") { Console.WriteLine("No more episodes :-( The show has ended!"); continue; } // Load up a list of the existing files in this folder TVFiles myTVFiles = new TVFiles(p); bool foundNewEpisode = false; foreach (DataEpisode de in tvShow.Episodes) { DateTime date; try { date = DateTime.ParseExact(de.FirstAired, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture); } catch { // Probably a blank date so it is in the future. continue; } if (date >= DateTime.Now) { foundNewEpisode = true; Console.WriteLine("NEXT AIR: {0}\t{1}\t{2}\t{3}x{4}\t{5}", de.FirstAired, tvShow.Series.id, tvShow.Series.SeriesName, de.SeasonNumber, de.EpisodeNumber, de.EpisodeName); break; } if (!myTVFiles.Exist(Convert.ToInt32(de.SeasonNumber), Convert.ToInt32(de.EpisodeNumber))) { Console.WriteLine("MISSING! {0}\t{1}\t{2}\t{3}x{4}\t{5}", de.FirstAired, tvShow.Series.id, tvShow.Series.SeriesName, de.SeasonNumber, de.EpisodeNumber, de.EpisodeName); } } if (!foundNewEpisode) { Console.WriteLine("Unable to locate a new episode."); } } Misc.PauseIfInIDE(); }
private static void Main(string[] args) { ProgramOptions options = new ProgramOptions(); // Parse command line options any errors and you get Usage if (options.ParseArgs(args) == false) ProgramOptions.Usage(); // We must have at least 1 path to process files, else Usage and exit if (options.PathList.Count < 1) ProgramOptions.Usage("You must specify at least one TVShowFolder."); List<String> validPaths = new List<string>(); foreach (string p in options.PathList) { Console.WriteLine("Processing: {0}", p); TVShowFolder f = new TVShowFolder(p); if (f.IsValid) { validPaths.Add(p); } else { Console.WriteLine("INGNORED! NOT A VALID PATH: {0}", p); } } // Read program options from the App.Config AppConfigOptions AppConfig = new AppConfigOptions(); // Setup new search object TVSearcher tvSearcher = new TVSearcher(AppConfig.ApiKey); // Search each path foreach (string p in validPaths) { TVShowFolder myShow = new TVShowFolder(p); Console.WriteLine("Looking for show: {0}", myShow.ShowName); string showID; if (myShow.HasAssignedID) { showID = myShow.AssignedID; Console.WriteLine("Has Assigned ID: {0}", showID); } else { TVSeries tvSearch = tvSearcher.GetSeries(myShow.ShowName); if (tvSearch.IsSearchResult()) { foreach (DataSeries s in tvSearch.Shows) { Console.WriteLine("Located: {0} {1} {2}", s.id, s.FirstAired, s.SeriesName); } } if (tvSearch.Shows.Count > 1) { Console.WriteLine("Ambigious search for: {0}", myShow.ShowName); Console.WriteLine("Create a .thetvdb.id file with the show ID as the 1st line."); continue; } if (tvSearch.Shows.Count == 0) { Console.WriteLine("Unable to locate: {0}", myShow.ShowName); continue; } showID = tvSearch.Series.id; } TVSeries tvShow = tvSearcher.GetShow(showID); if (!tvShow.HasEpisodes()) { Console.WriteLine("Unable to locate any episode data!"); continue; } if (tvShow.Series.Status == "Ended") { Console.WriteLine("No more episodes :-( The show has ended!"); continue; } // Load up a list of the existing files in this folder TVFiles myTVFiles = new TVFiles(p); bool foundNewEpisode = false; foreach (DataEpisode de in tvShow.Episodes) { DateTime date; try { date = DateTime.ParseExact(de.FirstAired, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture); } catch { // Probably a blank date so it is in the future. continue; } if (date >= DateTime.Now) { foundNewEpisode = true; Console.WriteLine("NEXT AIR: {0}\t{1}\t{2}\t{3}x{4}\t{5}", de.FirstAired, tvShow.Series.id, tvShow.Series.SeriesName, de.SeasonNumber, de.EpisodeNumber, de.EpisodeName); break; } if (!myTVFiles.Exist(Convert.ToInt32(de.SeasonNumber), Convert.ToInt32(de.EpisodeNumber))) { Console.WriteLine("MISSING! {0}\t{1}\t{2}\t{3}x{4}\t{5}", de.FirstAired, tvShow.Series.id, tvShow.Series.SeriesName, de.SeasonNumber, de.EpisodeNumber, de.EpisodeName); } } if (!foundNewEpisode) { Console.WriteLine("Unable to locate a new episode."); } } Misc.PauseIfInIDE(); }
private static void Main(string[] args) { ProgramOptions options = new ProgramOptions(); // Parse command line options any errors and you get Usage if (options.ParseArgs(args) == false) { ProgramOptions.Usage(); } // We must have at least 1 path to process files, else Usage and exit if (options.PathList.Count < 1) { ProgramOptions.Usage("You must specify at least one TVShowFolder."); } List <String> validPaths = new List <string>(); foreach (string p in options.PathList) { Console.WriteLine("Processing: {0}", p); TVShowFolder f = new TVShowFolder(p); if (f.IsValid) { validPaths.Add(p); } else { Console.WriteLine("INGNORED! NOT A VALID PATH: {0}", p); } } // Read program options from the App.Config AppConfigOptions AppConfig = new AppConfigOptions(); // Setup new search object TVSearcher tvSearcher = new TVSearcher(AppConfig.ApiKey); foreach (string p in validPaths) { int TotalEpisodes = 0; int RenamedEpisodes = 0; int ErrorsEpisodes = 0; TVShowFolder myShow = new TVShowFolder(p); if (myShow.HasError()) { Console.WriteLine("Error parsing show name: {0}", myShow.ErrorMessage); continue; } Console.WriteLine("Looking for show: {0}", myShow.ShowName); string outputFile = String.Empty; if (String.IsNullOrEmpty(options.OutputPath)) { outputFile = Platform.IsWindows() ? Path.Combine(myShow.Location, ".rename.bat") : Path.Combine(myShow.Location, ".rename.sh"); } else { outputFile = Path.Combine(options.OutputPath, Path.ChangeExtension(myShow.ShowName, Platform.IsWindows() ? "bat" : "sh")); } TextWriter tw = new StreamWriter(outputFile); string showID; if (myShow.HasAssignedID) { showID = myShow.AssignedID; Console.WriteLine("Has Assigned ID: {0}", showID); } else { TVSeries tvSearch = new TVSeries(); tvSearch = tvSearcher.GetSeries(myShow.ShowName); if (tvSearch.IsSearchResult()) { foreach (DataSeries s in tvSearch.Shows) { Console.WriteLine("Located: {0} {1} {2}", s.id, s.FirstAired, s.SeriesName); } } if (tvSearch.Shows.Count > 1) { Console.WriteLine("Ambigious search for: {0}", myShow.ShowName); Console.WriteLine("Create a .thetvdb.id file wiht the show ID as the 1st line."); continue; } if (tvSearch.Shows.Count == 0) { Console.WriteLine("Unable to locate: {0}", myShow.ShowName); continue; } showID = tvSearch.Series.id; } Console.WriteLine("Located show Number: {0}", showID); TVSeries tvShow = new TVSeries(); tvShow = tvSearcher.GetShow(showID); if (!tvShow.HasEpisodes()) { Console.WriteLine("Unable to locate any episode data!"); continue; } DirectoryInfo dir = new DirectoryInfo(myShow.Location); foreach (FileInfo f in dir.GetFiles("*.*")) { // Ignore any . files if (f.Name.StartsWith(".")) { continue; } TotalEpisodes++; TVShowNameParser myNameParser = new TVShowNameParser(f.Name); if (myNameParser.Matched()) { DataEpisode thisShow = tvShow.GetEpisode(myNameParser.Season, myNameParser.Episode); tvShow.nameMaskS99E99 = AppConfig.namemasks99e99; tvShow.nameMask99x99 = AppConfig.namemask99x99; if (thisShow != null) { string newName = String.Empty; if (myNameParser.wasSENaming) { newName = tvShow.SEFileName(myNameParser.Season, myNameParser.Episode, Path.GetExtension(f.Name)); } if (myNameParser.wasXNaming) { newName = tvShow.XFileName(myNameParser.Season, myNameParser.Episode, Path.GetExtension(f.Name)); } if (myNameParser.wasSMNaming) { newName = tvShow.SMFileName(myNameParser.Season, myNameParser.Episode, Path.GetExtension(f.Name)); } if (options.ForceXNaming) { newName = tvShow.XFileName(myNameParser.Season, myNameParser.Episode, Path.GetExtension(f.Name)); } if (options.ForceENaming) { newName = tvShow.SEFileName(myNameParser.Season, myNameParser.Episode, Path.GetExtension(f.Name)); } if (newName != f.Name) { RenamedEpisodes++; string sourcePath; string destpath; if (options.UseRelativeNaming) { sourcePath = f.Name; destpath = newName; } else { sourcePath = Path.Combine(myShow.Location, f.Name); destpath = Path.Combine(myShow.Location, newName); } if (File.Exists(destpath)) { Console.WriteLine("WARNING! {0} already exists!"); } if (Platform.IsWindows()) { tw.WriteLine(@"ren ""{0}"" ""{1}"" ", sourcePath, destpath); } else { tw.WriteLine(@"mv ""{0}"" ""{1}"" ", sourcePath, destpath); } Console.WriteLine("RENAME: {0}", newName); } else { Console.WriteLine("GOOD: {0}", f.Name); } } else { ErrorsEpisodes++; Console.WriteLine("ERROR: {0} (Can't Locate)", f.Name); } } else { if (myNameParser.AmbigiousNaming) { ErrorsEpisodes++; Console.WriteLine("ERROR: {0} (AMBIGIOUS NAMING)", f.Name); } else { ErrorsEpisodes++; Console.WriteLine("ERROR: {0} (CAN'T MATCH)", f.Name); } } } Console.WriteLine(""); Console.WriteLine("Total Episodes : {0}", TotalEpisodes); Console.WriteLine("Renamed Episodes: {0}", RenamedEpisodes); Console.WriteLine("Episode Errors : {0}", ErrorsEpisodes); if (RenamedEpisodes > 0) { Console.WriteLine(""); Console.WriteLine("Created {0} for renaming.", outputFile); Console.WriteLine("Please inspect and execute CAREFULLY!"); Console.WriteLine(""); } tw.Close(); // If we didn't rename anything, remove the empty outputFile if (RenamedEpisodes == 0) { File.Delete(outputFile); } } Misc.PauseIfInIDE(); }
/// <summary> /// Initialize Paypal payment /// </summary> public PaypalPayment(IOptions<AppConfigOptions> appConfig) { _appConfig = appConfig.Value; }
/// <summary> /// Initialize /// </summary> /// <param name="appConfig">App configruation</param> public SendGridEmailSender(IOptions <AppConfigOptions> appConfig) { _appConfig = appConfig.Value; }
/// <summary> /// Initialize course controller /// </summary> /// <param name="courseCatalogRepo">Course catalog repository</param> /// <param name="config">App configuration option</param> public CourseController(ICourseCatalogRepository courseCatalogRepo, IOptions<AppConfigOptions> options) { _repo = courseCatalogRepo; _appConfig = options.Value; }
/// <summary> /// Initialize course controller /// </summary> /// <param name="courseCatalogRepo">Course catalog repository</param> /// <param name="config">App configuration option</param> public CourseController(ICourseCatalogRepository courseCatalogRepo, IOptions <AppConfigOptions> options) { _repo = courseCatalogRepo; _appConfig = options.Value; }
/// <summary> /// Initialize /// </summary> /// <param name="appConfig">App configruation</param> public SendGridEmailSender(IOptions<AppConfigOptions> appConfig) { _appConfig = appConfig.Value; }