Beispiel #1
0
        void setDataSE(ClassCSV cCSV, string retbuff, long rowTarget)
        {
            long rowWrite;

            JVData_Struct.JV_SE_RACE_UMA mSeData =
                new JVData_Struct.JV_SE_RACE_UMA();
            mSeData.SetDataB(ref retbuff);
            if (int.Parse(mSeData.head.DataKubun) == 3 ||
                int.Parse(mSeData.head.DataKubun) == 4 ||
                int.Parse(mSeData.head.DataKubun) == 5 ||
                int.Parse(mSeData.head.DataKubun) == 6 ||
                int.Parse(mSeData.head.DataKubun) == 7)
            {
                rowWrite = rowTarget + 1 + int.Parse(mSeData.Umaban);
                cCSV.setData(rowWrite, 11,
                             (int.Parse(mSeData.KakuteiJyuni)).ToString());
            }
        }
Beispiel #2
0
        /// <summary>
        /// JVReading処理
        /// </summary>
        /// <param name="endDate">終了日</param>
        public static void JVReading(string endDate)
        {
            bool reading = true;
            int nCount = 0;
            object buffObj = new byte[0];
            int buffsize = 110000;
            string endTimeStamp = endDate + "235959";
            string timeStamp;
            string buffname;

            if (JVDataAccessType == eJVDataAccessType.eRACE)
            {
                ProgressUserState.Maxinum = ReadCount;
                ProgressUserState.Value = 0;
                ProgressUserState.Text = "データ読み込み中...";
                MainBackgroundWorker.ReportProgress(0, ProgressUserState);
            }

            do
            {
                //---------------------
                // JVLink読込み処理
                //---------------------
                buffObj = new byte[0];
                int nRet = AxJVLink.JVGets(ref buffObj, buffsize, out buffname);
                timeStamp = AxJVLink.m_CurrentFileTimeStamp;
                byte[] buff = (byte[])buffObj;
                string buffStr = System.Text.Encoding.GetEncoding(932).GetString(buff);

                // 正常
                if (0 < nRet)
                {
                    string recordSpec = JVData_Struct.MidB2S(ref buff, 1, 2);
                    buffObj = new byte[0];
                    buff = new byte[0];

                    if (0 <= endTimeStamp.CompareTo(timeStamp))
                    {
                        switch (recordSpec)
                        {
                            case "RA":
                                JVData_Struct.JV_RA_RACE race = new JVData_Struct.JV_RA_RACE();
                                race.SetDataB(ref buffStr);
                                OutputRaceData(eOutput.Umanushi, race);
                                break;

                            case "SE":
                                JVData_Struct.JV_SE_RACE_UMA raceUma = new JVData_Struct.JV_SE_RACE_UMA();
                                raceUma.SetDataB(ref buffStr);
                                OutputRaceUmaData(eOutput.Umanushi, raceUma);
                                break;

                            default:
                                if (JVDataAccessType == eJVDataAccessType.eRACE)
                                {
                                    // 対象外recspecのファイルをスキップする。
                                    AxJVLink.JVSkip();
                                    nCount++;
                                    ProgressUserState.Value = nCount;
                                    ProgressUserState.Text = "データ読み込み中...";
                                    MainBackgroundWorker.ReportProgress(0, ProgressUserState);
                                }
                                break;
                        }
                    }
                    else
                    {
                        // 対象外recspecのファイルをスキップする。
                        AxJVLink.JVSkip();
                        nCount++;
                        ProgressUserState.Value = nCount;
                        ProgressUserState.Text = "データ読み込み中...";
                        MainBackgroundWorker.ReportProgress(0, ProgressUserState);
                    }
                }
                // ファイルの切れ目
                else if (-1 == nRet)
                {
                    if (JVDataAccessType == eJVDataAccessType.eRACE)
                    {
                        nCount++;
                        ProgressUserState.Value = nCount;
                        ProgressUserState.Text = "データ読み込み中...";
                        MainBackgroundWorker.ReportProgress(0, ProgressUserState);
                    }
                }
                // 全レコード読込み終了(EOF)
                else if (0 == nRet)
                {
                    if (JVDataAccessType == eJVDataAccessType.eRACE)
                    {
                        ProgressUserState.Value = ProgressUserState.Maxinum;
                        ProgressUserState.Text = "データ読み込み完了";
                        MainBackgroundWorker.ReportProgress(0, ProgressUserState);
                    }

                    reading = false;
                }
                // エラー
                else if (-1 > nRet)
                {
                    // エラーファイルをスキップする。
                    AxJVLink.JVSkip();
                    nCount++;
                    ProgressUserState.Value = nCount;
                    ProgressUserState.Text = "データ読み込み中...";
                    MainBackgroundWorker.ReportProgress(0, ProgressUserState);
                }

                System.Threading.Thread.Sleep(10);
            }
            while (true == reading);
        }
