Sindbad~EG File Manager

Current Path : /home/numerotech/scans.numerotech.com/scan_v1/core/model/__pycache__/
Upload File :
Current File : //home/numerotech/scans.numerotech.com/scan_v1/core/model/__pycache__/BadgeUserModel.cpython-39.pyc

a

�/�d�0�@srddlmZmZmZmZmZmZmZmZddl	m
Z
mZddlm
Z
ddlZee
jdddd�ZGd	d
�d
�ZdS)�)�
create_engine�MetaData�Table�insert�select�update�delete�text)�and_�or_)�appN�DATABASE_URITi)�
pool_pre_ping�pool_recyclec@sdeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�BadgeUserModelc
Cs>zt�|_Wn,ty8}zt|�WYd}~n
d}~00dS)N)r�meta�	Exception�print)�self�e�r�Z/home/numerote/conference.numerotech.com/food_kit_scan_badges/core/model/BadgeUserModel.py�__init__szBadgeUserModel.__init__cCs"t��}td|d�}|�|�}td|d�}|�|�}td|d�}|�|�}td|d�}	|�|	�}td	|d
�}	|�|	�}d|}
d|}d
|}d|}
d|}td|
d|d|d|
d|d|dt|�d�}|�|�}|��td�|�rdSdSdS)Nz&CREATE TABLE IF NOT EXISTS `delegates_aT` ( `delegate_id` int(11) unsigned zerofill NOT NULL AUTO_INCREMENT,`user_id` int DEFAULT NULL, `delegate_no` int DEFAULT NULL,`conf_id` int DEFAULT NULL, `role` varchar(100) DEFAULT NULL, `full_name` varchar(250) DEFAULT NULL, `email` varchar(70) DEFAULT NULL,  `mobile` varchar(30) DEFAULT NULL,  `city` varchar(70) DEFAULT NULL,  `state` varchar(70) DEFAULT NULL,  `membership_no` varchar(50) DEFAULT NULL, `mc_number` varchar(70) DEFAULT NULL  , `company_name` varchar(600) DEFAULT NULL,  `counter` int DEFAULT NULL,  `batch` varchar(30) DEFAULT NULL,  `is_kit` int DEFAULT '0',  `is_exhibitor` int DEFAULT '0',  `signed_by` varchar(100) DEFAULT NULL,  `comments` varchar(350) DEFAULT NULL,  `signed_on` datetime DEFAULT NULL,  `sync_at` datetime DEFAULT NULL,  `devie_type` varchar(60) DEFAULT NULL,  `user_type` varchar(100) DEFAULT NULL, `created_at` datetime DEFAULT NULL, `updated_at` datetime DEFAULT NULL, `deleted_at` datetime DEFAULT NULL,  `b_color` varchar(45) DEFAULT NULL,  `commitment_content` mediumtext, PRIMARY KEY (`delegate_id`)) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;z2CREATE TABLE IF NOT EXISTS `fc_delegates_sessions_z�` (`delegate_session_id` int NOT NULL PRIMARY KEY AUTO_INCREMENT,`delegate_no` int(11),`session_id` int(11),`created_at` datetime,`updated_at` datetime,`deleted_at` datetime,`limit` int DEFAULT '1' );z.CREATE TABLE IF NOT EXISTS `fc_sessions_entry_a
` (`session_entry_id` int unsigned NOT NULL AUTO_INCREMENT,  `delegate_no` int DEFAULT NULL, `session_id` int unsigned DEFAULT NULL,  `created_at` datetime DEFAULT NULL,  `updated_at` datetime DEFAULT NULL,  `deleted_at` datetime DEFAULT NULL,  `is_token` int DEFAULT NULL, `ref_delegate_no` int DEFAULT NULL,  `ref_name` varchar(120) DEFAULT NULL,  `ref_mobile` varchar(30) DEFAULT NULL,`scan_system_name` varchar(120) DEFAULT NULL,  PRIMARY KEY (`session_entry_id`)) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 ;z2CREATE TABLE IF NOT EXISTS `kc_delegates_sessions_a_` ( `delegate_session_id` int NOT NULL AUTO_INCREMENT,  `delegate_no` int DEFAULT NULL,  `session_id` int DEFAULT NULL,  `created_at` datetime DEFAULT NULL,  `updated_at` datetime DEFAULT NULL,  `deleted_at` datetime DEFAULT NULL,  `limit` int DEFAULT '1',  PRIMARY KEY (`delegate_session_id`)) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 ;z.CREATE TABLE IF NOT EXISTS `kc_sessions_entry_a�` (`session_entry_id` int unsigned NOT NULL AUTO_INCREMENT,  `delegate_no` int DEFAULT NULL,  `session_id` int unsigned DEFAULT NULL,  `created_at` datetime DEFAULT NULL,  `updated_at` datetime DEFAULT NULL,  `deleted_at` datetime DEFAULT NULL,  `is_token` int DEFAULT NULL,  `ref_delegate_no` int DEFAULT NULL,  `ref_name` varchar(120) DEFAULT NULL,  `ref_mobile` varchar(30) DEFAULT NULL,  PRIMARY KEY (`session_entry_id`)) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 ;Z
delegates_Zfc_delegates_sessions_Zfc_sessions_entry_Zkc_delegates_sessions_Zkc_sessions_entry_z(update conference set del_table_name = 'z ' ,fc_del_session_table_name = 'z#' , fc_session_entry_table_name = 'z ', kc_del_session_table_name = 'z"', kc_session_entry_table_name = 'z'  , updated_at = 'z'   where conf_id = �  ;z,create conference table function calling ...�success)�engine�connectr	�execute�str�closer)r�conf_id�conf_key�curr_dt�connZconf_del_table_stmt�resultZconf_fcdel_session_stmtZconf_fcdel_sessionentry_stmtZconf_kcdel_entry_stmt�del_table_name�fc_del_session_table_name�fc_session_entry_table_name�kc_del_session_table_name�kc_session_entry_table_nameZmap_conf_table_stmtZresult_5rrr�createConfTabless.




