Esempio n. 1
0
 public void Client()
 {
     Race race = new Race(new[] {"asdfasdf"}) {TotalFilesExpected = 5};
     Output output = new Output(race);
     Assert.AreEqual("=[   0/5   ]=", output.Format("=[   0/{5,-3:B3} ]="));
     Assert.AreEqual("=[   0/asd ]=", output.Format("=[   0/asd ]="));
     RaceStats raceStats = new RaceStats();
     const ulong bytes = 123456789;
     raceStats
         .AddFileName("a.txt")
         .AddCrc32("aabbccdd")
         .AddFileUploaded(true)
         .AddFileSpeed(100)
         .AddFileSize(bytes)
         .AddUserName("user1")
         .AddGroupName("group1");
     race.AddRaceStats(raceStats);
     Assert.AreEqual("]-[Complete 123456789MB - 1/5F]-[", output.Format("]-[Complete {7}MB - {6}/{5}F]-["));
     Assert.AreEqual("]-[Complete 117MB - 1/5F]-[", output.Format("]-[Complete {8}MB - {6}/{5}F]-["));
     Assert.AreEqual("|  1.           user1/group1           117MB   100kBit/s   1F |",
                     output.FormatUserStats(1,
                                            race.GetUserStats() [0],
                                            "| {0,2:B2}. {2,15:B15}/{3,-15:B15} {8,6:B6} {6,5:B5}kBit/s {7,3:B3}F |"));
     Assert.AreEqual("|  1. group1           117MB   100kBit/s   1F |",
                     output.FormatGroupStats(1,
                                             race.GetGroupStats() [0],
                                             "| {0,2:B2}. {3,-15:B15} {7,6:B6} {5,5:B5}kBit/s {6,3:B3}F |"));
     Assert.AreEqual("###--------------", output.Format("{14}"), "ProgressBar");
     Assert.AreEqual("117MB", bytes.FormatSize(), "FormatBytesUploaded");
 }
Esempio n. 2
0
 public void GetImdbResponseForEventId()
 {
     Dictionary<string, object> imdbResponseForEventId = Extensions.GetImdbResponseForEventId("tt0088247");
     string formatImdb = new Output(new Race(new[] { "upload" })).FormatImdb(Config.LogLineIoFtpdUpdateImdb, imdbResponseForEventId);
     const string expectedValue = "IMDBJEZA: \"\" \"\" \"\" \"\" \"The Terminator\" \"1984\" \"R\" \"26 Oct 1984\" \"Action, Sci-Fi\" \"James Cameron\" \"James Cameron, Gale Anne Hurd\" \"Arnold Schwarzenegger, Linda Hamilton, Michael Biehn, Paul Winfield\" \"A cyborg is sent back in time by the sinister computer network Skynet to murder a woman who will one day give birth to the leader of the militia destined to end the coming robo-apocalypse.\" \"http://ia.media-imdb.com/images/M/MV5BODE1MDczNTUxOV5BMl5BanBnXkFtZTcwMTA0NDQyNA@@._V1_SX300.jpg\" \"1 h 47 min\" \"\" \"\" \"\"";
     Assert.AreEqual(expectedValue, formatImdb, "Maybe imdb response was changed???");
 }
Esempio n. 3
0
 public void Process()
 {
     TagManager tagManager = new TagManager(race);
     CreateZipRaceDataFile();
     Output output = new Output(race);
     //output
     //    .Client(Config.ClientHead)
     //    .Client(Config.ClientFileName)
     //    .Client(Config.ClientFoot);
     tagManager.CreateTag(currentRaceData.DirectoryPath, output.Format(Config.TagIncomplete, null));
     tagManager.CreateSymLink(currentRaceData.DirectoryParent, output.Format(Config.TagIncompleteLink, null));
 }
