Anlage des Repos
This commit is contained in:
535
archive/Zeiterfassung/07.12.2021/Zeiterfassung2.py
Normal file
535
archive/Zeiterfassung/07.12.2021/Zeiterfassung2.py
Normal file
@@ -0,0 +1,535 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Digital Data - Zeiterfassung
|
||||
# ----------------------------------------------------------------------------
|
||||
# Python-Script zur Buchung von Zeiten via QR/Barcode-Scanner inkl. Anbindung
|
||||
# an die Mesonic WinLine. Per tkinter-Bibliothek wird eine GUI erzeugt.
|
||||
# Via Webservice-Calls erfolgen verschiedene Abfragen.
|
||||
#
|
||||
# ----------------------------------------------------------------------------
|
||||
# Copyright (c) 2021 by Digital Data GmbH
|
||||
#
|
||||
# Digital Data GmbH • Ludwig-Rinn-Strasse 16 • D-35452 Heuchelheim
|
||||
# Tel.: 0641/202360 • E-Mail: info-flow@digitaldata.works
|
||||
# ----------------------------------------------------------------------------
|
||||
# Creation Date / Author: 15.09.2021 / MD
|
||||
# Version Date / Editor: 06.12.2021 / MD
|
||||
# Version Number: 1.1.0
|
||||
|
||||
|
||||
####################################
|
||||
# # Import # #
|
||||
####################################
|
||||
|
||||
import tkinter as tk
|
||||
|
||||
from datetime import datetime
|
||||
import cv2
|
||||
import numpy as np
|
||||
from pyzbar.pyzbar import decode
|
||||
import requests
|
||||
import configparser
|
||||
import cryptocode
|
||||
import logging
|
||||
from logging.handlers import TimedRotatingFileHandler
|
||||
from logging import Formatter
|
||||
|
||||
#####################################
|
||||
# # Server-Options # #
|
||||
# # In DD-Time.ini bearbeitbar # #
|
||||
#####################################
|
||||
config = configparser.ConfigParser()
|
||||
config.sections()
|
||||
config.read('DD-Time.ini')
|
||||
|
||||
###############################################
|
||||
|
||||
WebServiceURL = config['WEBSERVICE']['WebServiceURL']
|
||||
WebServiceBenutzerName = config['WEBSERVICE']['WebServiceBenutzerName']
|
||||
WebServiceBenutzerPasswort = config['WEBSERVICE']['WebServiceBenutzerPasswort']
|
||||
WinLineMandant = config['WEBSERVICE']['WinLineMandant']
|
||||
WebServiceTemplateSTART = config['WEBSERVICE']['WebServiceTemplateSTART']
|
||||
WebServiceTemplateSTOP = config['WEBSERVICE']['WebServiceTemplateSTOP']
|
||||
WebServiceType = config['WEBSERVICE']['WebServiceType']
|
||||
Fehlzeitenstamm = config['WEBSERVICE']['Fehlzeitenstamm']
|
||||
WeekRule = config['PAUSEKEYRULE']['WeekRule']
|
||||
WebServiceActioncode = "1"
|
||||
|
||||
###############################################
|
||||
|
||||
TextDayStart = config['STARTBUTTON']['TextDayStart']
|
||||
ColorTextStartButton = config['STARTBUTTON']['ColorText']
|
||||
BackgroundStartButton = config['STARTBUTTON']['ColorBackground']
|
||||
ColorPressedStartButton = config['STARTBUTTON']['ColorPressed']
|
||||
|
||||
###############################################
|
||||
|
||||
TextDayEnd = config['ENDBUTTON']['TextDayEnd']
|
||||
ColorTextEndButton = config['ENDBUTTON']['ColorText']
|
||||
BackgroundEndButton = config['ENDBUTTON']['ColorBackground']
|
||||
ColorPressedEndButton = config['ENDBUTTON']['ColorPressed']
|
||||
|
||||
###############################################
|
||||
|
||||
TextBreakStart = config['PAUSEBUTTON']['TextBreakStart']
|
||||
ColorTextPauseButton = config['PAUSEBUTTON']['ColorText']
|
||||
BackgroundPauseButton = config['PAUSEBUTTON']['ColorBackground']
|
||||
ColorPressedPauseButton = config['PAUSEBUTTON']['ColorPressed']
|
||||
|
||||
###############################################
|
||||
|
||||
TextBreakEnd = config['ENDPAUSEBUTTON']['TextBreakEnd']
|
||||
ColorTextEndPauseButton = config['ENDPAUSEBUTTON']['ColorText']
|
||||
BackgroundEndPauseButton = config['ENDPAUSEBUTTON']['ColorBackground']
|
||||
ColorPressedEndPauseButton = config['ENDPAUSEBUTTON']['ColorPressed']
|
||||
|
||||
###############################################
|
||||
|
||||
TextDefault = config['LABEL']['TextDefault']
|
||||
TextStart = config['LABEL']['TextStart']
|
||||
TextEnd = config['LABEL']['TextEnd']
|
||||
TextPauseStart = config['LABEL']['TextPauseStart']
|
||||
TextPauseEnd = config['LABEL']['TextPauseEnd']
|
||||
TextErrorStart = config['LABEL']['TextErrorStart']
|
||||
TextErrorEnd = config['LABEL']['TextErrorEnd']
|
||||
TextErrorPause = config['LABEL']['TextErrorPause']
|
||||
TextErrorPauseEnd = config['LABEL']['TextErrorPauseEnd']
|
||||
TextWorkday = config['LABEL']['TextWorkday']
|
||||
TextPause = config['LABEL']['TextPause']
|
||||
|
||||
###############################################
|
||||
|
||||
TimeToScan = int(config['TIMETOSCAN']['TimeToScan'])
|
||||
|
||||
###############################################
|
||||
|
||||
TimeToShowScreens = int(config['TIMETOSHOWSCREENS']['TimeToShowScreens'])
|
||||
|
||||
###############################################
|
||||
|
||||
Height = int(config['SCANWINDOWSIZE']['Height'])
|
||||
Width = int(config['SCANWINDOWSIZE']['Width'])
|
||||
|
||||
###############################################
|
||||
|
||||
TextStartButton = TextWorkday + NewLine + TextDayStart
|
||||
TextEndButton = TextWorkday + NewLine + TextDayEnd
|
||||
TextPauseButton = TextPause + NewLine + TextBreakStart
|
||||
TextEndPauseButton = TextPause + NewLine + TextBreakEnd
|
||||
|
||||
###############################################
|
||||
|
||||
Path = config['LOGGING']['Path']
|
||||
When = config['LOGGING']['When']
|
||||
Interval = int(config['LOGGING']['Interval'])
|
||||
BackupCount = int(config['LOGGING']['BackupCount'])
|
||||
Encoding = config['LOGGING']['Encoding']
|
||||
|
||||
###############################################
|
||||
|
||||
NewLine = "\n"
|
||||
dePW = cryptocode.decrypt(WebServiceBenutzerPasswort, "Zeiterfassung")
|
||||
|
||||
|
||||
class App(tk.Tk):
|
||||
|
||||
def showError(self, exc, val, tb):
|
||||
#showerror("Error", message=str(val))
|
||||
self.logger.error('')
|
||||
self.logger.error(exc)
|
||||
self.logger.error(val)
|
||||
self.logger.error(tb)
|
||||
|
||||
############################################
|
||||
# # Frame # #
|
||||
# Erstellt die GUI inkl. Button und Labels #
|
||||
############################################
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
# LOG-File-Generator
|
||||
self.logger = logging.getLogger('mylogger')
|
||||
self.handler = TimedRotatingFileHandler(filename=Path, when=When, interval=int(Interval), backupCount=int(BackupCount), encoding=Encoding, delay=False)
|
||||
|
||||
formatter = Formatter(fmt='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||
self.handler.setFormatter(formatter)
|
||||
|
||||
self.logger.addHandler(self.handler)
|
||||
self.logger.setLevel(logging.DEBUG)
|
||||
###############################################
|
||||
self.configure(bg="white")
|
||||
self.title("DD-Zeiterfassung")
|
||||
self.geometry("1024x768")
|
||||
#self.attributes("-topmost", True) -- tkinter gui immer im vordergrund
|
||||
#self.wm_overrideredirect(True) -- tkinter gui ohne Titlezeile
|
||||
self.wm_attributes('-type', 'splash') # -- tkinter gui Titelzeile klappt sich ein
|
||||
|
||||
self.start_button = tk.Button(self, font=('Arial', 12), text=TextStartButton, height =15, width=15, fg=ColorTextStartButton, bg=BackgroundStartButton, activebackground=ColorPressedStartButton, command=self.Startbutton_action)
|
||||
self.stop_button = tk.Button(self, font=('Arial', 12), text=TextEndButton, height =15, width=15, fg=ColorTextEndButton, bg=BackgroundEndButton, activebackground=ColorPressedEndButton, command=self.Stopbutton_action)
|
||||
self.pause_button = tk.Button(self, font=('Arial', 12), text=TextPauseButton, height=15, width=15, fg=ColorTextPauseButton, bg=BackgroundPauseButton, activebackground=ColorPressedPauseButton, command=self.PauseStartbutton_action)
|
||||
self.pause_end_button = tk.Button(self, font=('Arial', 12), text=TextEndPauseButton, height=15, width=15, fg=ColorTextEndPauseButton, bg=BackgroundEndPauseButton, activebackground=ColorPressedEndPauseButton, command=self.PauseStopbutton_action)
|
||||
self.anweisungs_label = tk.Label(self, font=('Arial', 12), text=TextDefault)
|
||||
self.anweisungs_label2 = tk.Label(self, font=('Arial', 12), bg="white", fg="black")
|
||||
|
||||
self.labelUhr = tk.Label(text="", font=('Arial', 12), fg='red')
|
||||
self.update_clock()
|
||||
|
||||
self.labelUhr.grid(row=0,column=4)
|
||||
self.anweisungs_label.grid(row=0, column=2, pady=20, padx=10, sticky='ew')
|
||||
self.anweisungs_label2.grid(row=1, column=2, pady=20, padx=10, sticky='ew')
|
||||
self.start_button.grid(row=2, column=1, pady=20, padx=10, sticky='ew')
|
||||
self.stop_button.grid(row=2, column=2, pady=20, padx=10, sticky='ew')
|
||||
self.pause_button.grid(row=2, column=3, pady=20, padx=10, sticky='ew')
|
||||
self.pause_end_button.grid(row=2, column=4, pady=20, padx=10, sticky='ew')
|
||||
self.report_callback_exception = self.showError
|
||||
|
||||
self.logger.info("Initialisierung abgeschlossen!")
|
||||
|
||||
########################################
|
||||
# # Button-Action # #
|
||||
# # Legende # #
|
||||
# RequestTyp = 1 = Arbeitstag beginnen #
|
||||
# RequestTyp = 2 = Arbeitstag beenden #
|
||||
# RequestTyp = 3 = Pause beginnen #
|
||||
# RequestTyp = 4 = Pause beenden #
|
||||
########################################
|
||||
|
||||
#####################################
|
||||
# # Different-Buttons # #
|
||||
#####################################
|
||||
def update_clock(self):
|
||||
now = datetime.now()
|
||||
clock = now.strftime('%H:%M:%S')
|
||||
self.labelUhr.configure(text=clock)
|
||||
self.after(1000, self.update_clock)
|
||||
|
||||
###############################################
|
||||
|
||||
def Startbutton_action(self):
|
||||
RequestTyp = 1
|
||||
self.Button_action(RequestTyp)
|
||||
|
||||
###############################################
|
||||
|
||||
def Stopbutton_action(self):
|
||||
RequestTyp = 2
|
||||
self.Button_action(RequestTyp)
|
||||
|
||||
###############################################
|
||||
|
||||
def PauseStartbutton_action(self):
|
||||
RequestTyp = 3
|
||||
self.Button_action(RequestTyp)
|
||||
|
||||
###############################################
|
||||
|
||||
def PauseStopbutton_action(self):
|
||||
RequestTyp = 4
|
||||
self.Button_action(RequestTyp)
|
||||
|
||||
|
||||
###############################################
|
||||
|
||||
def Button_action(self, RequestTyp):
|
||||
myData = Scanner(self)
|
||||
print(myData)
|
||||
#myDataListe = myData.split("-")
|
||||
now = datetime.now()
|
||||
actDateTime = now.strftime('%Y-%m-%d') + "T" + now.strftime('%H:%M:%S')
|
||||
MakeWinLineRequest(self, RequestTyp, myData, actDateTime, now)
|
||||
|
||||
|
||||
######################################
|
||||
# # Reset der GUI # #
|
||||
######################################
|
||||
def LabelReset(self):
|
||||
|
||||
anweisungs_label = tk.Label(font=('Arial', 12), text=TextDefault)
|
||||
anweisungs_label.grid(row=0, column=2, sticky='ew')
|
||||
anweisungs_label2 = tk.Label(font=('Arial', 12), bg="white", text="")
|
||||
anweisungs_label2.grid(row=1, column=2, sticky='ew')
|
||||
self.configure(bg="white")
|
||||
app.event_generate('<Motion>', warp=True, x=1, y=1) # Set the Mouse-Position to x/y
|
||||
|
||||
######################################
|
||||
# # Build Start-XML # #
|
||||
######################################
|
||||
def BuildXMLStart(RequestTyp, myData, Datumvon):
|
||||
if RequestTyp == 1:
|
||||
ArbeitsZeitPause = "0"
|
||||
Fehlzeitenstamm =config['WEBSERVICE']['Fehlzeitenstamm']
|
||||
|
||||
else:
|
||||
ArbeitsZeitPause = "1"
|
||||
if WeekRule == 'on':
|
||||
Weekday = datetime.today().isoweekday()
|
||||
Fehlzeitenstamm = config['PAUSEKEYRULE']['Weekday' + str(Weekday)]
|
||||
else:
|
||||
Fehlzeitenstamm = "1"
|
||||
myDataListe = myData.split("-")
|
||||
AN_Gruppe_Ressource = myDataListe[0]
|
||||
XML_Start = ""
|
||||
XML_Start = XML_Start + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
||||
XML_Start = XML_Start + "<MESOWebService TemplateType=\"" + WebServiceType + "\"" " Template=\"" + WebServiceTemplateSTART + "\">"
|
||||
XML_Start = XML_Start + "<" + WebServiceTemplateSTART + ">"
|
||||
XML_Start = XML_Start + "<Datumvon>" + Datumvon + "</Datumvon>"
|
||||
XML_Start = XML_Start + "<Fehlzeitenstamm>" + Fehlzeitenstamm + "</Fehlzeitenstamm>"
|
||||
XML_Start = XML_Start + "<ANGruppeRessource>" + AN_Gruppe_Ressource + "</ANGruppeRessource>"
|
||||
XML_Start = XML_Start + "<TypZeitartPause>" + ArbeitsZeitPause + "</TypZeitartPause>"
|
||||
XML_Start = XML_Start + "</" + WebServiceTemplateSTART + ">"
|
||||
XML_Start = XML_Start + "</MESOWebService>"
|
||||
print("XML-Start =" + XML_Start)
|
||||
return XML_Start
|
||||
|
||||
######################################
|
||||
# # Build Start-URL # #
|
||||
######################################
|
||||
|
||||
def BuildURLStart(XML_Start):
|
||||
URL_Start = "http://%SERVER%/ewlservice/import?User=%USER%&Password=%PASSWORD%&Company=%COMPANY%&Type=%TYPE%&Vorlage=%VORLAGE%&Actioncode=%ACTIONCODE%&byref=0&Data=%DATA%"
|
||||
URL_Start = URL_Start.replace("%SERVER%", WebServiceURL)
|
||||
URL_Start = URL_Start.replace("%USER%", WebServiceBenutzerName)
|
||||
URL_Start = URL_Start.replace("%PASSWORD%", dePW)
|
||||
URL_Start = URL_Start.replace("%COMPANY%", WinLineMandant)
|
||||
URL_Start = URL_Start.replace("%TYPE%", WebServiceType)
|
||||
URL_Start = URL_Start.replace("%VORLAGE%", WebServiceTemplateSTART)
|
||||
URL_Start = URL_Start.replace("%ACTIONCODE%", WebServiceActioncode)
|
||||
URL_Start = URL_Start.replace("%DATA%", XML_Start)
|
||||
|
||||
return URL_Start
|
||||
|
||||
#####################################
|
||||
# # Build Export-URL # #
|
||||
#####################################
|
||||
|
||||
def BuildURLExport(myData,RequestTyp):
|
||||
myDataListe = myData.split("-")
|
||||
Arbeitnehmernummer = myDataListe[0]
|
||||
if RequestTyp == 1:
|
||||
WebServiceTemplateExport = "Export"
|
||||
Filter = "FilterZeit-" + Arbeitnehmernummer
|
||||
elif RequestTyp == 2:
|
||||
WebServiceTemplateExport = "Export"
|
||||
Filter = "FilterZeit-" + Arbeitnehmernummer
|
||||
elif RequestTyp == 3:
|
||||
WebServiceTemplateExport = "ExportPause"
|
||||
Filter = "FilterZeitP-" + Arbeitnehmernummer
|
||||
elif RequestTyp == 4:
|
||||
WebServiceTemplateExport = "ExportPause"
|
||||
Filter = "FilterZeitP-" + Arbeitnehmernummer
|
||||
|
||||
XMLExport = Filter
|
||||
URL_Export = "http://%SERVER%/ewlservice/export?User=%USER%&Password=%PASSWORD%&Company=%COMPANY%&Type=%TYPE%&Vorlage=%VORLAGE%&Actioncode=%ACTIONCODE%&byref=0&Key=%KEY%"
|
||||
URL_Export = URL_Export.replace("%SERVER%", WebServiceURL)
|
||||
URL_Export = URL_Export.replace("%USER%", WebServiceBenutzerName)
|
||||
URL_Export = URL_Export.replace("%PASSWORD%", dePW)
|
||||
URL_Export = URL_Export.replace("%COMPANY%", WinLineMandant)
|
||||
URL_Export = URL_Export.replace("%TYPE%", WebServiceType)
|
||||
URL_Export = URL_Export.replace("%VORLAGE%", WebServiceTemplateExport)
|
||||
URL_Export = URL_Export.replace("%ACTIONCODE%", WebServiceActioncode)
|
||||
URL_Export = URL_Export.replace("%KEY%", XMLExport)
|
||||
URL_Export = URL_Export.replace("%FILTER%", Filter)
|
||||
print("URL_Export = " + URL_Export)
|
||||
HTTPRequest_Export = requests.post(URL_Export)
|
||||
IndexVonDatum = HTTPRequest_Export.text.find("<Datumvon>")
|
||||
v1 = IndexVonDatum + len("<Datumvon>")
|
||||
v2 = v1 + 19
|
||||
Datumvon = HTTPRequest_Export.text[v1:v2]
|
||||
return Datumvon
|
||||
|
||||
|
||||
#####################################
|
||||
# # Build End-XML # #
|
||||
#####################################
|
||||
def BuildXMLEnde(RequestTyp, myData, OrgDateTime, ActDateTime):
|
||||
print(RequestTyp)
|
||||
if RequestTyp == 2:
|
||||
ArbeitsZeitPause = "0"
|
||||
Fehlzeitenstamm =config['WEBSERVICE']['Fehlzeitenstamm']
|
||||
else:
|
||||
ArbeitsZeitPause = "1"
|
||||
if WeekRule == 'on':
|
||||
Weekday = datetime.today().isoweekday()
|
||||
Fehlzeitenstamm = config['PAUSEKEYRULE']['Weekday' + str(Weekday)]
|
||||
else:
|
||||
Fehlzeitenstamm = "1"
|
||||
myDataListe = myData.split("-")
|
||||
AN_Gruppe_Ressource = myDataListe[0]
|
||||
|
||||
XML_Ende = ""
|
||||
XML_Ende = XML_Ende + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
||||
XML_Ende = XML_Ende + "<MESOWebService TemplateType=\"" + WebServiceType + "\"" " Template=\"" + WebServiceTemplateSTOP + "\">"
|
||||
XML_Ende = XML_Ende + "<" + WebServiceTemplateSTOP + ">"
|
||||
XML_Ende = XML_Ende + "<Datumvon>" + OrgDateTime + "</Datumvon>"
|
||||
XML_Ende = XML_Ende + "<Datumbis>" + ActDateTime + "</Datumbis>"
|
||||
XML_Ende = XML_Ende + "<Fehlzeitenstamm>" + Fehlzeitenstamm + "</Fehlzeitenstamm>"
|
||||
XML_Ende = XML_Ende + "<ANGruppeRessource>" + AN_Gruppe_Ressource + "</ANGruppeRessource>"
|
||||
XML_Ende = XML_Ende + "<TypZeitartPause>" + ArbeitsZeitPause + "</TypZeitartPause>"
|
||||
XML_Ende = XML_Ende + "<Importoption>" + "1" + "</Importoption>"
|
||||
XML_Ende = XML_Ende + "</" + WebServiceTemplateSTOP + ">"
|
||||
XML_Ende = XML_Ende + "</MESOWebService>"
|
||||
return XML_Ende
|
||||
|
||||
#####################################
|
||||
# # Build End-URL # #
|
||||
#####################################
|
||||
def BuildURLEnde(XML_Ende):
|
||||
|
||||
URL_Ende = "http://%SERVER%/ewlservice/import?User=%USER%&Password=%PASSWORD%&Company=%COMPANY%&Type=%TYPE%&Vorlage=%VORLAGE%&Actioncode=%ACTIONCODE%&byref=0&Data=%DATA%"
|
||||
URL_Ende = URL_Ende.replace("%SERVER%", WebServiceURL)
|
||||
URL_Ende = URL_Ende.replace("%USER%", WebServiceBenutzerName)
|
||||
URL_Ende = URL_Ende.replace("%PASSWORD%", dePW)
|
||||
URL_Ende = URL_Ende.replace("%COMPANY%", WinLineMandant)
|
||||
URL_Ende = URL_Ende.replace("%TYPE%", WebServiceType)
|
||||
URL_Ende = URL_Ende.replace("%VORLAGE%", WebServiceTemplateSTOP)
|
||||
URL_Ende = URL_Ende.replace("%ACTIONCODE%", WebServiceActioncode)
|
||||
URL_Ende = URL_Ende.replace("%DATA%", XML_Ende)
|
||||
return URL_Ende
|
||||
|
||||
#####################################
|
||||
# # WinLine Requests # #
|
||||
#####################################
|
||||
|
||||
def MakeWinLineRequest(self, RequestTyp, myData, actDateTime, now):
|
||||
myDataListe = myData.split("-")
|
||||
name = myDataListe[1]
|
||||
TimeWithoutsec = now.strftime('%H:%M:%S')
|
||||
|
||||
###############################################
|
||||
|
||||
if RequestTyp == 1:
|
||||
CheckStatus = BuildURLExport(myData, RequestTyp)
|
||||
print(CheckStatus)
|
||||
if CheckStatus == "sion=\"1.0\" encoding":
|
||||
XMLStart = BuildXMLStart(RequestTyp, myData, actDateTime)
|
||||
URLStart = BuildURLStart(XMLStart)
|
||||
HTTPRequest_Start = requests.post(URLStart)
|
||||
print(HTTPRequest_Start.text)
|
||||
self.anweisungs_label = tk.Label(font=('Arial', 12), text=TextStart + str(name))
|
||||
self.anweisungs_label.grid(row=0, column=2, sticky='ew')
|
||||
self.anweisungs_label2 = tk.Label(font=('Arial', 12), text="Es ist " + str(TimeWithoutsec) + " Uhr ")
|
||||
self.anweisungs_label2.grid(row=1, column=2, sticky='ew')
|
||||
self.configure(bg="green")
|
||||
self.after(TimeToShowScreens, LabelReset, self)
|
||||
|
||||
|
||||
else:
|
||||
self.anweisungs_label = tk.Label(font=('Arial', 12), text=TextErrorStart)
|
||||
self.anweisungs_label.grid(row=0, column=2, sticky='ew')
|
||||
self.configure(bg="red")
|
||||
self.after(TimeToShowScreens, LabelReset, self)
|
||||
|
||||
###############################################
|
||||
|
||||
elif RequestTyp == 2:
|
||||
OrgDateTime = BuildURLExport(myData, RequestTyp)
|
||||
Weekday = datetime.today().isoweekday()
|
||||
if OrgDateTime == "sion=\"1.0\" encoding":
|
||||
#if OrgDateTime == "Kein Datensatz für den Export vorhanden!":
|
||||
self.anweisungs_label = tk.Label(font=('Arial', 12), text=TextErrorEnd)
|
||||
self.anweisungs_label.grid(row=0, column=2, sticky='ew')
|
||||
self.configure(bg="red")
|
||||
self.after(TimeToShowScreens, LabelReset, self)
|
||||
|
||||
else:
|
||||
XMLEnde = BuildXMLEnde(RequestTyp, myData, OrgDateTime, actDateTime)
|
||||
URLEnde = BuildURLEnde(XMLEnde)
|
||||
HTTPRequest_Ende = requests.post(URLEnde)
|
||||
print(HTTPRequest_Ende.text)
|
||||
self.anweisungs_label = tk.Label(font=('Arial', 12), text=TextEnd + str(name))
|
||||
self.anweisungs_label.grid(row=0, column=2, sticky='ew')
|
||||
self.anweisungs_label2 = tk.Label(font=('Arial', 12), text="Es ist " + str(TimeWithoutsec) + " Uhr ")
|
||||
self.anweisungs_label2.grid(row=1, column=2, sticky='ew')
|
||||
self.configure(bg="green")
|
||||
self.after(TimeToShowScreens, LabelReset, self)
|
||||
|
||||
###############################################
|
||||
|
||||
elif RequestTyp == 3:
|
||||
CheckStatus = BuildURLExport(myData, RequestTyp)
|
||||
if CheckStatus == "sion=\"1.0\" encoding":
|
||||
#if CheckStatus == "Kein Datensatz für den Export vorhanden!":
|
||||
XMLStart = BuildXMLStart(RequestTyp, myData, actDateTime)
|
||||
URLStart = BuildURLStart(XMLStart)
|
||||
HTTPRequest_Start = requests.post(URLStart)
|
||||
print(HTTPRequest_Start.text)
|
||||
self.anweisungs_label = tk.Label(font=('Arial', 12), text=TextPause + str(name))
|
||||
self.anweisungs_label.grid(row=0, column=2, sticky='ew')
|
||||
self.anweisungs_label2 = tk.Label(font=('Arial', 12), text="Es ist " + str(TimeWithoutsec) + " Uhr ")
|
||||
self.anweisungs_label2.grid(row=1, column=2, sticky='ew')
|
||||
self.configure(bg="green")
|
||||
self.after(TimeToShowScreens, LabelReset, self)
|
||||
|
||||
else:
|
||||
self.anweisungs_label = tk.Label(font=('Arial', 12), text=TextErrorPause)
|
||||
self.anweisungs_label.grid(row=0, column=2, sticky='ew')
|
||||
self.configure(bg="red")
|
||||
self.after(TimeToShowScreens, LabelReset, self)
|
||||
|
||||
###############################################
|
||||
|
||||
elif RequestTyp == 4:
|
||||
OrgDateTime = BuildURLExport(myData, RequestTyp)
|
||||
if OrgDateTime == "sion=\"1.0\" encoding":
|
||||
|
||||
self.anweisungs_label = tk.Label(font=('Arial', 12), text=TextErrorPauseEnd)
|
||||
self.anweisungs_label.grid(row=0, column=2, sticky='ew')
|
||||
self.configure(bg="red")
|
||||
self.after(TimeToShowScreens, LabelReset, self)
|
||||
|
||||
else:
|
||||
XMLEnde = BuildXMLEnde(RequestTyp, myData, OrgDateTime, actDateTime)
|
||||
URLEnde = BuildURLEnde(XMLEnde)
|
||||
HTTPRequest_Ende = requests.post(URLEnde)
|
||||
print(HTTPRequest_Ende.text)
|
||||
self.anweisungs_label = tk.Label(font=('Arial', 12), text=TextPauseEnd + str(name))
|
||||
self.anweisungs_label.grid(row=0, column=2, sticky='ew')
|
||||
self.anweisungs_label2 = tk.Label(font=('Arial', 12), text="Es ist " + str(TimeWithoutsec) + " Uhr ")
|
||||
self.anweisungs_label2.grid(row=1, column=2, sticky='ew')
|
||||
self.configure(bg="green")
|
||||
self.after(TimeToShowScreens, LabelReset, self)
|
||||
#####################################
|
||||
# # Scanner # #
|
||||
#####################################
|
||||
|
||||
def Scanner(self):
|
||||
app.event_generate('<Motion>', warp=True, x=1, y=1)
|
||||
self.anweisungs_label = tk.Label(font=('Arial', 12), text=TextDefault)
|
||||
cap = cv2.VideoCapture(0)
|
||||
cap.set(3, Height)
|
||||
cap.set(4, Width)
|
||||
|
||||
cv2.namedWindow('Result')
|
||||
cv2.moveWindow('Result', 2, 2)
|
||||
|
||||
myData = None
|
||||
|
||||
for x in range(0, TimeToScan):
|
||||
success, img = cap.read()
|
||||
for barcode in decode(img):
|
||||
myData = barcode.data.decode('utf-8')
|
||||
rotated_img = np.rot90(img, k=3)
|
||||
|
||||
cv2.imshow('Result', rotated_img)
|
||||
cv2.waitKey(1)
|
||||
|
||||
if myData is not None:
|
||||
cap.release()
|
||||
cv2.destroyAllWindows()
|
||||
return myData
|
||||
else:
|
||||
self.after(100)
|
||||
|
||||
cap.release()
|
||||
cv2.destroyAllWindows()
|
||||
LabelReset(self)
|
||||
|
||||
#####################################
|
||||
# # Main # #
|
||||
#####################################
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = App()
|
||||
app.mainloop()
|
||||
|
||||
1
archive/Zeiterfassung/Vorlagen_Zeiterfassung
Normal file
1
archive/Zeiterfassung/Vorlagen_Zeiterfassung
Normal file
File diff suppressed because one or more lines are too long
3
archive/Zeiterfassung/Zeiterfassung vor Umbau auf WinLine 12/.idea/.gitignore
generated
vendored
Normal file
3
archive/Zeiterfassung/Zeiterfassung vor Umbau auf WinLine 12/.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
1
archive/Zeiterfassung/Zeiterfassung vor Umbau auf WinLine 12/.idea/.name
generated
Normal file
1
archive/Zeiterfassung/Zeiterfassung vor Umbau auf WinLine 12/.idea/.name
generated
Normal file
@@ -0,0 +1 @@
|
||||
Zeiterfassung2.py
|
||||
10
archive/Zeiterfassung/Zeiterfassung vor Umbau auf WinLine 12/.idea/Zeiterfassung.iml
generated
Normal file
10
archive/Zeiterfassung/Zeiterfassung vor Umbau auf WinLine 12/.idea/Zeiterfassung.iml
generated
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Python 3.9 (Zeiterfassung)" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -0,0 +1,6 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
||||
4
archive/Zeiterfassung/Zeiterfassung vor Umbau auf WinLine 12/.idea/misc.xml
generated
Normal file
4
archive/Zeiterfassung/Zeiterfassung vor Umbau auf WinLine 12/.idea/misc.xml
generated
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (Zeiterfassung)" project-jdk-type="Python SDK" />
|
||||
</project>
|
||||
8
archive/Zeiterfassung/Zeiterfassung vor Umbau auf WinLine 12/.idea/modules.xml
generated
Normal file
8
archive/Zeiterfassung/Zeiterfassung vor Umbau auf WinLine 12/.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/Zeiterfassung.iml" filepath="$PROJECT_DIR$/.idea/Zeiterfassung.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
@@ -0,0 +1,19 @@
|
||||
import configparser
|
||||
import cryptocode
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
config.sections()
|
||||
config.read('config.ini')
|
||||
|
||||
WebServiceURL = config['WEBSERVICE']['WebServiceURL']
|
||||
WebServiceBenutzerName = config['WEBSERVICE']['WebServiceBenutzerName']
|
||||
WebServiceBenutzerPasswort = config['WEBSERVICE']['WebServiceBenutzerPasswort']
|
||||
WinLineMandant = config['WEBSERVICE']['WinLineMandant']
|
||||
WebServiceTemplateSTART = config['WEBSERVICE']['WebServiceTemplateSTART']
|
||||
WebServiceTemplateSTOP = config['WEBSERVICE']['WebServiceTemplateSTOP']
|
||||
WebServiceType = config['WEBSERVICE']['WebServiceType']
|
||||
Fehlzeitenstamm = config['WEBSERVICE']['Fehlzeitenstamm']
|
||||
|
||||
|
||||
pw2 = cryptocode.decrypt(WebServiceBenutzerPasswort, "Zeiterfassung")
|
||||
print(pw2)
|
||||
@@ -0,0 +1,13 @@
|
||||
from tkinter import *
|
||||
|
||||
root = Tk()
|
||||
def key():
|
||||
root.event_generate('<Motion>', warp=True, x=50, y=50)
|
||||
|
||||
def motion(event):
|
||||
print('motion {}, {}'.format(event.x, event.y))
|
||||
|
||||
|
||||
root.bind('<Key>', key)
|
||||
root.bind('<Motion>', motion)
|
||||
root.mainloop()
|
||||
@@ -0,0 +1,195 @@
|
||||
##### Import #####
|
||||
from tkinter import*
|
||||
from datetime import datetime
|
||||
import cv2
|
||||
import numpy as np
|
||||
from pyzbar.pyzbar import decode
|
||||
import requests
|
||||
|
||||
###### Variables #####
|
||||
WebServiceActioncode = "1"
|
||||
Arbeitnehmernummer = ""
|
||||
ArbeitsZeitPause = "0" # "0" - Arbeitszeit "1" - Pause
|
||||
StartStopPause = "Ende" # "Start" = Arbeitszeit beginnen "Ende" = Arbeitszeit beenden
|
||||
Fehlzeitenstamm = "1"
|
||||
|
||||
##### Server-Options #####
|
||||
WebServiceURL = "localhost"
|
||||
WebServiceBenutzerName = "a"
|
||||
WebServiceBenutzerPasswort = "b"
|
||||
WinLineMandant = "MEDT"
|
||||
WebServiceTemplateSTART = "Zeitnahme"
|
||||
WebServiceTemplateSTOP = "STOP"
|
||||
WebServiceType = "36"
|
||||
###### Variables for Timestamp and XML #####
|
||||
now = datetime.now()
|
||||
current_time = now.strftime("%D:%H:%M:%S")
|
||||
Datumvon = datetime.now().strftime('%Y-%m-%d') + "T" + datetime.now().strftime('%H:%M:%S')
|
||||
Datumbis = datetime.now().strftime('%Y-%m-%d') + "T" + datetime.now().strftime('%H:%M:%S')
|
||||
AN_Gruppe_Ressource = Arbeitnehmernummer
|
||||
###### Filter ######
|
||||
if ArbeitsZeitPause == "1":
|
||||
WebServiceTemplateExport = "ExportPause"
|
||||
Filter = "FilterTestP-" + Arbeitnehmernummer
|
||||
else:
|
||||
WebServiceTemplateExport = "Export"
|
||||
Filter = "FilterTest-" + Arbeitnehmernummer
|
||||
###### QR-Code-Scan ######
|
||||
def button_action():
|
||||
anweisungs_label.config(text=current_time)
|
||||
#img = cv2.imread ('QR1.jpg')
|
||||
cap = cv2.VideoCapture(0)
|
||||
cap.set(3,640)
|
||||
cap.set(4,480)
|
||||
x = True
|
||||
myData = None
|
||||
while x == True:
|
||||
#code=decode(img)
|
||||
#print(code)
|
||||
success, img = cap.read()
|
||||
for barcode in decode(img):
|
||||
myData = barcode.data.decode('utf-8')
|
||||
print(myData)
|
||||
|
||||
#pts = np.array([barcode.polygon],np.int32)
|
||||
#pts = pts.reshape((-1,1,2))
|
||||
#cv2.polylines(img,[pts],True,(255,0,255),5)
|
||||
#pts2 = barcode.rect
|
||||
#cv2.putText(img,myData,(pts2[0],pts[1]),cv2.FONT_HERSHEY_SIMPLEX)
|
||||
|
||||
cv2.imshow('Result',img)
|
||||
cv2.waitKey(1)
|
||||
if myData is not None:
|
||||
x = False
|
||||
return myData
|
||||
|
||||
###### Frame ######
|
||||
fenster = Tk()
|
||||
fenster.configure(bg="white")
|
||||
fenster.title("DD-Zeiterfassung")
|
||||
fenster.geometry("1024x768")
|
||||
|
||||
|
||||
start_button = Button(fenster, text="Arbeitstag beginnen",fg="white",bg="green", command=button_action)
|
||||
exit_button = Button (fenster, text="Arbeitstag beenden",fg="white",bg="red",command=fenster.quit)
|
||||
pause_button = Button (fenster, text="Pause beginnen",fg="white",bg="#b47a0e", command=button_action)
|
||||
pause_end_button = Button (fenster, text="Pause beenden",fg="white",bg="#b47a0e", command=button_action)
|
||||
anweisungs_label = Label(fenster, text="Test")
|
||||
info_label = Label(fenster, text="info")
|
||||
|
||||
anweisungs_label.grid(row=0, column=2, pady = 20)
|
||||
start_button.grid(row=1, column=1, pady = 20)
|
||||
exit_button.grid(row=1, column=2)
|
||||
pause_button.grid (row=1, column=3)
|
||||
pause_end_button.grid (row=1, column=4)
|
||||
fenster.mainloop()
|
||||
|
||||
|
||||
##### Build Start-XML #####
|
||||
def BuildXMLStart():
|
||||
XML_Start = ""
|
||||
XML_Start = XML_Start + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
||||
XML_Start = XML_Start + "<MESOWebService TemplateType=\"" + WebServiceType + "\"" " Template=\"" + WebServiceTemplateSTART + "\">"
|
||||
XML_Start = XML_Start + "<" + WebServiceTemplateSTART + ">"
|
||||
#Location for WinLine fields
|
||||
XML_Start = XML_Start + "<Datumvon>" + Datumvon + "</Datumvon>"
|
||||
XML_Start = XML_Start + "<Fehlzeitenstamm>" + Fehlzeitenstamm + "</Fehlzeitenstamm>"
|
||||
XML_Start = XML_Start + "<ANGruppeRessource>" + AN_Gruppe_Ressource + "</ANGruppeRessource>"
|
||||
XML_Start = XML_Start + "<TypZeitartPause>" + ArbeitsZeitPause + "</TypZeitartPause>"
|
||||
XML_Start = XML_Start + "</" + WebServiceTemplateSTART + ">"
|
||||
XML_Start = XML_Start + "</MESOWebService>"
|
||||
return XML_Start
|
||||
|
||||
##### Build Start-URL #####
|
||||
def BuildURLStart(XML_Start):
|
||||
URL_Start = "http://%SERVER%/ewlservice/import?User=%USER%&Password=%PASSWORD%&Company=%COMPANY%&Type=%TYPE%&Vorlage=%VORLAGE%&Actioncode=%ACTIONCODE%&byref=0&Data=%DATA%"
|
||||
URL_Start = "http://%SERVER%/ewlservice/import?User=%USER%&Password=%PASSWORD%&Company=%COMPANY%&Type=%TYPE%&Vorlage=%VORLAGE%&Actioncode=%ACTIONCODE%&byref=0&Data=%DATA%""
|
||||
URL_Start.replace("%SERVER%", WebServiceURL)
|
||||
URL_Start = URL_Start.replace("%USER%", WebServiceBenutzerName)
|
||||
URL_Start = URL_Start.replace("%PASSWORD%", WebServiceBenutzerPasswort)
|
||||
URL_Start = URL_Start.replace("%COMPANY%", WinLineMandant)
|
||||
URL_Start = URL_Start.replace("%TYPE%", WebServiceType)
|
||||
URL_Start = URL_Start.replace("%VORLAGE%", WebServiceTemplateSTART)
|
||||
URL_Start = URL_Start.replace("%ACTIONCODE%", WebServiceActioncode)
|
||||
URL_Start = URL_Start.replace("%DATA%", XML_Start)
|
||||
return URL_Start
|
||||
##### Webservice-Export #####
|
||||
def BuildURLExport(XML_Start):
|
||||
XMLExport = Filter
|
||||
URL_Export = "http://%SERVER%/ewlservice/export?User=%USER%&Password=%PASSWORD%&Company=%COMPANY%&Type=%TYPE%&Vorlage=%VORLAGE%&Actioncode=%ACTIONCODE%&byref=0&Key=%KEY%"
|
||||
URL_Export = URL_Export.replace("%SERVER%", WebServiceURL)
|
||||
URL_Export = URL_Export.replace("%USER%", WebServiceBenutzerName)
|
||||
URL_Export = URL_Export.replace("%PASSWORD%", WebServiceBenutzerPasswort)
|
||||
URL_Export = URL_Export.replace("%COMPANY%", WinLineMandant)
|
||||
URL_Export = URL_Export.replace("%TYPE%", WebServiceType)
|
||||
URL_Export = URL_Export.replace("%VORLAGE%", WebServiceTemplateExport)
|
||||
URL_Export = URL_Export.replace("%ACTIONCODE%", WebServiceActioncode)
|
||||
URL_Export = URL_Export.replace("%KEY%", XMLExport)
|
||||
URL_Export = URL_Export.replace("%FILTER%", Filter)
|
||||
print("URL_Export = " + URL_Export)
|
||||
HTTPRequest_Export = requests.post(URL_Export)
|
||||
return URL_Export
|
||||
|
||||
##### Build End-XML #####
|
||||
IndexVonDatum = HTTPRequest_Export.text.find("<Datumvon>")
|
||||
v1 = IndexVonDatum + len("<Datumvon>")
|
||||
v2 = v1 + 19
|
||||
Datumvon = HTTPRequest_Export.text[v1:v2]
|
||||
print(Datumvon)
|
||||
print(Datumbis)
|
||||
|
||||
XML_Ende = ""
|
||||
XML_Ende = XML_Ende + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
||||
XML_Ende = XML_Ende + "<MESOWebService TemplateType=\"" + WebServiceType + "\"" " Template=\"" + WebServiceTemplateSTOP + "\">"
|
||||
XML_Ende = XML_Ende + "<" + WebServiceTemplateSTOP + ">"
|
||||
# Location for WinLine fields
|
||||
XML_Ende = XML_Ende + "<Datumvon>" + Datumvon + "</Datumvon>"
|
||||
XML_Ende = XML_Ende + "<Datumbis>" + Datumbis + "</Datumbis>"
|
||||
XML_Ende = XML_Ende + "<Fehlzeitenstamm>" + Fehlzeitenstamm + "</Fehlzeitenstamm>"
|
||||
XML_Ende = XML_Ende + "<ANGruppeRessource>" + AN_Gruppe_Ressource + "</ANGruppeRessource>"
|
||||
XML_Ende = XML_Ende + "<TypZeitartPause>" + ArbeitsZeitPause + "</TypZeitartPause>"
|
||||
XML_Ende = XML_Ende + "<Importoption>" + "1" + "</Importoption>"
|
||||
XML_Ende = XML_Ende + "</" + WebServiceTemplateSTOP + ">"
|
||||
XML_Ende = XML_Ende + "</MESOWebService>"
|
||||
|
||||
##### Build End-URL #####
|
||||
URL_Ende = "http://%SERVER%/ewlservice/import?User=%USER%&Password=%PASSWORD%&Company=%COMPANY%&Type=%TYPE%&Vorlage=%VORLAGE%&Actioncode=%ACTIONCODE%&byref=0&Data=%DATA%"
|
||||
URL_Ende = URL_Ende.replace("%SERVER%", WebServiceURL)
|
||||
URL_Ende = URL_Ende.replace("%USER%", WebServiceBenutzerName)
|
||||
URL_Ende = URL_Ende.replace("%PASSWORD%", WebServiceBenutzerPasswort)
|
||||
URL_Ende = URL_Ende.replace("%COMPANY%", WinLineMandant)
|
||||
URL_Ende = URL_Ende.replace("%TYPE%", WebServiceType)
|
||||
URL_Ende = URL_Ende.replace("%VORLAGE%", WebServiceTemplateSTOP)
|
||||
URL_Ende = URL_Ende.replace("%ACTIONCODE%", WebServiceActioncode)
|
||||
URL_Ende = URL_Ende.replace("%DATA%", XML_Ende)
|
||||
|
||||
##### Requests #####
|
||||
if StartStopPause == "Start":
|
||||
HTTPRequest_Start = requests.post(URL_Start)
|
||||
print(URL_Start)
|
||||
print(HTTPRequest_Start.text)
|
||||
else:
|
||||
HTTPRequest_Ende = requests.post(URL_Ende)
|
||||
print(HTTPRequest_Ende.text)
|
||||
|
||||
fenster = Tk()
|
||||
fenster.configure(bg="white")
|
||||
fenster.title("DD-Zeiterfassung")
|
||||
fenster.geometry("1024x768")
|
||||
|
||||
|
||||
start_button = Button(fenster, text="Arbeitstag beginnen",fg="white",bg="green", command=button_action)
|
||||
exit_button = Button (fenster, text="Arbeitstag beenden",fg="white",bg="red",command=fenster.quit)
|
||||
pause_button = Button (fenster, text="Pause beginnen",fg="white",bg="#b47a0e", command=button_action)
|
||||
pause_end_button = Button (fenster, text="Pause beenden",fg="white",bg="#b47a0e", command=button_action)
|
||||
anweisungs_label = Label(fenster, text="Test")
|
||||
info_label = Label(fenster, text="info")
|
||||
|
||||
anweisungs_label.grid(row=0, column=2, pady = 20)
|
||||
start_button.grid(row=1, column=1, pady = 20)
|
||||
exit_button.grid(row=1, column=2)
|
||||
pause_button.grid (row=1, column=3)
|
||||
pause_end_button.grid (row=1, column=4)
|
||||
fenster.mainloop()
|
||||
|
||||
def WebserviceCall():
|
||||
@@ -0,0 +1,10 @@
|
||||
import logging
|
||||
logger = logging.getLogger('mylogger')
|
||||
|
||||
handler = logging.FileHandler('mylog.log')
|
||||
logger.addHandler(handler)
|
||||
|
||||
logger.warning('This is a WARNING message')
|
||||
logger.error('This is an ERROR message')
|
||||
logger.critical('This is a CRITICAL message')
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
# Python program to determine which
|
||||
# button was pressed in tkinter
|
||||
|
||||
# Import the library tkinter
|
||||
import tkinter
|
||||
from tkinter import *
|
||||
|
||||
# Create a GUI app
|
||||
app = Tk()
|
||||
|
||||
|
||||
# Create a function with one paramter, i.e., of
|
||||
# the text you want to show when button is clicked
|
||||
def which_button(button_press):
|
||||
|
||||
# Printing the text when a button is clicked
|
||||
print(button_press)
|
||||
label1 = tkinter.Label(font=('Arial', 12), bg="green", fg="black",text=" ")
|
||||
label1.grid(row=1, column=2)
|
||||
def key(event):
|
||||
app.event_generate('<Motion>', warp=True, x=50, y=50)
|
||||
|
||||
def motion(event):
|
||||
print('motion {}, {}'.format(event.x, event.y))
|
||||
|
||||
# Creating and displaying of button b1
|
||||
b1 = Button(app, text="Apple", activebackground='blue', activeforeground='yellow', command=key(): which_button(m), bg="green", fg="black")
|
||||
|
||||
b1.grid(row=0, column=1, padx=10, pady=10)
|
||||
|
||||
# Creating and displaying of button b2
|
||||
b2 = Button(app, text="Banana",
|
||||
command=lambda m="It is a banana": which_button(m))
|
||||
|
||||
|
||||
b2.grid(row=0, column=2, padx=10, pady=10)
|
||||
|
||||
|
||||
# Make the infinite loop for displaying the app
|
||||
|
||||
app.mainloop()
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
import cryptocode
|
||||
Passwort = 'SIVmeso!'
|
||||
str_encoded = cryptocode.encrypt(Passwort,"Zeiterfassung")
|
||||
print(str_encoded)
|
||||
@@ -0,0 +1,7 @@
|
||||
0 Montag = 1
|
||||
1 Dienstag = 1
|
||||
2 Mittwoch = 1
|
||||
3 Donnerstag = 1
|
||||
4 Freitag = 2
|
||||
5 Samstag = 1
|
||||
6 Sonntag = 1
|
||||
@@ -0,0 +1,27 @@
|
||||
import cv2
|
||||
import numpy as np
|
||||
from pyzbar.pyzbar import decode
|
||||
import requests
|
||||
from datetime import *
|
||||
|
||||
#img = cv2.imread ('QR1.jpg')
|
||||
cap = cv2.VideoCapture(0)
|
||||
cap.set(3,640)
|
||||
cap.set(4,480)
|
||||
|
||||
while True:
|
||||
#code=decode(img)
|
||||
#print(code)
|
||||
success, img = cap.read()
|
||||
for barcode in decode(img):
|
||||
#print(barcode.data)
|
||||
myData = barcode.data.decode('utf-8')
|
||||
print(myData)
|
||||
pts = np.array([barcode.polygon],np.int32)
|
||||
pts = pts.reshape((-1,1,2))
|
||||
cv2.polylines(img,[pts],True,(255,0,255),5)
|
||||
pts2 = barcode.rect
|
||||
# cv2.putText(img,myData,(pts2[0],pts[1]),cv2.FONT_HERSHEY_SIMPLEX)
|
||||
|
||||
cv2.imshow('Result',img)
|
||||
cv2.waitKey(1)
|
||||
@@ -0,0 +1,23 @@
|
||||
import tkinter as tk
|
||||
class App(tk.Tk):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
self.configure(bg="white")
|
||||
self.title("DD-Zeiterfassung")
|
||||
self.geometry("1024x768")
|
||||
|
||||
|
||||
|
||||
self.anweisungs_label = tk.Label(self, font=('Arial', 12), text="ä = ÄÄÄÄÄÄ ääääääää ÜÜÜÜÜÜÜÜÜ üüüüüüüü ÖÖÖÖÖÖÖÖ öööööö\n")
|
||||
self.anweisungs_label2 = tk.Label(self, font=('Arial', 12), bg="white", fg="black")
|
||||
|
||||
self.anweisungs_label.grid(row=0, column=2, pady=20, padx=10, sticky='ew')
|
||||
self.anweisungs_label2.grid(row=1, column=2, pady=20, padx=10, sticky='ew')
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = App()
|
||||
app.mainloop()
|
||||
@@ -0,0 +1,189 @@
|
||||
# Import von Bibliotheken
|
||||
import time
|
||||
|
||||
import requests
|
||||
from datetime import *
|
||||
|
||||
# IF (DEBUG_ON = True) Or (DebugMode = "Enabled") THEN
|
||||
|
||||
# MSGBOX "Kennzeichen: " + Kennzeichen + vbCrLf &_
|
||||
# "AccountNr: " + AccountNr + vbCrLf &_
|
||||
# "Mandator: " + Mandator + vbCrLf &_
|
||||
# "",,DEBUG_TITLE& " - Call Webservice"
|
||||
# x = date(1, 1, 1)
|
||||
# End if
|
||||
# Variablen
|
||||
WebServiceActioncode = "1"
|
||||
Arbeitnehmernummer = "4" # "1" - Lantelme "4" - Knaus
|
||||
|
||||
# Arbeitstagbeginnen = "Start"
|
||||
ArbeitsZeitPause = "0" # "0" - Arbeitszeit "1" - Pause
|
||||
StartStopPause = "Ende"
|
||||
print(ArbeitsZeitPause)
|
||||
#Feste Variablen
|
||||
WebServiceURL = "localhost"
|
||||
WebServiceBenutzerName = "a"
|
||||
WebServiceBenutzerPasswort = "b"
|
||||
WinLineMandant = "MEDT"
|
||||
WebServiceTemplateSTART = "Zeitnahme"
|
||||
WebServiceTemplateSTOP = "STOP"
|
||||
#WebServiceTemplateExport = "Export"
|
||||
if ArbeitsZeitPause == "1":
|
||||
WebServiceTemplateExport = "ExportPause"
|
||||
Filter = "FilterTestP-" + Arbeitnehmernummer
|
||||
else:
|
||||
WebServiceTemplateExport = "Export"
|
||||
Filter = "FilterTest-" + Arbeitnehmernummer
|
||||
WebServiceType = "36"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Testvariablen
|
||||
Datumvon = datetime.now().strftime('%Y-%m-%d') + "T" + datetime.now().strftime('%H:%M:%S')
|
||||
Datumbis = datetime.now().strftime('%Y-%m-%d') + "T" + datetime.now().strftime('%H:%M:%S')
|
||||
Fehlzeitenstamm = "1"
|
||||
AN_Gruppe_Ressource = Arbeitnehmernummer
|
||||
# Build START XML
|
||||
XML_Start = ""
|
||||
XML_Start = XML_Start + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
||||
XML_Start = XML_Start + "<MESOWebService TemplateType=\"" + WebServiceType + "\"" " Template=\"" + WebServiceTemplateSTART + "\">"
|
||||
XML_Start = XML_Start + "<" + WebServiceTemplateSTART + ">"
|
||||
# Location for WinLine fields
|
||||
XML_Start = XML_Start + "<Datumvon>" + Datumvon + "</Datumvon>"
|
||||
# XML = XML + "<Datum bis>"+ Datumbis+ "</Datum bis>"
|
||||
XML_Start = XML_Start + "<Fehlzeitenstamm>" + Fehlzeitenstamm + "</Fehlzeitenstamm>"
|
||||
XML_Start = XML_Start + "<ANGruppeRessource>" + AN_Gruppe_Ressource + "</ANGruppeRessource>"
|
||||
XML_Start = XML_Start + "<TypZeitartPause>" + ArbeitsZeitPause + "</TypZeitartPause>"
|
||||
XML_Start = XML_Start + "</" + WebServiceTemplateSTART + ">"
|
||||
XML_Start = XML_Start + "</MESOWebService>"
|
||||
# Replace placeholder in XML
|
||||
# XML = Replace(XML,"%WebServiceType%",WebServiceType)
|
||||
# XML = Replace(XML,"%WebServiceTemplate%",WebServiceTemplate)
|
||||
|
||||
#####################################START################################
|
||||
# Build webservice URL
|
||||
URL_Start = "http://%SERVER%/ewlservice/import?User=%USER%&Password=%PASSWORD%&Company=%COMPANY%&Type=%TYPE%&Vorlage=%VORLAGE%&Actioncode=%ACTIONCODE%&byref=0&Data=%DATA%"
|
||||
URL_Start = URL_Start.replace("%SERVER%", WebServiceURL)
|
||||
URL_Start = URL_Start.replace("%USER%", WebServiceBenutzerName)
|
||||
URL_Start = URL_Start.replace("%PASSWORD%", WebServiceBenutzerPasswort)
|
||||
URL_Start = URL_Start.replace("%COMPANY%", WinLineMandant)
|
||||
URL_Start = URL_Start.replace("%TYPE%", WebServiceType)
|
||||
URL_Start = URL_Start.replace("%VORLAGE%", WebServiceTemplateSTART)
|
||||
URL_Start = URL_Start.replace("%ACTIONCODE%", WebServiceActioncode)
|
||||
URL_Start = URL_Start.replace("%DATA%", XML_Start)
|
||||
#print("URL_Start =" + URL_Start)
|
||||
# Webservice Export
|
||||
|
||||
XMLExport = Filter
|
||||
URL_Export = "http://%SERVER%/ewlservice/export?User=%USER%&Password=%PASSWORD%&Company=%COMPANY%&Type=%TYPE%&Vorlage=%VORLAGE%&Actioncode=%ACTIONCODE%&byref=0&Key=%KEY%"
|
||||
URL_Export = URL_Export.replace("%SERVER%", WebServiceURL)
|
||||
URL_Export = URL_Export.replace("%USER%", WebServiceBenutzerName)
|
||||
URL_Export = URL_Export.replace("%PASSWORD%", WebServiceBenutzerPasswort)
|
||||
URL_Export = URL_Export.replace("%COMPANY%", WinLineMandant)
|
||||
URL_Export = URL_Export.replace("%TYPE%", WebServiceType)
|
||||
URL_Export = URL_Export.replace("%VORLAGE%", WebServiceTemplateExport)
|
||||
URL_Export = URL_Export.replace("%ACTIONCODE%", WebServiceActioncode)
|
||||
URL_Export = URL_Export.replace("%KEY%", XMLExport)
|
||||
URL_Export = URL_Export.replace("%FILTER%", Filter)
|
||||
print("URL_Export = " + URL_Export)
|
||||
|
||||
HTTPRequest_Export = requests.post(URL_Export)
|
||||
print(HTTPRequest_Export.text)
|
||||
|
||||
#########################ENDE DER ZEITNAHME##########################################################
|
||||
|
||||
IndexVonDatum = HTTPRequest_Export.text.find("<Datumvon>")
|
||||
v1 = IndexVonDatum + len("<Datumvon>")
|
||||
v2 = v1 + 19
|
||||
Datumvon = HTTPRequest_Export.text[v1:v2]
|
||||
print(Datumvon)
|
||||
print(Datumbis)
|
||||
|
||||
XML_Ende = ""
|
||||
XML_Ende = XML_Ende + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
||||
XML_Ende = XML_Ende + "<MESOWebService TemplateType=\"" + WebServiceType + "\"" " Template=\"" + WebServiceTemplateSTOP + "\">"
|
||||
XML_Ende = XML_Ende + "<" + WebServiceTemplateSTOP + ">"
|
||||
# Location for WinLine fields
|
||||
XML_Ende = XML_Ende + "<Datumvon>" + Datumvon + "</Datumvon>"
|
||||
XML_Ende = XML_Ende + "<Datumbis>" + Datumbis + "</Datumbis>"
|
||||
XML_Ende = XML_Ende + "<Fehlzeitenstamm>" + Fehlzeitenstamm + "</Fehlzeitenstamm>"
|
||||
XML_Ende = XML_Ende + "<ANGruppeRessource>" + AN_Gruppe_Ressource + "</ANGruppeRessource>"
|
||||
XML_Ende = XML_Ende + "<TypZeitartPause>" + ArbeitsZeitPause + "</TypZeitartPause>"
|
||||
XML_Ende = XML_Ende + "<Importoption>" + "1" + "</Importoption>"
|
||||
XML_Ende = XML_Ende + "</" + WebServiceTemplateSTOP + ">"
|
||||
XML_Ende = XML_Ende + "</MESOWebService>"
|
||||
#######################################################################################################################
|
||||
URL_Ende = "http://%SERVER%/ewlservice/import?User=%USER%&Password=%PASSWORD%&Company=%COMPANY%&Type=%TYPE%&Vorlage=%VORLAGE%&Actioncode=%ACTIONCODE%&byref=0&Data=%DATA%"
|
||||
URL_Ende = URL_Ende.replace("%SERVER%", WebServiceURL)
|
||||
URL_Ende = URL_Ende.replace("%USER%", WebServiceBenutzerName)
|
||||
URL_Ende = URL_Ende.replace("%PASSWORD%", WebServiceBenutzerPasswort)
|
||||
URL_Ende = URL_Ende.replace("%COMPANY%", WinLineMandant)
|
||||
URL_Ende = URL_Ende.replace("%TYPE%", WebServiceType)
|
||||
URL_Ende = URL_Ende.replace("%VORLAGE%", WebServiceTemplateSTOP)
|
||||
URL_Ende = URL_Ende.replace("%ACTIONCODE%", WebServiceActioncode)
|
||||
URL_Ende = URL_Ende.replace("%DATA%", XML_Ende)
|
||||
#print("URL_ENDE = " + URL_Ende)
|
||||
# Set XML content
|
||||
# Requests
|
||||
if StartStopPause == "Start":
|
||||
HTTPRequest_Start = requests.post(URL_Start)
|
||||
print(URL_Start)
|
||||
print(HTTPRequest_Start.text)
|
||||
else:
|
||||
HTTPRequest_Ende = requests.post(URL_Ende)
|
||||
print(HTTPRequest_Ende.text)
|
||||
|
||||
#print("Zeile die ich zurück bekomme: " + HTTPRequest_Export.text)
|
||||
|
||||
|
||||
# 'Send request to WebServer
|
||||
# HTTPRequest.Open "POST", URL, False
|
||||
# HTTPRequest.Send
|
||||
#
|
||||
# IF (HTTPRequest.Status = 200) Then
|
||||
#
|
||||
# If InStr(HTTPRequest.ResponseText, "<?xml") = 1 Then
|
||||
#
|
||||
# Doc.loadXML(HTTPRequest.ResponseText)
|
||||
#
|
||||
# Set Nodes = Doc.SelectNodes("MESOWebServiceResult/ResultDetails")
|
||||
# Set OverallSuccess = Doc.SelectSingleNode("MESOWebServiceResult/OverallSuccess")
|
||||
#
|
||||
# If OverallSuccess.Text = "true" Then
|
||||
# Dim IsSuccess : IsSuccess = True
|
||||
#
|
||||
# For Each Node in Nodes
|
||||
# Set Success = Node.SelectSingleNode("Success")
|
||||
#
|
||||
# If Success.Text <> "true" Then
|
||||
# IsSuccess = False
|
||||
# End If
|
||||
# Next
|
||||
#
|
||||
# msgbox "Die Übertragung war erfolgreich!" & vbCrlf & vbCrlf & _
|
||||
# "Bitte prüfen Sie nun noch Felder," & vbCrlf & _
|
||||
# "welche von der Übertragung ausgeschloßen sind."& vbCrlf & vbCrlf & _
|
||||
# "Beispiele: " & vbCrlf & _
|
||||
# "ZahlungskonditionFIBU, ZahlungskonditionFAKT," & vbCrlf & _
|
||||
# "Belegart, Lieferbedingungen, BKZ, ..." & vbCrlf & _
|
||||
# "",vbInformation,DEFAULT_TITLE
|
||||
# Else
|
||||
# msgbox "Fehler bei der Übertragung!" & vbCrLf &_
|
||||
# HTTPRequest.ResponseText & vbCrLf &_
|
||||
# "",,DEFAULT_TITLE &" - WebServices"
|
||||
#
|
||||
# End If
|
||||
# Else
|
||||
# msgbox "Fehler bei der Übertragung!" & vbCrLf &_
|
||||
# HTTPRequest.ResponseText & vbCrLf &_
|
||||
# "",,DEFAULT_TITLE &" - WebServices"
|
||||
#
|
||||
# End If
|
||||
#
|
||||
# Else
|
||||
# msgbox "Fehler bei der Übertragung!" & vbCrLf &_
|
||||
# HTTPRequest.ResponseText & vbCrLf &_
|
||||
# "",,DEFAULT_TITLE &" - WebServices"
|
||||
@@ -0,0 +1,282 @@
|
||||
#######################################################################################################################
|
||||
##### Import #####
|
||||
#######################################################################################################################
|
||||
from tkinter import*
|
||||
from datetime import datetime
|
||||
import cv2
|
||||
import numpy as np
|
||||
from pyzbar.pyzbar import decode
|
||||
import requests
|
||||
|
||||
|
||||
#######################################################################################################################
|
||||
##### Server-Options #####
|
||||
#######################################################################################################################
|
||||
WebServiceURL = "172.24.12.56"
|
||||
WebServiceBenutzerName = "a"
|
||||
WebServiceBenutzerPasswort = "b"
|
||||
WinLineMandant = "MEDT"
|
||||
WebServiceTemplateSTART = "Zeitnahme"
|
||||
WebServiceTemplateSTOP = "STOP"
|
||||
WebServiceType = "36"
|
||||
WebServiceActioncode = "1"
|
||||
|
||||
#######################################################################################################################
|
||||
##### WinLine-Options #####
|
||||
#######################################################################################################################
|
||||
Fehlzeitenstamm = "1"
|
||||
|
||||
#######################################################################################################################
|
||||
###### Frame ######
|
||||
#######################################################################################################################
|
||||
def BuildMainFrame():
|
||||
fenster = Tk()
|
||||
fenster.configure(bg="white")
|
||||
fenster.title("DD-Zeiterfassung")
|
||||
fenster.geometry("1024x768")
|
||||
|
||||
start_button = Button(fenster, text="Arbeitstag beginnen", fg="white", bg="green", command=Startbutton_action)
|
||||
exit_button = Button (fenster, text="Arbeitstag beenden ", fg="white", bg="red", command=Stopbutton_action)
|
||||
pause_button = Button (fenster, text="Pause beginnen", fg="white", bg="#b47a0e", command=PauseStartbutton_action)
|
||||
pause_end_button = Button (fenster, text="Pause beenden", fg="white", bg="#b47a0e", command=PauseStopbutton_action)
|
||||
anweisungs_label = Label(fenster, justify=CENTER, text="Wählen Sie eine Buchungsart")
|
||||
anweisungs_label2 = Label(fenster, bg="white", justify=CENTER, fg="black")
|
||||
|
||||
anweisungs_label.grid(row=0, column=2, pady=20, padx=10, sticky='ew')
|
||||
anweisungs_label2.grid(row=1, column=2, pady=20, padx=10, sticky='ew')
|
||||
start_button.grid(row=2, column=1, pady=20, padx=10, sticky='ew')
|
||||
exit_button.grid(row=2, column=2, pady=20, padx=10, sticky='ew')
|
||||
pause_button.grid(row=2, column=3, pady=20, padx=10, sticky='ew')
|
||||
pause_end_button.grid(row=2, column=4, pady=20, padx=10, sticky='ew')
|
||||
fenster.mainloop()
|
||||
|
||||
#######################################################################################################################
|
||||
##### Build Start-XML #####
|
||||
#######################################################################################################################
|
||||
def BuildXMLStart(RequestTyp, myData, Datumvon):
|
||||
if RequestTyp == 1:
|
||||
ArbeitsZeitPause = "0"
|
||||
else:
|
||||
ArbeitsZeitPause = "1"
|
||||
myDataListe = myData.split("-")
|
||||
AN_Gruppe_Ressource = myDataListe[0]
|
||||
XML_Start = ""
|
||||
XML_Start = XML_Start + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
||||
XML_Start = XML_Start + "<MESOWebService TemplateType=\"" + WebServiceType + "\"" " Template=\"" + WebServiceTemplateSTART + "\">"
|
||||
XML_Start = XML_Start + "<" + WebServiceTemplateSTART + ">"
|
||||
#Location for WinLine fields
|
||||
XML_Start = XML_Start + "<Datumvon>" + Datumvon + "</Datumvon>"
|
||||
XML_Start = XML_Start + "<Fehlzeitenstamm>" + Fehlzeitenstamm + "</Fehlzeitenstamm>"
|
||||
XML_Start = XML_Start + "<ANGruppeRessource>" + AN_Gruppe_Ressource + "</ANGruppeRessource>"
|
||||
XML_Start = XML_Start + "<TypZeitartPause>" + ArbeitsZeitPause + "</TypZeitartPause>"
|
||||
XML_Start = XML_Start + "</" + WebServiceTemplateSTART + ">"
|
||||
XML_Start = XML_Start + "</MESOWebService>"
|
||||
return XML_Start
|
||||
#######################################################################################################################
|
||||
##### Build Start-URL #####
|
||||
#######################################################################################################################
|
||||
|
||||
def BuildURLStart(XML_Start):
|
||||
URL_Start = "http://%SERVER%/ewlservice/import?User=%USER%&Password=%PASSWORD%&Company=%COMPANY%&Type=%TYPE%&Vorlage=%VORLAGE%&Actioncode=%ACTIONCODE%&byref=0&Data=%DATA%"
|
||||
URL_Start = URL_Start.replace("%SERVER%", WebServiceURL)
|
||||
URL_Start = URL_Start.replace("%USER%", WebServiceBenutzerName)
|
||||
URL_Start = URL_Start.replace("%PASSWORD%", WebServiceBenutzerPasswort)
|
||||
URL_Start = URL_Start.replace("%COMPANY%", WinLineMandant)
|
||||
URL_Start = URL_Start.replace("%TYPE%", WebServiceType)
|
||||
URL_Start = URL_Start.replace("%VORLAGE%", WebServiceTemplateSTART)
|
||||
URL_Start = URL_Start.replace("%ACTIONCODE%", WebServiceActioncode)
|
||||
URL_Start = URL_Start.replace("%DATA%", XML_Start)
|
||||
return URL_Start
|
||||
|
||||
#######################################################################################################################
|
||||
##### Build Export-URL #####
|
||||
#######################################################################################################################
|
||||
def BuildURLExport(myData,RequestTyp):
|
||||
myDataListe = myData.split("-")
|
||||
Arbeitnehmernummer = myDataListe[0]
|
||||
if RequestTyp == 4:
|
||||
WebServiceTemplateExport = "ExportPause"
|
||||
Filter = "FilterTestP-" + Arbeitnehmernummer
|
||||
else:
|
||||
WebServiceTemplateExport = "Export"
|
||||
Filter = "FilterTest-" + Arbeitnehmernummer
|
||||
XMLExport = Filter
|
||||
URL_Export = "http://%SERVER%/ewlservice/export?User=%USER%&Password=%PASSWORD%&Company=%COMPANY%&Type=%TYPE%&Vorlage=%VORLAGE%&Actioncode=%ACTIONCODE%&byref=0&Key=%KEY%"
|
||||
URL_Export = URL_Export.replace("%SERVER%", WebServiceURL)
|
||||
URL_Export = URL_Export.replace("%USER%", WebServiceBenutzerName)
|
||||
URL_Export = URL_Export.replace("%PASSWORD%", WebServiceBenutzerPasswort)
|
||||
URL_Export = URL_Export.replace("%COMPANY%", WinLineMandant)
|
||||
URL_Export = URL_Export.replace("%TYPE%", WebServiceType)
|
||||
URL_Export = URL_Export.replace("%VORLAGE%", WebServiceTemplateExport)
|
||||
URL_Export = URL_Export.replace("%ACTIONCODE%", WebServiceActioncode)
|
||||
URL_Export = URL_Export.replace("%KEY%", XMLExport)
|
||||
URL_Export = URL_Export.replace("%FILTER%", Filter)
|
||||
print("URL_Export = " + URL_Export)
|
||||
HTTPRequest_Export = requests.post(URL_Export)
|
||||
IndexVonDatum = HTTPRequest_Export.text.find("<Datumvon>")
|
||||
v1 = IndexVonDatum + len("<Datumvon>")
|
||||
v2 = v1 + 19
|
||||
Datumvon = HTTPRequest_Export.text[v1:v2]
|
||||
return Datumvon
|
||||
|
||||
|
||||
#######################################################################################################################
|
||||
##### Build End-XML #####
|
||||
#######################################################################################################################
|
||||
def BuildXMLEnde(RequestTyp, myData, OrgDateTime, ActDateTime):
|
||||
|
||||
if RequestTyp == 2:
|
||||
ArbeitsZeitPause = "0"
|
||||
else:
|
||||
ArbeitsZeitPause = "1"
|
||||
|
||||
myDataListe = myData.split("-")
|
||||
AN_Gruppe_Ressource = myDataListe[0]
|
||||
|
||||
XML_Ende = ""
|
||||
XML_Ende = XML_Ende + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
||||
XML_Ende = XML_Ende + "<MESOWebService TemplateType=\"" + WebServiceType + "\"" " Template=\"" + WebServiceTemplateSTOP + "\">"
|
||||
XML_Ende = XML_Ende + "<" + WebServiceTemplateSTOP + ">"
|
||||
XML_Ende = XML_Ende + "<Datumvon>" + OrgDateTime + "</Datumvon>"
|
||||
XML_Ende = XML_Ende + "<Datumbis>" + ActDateTime + "</Datumbis>"
|
||||
XML_Ende = XML_Ende + "<Fehlzeitenstamm>" + Fehlzeitenstamm + "</Fehlzeitenstamm>"
|
||||
XML_Ende = XML_Ende + "<ANGruppeRessource>" + AN_Gruppe_Ressource + "</ANGruppeRessource>"
|
||||
XML_Ende = XML_Ende + "<TypZeitartPause>" + ArbeitsZeitPause + "</TypZeitartPause>"
|
||||
XML_Ende = XML_Ende + "<Importoption>" + "1" + "</Importoption>"
|
||||
XML_Ende = XML_Ende + "</" + WebServiceTemplateSTOP + ">"
|
||||
XML_Ende = XML_Ende + "</MESOWebService>"
|
||||
return XML_Ende
|
||||
|
||||
#######################################################################################################################
|
||||
##### Build End-URL #####
|
||||
#######################################################################################################################
|
||||
def BuildURLEnde(XML_Ende):
|
||||
|
||||
URL_Ende = "http://%SERVER%/ewlservice/import?User=%USER%&Password=%PASSWORD%&Company=%COMPANY%&Type=%TYPE%&Vorlage=%VORLAGE%&Actioncode=%ACTIONCODE%&byref=0&Data=%DATA%"
|
||||
URL_Ende = URL_Ende.replace("%SERVER%", WebServiceURL)
|
||||
URL_Ende = URL_Ende.replace("%USER%", WebServiceBenutzerName)
|
||||
URL_Ende = URL_Ende.replace("%PASSWORD%", WebServiceBenutzerPasswort)
|
||||
URL_Ende = URL_Ende.replace("%COMPANY%", WinLineMandant)
|
||||
URL_Ende = URL_Ende.replace("%TYPE%", WebServiceType)
|
||||
URL_Ende = URL_Ende.replace("%VORLAGE%", WebServiceTemplateSTOP)
|
||||
URL_Ende = URL_Ende.replace("%ACTIONCODE%", WebServiceActioncode)
|
||||
URL_Ende = URL_Ende.replace("%DATA%", XML_Ende)
|
||||
return URL_Ende
|
||||
|
||||
#######################################################################################################################
|
||||
###### WinLine Requests ######
|
||||
#######################################################################################################################
|
||||
|
||||
def MakeWinLineRequest(RequestTyp, myData, actDateTime):
|
||||
if RequestTyp == 1:
|
||||
XMLStart = BuildXMLStart(RequestTyp, myData, actDateTime)
|
||||
URLStart = BuildURLStart(XMLStart)
|
||||
HTTPRequest_Start = requests.post(URLStart)
|
||||
print(HTTPRequest_Start.text)
|
||||
|
||||
elif RequestTyp == 2:
|
||||
OrgDateTime = BuildURLExport(myData, RequestTyp)
|
||||
XMLEnde = BuildXMLEnde(RequestTyp, myData, OrgDateTime, actDateTime)
|
||||
URLEnde = BuildURLEnde(XMLEnde)
|
||||
HTTPRequest_Ende = requests.post(URLEnde)
|
||||
print(HTTPRequest_Ende.text)
|
||||
|
||||
elif RequestTyp == 3:
|
||||
XMLStart = BuildXMLStart(RequestTyp, myData, actDateTime)
|
||||
URLStart = BuildURLStart(XMLStart)
|
||||
HTTPRequest_Start = requests.post(URLStart)
|
||||
print(HTTPRequest_Start.text)
|
||||
|
||||
elif RequestTyp == 4:
|
||||
OrgDateTime = BuildURLExport(myData, RequestTyp)
|
||||
XMLEnde = BuildXMLEnde(RequestTyp, myData, OrgDateTime, actDateTime)
|
||||
URLEnde = BuildURLEnde(XMLEnde)
|
||||
HTTPRequest_Ende = requests.post(URLEnde)
|
||||
print(HTTPRequest_Ende.text)
|
||||
#######################################################################################################################
|
||||
##### Scanner ######
|
||||
#######################################################################################################################
|
||||
def Scanner():
|
||||
cap = cv2.VideoCapture(0)
|
||||
cap.set(3, 640)
|
||||
cap.set(4, 480)
|
||||
x = True
|
||||
myData = None
|
||||
while x == True:
|
||||
success, img = cap.read()
|
||||
for barcode in decode(img):
|
||||
myData = barcode.data.decode('utf-8')
|
||||
|
||||
cv2.imshow('Result', img)
|
||||
cv2.waitKey(1)
|
||||
if myData is not None:
|
||||
x = False
|
||||
return myData
|
||||
#######################################################################################################################
|
||||
###### Button-Action ######
|
||||
# Legende #
|
||||
# RequestTyp = 1 = Arbeitstag beginnen #
|
||||
# RequestTyp = 2 = Arbeitstag beenden #
|
||||
# RequestTyp = 3 = Pause beginnen #
|
||||
# RequestTyp = 4 = Pause beenden #
|
||||
#######################################################################################################################
|
||||
def Button_action(self, RequestTyp):
|
||||
myData = Scanner()
|
||||
myDataListe = myData.split("-")
|
||||
name = myDataListe[1]
|
||||
now = datetime.now()
|
||||
actDateTime = now.strftime('%Y-%m-%d') + "T" + now.strftime('%H:%M:%S')
|
||||
TimeWithoutsec = now.strftime('%H:%M:%S')
|
||||
MakeWinLineRequest(RequestTyp, myData, actDateTime)
|
||||
|
||||
if RequestTyp == 1:
|
||||
anweisungs_label = Label(text="Hallo, " + str(name))
|
||||
anweisungs_label.grid(row=0, column=2, sticky='ew')
|
||||
anweisungs_label2 = Label(text="Es ist " + str(TimeWithoutsec) + " Uhr ")
|
||||
anweisungs_label2.grid(row=1, column=2, sticky='ew')
|
||||
self.after(3000, LabelReset)
|
||||
|
||||
elif RequestTyp == 2:
|
||||
anweisungs_label = Label(text="Auf Wiedersehen, " + str(name))
|
||||
anweisungs_label.grid(row=0, column=2, sticky='ew')
|
||||
anweisungs_label2 = Label(text="Es ist " + str(TimeWithoutsec) + " Uhr ")
|
||||
anweisungs_label2.grid(row=1, column=2, sticky='ew')
|
||||
|
||||
elif RequestTyp == 3:
|
||||
anweisungs_label = Label(text="Eine schöne Pause, " + str(name))
|
||||
anweisungs_label.grid(row=0, column=2, sticky='ew')
|
||||
anweisungs_label2 = Label(text="Es ist " + str(TimeWithoutsec) + " Uhr ")
|
||||
anweisungs_label2.grid(row=1, column=2, sticky='ew')
|
||||
|
||||
elif RequestTyp == 4:
|
||||
anweisungs_label = Label(text="Willkommen zurück, " + str(name))
|
||||
anweisungs_label.grid(row=0, column=2, sticky='ew')
|
||||
anweisungs_label2 = Label(text="Es ist " + str(TimeWithoutsec) + " Uhr ")
|
||||
anweisungs_label2.grid(row=1, column=2, sticky='ew')
|
||||
|
||||
def LabelReset():
|
||||
anweisungs_label = Label(text="Hallo2!!")
|
||||
anweisungs_label.grid(row=0, column=2, sticky='ew')
|
||||
|
||||
#######################################################################################################################
|
||||
###### Diffrent-Buttons ######
|
||||
#######################################################################################################################
|
||||
def Startbutton_action():
|
||||
RequestTyp = 1
|
||||
Button_action(RequestTyp)
|
||||
#######################################################################################################################
|
||||
def Stopbutton_action():
|
||||
RequestTyp = 2
|
||||
Button_action(RequestTyp)
|
||||
#######################################################################################################################
|
||||
def PauseStartbutton_action():
|
||||
RequestTyp = 3
|
||||
Button_action(RequestTyp)
|
||||
#######################################################################################################################
|
||||
def PauseStopbutton_action():
|
||||
RequestTyp = 4
|
||||
Button_action(RequestTyp)
|
||||
#######################################################################################################################
|
||||
##### Main #####
|
||||
#######################################################################################################################
|
||||
BuildMainFrame()
|
||||
@@ -0,0 +1,468 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Digital Data - Zeiterfassung
|
||||
# ----------------------------------------------------------------------------
|
||||
# Python-Script zur Buchung von Zeiten via QR/Barcode-Scanner inkl. Anbindung
|
||||
# an die Mesonic WinLine. Per tkinter-Bibliothek wird eine GUI erzeugt.
|
||||
# Via Webservice-Calls erfolgen verschiedene Abfragen.
|
||||
#
|
||||
# ----------------------------------------------------------------------------
|
||||
# Copyright (c) 2021 by Digital Data GmbH
|
||||
#
|
||||
# Digital Data GmbH • Ludwig-Rinn-Strasse 16 • D-35452 Heuchelheim
|
||||
# Tel.: 0641/202360 • E-Mail: info-flow@digitaldata.works
|
||||
# ----------------------------------------------------------------------------
|
||||
# Creation Date / Author: 15.09.2021 / MD
|
||||
# Version Date / Editor: 04.11.2021 / MD
|
||||
# Version Number: 1.0.1.1
|
||||
|
||||
|
||||
####################################
|
||||
# # Import # #
|
||||
####################################
|
||||
|
||||
import tkinter as tk
|
||||
|
||||
from datetime import datetime
|
||||
import cv2
|
||||
import numpy as np
|
||||
from pyzbar.pyzbar import decode
|
||||
import requests
|
||||
import configparser
|
||||
import cryptocode
|
||||
from tkinter.messagebox import showerror
|
||||
import logging
|
||||
from logging.handlers import TimedRotatingFileHandler
|
||||
from logging import Formatter
|
||||
|
||||
#####################################
|
||||
# # Server-Options # #
|
||||
# # In config.in bearbeitbar # #
|
||||
#####################################
|
||||
config = configparser.ConfigParser()
|
||||
config.sections()
|
||||
config.read('config.ini')
|
||||
|
||||
WebServiceURL = config['WEBSERVICE']['WebServiceURL']
|
||||
WebServiceBenutzerName = config['WEBSERVICE']['WebServiceBenutzerName']
|
||||
WebServiceBenutzerPasswort = config['WEBSERVICE']['WebServiceBenutzerPasswort']
|
||||
WinLineMandant = config['WEBSERVICE']['WinLineMandant']
|
||||
WebServiceTemplateSTART = config['WEBSERVICE']['WebServiceTemplateSTART']
|
||||
WebServiceTemplateSTOP = config['WEBSERVICE']['WebServiceTemplateSTOP']
|
||||
WebServiceType = config['WEBSERVICE']['WebServiceType']
|
||||
Fehlzeitenstamm = config['WEBSERVICE']['Fehlzeitenstamm']
|
||||
WeekRule = config['PAUSEKEYRULE']['WeekRule']
|
||||
WebServiceActioncode = "1"
|
||||
|
||||
dePW = cryptocode.decrypt(WebServiceBenutzerPasswort, "Zeiterfassung")
|
||||
|
||||
|
||||
|
||||
|
||||
class App(tk.Tk):
|
||||
|
||||
def showError(self, exc, val, tb):
|
||||
#showerror("Error", message=str(val))
|
||||
self.logger.error('')
|
||||
self.logger.error(exc)
|
||||
self.logger.error(val)
|
||||
self.logger.error(tb)
|
||||
|
||||
############################################
|
||||
# # Frame # #
|
||||
# Erstellt die GUI inkl. Button und Labels #
|
||||
############################################
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
# LOG-File-Generator
|
||||
self.logger = logging.getLogger('mylogger')
|
||||
self.handler = TimedRotatingFileHandler(filename='log/Zeiterfassung.log', when='D', interval=1, backupCount=30, encoding='utf-8', delay=False)
|
||||
# logging.basicConfig(format='%(asctime)s|%(levelname)s|%(message)s', level=logging.DEBUG, filename='Zeiterfassung2.log')
|
||||
|
||||
formatter = Formatter(fmt='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||
self.handler.setFormatter(formatter)
|
||||
|
||||
self.logger.addHandler(self.handler)
|
||||
self.logger.setLevel(logging.DEBUG)
|
||||
|
||||
self.configure(bg="white")
|
||||
self.title("DD-Zeiterfassung")
|
||||
self.geometry("1024x768")
|
||||
#self.attributes("-topmost", True) -- tkinter gui immer im vordergrund
|
||||
#self.wm_overrideredirect(True) -- tkinter gui ohne Titlezeile
|
||||
self.wm_attributes('-type', 'splash') # -- tkinter gui Titelzeile klappt sich ein
|
||||
|
||||
self.start_button = tk.Button(self, font=('Arial', 12), text="Arbeitstag\n beginnen", height =15, width=15, fg="white", bg="green", activebackground='blue', command=self.Startbutton_action)
|
||||
self.stop_button = tk.Button(self, font=('Arial', 12), text="Arbeitstag\n beenden ", height =15, width=15, fg="white", bg="red", activebackground='blue', command=self.Stopbutton_action)
|
||||
self.pause_button = tk.Button(self, font=('Arial', 12), text="Pause\n beginnen", height=15, width=15, fg="white", bg="#b47a0e", activebackground='blue', command=self.PauseStartbutton_action)
|
||||
self.pause_end_button = tk.Button(self, font=('Arial', 12), text="Pause\n beenden", height=15, width=15, fg="white", bg="#b47a0e", activebackground='blue', command=self.PauseStopbutton_action)
|
||||
self.anweisungs_label = tk.Label(self, font=('Arial', 12), text="Wählen Sie eine Buchungsart\n")
|
||||
self.anweisungs_label2 = tk.Label(self, font=('Arial', 12), bg="white", fg="black")
|
||||
|
||||
self.labelUhr = tk.Label(text="", font=('Arial', 12), fg='red')
|
||||
self.update_clock()
|
||||
|
||||
self.labelUhr.grid(row=0,column=4)
|
||||
self.anweisungs_label.grid(row=0, column=2, pady=20, padx=10, sticky='ew')
|
||||
self.anweisungs_label2.grid(row=1, column=2, pady=20, padx=10, sticky='ew')
|
||||
self.start_button.grid(row=2, column=1, pady=20, padx=10, sticky='ew')
|
||||
self.stop_button.grid(row=2, column=2, pady=20, padx=10, sticky='ew')
|
||||
self.pause_button.grid(row=2, column=3, pady=20, padx=10, sticky='ew')
|
||||
self.pause_end_button.grid(row=2, column=4, pady=20, padx=10, sticky='ew')
|
||||
self.report_callback_exception = self.showError
|
||||
|
||||
self.logger.info("Initialisierung abgeschlossen!")
|
||||
|
||||
########################################
|
||||
# # Button-Action # #
|
||||
# # Legende # #
|
||||
# RequestTyp = 1 = Arbeitstag beginnen #
|
||||
# RequestTyp = 2 = Arbeitstag beenden #
|
||||
# RequestTyp = 3 = Pause beginnen #
|
||||
# RequestTyp = 4 = Pause beenden #
|
||||
########################################
|
||||
# # Different-Buttons # #
|
||||
########################################
|
||||
def update_clock(self):
|
||||
now = datetime.now()
|
||||
clock = now.strftime('%H:%M:%S')
|
||||
self.labelUhr.configure(text=clock)
|
||||
self.after(1000, self.update_clock)
|
||||
|
||||
def disableButtons(self):
|
||||
self.start_button['state'] = tk.DISABLED
|
||||
self.stop_button['state'] = tk.DISABLED
|
||||
self.pause_button['state'] = tk.DISABLED
|
||||
self.pause_end_button['state'] = tk.DISABLED
|
||||
|
||||
def enableButtons(self):
|
||||
self.start_button['state'] = tk.NORMAL
|
||||
self.stop_button['state'] = tk.NORMAL
|
||||
self.pause_button['state'] = tk.NORMAL
|
||||
self.pause_end_button['state'] = tk.NORMAL
|
||||
|
||||
|
||||
def Startbutton_action(self):
|
||||
RequestTyp = 1
|
||||
self.Button_action(RequestTyp)
|
||||
|
||||
######################################
|
||||
|
||||
def Stopbutton_action(self):
|
||||
RequestTyp = 2
|
||||
self.Button_action(RequestTyp)
|
||||
|
||||
######################################
|
||||
|
||||
def PauseStartbutton_action(self):
|
||||
RequestTyp = 3
|
||||
self.Button_action(RequestTyp)
|
||||
|
||||
######################################
|
||||
|
||||
def PauseStopbutton_action(self):
|
||||
RequestTyp = 4
|
||||
self.Button_action(RequestTyp)
|
||||
|
||||
|
||||
######################################
|
||||
|
||||
def Button_action(self, RequestTyp):
|
||||
myData = Scanner(self)
|
||||
#myDataListe = myData.split("-")
|
||||
now = datetime.now()
|
||||
actDateTime = now.strftime('%Y-%m-%d') + "T" + now.strftime('%H:%M:%S')
|
||||
MakeWinLineRequest(self, RequestTyp, myData, actDateTime, now)
|
||||
|
||||
|
||||
######################################
|
||||
# # Reset der GUI # #
|
||||
######################################
|
||||
def LabelReset(self):
|
||||
|
||||
anweisungs_label = tk.Label(font=('Arial', 12), text="Wählen Sie eine Buchungsart\n")
|
||||
anweisungs_label.grid(row=0, column=2, sticky='ew')
|
||||
anweisungs_label2 = tk.Label(font=('Arial', 12), bg="white", text="")
|
||||
anweisungs_label2.grid(row=1, column=2, sticky='ew')
|
||||
self.configure(bg="white")
|
||||
app.event_generate('<Motion>', warp=True, x=1, y=1) # Set the Mouse-Position to x/y
|
||||
self.enableButtons(self)
|
||||
|
||||
######################################
|
||||
# # Build Start-XML # #
|
||||
######################################
|
||||
def BuildXMLStart(RequestTyp, myData, Datumvon):
|
||||
if RequestTyp == 1:
|
||||
ArbeitsZeitPause = "0"
|
||||
Fehlzeitenstamm =config['WEBSERVICE']['Fehlzeitenstamm']
|
||||
|
||||
else:
|
||||
ArbeitsZeitPause = "1"
|
||||
if WeekRule == 'on':
|
||||
Weekday = datetime.today().isoweekday()
|
||||
Fehlzeitenstamm = config['PAUSEKEYRULE']['Weekday' + str(Weekday)]
|
||||
else:
|
||||
Fehlzeitenstamm = "1"
|
||||
myDataListe = myData.split("-")
|
||||
AN_Gruppe_Ressource = myDataListe[0]
|
||||
XML_Start = ""
|
||||
XML_Start = XML_Start + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
||||
XML_Start = XML_Start + "<MESOWebService TemplateType=\"" + WebServiceType + "\"" " Template=\"" + WebServiceTemplateSTART + "\">"
|
||||
XML_Start = XML_Start + "<" + WebServiceTemplateSTART + ">"
|
||||
#Location for WinLine fields
|
||||
XML_Start = XML_Start + "<Datumvon>" + Datumvon + "</Datumvon>"
|
||||
XML_Start = XML_Start + "<Fehlzeitenstamm>" + Fehlzeitenstamm + "</Fehlzeitenstamm>"
|
||||
XML_Start = XML_Start + "<ANGruppeRessource>" + AN_Gruppe_Ressource + "</ANGruppeRessource>"
|
||||
XML_Start = XML_Start + "<TypZeitartPause>" + ArbeitsZeitPause + "</TypZeitartPause>"
|
||||
XML_Start = XML_Start + "</" + WebServiceTemplateSTART + ">"
|
||||
XML_Start = XML_Start + "</MESOWebService>"
|
||||
return XML_Start
|
||||
######################################
|
||||
# # Build Start-URL # #
|
||||
######################################
|
||||
|
||||
def BuildURLStart(XML_Start):
|
||||
URL_Start = "http://%SERVER%/ewlservice/import?User=%USER%&Password=%PASSWORD%&Company=%COMPANY%&Type=%TYPE%&Vorlage=%VORLAGE%&Actioncode=%ACTIONCODE%&byref=0&Data=%DATA%"
|
||||
URL_Start = URL_Start.replace("%SERVER%", WebServiceURL)
|
||||
URL_Start = URL_Start.replace("%USER%", WebServiceBenutzerName)
|
||||
URL_Start = URL_Start.replace("%PASSWORD%", dePW)
|
||||
URL_Start = URL_Start.replace("%COMPANY%", WinLineMandant)
|
||||
URL_Start = URL_Start.replace("%TYPE%", WebServiceType)
|
||||
URL_Start = URL_Start.replace("%VORLAGE%", WebServiceTemplateSTART)
|
||||
URL_Start = URL_Start.replace("%ACTIONCODE%", WebServiceActioncode)
|
||||
URL_Start = URL_Start.replace("%DATA%", XML_Start)
|
||||
return URL_Start
|
||||
|
||||
####################################
|
||||
# # Build Export-URL # #
|
||||
####################################
|
||||
def BuildURLExport(myData,RequestTyp):
|
||||
myDataListe = myData.split("-")
|
||||
Arbeitnehmernummer = myDataListe[0]
|
||||
if RequestTyp == 1:
|
||||
WebServiceTemplateExport = "Export"
|
||||
Filter = "FilterTest-" + Arbeitnehmernummer
|
||||
elif RequestTyp == 2:
|
||||
WebServiceTemplateExport = "Export"
|
||||
Filter = "FilterTest-" + Arbeitnehmernummer
|
||||
elif RequestTyp == 3:
|
||||
WebServiceTemplateExport = "ExportPause"
|
||||
Filter = "FilterTestP-" + Arbeitnehmernummer
|
||||
elif RequestTyp == 4:
|
||||
WebServiceTemplateExport = "ExportPause"
|
||||
Filter = "FilterTestP-" + Arbeitnehmernummer
|
||||
|
||||
XMLExport = Filter
|
||||
URL_Export = "http://%SERVER%/ewlservice/export?User=%USER%&Password=%PASSWORD%&Company=%COMPANY%&Type=%TYPE%&Vorlage=%VORLAGE%&Actioncode=%ACTIONCODE%&byref=0&Key=%KEY%"
|
||||
URL_Export = URL_Export.replace("%SERVER%", WebServiceURL)
|
||||
URL_Export = URL_Export.replace("%USER%", WebServiceBenutzerName)
|
||||
URL_Export = URL_Export.replace("%PASSWORD%", dePW)
|
||||
URL_Export = URL_Export.replace("%COMPANY%", WinLineMandant)
|
||||
URL_Export = URL_Export.replace("%TYPE%", WebServiceType)
|
||||
URL_Export = URL_Export.replace("%VORLAGE%", WebServiceTemplateExport)
|
||||
URL_Export = URL_Export.replace("%ACTIONCODE%", WebServiceActioncode)
|
||||
URL_Export = URL_Export.replace("%KEY%", XMLExport)
|
||||
URL_Export = URL_Export.replace("%FILTER%", Filter)
|
||||
print("URL_Export = " + URL_Export)
|
||||
HTTPRequest_Export = requests.post(URL_Export)
|
||||
IndexVonDatum = HTTPRequest_Export.text.find("<Datumvon>")
|
||||
v1 = IndexVonDatum + len("<Datumvon>")
|
||||
v2 = v1 + 19
|
||||
Datumvon = HTTPRequest_Export.text[v1:v2]
|
||||
return Datumvon
|
||||
|
||||
|
||||
######################################
|
||||
# # Build End-XML # #
|
||||
######################################
|
||||
def BuildXMLEnde(RequestTyp, myData, OrgDateTime, ActDateTime):
|
||||
print(RequestTyp)
|
||||
if RequestTyp == 2:
|
||||
ArbeitsZeitPause = "0"
|
||||
Fehlzeitenstamm =config['WEBSERVICE']['Fehlzeitenstamm']
|
||||
else:
|
||||
ArbeitsZeitPause = "1"
|
||||
if WeekRule == 'on':
|
||||
Weekday = datetime.today().isoweekday()
|
||||
Fehlzeitenstamm = config['PAUSEKEYRULE']['Weekday' + str(Weekday)]
|
||||
else:
|
||||
Fehlzeitenstamm = "1"
|
||||
myDataListe = myData.split("-")
|
||||
AN_Gruppe_Ressource = myDataListe[0]
|
||||
|
||||
XML_Ende = ""
|
||||
XML_Ende = XML_Ende + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
||||
XML_Ende = XML_Ende + "<MESOWebService TemplateType=\"" + WebServiceType + "\"" " Template=\"" + WebServiceTemplateSTOP + "\">"
|
||||
XML_Ende = XML_Ende + "<" + WebServiceTemplateSTOP + ">"
|
||||
XML_Ende = XML_Ende + "<Datumvon>" + OrgDateTime + "</Datumvon>"
|
||||
XML_Ende = XML_Ende + "<Datumbis>" + ActDateTime + "</Datumbis>"
|
||||
XML_Ende = XML_Ende + "<Fehlzeitenstamm>" + Fehlzeitenstamm + "</Fehlzeitenstamm>"
|
||||
XML_Ende = XML_Ende + "<ANGruppeRessource>" + AN_Gruppe_Ressource + "</ANGruppeRessource>"
|
||||
XML_Ende = XML_Ende + "<TypZeitartPause>" + ArbeitsZeitPause + "</TypZeitartPause>"
|
||||
XML_Ende = XML_Ende + "<Importoption>" + "1" + "</Importoption>"
|
||||
XML_Ende = XML_Ende + "</" + WebServiceTemplateSTOP + ">"
|
||||
XML_Ende = XML_Ende + "</MESOWebService>"
|
||||
return XML_Ende
|
||||
|
||||
######################################
|
||||
# # Build End-URL # #
|
||||
######################################
|
||||
def BuildURLEnde(XML_Ende):
|
||||
|
||||
URL_Ende = "http://%SERVER%/ewlservice/import?User=%USER%&Password=%PASSWORD%&Company=%COMPANY%&Type=%TYPE%&Vorlage=%VORLAGE%&Actioncode=%ACTIONCODE%&byref=0&Data=%DATA%"
|
||||
URL_Ende = URL_Ende.replace("%SERVER%", WebServiceURL)
|
||||
URL_Ende = URL_Ende.replace("%USER%", WebServiceBenutzerName)
|
||||
URL_Ende = URL_Ende.replace("%PASSWORD%", dePW)
|
||||
URL_Ende = URL_Ende.replace("%COMPANY%", WinLineMandant)
|
||||
URL_Ende = URL_Ende.replace("%TYPE%", WebServiceType)
|
||||
URL_Ende = URL_Ende.replace("%VORLAGE%", WebServiceTemplateSTOP)
|
||||
URL_Ende = URL_Ende.replace("%ACTIONCODE%", WebServiceActioncode)
|
||||
URL_Ende = URL_Ende.replace("%DATA%", XML_Ende)
|
||||
return URL_Ende
|
||||
|
||||
######################################
|
||||
# WinLine Requests # #
|
||||
######################################
|
||||
|
||||
def MakeWinLineRequest(self, RequestTyp, myData, actDateTime, now):
|
||||
myDataListe = myData.split("-")
|
||||
name = myDataListe[1]
|
||||
TimeWithoutsec = now.strftime('%H:%M:%S')
|
||||
|
||||
#######################################
|
||||
|
||||
if RequestTyp == 1:
|
||||
CheckStatus = BuildURLExport(myData, RequestTyp)
|
||||
|
||||
if CheckStatus == "sion=\"1.0\" encoding":
|
||||
XMLStart = BuildXMLStart(RequestTyp, myData, actDateTime)
|
||||
URLStart = BuildURLStart(XMLStart)
|
||||
HTTPRequest_Start = requests.post(URLStart)
|
||||
print(HTTPRequest_Start.text)
|
||||
self.anweisungs_label = tk.Label(font=('Arial', 12), text="Hallo,\n " + str(name))
|
||||
self.anweisungs_label.grid(row=0, column=2, sticky='ew')
|
||||
self.anweisungs_label2 = tk.Label(font=('Arial', 12), text="Es ist " + str(TimeWithoutsec) + " Uhr ")
|
||||
self.anweisungs_label2.grid(row=1, column=2, sticky='ew')
|
||||
self.configure(bg="green")
|
||||
self.after(5000, LabelReset, self)
|
||||
|
||||
|
||||
else:
|
||||
self.anweisungs_label = tk.Label(font=('Arial', 12), text= "Sie sind bereits eingeloggt\n")
|
||||
self.anweisungs_label.grid(row=0, column=2, sticky='ew')
|
||||
self.configure(bg="red")
|
||||
self.after(5000, LabelReset, self)
|
||||
|
||||
###################################
|
||||
|
||||
elif RequestTyp == 2:
|
||||
OrgDateTime = BuildURLExport(myData, RequestTyp)
|
||||
Weekday = datetime.today().isoweekday()
|
||||
if OrgDateTime == "sion=\"1.0\" encoding":
|
||||
self.anweisungs_label = tk.Label(font=('Arial', 12), text="Sie sind nicht eingeloggt\n")
|
||||
self.anweisungs_label.grid(row=0, column=2, sticky='ew')
|
||||
self.configure(bg="red")
|
||||
self.after(5000, LabelReset, self)
|
||||
|
||||
else:
|
||||
XMLEnde = BuildXMLEnde(RequestTyp, myData, OrgDateTime, actDateTime)
|
||||
URLEnde = BuildURLEnde(XMLEnde)
|
||||
HTTPRequest_Ende = requests.post(URLEnde)
|
||||
print(HTTPRequest_Ende.text)
|
||||
self.anweisungs_label = tk.Label(font=('Arial', 12), text="Auf Wiedersehen,\n " + str(name))
|
||||
self.anweisungs_label.grid(row=0, column=2, sticky='ew')
|
||||
self.anweisungs_label2 = tk.Label(font=('Arial', 12), text="Es ist " + str(TimeWithoutsec) + " Uhr ")
|
||||
self.anweisungs_label2.grid(row=1, column=2, sticky='ew')
|
||||
self.configure(bg="green")
|
||||
self.after(5000, LabelReset, self)
|
||||
|
||||
####################################
|
||||
|
||||
elif RequestTyp == 3:
|
||||
CheckStatus = BuildURLExport(myData, RequestTyp)
|
||||
if CheckStatus == "sion=\"1.0\" encoding":
|
||||
XMLStart = BuildXMLStart(RequestTyp, myData, actDateTime)
|
||||
URLStart = BuildURLStart(XMLStart)
|
||||
HTTPRequest_Start = requests.post(URLStart)
|
||||
print(HTTPRequest_Start.text)
|
||||
self.anweisungs_label = tk.Label(font=('Arial', 12), text=u"Eine schöne Pause,\n " + str(name))
|
||||
self.anweisungs_label.grid(row=0, column=2, sticky='ew')
|
||||
self.anweisungs_label2 = tk.Label(font=('Arial', 12), text="Es ist " + str(TimeWithoutsec) + " Uhr ")
|
||||
self.anweisungs_label2.grid(row=1, column=2, sticky='ew')
|
||||
self.configure(bg="green")
|
||||
self.after(5000, LabelReset, self)
|
||||
|
||||
else:
|
||||
self.anweisungs_label = tk.Label(font=('Arial', 12), text="Sie sind bereits in Pause\n")
|
||||
self.anweisungs_label.grid(row=0, column=2, sticky='ew')
|
||||
self.configure(bg="red")
|
||||
self.after(5000, LabelReset, self)
|
||||
|
||||
#######################################
|
||||
|
||||
elif RequestTyp == 4:
|
||||
OrgDateTime = BuildURLExport(myData, RequestTyp)
|
||||
if OrgDateTime == "sion=\"1.0\" encoding":
|
||||
|
||||
self.anweisungs_label = tk.Label(font=('Arial', 12), text="Sie sind nicht in Pause\n")
|
||||
self.anweisungs_label.grid(row=0, column=2, sticky='ew')
|
||||
self.configure(bg="red")
|
||||
self.after(5000, LabelReset, self)
|
||||
|
||||
else:
|
||||
XMLEnde = BuildXMLEnde(RequestTyp, myData, OrgDateTime, actDateTime)
|
||||
URLEnde = BuildURLEnde(XMLEnde)
|
||||
HTTPRequest_Ende = requests.post(URLEnde)
|
||||
print(HTTPRequest_Ende.text)
|
||||
self.anweisungs_label = tk.Label(font=('Arial', 12), text="Willkommen zurück,\n " + str(name))
|
||||
self.anweisungs_label.grid(row=0, column=2, sticky='ew')
|
||||
self.anweisungs_label2 = tk.Label(font=('Arial', 12), text="Es ist " + str(TimeWithoutsec) + " Uhr ")
|
||||
self.anweisungs_label2.grid(row=1, column=2, sticky='ew')
|
||||
self.configure(bg="green")
|
||||
self.after(5000, LabelReset, self)
|
||||
######################################
|
||||
# # Scanner # #
|
||||
######################################
|
||||
|
||||
def Scanner(self):
|
||||
app.event_generate('<Motion>', warp=True, x=1, y=1)
|
||||
self.anweisungs_label = tk.Label(font=('Arial', 12), text="Wählen Sie eine Buchungsart\n")
|
||||
cap = cv2.VideoCapture(0)
|
||||
cap.set(3, 160) # vorher 640
|
||||
cap.set(4, 120) # vorher 480
|
||||
|
||||
cv2.namedWindow('Result')
|
||||
cv2.moveWindow('Result', 2, 2)
|
||||
|
||||
myData = None
|
||||
#Abbruch = False
|
||||
for x in range(0, 100):
|
||||
success, img = cap.read()
|
||||
for barcode in decode(img):
|
||||
myData = barcode.data.decode('utf-8')
|
||||
rotated_img = np.rot90(img, k=3)
|
||||
|
||||
cv2.imshow('Result', rotated_img)
|
||||
cv2.waitKey(1)
|
||||
|
||||
if myData is not None:
|
||||
cap.release()
|
||||
cv2.destroyAllWindows()
|
||||
return myData
|
||||
else:
|
||||
self.after(100)
|
||||
|
||||
cap.release()
|
||||
cv2.destroyAllWindows()
|
||||
LabelReset(self)
|
||||
|
||||
######################################
|
||||
# # Main # #
|
||||
######################################
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = App()
|
||||
app.mainloop()
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
[WEBSERVICE]
|
||||
WebServiceURL = 172.24.12.56
|
||||
WebServiceBenutzerName = a
|
||||
WebServiceBenutzerPasswort = oA==*np3ABdKeUUVEVpS3NcQfWw==*VgQhIsYMNUKADPS33oREdQ==*CaGcqXysPJcpk/GD25qZfw==
|
||||
WinLineMandant = MEDT
|
||||
WebServiceTemplateSTART = Zeitnahme
|
||||
WebServiceTemplateSTOP = STOP
|
||||
WebServiceType = 36
|
||||
Fehlzeitenstamm = 1
|
||||
|
||||
###### PAUSEKEYRULE = on/off ### on = Verschiedene Pausenarten für verschiedene Wochentage. off = Es existiert nur eine Pausenart ### Weekday1 = Montag Weekday7 = sunday ### Aufbau: Weekday = Keynr aus Pausenstamm
|
||||
|
||||
[PAUSEKEYRULE]
|
||||
WeekRule = on
|
||||
Weekday1 = 1
|
||||
Weekday2 = 1
|
||||
Weekday3 = 1
|
||||
Weekday4 = 1
|
||||
Weekday5 = 1
|
||||
Weekday6 = 2
|
||||
Weekday7 = 1
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
This is a WARNING message
|
||||
This is an ERROR message
|
||||
This is a CRITICAL message
|
||||
This is a WARNING message
|
||||
This is an ERROR message
|
||||
This is a CRITICAL message
|
||||
@@ -0,0 +1,94 @@
|
||||
# import the necessary packages
|
||||
from __future__ import print_function
|
||||
from PIL import Image
|
||||
from PIL import ImageTk
|
||||
import Tkinter as tki
|
||||
import threading
|
||||
import datetime
|
||||
import imutils
|
||||
import cv2
|
||||
import os
|
||||
|
||||
class PhotoBoothApp:
|
||||
def __init__(self, vs, outputPath):
|
||||
# store the video stream object and output path, then initialize
|
||||
# the most recently read frame, thread for reading frames, and
|
||||
# the thread stop event
|
||||
self.vs = vs
|
||||
self.outputPath = outputPath
|
||||
self.frame = None
|
||||
self.thread = None
|
||||
self.stopEvent = None
|
||||
# initialize the root window and image panel
|
||||
self.root = tki.Tk()
|
||||
self.panel = None
|
||||
|
||||
|
||||
# create a button, that when pressed, will take the current
|
||||
# frame and save it to file
|
||||
btn = tki.Button(self.root, text="Snapshot!",
|
||||
command=self.takeSnapshot)
|
||||
btn.pack(side="bottom", fill="both", expand="yes", padx=10,
|
||||
pady=10)
|
||||
# start a thread that constantly pools the video sensor for
|
||||
# the most recently read frame
|
||||
self.stopEvent = threading.Event()
|
||||
self.thread = threading.Thread(target=self.videoLoop, args=())
|
||||
self.thread.start()
|
||||
# set a callback to handle when the window is closed
|
||||
self.root.wm_title("PyImageSearch PhotoBooth")
|
||||
self.root.wm_protocol("WM_DELETE_WINDOW", self.onClose)
|
||||
|
||||
|
||||
def videoLoop(self):
|
||||
# DISCLAIMER:
|
||||
# I'm not a GUI developer, nor do I even pretend to be. This
|
||||
# try/except statement is a pretty ugly hack to get around
|
||||
# a RunTime error that Tkinter throws due to threading
|
||||
try:
|
||||
# keep looping over frames until we are instructed to stop
|
||||
while not self.stopEvent.is_set():
|
||||
# grab the frame from the video stream and resize it to
|
||||
# have a maximum width of 300 pixels
|
||||
self.frame = self.vs.read()
|
||||
self.frame = imutils.resize(self.frame, width=300)
|
||||
|
||||
# OpenCV represents images in BGR order; however PIL
|
||||
# represents images in RGB order, so we need to swap
|
||||
# the channels, then convert to PIL and ImageTk format
|
||||
image = cv2.cvtColor(self.frame, cv2.COLOR_BGR2RGB)
|
||||
image = Image.fromarray(image)
|
||||
image = ImageTk.PhotoImage(image)
|
||||
|
||||
# if the panel is not None, we need to initialize it
|
||||
if self.panel is None:
|
||||
self.panel = tki.Label(image=image)
|
||||
self.panel.image = image
|
||||
self.panel.pack(side="left", padx=10, pady=10)
|
||||
|
||||
# otherwise, simply update the panel
|
||||
else:
|
||||
self.panel.configure(image=image)
|
||||
self.panel.image = image
|
||||
except RuntimeError, e:
|
||||
print("[INFO] caught a RuntimeError")
|
||||
|
||||
|
||||
def takeSnapshot(self):
|
||||
# grab the current timestamp and use it to construct the
|
||||
# output path
|
||||
ts = datetime.datetime.now()
|
||||
filename = "{}.jpg".format(ts.strftime("%Y-%m-%d_%H-%M-%S"))
|
||||
p = os.path.sep.join((self.outputPath, filename))
|
||||
# save the file
|
||||
cv2.imwrite(p, self.frame.copy())
|
||||
print("[INFO] saved {}".format(filename))
|
||||
|
||||
|
||||
ef onClose(self):
|
||||
# set the stop event, cleanup the camera, and allow the rest of
|
||||
# the quit process to continue
|
||||
print("[INFO] closing...")
|
||||
self.stopEvent.set()
|
||||
self.vs.stop()
|
||||
self.root.quit()
|
||||
@@ -0,0 +1,24 @@
|
||||
try:
|
||||
import Tkinter as tk
|
||||
except:
|
||||
import tkinter as tk
|
||||
|
||||
import time
|
||||
import logging
|
||||
|
||||
class Clock():
|
||||
def __init__(self):
|
||||
self.root = tk.Tk()
|
||||
self.label = tk.Label(text="", font=('Helvetica', 48), fg='red')
|
||||
self.label.pack()
|
||||
self.update_clock()
|
||||
self.root.mainloop()
|
||||
|
||||
def update_clock(self):
|
||||
now = time.strftime("%H:%M:%S")
|
||||
self.label.configure(text=now)
|
||||
self.root.after(1000, self.update_clock)
|
||||
|
||||
|
||||
logging.basicConfig( level=logging.DEBUG, filename='example.log')
|
||||
app = Clock()
|
||||
Reference in New Issue
Block a user