D
zBadgeUserModel.createConfTablescCs>t��}td|d�}|�|���}|��|r6|SdSdS)Nzrselect delegate_no,full_name,email,mobile,role,city,state,membership_no,mc_number,company_name,counter,batch from z	 limit 1;)rrr	r�keysr)rr r%r#�stmt�resultsrrr�getDelegatesTableColumnDsz&BadgeUserModel.getDelegatesTableColumnc
Cs�g}z�t��}|��}|�d|||||g�dd�|jD�}	g}
|��}|durRqltt|	|��}|
�|�q@|�t	|
��|�
�dur�q�|jdur,q�q,W|��n
|��0|S)NZ!usp_delegates_bulk_upload_previewcSsg|]}|d�qS)rr)�.0�crrr�
<listcomp>��zCBadgeUserModel.insertBulkUploadTempTablePreview.<locals>.<listcomp>)r�raw_connection�cursor�callproc�description�fetchone�dict�zip�append�list�nextsetr)
rr �insert_query�columnssr%�del_nos�sets�
connectionr4�names�set_�row_raw�rowrrr� insertBulkUploadTempTablePreviews&
z/BadgeUserModel.insertBulkUploadTempTablePreviewc

Cs�t��}zHtd|d|d|d|d�}t|�|�|�}|��WdSty�}	z|��t|	�WYd}	~	Sd}	~	00dS)N�INSERT INTO � (�)SELECT �" from bulk_upload  where conf_id =rr)rrr	rrrrr)
rr r=r>r%�checked_del_nosr#r,r-rrrr�insertBulkUpload�s(
zBadgeUserModel.insertBulkUploadc
Cs�t��}z|td�}|�|�t|�}|�|�td|dt|�d�}|�|�}	|	rfdd�|	D�nd}	|��|	r||	WSWdSWn4ty�}
z|��t|
�WYd}
~
Sd}
~
00dS)Nztruncate table bulk_upload�SELECT  z# FROM bulk_upload where conf_id  = z! and   delegate_no is not null  ;cSsg|]}t|��qSr�r8�r/�rrrrr1�r2z5BadgeUserModel.bulkuploadPreview1.<locals>.<listcomp>)rrr	rrrr)rr r=r>r%r?r#�stmt_1r,r-rrrr�bulkuploadPreview1�s 