Beispiel #3
0
        bool getDbDataJvLink(DateTime datetimeTarg, List <string> listdbDate)
        {
            JVData_Struct.JV_RA_RACE     jvRaRace    = new JVData_Struct.JV_RA_RACE();
            JVData_Struct.JV_SE_RACE_UMA jvSeRaceUma = new JVData_Struct.JV_SE_RACE_UMA();
            string   retbuff;
            long     cntLoop     = 0;
            bool     isExistData = false;
            int      size        = 40000;
            int      count       = 256;
            int      option;
            string   strDate;
            double   bunbo;
            DateTime DateTimeStart;

            if (listdbDate.Count > 0)
            {
                strDate       = listdbDate[listdbDate.Count - 1];
                DateTimeStart = DateTime.Parse(listdbDate[listdbDate.Count - 1].Insert(4, "/").Insert(7, "/"));
                option        = 1;
            }
            else
            {
                TimeSpan timeSpan = new TimeSpan(365 * 4, 0, 0, 0); //365*4
                strDate       = (datetimeTarg - timeSpan).ToString("yyyyMMdd");
                DateTimeStart = datetimeTarg - timeSpan;
                option        = 4;
            }
            bunbo = (datetimeTarg - DateTimeStart).TotalDays;

            _form1.prgJVRead.Maximum = 100;
            _form1.prgJVRead.Value   = 0;
            if (!cCommon.isJVOpen("RACE", strDate, option))
            {
                return(false);
            }

            do
            {
                retbuff = cCommon.loopJVRead(size, count, true);
                if (retbuff == "" || retbuff == "END")
                {
                    break;
                }
                if (retbuff.Substring(0, 2) == "RA")
                {
                    jvRaRace.SetDataB(ref retbuff);

                    // 中央競馬以外は除外
                    int intJyoCD;
                    if (!int.TryParse(jvRaRace.id.JyoCD, out intJyoCD))
                    {
                        continue;
                    }
                    else if (intJyoCD < 1 || intJyoCD > 10)
                    {
                        continue;
                    }

                    // プログレスバー更新
                    DateTime dateTimeJv = DateTime.Parse((retbuff.Substring(11, 8)).Insert(4, "/").Insert(7, "/"));
                    if (dateTimeJv > datetimeTarg)
                    {
                        continue;
                    }
                    double bunshi = (dateTimeJv - DateTimeStart).TotalDays;
                    if (bunshi < 0)
                    {
                        bunshi = 0;
                    }
                    _form1.prgJVRead.Value = (int)(bunshi / bunbo * 100);
                    if (_form1.prgJVRead.Value < _form1.prgJVRead.Maximum)
                    {
                        _form1.prgJVRead.Value++;
                        _form1.prgJVRead.Value--;
                    }
                    _form1.rtbData.Text = jvRaRace.id.Year + jvRaRace.id.MonthDay;
                    _form1.rtbData.Refresh();

                    // DBにデータがある場合は除外
                    if (isExistDateList(listdbDate, jvRaRace.id.Year + jvRaRace.id.MonthDay))
                    {
                        isExistData = true;
                        //_form1.axJVLink1.JVSkip();
                        continue;
                    }

                    isExistData = false;

                    // テキストボックス更新
                    string codeName = this.objCodeConv.GetCodeName("2001", jvRaRace.id.JyoCD, 1);
                    _form1.rtbData.Text = jvRaRace.id.Year +
                                          jvRaRace.id.MonthDay + " " +
                                          codeName + " " +
                                          "取得中";
                    _form1.rtbData.Refresh();

                    listRaceInfo.Add(new clsDbInfo()
                    {
                        strdate = jvRaRace.id.Year + jvRaRace.id.MonthDay,
                        nameJyo = codeName,
                        racenum = jvRaRace.id.RaceNum,
                        raceId  = jvRaRace.id.Year + jvRaRace.id.MonthDay +
                                  jvRaRace.id.JyoCD + jvRaRace.id.RaceNum,
                    });
                }
                else if (retbuff.Substring(0, 2) == "SE")
                {
                    if (isExistData)
                    {
                        _form1.axJVLink1.JVSkip();
                        continue;
                    }
                    jvSeRaceUma.SetDataB(ref retbuff);

                    // 中央競馬以外は除外
                    int intJyoCD;
                    if (!int.TryParse(jvSeRaceUma.id.JyoCD, out intJyoCD))
                    {
                        continue;
                    }
                    else if (intJyoCD < 1 || intJyoCD > 10)
                    {
                        continue;
                    }

                    string codeName = objCodeConv.GetCodeName("2001", jvSeRaceUma.id.JyoCD, 1);
                    foreach (clsDbInfo RaceInfo in listRaceInfo)
                    {
                        if (RaceInfo.strdate ==
                            jvSeRaceUma.id.Year + jvSeRaceUma.id.MonthDay &&
                            RaceInfo.nameJyo == codeName &&
                            RaceInfo.racenum == jvSeRaceUma.id.RaceNum)
                        {
                            listdbInfo.Add(new clsDbInfo()
                            {
                                strdate = RaceInfo.strdate,
                                nameJyo = RaceInfo.nameJyo,
                                racenum = RaceInfo.racenum,
                                Bamei   = jvSeRaceUma.Bamei.Trim(),
                                Umaban  = jvSeRaceUma.Umaban,
                                raceId  = RaceInfo.raceId,
                            });
                            break;
                        }
                    }
                }
                else
                {
                    _form1.axJVLink1.JVSkip();
                }
                cntLoop++;
            }while (cntLoop <= 1000000);
            _form1.prgJVRead.Maximum++;
            _form1.prgJVRead.Value =
                _form1.prgJVRead.Maximum;
            _form1.prgJVRead.Maximum--;

            int retJVClose = _form1.axJVLink1.JVClose();

            if (retJVClose != 0)
            {
                return(false);
            }

            return(true);
        }
