def dateTableViewFinderJSON(request): logging.getLogger('info_logger').info('--- dateTableViewFinderJSON ---') if not checkValue(request): date = {"error": "error"} json_data = json.dumps(date) return HttpResponse(json_data, content_type='application/json') type_network = request.GET.get('type_network') type_error = request.GET.get('type_error') level_alert = request.GET.get('level_alert') date_monitoring = request.GET.get('date_monitoring') query = queryTableViewFinder(type_network, type_error, level_alert, date_monitoring) dates = select(query, 'tvazteca_vidnotd') #dates = select(query, 'tvazteca_bloq') for i in range(len(dates)): dates[i]['MUX'] = optionMux(dates[i]['MUX']) dates[i]['ULTIMO'] = formattTimeSecond(dates[i]['ULTIMO']) json_data = json.dumps(dates) return HttpResponse(json_data, content_type='application/json')
def evaluation_history(datas_report): logging.getLogger('info_logger').info('--- evaluation_history ---') history = History() for i in range(len(datas_report)): id_report = datas_report[i]['ID_REPORTE'] history.setId(id_report) history.setTypeReport(datas_report[i]['TIPO_REPORTE']) history.setSubReport(datas_report[i]['SUB_REPORTE']) history.state = datas_report[i]['ESTADO'] history.user = datas_report[i]['NOMBRE'] history.date = datas_report[i]['FECHA'].strftime('%d/%m/%Y - %H:%M:%S') query = queryHistory(id_report) # datas = select(query, 'tvazteca_vidnotd') data_history = select(query, 'tvazteca_bloq') if data_history: for x in range(len(data_history)): data_history[x]['FECHA'] = data_history[x]['FECHA'].strftime( '%d/%m/%Y - %H:%M:%S') history.checkUpdateHistory(data_history[x]) history.addHistory() else: history.addHistory() history.addRegistry() if (len(history.getRegistry()) - 1) != i or len( history.getRegistry()) == 0: history.validationRegistry() history.comment = '' history.action = '' return history
def startMetrics(request): logging.getLogger('info_logger').info('--- startMetrics ---') query = queryListUser() users = select(query, 'tvazteca_bloq') query = queryListWitness() witness = select(query, 'tvazteca_bloq') if checkValue(request): return render(request, 'metrics/metrics_general.html', { 'users': users, 'witness': witness }) else: return render( request, 'login/start_login.html', { 'message_warning': 'Para visualizar las metricas del sistema favor de logearse primero.' })
def listReport(request): logging.getLogger('info_logger').info('--- listReport ---') if not checkValue(request): date = {"error": "error"} json_data = json.dumps(date) return HttpResponse(json_data, content_type='application/json') id_witness = request.GET.get('id_witness') query = queryCheckReportsDesc(id_witness) # datas = select(query, 'tvazteca_vidnotd') datas_report = select(query, 'tvazteca_bloq') history = evaluation_history(datas_report) json_data = json.dumps(history.getRegistry()) return HttpResponse(json_data, content_type='application/json')
def startHistoryReport(request, id_report=None): logging.getLogger('info_logger').info('--- startHistoryReport ---') id = request.session['witness'] if checkValue(request): query = queryDataWitness(id) # witness = select(query, 'tvazteca_vidnotd') witness = select(query, 'tvazteca_bloq') witness[0]['TIPO_MUX'] = optionMux(witness[0]['TIPO_MUX']) return render(request, 'report/history.html', { 'witness': witness, 'id_report': id_report }) else: return render( request, 'login/start_login.html', { 'message_warning': 'Para poder crear un reporte de un testigo se necesita iniciar sesión' })
def listActionReportJSON(request): logging.getLogger('info_logger').info('--- listActionReportJSON ---') if not checkValue(request): date = {"error": "error"} json_data = json.dumps(date) return HttpResponse(json_data, content_type='application/json') type = request.GET.get('type') if type == 0: return HttpResponse({}, content_type='application/json') query = queryActionReport(type) # datas = select(query, 'tvazteca_vidnotd') datas = select(query, 'tvazteca_bloq') json_data = json.dumps(datas) return HttpResponse(json_data, content_type='application/json')
def dateCheck(request): logging.getLogger('info_logger').info('--- dateCheck ---') if not checkValue(request): date = {"error": "error"} json_data = json.dumps(date) return HttpResponse(json_data, content_type='application/json') id_testigo = request.GET.get('id_testigo') check = request.GET.get('check') date_monitoring = request.GET.get('date_monitoring') query = queryChangeTestigoDetails(id_testigo, date_monitoring) number = select(query, 'tvazteca_bloq') datas = 'ACTUALIZACION, montest_concentrado_error(REVISADOS: 0, {check}) ' \ 'montest_detalle_error(REVISADO: 0,1) {number} : ' \ 'id_tesgigo: {id}, fecha {date}'.format(check=check, number=number[0]['REVISADO'], id=id_testigo, date=date_monitoring) query = queryCheckTestigoConcentrated(id_testigo, check, date_monitoring) result1 = queryDLL(query, 'tvazteca_vidnotd') #result1 = queryDLL(query, 'tvazteca_bloq') query = queryCheckTestigoDetails(id_testigo, date_monitoring) result2 = queryDLL(query, 'tvazteca_vidnotd') #result2 = queryDLL(query, 'tvazteca_bloq') id = int(request.session['id']) browser = getBrowser(request) os = getSO(request) ip = request.META['REMOTE_ADDR'] counter = str(ckackCounter(request)) query = queryInsertBinnacle(counter, 7, ip, id, browser, os, datas) # queryDLL(query, 'tvazteca_bloq') queryDLL(query, 'tvazteca_bloq') date = {"result1": result1, "result2": result2} json_data = json.dumps(date) return HttpResponse(json_data, content_type='application/json')
def dateTableTracingJSON(request): logging.getLogger('info_logger').info('--- dateTableTracingJSON ---') if not checkValue(request): date = {"error": "error"} json_data = json.dumps(date) return HttpResponse(json_data, content_type='application/json') type_network = request.GET.get('type_network') query = queyTableListWitness(type_network) # datas = select(query, 'tvazteca_vidnotd') datas = select(query, 'tvazteca_bloq') for i in range(len(datas)): datas[i]['MUX'] = optionMux(datas[i]['MUX']) if datas[i]['ID_REPORTE'] is None: datas[i]['ID_REPORTE'] = 0 if datas[i]['ID_ESTADO'] is None: datas[i]['ID_ESTADO'] = 0 if datas[i]['RN_UNO'] is None: datas[i]['RN_UNO'] = 0 if datas[i]['RN_DOS'] is None: datas[i]['RN_DOS'] = 0 if datas[i]['RN_TRES'] is None: datas[i]['RN_TRES'] = 0 if datas[i]['RN_CUATRO'] is None: datas[i]['RN_CUATRO'] = 0 if datas[i]['C_UNO'] is None: datas[i]['C_UNO'] = 0 if datas[i]['C_DOS'] is None: datas[i]['C_DOS'] = 0 if datas[i]['C_TRES'] is None: datas[i]['C_TRES'] = 0 if datas[i]['C_CUATRO'] is None: datas[i]['C_CUATRO'] = 0 json_data = json.dumps(datas) return HttpResponse(json_data, content_type='application/json')
def dateTableViewDetailsJSON(request): logging.getLogger('info_logger').info('--- dateTableViewDetailsJSON ---') if not checkValue(request): date = {"error": "error"} json_data = json.dumps(date) return HttpResponse(json_data, content_type='application/json') id_testigo = request.GET.get('id_testigo') date_monitoring = request.GET.get('date_monitoring') query = queryTableViewDetails(id_testigo, date_monitoring) dates = select(query, 'tvazteca_vidnotd') #dates = select(query, 'tvazteca_bloq') for i in range(len(dates)): dates[i]['NUM_EVENTO'] = formattTimeSecond(dates[i]['NUM_EVENTO']) duration = dates[i]['DURACION'] if duration == -1: dates[i]['DURACION'] = '00:00:00' else: dates[i]['DURACION'] = formattTimeMinute(duration) dates[i]['TAMANO'] = converterBytes(dates[i]['TAMANO']) type_error = dates[i]['TIPO_ERROR'] if type_error == 1: dates[i]['TIPO_ERROR'] = 'DURACIÓN' elif type_error == 2: dates[i]['TIPO_ERROR'] = 'TAMAÑO' elif type_error == 3: dates[i]['TIPO_ERROR'] = 'NO EXISTE' reviewed = dates[i]['REVISADO'] if reviewed == 0: dates[i]['REVISADO'] = 'NO' else: dates[i]['REVISADO'] = 'SI' json_data = json.dumps(dates) return HttpResponse(json_data, content_type='application/json')
def evaluationLogin(request): logging.getLogger('info_logger').info('--- evaluationLogin ---') browser = getBrowser(request) os = getSO(request) ip = request.META['REMOTE_ADDR'] counter = str(ckackCounter(request)) if request.method == 'POST': form = Login(request.POST) if form.is_valid(): inputEmployee = form.cleaned_data['inputEmployee'] inputPassword = form.cleaned_data['inputPassword'] encryption = Encryption() encryption.setData(inputEmployee) inputEmployee = encryption.getEncryption() encryption.setData(inputPassword) inputPassword = encryption.getEncryption() try: resultSoap = Soap(inputEmployee, inputPassword) soap = resultSoap.accessLogin() result = soap['result'] except: logging.getLogger('info_logger').error( '--- Error 404 - El servicio de autenticación no se encuentra disponible por el momento. ---' ) return render( request, 'error/error.html', { 'number': '404', 'message': 'No Encontrado', 'error': 'El servicio de autenticación no se encuentra disponible por el momento' }) # print(request.META) if '[Ok]' == result: query = queryDetailsUser(soap['employee'][2]) # details = select(query, 'tvazteca_bloq') details = select(query, 'tvazteca_bloq') if len(details) == 1: if details[0]['ACTIVO'] == 0: request.session['sessionStart'] = True request.session['name'] = details[0]['NOMBRE'] request.session['email'] = soap['employee'][1] request.session['number_employee'] = soap['employee'][ 2] request.session['business'] = soap['employee'][3] request.session['marketstall'] = details[0]['PERFIL'] request.session['id_user'] = soap['employee'][5] request.session['permission'] = details[0]['PERMISOS'] request.session['active'] = details[0]['ACTIVO'] request.session['id'] = details[0]['ID'] request.session.set_expiry(30000) query = queryInsertBinnacle(counter, 1, ip, int(request.session['id']), browser, os, '') # queryDLL(query, 'tvazteca_bloq') queryDLL(query, 'tvazteca_bloq') return HttpResponseRedirect('inicio/') else: query = queryInsertBinnacle(counter, 6, ip, 1, browser, os, '') # queryDLL(query, 'tvazteca_bloq') queryDLL(query, 'tvazteca_bloq') logging.getLogger('info_logger').error( '--- El Usuario. No esta activo por lo tanto no tiene acceso al sistema, Verificar su acceso ---' ) return render( request, 'login/start_login.html', { 'message_warning': 'El Usuario. No esta activo por lo tanto no tiene acceso al sistema, Verificar su acceso' }) else: query = queryInsertBinnacle(counter, 5, ip, 1, browser, os, '') # queryDLL(query, 'tvazteca_bloq') queryDLL(query, 'tvazteca_bloq') logging.getLogger('info_logger').error( '--- El Usuario. No cuenta con privilegios para entrar ---' ) return render( request, 'login/start_login.html', { 'message_warning': 'El Usuario. No cuenta con privilegios para entrar' }) elif '[Error]' == result: query = queryInsertBinnacle(counter, 4, ip, 1, browser, os, '') # queryDLL(query, 'tvazteca_bloq') queryDLL(query, 'tvazteca_bloq') logging.getLogger('info_logger').error( '--- Contraseña incorrecta. Verficar ---') return render( request, 'login/start_login.html', {'message_error': 'Contraseña incorrecta. Verficar'}) elif '[Fail]' == result: query = queryInsertBinnacle(counter, 3, ip, 1, browser, os, '') # queryDLL(query, 'tvazteca_bloq') queryDLL(query, 'tvazteca_bloq') logging.getLogger('info_logger').error( '--- Usuario y Contraseña incorrectos. Verficar ---') return render(request, 'login/start_login.html', { 'message_error': 'Usuario y Contraseña incorrectos. Verficar' }) else: query = queryInsertBinnacle(counter, 3, ip, 1, browser, os, '') # queryDLL(query, 'tvazteca_bloq') queryDLL(query, 'tvazteca_bloq') logging.getLogger('info_logger').error( '--- Usuario y Contraseña incorrectos. Verficar ---') return render(request, 'login/start_login.html', { 'message_error': 'Usuario y Contraseña incorrectos. Verficar' }) return render(request, 'login/start_login.html')
def insertReportWitness(request): logging.getLogger('info_logger').info('--- insertReportWitness ---') if not checkValue(request): return render(request, 'login/start_login.html') if request.method == 'POST': id_user = request.session['id'] witness = request.session['witness'] if request.POST['list_sub_report'] == '0': query = queryReportID(request.POST['list_type_report'], 1) else: query = queryReportID(request.POST['list_type_report'], request.POST['list_sub_report']) # dates = select(query, 'tvazteca_vidnotd') data = select(query, 'tvazteca_bloq') report = data[0]['ID'] query = queryInsertReport(witness, id_user, report, 1) # dates = select(query, 'tvazteca_vidnotd') id_report = query['1'] queryDLL(query['0'], 'tvazteca_bloq') action = request.POST['list_action_report'] if '0' != action: query = queryInsertAction(id_user, id_report, action) # dates = select(query, 'tvazteca_vidnotd') queryDLL(query, 'tvazteca_bloq') comment = request.POST['commentArea'] if comment: query = queryInsertComment(id_user, id_report, comment.upper()) # dates = select(query, 'tvazteca_vidnotd') queryDLL(query, 'tvazteca_bloq') if 'option_one_setting' in request.POST: query = queryInsertAction(id_user, id_report, 2) # dates = select(query, 'tvazteca_vidnotd') queryDLL(query, 'tvazteca_bloq') if 'option_two_setting' in request.POST: query = queryInsertAction(id_user, id_report, 3) # dates = select(query, 'tvazteca_vidnotd') queryDLL(query, 'tvazteca_bloq') if 'option_three_setting' in request.POST: query = queryInsertAction(id_user, id_report, 4) # dates = select(query, 'tvazteca_vidnotd') queryDLL(query, 'tvazteca_bloq') if 'option_four_setting' in request.POST: query = queryInsertAction(id_user, id_report, 5) # dates = select(query, 'tvazteca_vidnotd') queryDLL(query, 'tvazteca_bloq') if 'option_one' in request.POST: query = queryInsertAction(id_user, id_report, 6) # dates = select(query, 'tvazteca_vidnotd') queryDLL(query, 'tvazteca_bloq') if 'option_two' in request.POST: query = queryInsertAction(id_user, id_report, 7) # dates = select(query, 'tvazteca_vidnotd') queryDLL(query, 'tvazteca_bloq') if 'option_three' in request.POST: query = queryInsertAction(id_user, id_report, 8) # dates = select(query, 'tvazteca_vidnotd') queryDLL(query, 'tvazteca_bloq') if 'option_four' in request.POST: query = queryInsertAction(id_user, id_report, 9) # dates = select(query, 'tvazteca_vidnotd') queryDLL(query, 'tvazteca_bloq') return HttpResponseRedirect('/inventario_testigos/inicio/')
def startReportWitness(request, id=None): logging.getLogger('info_logger').info('--- startReportWitness ---') request.session['witness'] = id setting = False if checkValue(request): query = queryTypeReport() # type_report = select(query, 'tvazteca_vidnotd') type_report = select(query, 'tvazteca_bloq') query = queryDataWitness(id) # witness = select(query, 'tvazteca_vidnotd') witness = select(query, 'tvazteca_bloq') witness[0]['TIPO_MUX'] = optionMux(witness[0]['TIPO_MUX']) query = queryCheckReports(id) reports = select(query, 'tvazteca_bloq') if reports: latest = len(reports) - 1 if reports[latest]['ESTADO'] != 'FINALIZADO': request.session['id_report'] = reports[latest]['ID_REPORTE'] id_type_report = reports[latest]['ID_TIPO_REPORTE'] id_sub_report = reports[latest]['ID_SUB_REPORTE'] if id_type_report == 1: setting = True query = querySubReport(id_type_report) # datas = select(query, 'tvazteca_vidnotd') sub_report = select(query, 'tvazteca_bloq') query = queryActionReport(id_type_report) # datas = select(query, 'tvazteca_vidnotd') action_report = select(query, 'tvazteca_bloq') report = [] comments = {} comment = '' report.append(reports[latest]) history = evaluation_history(report).getHistory() print(history) option_one_setting = 0 option_two_setting = 0 option_three_setting = 0 option_four_setting = 0 option_one = 0 option_two = 0 option_three = 0 option_four = 0 request.session['id_action'] = -1 id_action = 0 for i in range(len(history)): if history[i]['COMENTARIO'] != 'N/A' and history[i][ 'COMENTARIO'] != comment: comment = comments[ history[i]['FECHA']] = history[i]['COMENTARIO'] if history[i]['ACCION'] == 'GRABADOR': option_one_setting = 2 if history[i]['ACCION'] == 'ENVIO': option_two_setting = 3 if history[i]['ACCION'] == 'SERVIDOR Y BASE DE DATOS': option_three_setting = 4 if history[i]['ACCION'] == 'PROBADO EN TESTIGO WEB': option_four_setting = 5 if history[i]['ACCION'] == 'REPORTE A RN': option_one = 6 if history[i]['ACCION'] == 'TARJETA WINTV ESTREGADA A RN': option_two = 7 if history[i]['ACCION'] == 'DISCO DURO ENTREGADO A RN': option_three = 8 if history[i]['ACCION'] == 'CPU ENTREGADO A RN': option_four = 9 for x in action_report: if x['ACCION'] == history[i]['ACCION']: id_action = request.session['id_action'] = x['ID'] details = reports[latest]['FECHA'].strftime( '%d/%m/%Y - %H:%M:%S') details += ' por ' + reports[latest]['NOMBRE'] return render( request, 'report/witness.html', { 'type_report': type_report, 'witness': witness, 'history': True, 'buttom': True, 'details': details, 'id_type_report': id_type_report, 'sub_report': sub_report, 'id_sub_report': id_sub_report, 'action_report': action_report, 'id_action': id_action, 'comments': comments, 'option_one_setting': option_one_setting, 'option_two_setting': option_two_setting, 'option_three_setting': option_three_setting, 'option_four_setting': option_four_setting, 'option_one': option_one, 'option_two': option_two, 'option_three': option_three, 'option_four': option_four, 'setting': setting }) else: return render( request, 'report/witness.html', { 'type_report': type_report, 'witness': witness, 'setting': setting, 'history': True }) else: return render(request, 'report/witness.html', { 'type_report': type_report, 'setting': setting, 'witness': witness }) else: return render( request, 'login/start_login.html', { 'message_warning': 'Para poder crear un reporte de un testigo se necesita iniciar sesión' })