Esempio n. 4
0
 public void Format()
 {
     Race race = new Race(new[] {"upload", @"..\..\TestFiles\Mp3\06-judas_priest-beyond_the_realms_of_death.mp3", "00000000", @"../../TestFiles/Mp3/06-judas_priest-beyond_the_realms_of_death.mp3"});
     race.ParseUpload();
     const int totalFilesExpected = 123;
     race.TotalFilesExpected = totalFilesExpected;
     bool isAudioRace = race.IsAudioRace;
     Assert.IsTrue(isAudioRace);
     Output output = new Output(race);
     File file = File.Create(@"..\..\TestFiles\Mp3\06-judas_priest-beyond_the_realms_of_death.mp3");
     Assert.AreEqual("06-judas_priest-beyond_the_realms_of_death.mp3", output.Format("{0}", file), "FileName");
     Assert.AreEqual("Mp3", output.Format("{1}", file), "DirectoryName");
     Assert.AreEqual("NoUser", output.Format("{2}", file), "UserName");
     Assert.AreEqual("NoGroup", output.Format("{3}", file), "GroupName");
     Assert.AreEqual("/NoPath", output.Format("{4}", file), "UploadVirtualPath");
     Assert.AreEqual(totalFilesExpected.ToString(), output.Format("{5}", file), "TotalFilesExpected");
     Assert.AreEqual("0", output.Format("{6}", file), "TotalFilesUploaded");
     Assert.AreEqual("0", output.Format("{7}", file), "TotalBytesUploaded");
     Assert.AreEqual("0", output.Format("{8}", file), "TotalMegaBytesUploaded");
     Assert.AreEqual("0B", output.Format("{9}", file), "TotalBytesUploadedFormated");
     Assert.AreEqual("0B", output.Format("{10}", file), "TotalBytesExpected");
     Assert.AreEqual("1", output.Format("{11}", file), "TotalAvarageSpeed");
     Assert.AreEqual("0", output.Format("{12}", file), "TotalUsersRacing");
     Assert.AreEqual("0", output.Format("{13}", file), "TotalGroupsRacing");
     Assert.AreEqual("-----------------", output.Format("{14}", file), "ProgressBar");
     Assert.AreEqual("0%", output.Format("{15}%", file), "PercentComplete");
     Assert.AreEqual(Constants.CodeIrcColor, output.Format("{16}", file), "CodeIrcColor");
     Assert.AreEqual(Constants.CodeIrcBold, output.Format("{17}", file), "CodeIrcBold");
     Assert.AreEqual(Constants.CodeIrcUnderline, output.Format("{18}", file), "CodeIrcUnderline");
     Assert.AreEqual(Constants.CodeNewLine, output.Format("{19}", file), "codeNewLine");
     Assert.AreEqual("Judas Priest", output.Format("{20}", file), "FirstPerformer");
     Assert.AreEqual("A Touch of Evil Live", output.Format("{21}", file), "Album");
     Assert.AreEqual("Beyond the Realms of Death", output.Format("{22}", file), "Title");
     Assert.AreEqual("Heavy Metal", output.Format("{23}", file), "FirstGenre");
     Assert.AreEqual("2009", output.Format("{24}", file), "Year");
     Assert.AreEqual("6", output.Format("{25}", file), "Track");
     Assert.AreEqual("1", output.Format("{26}", file), "Speed");
     Assert.AreEqual("231", output.Format("{27}", file), "AudioBitrate");
     Assert.AreEqual("2", output.Format("{28}", file), "AudioChannels");
     Assert.AreEqual("44100", output.Format("{29}", file), "AudioSampleRate");
     Assert.AreEqual("0", output.Format("{30}", file), "BitsPerSample");
     Assert.AreEqual("MPEG Version 1 Audio, Layer 3 VBR", output.Format("{31}", file), "Description");
     Assert.AreEqual("Audio", output.Format("{32}", file), "MediaTypes");
     Assert.AreEqual("MPEG Version 1 Audio, Layer 3 VBR", output.Format("{33}", file), "Codecs");
     Assert.AreEqual("00:06:51", output.Format("{34}", file), "Duration");
 }
Esempio n. 5
0
 public void Process()
 {
     Log.Debug("DataParser.Process()");
     if (GetCrc32ForFile(race.CurrentRaceData.FileName) != null)
     {
         race.LeadUser = race.GetLeadUser();
         race.LeadGroup = race.GetLeadGroup();
         Extensions.UpdateRaceData(race);
         Parse();
         Extensions.ProcessRaceData(race);
     }
     else
     {
         Log.Debug("CRC not found!");
         Output output = new Output(race);
         output
             .Client(Config.ClientHead)
             .Client(Config.ClientFileNameBadCrc)
             .Client(Config.ClientFoot);
         race.IsValid = false;
     }
 }
