Exemplo n.º 1
0
        /// <summary>
        /// ワーカーを実行する
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            Accessor.Convertor convert = new Accessor.Convertor();
            List <string>      taskIds = (List <string>)e.Argument;
            MigrateTask        task    = null;

            using (SqlAccessor sqlAccessor = Accessor.AccessorFactory.GetSqlAccessor())
            {
                foreach (string id in taskIds)
                {
                    //開始時間
                    DateTime sdate = DateTime.Now;
                    try
                    {
                        task = sqlAccessor.GetMigrateTaskById(id, SqlAccessor.DataKind.All);
                        ProgressReporter reporter = new ProgressReporter(task.TaskName, OnReported);
                        convert.DoConvert(task, reporter);
                        //終了時間
                        DateTime edate = DateTime.Now;
                        sqlAccessor.UpdateMigrate(task, true);
                        Log.Write(task, RSM.GetMessage(RS.Informations.ConvertCompleted, task.TaskName), true, sdate, edate);
                    }
                    catch (Exception)
                    {
                        if (task != null)
                        {
                            sqlAccessor.UpdateMigrate(task, false);
                        }
                        //終了時間
                        DateTime edate = DateTime.Now;
                        Log.Write(task, RSM.GetMessage(RS.Informations.ConvertFailed, task.TaskName), true, sdate, edate);
                        throw;
                    }
                }
            }
        }