Commit 45010501 by 陶腾飞

加入Error Json,walk.Resouce.Icon()使用绝对路径,修改users.exe的报错机制

parent fe5d1b5a
No preview for this file type
......@@ -3,6 +3,7 @@ import (
"AD-Control/public"
"time"
"flag"
"strings"
)
......@@ -52,16 +53,27 @@ func flag_hour(){
switch nh{
case 0:
public.MsgBox(`5分钟后,即将关机,运行Z:\tools\【工具】取消关机.bat`)
public.Execcmd_nowait("shutdown -s -t 300")
if strings.Index(public.User_computername,"TXHD")!=-1{
reboot()
} else{
shutdown()
}
break
case 1:
public.MsgBox(`5分钟后,即将关机,运行Z:\tools\【工具】取消关机.bat`)
public.Execcmd_nowait("shutdown -s -t 300")
if strings.Index(public.User_computername,"TXHD")!=-1{
reboot()
} else{
shutdown()
}
break
case 2:
public.MsgBox(`5分钟后,即将关机,运行Z:\tools\【工具】取消关机.bat`)
public.Execcmd_nowait("shutdown -s -t 300")
if strings.Index(public.User_computername,"TXHD")!=-1{
reboot()
} else{
shutdown()
}
break
case 3:
public.MsgBox(`5分钟后,即将关机,运行Z:\tools\【工具】取消关机.bat`)
......@@ -74,3 +86,11 @@ func flag_hour(){
break
}
}
func shutdown(){
public.MsgBox(`5分钟后,即将关机,或者运行Z:\tools\【工具】取消关机.bat`)
public.Execcmd_nowait("shutdown -s -t 300")
}
func reboot(){
public.MsgBox(`5分钟后,即将重启,或者运行Z:\tools\【工具】取消关机.bat`)
public.Execcmd_nowait("shutdown -r -t 300")
}
\ No newline at end of file
No preview for this file type
package main
import (
"fyne.io/fyne/widget"
"fyne.io/fyne/app"
)
func main() {
app := app.New()
w := app.NewWindow("Hello")
w.SetContent(widget.NewVBox(
widget.NewLabel("Hello Fyne!"),
widget.NewButton("Quit", func() {
app.Quit()
}),
))
w.ShowAndRun()
}
\ No newline at end of file
......@@ -9,7 +9,7 @@ const ADServerDaemon string = Env_MainADHostname + DaemonListen
var LocalDaemon string = User_computername + DaemonListen
const DocuBase string = `C:\Users\Public\Documents\AD-Control\`
const RandMax int = 60
const Version string = "0.6"
const Version string = "0.7"
const Application string = "AD-Control-Log"
......
......@@ -27,11 +27,16 @@ func DealMsgEnter(ip string,msgtype string,unmsg []byte) []byte {
ret = pmsg.Msg_Deal()
// 注册表 消息
case Msg_reg:
case Msg_Reg:
var pmsg MJreg
ParseJsonBody(unmsg,&pmsg)
ret = pmsg.Msg_Deal()
// 错误 消息
case Msg_Error:
return nil
// var pmsg MJerror
// ParseJsonBody(unmsg,&pmsg)
// ret = pmsg.Msg_Deal()
}
return JsonToByte(&ret)
......@@ -194,9 +199,7 @@ func (bak * MJbackup)Msg_Deal() interface{}{
//判断是否有最新版本的文件是否存在
if NotExist(Env_FreeFileSyncExe){
bak.Errorf("FreeFileSync hasn't been installed")
PrintLog(bak.Explain)
SendServer(bak)
SendServerError("FreeFileSync hasn't been installed")
return nil
}
......@@ -220,7 +223,6 @@ func (bak * MJbackup)Msg_Deal() interface{}{
}
bak.Explain = "Backup Fill In BatchFile"
bak.PrintExplain()
bak.Status = Msg_Backup_Status_Continue
// 交给daemon 处理 Msg_Backup_Status_Continue
......@@ -233,21 +235,16 @@ func (bak * MJbackup)Msg_Deal() interface{}{
if !bak.BatchFileExist{
PrintLog("init ",string(bak.BatchFileName))
if err := WriteBytesFile(bak.BatchFileName,bak.BatchFileData);err !=nil{
bak.Errorf("Write Batch File Error "+err.Error())
SendServerError("Write Batch File Error "+err.Error())
return bak
}
}
bak.Status = Msg_Backup_Status_Run
bak.Explain = "Backup Ready"
bak.PrintExplain()
return bak
case Msg_Backup_Status_Run:
SysMsgBox(bak.Computername,bak.Username + " 开始备份")
PsExec_sd(bak.Computername,Env_FreeFileSyncExe + " "+ bak.BatchFileName)
case Msg_Backup_Status_Error:
PrintLog(bak.Explain)
default:
PrintLog("Default Backup Json ",bak.Status)
}
return nil
......@@ -264,3 +261,9 @@ func (reg * MJreg)Msg_Deal() interface{}{
}
return reg
}
// 关于 error 错误 的 消息处理
func (err * MJerror)Msg_Deal() interface{}{
return nil
}
\ No newline at end of file
......@@ -14,7 +14,8 @@ const msgerror string = "error"
const Msg_Report string = "report"
const Msg_Exec string = "exec"
const Msg_Backup string = "backup"
const Msg_reg string = "reg"
const Msg_Reg string = "reg"
const Msg_Error string = "error"
// msg report type ///////////////////////////////////////////////////////////
......@@ -25,7 +26,9 @@ const Msg_Report_OverBak string = "overbak"
const Msg_Report_CloseWindows string = "closewindows"
const Msg_Report_OverCopyToWeDrive string = "overcopytowedrive"
const Msg_Report_OverCopyToDeptShare string = "OverCopyToDeptShare"
// msg backup status //////////////////////////////////////////////////////////////
// msg backup type //////////////////////////////////////////////////////////////
const Msg_Backup_Status_Start string = "start"
const Msg_Backup_Status_If string = "if"
......@@ -34,7 +37,7 @@ const Msg_Backup_Status_Run string = "run"
const Msg_Backup_Status_Error string = msgerror
// msg exec status ////////////////////////////////////////////////////////////////
// msg exec type ////////////////////////////////////////////////////////////////
const (
Msg_Exec_Cmder_ADServer = iota
......@@ -58,6 +61,10 @@ const Msg_Exec_InstallSoftware string = "installsoftware"
const Msg_Exec_CopyWeDrive string = "copyWeDrive"
const Msg_Exec_CopyDeptShare string = "copydeptshare"
// msg error type ///////////////////////////////////////////////////////////////
//
const (
Msg_Reg_Query = iota
Msg_Reg_Read
......@@ -77,7 +84,6 @@ type MJbase struct{
Computername string `json:"computername"`
Dept string `json:"dept"`
Timestamp int64 `json:"timestamp"`
DataBool bool `json:"databool"`
DataStr string `json:"datastr"`
}
......@@ -86,7 +92,6 @@ type MJreport struct {
MJbase
Report string `json:"report"`
Version string `json:"version"`
}
// Exec Json Fromat ///////////////////////////////////////////////////////
......@@ -118,7 +123,9 @@ type MJreg struct{
DataType int `json:"datatype"`
}
type MJerror struct{
MJbase
}
//
//
......@@ -139,16 +146,12 @@ func (rep * MJreport)init(Report string) {
rep.Username = User_name
rep.Dept = User_dept
rep.Timestamp = NowTimestamp()
rep.Computername = User_computername
rep.MsgType = Msg_Report
rep.Report = Report
rep.Version = Version
}
func (rep * MJreport)PrintExplain(){
PrintLog(rep.Computername,rep.Username,rep.Explain)
}
// Exec
......@@ -180,7 +183,6 @@ func GJexecInstallSoftware(b bool,s string) interface{}{
exec.Command = s
return exec
}
func GJexecUserCmd(s string) interface{}{
var exec MJexec
exec.init("")
......@@ -198,8 +200,6 @@ func (exec * MJexec)init(s string){
exec.SessionID = User_sessionID
exec.Cmder = Msg_Exec_Cmder_LocalDaemon
exec.Status = Msg_Exec_State_Request
// exec.IfDelay = false
// exec.Delay = Rand(RandMax)
exec.Timestamp = NowTimestamp()
}
......@@ -219,10 +219,19 @@ func (bak * MJbackup)init() {
bak.Status = Msg_Backup_Status_Start
bak.Version = Version
}
func (bak * MJbackup)Errorf(s string){
bak.Status = Msg_Backup_Status_Error
bak.Explain = "Backup Error: " + bak.Computername + " -> " + s
// error
func GJerror(s * string) interface{}{
var err MJerror
err.init(s)
return err
}
func (bak * MJbackup)PrintExplain(){
PrintLog(bak.Username,bak.Status,bak.Explain)
func (err * MJerror)init(s* string ){
err.Username = User_name
err.Dept = User_dept
err.Timestamp = NowTimestamp()
err.Computername = User_computername
err.MsgType = Msg_Error
err.DataStr = *s
}
\ No newline at end of file
......@@ -24,7 +24,9 @@ func SendServerExec(s string)[]byte{
return SendServer(GJexec(s))
}
func SendServerError(s string)[]byte{
return SendServer(GJerror(&s))
}
// send to server
func SendServer(v interface{})[]byte{
return SendMsg(ADServerDaemon,v)
......
No preview for this file type
......@@ -4,7 +4,7 @@ import (
"github.com/lxn/walk"
"AD-Control/public"
)
func userInit(){
func userInit() string{
public.Reg_Exist_item(public.HKCU,public.Reg_Path_achome)
// 如果微盘的文件夹存在
......@@ -19,6 +19,14 @@ func userInit(){
}
}()
}
var icoDir =[]string {`AD-Control.ico`,`C:\Users\Public\Documents\AD-Control\AD-Control.ico`}
for _,i := range icoDir{
if public.Exist(i){
return i
}
}
public.SendServerError("no icon file")
return ""
}
func menuInit(ni * walk.NotifyIcon){
menuInitPower(ni)
......@@ -32,9 +40,9 @@ func menuInit(ni * walk.NotifyIcon){
func main() {
// 用户初始化
userInit()
icodir := userInit()
//if public.Daemon {public.Msg("版本错误")}
public.PrintLog(icodir)
// 程序初始化
mw,err := walk.NewMainWindow()
......@@ -42,7 +50,7 @@ func main() {
public.PrintLog(err)
}
icon, err := walk.Resources.Icon(`AD-Control.ico`)
icon, err := walk.Resources.Icon(icodir)
if err != nil {
public.PrintLog(err)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment