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);
            }
        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
0
        private void generateXls(List <Dictionary <string, string> > propsCw, string path)
        {
            var dicList  = new Dictionary <string, List <string> >();
            var listTile = new List <string>()
            {
                "Effective Date",
                "SYMBOL",
                "DSPLY_NAME",
                "RIC",
                "OFFCL_CODE",
                "EX_SYMBOL",
                "BCKGRNDPAG",
                "BCAST_REF",
                "#INSTMOD_EXPIR_DATE",
                "#INSTMOD_LONGLINK1",
                "#INSTMOD_LONGLINK2",
                "#INSTMOD_MATUR_DATE",
                "#INSTMOD_OFFC_CODE2",
                "#INSTMOD_STRIKE_PRC",
                "#INSTMOD_WNT_RATIO",
                "#INSTMOD_MNEMONIC",
                "#INSTMOD_TDN_SYMBOL",
                "#INSTMOD_LONGLINK3",
                "EXL_NAME",
                "Old Chain",
                "New BCU",
                "NDA Common Name",
                "Primary Listing",
                "Organisation Name DIRNAME",
                "Issue Date",
                "First Exercise Date",
                "Last Exercise Date",
                "Outstanding Warrant Quantity",
                "Exercise Period"
            };

            dicList.Add("title", listTile);

            //foreach (var dic in propsCw)
            for (int index = 0; index < propsCw.Count; index++)
            {
                List <string> listBody = propsCw[index].Values.ToList();
                dicList.Add(index.ToString(), listBody);
            }

            if (dicList == null || dicList.Count <= 1)
            {
                return;
            }

            XlsOrCsvUtil.GenerateXls0rCsv(path, dicList);
        }
Ejemplo n.º 4
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);
            }
        }
Ejemplo n.º 5
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);
            }
        }
Ejemplo n.º 6
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");
        }
Ejemplo n.º 7
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);
            }
        }
Ejemplo n.º 8
0
        protected override void Start()
        {
            try
            {
                int i       = 1;
                var propsPc = new List <Dictionary <string, string> >();
                foreach (Dictionary <string, string> infos in GetPages().Select(page => CleanInfos(GetInfos(page)))
                         .Where(infos => infos != null)
                         .Where(infos => infos["subject"] == "Adjustment"))
                {
                    propsPc.Add(infos);
                    i++;
                }
                if (i > 1)
                {
                    string        path  = string.Format("{0}Price_Change_{1}.xlsx", configObj.ResultFolderPath, DateTime.Now.ToString("ddMM"));
                    List <string> title = new List <string>()
                    {
                        "RIC", "Symbol", "ISIN", "OLD_RATIO", "#INSTMOD_WNT_RATIO", "OLD_PRC", "#INSTMOD_STRIKE_PRC"
                    };
                    List <List <string> > bulkFile = new List <List <string> >();
                    bulkFile.Add(title);
                    FillInBulkFile(bulkFile, propsPc);
                    XlsOrCsvUtil.GenerateXls0rCsv(path, bulkFile);
                    AddResult(Path.GetFileNameWithoutExtension(path), path, "");

                    //var ndaDw1 = new Nda(FileMode.WriteOnly);
                    //ndaDw1.LoadFromTemplate(TemplateFm.ThPriceChange, propsPc);
                    //ndaDw1.Save(String.Format("{0}Price_Change_{1}.xlsx", configObj.ResultFolderPath, DateTime.Now.ToString("ddMM")));
                    //AddResult("Price change Nda bulk file", ndaDw1.Path, "nda");
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Task failed, error: " + ex.Message, ex);
            }
        }