Esempio n. 6
0
        public void Process()
        {
            Output output = new Output(race);
            output
                .Client(Config.ClientHead)
                .Client(Config.ClientFileName)
                .Client(Config.ClientFoot);

            if (String.IsNullOrEmpty(imdbUrl))
            {
                return;
            }
            Log.Debug("Process IMDB info");
            race.CurrentRaceData.LinkImdb = imdbUrl;
            if (Config.LogToIoFtpdUpdateNfo)
            {
                Log.IoFtpd(output.Format(Config.LogLineIoFtpdUpdateNfo));
            }
            if (Config.LogToInternalUpdateNfo)
            {
                Log.Internal(output.Format(Config.LogLineInternalUpdateNfo));
            }
            string imdbId = Extensions.GetImdbId(imdbUrl);
            if (String.IsNullOrEmpty(imdbId))
            {
                return;
            }
            Dictionary<string, object> imdbResponse = Extensions.GetImdbResponseForEventId(imdbId);
            if (Config.LogToIoFtpdUpdateImdb)
            {
                Log.IoFtpd(output.FormatImdb(Config.LogLineIoFtpdUpdateImdb, imdbResponse));
            }
            if (Config.LogToInternalUpdateImdb)
            {
                Log.Internal(output.FormatImdb(Config.LogLineInternalUpdateImdb, imdbResponse));
            }
        }
Esempio n. 7
0
 /// <summary>
 /// Prints output to the client.
 /// </summary>
 /// <param name="skip">if set to <c>true</c> use skip file template.</param>
 private void OutputFileName(bool skip)
 {
     Output output = new Output(this);
     string filename = skip ? Config.ClientFileNameSkip : Config.ClientFileName;
     output
         .Client(Config.ClientHead)
         .Client(filename)
         .Client(Config.ClientFoot);
 }
Esempio n. 8
0
 public void Process()
 {
     if (dataParserSfv != null)
     {
         if (dataParserSfv.SfvData != null)
         {
             if (dataParserSfv.SfvData.Count > 0)
             {
                 Output outputHead = new Output(new Race(null));
                 outputHead.Client(Config.ClientCrc32Head);
                 rescanStats.TotalFiles = dataParserSfv.SfvData.Count;
                 foreach (KeyValuePair<string, string> keyValuePair in dataParserSfv.SfvData)
                 {
                     if (!rescanFolder && !(keyValuePair.Key.ToLowerInvariant().Equals(args [1].ToLowerInvariant())))
                     {
                         continue;
                     }
                     RescanStatsData rescanStatsData = new RescanStatsData
                                                       {
                                                           FileName = keyValuePair.Key,
                                                           ExpectedCrc32Value = keyValuePair.Value,
                                                           ReleaseName = directoryInfo.Name,
                                                       };
                     string fileName = Misc.PathCombine(SourceFolder, keyValuePair.Key);
                     FileInfo fileInfo = new FileInfo();
                     if (File.Exists(fileName))
                     {
                         uint crc32 = Crc32.GetFileCrc32(fileName);
                         string actualCrc32Value = String.Format(CultureInfo.InvariantCulture, "{0:X8}", crc32);
                         rescanStatsData.ActualCrc32Value = actualCrc32Value;
                         if (actualCrc32Value.ToLower().Equals(keyValuePair.Value.ToLower()))
                         {
                             rescanStats.OkFiles++;
                             rescanStats.TotalBytesUploaded += fileInfo.GetFileSize(fileName);
                             rescanStatsData.Status = "OK";
                             fileInfo.DeleteFile(SourceFolder, fileName + Config.FileExtensionMissing);
                         }
                         else
                         {
                             rescanStats.FailedFiles++;
                             rescanStatsData.Status = "FAILED";
                             if (Config.DeleteCrc32FailedFiles)
                             {
                                 fileInfo.DeleteFile(SourceFolder, keyValuePair.Key);
                             }
                             else
                             {
                                 FileInfo.Create0ByteFile(fileName + Config.FileExtensionCrc32Failed);
                             }
                         }
                     }
                     else
                     {
                         rescanStats.MissingFiles++;
                         rescanStatsData.ActualCrc32Value = "00000000";
                         rescanStatsData.Status = "MISSING";
                         FileInfo.Create0ByteFile(fileName + Config.FileExtensionMissing);
                     }
                     rescanStats.RescanStatsData.Add(rescanStatsData);
                     Output output = new Output(rescanStatsData, rescanStats);
                     output.ClientRescan(Config.ClientCrc32Body);
                 }
                 Output outputFoot = new Output(rescanStats);
                 outputFoot.ClientRescan(Config.ClientCrc32Foot);
                 new FileInfo().DeleteFoldersThatStartsWith(SourceFolder, Config.TagCleanUpStringCrc32);
                 new FileInfo().DeleteFilesThatStartsWith(SourceFolder, Config.TagCleanUpStringCrc32);
                 if (Config.TagAsFolderCrc32)
                 {
                     FileInfo.CreateFolder(Misc.PathCombine(SourceFolder,
                                                               outputFoot.FormatCrc32(rescanStats.TotalFiles == rescanStats.OkFiles
                                                                                          ? Config.TagCompleteCrc32
                                                                                          : Config.TagIncompleteCrc32)));
                 }
                 else
                 {
                     FileInfo.Create0ByteFile(Misc.PathCombine(SourceFolder,
                                                               outputFoot.FormatCrc32(rescanStats.TotalFiles == rescanStats.OkFiles
                                                                                          ? Config.TagCompleteCrc32
                                                                                          : Config.TagIncompleteCrc32)));
                 }
             }
         }
     }
 }
