Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision aee10de2

Von Sven Schöling vor fast 12 Jahren hinzugefügt

  • ID aee10de25a63ec46afee4aec4b50ff509c0dcfd1
  • Vorgänger 3d2fe5b2
  • Nachfolger b6cdc154

Error Reporting, und robuster gegen Fehler im Report save/load

Unterschiede anzeigen:

SL/Controller/CsvImport.pm
8 8
use SL::DB::Unit;
9 9
use SL::DB::Helper::Paginated ();
10 10
use SL::Helper::Flash;
11
use SL::Locale::String;
11 12
use SL::SessionFile;
12 13
use SL::Controller::CsvImport::Contact;
13 14
use SL::Controller::CsvImport::CustomerVendor;
......
100 101
  if ($data->{progress}{finished} || $data->{errors}) {
101 102
    $self->render('csv_import/_deferred_report', { no_layout => 1 });
102 103
  } else {
104
    if (!$self->task_server->is_running) {
105
      $self->task_server->start;
106
      $self->{status_text} = t8('Task Server is not running, starting it now. If this does not change, please check your task server config');
107
    } elsif (my $phase = $data->{progress}{phase}) {
108
      $self->{status_text} = "$data->{progress}{plan}{$phase} / $data->{progress}{num_phases} " . t8($phase);
109
    } else {
110
      $self->{status_text} = t8('Import not started yet, please wait...');
111
    }
112

  
103 113
    $self->render('csv_import/_deferred_results', { no_layout => 1 });
104 114
  }
105 115
}
......
130 140
  my $report_id = $params{report_id} || $::form->{id};
131 141

  
132 142
  $self->{report}      = SL::DB::Manager::CsvImportReport->find_by(id => $report_id);
143

  
144
  if (!$self->{report}) {
145
    $::form->error(t8('No report with id #1', $report_id));
146
  }
133 147
  my $num_rows         = $self->{report}->numrows;
134 148
  my $num_cols         = SL::DB::Manager::CsvImportReportRow->get_all_count(query => [ csv_import_report_id => $report_id, row => 0 ]);
135 149

  
......
384 398
    type       => $self->type,
385 399
    file       => '',
386 400
    numrows    => scalar @{ $self->data },
387
  )->save(cascade => 1);
401
  );
402

  
403
  $report->save(cascade => 1) or die $report->db->error;
388 404

  
389 405
  my $dbh = $::form->get_standard_dbh;
390 406
  $dbh->begin_work;
......
421 437
  my $o2 = $o1 + @methods;
422 438

  
423 439
  for my $row (0 .. $#{ $self->data }) {
424
    $self->track_progress(progress => $row / @{ $self->data } * 100) if $row % 100 == 0;
440
    $self->track_progress(progress => $row / @{ $self->data } * 100) if $row % 1000 == 0;
425 441
    my $data_row = $self->{data}[$row];
426 442

  
427 443
    $sth->execute($report->id,       $_, $row + 1, $data_row->{info_data}{ $info_methods[$_] }) for 0 .. $#info_methods;

Auch abrufbar als: Unified diff