// TODO: Fix MarketSpeed Inserterの動作確認。. /// <summary> /// MarketSpeedから取得したデータの挿入 /// </summary> /// <param name="path"></param> private void MSInserter(string path) { var sepapath = path.Split('\\'); if (sepapath.Count() < 1) { return; } string filename = sepapath[sepapath.Count() - 1]; DateTime date; string datestr = filename.Substring(0, 12); try { date = new DateTime(int.Parse(datestr.Substring(0, 4)), int.Parse(datestr.Substring(4, 2)), int.Parse(datestr.Substring(6, 2)), int.Parse(datestr.Substring(8, 2)), int.Parse(datestr.Substring(10, 2)), 0); } catch { return; } using (StreamReader sr = new StreamReader(path, Encoding.GetEncoding(932))) { double counter = 0; string line = ""; while ((line = sr.ReadLine()) != null) { counter++; if (counter <= 1) { continue; } var sepa = line.Split(','); if (sepa[0].Length != 4) { continue; throw new Exception("不明な銘柄コードが検出されました。\r\n" + "銘柄コード:" + sepa[0]); } StockDataFull.StockDataFullDataTable dt = new StockDataFull.StockDataFullDataTable(); var row = dt.NewRow() as StockDataFull.StockDataFullRow; StockDataConverter.ConvertToDBFormat("", "銘柄コード", sepa[0], row); StockDataConverter.ConvertToDBFormat("", "市場コード", sepa[1], row); StockDataConverter.ConvertToDBFormat("", "銘柄名称", sepa[2], row); StockDataConverter.ConvertToDBFormat("", "市場名称", sepa[3], row); StockDataConverter.ConvertToDBFormat("", "市場部名称", sepa[4], row); StockDataConverter.ConvertToDBFormat("", "市場部略称", sepa[5], row); StockDataConverter.ConvertToDBFormat("", "現在日付", sepa[6], row); StockDataConverter.ConvertToDBFormat("", "現在値", sepa[7], row); StockDataConverter.ConvertToDBFormat("", "前日比", sepa[8], row); StockDataConverter.ConvertToDBFormat("", "前日比率", sepa[9], row); StockDataConverter.ConvertToDBFormat("", "前日終値", sepa[10], row); StockDataConverter.ConvertToDBFormat("", "前日日付", sepa[11], row); StockDataConverter.ConvertToDBFormat("", "出来高", sepa[12], row); StockDataConverter.ConvertToDBFormat("", "売買代金", sepa[13], row); StockDataConverter.ConvertToDBFormat("", "出来高加重平均", sepa[14], row); StockDataConverter.ConvertToDBFormat("", "始値", sepa[15], row); StockDataConverter.ConvertToDBFormat("", "高値", sepa[16], row); StockDataConverter.ConvertToDBFormat("", "安値", sepa[17], row); StockDataConverter.ConvertToDBFormat("", "始値時刻", sepa[18], row); StockDataConverter.ConvertToDBFormat("", "高値時刻", sepa[19], row); StockDataConverter.ConvertToDBFormat("", "安値時刻", sepa[20], row); StockDataConverter.ConvertToDBFormat("", "前場出来高", sepa[21], row); StockDataConverter.ConvertToDBFormat("", "信用貸借区分", sepa[22], row); StockDataConverter.ConvertToDBFormat("", "逆日歩", sepa[23], row); StockDataConverter.ConvertToDBFormat("", "逆日歩更新日付", sepa[24], row); StockDataConverter.ConvertToDBFormat("", "信用売残", sepa[25], row); StockDataConverter.ConvertToDBFormat("", "信用売残前週比", sepa[26], row); StockDataConverter.ConvertToDBFormat("", "信用買残", sepa[27], row); StockDataConverter.ConvertToDBFormat("", "信用買残前週比", sepa[28], row); StockDataConverter.ConvertToDBFormat("", "信用倍率", sepa[29], row); StockDataConverter.ConvertToDBFormat("", "証金コード", sepa[30], row); StockDataConverter.ConvertToDBFormat("", "証金残更新日付", sepa[31], row); StockDataConverter.ConvertToDBFormat("", "新規貸株", sepa[32], row); StockDataConverter.ConvertToDBFormat("", "新規融資", sepa[33], row); StockDataConverter.ConvertToDBFormat("", "返済貸株", sepa[34], row); StockDataConverter.ConvertToDBFormat("", "返済融資", sepa[35], row); StockDataConverter.ConvertToDBFormat("", "残高貸株", sepa[36], row); StockDataConverter.ConvertToDBFormat("", "残高融資", sepa[37], row); StockDataConverter.ConvertToDBFormat("", "残高差引", sepa[38], row); StockDataConverter.ConvertToDBFormat("", "前日比貸株", sepa[39], row); StockDataConverter.ConvertToDBFormat("", "前日比融資", sepa[40], row); StockDataConverter.ConvertToDBFormat("", "前日比差引", sepa[41], row); StockDataConverter.ConvertToDBFormat("", "回転日数", sepa[42], row); StockDataConverter.ConvertToDBFormat("", "貸借倍率", sepa[43], row); StockDataConverter.ConvertToDBFormat("", "単位株数", sepa[44], row); StockDataConverter.ConvertToDBFormat("", "配当", sepa[45], row); StockDataConverter.ConvertToDBFormat("", "配当落日", sepa[46], row); StockDataConverter.ConvertToDBFormat("", "権利落日", sepa[47], row); StockDataConverter.ConvertToDBFormat("", "PER", sepa[48], row); StockDataConverter.ConvertToDBFormat("", "PBR", sepa[49], row); StockDataConverter.ConvertToDBFormat("", "年初来高値", sepa[50], row); StockDataConverter.ConvertToDBFormat("", "年初来安値", sepa[51], row); StockDataConverter.ConvertToDBFormat("", "年初来高値日付", sepa[52], row); StockDataConverter.ConvertToDBFormat("", "年初来安値日付", sepa[53], row); StockDataConverter.ConvertToDBFormat("", "上場来高値", sepa[54], row); StockDataConverter.ConvertToDBFormat("", "上場来安値", sepa[55], row); StockDataConverter.ConvertToDBFormat("", "上場来高値日付", sepa[56], row); StockDataConverter.ConvertToDBFormat("", "上場来安値日付", sepa[57], row); try { StartInsert ( date, row.銘柄コード, row.市場コード, row.Is銘柄名称Null() ? null : row.銘柄名称, row.Is市場名称Null() ? null : row.市場名称, row.Is市場部名称Null() ? null : row.市場部名称, row.Is市場部略称Null() ? null : row.市場部略称, row.現在日付, row.Is現在値Null() ? (double?)null : row.現在値, row.Is前日比Null() ? (double?)null : row.前日比, row.Is前日比率Null() ? (double?)null : row.前日比率, row.Is前日終値Null() ? (double?)null : row.前日終値, row.Is前日日付Null() ? (DateTime?)null : row.前日日付, row.Is出来高Null() ? (double?)null : row.出来高, row.Is売買代金Null() ? (double?)null : row.売買代金, row.Is出来高加重平均Null() ? (double?)null : row.出来高加重平均, row.Is始値Null() ? (double?)null : row.始値, row.Is高値Null() ? (double?)null : row.高値, row.Is安値Null() ? (double?)null : row.安値, row.Is始値時刻Null() ? (DateTime?)null : row.始値時刻, row.Is高値時刻Null() ? (DateTime?)null : row.高値時刻, row.Is安値時刻Null() ? (DateTime?)null : row.安値時刻, row.Is前場出来高Null() ? (double?)null : row.前場出来高, row.Is信用貸借区分Null() ? null : row.信用貸借区分, row.Is逆日歩Null() ? (double?)null : row.逆日歩, row.Is逆日歩更新日付Null() ? (DateTime?)null : row.逆日歩更新日付, row.Is信用売残Null() ? (double?)null : row.信用売残, row.Is信用売残前週比Null() ? (double?)null : row.信用売残前週比, row.Is信用買残Null() ? (double?)null : row.信用買残, row.Is信用買残前週比Null() ? (double?)null : row.信用買残前週比, row.Is信用倍率Null() ? (double?)null : row.信用倍率, row.Is証金コードNull() ? null : row.証金コード, row.Is証金残更新日付Null() ? (DateTime?)null : row.証金残更新日付, row.Is新規貸株Null() ? (double?)null : row.新規貸株, row.Is新規融資Null() ? (double?)null : row.新規融資, row.Is返済貸株Null() ? (double?)null : row.返済貸株, row.Is返済融資Null() ? (double?)null : row.返済融資, row.Is残高貸株Null() ? (double?)null : row.残高貸株, row.Is残高融資Null() ? (double?)null : row.残高融資, row.Is残高差引Null() ? (double?)null : row.残高差引, row.Is前日比貸株Null() ? (double?)null : row.前日比貸株, row.Is前日比融資Null() ? (double?)null : row.前日比融資, row.Is前日比差引Null() ? (double?)null : row.前日比差引, row.Is回転日数Null() ? (double?)null : row.回転日数, row.Is貸借倍率Null() ? (double?)null : row.貸借倍率, row.Is単位株数Null() ? (double?)null : row.単位株数, row.Is配当Null() ? (double?)null : row.配当, row.Is配当落日Null() ? (DateTime?)null : row.配当落日, row.Is権利落日Null() ? (DateTime?)null : row.権利落日, row.IsPERNull() ? (double?)null : row.PER, row.IsPBRNull() ? (double?)null : row.PBR, row.Is年初来高値Null() ? (double?)null : row.年初来高値, row.Is年初来安値Null() ? (double?)null : row.年初来安値, row.Is年初来高値日付Null() ? (DateTime?)null : row.年初来高値日付, row.Is年初来安値日付Null() ? (DateTime?)null : row.年初来安値日付, row.Is上場来高値Null() ? (double?)null : row.場来高値, row.Is上場来安値Null() ? (double?)null : row.場来安値, row.Is上場来高値日付Null() ? (DateTime?)null : row.場来高値日付, row.Is上場来安値日付Null() ? (DateTime?)null : row.場来安値日付 ); } catch (Exception ex) { continue; } System.Diagnostics.Debug.WriteLine(string.Format("銘柄:{0}.{1} {2} 現在値:{3}", row.銘柄コード, row.市場コード, row.Is銘柄名称Null() ? "DBNull" : row.銘柄名称.ToString(), row.Is現在値Null() ? "DBNull" : row.現在値.ToString())); } } string destipath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), Path.Combine(HSTStockDataStream.Properties.Settings.Default.InsertCompleteFolderPathFromDesktop, filename)); File.Move(path, destipath); StockDataデータ挿入履歴Inserter(date, DateTime.Now); }
public static StockDataFull.StockDataFullDataTable GetStockDatas(List <string> topicslist, List <string> itemslist) { ResetMSandRSS(); StockDataFull.StockDataFullDataTable dt = new StockDataFull.StockDataFullDataTable(); int counter = 0; try { foreach (var topic in topicslist) { // DateTime start = DateTime.Now; int errorcounter = 0; StockDataFull.StockDataFullRow row = dt.NewRow() as StockDataFull.StockDataFullRow; using (DdeClient client = new DdeClient("RSS", topic)) { foreach (var item in itemslist) { // System.Diagnostics.Debug.WriteLine(item); counter++; string name = null; NDde.DdeException ddeex = null; for (int i = 0; i < 5; i++) { try { name = Request(topic, item, client); } catch (NDde.DdeException e) { errorcounter++; if (errorcounter == 5) { ddeex = e; //continue; break; } if (e.Message.Contains("The client failed to request") || e.Message.Contains("The client failed to connect")) { // 最後は例外入れる if (i == 4) { ddeex = e; // continue; break; } continue; } else { ddeex = e; //continue; break; } } break; } if (ddeex != null) { // throw ddeex; break; } if (name == null) { //continue; break; // throw new Exception("Request中に予期せぬ例外が発生しました。"); } StockDataConverter.ConvertToDBFormat(topic, item, name, row); } } try { dt.AddStockDataFullRow(row); } catch { continue; } #region DebugWriteline System.Diagnostics.Debug.WriteLine( string.Format ( "count:{58} 銘柄コード:{0},市場コード:{1},銘柄名称:{2},市場名称:{3},市場部名称:{4},市場部略称:{5},現在日付:{6},現在値:{7},前日比:{8},前日比率:{9},前日終値:{10},前日日付:{11},出来高:{12},売買代金:{13},出来高加重平均:{14},始値:{15},高値:{16},安値:{17},始値時刻:{18},高値時刻:{19},安値時刻:{20},前場出来高:{21},信用貸借区分:{22},逆日歩:{23},逆日歩更新日付:{24},信用売残:{25},信用売残前週比:{26},信用買残:{27},信用買残前週比:{28},信用倍率:{29},証金コード:{30},証金残更新日付:{31},新規貸株:{32},新規融資:{33},返済貸株:{34},返済融資:{35},残高貸株:{36},残高融資:{37},残高差引:{38},前日比貸株:{39},前日比融資:{40},前日比差引:{41},回転日数:{42},貸借倍率:{43},単位株数:{44},配当:{45},配当落日:{46},権利落日:{47},PER:{48},PBR:{49},年初来高値:{50},年初来安値:{51},年初来高値日付:{52},年初来安値日付:{53},上場来高値:{54},上場来安値:{55},上場来高値日付:{56},上場来安値日付{57}", row.銘柄コード.ToString(), row.市場コード.ToString(), row.Is銘柄名称Null() ? "DBnull" : row.銘柄名称.ToString(), row.Is市場名称Null() ? "DBnull" : row.市場名称.ToString(), row.Is市場部名称Null() ? "DBnull" : row.市場部名称.ToString(), row.Is市場部略称Null() ? "DBnull" : row.市場部略称.ToString(), row.現在日付.ToString(), row.Is現在値Null() ? "DBnull" : row.現在値.ToString(), row.Is前日比Null() ? "DBnull" : row.前日比.ToString(), row.Is前日比率Null() ? "DBnull" : row.前日比率.ToString(), row.Is前日終値Null() ? "DBnull" : row.前日終値.ToString(), row.Is前日日付Null() ? "DBnull" : row.前日日付.ToString(), row.Is出来高Null() ? "DBnull" : row.出来高.ToString(), row.Is売買代金Null() ? "DBnull" : row.売買代金.ToString(), row.Is出来高加重平均Null() ? "DBnull" : row.出来高加重平均.ToString(), row.Is始値Null() ? "DBnull" : row.始値.ToString(), row.Is高値Null() ? "DBnull" : row.高値.ToString(), row.Is安値Null() ? "DBnull" : row.安値.ToString(), row.Is始値時刻Null() ? "DBnull" : row.始値時刻.ToString(), row.Is高値時刻Null() ? "DBnull" : row.高値時刻.ToString(), row.Is安値時刻Null() ? "DBnull" : row.安値時刻.ToString(), row.Is前場出来高Null() ? "DBnull" : row.前場出来高.ToString(), row.Is信用貸借区分Null() ? "DBnull" : row.信用貸借区分.ToString(), row.Is逆日歩Null() ? "DBnull" : row.逆日歩.ToString(), row.Is逆日歩更新日付Null() ? "DBnull" : row.逆日歩更新日付.ToString(), row.Is信用売残Null() ? "DBnull" : row.信用売残.ToString(), row.Is信用売残前週比Null() ? "DBnull" : row.信用売残前週比.ToString(), row.Is信用買残Null() ? "DBnull" : row.信用買残.ToString(), row.Is信用買残前週比Null() ? "DBnull" : row.信用買残前週比.ToString(), row.Is信用倍率Null() ? "DBnull" : row.信用倍率.ToString(), row.Is証金コードNull() ? "DBnull" : row.証金コード.ToString(), row.Is証金残更新日付Null() ? "DBnull" : row.証金残更新日付.ToString(), row.Is新規貸株Null() ? "DBnull" : row.新規貸株.ToString(), row.Is新規融資Null() ? "DBnull" : row.新規融資.ToString(), row.Is返済貸株Null() ? "DBnull" : row.返済貸株.ToString(), row.Is返済融資Null() ? "DBnull" : row.返済融資.ToString(), row.Is残高貸株Null() ? "DBnull" : row.残高貸株.ToString(), row.Is残高融資Null() ? "DBnull" : row.残高融資.ToString(), row.Is残高差引Null() ? "DBnull" : row.残高差引.ToString(), row.Is前日比貸株Null() ? "DBnull" : row.前日比貸株.ToString(), row.Is前日比融資Null() ? "DBnull" : row.前日比融資.ToString(), row.Is前日比差引Null() ? "DBnull" : row.前日比差引.ToString(), row.Is回転日数Null() ? "DBnull" : row.回転日数.ToString(), row.Is貸借倍率Null() ? "DBnull" : row.貸借倍率.ToString(), row.Is単位株数Null() ? "DBnull" : row.単位株数.ToString(), row.Is配当Null() ? "DBnull" : row.配当.ToString(), row.Is配当落日Null() ? "DBnull" : row.配当落日.ToString(), row.Is権利落日Null() ? "DBnull" : row.権利落日.ToString(), row.IsPERNull() ? "DBnull" : row.PER.ToString(), row.IsPBRNull() ? "DBnull" : row.PBR.ToString(), row.Is年初来高値Null() ? "DBnull" : row.年初来高値.ToString(), row.Is年初来安値Null() ? "DBnull" : row.年初来安値.ToString(), row.Is年初来高値日付Null() ? "DBnull" : row.年初来高値日付.ToString(), row.Is年初来安値日付Null() ? "DBnull" : row.年初来安値日付.ToString(), row.Is上場来高値Null() ? "DBnull" : row.場来高値.ToString(), row.Is上場来安値Null() ? "DBnull" : row.場来安値.ToString(), row.Is上場来高値日付Null() ? "DBnull" : row.場来高値日付.ToString(), row.Is上場来安値日付Null() ? "DBnull" : row.場来安値日付.ToString(), counter ) ); #endregion //DateTime end = DateTime.Now; //var span = end - start; //System.Diagnostics.Debug.WriteLine(span.TotalSeconds); } } catch (Exception e) { throw e; } return(dt); }
public static void MarketSpeedDataWriteToCSV(DateTime date, StockDataFull.StockDataFullDataTable dt) { string SAVE_DESTINATION = string.Format(@"{0}\{1}_StockAllData_MS.csv", Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), HSTStockDataStream.Properties.Settings.Default.DownloadFolderPathFromDesktop), date.ToString("yyyyMMddHHmm")); using (StreamWriter sw = new StreamWriter(SAVE_DESTINATION, false, Encoding.GetEncoding(932))) { // ヘッダー sw.WriteLine("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17},{18},{19},{20},{21},{22},{23},{24},{25},{26},{27},{28},{29},{30},{31},{32},{33},{34},{35},{36},{37},{38},{39},{40},{41},{42},{43},{44},{45},{46},{47},{48},{49},{50},{51},{52},{53},{54},{55},{56},{57}", "銘柄コード", "市場コード", "銘柄名称", "市場名称", "市場部名称", "市場部略称", "現在日付", "現在値", "前日比", "前日比率", "前日終値", "前日日付", "出来高", "売買代金", "出来高加重平均", "始値", "高値", "安値", "始値時刻", "高値時刻", "安値時刻", "前場出来高", "信用貸借区分", "逆日歩", "逆日歩更新日付", "信用売残", "信用売残前週比", "信用買残", "信用買残前週比", "信用倍率", "証金コード", "証金残更新日付", "新規貸株", "新規融資", "返済貸株", "返済融資", "残高貸株", "残高融資", "残高差引", "前日比貸株", "前日比融資", "前日比差引", "回転日数", "貸借倍率", "単位株数", "配当", "配当落日", "権利落日", "PER", "PBR", "年初来高値", "年初来安値", "年初来高値日付", "年初来安値日付", "上場来高値", "上場来安値", "上場来高値日付", "上場来安値日付" ); foreach (var row in dt) { sw.WriteLine ( "{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17},{18},{19},{20},{21},{22},{23},{24},{25},{26},{27},{28},{29},{30},{31},{32},{33},{34},{35},{36},{37},{38},{39},{40},{41},{42},{43},{44},{45},{46},{47},{48},{49},{50},{51},{52},{53},{54},{55},{56},{57}", row.銘柄コード.ToString(), row.市場コード.ToString(), row.Is銘柄名称Null() ? "-" : row.銘柄名称.ToString(), row.Is市場名称Null() ? "-" : row.市場名称.ToString(), row.Is市場部名称Null() ? "-" : row.市場部名称.ToString(), row.Is市場部略称Null() ? "-" : row.市場部略称.ToString(), row.現在日付.ToString(), row.Is現在値Null() ? "-" : row.現在値.ToString(), row.Is前日比Null() ? "-" : row.前日比.ToString(), row.Is前日比率Null() ? "-" : row.前日比率.ToString(), row.Is前日終値Null() ? "-" : row.前日終値.ToString(), row.Is前日日付Null() ? "-" : row.前日日付.ToString(), row.Is出来高Null() ? "-" : row.出来高.ToString(), row.Is売買代金Null() ? "-" : row.売買代金.ToString(), row.Is出来高加重平均Null() ? "-" : row.出来高加重平均.ToString(), row.Is始値Null() ? "-" : row.始値.ToString(), row.Is高値Null() ? "-" : row.高値.ToString(), row.Is安値Null() ? "-" : row.安値.ToString(), row.Is始値時刻Null() ? "-" : row.始値時刻.ToString(), row.Is高値時刻Null() ? "-" : row.高値時刻.ToString(), row.Is安値時刻Null() ? "-" : row.安値時刻.ToString(), row.Is前場出来高Null() ? "-" : row.前場出来高.ToString(), row.Is信用貸借区分Null() ? "-" : row.信用貸借区分.ToString(), row.Is逆日歩Null() ? "-" : row.逆日歩.ToString(), row.Is逆日歩更新日付Null() ? "-" : row.逆日歩更新日付.ToString(), row.Is信用売残Null() ? "-" : row.信用売残.ToString(), row.Is信用売残前週比Null() ? "-" : row.信用売残前週比.ToString(), row.Is信用買残Null() ? "-" : row.信用買残.ToString(), row.Is信用買残前週比Null() ? "-" : row.信用買残前週比.ToString(), row.Is信用倍率Null() ? "-" : row.信用倍率.ToString(), row.Is証金コードNull() ? "-" : row.証金コード.ToString(), row.Is証金残更新日付Null() ? "-" : row.証金残更新日付.ToString(), row.Is新規貸株Null() ? "-" : row.新規貸株.ToString(), row.Is新規融資Null() ? "-" : row.新規融資.ToString(), row.Is返済貸株Null() ? "-" : row.返済貸株.ToString(), row.Is返済融資Null() ? "-" : row.返済融資.ToString(), row.Is残高貸株Null() ? "-" : row.残高貸株.ToString(), row.Is残高融資Null() ? "-" : row.残高融資.ToString(), row.Is残高差引Null() ? "-" : row.残高差引.ToString(), row.Is前日比貸株Null() ? "-" : row.前日比貸株.ToString(), row.Is前日比融資Null() ? "-" : row.前日比融資.ToString(), row.Is前日比差引Null() ? "-" : row.前日比差引.ToString(), row.Is回転日数Null() ? "-" : row.回転日数.ToString(), row.Is貸借倍率Null() ? "-" : row.貸借倍率.ToString(), row.Is単位株数Null() ? "-" : row.単位株数.ToString(), row.Is配当Null() ? "-" : row.配当.ToString(), row.Is配当落日Null() ? "-" : row.配当落日.ToString(), row.Is権利落日Null() ? "-" : row.権利落日.ToString(), row.IsPERNull() ? "-" : row.PER.ToString(), row.IsPBRNull() ? "-" : row.PBR.ToString(), row.Is年初来高値Null() ? "-" : row.年初来高値.ToString(), row.Is年初来安値Null() ? "-" : row.年初来安値.ToString(), row.Is年初来高値日付Null() ? "-" : row.年初来高値日付.ToString(), row.Is年初来安値日付Null() ? "-" : row.年初来安値日付.ToString(), row.Is上場来高値Null() ? "-" : row.場来高値.ToString(), row.Is上場来安値Null() ? "-" : row.場来安値.ToString(), row.Is上場来高値日付Null() ? "-" : row.場来高値日付.ToString(), row.Is上場来安値日付Null() ? "-" : row.場来安値日付.ToString() ); } } }
// TODO: MarketSpeedで取得したデータでイレギュラーデータの形式を確認 public static void ConvertToDBFormat(string topic, string item, string value, StockDataFull.StockDataFullRow row) { StockDataFull.StockDataFullDataTable dt = new StockDataFull.StockDataFullDataTable(); var t = dt.Columns[item].DataType; try { //始値時刻などが09:00の様な時刻形式であることを確認 //パターンは"\d\d-\d\d"とも書ける if (Regex.IsMatch(value, @"^\d\d:\d\d$") && t == typeof(DateTime)) { row[item] = new DateTime(row.現在日付.Year, row.現在日付.Month, row.現在日付.Day, int.Parse(value.Split(':')[0]), int.Parse(value.Split(':')[1]), 0); } else if (value == " - - " && t == typeof(DateTime)) { row[item] = new DateTime(1900, 1, 1); } // 現在値、始値などが"-"の場合 else if ((value == "-") && t == typeof(Double)) { row[item] = DBNull.Value; } else { var val = Convert.ChangeType(value, t); row[item] = val; } } catch (Exception e) { if (t == typeof(DateTime)) { row[item] = new DateTime(1900, 1, 1); } else { System.Diagnostics.Debug.WriteLine(string.Format("Error! \r\ntopic:{0} item:{1} value:{2}\r\n{3}\r\n{4}", topic, item, value, e.Message, e.StackTrace)); row[item] = DBNull.Value; } } #region スニペット //if (item == "銘柄コード") //{ //} //else if (item == "市場コード") //{ //} //else if (item == "銘柄名称") //{ //} //else if (item == "市場名称") //{ //} //else if (item == "市場部名称") //{ //} //else if (item == "市場部略称") //{ //} //else if (item == "現在日付") //{ //} //else if (item == "現在値") //{ //} //else if (item == "前日比") //{ //} //else if (item == "前日比率") //{ //} //else if (item == "前日終値") //{ //} //else if (item == "前日日付") //{ //} //else if (item == "出来高") //{ //} //else if (item == "売買代金") //{ //} //else if (item == "出来高加重平均") //{ //} //else if (item == "始値") //{ //} //else if (item == "高値") //{ //} //else if (item == "安値") //{ //} //else if (item == "始値時刻") //{ //} //else if (item == "高値時刻") //{ //} //else if (item == "安値時刻") //{ //} //else if (item == "前場出来高") //{ //} //else if (item == "信用貸借区分") //{ //} //else if (item == "逆日歩") //{ //} //else if (item == "逆日歩更新日付") //{ //} //else if (item == "信用売残") //{ //} //else if (item == "信用売残前週比") //{ //} //else if (item == "信用買残") //{ //} //else if (item == "信用買残前週比") //{ //} //else if (item == "信用倍率") //{ //} //else if (item == "証金コード") //{ //} //else if (item == "証金残更新日付") //{ //} //else if (item == "新規貸株") //{ //} //else if (item == "新規融資") //{ //} //else if (item == "返済貸株") //{ //} //else if (item == "返済融資") //{ //} //else if (item == "残高貸株") //{ //} //else if (item == "残高融資") //{ //} //else if (item == "残高差引") //{ //} //else if (item == "前日比貸株") //{ //} //else if (item == "前日比融資") //{ //} //else if (item == "前日比差引") //{ //} //else if (item == "回転日数") //{ //} //else if (item == "貸借倍率") //{ //} //else if (item == "単位株数") //{ //} //else if (item == "配当") //{ //} //else if (item == "配当落日") //{ //} //else if (item == "権利落日") //{ //} //else if (item == "PER") //{ //} //else if (item == "PBR") //{ //} //else if (item == "年初来高値") //{ //} //else if (item == "年初来安値") //{ //} //else if (item == "年初来高値日付") //{ //} //else if (item == "年初来安値日付") //{ //} //else if (item == "上場来高値") //{ //} //else if (item == "上場来安値") //{ //} //else if (item == "上場来高値日付") //{ //} //else if (item == "上場来安値日付") //{ //} //else //{ // throw new Exception("存在しないitemの為、処理を中断します。"); //} #endregion }