Esempio n. 9
0
 public void Process()
 {
     Output output = new Output();
     switch (target)
     {
         case Trial.TargetTrial.Add:
         {
             int userId = UserManager.UsernameToUid(args[2]);
             if (userId < 0)
             {
                 output.Client(String.Format(Config.ClientTrialUserNotFound, args[2]));
                 return;
             }
             TrialQuota.Trial trial = new TrialQuota.Trial
                                      {
                                          Uid = userId,
                                          DateAdded = new DateTime(DateTime.UtcNow.Ticks),
                                          Period = Config.TrialDefaultTime,
                                          QuotaToPass = Config.TrialDefaultQuota,
                                          StartAllUp = UserManager.GetStats(userId, UploadStats.AllUp),
                                      };
             bool exists = trials.Exists(t => t.Uid == userId);
             if (!exists)
             {
                 trials.Add(trial);
                 SaveTrials();
                 output.Client(String.Format(Config.ClientTrialUserAdd, args[2]));
             }
             else
             {
                 output.Client(String.Format(Config.ClientTrialUserExists, args[2]));
             }
             ShowTrials();
             break;
         }
         case Trial.TargetTrial.Remove:
         {
             int userId = UserManager.UsernameToUid(args [2]);
             if (userId < 0)
             {
                 output.Client(String.Format(Config.ClientTrialUserNotFound, args[2]));
                 return;
             }
             bool removed = trials.Remove(new TrialQuota.Trial {Uid = userId});
             if (removed)
             {
                 output.Client(String.Format(Config.ClientTrialUserRemove, args[2]));
                 SaveTrials();
             }
             else
             {
                 output.Client(String.Format(Config.ClientTrialUserRemoveFail, args[2]));
             }
             ShowTrials();
             break;
         }
         default:
         {
             ShowTrials();
             break;
         }
     }
 }
Esempio n. 10
0
 private void ShowTrials()
 {
     Output output = new Output();
     output.Client(output.FormatNone(Config.ClientTrialListHead));
     foreach (TrialQuota.Trial trial in trials)
     {
         output.Client(output.FormatTrial(Config.ClientTrialListBody, trial));
     }
     output.Client(output.FormatNone(Config.ClientTrialListFoot));
     //DateTime dateTime = new DateTime(DateTime.UtcNow.Ticks);
 }
Esempio n. 11
0
 private void OutputWeeklyTaskList()
 {
     var output = new Output();
     foreach (WeeklyTask weeklyTask in taskConfiguration.WeeklyTasks)
     {
         output.Client(output.FormatWeeklyTask(Config.ClientWeeklyList, weeklyTask));
     }
 }
