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-37.pyc

B

�/�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<yt�|_Wn*tk
r6}zt|�Wdd}~XYnXdS)N)r�meta�	Exception�print)�self�e�r�_/home/numerote/test-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  ;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)rrr$r"�stmt�resultsrrr�getDelegatesTableColumnDsz&BadgeUserModel.getDelegatesTableColumnc
Cs�g}z�t��}|��}|�d|||||g�xpdd�|jD�}	g}
x.|��}|dkrVPtt|	|��}|
�|�qDW|�t	|
��|�
�dkr�P|jdkr.Pq.WWd|��X|S)NZ!usp_delegates_bulk_upload_previewcSsg|]}|d�qS)rr)�.0�crrr�
<listcomp>�szCBadgeUserModel.insertBulkUploadTempTablePreview.<locals>.<listcomp>)r�raw_connection�cursor�callproc�description�fetchone�dict�zip�append�list�nextsetr)
rr�insert_query�columnssr$�del_nos�sets�
connectionr2�names�set_�row_raw�rowrrr� insertBulkUploadTempTablePreviews*


z/BadgeUserModel.insertBulkUploadTempTablePreviewc

Cs�t��}yFtd|d|d|d|d�}t|�|�|�}|��dStk
r|}	z|��t|	�Sd}	~	XYnXdS)NzINSERT INTO z (z)SELECT z" from bulk_upload  where conf_id =z  ;r)rrr	rrrrr)
rrr;r<r$�checked_del_nosr"r+r,rrrr�insertBulkUpload�s(
zBadgeUserModel.insertBulkUploadc
Cs�t��}yxtd�}|�|�t|�}|�|�td|dt|�d�}|�|�}	|	rfdd�|	D�nd}	|��|	rz|	SdSWn.tk
r�}
z|��t|
�Sd}
~
XYnXdS)Nztruncate table bulk_uploadzSELECT  z# FROM bulk_upload where conf_id  = z! and   delegate_no is not null  ;cSsg|]}t|��qSr)r6)r.�rrrrr0�sz5BadgeUserModel.bulkuploadPreview1.<locals>.<listcomp>)rrr	rrrr)rrr;r<r$r=r"�stmt_1r+r,rrrr�bulkuploadPreview1�s 


z!BadgeUserModel.bulkuploadPreview1c

Cs�t��}y\td|d|dt|�d|d�}|�|�}|rRdd�|D�nd}|r^|SdSWn.tk
r�}	z|��t|	�Sd}	~	XYnXdS)NzSELECT  z FROM z where conf_id  = z and delegate_no in ( z!) and  delegate_no is not null  ;cSsg|]}t|��qSr)r6)r.rGrrrr0�sz>BadgeUserModel.bulkuploadDublicatePreview2.<locals>.<listcomp>)rrr	rrrr)
rrr;r<r$r=r"rHr,rrrr�bulkuploadDublicatePreview2�s,
z*BadgeUserModel.bulkuploadDublicatePreview2c
Cs�t��}y�td|dt|�d|d�}|�|�td|d|d|dt|�d	|d�}|�|�}	td
t|�d|dt|�d
t|�d�}
|�|
�|��|	r�dSdSWn.tk
r�}z|��t|�Sd}~XYnXdS)NzDELETE FROM z  where conf_id = z and delegate_no in (z) ;zINSERT INTO z (z)SELECT z" from bulk_upload  where conf_id =z  and delegate_no in (z7insert into badge_role (b_role ,conf_id) (select role, z from z where conf_id = zA and role not in (select b_role from  badge_role where conf_id = z  ) group by role ) ;r)rrr	rrrr)rrr;r<r$r=r"r+rHr,Zstmt_3rrrr�bulkuploadSelected�s $
4
2
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|��qSr)r6)r.rGrrrr0�sz0BadgeUserModel.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)NzDELETE FROM z  where  conf_id = z and delegate_no in  (z ) ;zSELECT  z  from z where conf_id = z and delegate_no   in (z)   ;cSsg|]}t|��qSr)r6)r.rGrrrr0�sz<BadgeUserModel.removeAndGetRemainRecords.<locals>.<listcomp>)rrr	rrr)
rrr$r=r<�remove_delegate_nosr"r+rHr,rrr�removeAndGetRemainRecords�s$
,
z(BadgeUserModel.removeAndGetRemainRecordsc	Cs\t��}td|dt|�d�}|�|�}|��|rHdd�|D�nd}|rT|SdSdS)NzSELECT  z#  from bulk_upload where conf_id = z  ;cSsg|]}t|��qSr)r6)r.rGrrrr0sz8BadgeUserModel.GetAllRecordsFromFile.<locals>.<listcomp>)rrr	rrr)	rrr$r=r<rNr"rHr,rrr�GetAllRecordsFromFiles
z$BadgeUserModel.GetAllRecordsFromFileN)�__name__�
__module__�__qualname__rr)r-rDrFrIrJrKrMrOrPrrrrr
s.;"
r)�
sqlalchemyrrrrrrrr	Zsqlalchemy.sqlr
r�corer�json�configrrrrrr�<module>s
(

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