Beispiel #4
0
        private List <cRaceUma> GetRaceUmaX(DateTime datetimeTarg, string collplace, string collRace)
        {
            List <cRaceUma> cRaceUmaList = new List <cRaceUma>();

            try
            {
                int size  = 110000;
                int count = 256;
                JVData_Struct.JV_SE_RACE_UMA jvSeRaceUma = new JVData_Struct.JV_SE_RACE_UMA();
                this.tmrDownload.Enabled = false;
                this.prgJVRead.Value     = 0;
                string   dataspec      = "RACE";
                TimeSpan timeSpan      = new TimeSpan(1, 0, 0, 0);
                string   str           = (datetimeTarg - timeSpan).ToString("yyyyMMdd");
                int      option        = DateTime.Now > datetimeTarg.AddYears(1) ? 4 : 1;
                int      readcount     = 0;
                int      downloadcount = 0;
                int      num1          = this.AxJVLink1.JVOpen(dataspec, str + "000000", option, ref readcount, ref downloadcount, out string _);
                if (num1 != 0)
                {
                    int num2 = (int)MessageBox.Show("JVOpen エラー:" + (object)num1);
                }
                else
                {
                    this.prgJVRead.Maximum = readcount;
                    if (readcount > 0)
                    {
                        bool flag1 = false;
                        bool flag2 = false;
                        do
                        {
                            System.Windows.Forms.Application.DoEvents();
                            string buff     = new string(char.MinValue, size);
                            string filename = new string(char.MinValue, count);
                            switch (this.AxJVLink1.JVRead(out buff, out size, out filename))
                            {
                            case -503:
                                int num3 = (int)MessageBox.Show(filename + "が存在しません。");
                                flag1 = true;
                                goto case -3;

                            case -203:
                                int num4 = (int)MessageBox.Show("JVOpen が行われていません。");
                                flag1 = true;
                                goto case -3;

                            case -201:
                                int num5 = (int)MessageBox.Show("JVInit が行われていません。");
                                flag1 = true;
                                goto case -3;

                            case -3:
                                continue;

                            case -1:
                                ++this.prgJVRead.Value;
                                goto case -3;

                            case 0:
                                this.prgJVRead.Value = this.prgJVRead.Maximum;
                                flag1 = true;
                                goto case -3;

                            default:
                                if (buff.Substring(0, 2) == "SE")
                                {
                                    jvSeRaceUma.SetDataB(ref buff);
                                    string   s        = (jvSeRaceUma.id.Year + jvSeRaceUma.id.MonthDay).Insert(4, "/").Insert(7, "/");
                                    DateTime dateTime = DateTime.Parse(s);
                                    if (flag2 && dateTime > datetimeTarg)
                                    {
                                        flag1 = true;
                                    }
                                    if (s == datetimeTarg.ToString("yyyy/MM/dd"))
                                    {
                                        string codeName = this.objCodeConv.GetCodeName("2001", jvSeRaceUma.id.JyoCD, (short)1);
                                        if (collplace == codeName && collRace == jvSeRaceUma.id.RaceNum)
                                        {
                                            flag2 = true;
                                            cRaceUmaList.Add(new cRaceUma()
                                            {
                                                strdate  = jvSeRaceUma.id.Year + jvSeRaceUma.id.MonthDay,
                                                nameJyo  = codeName,
                                                racenum  = jvSeRaceUma.id.RaceNum,
                                                KettoNum = jvSeRaceUma.KettoNum,
                                                Bamei    = jvSeRaceUma.Bamei.Trim(),
                                                Umaban   = jvSeRaceUma.Umaban
                                            });
                                            goto case -3;
                                        }
                                        else
                                        {
                                            goto case -3;
                                        }
                                    }
                                    else
                                    {
                                        goto case -3;
                                    }
                                }
                                else
                                {
                                    this.AxJVLink1.JVSkip();
                                    goto case -3;
                                }
                            }
                        }while (!flag1);
                    }
                }
            }
            catch (Exception ex)
            {
                return((List <cRaceUma>)null);
            }
            int num6 = this.AxJVLink1.JVClose();

            if (num6 != 0)
            {
                int num7 = (int)MessageBox.Show("JVClose エラー:" + (object)num6);
            }
            this.prgJVRead.Value = this.prgJVRead.Maximum;
            return(cRaceUmaList);
        }