Esempio n. 12
0
 private void OutputRequestList()
 {
     var sb = new StringBuilder();
     var output = new Output();
     string head = output.FormatNone(Config.ClientRequestHead);
     output.Client(head);
     sb.AppendLine(head);
     if (taskConfiguration.RequestTasks != null)
     {
         foreach (RequestTask requestTask in taskConfiguration.RequestTasks)
         {
             string body = output.FormatRequestTask(Config.ClientRequestBody, requestTask);
             output.Client(body);
             sb.AppendLine(body);
         }
     }
     string foot = output.FormatNone(Config.ClientRequestFoot);
     output.Client(foot);
     sb.AppendLine(foot);
     WriteToMesasageFile(sb.ToString());
 }
Esempio n. 13
0
 private static void WriteToFile(string fileName,
     string line,
     object[] args)
 {
     try
     {
         if (string.IsNullOrEmpty(fileName))
         {
             return;
         }
         System.IO.FileInfo fileInfo = new System.IO.FileInfo(fileName);
         LogMutex.WaitOne();
         using (FileStream stream = new FileStream(fileInfo.FullName,
                                                   FileMode.Append,
                                                   FileAccess.Write,
                                                   FileShare.None))
         {
             using (StreamWriter streamWriter = new StreamWriter(stream))
             {
                 DateTime dt = new DateTime(DateTime.Now.Ticks);
                 line = dt.ToString("[yyyy-MM-dd HH:mm:ss] ") + line;
                 if (args != null)
                 {
                     streamWriter.WriteLine(line, args);
                     if(Config.LogToConsole)
                     {
                         Console.WriteLine(line, args);
                     }
                 }
                 else
                 {
                     streamWriter.WriteLine(line);
                     if (Config.LogToConsole)
                     {
                         Console.WriteLine(line);
                     }
                 }
             }
         }
         LogMutex.ReleaseMutex();
     }
     catch (Exception exception)
     {
         Output output = new Output();
         output.Client(fileName);
         output.Client(args != null ? String.Format(line, args) : line);
         output.Client(exception.ToString());
     }
 }
Esempio n. 14
0
 private void ExecuteDupeRemoveTask()
 {
     string releaseName = args [1].Trim();
     int rows = DataBase.ExecuteNonQuery(String.Format("DELETE FROM Folders WHERE ReleaseName = '{0}'", releaseName));
     var output = new Output();
     output.Client(rows > 0
                       ? String.Format(Config.ClientDupeRemove, releaseName)
                       : String.Format(Config.ClientDupeRemoveNotFound, releaseName));
 }
Esempio n. 15
0
 public bool SpeedTest()
 {
     IsValid = true;
     if (CurrentRaceData != null)
     {
         string virtualPath = CurrentRaceData.UploadVirtualPath;
         if (virtualPath.StartsWith(Config.SpeedTestFolder, StringComparison.InvariantCultureIgnoreCase))
         {
             Log.Debug("SpeedTest path match. ['{0}' => '{1}']", Config.SpeedTestFolder, virtualPath);
             if (Config.DeleteSpeedTest)
             {
                 IsValid = false;
             }
             Output output = new Output(this);
             output.LogSpeedTest();
             return true;
         }
     }
     return false;
 }
Esempio n. 16
0
 private void ExecuteDupeListTask()
 {
     string releaseName = args [1].Trim();
     List<DataBaseDupe> dupes = DataBase.SelectFromDupeAll(String.Format("SELECT * FROM Folders WHERE ReleaseName like '%{0}%'", releaseName));
     var output = new Output();
     output.Client(output.FormatNone(Config.ClientDupeListHead));
     if (dupes != null)
     {
         foreach (DataBaseDupe dataBaseDupe in dupes)
         {
             output.Client(output.FormatDupe(Config.ClientDupeListBody, dataBaseDupe));
         }
     }
     output.Client(output.FormatNone(Config.ClientDupeListFoot));
 }
