示例#1
0
        public static IEnumerable <DataTable> Extract()
        {
            Logger.Info("Analyzing Downloaded Excels and Extracting Data...");
            foreach (var xls in Directory.GetFiles(DownloadPath, "*"
                                                   +
                                                   ConfigurationManager.AppSettings["DownloadedFileType"])
                     )
            {
                CompanyName company = default(CompanyName);
                foreach (CompanyName name in Enum.GetValues(typeof(CompanyName)))
                {
                    if (Path.GetFileNameWithoutExtension(xls)?.Contains(name.ToString()) ?? false)
                    {
                        company = name;
                    }
                }
                var tableList = new HTMLParser(xls).Process().ToList();
                var cleared   = tableList.First(dt => dt.TableName == Headers[0]);
                cleared.TableName = "" + company + ProductType.Swap;
                var future = tableList.First(dt => dt.TableName == Headers[1]);
                future.TableName = "" + company + ProductType.Futures;
                TrimDataTable(cleared);
                TrimDataTable(future);
                yield return(cleared);

                yield return(future);
            }
        }