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;
SL/Controller/CsvImport/Part.pm
110 110
  my $i;
111 111
  my $num_data = scalar @{ $self->controller->data };
112 112
  foreach my $entry (@{ $self->controller->data }) {
113
    $self->controller->track_progress(progress => $i/$num_data * 100) if $i % 1000 == 0;
113
    $self->controller->track_progress(progress => $i/$num_data * 100) if $i % 100 == 0;
114 114

  
115 115
    $self->check_buchungsgruppe($entry);
116 116
    $self->check_type($entry);
templates/webpages/csv_import/_deferred_results.html
24 24
  }
25 25
[%- UNLESS SELF.background_job.data_as_hash.errors %]
26 26
  $(document).ready(function(){
27
    $('#progress_description').html('[% SELF.background_job.data_as_hash.progress.plan.${SELF.background_job.data_as_hash.progress.phase} %] / [% SELF.background_job.data_as_hash.progress.num_phases %] [% SELF.background_job.data_as_hash.progress.phase | $T8 | html %]');
27
    $('#progress_description').html('[% SELF.status_text | html %]');
28 28
    $('#progressbar').progressbar({ value: [% SELF.background_job.data_as_hash.progress.progress * 1 %] });
29 29
    window.setTimeout(reload_results, 500);
30 30
  })
templates/webpages/csv_import/form.html
106 106

  
107 107
  <h2>[%- LxERP.t8('Settings') %]</h2>
108 108

  
109
  <div class="settings_toggle"[% UNLESS SELF.deferred || SELF.import_status %] style="display:none"[% END %]>
110
   <a href="#" onClick="javascript:$('.settings_toggle').toggle()">[% LxERP.t8("Show settings") %]</a>
111
  </div>
112

  
113
  <div class="settings_toggle"[% IF SELF.deferred || SELF.import_status %] style="display:none"[% END %]>
114
   <p><a href="#" onClick="javascript:$('.settings_toggle').toggle()">[% LxERP.t8("Hide settings") %]</a></p>
115

  
109 116
  <table>
110 117
   <tr>
111 118
    <th align="right">[%- LxERP.t8('Number Format') %]:</th>
......
221 228

  
222 229
  </table>
223 230

  
231
  </div>
232
  <hr>
233

  
224 234
  [% L.submit_tag('action_test', LxERP.t8('Test and preview')) %]
225 235
  [% L.submit_tag('action_import', LxERP.t8('Import'), style='display:none') %]
226 236

  

Auch abrufbar als: Unified diff