예제 #1
0
func AddTask(t *model.TaskDTO) error {
	sess, err := newSession(true, "task")
	if err != nil {
		return err
	}
	defer sess.Cleanup()
	if err = addTask(sess, t); err != nil {
		return err
	}
	sess.Complete()
	event.Publish(&event.TaskCreated{Ts: time.Now(), Payload: t}, 0)
	return nil
}
예제 #2
0
func DeleteTask(id int64, orgId int64) (*model.TaskDTO, error) {
	sess, err := newSession(true, "task")
	if err != nil {
		return nil, err
	}
	defer sess.Cleanup()
	existing, err := deleteTask(sess, id, orgId)
	if err != nil {
		return nil, err
	}
	sess.Complete()

	event.Publish(&event.TaskDeleted{Ts: time.Now(), Payload: existing}, 0)

	return existing, nil
}
예제 #3
0
func RelocateRouteAnyTasks(agent *model.AgentDTO) error {
	sess, err := newSession(true, "task")
	if err != nil {
		return err
	}
	defer sess.Cleanup()
	events, err := relocateRouteAnyTasks(sess, agent)
	if err != nil {
		return err
	}
	sess.Complete()
	for _, e := range events {
		event.Publish(e, 0)
	}
	return nil
}
예제 #4
0
func UpdateTask(t *model.TaskDTO) error {
	sess, err := newSession(true, "task")
	if err != nil {
		return err
	}
	defer sess.Cleanup()
	events, err := updateTask(sess, t)
	if err != nil {
		return err
	}
	sess.Complete()
	for _, e := range events {
		event.Publish(e, 0)
	}
	return nil
}
예제 #5
0
func DeleteAgentSessionsByServer(server string) error {
	sess, err := newSession(true, "agent_session")
	if err != nil {
		return err
	}
	defer sess.Cleanup()
	events, err := deleteAgentSessionsByServer(sess, server)
	if err != nil {
		return err
	}
	sess.Complete()
	for _, e := range events {
		event.Publish(e, 0)
	}
	return nil
}
예제 #6
0
func DeleteAgentSession(a *model.AgentSession) error {
	sess, err := newSession(true, "agent_session")
	if err != nil {
		return err
	}
	defer sess.Cleanup()
	events, err := deleteAgentSession(sess, a)
	if err != nil {
		return err
	}
	sess.Complete()
	for _, e := range events {
		event.Publish(e, 0)
	}
	return nil
}