#!D:/IDE/anaconda3/envs/Microscope_Scan python
# -*- coding: UTF-8 -*-
"""
@FileName：NoneWebAPIBusiness.py
@Description：
@Author：XSH
@Time：2025/12/3 12:25
@Department：研发部
@Copyright：©2025 乐辰生物
"""
from PyQt5 import Qt
from abc import abstractmethod, abstractclassmethod, abstractstaticmethod
from AppInterfaces.utils                    import *
from AppSettings.utils                      import *
from AppCore.Requests                       import *
from AppInterfaces.Interfaces               import *
from AppCore.Levels                         import *
from AppUtils.utils                         import *
from AppBackEnd.WebBusinessInterface import WebBusinessInterface
class NoneWebAPIBusiness(Qt.QObject, WebBusinessInterface):
    def __init__(self, manager: WebReaderInterface = None, parent: Qt.QObject = None):
        super(NoneWebAPIBusiness, self).__init__(parent=parent)
        self.Manager = manager
        self.Initialization("NoneWebAPIBusiness", self, parent)
    def initWEBAPILevel(self):
        self.Level = WebAPILevel.getConnectionStatus
    def Done(self, handler: WebClientInterface, **args):
        isWrong: int = RECODE_FAILURE
        from AppCore.DBModels import OperatingStatusModel
        try:
            self.Handler = handler
            item: OperatingStatusModel = OperatingStatusModel.first()
            if item is None:
                return
            request: Request = Request.APIInstance(self.Level)
            request.data = item.to_save_field()
            isWrong = self.WebSendFrame(request.toJson())
        except Exception as e:
            AppUtils.print_Exception(e)
        return
    def WaitDone(self, handler: WebClientInterface, **args) -> int:
        isWrong: int = RECODE_FAILURE
        from AppCore.DBModels import OperatingStatusModel
        try:
            self.Handler = handler
            item: OperatingStatusModel = OperatingStatusModel.first()
            if item is None:
                return
            request: Request = Request.APIInstance(self.Level)
            request.data = item.to_save_field()
            isWrong = self.WebSendFrame(request.toJson())
        except Exception as e:
            AppUtils.print_Exception(e)
        return isWrong