def processForm(self, REQUEST, RESPONSE):
     site = Code(cc('dbsite', '%s' % getDBSite() ) )
     
     res = []
     res.append(head_normal_ohne_help_t %('Stellenabgleich: Ex- und Import von Daten in die Datenbank der ' + site['name']))
     res.append(formexport_t)
     return ''.join(res)
Beispiel #2
0
def dbexport(mit_id):
    opendb()
    site = ebapi.getDBSite()
    site_id = ebapi.cc('dbsite', site)
    export_time = int(time.time())
    export_time_string = time.strftime('%d%m%y-%H%M%S', time.localtime(export_time))
    exportprot = ebapi.Exportprotokoll()
    exportprot.new()
    export_id = exportprot['id']
    this_export_dir = os.path.join(config.INSTANCE_HOME, 'daten', 'export',
                                   'export-%s-%s-%s' %
                                   (site, export_id, export_time_string))
    os.mkdir(this_export_dir,0700)
    
    print "Daten exportieren nach: '%s' ..." % this_export_dir
    
    def dump(klass, dir = this_export_dir, where = '', order = 'id'):
        name = klass.resultClass.table
        # Tabelle aus der Datenbank holen (Tupelliste, *keine* dicts Feldname:Wert)
        table = klass().getTable(where = where, order = order)
        # In eine Datei schreiben
        f = open('%s/%s' % (dir, name), 'wb')
        marshal.dump(table, f)
        f.close()
        
    if site == config.MASTER_SITE:
        dump(ebapi.MitarbeiterList)
        dump(ebapi.CodeList)
    else:
        dump(ebapi.AkteList)
        dump(ebapi.FallList)
        dump(ebapi.BezugspersonList)
        dump(ebapi.EinrichtungskontaktList)
        dump(ebapi.LeistungList)
        dump(ebapi.AnmeldungList)
        dump(ebapi.ZustaendigkeitList)
        dump(ebapi.FachstatistikList)
        dump(ebapi.FachstatistikleistungList)
        dump(ebapi.FachstatistikkindproblemList)
        dump(ebapi.FachstatistikelternproblemList)
        dump(ebapi.JugendhilfestatistikList)
        
    dump(ebapi.ImportprotokollList, where = 'dbsite = %s' % site_id)
    exportprot['dbsite'] = site_id
    exportprot['zeit'] = export_time
    exportprot['mit_id'] = mit_id
    exportprot.insert()
    dump(ebapi.ExportprotokollList, where = 'dbsite = %s' % site_id)
    f = open(os.path.join(this_export_dir, 'export.inf'), 'w')
    f.write("%s\n%s\n%s\n" % (site, str(export_id), str(export_time)))
    f.close()
    print 'Ok'
 def processForm(self, REQUEST, RESPONSE):
     mitarbeiterliste = self.getMitarbeiterliste()
     user = self.user
     site = Code(cc('dbsite', '%s' % getDBSite()))
     
     res = []
     bestaetigung = {'titel':("Bundesjugendhilfestatistik: Exportdatei erstellen der %s" % site['name']),
                     'legende':'Bestätigung des Exportvorgangs',
                     'zeile':'Bitte das Exportjahr eingeben und mit Ok bestätigen!',
                     'jahr' : '%s' % (today().year),
                     'dest_url':'menu'}
     res.append(bestaetigung_t %(bestaetigung))
     return ''.join(res)
Beispiel #4
0
def _dbimport(mit_id, dir, export_site, export_id, export_time):
    print '_dbimport', dir, export_site, export_id
    opendb()
    site = ebapi.getDBSite()
    site_id = ebapi.cc('dbsite', site)
    exp_site = ebapi.cc('dbsite', export_site)
    if site_id == exp_site:
        print "Kein Import von '%s', da selbe Stelle" % dir
        return
    importprot = ebapi.ImportprotokollList(where = "exp_id = %s" % export_id)
    if len(importprot) > 0:
        print "Bereits importiert aus: '%s'" % dir
        return
    print "Daten Importieren aus: '%s' ... " % dir
    
    def load(klass, dir = dir):
        name = klass.resultClass.table
        f = open(os.path.join(dir, name), 'rb')
        table = marshal.load(f)
        klass().updateOrInsertTable(table)
        
    import_time = int(time.time())
    if export_site == config.MASTER_SITE:
        load(ebapi.MitarbeiterList)
        load(ebapi.CodeList)
    else:
        load(ebapi.AkteList)
        load(ebapi.FallList)
        load(ebapi.BezugspersonList)
        load(ebapi.EinrichtungskontaktList)
        load(ebapi.LeistungList)
        load(ebapi.AnmeldungList)
        load(ebapi.ZustaendigkeitList)
        load(ebapi.FachstatistikList)
        load(ebapi.FachstatistikleistungList)
        load(ebapi.FachstatistikkindproblemList)
        load(ebapi.FachstatistikelternproblemList)
        load(ebapi.JugendhilfestatistikList)
        load(ebapi.ImportprotokollList)
    load(ebapi.ExportprotokollList)
    importprot = ebapi.Importprotokoll()
    importprot['exp_id'] = export_id
    importprot['dbsite'] = site_id
    importprot['zeit'] = import_time
    importprot['mit_id'] = mit_id
    importprot.new()
    importprot.insert()
    print 'Ok'
 def processForm(self, REQUEST, RESPONSE):
     import os
     site = Code(cc('dbsite', '%s' % getDBSite()))
     if self.form.has_key('dbexport'):
         arg = self.form.get('dbexport')
     else:
         self.last_error_message = "Kein Jahr erhalten"
         return self.EBKuSError(REQUEST, RESPONSE)
         
     if arg == 'i' or arg == 'e':
         try:
             # TBD: dbexport importieren!
             os.system('python %s/ebkus/app/dbexport.py -%s %s ' % (config.INSTANCE_HOME,
                                                arg, self.mitarbeiter['ben']))
         except Exception, e:
             raise EE("Fehler beim Exportieren: %s") % str(e)