func (this *TemplatesDetailController) List(serviceId int64) {
	service := entity.Service{}
	service.Id = serviceId
	service.Load()

	template, errs := entity.LoadTemplateList(serviceId)
	this.Data["Template"] = template

	if errs != nil {
		this.Data["MessageErr"] = fmt.Sprintf("Errors: %s", errs)
	}

	component, componenterrors := entity.LoadComponentList(serviceId)

	this.Data["Component"] = component
	if componenterrors != nil {
		this.Data["MessageErr"] = fmt.Sprintf("Errors: %s", componenterrors)
	}

	if service.Where == utils.Deploy_On_Vms {
		operation := entity.Operation{}
		operation.Sid = serviceId
		operationerrors := operation.LoadBySid()

		this.Data["Operation"] = operation
		if operationerrors != nil {
			this.Data["MessageErr"] = fmt.Sprintf("Errors: %s", operationerrors)
		}
	}
	this.TplName = "templates/index_detail.tpl"
}
// operate service on vms
func (serviceDeploy *ServiceDeployWebSocketController) OperateOnVms(ws *websocket.Conn, service entity.Service, operate string) {
	//加载serviceDto
	//	writeStringMessage(ws, "Load ServiceDto")
	serviceDto := entity.ServiceDto{}
	serviceDto.Service = service
	err := serviceDto.Load()

	if err != nil {
		writeStringMessage(ws, fmt.Sprintf("Error,%s", err))
		return
	}
	writeStringMessage(ws, "Load custom vms info")
	onCustom := serviceDto.OnCustom
	sshRunner := utils.NewDeploySSHRunner(onCustom.Ip, onCustom.User, onCustom.Passwd)

	operation := entity.Operation{}
	operation.Sid = service.Id
	err = operation.LoadBySid()

	var out bytes.Buffer

	if err == nil {
		switch operate {
		case utils.Service_Restart:
			writeStringMessage(ws, fmt.Sprintf("Start run command: %s app, please wait for a monent", "Restart"))
			err = sshRunner.RunCommand(operation.Restart, &out)
			if err == nil {
				writeStringMessage(ws, fmt.Sprintf("%s app successful", "Restart"))
			}
		case utils.Service_Start:
			writeStringMessage(ws, fmt.Sprintf("Start run command: %s app, please wait for a monent", "Start"))
			err = sshRunner.RunCommand(operation.Start, &out)
			if err == nil {
				writeStringMessage(ws, fmt.Sprintf("%s app successful", "Start"))
			}
		case utils.Service_Stop:
			writeStringMessage(ws, fmt.Sprintf("Start run command: %s app, please wait for a monent", "Stop"))
			err = sshRunner.RunCommand(operation.Stop, &out)
			if err == nil {
				writeStringMessage(ws, fmt.Sprintf("%s app successful", "Stop"))
			}
		}
		if err != nil {
			writeStringMessage(ws, fmt.Sprintf("%s app failed ,errors: %v", operate, err))
		}
	}

}
func (this *ServiceOperationController) Get() {
	id, err := this.GetInt64("sid", 0)
	if id == 0 {
		this.Data["json"] = ""
		this.ServeJSON()
	}
	operation := entity.Operation{}
	if err == nil {
		operation.Id = id
		err = operation.Load()
		if err == nil {
			this.Data["json"] = &operation
			this.ServeJSON()
		} else {
			this.Data["json"] = ""
			this.ServeJSON()
		}
	}
}
func (this *ServiceOperationController) Post() {
	sid, _ := this.GetInt64("sid", 0)
	id, _ := this.GetInt64("id", 0)
	operation := entity.Operation{}
	operation.Id = id
	operation.Sid = sid

	operation.Start = this.GetString("start")
	operation.Restart = this.GetString("restart")
	operation.Stop = this.GetString("stop")

	if id == 0 {
		operation.Save()
	} else {
		operation.Update()
	}

	redirectUrl := fmt.Sprintf("templatesdetail?serviceId=%d", sid)
	this.Redirect(redirectUrl, 301) //this.Get()
}