Esempio n. 1
0
        public List <CloudCoin> LoadFolderCoins(string folder)
        {
            List <CloudCoin> folderCoins = new List <CloudCoin>();


            // Get All the supported CloudCoin Files from the folder
            var files = Directory
                        .GetFiles(folder)
                        .Where(file => Config.allowedExtensions.Any(file.ToLower().EndsWith))
                        .ToList();

            string[] fnames = new string[files.Count()];
            for (int i = 0; i < files.Count(); i++)
            {
                fnames[i] = Path.GetFileName(files.ElementAt(i));
                string ext = Path.GetExtension(files.ElementAt(i));
                if (ext == ".stack" || ext == ".celebrium" || ext == ".celeb")
                {
                    var coins = Utils.LoadJson(files[i]);
                    if (coins != null)
                    {
                        folderCoins.AddRange(coins);
                    }
                }
                if (ext == ".jpeg" || ext == ".jpg")
                {
                    try
                    {
                        var coin = DepositJPEG(files[i]);
                        folderCoins.Add(coin);
                    }
                    catch (Exception)
                    {
                    }
                }
                if (ext == ".csv")
                {
                    var lines = File.ReadAllLines(files[i]);
                    //var lines = File.ReadAllLines(fileName).Select(a => a.Split(','));
                    List <CloudCoin> CsvCoins = new List <CloudCoin>();


                    foreach (var line in lines)
                    {
                        CsvCoins.Add(CloudCoin.FromCSV(line));
                    }
                    CsvCoins.RemoveAll(item => item == null);
                    folderCoins.AddRange(CsvCoins);
                }
            }
            ;

            return(folderCoins);
        }
Esempio n. 2
0
        public IEnumerable <CloudCoin> LoadCoins(string fileName)
        {
            string ext = Path.GetExtension(fileName);

            if (ext == ".stack" || ext == ".celebrium" || ext == ".celeb")
            {
                var coins = Utils.LoadJson(fileName);
                if (coins != null && coins.Length > 0)
                {
                    return(coins);
                }
            }
            if (ext == ".jpeg" || ext == ".jpg")
            {
                try
                {
                    var coin = DepositJPEG(fileName);
                    if (coin == null)
                    {
                        return(null);
                    }
                    List <CloudCoin> coins = new List <CloudCoin>();
                    coins.Add(coin);
                    return(coins);
                }
                catch (Exception e)
                {
                }
            }
            if (ext == ".csv")
            {
                var lines = File.ReadAllLines(fileName);
                //var lines = File.ReadAllLines(fileName).Select(a => a.Split(','));
                List <CloudCoin> CsvCoins = new List <CloudCoin>();


                foreach (var line in lines)
                {
                    CsvCoins.Add(CloudCoin.FromCSV(line));
                }
                CsvCoins.RemoveAll(item => item == null);
                return(CsvCoins);
            }
            return(null);
        }