Beispiel #5
0
        private int JvReadFuncToRCOVData()
        {
            String  buff       = null;
            int     buffsize   = 2000;
            String  fName      = null;
            int     skipCount  = 0;
            int     boolStatus = 0;
            Boolean eof        = false;

            do
            {
                int ret = JvMain.ReadJv(out buff, out buffsize, out fName);

                if (ret == -1)
                {
                    /* ファイルの切り替え */
                    if (eof == true)
                    {
                        break;
                    } //2日分の開催データ取得完了

                    JvMain.SkipJv();
                }
                else if (buff == null)
                {
                    break;  //エラー
                }
                else if (ret == 0)
                {
                    if (eof == true)
                    {
                        /* ファイル読み込みの終了 */
                        break;
                    }
                    else
                    {
                        skipCount++;        //3回以上スキップしたら終了する。
                        JvMain.SkipJv();
                        continue;
                    }
                }
                if (buff == null)
                {
                    JvMain.SkipJv();
                    continue;
                }

                JvRaceDataMasterStructures MasterDataSe = new JvRaceDataMasterStructures();
                switch (buff.Substring(0, 2))
                {
                case "SE":
                    /* 相手馬 */
                    JVData_Struct.JV_SE_RACE_UMA Se = new JVData_Struct.JV_SE_RACE_UMA();

                    Se.SetDataB(ref buff);
                    MasterDataSe.Common.Waku   = Int32.Parse(Se.Wakuban);
                    MasterDataSe.Common.Umaban = Int32.Parse(Se.Umaban);
                    MasterDataSe.Common.Bamei  = Se.Bamei;
                    MasterDataSe.Common.Jokkey = Se.KisyuRyakusyo;
                    MasterDataSe.Common.Omosa  = Int32.Parse(Se.Futan);
                    MasterDataSe.Rank          = Se.KakuteiJyuni;
                    if (Se.KakuteiJyuni.Equals("01"))
                    {
                        MasterDataSe.AiteUma = "(" + Se.ChakuUmaInfo[0].Bamei + ")";
                    }
                    else
                    {
                        MasterDataSe.AiteUma = Se.ChakuUmaInfo[0].Bamei;
                    }
                    MasterDataSe.Bataiju     = Se.BaTaijyu;
                    MasterDataSe.Zougen      = Se.ZogenFugo;            /* + - */
                    MasterDataSe.BataijuDiff = Se.ZogenSa;

                    MasterDataSe.final3F        = Se.HaronTimeL3;
                    MasterDataSe.DiffTime       = Se.TimeDiff;
                    MasterDataSe.Conner.conner1 = Int32.Parse(Se.Jyuni1c);
                    MasterDataSe.Conner.conner2 = Int32.Parse(Se.Jyuni2c);
                    MasterDataSe.Conner.conner3 = Int32.Parse(Se.Jyuni3c);
                    MasterDataSe.Conner.conner4 = Int32.Parse(Se.Jyuni4c);
                    MasterDataSe.Time           = Se.Time;


                    tmpFormPerfomanceSE.Add(MasterDataSe);
                    break;

                case "RA":
                    /* 頭数・馬場状態 */
                    JVData_Struct.JV_RA_RACE Race = new JVData_Struct.JV_RA_RACE();
                    Race.SetDataB(ref buff);
                    String TrackCD = Race.TenkoBaba.SibaBabaCD + Race.TenkoBaba.DirtBabaCD;
                    MasterDataSe.SyusouTosu = Int32.Parse(Race.SyussoTosu);
                    MasterDataSe.BabaJotai  = TrackCD;

                    tmpFormPerfomanceRA.Add(MasterDataSe);
                    break;

                case "UM":
                    JVData_Struct.JV_UM_UMA    Uma        = new JVData_Struct.JV_UM_UMA();
                    JvRaceDataMasterStructures MasterData = new JvRaceDataMasterStructures();
                    Uma.SetDataB(ref buff);
                    MasterDataSe.Common.Bamei = Uma.Bamei;
                    MasterDataSe.Blood.fHorse = Uma.Ketto3Info[0].Bamei;
                    MasterDataSe.Blood.mHours = Uma.Ketto3Info[1].Bamei;
                    MasterDataSe.Blood.BMS    = Uma.Ketto3Info[4].Bamei;
                    MasterDataSe.Blood.BMS1   = Uma.Ketto3Info[12].Bamei;
                    tmpFormPerfomance.Add(MasterDataSe);
                    break;
                }
            }while (boolStatus == 0 && skipCount < 10);

            /* 結合処理を加える */
            //  JointmpFormPerfomanceData();
            return(0);
        }
        bool setDataSE(ClassCSV cCSV, string retbuff, DateTime datetimeTarg, bool isFind)
        {
            DateTime dateTime;
            string   strShortJyo;
            string   strJyo;
            long     rowTarget;
            long     rowWrite;
            long     rowadj;
            int      zogensa;

            JVData_Struct.JV_SE_RACE_UMA mSeData =
                new JVData_Struct.JV_SE_RACE_UMA();
            mSeData.SetDataB(ref retbuff);
            dateTime = DateTime.Parse(
                (mSeData.id.Year +
                 mSeData.id.MonthDay).Insert(4, "/").Insert(7, "/"));
            if (isFind && dateTime > datetimeTarg)
            {
                return(true);
            }
            if (dateTime.ToShortDateString() != datetimeTarg.ToShortDateString())
            {
                return(false);
            }
            string codeName = objCodeConv.GetCodeName("2001",
                                                      mSeData.id.JyoCD, 1);

            strJyo = cCommon.JyoCord(mSeData.id.JyoCD);
            if (strJyo == "")
            {
                return(false);
            }
            strShortJyo = cCommon.Jyo2ShortJyo(strJyo);
            if (strShortJyo == "")
            {
                return(false);
            }
            rowTarget = cCSV.getDataRow(strShortJyo,
                                        int.Parse(mSeData.id.RaceNum));
            // 馬体重
            rowadj = long.Parse(mSeData.Umaban) + 1;
            cCSV.setData(rowTarget + rowadj, 29, mSeData.BaTaijyu);
            if (mSeData.ZogenSa.Contains(" "))
            {
                zogensa = 0;
            }
            else
            {
                zogensa = int.Parse(mSeData.ZogenSa);
            }
            if (zogensa == 999)
            {
                cCSV.setData(rowTarget + rowadj, 30, "0");
            }
            else if (zogensa == 0)
            {
                cCSV.setData(rowTarget + rowadj, 30, "0");
            }
            else
            {
                cCSV.setData(rowTarget + rowadj, 30,
                             mSeData.ZogenFugo + String.Format("{0, 2}", zogensa));
            }
            // 着順
            if (int.Parse(mSeData.head.DataKubun) >= 5)
            {
                rowWrite = rowTarget + 1 + long.Parse(mSeData.Umaban);
                cCSV.setData(rowWrite, 11, (int.Parse(mSeData.KakuteiJyuni)).ToString());
            }

            return(false);
        }
