diff --git a/contact.xlsx b/contact.xlsx index 8f29640..e63e48f 100644 Binary files a/contact.xlsx and b/contact.xlsx differ diff --git a/db/DbManager.py b/db/DbManager.py index d3d29fe..7106046 100644 --- a/db/DbManager.py +++ b/db/DbManager.py @@ -1,7 +1,9 @@ import datetime import firebase_admin +import xlsxwriter as xlsxwriter from firebase_admin import credentials, firestore +import params from pojo.ReserveResultPojo import ReserveResultPojo, PublishType from pojo.SimInfoPojo import SimInfoPojo from pojo.contact_pojo import ContactPojo @@ -20,6 +22,10 @@ class DataManager: def get_all_error_items(self): pass + def get_all_sim_infos(self): + sim_info_collection = self._db.collection(SIM_INFOS) + return sim_info_collection + def get_all_successful_items(self): doc_ref = self._db.collection(str(datetime.date.today())) return doc_ref @@ -46,5 +52,17 @@ class DataManager: if __name__ == '__main__': - manager = DataManager() - manager.save() + # Create a workbook and add a worksheet. + workbook = xlsxwriter.Workbook('sim_infos.xlsx') + worksheet = workbook.add_worksheet() + # Start from the first cell. Rows and columns are zero indexed. + row = 0 + col = 0 + for sim in params.firebase_store_manager.get_all_sim_infos().stream(): + print(sim) + sim_pojo = SimInfoPojo.from_firestore_dict(sim.to_dict()) + # Iterate over the data and write it out row by row. + worksheet.write(row, col, sim_pojo.phone[2:len(sim_pojo.phone)]) + worksheet.write(row, col + 1, sim_pojo.ccid) + row += 1 + workbook.close() diff --git a/db/sim_infos.xlsx b/db/sim_infos.xlsx new file mode 100644 index 0000000..ba5288a Binary files /dev/null and b/db/sim_infos.xlsx differ diff --git a/main.py b/main.py index d62e314..bcea0b3 100644 --- a/main.py +++ b/main.py @@ -197,6 +197,6 @@ if __name__ == '__main__': init_logger() logger = logging.getLogger() logger.addHandler(logging.StreamHandler(stream=sys.stdout)) - read_all_the_phone_number() - # start_listen() - # start_book() + # read_all_the_phone_number() + start_listen() + start_book() diff --git a/pojo/SimInfoPojo.py b/pojo/SimInfoPojo.py index 4598933..27e37b4 100644 --- a/pojo/SimInfoPojo.py +++ b/pojo/SimInfoPojo.py @@ -6,6 +6,14 @@ class SimInfoPojo: self.phone = phone self.ccid = ccid + @staticmethod + def from_firestore_dict(source): + phone = source['phone'] + ccid = source['ccid'] + result = SimInfoPojo(phone=phone, ccid=ccid) + result.id = id + return result + def to_firestore_dict(self): dest = { u'phone': self.phone,