package public

// app env ////////////////////////////////////////////////////////////////

const Debug								bool   = true
const DaemonPort						string = "16823"
const DaemonListen						string = ":" + DaemonPort
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.5.1"
const Application						string = "AD-Control-Log"


// user env ///////////////////////////////////////////////////////////////

var User_profile						string = GetEnv("USERPROFILE")
var User_name							string = GetEnv("USERNAME")
var User_computername					string = GetEnv("COMPUTERNAME")
var User_homeshare						string = GetEnv("HOMESHARE")
var User_userdomain						string = GetEnv("USERDOMAIN")
var User_fqdn_cn						string = GetEnvFqdn("CN")
var User_dept							string = GetEnvFqdn("OU")
var User_sid							string = Reg_query_key_one(HKCU,`Software\Microsoft\Windows\CurrentVersion\FileAssociations`,"UserSid")
var User_sessionID						string = Reg_query_item_one(HKU,User_sid+`\Volatile Environment`)

// win-computer env /////////////////////////////////////////////////////

const Env_FreeFileSyncExe				string = `C:\Progra~2\zhiwei\FreeFileSync_10.22\FreeFileSync.exe`
const HKCU								string = "HKCU"
const HKLM								string = "HKLM"
const HKU								string = "HKU"


// AD env ///////////////////////////////////////////////////////////

const Env_MainADHostname				string = "ADSERVER"
const Env_SMBAdserver 					string = `\\` +  Env_MainADHostname + `\`
const Env_ADSoft						string = Env_SMBAdserver + "software"
const Env_ADMain						string = Env_SMBAdserver + "ADMAIN"
var   Env_ADMainDeptShare				string = Env_ADMain + `\` + User_dept + `\` + "部门共享"
const Env_ADSoftlike					string = Env_ADSoft + `\` + "softlike"
const Env_ADApplication					string = Env_ADSoft	+ `\` + "application" + `\`	
const Env_ADSoftTool					string = Env_ADSoft + `\` + "tools" + `\`
const Env_ADSoftTool_RebootUser			string = Env_ADApplication + "reboot.bat"
const Env_ADSoftTool_Update				string = Env_ADApplication + "update.bat"
const Env_ADsoftware_local				string = `F:\software\softlike\`


// backup env //////////////////////////////////////////////////////////////

var BackupVersion						string = "0428"
var BackupExtFile						string = ".ffs_batch"
var BackupReplaceKey					=[]byte("-tengfei-")



// other env ///////////////////////////////////////////////////////////////

const Link_WxworkBot					string = `https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=59107f72-5b72-4a20-a33c-fdb1cd46f2c6`
const Link_MultiSplit					string = Env_ADApplication + "win_MultiSplit.exe"	
const Cmdk								string = "cmd /k "	
const Startk							string = "cmd /k start "
var  Dir_Windows						string = GetEnv("windir") + `\`
//
//
//
//  msg msG mSg mSG Msg MsG MSg MSG 
//
//


// msg env ////////////////////////////////////////////////////////////////

const EndSign							byte    = 125
const msgerror							string = "error"


// msg type ////////////////////////////////////////////////////////////////

const Msg_Report						string = "report"
const Msg_Exec							string = "exec"
const Msg_Backup						string = "backup"
const Msg_User							string = "user"


// msg report type ///////////////////////////////////////////////////////////

const Msg_Report_DaemonStart			string = "Daemon Start"
const Msg_Report_UserStart				string = "User Start"
const Msg_Report_Offwork				string = "offwork"
const Msg_Report_OverBak				string = "overbak"


// msg backup status //////////////////////////////////////////////////////////////

const Msg_Backup_Status_Start			string = "start"
const Msg_Backup_Status_If				string = "if"
const Msg_Backup_Status_Continue		string = "Continue"
const Msg_Backup_Status_Run				string = "run"
const Msg_Backup_Status_Error			string = msgerror		


// msg exec status ////////////////////////////////////////////////////////////////

const Msg_Exec_Cmder_ADServer			int    = 0
const Msg_Exec_Cmder_LocalDaemon		int    = 1
const Msg_Exec_Cmder_LocalUser			int	   = 2
const Msg_Exec_State_Request			string = "request"
const Msg_Exec_State_Ack				string = "ack"
const Msg_Exec_CloseWindows				string = "closewindow"
const Msg_Exec_CloseWindows_cmd			string = "shutdown -s -t 15"
const Msg_Exec_CancelCloseWindows		string = "cancelclosewindows"
const Msg_Exec_CancelCloseWindows_cmd	string = "shutdown -a"
const Msg_Exec_LogOffUser				string = "logoffuser"
const Msg_Exec_LogOffUser_cmd			string = "shutdown -l"
const Msg_Exec_UserExec					string = "userexec"
const Msg_Exec_RebootWindows			string = "rebootWindows"
const Msg_Exec_RebootWindows_cmd		string = "shutdown -r -t 15"
const Msg_Exec_UpdateVersion			string = "updateverion"
const Msg_Exec_UpdateVersion_cmd		string = Env_ADSoftTool_Update
const Msg_Exec_InstallSoftware			string = "installsoftware"


// group msg ////

// Basic Json Fromat ///////////////////////////////////////////////////////
type MJbase struct{
	MsgType								string `json:"msgtype"`
	Status								string `json:"status"`
	Explain								string `json:"explain"`
	Username 							string `json:"username"`
	Computername 						string `json:"computername"`

}
// report Json Format //////////////////////////////////////////////////////
type MJreport struct {
	MJbase
	Report								string `json:"report"`
	Version								string `json:"version"`

}

// Exec Json Fromat ///////////////////////////////////////////////////////
type MJexec struct {
	MJbase
	Instruction							string `json:"instruction"`
	Command								string `json:"command"`
	Extbool								bool   `json:"extbool"`
	Cmder								int    `josn:"cmder"`
	SessionID							string `json:"sessionid"`		
	IfDelay								bool   `josn:"ifDelay"`
	Delay								string `json:"delay"`
}
// backup Json Format /////////////////////////////////////////////////////
type MJbackup struct{
	MJbase
	Version								string `json:"version"`
	DiskFree							string `json:"diskfree"`
	Error								bool   `json:"error"`
	BatchFileExist						bool   `json:"batchfileexist"`
	BatchFileData						[]byte `json:"batchfiledata"`
	BatchFileName						string `json:"batchfilename"`
}


// AD User ////////////////////////////////////////////////////////////////
const AD_User_main_admin				string = "zhiweiadserver"
const AD_User_tengfei					string = "tengfei"
const AD_User_taotengfei				string = "taotengfei"
const AD_User_huyibo					string = "huyibo"	