Beispiel #1
0
        private void GenerateOutputFile(Dictionary <string, List <string> > dicList, string path)
        {
            try
            {
                if (File.Exists(path))
                {
                    File.Delete(path);
                }

                if (path.EndsWith(".csv"))
                {
                    XlsOrCsvUtil.GenerateStringCsv(path, dicList);
                }
                else
                {
                    XlsOrCsvUtil.GenerateXls0rCsv(path, dicList);
                }

                AddResult("ReportDiff", path, configObj.OutputFileType.ToString());
            }
            catch (Exception ex)
            {
                string msg = string.Format("\r\n	     ClassName:  {0}\r\n	     MethodName: {1}\r\n	     Message:    {2}",
                                           System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(),
                                           System.Reflection.MethodBase.GetCurrentMethod().Name,
                                           ex.Message);
                Logger.Log(msg, Logger.LogType.Error);
            }
        }
        private void GenerateFile(string path, List <List <string> > template)
        {
            try
            {
                if (!Directory.Exists(Path.GetDirectoryName(path)))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(path));
                }

                if (File.Exists(path))
                {
                    File.Delete(path);
                }

                XlsOrCsvUtil.GenerateStringCsv(path, template);
            }
            catch (Exception ex)
            {
                string msg = string.Format("\r\n	     ClassName:  {0}\r\n	     MethodName: {1}\r\n	     Message:    {2}",
                                           System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(),
                                           System.Reflection.MethodBase.GetCurrentMethod().Name,
                                           ex.Message);
                Logger.Log(msg, Logger.LogType.Error);
            }
        }
Beispiel #3
0
        private void GenerateBulkFile(string file, Dictionary <string, List <string> > dicList)
        {
            if (dicList == null || dicList.Count <= 1)
            {
                string msg = string.Format("no column need to generate bulk file.");
                Logger.Log(msg, Logger.LogType.Info);
                return;
            }

            try
            {
                if (!Directory.Exists(outPutPath))
                {
                    Directory.CreateDirectory(outPutPath);
                }

                if (File.Exists(file))
                {
                    File.Delete(file);
                }
            }
            catch (Exception ex)
            {
                string msg = string.Format("delete old the file :{0} error. msg:{1}", file, ex.ToString());
                Logger.Log(msg, Logger.LogType.Error);
                return;
            }

            try
            {
                XlsOrCsvUtil.GenerateStringCsv(file, dicList);
                attacheFileList.Add(file);
                AddResult("bulk file", file, "CSV Bulk File");
                //TaskResultList.Add(new TaskResultEntry(MethodBase.GetCurrentMethod().DeclaringType.FullName.Replace("Ric.Generator.Lib.", ""), "ResultFile", file));
            }
            catch (Exception ex)
            {
                string msg = string.Format("generate the file :{0} error. msg:{1}", file, ex.ToString());
                Logger.Log(msg, Logger.LogType.Error);
            }
        }
Beispiel #4
0
        private void GenerateOutPutFile(List <TFEXBulkFileTemplate> listTFEX)
        {
            List <List <string> > listListOutput = new List <List <string> >();
            string path = Path.Combine(configObj.FolderPath, string.Format("TFEX_QA_Add_{0}.csv", configObj.DateOfSource));

            try
            {
                listListOutput.Add(title);
                FormateTemplate(listTFEX, listListOutput);
                XlsOrCsvUtil.GenerateStringCsv(path, listListOutput);
                AddResult("TFEX_yyy-MM-dd.csv", path, "Bulk file");
            }
            catch (Exception ex)
            {
                string msg = string.Format("\r\n	     ClassName:  {0}\r\n	     MethodName: {1}\r\n	     Message:    {2}",
                                           System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(),
                                           System.Reflection.MethodBase.GetCurrentMethod().Name,
                                           ex.Message);
                Logger.Log(msg, Logger.LogType.Error);
            }
        }
Beispiel #5
0
        private void StartExtract2()
        {
            List <List <string> > bulkFileFilter = null;
            List <LineFound>      bulkFile       = null;

            pdftron.PDFNet.Initialize("Reuters Technology China Ltd.(thomsonreuters.com):CPU:1::W:AMC(20121010):AD5EE33F2505D1CAF1B425461F9C92BAA89204FA0AD8AAA17E07887EF0FA");
            PDFDoc doc = new PDFDoc(config.FilePath2);

            doc.InitSecurityHandler();
            string    patternTitle = @"コード";
            int       page         = 5;
            PdfString ricPosition  = GetRicPosition(doc, patternTitle, page);

            if (ricPosition == null)
            {
                return;
            }

            ricPosition.Position.x1 = 106.8;
            ricPosition.Position.x2 = 99.12;
            ricPosition.Position.y1 = 29.5105;
            ricPosition.Position.y2 = 44.8734;
            string patternRic = @"\d{4}";
            //string patternValue = @"\-?(\,\.\d)*";
            string patternValue = @"(\-|\+)?\d+(\,|\.|\d)+";

            bulkFile = GetValue(doc, ricPosition, patternRic, patternValue);
            int indexOK = 0;

            bulkFileFilter = FilterBulkFile(bulkFile, indexOK);
            string filePath = Path.Combine(config.OutputFolder, string.Format("{0}.csv", Path.GetFileNameWithoutExtension(config.FilePath2)));

            if (File.Exists(filePath))
            {
                File.Delete(filePath);
            }

            XlsOrCsvUtil.GenerateStringCsv(filePath, bulkFileFilter);
            AddResult(Path.GetFileNameWithoutExtension(filePath), filePath, "type2");
        }
Beispiel #6
0
        private void GenerateOutputFile(Dictionary <string, List <string> > dicList, string path)
        {
            try
            {
                try
                {
                    if (File.Exists(path))
                    {
                        File.Delete(path);
                    }
                }
                catch (Exception ex)
                {
                    Logger.Log(string.Format("delete alerday exist file: {0} error.msg:{1}", path, ex.Message), Logger.LogType.Error);
                }

                if (path.ToLower().EndsWith(".xls") || path.ToLower().EndsWith(".xlsx"))
                {
                    XlsOrCsvUtil.GenerateXls0rCsv(path, dicList);
                }
                else if (path.ToLower().EndsWith(".csv"))
                {
                    XlsOrCsvUtil.GenerateStringCsv(path, dicList);
                }
                else
                {
                    MessageBox.Show("Output path must be end with .xls(x) or .csv");
                }
            }
            catch (Exception ex)
            {
                string msg = string.Format("\r\n	     ClassName:  {0}\r\n	     MethodName: {1}\r\n	     Message:    {2}",
                                           System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(),
                                           System.Reflection.MethodBase.GetCurrentMethod().Name,
                                           ex.Message);
                Logger.Log(msg, Logger.LogType.Error);
            }
        }