def insert_new_characters(self): self.total_count = 0 self.inserted_count = 0 for character_id in self._get_not_existed_ids(): self.total_count += 1 try: # 逐一根據其 ID 開啟新增視窗 character = Character.create_by_cgdt_character(self.data_owner.find_character_by_id(character_id)) popup = CharacterWindow(self.view, character, lambda: self._insert_new_character(character)) self.view.wait_window(popup) # 若資料取得發生問題,則記錄後就略過 except StandardError as e: print e tkMessageBox.showinfo( "Completed", "總計 {0} 筆新資料,其中 {1} 筆新增完成".format(self.total_count, self.inserted_count), parent=self.view )
def update_new_characters(self): self.total_count = 0 self.updated_count = 0 for character_name in self._get_new_character_names(): self.total_count += 1 try: # 逐一根據其 FullName 開啟更新視窗 character = Character.create_by_cgdt_character( self.data_owner.find_character_by_full_name(character_name) ) popup = CharacterWindow(self.view, character, lambda: self._update_new_character_with_its_id(character)) self.view.wait_window(popup) # 若資料取得發生問題,則記錄後就略過 except StandardError as e: print e tkMessageBox.showinfo( "Completed", "總計 {0} 筆新資料,其中 {1} 筆更新完成".format(self.total_count, self.updated_count), parent=self.view )
def insert_new_characters(self): self.total_count = 0 self.inserted_count = 0 for character_id in self._get_not_existed_ids(): self.total_count += 1 try: # 逐一根據其 ID 開啟新增視窗 character = Character.create_by_cgdt_character( self.data_owner.find_character_by_id(character_id)) popup = CharacterWindow( self.view, character, lambda: self._insert_new_character(character)) self.view.wait_window(popup) # 若資料取得發生問題,則記錄後就略過 except StandardError as e: print e tkMessageBox.showinfo('Completed', '總計 {0} 筆新資料,其中 {1} 筆新增完成'.format( self.total_count, self.inserted_count), parent=self.view)
def update_new_characters(self): self.total_count = 0 self.updated_count = 0 for character_name in self._get_new_character_names(): self.total_count += 1 try: # 逐一根據其 FullName 開啟更新視窗 character = Character.create_by_cgdt_character( self.data_owner.find_character_by_full_name( character_name)) popup = CharacterWindow( self.view, character, lambda: self._update_new_character_with_its_id(character)) self.view.wait_window(popup) # 若資料取得發生問題,則記錄後就略過 except StandardError as e: print e tkMessageBox.showinfo('Completed', '總計 {0} 筆新資料,其中 {1} 筆更新完成'.format( self.total_count, self.updated_count), parent=self.view)
def select_character_by_specific_column(column_name, key): matched_character = DBAccessor.execute('select * from Character where {0}={1} limit 1'.format( column_name, convert_datum_to_command(key))).fetchone() if matched_character is None: raise ValueError('Character with {0} {1} does not existed.'.format(column_name, key)) return Character(matched_character)
def create_new_cn_character(): character = Character.create_empty_character() max_id = DBAccessor.execute('select max(ID) from Character').fetchone()[0] character.c_id = max_id + 1 if max_id > 6000 else 6001 return character
def create_new_jp_character(): character = Character.create_empty_character() min_id = DBAccessor.execute('select min(ID) from Character').fetchone()[0] character.c_id = min_id - 1 if min_id < 1000 else 900 return character
def select_character_list(): return [Character(each) for each in DBAccessor.execute('select {0} from Character'.format(','.join(Character.DB_TABLE)))]