Exemplo n.º 1
0
 def init_student_records(self):
     stu_records = BaseFile.read_file(BaseCheckin.student_file.name)
     class_list = self.init_class_records()
     temp_list = []
     for stu_rec in stu_records:
         if stu_rec['ClassID'] in class_list:
             temp_list.append(stu_rec)
     print PrtInfo.successMessage(1)
     return temp_list
Exemplo n.º 2
0
 def init_detail_records(self):
     stu_records = BaseFile.read_file(BaseCheckin.student_file.name)
     temp_list = []
     for stu_rec in stu_records:
         temp_dict = {'StuID': stu_rec['StuID'],
                      'checkinTime': time.strftime('%Y-%m-%d %H:%M:%S'),
                      'ProofPath': 'Auto',
                      'checkinType': 'Man',
                      'IsSuc': 'True',
                      'checkinResult': '出勤'
                      }
         temp_list.append(temp_dict)
     print PrtInfo.successMessage(3)
     return temp_list
Exemplo n.º 3
0
 def init_detail_records(self):
     stu_records = self.init_student_records()
     temp_list = []
     for stu_rec in stu_records:
         temp_dict = {
             'StuID': stu_rec['StuID'],
             'checkinTime': time.strftime('%Y-%m-%d %H:%M:%S'),
             'ProofPath': 'Auto',
             'checkinType': 'Auto',
             'IsSuc': 'False',
             'checkinResult': '缺勤'
         }
         temp_list.append(temp_dict)
     print PrtInfo.successMessage(3)
     return temp_list
Exemplo n.º 4
0
 def update_stu_detail_checkin_result(stu_id, seq_id,tea_id,crs_id):
     detail_records = BaseFile.read_file(BaseCheckin.init_detail_name(tea_id,crs_id, seq_id))
     for detail_rec in detail_records:
         if detail_rec['StuID'] == str(stu_id):
             if detail_rec['checkinResult'] == '请假提交':
                 if raw_input(PrtInfo.promptMessage(4)) == 'y' | 'Y':
                     detail_rec['checkinResult'] = '请假'
                 else:
                     detail_rec['checkinResult'] = '缺勤'
             detail_rec['IsSuc'] = 'True'
             detail_rec['checkinResult'] = raw_input(PrtInfo.promptMessage(4))
             print PrtInfo.successMessage(0)+detail_rec['checkinResult']
             detail_file = DetailFile(BaseCheckin.init_detail_name(tea_id, crs_id, seq_id))
             detail_file.write_file([detail_rec],'ab')
             return True
     print PrtInfo.notFoundMessage(3)
     return False
Exemplo n.º 5
0
 def join_checkin(self, wechat_id):
     if self in BaseCheckin.checkin_list:
         checkin_type = raw_input(PrtInfo.promptMessage(6))
         if checkin_type == 'Auto':
             self.init_new_detail_record(wechat_id, 'Auto')
             PrtInfo.successMessage(8)
             return True
         elif checkin_type == 'Random':
             random_list = self.get_random_list()
             if random_list == []:
                 print 'No random check in now'
                 return False
             if self.get_stu_id_in_class_list(wechat_id) not in random_list:
                 print PrtInfo.notFoundMessage(4)
                 return False
             else:
                 self.init_new_detail_record(wechat_id, 'Random')
                 PrtInfo.successMessage(8)
         else:
             print PrtInfo.failedMessage(1)
     else:
         print PrtInfo.failedMessage(0)
         return False
Exemplo n.º 6
0
 def entry_list(self):
     # self.enter_time = '8:30'
     class_list = self.init_class_records()
     intersection_flag = False
     # 全局队列为空:
     if BaseCheckin.checkin_list == []:
         print PrtInfo.successMessage(7)
         BaseCheckin.checkin_list.append(self)
         self.time_window.start_timing()
         return True
     # 非空
     kick_head = False
     for checkin_obj in BaseCheckin.checkin_list[:]:
         try:
             if set(class_list) & set(checkin_obj.class_list):
                 # 存在交集
                 # 节次不一样 踢掉
                 if self.section_id != checkin_obj.section_id:
                     intersection_flag = True
                     if BaseCheckin.checkin_list.index(checkin_obj) == 0:
                         # 踢掉的是队首
                         kick_head = True
                     checkin_obj.notify()
                     BaseCheckin.checkin_list.remove(checkin_obj)
                 # 节次一样,无法进入,退出函数
                 else:
                     return False
         except TypeError:
             print 'invalid operation'
             return False
     # 队列中的所有班都与来者没有交集,或者有交集被踢出去
     if (intersection_flag == False) | (kick_head == False):
         # 没有交集 或者 踢掉的不是队首
         self.time_window.just_waiting()
         BaseCheckin.checkin_list.append(self)
     elif (intersection_flag == True) & (kick_head == True) & \
             (BaseCheckin.checkin_list.__len__() != 0):
         # 有交集 且 踢掉的是队首 且 当前者不是队首
         print PrtInfo.successMessage(7)
         BaseCheckin.checkin_list.append(self)
         t2 = BaseCheckin.checkin_list[0].enter_time
         t3 = BaseCheckin.checkin_list[1].enter_time
         self.time_window.time_second(t2, t3)
     else:
         # 有交集 且 踢掉队首 且 自己是队首
         print PrtInfo.successMessage(6)
         BaseCheckin.checkin_list.append(self)
         self.time_window.start_timing()
Exemplo n.º 7
0
 def write_detail_file(self, detail_records):
     DetailFile(self.init_detail_name(
         self.tea_id, self.crs_id, self.seq_id)).write_file(detail_records)
     print PrtInfo.successMessage(4)