Esempio n. 17
0
 /// <summary>
 /// Executes the archive task (Move or Delete).
 /// </summary>
 /// <param name="archiveTask">The archive task.</param>
 /// <param name="directoryInfo">Source directory.</param>
 private static void ExecuteArchiveTask(ArchiveTask archiveTask,
     DirectoryInfo directoryInfo)
 {
     Log.Debug("ExecuteArchiveTask '{0}' on '{1}'!", archiveTask.Action.Id, directoryInfo.FullName);
     switch (archiveTask.ArchiveType)
     {
         case ArchiveType.Copy:
         {
             CopySourceFolders(archiveTask, directoryInfo);
             UpdateDupeDb(archiveTask, directoryInfo);
             break;
         }
         case ArchiveType.Move:
         {
             CopySourceFolders(archiveTask, directoryInfo);
             UpdateDupeDb(archiveTask, directoryInfo);
             if (!sameRoot)
             {
                 DeleteFolder(directoryInfo, true);
             }
             break;
         }
         case ArchiveType.Delete:
         {
             DeleteFolder(directoryInfo, true);
             break;
         }
         default:
         {
             throw new NotSupportedException();
         }
     }
     if (!String.IsNullOrEmpty(archiveTask.LogFormat))
     {
         var output = new Output(archiveTask);
         string formatArchive = output.FormatArchive(archiveTask.LogFormat, directoryInfo);
         Log.IoFtpd(formatArchive);
         Log.Internal(formatArchive);
     }
 }
Esempio n. 18
0
 private void OutputSfvFirst(string fileInfo,
     string fileReason)
 {
     Output output = new Output(this);
     output
         .Client(Config.ClientHead)
         .Client(fileInfo)
         .Client(fileReason)
         .Client(Config.ClientFoot);
 }
Esempio n. 19
0
 public void Race()
 {
     CleanTestFilesOutput();
     UploadSfvFileMp3();
     Race race = new Race(ArgsMp3File1);
     race.ParseUpload();
     race.Process();
     Output output = new Output(race);
     FileInfo fileInfo = new FileInfo(Misc.PathCombine(race.CurrentRaceData.DirectoryPath, Config.FileNameRace));
     using (FileStream stream = new FileStream(fileInfo.FullName,
                                               FileMode.Open,
                                               FileAccess.Read,
                                               FileShare.None))
     {
         using (BinaryReader reader = new BinaryReader(stream))
         {
             stream.Seek(0, SeekOrigin.Begin);
             Assert.AreEqual(4, reader.ReadInt32(), "Total files count");
             stream.Seek(256 * 1, SeekOrigin.Begin);
             Assert.AreEqual("01-jozek.Pepek-2009-asd-Ind.mp3", reader.ReadString(), "FileName");
             Assert.AreEqual("2e04944c", reader.ReadString(), "CRC32");
             Assert.AreEqual(true, reader.ReadBoolean(), "File was uploaded");
             Assert.AreEqual((UInt64) 5000, reader.ReadUInt64(), "FileSize");
         }
     }
     Assert.AreEqual((UInt64) 5000, race.TotalBytesUploaded, "TotalBytesUploaded");
     Assert.AreEqual(4, race.TotalFilesExpected, "TotalFilesExpected");
     Assert.AreEqual(1, race.TotalFilesUploaded, "TotalFilesUploaded");
     Assert.IsFalse(
         File.Exists(@"..\..\TestFiles\Mp3\01-jozek.Pepek-2009-asd-Ind.mp3" + Config.FileExtensionMissing),
         "01-jozek.Pepek-2009-asd-Ind.mp3" + Config.FileExtensionMissing);
     Assert.IsTrue(
         Directory.Exists(Misc.PathCombine(race.CurrentRaceData.DirectoryParent, output.Format(Config.TagIncompleteLink))),
         "Symlink does not exist!");
     race = new Race(ArgsMp3File2);
     race.ParseUpload();
     race.Process();
     output = new Output(race);
     Assert.IsFalse(
         File.Exists(@"..\..\TestFiles\Mp3\02-jozek.Pepek-2009-asd-Ind.mp3" + Config.FileExtensionMissing),
         "02-jozek.Pepek-2009-asd-Ind.mp3" + Config.FileExtensionMissing);
     Assert.IsTrue(
         Directory.Exists(Misc.PathCombine(race.CurrentRaceData.DirectoryParent, output.Format(Config.TagIncompleteLink))),
         "Symlink does not exist!");
     race = new Race(ArgsMp3File3);
     race.ParseUpload();
     race.Process();
     output = new Output(race);
     Assert.IsFalse(
         File.Exists(@"..\..\TestFiles\Mp3\03-jozek.Pepek-2009-asd-Ind(2).mp3" + Config.FileExtensionMissing),
         "03-jozek.Pepek-2009-asd-Ind(2).mp3" + Config.FileExtensionMissing);
     Assert.IsTrue(
         Directory.Exists(Misc.PathCombine(race.CurrentRaceData.DirectoryParent, output.Format(Config.TagIncompleteLink))),
         "Symlink does not exist!");
     race = new Race(ArgsMp3File4);
     race.ParseUpload();
     race.Process();
     output = new Output(race);
     Assert.AreEqual(4, race.TotalFilesExpected, "TotalFilesExpected");
     Assert.AreEqual(4, race.TotalFilesUploaded, "TotalFilesUploaded");
     Assert.IsFalse(
         File.Exists(@"..\..\TestFiles\Mp3\04-jozek.Pepek-2009-asd-Ind(3).mp3" + Config.FileExtensionMissing),
         "04-jozek.Pepek-2009-asd-Ind(3).mp3" + Config.FileExtensionMissing);
     Assert.IsFalse(
         Directory.Exists(Misc.PathCombine(race.CurrentRaceData.DirectoryParent, output.Format(Config.TagIncompleteLink))),
         "Symlink not deleted!");
 }
