public bool create(TableType type, string dateTime, List <string> datas) { bool flag = false; try { List <string> data = new List <string>(); SetFile f = new SetFile(type, dateTime); //ex: commpanyA53_20170803 string getFileName = f.getCommpanyFileName(); #region File data.Add("START-OF-FILE"); #region Title data.Add($"REPLYFILENAME={getFileName}"); data.Add("PROGRAMNAME=getcompany"); data.Add("PROGRAMFLAG=" + f.getPROGRAMFLAG()); data.Add("FIRMNAME=" + f.getFIRMNAME()); //確認是否提出來? data.Add("CREDITRISK=yes"); data.Add("SECID=TICKER"); #endregion Title //空一行 data.Add(string.Empty); #region START-OF-FIELDS data.Add("START-OF-FIELDS"); object obj = null; bool findFlag = false; if (TableType.A53.ToString().Equals(type.ToString())) { obj = new A53Commpany(); findFlag = true; } if (findFlag) { obj.GetType() .GetProperties() //.OrderBy(x => x.Name) .ToList() .ForEach(x => data.Add(x.Name)); } data.Add("END-OF-FIELDS"); #endregion START-OF-FIELDS //空一行 data.Add(string.Empty); #region START-OF-DATA data.Add("START-OF-DATA"); datas.ForEach(x => data.Add(string.Format("{0} Equity|TICKER", x))); data.Add("END-OF-DATA"); #endregion START-OF-DATA data.Add("END-OF-FILE"); #endregion File //ex: ../commpanyPut 資料夾 //f.putCommpanyFilePath(); //ex: commpanyA53_20170803 //f.putCommpanyFileName(); flag = new CreatePutFile().create( f.putCommpanyFilePath(), f.putCommpanyFileName(), data); } catch { flag = false; } return(flag); }
/// <summary> /// create Put A07 File /// </summary> /// <param name="type"></param> /// <param name="dateTime"></param> public bool create(TableType type, string dateTime) { bool flag = false; try { List <string> data = new List <string>(); SetFile f = new SetFile(type, dateTime); //ex: GetA07_20170908.csv string getFileName = f.getFileName(); //string getFileName = f.getGZFileName(); DateTime dt = DateTime.Now; DateTime dt2 = dt.AddMonths(-18); #region File data.Add("START-OF-FILE"); #region Title data.Add("FIRMNAME=" + f.getFIRMNAME()); data.Add("PROGRAMFLAG=" + f.getPROGRAMFLAG()); data.Add("FILETYPE=pc"); data.Add($"REPLYFILENAME={getFileName}"); data.Add($"DATERANGE={dt2.ToString("yyyyMMdd")}|{dt.ToString("yyyyMMdd")}"); data.Add("HIST_PERIOD=q"); data.Add("PROGRAMNAME=gethistory"); #endregion Title //空一行 data.Add(string.Empty); data.Add("# Automatically generated by Bloomberg Data License Request Builder version 7.0.1"); data.Add("# Build Code: 000000000000000148"); //空一行 data.Add(string.Empty); #region START-OF-FIELDS data.Add("START-OF-FIELDS"); data.Add("NAME"); data.Add("PX_LAST"); data.Add("LAST_UPDATE_DT"); data.Add("END-OF-FIELDS"); #endregion START-OF-FIELDS //空一行 data.Add(string.Empty); #region START-OF-DATA data.Add("START-OF-DATA"); new Econ_Domestic().GetType().GetProperties() .Skip(2).ToList().ForEach(x => { if (x.Name == "SINYI_HOUSE_PRICE_index" || x.Name == "CATHAY_ESTATE_index" || x.Name == "Real_GDP2011") { data.Add(x.Name); } else if (x.Name != "Econ_D_YYYYMMDD") { data.Add(x.Name.Replace("_", " ")); } }); data.Add("END-OF-DATA"); #endregion START-OF-DATA data.Add("END-OF-FILE"); #endregion File flag = new CreatePutFile().create( f.putA07FilePath(), f.putFileName(), data); } catch { flag = false; } return(flag); }
/// <summary> /// create Put Sample File /// </summary> /// <param name="type"></param> /// <param name="dateTime"></param> /// <param name="ver"></param> public bool create(TableType type, string dateTime, int ver) { bool flag = false; try { List <string> data = new List <string>(); SetFile f = new SetFile(type, dateTime); //ex: sampleA53_20170803 string getFileName = f.getSampleFileName(); #region File data.Add("START-OF-FILE"); #region Title data.Add($"REPLYFILENAME={getFileName}"); data.Add("PROGRAMNAME=getdata"); data.Add("PROGRAMFLAG=" + f.getPROGRAMFLAG()); data.Add("FIRMNAME=" + f.getFIRMNAME()); //確認是否提出來? data.Add("SECMASTER=YES"); data.Add("OUTPUTFORMAT=bulklist"); data.Add("DELIMITER=,"); data.Add("FUNDAMENTALS=yes"); #endregion Title //空一行 data.Add(string.Empty); #region START-OF-FIELDS data.Add("START-OF-FIELDS"); object obj = null; bool findFlag = false; if (TableType.A53.ToString().Equals(type.ToString())) { obj = new A53Sample(); findFlag = true; } if (findFlag) { obj.GetType() .GetProperties() //.OrderBy(x => x.Name) .ToList() .ForEach(x => data.Add(x.Name)); } data.Add("END-OF-FIELDS"); #endregion START-OF-FIELDS //空一行 data.Add(string.Empty); #region START-OF-DATA data.Add("START-OF-DATA"); int year = Int32.Parse(dateTime.Substring(0, 4)); int month = Int32.Parse(dateTime.Substring(4, 2)); int day = Int32.Parse(dateTime.Substring(6, 2)); DateTime date = new DateTime(year, month, day); IFRS9Entities db = new IFRS9Entities(); db.Bond_Account_Info.AsNoTracking() .Where(x => x.Report_Date.HasValue && x.Report_Date.Value == date && x.Version.HasValue && x.Version == ver) .Select(x => x.Bond_Number).Distinct() .OrderBy(x => x) .ToList().ForEach(x => { if (!x.IsNullOrWhiteSpace()) { data.Add(string.Format("{0}|ISIN", x)); } }); db.Dispose(); data.Add("END-OF-DATA"); #endregion START-OF-DATA data.Add("END-OF-FILE"); #endregion File //ex: ../samplePut 資料夾 //f.putCommpanyFilePath(); //ex: sampleA53_20170803 //f.putSampleFileName(); //建立 scv 檔案 flag = new CreatePutFile().create( f.putSampleFilePath(), f.putSampleFileName(), data); } catch { flag = false; } return(flag); }
/// <summary> /// create Put Sample File /// </summary> /// <param name="dateTime"></param> public bool create(string dateTime) { bool flag = false; try { List <string> data = new List <string>(); SetFile f = new SetFile(TableType.C04, dateTime); //ex: GetC04_20170803.csv string getFileName = f.getFileName(); DateTime dt = DateTime.Now; DateTime dt2 = dt.AddMonths(-18); #region File data.Add("START-OF-FILE"); #region Title data.Add($"REPLYFILENAME={getFileName}"); data.Add("FILETYPE=pc"); data.Add("PROGRAMFLAG=" + f.getPROGRAMFLAG()); data.Add("FIRMNAME=" + f.getFIRMNAME()); data.Add($"DATERANGE={dt2.ToString("yyyyMMdd")}|{dt.ToString("yyyyMMdd")}"); data.Add("HIST_PERIOD=q"); data.Add("PROGRAMNAME=gethistory"); #endregion Title //空一行 data.Add(string.Empty); #region START-OF-FIELDS data.Add("START-OF-FIELDS"); data.Add("NAME"); data.Add("PX_LAST"); data.Add("LAST_UPDATE_DT"); data.Add("END-OF-FIELDS"); #endregion START-OF-FIELDS //空一行 data.Add(string.Empty); #region START-OF-DATA data.Add("START-OF-DATA"); new Econ_Foreign().GetType().GetProperties() .Skip(2).ToList().ForEach(x => { if (x.Name == "CNFRBAL_Index") //貿易收支 傳送要加$ { data.Add(x.Name.Replace("_", "$ ")); } else { data.Add(x.Name.Replace("_", " ")); } }); data.Add("END-OF-DATA"); #endregion START-OF-DATA data.Add("END-OF-FILE"); #endregion File //建立 req 檔案 flag = new CreatePutFile().create( f.putC04FilePath(), f.putFileName(), data); } catch { flag = false; } return(flag); }