Beispiel #1
0
 /// <summary>
 /// This function imports the desired DataRecord specified by the Path.
 /// This could be loading data from a url, or file.
 /// </summary>
 /// <param name="Record">The list of DataRecord being loaded into and returned</param>
 /// <param name="Path">The location of the desired data</param>
 /// <returns>A new or updated list of DataRecord including the newly acquired data</returns>
 /// For path include file://"path" for files and for urls include url://"path"
 public List <DataRecord> Import(List <DataRecord> Records, string Path, int priority = 1)
 {
     // Allocate a data record if one does not exist
     if (Records == null)
     {
         Records = new List <DataRecord>();
     }
     //DataTracker.updateJob(Path, DataTracker.Status.RUNNING);
     // Check the path
     Console.WriteLine("Path = " + Path);
     Transfer.Type type = Transfer.GetType(ref Path);
     if (type == Transfer.Type.URL)
     {
         // Call the url import function
         //DataTracker.submitJob(Path, Records);
         return(ImportFromURL(Records, Path, priority));
     }
     else if (type == Transfer.Type.FILE)
     {
         // Call the file import function
         //DataTracker.submitJob(Path, Records);
         return(ImportFromFile(Records, Path));
     }
     else
     {
         // Throw an exception for unsupported operation
         throw new System.ArgumentException("File type is not \'file\' or \'url\': " + Path);
     }
 }
    public override bool ExportToFile(string Path, string outputPath, string outputName)
    {
        // The getType function will determine the type of transfer (file or url) and strip off special tokens to help determine the type.
        Transfer.Type type = Transfer.GetType(ref Path);

        // Put Try Catch HERE
        // If file does not exist
        if (type == Transfer.Type.URL)
        {
            Console.WriteLine("URL: " + Path);
            // Beautiful Lambda here
            // Downloads the bytes and uses the ByteFunction lambda described in the passed parameter which will call the mime parser and populate the record.
            // Network Manager download
            nm.AddDownload(new DownloadRequest(Path, (StringFunction)((DownloadedString) => parser.Parse(outputPath, outputName, DownloadedString))));
        }

        // Return
        return(true);
    }
Beispiel #3
0
        public void MakeValidTransfers(MoneyAccount.Type source, MoneyAccount.Type destination, Transfer.Type expected)
        {
            var sourceAccount      = FakeRepository.First(source);
            var destinationAccount = FakeRepository.First(destination);

            var transfer = sourceAccount.TransferTo(destinationAccount);

            Assert.Equal(expected, transfer.TransferType);
        }