Esempio n. 20
0
 public void Process()
 {
     Log.Debug("Process with SFV");
     TagManager tagManager = new TagManager(race);
     Log.Debug("Create missing files");
     foreach (KeyValuePair<string, string> keyValuePair in sfvData)
     {
         FileInfo.Create0ByteFile(Misc.PathCombine(currentRaceData.DirectoryPath, keyValuePair.Key + Config.FileExtensionMissing));
     }
     race.TotalFilesExpected = sfvData.Count;
     Log.Debug("Total files expected: {0}", race.TotalFilesExpected);
     CreateSfvRaceDataFile();
     Output output = new Output(race);
     output
         .Client(Config.ClientHead)
         .Client(Config.ClientFileNameSfv)
         .Client(Config.ClientFoot);
     Log.Debug("Create INCOMPLETE Symlinks");
     tagManager.CreateTag(currentRaceData.DirectoryPath, output.Format(Config.TagIncomplete));
     tagManager.CreateSymLink(currentRaceData.DirectoryParent, output.Format(Config.TagIncompleteLink));
     if (Config.LogToIoFtpdSfv)
     {
         Log.IoFtpd(output.Format(Config.LogLineIoFtpdSfv));
     }
     if (Config.LogToInternalSfv)
     {
         Log.Internal(output.Format(Config.LogLineInternalSfv));
     }
 }
Esempio n. 21
0
 private bool ExecuteDupeNewDirTask()
 {
     var directoryInfo = new DirectoryInfo(args [1]);
     string releaseName = directoryInfo.Name;
     DataBaseDupe dataBaseDupe = DataBase.SelectFromDupe(String.Format("SELECT * FROM Folders WHERE ReleaseName = '{0}'", releaseName));
     if (dataBaseDupe == null)
     {
         string userName = IoEnvironment.GetUserName();
         string groupName = IoEnvironment.GetGroupName();
         string insertCommand = String.Format(@"INSERT INTO Folders (UserName, GroupName, PathReal, PathVirtual, ReleaseName) VALUES('{0}', '{1}', '{2}', '{3}', '{4}')", userName, groupName, args [1], args [2], releaseName);
         int rows = DataBase.Insert(insertCommand);
         if (rows > 0)
         {
             Log.Debug("INSERT new DUPE '{0}'", insertCommand);
             return true;
         }
         Log.Debug("INSERT of new DUPE FAILED! '{0}'", insertCommand);
         return false;
     }
     Log.Debug("New dir is a dupe of '{0}'", dataBaseDupe.ToString());
     var output = new Output();
     output.Client(output.FormatDupe(Config.ClientDupeNewDir, dataBaseDupe));
     if (Config.LogToIoFtpdDupe)
     {
         Log.IoFtpd(output.FormatDupe(Config.LogLineIoFtpdDupe, dataBaseDupe));
     }
     if (Config.LogToInternalDupe)
     {
         Log.Internal(output.FormatDupe(Config.LogLineIoFtpdDupe, dataBaseDupe));
     }
     return false;
 }
