from common.sql_lite import init_global_db_connection, close_global_db_connection
from logic.logic_ui import Win
from service.batch_task import stop_batch_task
from config import load_config
from service.robot import init_robot


def main():
    load_config()

    # 初始化sql_lite
    init_global_db_connection()

    # 初始化 wcf
    init_robot()

    try:
        win = Win()
        win.mainloop()
    finally:
        stop_batch_task()
        close_global_db_connection()


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    main()