Beispiel #7
-1
        /// <summary>
        /// JVUmaReadWriting処理
        /// </summary>
        public static void JVUmaReadWriting()
        {
            bool reading = true;
            int nCount = 0;
            object buffObj = new byte[0];
            int buffsize = 110000;
            string timeStamp;
            string buffname;
            DataTable umaDataTable = new DataTable();
            DataTable raceDataTable = new DataTable();
            DataTable raceUmaDataTable = new DataTable();

            // 初期化時
            if (JVRelayClass.Option == (int)JVRelayClass.eJVOpenFlag.SetupSkipDialog)
            {
                using (SQLiteCommand command = DbConn.CreateCommand())
                {
                    command.CommandText = "DELETE FROM uma";
                    command.ExecuteNonQuery();
                }
            }

            using (SQLiteCommand command = DbConn.CreateCommand())
            {
                command.CommandText = "SELECT * FROM uma";
                using (SQLiteDataAdapter da = new SQLiteDataAdapter(command))
                {
                    da.Fill(umaDataTable);
                }
            }
            raceDataTable.Columns.Add("RaceKey", typeof(string));
            raceDataTable.Columns.Add("RaceDate", typeof(string));
            raceDataTable.Columns.Add("DataKubun", typeof(string));
            raceDataTable.Columns.Add("GradeCD", typeof(string));
            raceDataTable.Columns.Add("SyubetuCD", typeof(string));
            raceUmaDataTable.Columns.Add("RaceKey", typeof(string));
            raceUmaDataTable.Columns.Add("RaceDate", typeof(string));
            raceUmaDataTable.Columns.Add("KettoNum", typeof(string));
            raceUmaDataTable.Columns.Add("KakuteiJyuni", typeof(string));

            if (umaDataTable.PrimaryKey.Length == 0)
            {
                umaDataTable.PrimaryKey = new[] { umaDataTable.Columns["KettoNum"] };
            }
            if (raceDataTable.PrimaryKey.Length == 0)
            {
                raceDataTable.PrimaryKey = new[] { raceDataTable.Columns["RaceKey"] };
            }
            if (raceUmaDataTable.PrimaryKey.Length == 0)
            {
                raceUmaDataTable.PrimaryKey = new[] { raceUmaDataTable.Columns["RaceKey"], raceUmaDataTable.Columns["KettoNum"] };
            }

            ProgressUserState.Maxinum = ReadCount;
            ProgressUserState.Value = 0;
            ProgressUserState.Text = "データ読み込み中...";
            MainBackgroundWorker.ReportProgress(0, ProgressUserState);

            do
            {
                //---------------------
                // JVLink読込み処理
                //---------------------
                buffObj = new byte[0];
                int nRet = AxJVLink.JVGets(ref buffObj, buffsize, out buffname);
                timeStamp = AxJVLink.m_CurrentFileTimeStamp;
                byte[] buff = (byte[])buffObj;
                string buffStr = System.Text.Encoding.GetEncoding(932).GetString(buff);

                // 正常
                if (0 < nRet)
                {
                    string recordSpec = JVData_Struct.MidB2S(ref buff, 1, 2);
                    buffObj = new byte[0];
                    buff = new byte[0];

                    switch (recordSpec)
                    {
                        case "UM":
                            {
                                JVData_Struct.JV_UM_UMA uma = new JVData_Struct.JV_UM_UMA();
                                uma.SetDataB(ref buffStr);
                                WriteDbUmaData(eOutput.Umanushi, uma, umaDataTable);
                            }
                            break;
                        case "RA":
                            {
                                JVData_Struct.JV_RA_RACE race = new JVData_Struct.JV_RA_RACE();
                                race.SetDataB(ref buffStr);
                                WriteDbRaceData(eOutput.Umanushi, race, raceDataTable);
                            }
                            break;
                        case "SE":
                            {
                                JVData_Struct.JV_SE_RACE_UMA raceUma = new JVData_Struct.JV_SE_RACE_UMA();
                                raceUma.SetDataB(ref buffStr);
                                WriteDbRaceUmaData(eOutput.Umanushi, raceUma, raceUmaDataTable);
                            }
                            break;
                        default:
                            // 対象外recspecのファイルをスキップする。
                            AxJVLink.JVSkip();
                            nCount++;
                            ProgressUserState.Value = nCount;
                            ProgressUserState.Text = "データ読み込み中...";
                            MainBackgroundWorker.ReportProgress(0, ProgressUserState);
                            break;
                    }
                }
                // ファイルの切れ目
                else if (-1 == nRet)
                {
                    nCount++;
                    ProgressUserState.Value = nCount;
                    ProgressUserState.Text = "データ読み込み中...";
                    MainBackgroundWorker.ReportProgress(0, ProgressUserState);
                }
                // 全レコード読込み終了(EOF)
                else if (0 == nRet)
                {
                    ProgressUserState.Value = ProgressUserState.Maxinum;
                    ProgressUserState.Text = "データ読み込み完了";
                    MainBackgroundWorker.ReportProgress(0, ProgressUserState);

                    reading = false;
                }
                // エラー
                else if (-1 > nRet)
                {
                    // エラーファイルをスキップする。
                    AxJVLink.JVSkip();
                    nCount++;
                    ProgressUserState.Value = nCount;
                    ProgressUserState.Text = "データ読み込み中...";
                    MainBackgroundWorker.ReportProgress(0, ProgressUserState);
                }

                System.Threading.Thread.Sleep(10);
            }
            while (true == reading);

            // データ整備
            if (raceUmaDataTable.Rows.Count > 0)
            {
                foreach (DataRow raceUmaDataRow in raceUmaDataTable.Select("", "RaceDate"))
                {
                    DataRow raceDataRow = raceDataTable.Rows.Find(raceUmaDataRow["RaceKey"]);
                    DataRow umaDataRow = umaDataTable.Rows.Find(raceUmaDataRow["KettoNum"]);
                    if (raceDataRow != null && umaDataRow != null)
                    {
                        string raceDate = umaDataRow["RaceDate"].ToString();
                        if ("" == raceDate || 0 > raceDate.CompareTo(raceUmaDataRow["RaceDate"].ToString()))
                        {
                            if (raceDataRow["DataKubun"].ToString() != "9" && raceDataRow["DataKubun"].ToString() != "0")
                            {
                                // レースを追加
                                umaDataRow["BeforeUmaClass"] = umaDataRow["UmaClass"];
                                umaDataRow["BeforeRaceDate"] = umaDataRow["RaceDate"];
                                umaDataRow["BeforeRaceDataKubun"] = umaDataRow["RaceDataKubun"];
                                umaDataRow["BeforeRaceGradeCD"] = umaDataRow["RaceGradeCD"];
                                umaDataRow["BeforeRaceSyubetuCD"] = umaDataRow["RaceSyubetuCD"];
                                umaDataRow["BeforeRaceKakuteiJyuni"] = umaDataRow["RaceKakuteiJyuni"];

                                umaDataRow["RaceDate"] = raceUmaDataRow["RaceDate"];
                                umaDataRow["RaceDataKubun"] = raceDataRow["DataKubun"];
                                umaDataRow["RaceGradeCD"] = raceDataRow["GradeCD"];
                                umaDataRow["RaceSyubetuCD"] = raceDataRow["SyubetuCD"];
                                umaDataRow["RaceKakuteiJyuni"] = raceUmaDataRow["KakuteiJyuni"];
                                umaDataRow["UmaClass"] = GetUmaClass(umaDataRow);
                            }
                        }
                        else if (0 == raceDate.CompareTo(raceUmaDataRow["RaceDate"].ToString()))
                        {
                            if (raceDataRow["DataKubun"].ToString() == "9" || raceDataRow["DataKubun"].ToString() == "0")
                            {
                                // レース中止、データ削除のため戻す
                                umaDataRow["UmaClass"] = umaDataRow["BeforeUmaClass"];
                                umaDataRow["RaceDate"] = umaDataRow["BeforeRaceDate"];
                                umaDataRow["RaceDataKubun"] = umaDataRow["BeforeRaceDataKubun"];
                                umaDataRow["RaceGradeCD"] = umaDataRow["BeforeRaceGradeCD"];
                                umaDataRow["RaceSyubetuCD"] = umaDataRow["BeforeRaceSyubetuCD"];
                                umaDataRow["RaceKakuteiJyuni"] = umaDataRow["BeforeRaceKakuteiJyuni"];

                                umaDataRow["BeforeUmaClass"] = null;
                                umaDataRow["BeforeRaceDate"] = null;
                                umaDataRow["BeforeRaceDataKubun"] = null;
                                umaDataRow["BeforeRaceGradeCD"] = null;
                                umaDataRow["BeforeRaceSyubetuCD"] = null;
                                umaDataRow["BeforeRaceKakuteiJyuni"] = null;
                            }
                            else
                            {
                                // レース結果の更新
                                if (umaDataRow["RaceDataKubun"].ToString() != raceDataRow["DataKubun"].ToString())
                                {
                                    umaDataRow["RaceDataKubun"] = raceDataRow["DataKubun"];
                                }
                                if (umaDataRow["RaceGradeCD"].ToString() != raceDataRow["GradeCD"].ToString())
                                {
                                    umaDataRow["RaceGradeCD"] = raceDataRow["GradeCD"];
                                }
                                if (umaDataRow["RaceSyubetuCD"].ToString() != raceDataRow["SyubetuCD"].ToString())
                                {
                                    umaDataRow["RaceSyubetuCD"] = raceDataRow["SyubetuCD"];
                                }
                                if (umaDataRow["RaceKakuteiJyuni"].ToString() != raceUmaDataRow["KakuteiJyuni"].ToString())
                                {
                                    umaDataRow["RaceKakuteiJyuni"] = raceUmaDataRow["KakuteiJyuni"];
                                }
                                if (umaDataRow["UmaClass"].ToString() != GetUmaClass(umaDataRow))
                                {
                                    umaDataRow["UmaClass"] = GetUmaClass(umaDataRow);
                                }
                            }
                        }
                    }
                }
            }

            // データ更新
            using (SQLiteTransaction tran = DbConn.BeginTransaction())
            {
                using (SQLiteCommand command = DbConn.CreateCommand())
                {
                    command.Transaction = tran;
                    command.CommandText = "SELECT * FROM uma";
                    using (SQLiteDataAdapter da = new SQLiteDataAdapter(command))
                    using (SQLiteCommandBuilder cb = new SQLiteCommandBuilder(da))
                    {
                        cb.SetAllValues = false;
                        cb.ConflictOption = ConflictOption.OverwriteChanges;
                        da.UpdateCommand = cb.GetUpdateCommand();
                        da.InsertCommand = cb.GetInsertCommand();
                        da.DeleteCommand = cb.GetDeleteCommand();
                        da.Update(umaDataTable);
                    }

                    command.CommandText = "DELETE FROM uma WHERE BirthYear <= '" + DiscardBirthYear + "'";
                    command.ExecuteNonQuery();

                    command.CommandText = "UPDATE timestamp SET date ='" + LastFileTimestamp + "'";
                    command.ExecuteNonQuery();
                }
                tran.Commit();
                JVRelayClass.DbTimeStamp = LastFileTimestamp;
            }
        }