Esempio n. 22
0
 private void ExecuteRequestTask()
 {
     if (args.Length < 2)
     {
         OutputRequestList();
         return;
     }
     if (args [0].ToLowerInvariant().Equals(Constants.RequestAdd))
     {
         string requestName = args [1];
         Log.Debug("REQUEST ADD '{0}'", requestName);
         string request = Misc.PathCombine(Config.RequestFolder, Config.RequestPrefix + requestName);
         string creator = IoEnvironment.GetUserName();
         string groupname = IoEnvironment.GetGroupName();
         var dateTime = new DateTime(DateTime.UtcNow.Ticks);
         var requestTask = new RequestTask
                           {
                               Username = creator,
                               Groupname = groupname,
                               DateAdded = dateTime,
                               Name = requestName,
                           };
         if (taskConfiguration.RequestTasks != null)
         {
             List<RequestTask> requestTasks = taskConfiguration.RequestTasks.ToList();
             RequestTask task = requestTasks.Find(r => r.Name == requestName);
             if (task == null)
             {
                 //add
                 requestTasks.Add(requestTask);
                 taskConfiguration.RequestTasks = requestTasks.ToArray();
                 if (!request.DirectoryExists())
                 {
                     FileInfo.CreateFolder(request);
                 }
                 if (Config.LogToIoFtpdRequest)
                 {
                     var output = new Output();
                     Log.IoFtpd(output.FormatRequestTask(Config.LogLineIoFtpdRequest, requestTask));
                 }
                 if (Config.LogToInternalRequest)
                 {
                     var output = new Output();
                     Log.Internal(output.FormatRequestTask(Config.LogLineInternalRequest, requestTask));
                 }
             }
             else
             {
                 Log.Debug("REQUEST allready exists!");
             }
         }
         else
         {
             taskConfiguration.RequestTasks = new[] {requestTask};
         }
         SaveConfiguration();
         OutputRequestList();
         return;
     }
     if (args [0].ToLowerInvariant().Equals(Constants.RequestDel))
     {
         string requestName = args [1];
         Log.Debug("REQUEST DEL '{0}'", requestName);
         string request = Misc.PathCombine(Config.RequestFolder, Config.RequestPrefix + requestName);
         if (taskConfiguration.RequestTasks != null)
         {
             List<RequestTask> requestTasks = taskConfiguration.RequestTasks.ToList();
             RequestTask requestTask = requestTasks.Find(task => task.Name == requestName);
             if (requestTask != null)
             {
                 requestTasks.Remove(requestTask);
             }
             taskConfiguration.RequestTasks = requestTasks.ToArray();
             SaveConfiguration();
             if (Config.LogToIoFtpdRequestDeleted)
             {
                 var output = new Output();
                 Log.IoFtpd(output.FormatRequestTask(Config.LogLineIoFtpdRequestDeleted, requestTask));
             }
             if (Config.LogToInternalRequestDeleted)
             {
                 var output = new Output();
                 Log.Internal(output.FormatRequestTask(Config.LogLineInternalRequestDeleted, requestTask));
             }
         }
         if (request.DirectoryExists())
         {
             request.KickUsersFromDirectory();
             request.RemoveFolder();
         }
         OutputRequestList();
         return;
     }
     if (args [0].ToLowerInvariant().Equals(Constants.RequestFill))
     {
         string requestName = args [1];
         Log.Debug("REQUEST FILL '{0}'", requestName);
         string request = Misc.PathCombine(Config.RequestFolder, Config.RequestPrefix + requestName);
         if (taskConfiguration.RequestTasks != null)
         {
             List<RequestTask> requestTasks = taskConfiguration.RequestTasks.ToList();
             RequestTask requestTask = requestTasks.Find(task => task.Name == requestName);
             if (requestTask != null)
             {
                 requestTasks.Remove(requestTask);
             }
             taskConfiguration.RequestTasks = requestTasks.ToArray();
             SaveConfiguration();
             if (Config.LogToIoFtpdRequestFilled)
             {
                 var output = new Output();
                 Log.IoFtpd(output.FormatRequestTask(Config.LogLineIoFtpdRequestFilled, requestTask));
             }
             if (Config.LogToInternalRequestFilled)
             {
                 var output = new Output();
                 Log.Internal(output.FormatRequestTask(Config.LogLineInternalRequestFilled, requestTask));
             }
         }
         if (request.DirectoryExists())
         {
             request.KickUsersFromDirectory();
             Directory.Move(request, Misc.PathCombine(Config.RequestFolder, Config.RequestFilled + requestName));
         }
         OutputRequestList();
     }
 }