Exemplo n.º 1
0
 def Confirm(self):
     try:
         if self.BusinessEntity == None:
             project = Project.Project(None,
                                       self.ProjectOmschrijvingVar.get(),
                                       self.ProjectIDVar.get(),
                                       self.Button.get(), True)
             if project.Button == '': project.Button = None
             bl = BLProject.BLProject(self.Connection)
             bl.Create(project)
         else:
             project = self.BusinessEntity
             project.Description = self.ProjectOmschrijvingVar.get()
             project.ExterneId = self.ProjectIDVar.get()
             project.Button = self.Button.get()
             if project.Button == '': project.Button = None
             bl = BLProject.BLProject(self.Connection)
             bl.Update(project)
     except sqlite3.IntegrityError as e:
         messagebox.showerror('Error', 'Button must be unique')
         Logger.LogError(str(e))
         return
     except Exception as e:
         Logger.LogError(str(e))
         return
     finally:
         self.Quit()
Exemplo n.º 2
0
 def __init__(self):
     config = configparser.ConfigParser()
     config.read('config.ini')
     try:
         self.Connection = sqlite3.connect(
             config['DEFAULT']['DataBaseName'])
         Logger.LogInfo('DataBase Connection Established')
     except Exception as e:
         Logger.LogError(str(e))
Exemplo n.º 3
0
def ConvertToEuropeanTime(dateString):
    try:
        timeArray = dateString.split('-')
        year = timeArray[0]
        month = timeArray[1]
        day = timeArray[2]
        return year + '-' + month + '-' + day
    except Exception as e:
        Logger.LogError(e)
Exemplo n.º 4
0
def CopyToCodex(dbConn, date):
    try:
        blTr = BLTimeRecord.BLTimeRecord(dbConn)
        timeRecords = blTr.GetAllForDate(date)
        blPr = BLProject.BLProject(dbConn)
        blRt = BLRecordType.BLRecordType(dbConn)
        sequence = ''
        for item in timeRecords:
            item1 = blPr.GetProjectExterneID(item.ProjectID)
            item2 = blRt.GetRecordTypeExterneID(item.RecordTypeID)
            s1Time = time.strptime(item.StartHour, "%Y-%m-%d %H:%M")
            s2Time = time.strptime(item.EndHour, "%Y-%m-%d %H:%M")
            item3 = time.strftime("%H:%M", s1Time)
            item4 = time.strftime("%H:%M", s2Time)
            item5 = item.Description
            s = ""
            string1 = ""
            string2 = ""
            item.StatusID = TimeRecordStatusEnum.TimeRecordStatusEnum.Gekopieerd.value
            blTr.Update(item)
            if len(item5) > 30:
                items = item5.split(" ")
                countChar = 0

                indexToSplit = 0
                for i in range(0, len(items)):
                    countChar = countChar + len(items[i])
                    if i > 30:
                        indexToSplit = i - 1
                        break
                filler = " "
                if indexToSplit == 0:
                    indexToSplit = 30
                    filler = ""
                list1 = item5[0:indexToSplit]
                list2 = item5[indexToSplit:]
                string1 = filler.join(list1)
                string2 = filler.join(list2)
            else:
                string1 = item5
            km = "\t"
            if not item.Km is None:
                km = str(item.Km) + "\t"
            line = (item1, "\t", "\t", "\t", item2, "\t", "\t", "\t", km, "\t",
                    item3, "\t", item4, "\t", string1, "\t", string2, "\n")
            sequence = sequence + s.join(line)
        return sequence
    except Exception as e:
        Logger.LogError(str(e))
Exemplo n.º 5
0
 def Confirm(self):
     try:
         if self.BusinessEntity == None:
             recordType = RecordType.RecordType(
                 None, self.RecordTypeOmschrijving.get(),
                 self.RecordTypeExterneID.get())
             bl = BLRecordType.BLRecordType(self.Connection)
             bl.Create(recordType)
         else:
             recordType = self.BusinessEntity
             recordType.Description = self.RecordTypeOmschrijving.get()
             recordType.ExterneId = self.RecordTypeExterneID.get()
             bl = BLRecordType.BLRecordType(self.Connection)
             bl.Update(recordType)
         self.Master.quit()
     except Exception as e:
         Logger.LogError(str(e))
         return
Exemplo n.º 6
0
def GetLastLogon():
    try:
        user = getpass.getuser()
        start_date = datetime.datetime.now() + datetime.timedelta(days=-1)
        end_date = start_date + datetime.timedelta(days=2)

        dtmStartDate = datetime.datetime.strftime(start_date,
                                                  '%Y%m%d000000.000000-480')
        #dtmStartDate = '20180512000000.000000-480'
        dtmEndDate = datetime.datetime.strftime(end_date,
                                                '%Y%m%d000000.000000-480')
        # Initialize WMI objects and query.
        wmi_o = wmi.WMI('.')
        wql = ("Select * from Win32_NTLogEvent Where TimeWritten > '" +
               dtmStartDate + "' and TimeWritten < '" + dtmEndDate + "'" +
               "and EventCode =" + str(4672))

        # Query WMI object.
        wql_r = wmi_o.query(wql)
        t = None
        for i in wql_r:
            if i.InsertionStrings[1] == user:
                t = i.TimeGenerated
                break

        # year = t[:4]
        # month = t[4:6]
        # day = t[6:8]
        hour = ""
        minutes = ""

        if not t is None:
            hour = str(int(t[8:10]) + 2)
            minutes = t[10:12]
        return hour + ":" + minutes  # + " " + day + "-" + month + "-" + year
    except Exception as e:
        Logger.LogError(e)
Exemplo n.º 7
0
from DataAccess.DataBaseConnection import DataBaseConnection
from BusinessEntities import *
from DataAccess.DAProject import DAProject
from DataAccess.DAController import DAController
from GUI.MainScreen import MainScreen
from DataAccess.Log import Logger
from tkinter import Tk, ttk

#Handle Project Initialisations
root = Tk()
databaseConnection = DataBaseConnection()
mainScreen = MainScreen(root, databaseConnection)
try:
    Logger.LogInfo('Application Starting...')
    mainScreen.Show()
except Exception as e:
    Logger.LogError(str(e), True)
finally:
    mainScreen.KillEvent.set()
    mainScreen.ControllerThread.join()
    Logger.LogInfo('Application Stopping...')
    databaseConnection.CloseConnection()