Object contact logic implemented
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
from .DbManager import DbManager
|
||||
from PySide6.QtCore import QObject, Signal
|
||||
import json
|
||||
import mariadb
|
||||
|
||||
|
||||
class ContactDAO:
|
||||
class ContactDAO(QObject):
|
||||
newObjectContactAdded = Signal(bool)
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
#print(f"*** File: {__file__}, __init__()")
|
||||
self.__con = DbManager().getConnection()
|
||||
if self.__con:
|
||||
@@ -18,18 +22,28 @@ class ContactDAO:
|
||||
if self.__cur:
|
||||
self.__cur.callproc("addContactPerson", (enc_key, json.dumps(contact),))
|
||||
self.__con.commit()
|
||||
self.__cur.callproc("getLastInsertId")
|
||||
contact_id = self.__cur.fetchone()
|
||||
self.__cur.callproc("logger",(contact_id[0], "INSERT", "addContactPerson: New Contact added",))
|
||||
self.__con.commit()
|
||||
return contact_id[0]
|
||||
else:
|
||||
return None
|
||||
except mariadb.Error as e:
|
||||
print("MDB: " + str(e))
|
||||
except Exception as e:
|
||||
print("PYT: " + str(e))
|
||||
|
||||
def addObjectContact(self, contact, objectid, enc_key):
|
||||
try:
|
||||
if self.__cur:
|
||||
self.__cur.callproc("addObjectContact", (enc_key, json.dumps(contact), objectid,))
|
||||
self.__con.commit()
|
||||
self.__cur.callproc("logObjectContact")
|
||||
self.__con.commit()
|
||||
self.newObjectContactAdded.emit(True)
|
||||
except mariadb.Error as e:
|
||||
print("MDB (addObjectContact): " + str(e))
|
||||
self.newObjectContactAdded.emit(False)
|
||||
except Exception as e:
|
||||
print("PYT: " + str(e))
|
||||
self.newObjectContactAdded.emit(False)
|
||||
|
||||
def getContact(self, contact_id, enc_key = None):
|
||||
try:
|
||||
if self.__cur:
|
||||
|
||||
Reference in New Issue
Block a user