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 }
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 }
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 }
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 }
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 }
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 }