예제 #1
0
        //private static OutputSettings _outputSettings;

        public static PSEDocument LoadFromReportFile(string fullFilePath, OutputSettings outputSettings)
        {
            //var doc = PDDocument.load(fullFilePath);
            ////PSEDocument pd = new PSEDocument();

            //var stripper = new PDFTextStripper();
            //string pdfText = stripper.getText(doc).TrimEnd();

            IPdfService pdfService = ServiceLocator.Current.GetInstance <IPdfService>();
            string      pdfText    = pdfService.ExtractTextFromPdf(fullFilePath);


            var document = new PSEDocument();
            var reader   = new PSEReportReader2();

            reader.Fill(document, pdfText);

            if (outputSettings is CSVOutputSettings)
            {
                (outputSettings as CSVOutputSettings).Filename = Path.GetFileNameWithoutExtension(fullFilePath) + ".csv";
                document.ToCSV(outputSettings as CSVOutputSettings);
            }

            if (outputSettings is AmiOutputSettings)
            {
                document.ToAmibroker(outputSettings as AmiOutputSettings);
            }

            if (outputSettings is MetaOutputSettings)
            {
                document.ToMetaStock(outputSettings as MetaOutputSettings);
            }

            return(document);
        }
예제 #2
0
        static void ConvertIt(string fileToConvert)
        {
            IPdfService      pdfService  = new PdfTextSharpService();
            var              pseDocument = new PSEDocument();
            IPSEReportReader reader      = new PSEReportReader2();

            reader.Fill(pseDocument, pdfService.ExtractTextFromPdf(fileToConvert));
            if (_outputFormat.Contains("csv"))
            {
                string[] csvParam  = _outputFormat.Split(':');
                string   csvFormat = string.Empty;
                if (csvParam.Length == 2)
                {
                    csvFormat = csvParam[1];
                    csvFormat = csvFormat.Replace("S", "{S}");
                    csvFormat = csvFormat.Replace("D", "{D}");
                    csvFormat = csvFormat.Replace("O", "{O}");
                    csvFormat = csvFormat.Replace("H", "{H}");
                    csvFormat = csvFormat.Replace("L", "{L}");
                    csvFormat = csvFormat.Replace("C", "{C}");
                    csvFormat = csvFormat.Replace("V", "{V}");
                    csvFormat = csvFormat.Replace("F", "{F}");
                }
                else
                {
                    csvFormat = "{S},{D},{O},{H},{L},{C},{V},{F}";
                }

                var csvOutputSettings = new CSVOutputSettings();
                csvOutputSettings.CSVFormat              = csvFormat;
                csvOutputSettings.DateFormat             = _dateFormat;
                csvOutputSettings.Delimiter              = ",";
                csvOutputSettings.Filename               = Path.GetFileName(fileToConvert).Replace("pdf", "csv");
                csvOutputSettings.OutputDirectory        = _outputPath;
                csvOutputSettings.UseSectorValueAsVolume = true;
                csvOutputSettings.SectorVolumeDivider    = 1000;

                pseDocument.ToCSV(csvOutputSettings);
            }
        }
예제 #3
0
파일: Program.cs 프로젝트: yvdjee/PSEGet
        static void ConvertIt(string fileToConvert)
        {
            IPdfService      pdfService  = new PdfTextSharpService();
            var              pseDocument = new PSEDocument();
            IPSEReportReader reader      = new PSEReportReader2();

            reader.Fill(pseDocument, pdfService.ExtractTextFromPdf(fileToConvert));
            if (_outputFormat.Contains("csv"))
            {
                string[] csvParam  = _outputFormat.Split(':');
                string   csvFormat = string.Empty;
                if (csvParam.Length == 2)
                {
                    csvFormat = csvParam[1];
                    csvFormat = csvFormat.Replace("S", "{S}");
                    csvFormat = csvFormat.Replace("D", "{D}");
                    csvFormat = csvFormat.Replace("O", "{O}");
                    csvFormat = csvFormat.Replace("H", "{H}");
                    csvFormat = csvFormat.Replace("L", "{L}");
                    csvFormat = csvFormat.Replace("C", "{C}");
                    csvFormat = csvFormat.Replace("V", "{V}");
                    csvFormat = csvFormat.Replace("F", "{F}");
                }
                else
                {
                    csvFormat = "{S},{D},{O},{H},{L},{C},{V},{F}";
                }

                var csvOutputSettings = new CSVOutputSettings();
                csvOutputSettings.CSVFormat              = csvFormat;
                csvOutputSettings.DateFormat             = _dateFormat;
                csvOutputSettings.Delimiter              = ",";
                csvOutputSettings.Filename               = Path.GetFileName(fileToConvert).Replace("pdf", "csv");
                csvOutputSettings.OutputDirectory        = _outputPath;
                csvOutputSettings.UseSectorValueAsVolume = true;
                csvOutputSettings.SectorVolumeDivider    = 1000;

                pseDocument.ToCSV(csvOutputSettings);
            }
            else if ((HostOS.determineHostEnviroment() == HostOS.HostEnviroment.Windows) && (_outputFormat.Contains("ami")))
            {
                IAmibrokerService amiService = new AmibrokerService();
                if (!amiService.IsAmibrokerInstalled())
                {
                    throw new Exception("Error: Amibroker is not installed on this machine.");
                }

                string[] amiParam = _outputFormat.Split(':');
                if (amiParam.Length < 2)
                {
                    throw new Exception("Error: Unspecified Amibroker database folder.");
                }
                string amiDatabaseFolder = _outputFormat.Replace("ami:", string.Empty);

                var amiOutputSettings = new AmiOutputSettings();
                amiOutputSettings.DatabaseDirectory      = amiDatabaseFolder;
                amiOutputSettings.SectorVolumeDivider    = 1000;
                amiOutputSettings.UseSectorValueAsVolume = true;

                pseDocument.ToAmibroker(amiOutputSettings);
            }
        }