private List <FurtherIssueModel> FurtherIssueDataFormat() { List <FurtherIssueModel> fList = new List <FurtherIssueModel>(); for (var i = 0; i < orgList.Count; i++) { if (orgList[i].New_Isin == null) { orgList.Remove(orgList[i]); i--; } else { FurtherIssueModel fim = new FurtherIssueModel { New_Isin = orgList[i].New_Isin, Old_Isin = orgList[i].New_Isin, Effective_Date = orgList[i].Effective_Date, Updated_Date = Convert.ToDateTime(DateTime.Today).ToString("dd-MMM-yy", new CultureInfo("en-US")), New_Ticker = orgList[i].New_Ticker.Substring(1, (orgList[i].New_Ticker.Length - 1)) }; fim.Old_Ticker = fim.New_Ticker; fim.New_Ric = orgList[i].New_Ticker.Substring(1, (orgList[i].New_Ticker.Length - 1)) + ".KS"; fim.Old_Ric = fim.New_Ric; string n_quantity = orgList[i].New_Quanity.Trim().Replace(",", ""); string o_quantity = orgList[i].Old_Quanity.Trim().Replace(",", ""); o_quantity = (Convert.ToInt32(n_quantity) - Convert.ToInt32(o_quantity)).ToString(); fim.New_Quanity = n_quantity; fim.Old_Quanity = o_quantity; fList.Add(fim); } } return(fList); }
private void GrabDataFromTXT(string txt) { try { System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); StreamReader sr = new StreamReader(txt); string fullTxT = sr.ReadToEnd(); sr.Dispose(); sr.Close(); int pageCount = Regex.Matches(fullTxT, "상장일\\s{0,}(\\d|-){1,}").Count; for (int i = 0; i < pageCount; i++) { FurtherIssueModel fim1 = new FurtherIssueModel(); FurtherIssueModel fim2 = new FurtherIssueModel(); Get_Isin(fullTxT, fim1, fim2, i); Get_Effective_Date(fullTxT, fim1, fim2, i); Get_Ticker(fullTxT, fim1, fim2, i); Get_Old_Quanity(fullTxT, fim1, fim2, i); Get_New_Quanity(fullTxT, fim1, fim2, i); orgList.Add(fim1); orgList.Add(fim2); } } catch (Exception ex) { string msg = "Error found in GrabDataFromTXT() : " + ex; Logger.Log(msg, Logger.LogType.Error); } }
private void Get_Isin(string txtConetnt, FurtherIssueModel fim1, FurtherIssueModel fim2, int pageNum) { try { Regex r = new Regex("\\s{0,}표준코드\\s{0,}(?<Isin>.*?)\\s{0,}\r\n"); MatchCollection mc = r.Matches(txtConetnt); string str_isin = mc[pageNum].Groups["Isin"].Value; //int pos_Isin = arr[i].IndexOf("코 표준코드"); //int pos_ticker = arr[i].IndexOf("드 단축코드"); //string str_isin = arr[i].Substring((pos_Isin + 13), (pos_ticker - pos_Isin - 13)).Trim().ToString(); String[] isin_array = str_isin.Split(' '); string left_isin = ""; string right_isin = ""; if (isin_array.Count() > 1) { left_isin = isin_array[0].Trim().ToString(); right_isin = isin_array[(isin_array.Count() - 1)].Trim().ToString(); } else { left_isin = isin_array[0].Trim().ToString(); } if (left_isin != string.Empty && right_isin != string.Empty) { fim1.New_Isin = left_isin; fim2.New_Isin = right_isin; } else { fim1.New_Isin = left_isin; } } catch (Exception ex) { string msg = "Error found in GetISIN() : \r\n" + ex.ToString(); Logger.Log(msg, Logger.LogType.Warning); } }
private void Get_Effective_Date(string txtConetnt, FurtherIssueModel fim1, FurtherIssueModel fim2, int pageNum) { try { Regex r = new Regex("\\s{0,}상장일\\s{0,}(?<EffectiveDate>.*?)\\s{0,}\r\n"); MatchCollection mc = r.Matches(txtConetnt); string str_effective_date = mc[pageNum].Groups["EffectiveDate"].Value; //int pos_effective_date = arr[i].IndexOf(" 상장일"); //int pos_effective_date_next = arr[i].IndexOf("\r\n 종목명"); //string str_effective_date = arr[i].Substring((pos_effective_date + 12), (pos_effective_date_next - pos_effective_date - 12)).Trim().ToString(); String[] effective_date_array = Regex.Split(str_effective_date, " ", RegexOptions.IgnoreCase);// str_effective_date.Split(' '); string left_effective_date = ""; string right_effective_date = ""; if (effective_date_array.Count() > 1) { left_effective_date = effective_date_array[0].Trim().ToString(); right_effective_date = effective_date_array[(effective_date_array.Count() - 2)].Trim().ToString(); } else { left_effective_date = effective_date_array[0].Trim().ToString(); } if (left_effective_date != string.Empty && right_effective_date != string.Empty) { fim1.Effective_Date = left_effective_date; fim2.Effective_Date = right_effective_date; } else { fim1.Effective_Date = left_effective_date; } } catch (Exception ex) { string msg = "Error found in GetEffectiveDate() : \r\n" + ex.ToString(); Logger.Log(msg, Logger.LogType.Warning); } }
private void Get_New_Quanity(string txtConetnt, FurtherIssueModel fim1, FurtherIssueModel fim2, int pageNum) { try { Regex r = new Regex("\\s{0,}누적발행수량\\s{1,}(?<NewQuanity>.*?)\\s{0,}\r\n"); MatchCollection mc = r.Matches(txtConetnt); string str_new_quanity = mc[pageNum].Groups["NewQuanity"].Value; //int pos_new_quanity = arr[i].IndexOf("발 누적발행수량"); //int pos_new_quanity_next = arr[i].IndexOf("행 기존추가발행총액합계"); //string str_new_quanity = arr[i].Substring((pos_new_quanity + 20), (pos_new_quanity_next - pos_new_quanity - 20)).Trim().ToString(); String[] new_quanity_array = str_new_quanity.Split(' '); string left_new_quanity = ""; string right_new_quanity = ""; if (new_quanity_array.Count() > 1) { left_new_quanity = new_quanity_array[0].Trim().ToString(); right_new_quanity = new_quanity_array[(new_quanity_array.Count() - 1)].Trim().ToString(); } else { left_new_quanity = new_quanity_array[0].Trim().ToString(); } if (left_new_quanity != string.Empty && right_new_quanity != string.Empty) { fim1.New_Quanity = left_new_quanity; fim2.New_Quanity = right_new_quanity; } else { fim1.New_Quanity = left_new_quanity; } } catch (Exception ex) { string msg = "Error found in GetNewQuantity() : \r\n" + ex.ToString(); Logger.Log(msg, Logger.LogType.Warning); } }
private void Get_Old_Quanity(string txtConetnt, FurtherIssueModel fim1, FurtherIssueModel fim2, int pageNum) { try { Regex r = new Regex("\\s{0,}추가발행수량\\s{1,}(?<OldQuantity>.*?)\\s{0,}\r\n"); MatchCollection mc = r.Matches(txtConetnt); string str_old_quanity = mc[pageNum].Groups["OldQuantity"].Value; String[] old_quanity_array = str_old_quanity.Split(' '); string left_old_quanity; string right_old_quanity = ""; if (old_quanity_array.Count() > 1) { left_old_quanity = old_quanity_array[0].Trim(); right_old_quanity = old_quanity_array[(old_quanity_array.Count() - 1)].Trim(); } else { left_old_quanity = old_quanity_array[0].Trim().ToString(); } if (left_old_quanity != string.Empty && right_old_quanity != string.Empty) { fim1.Old_Quanity = left_old_quanity; fim2.Old_Quanity = right_old_quanity; } else { fim1.Old_Quanity = left_old_quanity; } } catch (Exception ex) { string msg = "Error found in GetOldQuantity() : \r\n" + ex; Logger.Log(msg, Logger.LogType.Warning); } }
private void Get_Ticker(string txtConetnt, FurtherIssueModel fim1, FurtherIssueModel fim2, int pageNum) { try { Regex r = new Regex("\\s{1,}단축코드\\s{1,}(?<ticker>.*?)\\s{0,}\r\n"); MatchCollection mc = r.Matches(txtConetnt); string str_ticker = mc[pageNum].Groups["ticker"].Value; String[] ticker_array = str_ticker.Split(' '); string left_ticker; string right_ticker = ""; if (ticker_array.Count() > 1) { left_ticker = ticker_array[0].Trim(); right_ticker = ticker_array[(ticker_array.Count() - 1)].Trim(); } else { left_ticker = ticker_array[0].Trim(); } if (left_ticker != string.Empty && right_ticker != string.Empty) { fim1.New_Ticker = left_ticker; fim2.New_Ticker = right_ticker; } else { fim1.New_Ticker = left_ticker; } } catch (Exception ex) { string msg = "Error found in GetTicker() : \r\n" + ex; Logger.Log(msg, Logger.LogType.Warning); } }