z!BadgeUserModel.bulkuploadPreview1c

Cs�t��}z`td|d|dt|�d|d�}|�|�}|rRdd�|D�nd}|r`|WSWdSWn4ty�}	z|��t|	�WYd}	~	Sd}	~	00dS)NrMz FROM z where conf_id  = z and delegate_no in ( z!) and  delegate_no is not null  ;cSsg|]}t|��qSrrNrOrrrr1�r2z>BadgeUserModel.bulkuploadDublicatePreview2.<locals>.<listcomp>)rrr	rrrr)
rr r=r>r%r?r#rQr-rrrr�bulkuploadDublicatePreview2�s,

z*BadgeUserModel.bulkuploadDublicatePreview2c
Cs
t��}z�td|dt|�d|d�}|�|�td|d|d|dt|�d	|d�}|�|�}	td
t|�d|dt|�d
t|�d�}
|�|
�|��|	r�WdSWdSWn6t�y}z|��t|�WYd}~Sd}~00dS)N�DELETE FROM z  where conf_id = z and delegate_no in (z) ;rGrHrIrJz  and delegate_no in (z7insert into badge_role (b_role ,conf_id) (select role, z from � where conf_id = zA and role not in (select b_role from  badge_role where conf_id = z  ) group by role ) ;r)rrr	rrrr)rr r=r>r%r?r#r,rQr-Zstmt_3rrrr�bulkuploadSelected�s2$
4
�����

z!BadgeUserModel.bulkuploadSelectedcCs`t��}tdt|�d|d�}|�|�}|��|rHdd�|D�nd}|rX|dSdSdS)Nz)select * from conference where conf_id = z and conf_uuid = 'z'   limit 1;cSsg|]}t|��qSrrNrOrrrr1�r2z0BadgeUserModel.checkConfUUID.<locals>.<listcomp>r�rrr	rrr)rr �	conf_uuidr#r,r-rrr�
checkConfUUID�s
zBadgeUserModel.checkConfUUIDc
Cs�t��}td|dt|�d|d�}|�|�td|d|dt|�d|d	�}|�|�}	|��|	r�d
d�|	D�nd}	|	r�|	SdSdS)NrTz  where  conf_id = z and delegate_no in  (z ) ;rMz  from rUz and delegate_no   in (z)   ;cSsg|]}t|��qSrrNrOrrrr1�r2z<BadgeUserModel.removeAndGetRemainRecords.<locals>.<listcomp>rW)
rr r%r?r>�remove_delegate_nosr#r,rQr-rrr�removeAndGetRemainRecords�s$
,
z(BadgeUserModel.removeAndGetRemainRecordsc	Cs\t��}td|dt|�d�}|�|�}|��|rHdd�|D�nd}|rT|SdSdS)NrMz#  from bulk_upload where conf_id = rcSsg|]}t|��qSrrNrOrrrr1r2z8BadgeUserModel.GetAllRecordsFromFile.<locals>.<listcomp>rW)	rr r%r?r>rZr#rQr-rrr�GetAllRecordsFromFiles
z$BadgeUserModel.GetAllRecordsFromFileN)�__name__�
__module__�__qualname__rr*r.rFrLrRrSrVrYr[r\rrrrr
s.;"
r)�
sqlalchemyrrrrrrrr	Zsqlalchemy.sqlr
r�corer�json�configrrrrrr�<module>s
(

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists