Compare commits

..

1 Commits

Author SHA1 Message Date
Samuel Miranda c07f24d8fd Teste 2021-10-05 17:35:25 -03:00
20 changed files with 417 additions and 1341 deletions

View File

@ -5,19 +5,17 @@ import (
)
type Cli struct {
*api.ApiCli
//cli *api.Cli
cli *api.Cli
}
//func (c *Cli) HttpCli() *api.Cli {
//
// return c.HttpCli()
//}
func (c *Cli) HttpCli() *api.Cli {
return c.cli
}
type Req struct {
Site string `json:"site"`
Data string `json:"data"`
Img string `json:"img"`
Img []byte `json:"img"`
To int `json:"to"`
}
@ -26,37 +24,25 @@ func (c *Cli) Recaptchav2(site string, data string) (string, error) {
req := &Req{
Site: site,
Data: data,
Img: "",
Img: nil,
To: 300,
}
err := c.HttpCli().JsonPost("/ipc/anticaptcha/recaptchav2", req, &ret)
err := c.cli.HttpJsonPost("/ipc/anticaptcha/recaptchav2", req, &ret)
return ret, err
}
func (c *Cli) Hcaptcha(site string, data string) (string, error) {
ret := ""
req := &Req{
Site: site,
Data: data,
Img: "",
To: 300,
}
err := c.HttpCli().JsonPost("/ipc/anticaptcha/hcaptcha", req, &ret)
return ret, err
}
func (c *Cli) Image2text(site string, data string) (string, error) {
func (c *Cli) Image2text(site string, data []byte) (string, error) {
ret := ""
req := &Req{
Site: site,
Img: data,
To: 300,
}
err := c.HttpCli().JsonPost("/ipc/anticaptcha/image2text", req, &ret)
err := c.cli.HttpJsonPost("/ipc/anticaptcha/image2text", req, &ret)
return ret, err
}
func NewCli() *Cli {
ret := &Cli{ApiCli: api.NewApiCli()}
ret := &Cli{cli: api.NewCli()}
return ret
}

View File

@ -1,34 +0,0 @@
package apiproxy
import "go.digitalcircle.com.br/open/replaycli-go/api"
type APIProxyRequest struct {
Name string `json:"name,omitempty"`
Method string `json:"method,omitempty"`
Url string `json:"url,omitempty"`
Header map[string]string `json:"header,omitempty"`
Body []byte `json:"body,omitempty"`
Readonly bool `json:"readonly"`
}
type APIProxyResponse struct {
Status string `json:"status"`
StatusCode int `json:"status_code"`
Header map[string]string `json:"header,omitempty"`
Body []byte `json:"body,omitempty"`
}
type Cli struct {
*api.ApiCli
}
func (c *Cli) Do(req *APIProxyRequest) (*APIProxyResponse, error) {
res := &APIProxyResponse{}
err := c.HttpCli().JsonPost("/ipc/apiproxy/do", req, res)
return res, err
}
func NewCli() *Cli {
ret := &Cli{ApiCli: api.NewApiCli()}
return ret
}

View File

@ -1,22 +0,0 @@
package apiproxy
import (
"log"
"os"
"testing"
)
func TestCli_Do(t *testing.T) {
os.Setenv("REPLAY_APIKEY", "DONTBOTHER")
os.Setenv("REPLAY_ADDR", "https://localhost:8443")
c := NewCli()
res, err := c.Do(&APIProxyRequest{
Method: "GET",
Url: "https://www.slashdot.org",
})
if err != nil {
t.Fatal(err.Error())
}
log.Printf("%#v", res)
}

View File

@ -1,25 +0,0 @@
package autohotkey
import (
"go.digitalcircle.com.br/open/replaycli-go/api"
)
type Cli struct {
*api.ApiCli
}
func NewCli() *Cli {
ret := &Cli{ApiCli: api.NewApiCli()}
return ret
}
func (c *Cli) Test() (ret []byte, err error) {
ret, err = c.HttpCli().RawPost("/ipc/ahk/test", nil)
return ret, err
}
func (c *Cli) Do(data string) (ret []byte, err error) {
i := []byte(data)
ret, err = c.HttpCli().RawPost("/ipc/ahk/do", i)
return ret, err
}

View File

@ -1,25 +0,0 @@
package autoit
import (
"go.digitalcircle.com.br/open/replaycli-go/api"
)
type Cli struct {
*api.ApiCli
}
func NewCli() *Cli {
ret := &Cli{ApiCli: api.NewApiCli()}
return ret
}
func (c *Cli) Test() (ret []byte, err error) {
ret, err = c.HttpCli().RawPost("/ipc/autoit/test", nil)
return ret, err
}
func (c *Cli) Do(data string) (ret []byte, err error) {
i := []byte(data)
ret, err = c.HttpCli().RawPost("/ipc/autoit/do", i)
return ret, err
}

View File

@ -3,108 +3,63 @@ package chrome
import (
"encoding/json"
"fmt"
"go.digitalcircle.com.br/open/replaycli-go/api"
)
type Cli struct {
*api.ApiCli
cli *api.Cli
}
type TabMetadata struct {
Description string `json:"description"`
DevtoolsFrontendUrl string `json:"devtoolsFrontendUrl"`
Id string `json:"id"`
Title string `json:"title"`
Type string `json:"type"`
Url string `json:"url"`
WebSocketDebuggerUrl string `json:"webSocketDebuggerUrl"`
func (c *Cli) HttpCli() *api.Cli {
return c.cli
}
func (c *Cli) Start(to int) error {
// to -> Time out para a conexão com o Chrome. Dado em segundos.
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/chrome/start?to=%d", to), nil)
err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/chrome/start?to=%d", to), nil)
return err
}
func (c *Cli) StartHeadless() error {
err := c.HttpCli().JsonGet("/ipc/chrome/startHeadless", nil)
err := c.cli.HttpJsonGet("/ipc/chrome/startHeadless", nil)
return err
}
func (c *Cli) Stop() error {
err := c.HttpCli().JsonGet("/ipc/chrome/stop", nil)
err := c.cli.HttpJsonGet("/ipc/chrome/stop", nil)
return err
}
func (c *Cli) New(url string) (string, error) {
// url -> Site no qual se quer iniciar uma nova aba.
ret := ""
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/chrome/new?url=%s", url), &ret)
err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/chrome/new?url=%s", url), &ret)
return ret, err
// ret -> ID do Websocket criado para navegação na "url" informada.
}
func (c *Cli) Close(id string) error {
// id -> ID do websocket ativo. É o primeiro retorno do método "New".
err := c.HttpCli().JsonGet("/ipc/chrome/close/"+id, nil)
err := c.cli.HttpJsonGet("/ipc/chrome/close/"+id, nil)
return err
}
func (c *Cli) Eval(id string, s string) (map[string]interface{}, error) {
// id -> ID do websocket no qual se quer fazer um comando JavaScript.
// s -> Comando JavaScript a ser executado no terminal web do WebSocket informado.
ret := make(map[string]interface{})
bs, err := c.HttpCli().RawPost("/ipc/chrome/eval/"+id, []byte(s))
bs, err := c.cli.HttpRawPost("/ipc/chrome/eval/"+id, []byte(s))
json.Unmarshal(bs, &ret)
return ret, err
// ret -> O valor retornado pelo comando JavaScript executado.
}
func (c *Cli) Wait(id string, s string, to int) (string, error) {
// id -> ID do websocket no qual se quer fazer um comando JavaScript.
// s -> Comando JavaScript a ser executado no terminal web do WebSocket informado. Deve ser uma expressão que retorne um valor booleano para, por exemplo, verificar se um elemento já foi carregado.
// to -> TimeOut de espera para retorno "true" da expressão JavaScript informada. Informado em segundos.
ret := ""
bs, err := c.HttpCli().RawPost(fmt.Sprintf("/ipc/chrome/wait/%s?to=%d", id, to), []byte(s))
bs, err := c.cli.HttpRawPost(fmt.Sprintf("/ipc/chrome/wait/%s?to=%d", id, to), []byte(s))
json.Unmarshal(bs, &ret)
return ret, err
}
func (c *Cli) Send(id string, m string, ps map[string]interface{}) (interface{}, error) {
// id -> ID do Websocket no qual se deseja realizar a alteração.
var ret interface{}
func (c *Cli) Send(id string, m string, ps map[string]interface{}) (string, error) {
ret := ""
in := map[string]interface{}{
"method": m,
"params": ps,
}
err := c.HttpCli().JsonPost("/ipc/chrome/send/"+id, in, &ret)
err := c.cli.HttpJsonPost("/ipc/chrome/eval/"+id, in, &ret)
return ret, err
// ret -> Retorno do comando (Referência em: https://chromedevtools.github.io/devtools-protocol/)
}
func (c *Cli) OpenTabs() (ret []map[string]string, err error) {
err = c.HttpCli().JsonGet("/ipc/chrome/opentabs", &ret)
return ret, err
// ret -> Array contendo as abas abertas e metadados sobre as mesmas.
}
func (c *Cli) FindTabByUrl(url string) (ret string, err error) {
// url -> URL ativa em uma das abas abertas.
err = c.HttpCli().JsonGet("/ipc/chrome/findtabbyurl/"+url, &ret)
return ret, err
// ret -> ID do WebSocket contendo a aba encontrada.
}
func (c *Cli) FindUrlById(id string) (ret string, err error) {
// url -> URL ativa em uma das abas abertas.
err = c.HttpCli().JsonGet("/ipc/chrome/findurlbyid/"+id, &ret)
return ret, err
// ret -> Url da aba encontrada.
}
func (c *Cli) FindTabByTitle(title string) (ret string, err error) {
// title -> Título de uma das abas abertas.
err = c.HttpCli().JsonGet("/ipc/chrome/findtabbytitle/"+title, &ret)
return ret, err
// ret -> ID do WebSocket contendo a aba encontrada.
}
func NewCli() *Cli {
ret := &Cli{ApiCli: api.NewApiCli()}
ret := &Cli{cli: api.NewCli()}
return ret
// ret -> Nova instância do Chrome para utilização.
}

View File

@ -1,32 +1,144 @@
package api
import (
"go.digitalcircle.com.br/open/httpcli"
"go.digitalcircle.com.br/open/replaycli-go/ipcmux"
"go.digitalcircle.com.br/open/replaycli-go/util"
"bytes"
"encoding/json"
"io"
"net/http"
"os"
"strings"
)
type ApiCli struct {
cli *httpcli.Cli
type Cli struct {
cli *http.Client
headers map[string]string
}
func (a *ApiCli) HttpCli() *httpcli.Cli {
return a.cli
}
func (c *Cli) Addr() string {
ret := os.Getenv("REPLAY_ADDR")
if ret == "" {
ret = "https://localhost:8443"
} else if strings.HasPrefix(ret, ":") {
ret = "https://localhost" + ret
}
func NewApiCli() *ApiCli {
ret := &ApiCli{cli: httpcli.C()}
ret.cli.SetBasePath(util.Addr())
apikey = os.Getenv("REPLAY_APIKEY")
ret.cli.AddHeader("X-API-KEY", apikey)
return ret
}
func (c *Cli) AddHeader(k string, v string) {
c.headers[k] = v
}
func (c *Cli) DelHeader(k string) {
delete(c.headers, k)
}
func (c *Cli) HttpDo(method string, strurl string, body []byte) (*http.Response, error) {
if !strings.HasPrefix(strurl, "http") {
addr := c.Addr()
if strings.HasSuffix(addr, "/") {
addr = addr[:len(addr)-1]
}
if !strings.HasPrefix(strurl, "") {
strurl = "/" + strurl
}
strurl = addr + strurl
}
req, err := http.NewRequest(method, strurl, bytes.NewReader(body))
if err != nil {
return nil, err
}
if c.headers != nil {
for k, v := range c.headers {
req.Header.Set(k, v)
}
}
if body != nil && len(body) > 0 {
req, err = http.NewRequest(method, strurl, io.NopCloser(bytes.NewReader(body)))
func NewApiIPCCli() *ApiCli {
ret := &ApiCli{cli: httpcli.NewCli()}
ret.cli.SetCli(ipcmux.NewClient())
} else {
req, err = http.NewRequest(method, strurl, nil)
}
if err != nil {
return nil, err
}
req.Header.Set("X-API-KEY", apikey)
req.Header.Set("Content-Type", "application/json")
return c.cli.Do(req)
}
func (c *Cli) HttpDoJson(method string, strurl string, i interface{}, o interface{}) (err error) {
bs, err := json.Marshal(i)
if err != nil {
return err
}
res, err := c.HttpDo(method, strurl, bs)
if err != nil {
return
}
defer res.Body.Close()
if o != nil {
err = json.NewDecoder(res.Body).Decode(o)
}
return
}
func (c *Cli) HttpJsonGet(strurl string, o interface{}) error {
return c.HttpDoJson(http.MethodGet, strurl, nil, o)
}
func (c *Cli) HttpJsonDelete(strurl string, o interface{}) error {
return c.HttpDoJson(http.MethodDelete, strurl, nil, o)
}
func (c *Cli) HttpJsonHead(strurl string, o interface{}) error {
return c.HttpDoJson(http.MethodHead, strurl, nil, o)
}
func (c *Cli) HttpJsonPost(strurl string, i interface{}, o interface{}) error {
return c.HttpDoJson(http.MethodPost, strurl, i, o)
}
func (c *Cli) HttpJsonPut(strurl string, i interface{}, o interface{}) error {
return c.HttpDoJson(http.MethodPut, strurl, i, o)
}
func (c *Cli) HttpJsonPatch(strurl string, i interface{}, o interface{}) error {
return c.HttpDoJson(http.MethodPatch, strurl, i, o)
}
func (c *Cli) HttpRawGet(strurl string) ([]byte, error) {
res, err := c.HttpDo(http.MethodGet, strurl, nil)
if err != nil {
return nil, err
}
defer res.Body.Close()
bs, _ := io.ReadAll(res.Body)
return bs, nil
}
func (c *Cli) HttpRawDelete(strurl string) ([]byte, error) {
res, err := c.HttpDo(http.MethodDelete, strurl, nil)
if err != nil {
return nil, err
}
defer res.Body.Close()
bs, _ := io.ReadAll(res.Body)
return bs, nil
}
func (c *Cli) HttpRawPost(strurl string, i []byte) ([]byte, error) {
res, err := c.HttpDo(http.MethodPost, strurl, i)
if err != nil {
return nil, err
}
defer res.Body.Close()
bs, _ := io.ReadAll(res.Body)
return bs, nil
}
func (c *Cli) HttpRawPut(strurl string, i []byte) ([]byte, error) {
res, err := c.HttpDo(http.MethodPut, strurl, i)
if err != nil {
return nil, err
}
defer res.Body.Close()
bs, _ := io.ReadAll(res.Body)
return bs, nil
}
func NewCli() *Cli {
apikey = os.Getenv("REPLAY_APIKEY")
ret.cli.AddHeader("X-API-KEY", apikey)
ret := &Cli{
cli: &http.Client{},
headers: make(map[string]string),
}
ret.AddHeader("X-API-KEY", apikey)
return ret
}

View File

@ -1,131 +0,0 @@
package dataapi
import (
"strconv"
"time"
"go.digitalcircle.com.br/open/httpcli"
)
type DataApiOp string
const (
RETRIEVE DataApiOp = "R"
CREATE DataApiOp = "C"
DELETE DataApiOp = "D"
UPDATE DataApiOp = "U"
)
type DataAPIRequest struct {
Col string `json:"col"`
Q string `json:"q"`
Op DataApiOp `json:"op"`
Id string `json:"id"`
Data map[string]interface{} `json:"data"`
}
type DataAPIResponse struct {
Msg string `json:"msg"`
Id string `json:"id"`
Data []interface{} `json:"data"`
}
type Cli struct {
Httpcli *httpcli.Cli
}
func (c *Cli) Do(request *DataAPIRequest) (response *DataAPIResponse, err error) {
response = &DataAPIResponse{}
err = c.Httpcli.JsonPost("/", request, response)
return
}
func NewCli(apikey string) *Cli {
ret := &Cli{Httpcli: httpcli.NewCli()}
ret.Httpcli.AddHeader("X-API-KEY", apikey)
ret.Httpcli.SetBasePath("https://dataapi.digitalcircle.com.br")
return ret
}
func RegistrarExec(table, apikey string, check bool, checkC bool) {
//Para robôs, age como contador e registra cada repetição no mês
c := NewCli(apikey)
var registros int
var erro int
captReg := 0
current := time.Now().Format("2006-01")
res, err := c.Do(&DataAPIRequest{
Col: table,
Op: RETRIEVE,
Q: "@[?date=='" + current + "']",
})
if err != nil {
panic(err)
}
if len(res.Data) > 0 {
if check {
result := res.Data[0].(map[string]interface{})
registros = int(result["exec"].(float64))
registros = registros + 1
captReg = int(result["capt"].(float64))
if checkC {
captReg = captReg + 1
}
ident := strconv.Itoa(int(result["ID"].(float64)))
_, err = c.Do(&DataAPIRequest{
Col: table,
Op: UPDATE,
Id: ident,
Data: map[string]interface{}{
"exec": registros,
"capt": captReg,
},
})
if err != nil {
panic(err)
}
} else {
result := res.Data[0].(map[string]interface{})
registros = int(result["err"].(float64))
registros = registros + 1
ident := strconv.Itoa(int(result["ID"].(float64)))
_, err = c.Do(&DataAPIRequest{
Col: table,
Op: UPDATE,
Id: ident,
Data: map[string]interface{}{
"err": registros,
},
})
if err != nil {
panic(err)
}
}
} else {
if check {
registros = 1
erro = 0
if checkC {
captReg = 1
}
} else {
registros = 0
erro = 1
}
_, err = c.Do(&DataAPIRequest{
Col: table,
Op: CREATE,
Data: map[string]interface{}{
"date": current,
"exec": registros,
"err": erro,
"capt": captReg,
},
})
if err != nil {
panic(err)
}
}
}

View File

@ -1,145 +0,0 @@
package dataapi_test
import (
"log"
"strconv"
"testing"
"time"
"go.digitalcircle.com.br/open/replaycli-go/api/dataapi"
)
func TestAPIRetrieve(t *testing.T) {
c := dataapi.NewCli()
res, err := c.Do(&dataapi.DataAPIRequest{
Col: "teste3",
Op: dataapi.RETRIEVE,
})
if err != nil {
t.Fatal(err.Error())
}
log.Printf("%#v", res)
}
func TestAPIRetrieveWQuery(t *testing.T) {
c := dataapi.NewCli()
res, err := c.Do(&dataapi.DataAPIRequest{
Col: "C1",
Op: dataapi.RETRIEVE,
Q: "@[?ID==`2`]",
})
if err != nil {
t.Fatal(err.Error())
}
log.Printf("%#v", res)
}
func TestAPIUpdate(t *testing.T) {
c := dataapi.NewCli()
res, err := c.Do(&dataapi.DataAPIRequest{
Col: "C1",
Op: dataapi.UPDATE,
Id: "2",
Data: map[string]interface{}{
"F2": "Novo Campo",
},
})
if err != nil {
t.Fatal(err.Error())
}
log.Printf("%#v", res)
}
func TestAPIDelete(t *testing.T) {
c := dataapi.NewCli()
res, err := c.Do(&dataapi.DataAPIRequest{
Col: "C1",
Op: dataapi.DELETE,
Id: "2",
})
if err != nil {
t.Fatal(err.Error())
}
log.Printf("%#v", res)
}
func TestAPICreate(t *testing.T) {
if true {
print("a")
print("b")
}
c := dataapi.NewCli()
var registros int
var erro int
current := time.Now().Format("2006-01")
res, err := c.Do(&dataapi.DataAPIRequest{
Col: "teste3",
Op: dataapi.RETRIEVE,
Q: "@[?date=='" + current + "']",
})
if err != nil {
panic(err)
}
check := false
if len(res.Data) > 0 {
if check {
result := res.Data[0].(map[string]interface{})
registros = int(result["exec"].(float64))
registros = registros + 1
ident := strconv.Itoa(int(result["ID"].(float64)))
_, err = c.Do(&dataapi.DataAPIRequest{
Col: "teste3",
Op: dataapi.UPDATE,
Id: ident,
Data: map[string]interface{}{
"exec": registros,
},
})
if err != nil {
panic(err)
}
} else {
result := res.Data[0].(map[string]interface{})
registros = int(result["err"].(float64))
registros = registros + 1
ident := strconv.Itoa(int(result["ID"].(float64)))
_, err = c.Do(&dataapi.DataAPIRequest{
Col: "teste3",
Op: dataapi.UPDATE,
Id: ident,
Data: map[string]interface{}{
"err": registros,
},
})
if err != nil {
panic(err)
}
}
} else {
if check {
registros = 1
erro = 0
} else {
registros = 0
erro = 1
}
_, err = c.Do(&dataapi.DataAPIRequest{
Col: "teste3",
Op: dataapi.CREATE,
Data: map[string]interface{}{
"date": current,
"exec": registros,
"err": erro,
},
})
if err != nil {
panic(err)
}
}
}

View File

@ -5,16 +5,19 @@ import (
)
type Cli struct {
*api.ApiCli
cli *api.Cli
}
func (c *Cli) HttpCli() *api.Cli {
return c.cli
}
func (c *Cli) New(i interface{}) (string, error) {
res := ""
err := c.HttpCli().JsonPost("/ipc/datasyncreportmgr/new", i, &res)
err := c.cli.HttpJsonPost("/ipc/datasyncreportmgr/new", i, &res)
return res, err
}
func NewCli() *Cli {
ret := &Cli{ApiCli: api.NewApiCli()}
ret := &Cli{cli: api.NewCli()}
return ret
}

View File

@ -11,7 +11,11 @@ const (
)
type Cli struct {
*api.ApiCli
cli *api.Cli
}
func (c *Cli) HttpCli() *api.Cli {
return c.cli
}
type Req struct {
@ -28,7 +32,7 @@ func (c *Cli) Read(fname string, sheet string) ([][]string, error) {
Sheet: sheet,
}
res := make([][]string, 0)
err := c.HttpCli().JsonPost("/ipc/excel/read", req, &res)
err := c.cli.HttpJsonPost("/ipc/excel/read", req, &res)
return res, err
}
func (c *Cli) Write(fname string, sheet string, cell string, val string, celtype string) error {
@ -40,20 +44,21 @@ func (c *Cli) Write(fname string, sheet string, cell string, val string, celtype
Celtype: celtype,
}
res := ""
err := c.HttpCli().JsonPost("/ipc/excel/write", req, &res)
err := c.cli.HttpJsonPost("/ipc/excel/write", req, &res)
return err
}
func (c *Cli) New(fname string, sheet string) (string, error) {
req := &Req{
File: fname,
Sheet: sheet,
}
res := ""
err := c.HttpCli().JsonPost("/ipc/excel/new", req, &res)
err := c.cli.HttpJsonPost("/ipc/excel/new", req, &res)
return res, err
}
func NewCli() *Cli {
ret := &Cli{ApiCli: api.NewApiCli()}
ret := &Cli{cli: api.NewCli()}
return ret
}

View File

@ -1,184 +1,197 @@
package ocr
package wingui
import (
"encoding/xml"
"fmt"
"go.digitalcircle.com.br/open/replaycli-go/api"
"log"
)
const ScreenShot = "ss"
type AltoString struct {
Text string `xml:",chardata"`
ID string `xml:"ID,attr"`
HPOS int `xml:"HPOS,attr"`
VPOS int `xml:"VPOS,attr"`
WIDTH int `xml:"WIDTH,attr"`
HEIGHT int `xml:"HEIGHT,attr"`
WC float64 `xml:"WC,attr"`
CONTENT string `xml:"CONTENT,attr"`
AHPOS int `xml:"AHPOS,attr"`
AVPOS int `xml:"AVPOS,attr"`
AWIDTH int `xml:"AWIDTH,attr"`
AHEIGHT int `xml:"AHEIGHT,attr"`
type Cli struct {
cli *api.Cli
}
func (a *AltoString) AbsCoords(q *Opts) {
nx := int(float64(a.HPOS)/q.Proportion) + q.X
ny := int(float64(a.VPOS)/q.Proportion) + q.Y
nw := int(float64(a.WIDTH) / q.Proportion)
nh := int(float64(a.HEIGHT) / q.Proportion)
log.Printf("Mapping: x: %v=>%v; y:%v=>%v; w:%v=>%v; h:%v=>%v;(Prop: %v,qx: %v, qy: %v)", a.HPOS, nx, a.VPOS, ny, a.WIDTH, nw, a.HEIGHT, nh, q.Proportion, q.X, q.Y)
a.AHPOS = nx
a.AVPOS = ny
a.AWIDTH = nw
a.AHEIGHT = nh
func (c *Cli) HttpCli() *api.Cli {
return c.cli
}
func (c *Cli) Ocr_screen(l string) (map[string]interface{}, error) {
d := 0
ret := make(map[string]interface{})
err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/ocr/screen?l=%s&d=%d", l, d), &ret)
return ret, err
}
func (c *Cli) ClipRead() (string, error) {
ret := ""
err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/clip/read"), &ret)
return ret, err
}
func (c *Cli) ClipWrite(site string) error {
err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/clip/write?str=%s", site), nil)
return err
}
func (c *Cli) MouseClick() error {
err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/mouse/click"), nil)
return err
}
func (c *Cli) MouseMove(x, y int) error {
err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/mouse/move?x=%d&y=%d", x, y), nil)
return err
}
func (c *Cli) MouseMoveRelative(x, y int) error {
err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/mouse/moverelative?x=%d&y=%d", x, y), nil)
return err
}
func (c *Cli) MouseClickRelative(x, y int) error {
err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/mouse/clickatrelative?x=%d&y=%d", x, y), nil)
return err
}
func (c *Cli) MouseClickAt(x, y int) error {
err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/mouse/clickat?x=%d&y=%d", x, y), nil)
return err
}
func (c *Cli) ScreenClick(f string) error {
err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/screen/click?f=%s", f), nil)
return err
}
func (c *Cli) ScreenClickCenter(f string) error {
err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/screen/clickcenter?f=%s", f), nil)
return err
}
func (c *Cli) ScreenFind(f string) (ret map[string]interface{}, err error) {
ret = make(map[string]interface{})
err = c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/screen/find?f=%s", f), &ret)
return
}
type AltoSP struct {
Text string `xml:",chardata"`
WIDTH int `xml:"WIDTH,attr"`
VPOS int `xml:"VPOS,attr"`
HPOS int `xml:"HPOS,attr"`
}
type AltoTextLine struct {
Text string `xml:",chardata"`
ID string `xml:"ID,attr"`
HPOS string `xml:"HPOS,attr"`
VPOS string `xml:"VPOS,attr"`
WIDTH string `xml:"WIDTH,attr"`
HEIGHT string `xml:"HEIGHT,attr"`
String []*AltoString `xml:"String"`
SP []*AltoSP `xml:"SP"`
}
type AltoTextBlock struct {
Text string `xml:",chardata"`
ID string `xml:"ID,attr"`
HPOS int `xml:"HPOS,attr"`
VPOS int `xml:"VPOS,attr"`
WIDTH int `xml:"WIDTH,attr"`
HEIGHT int `xml:"HEIGHT,attr"`
TextLine []*AltoTextLine `xml:"TextLine"`
}
type AltoComposedBlock struct {
Text string `xml:",chardata"`
ID string `xml:"ID,attr"`
HPOS int `xml:"HPOS,attr"`
VPOS int `xml:"VPOS,attr"`
WIDTH int `xml:"WIDTH,attr"`
HEIGHT int `xml:"HEIGHT,attr"`
TextBlock []*AltoTextBlock `xml:"TextBlock"`
}
type AltoPrintSpace struct {
Text string `xml:",chardata"`
HPOS int `xml:"HPOS,attr"`
VPOS int `xml:"VPOS,attr"`
WIDTH int `xml:"WIDTH,attr"`
HEIGHT int `xml:"HEIGHT,attr"`
ComposedBlock []*AltoComposedBlock `xml:"ComposedBlock"`
}
type AltoPage struct {
Text string `xml:",chardata"`
WIDTH int `xml:"WIDTH,attr"`
HEIGHT int `xml:"HEIGHT,attr"`
PHYSICALIMGNR string `xml:"PHYSICAL_IMG_NR,attr"`
ID string `xml:"ID,attr"`
PrintSpace *AltoPrintSpace `xml:"PrintSpace"`
}
type AltoDescription struct {
Text string `xml:",chardata"`
MeasurementUnit string `xml:"MeasurementUnit"`
SourceImageInformation struct {
Text string `xml:",chardata"`
FileName string `xml:"fileName"`
} `xml:"sourceImageInformation"`
OCRProcessing *struct {
Text string `xml:",chardata"`
ID string `xml:"ID,attr"`
OcrProcessingStep struct {
Text string `xml:",chardata"`
ProcessingSoftware struct {
Text string `xml:",chardata"`
SoftwareName string `xml:"softwareName"`
} `xml:"processingSoftware"`
} `xml:"ocrProcessingStep"`
} `xml:"OCRProcessing"`
}
type AltoLayout struct {
Text string `xml:",chardata"`
Page *AltoPage `xml:"Page"`
}
type Alto struct {
XMLName xml.Name `xml:"alto"`
Text string `xml:",chardata"`
Xmlns string `xml:"xmlns,attr"`
Xlink string `xml:"xlink,attr"`
Xsi string `xml:"xsi,attr"`
SchemaLocation string `xml:"schemaLocation,attr"`
Description *AltoDescription `xml:"Description"`
Layout *AltoLayout `xml:"Layout"`
func (c *Cli) KBTap(t string) (map[string]interface{}, error) {
/*Envia uma tecla ou teclas para serem clicadas no componente com foco onde o robo é executado
Em caso de teclas alteradoras, elas devem ser sempre posicionadas apos a tecla alvo.
Dessa forma, para enviar ALT+d, vc envia o string "d,alt". Para enviar C maiusculo, vc utiiliza
"c,shift".
Referencia das teclas e respectivos strings:
"`": 41,
"1": 2,
"2": 3,
"3": 4,
"4": 5,
"5": 6,
"6": 7,
"7": 8,
"8": 9,
"9": 10,
"0": 11,
"-": 12,
"+": 13,
//
"q": 16,
"w": 17,
"e": 18,
"r": 19,
"t": 20,
"y": 21,
"u": 22,
"i": 23,
"o": 24,
"p": 25,
"[": 26,
"]": 27,
"\\": 43,
//
"a": 30,
"s": 31,
"d": 32,
"f": 33,
"g": 34,
"h": 35,
"j": 36,
"k": 37,
"l": 38,
";": 39,
"'": 40,
//
"z": 44,
"x": 45,
"c": 46,
"v": 47,
"b": 48,
"n": 49,
"m": 50,
",": 51,
".": 52,
"/": 53,
//
"f1": 59,
"f2": 60,
"f3": 61,
"f4": 62,
"f5": 63,
"f6": 64,
"f7": 65,
"f8": 66,
"f9": 67,
"f10": 68,
"f11": 69,
"f12": 70,
// more
"esc": 1,
"delete": 14,
"tab": 15,
"ctrl": 29,
"control": 29,
"alt": 56,
"space": 57,
"shift": 42,
"rshift": 54,
"enter": 28,
//
"cmd": 3675,
"command": 3675,
"rcmd": 3676,
"ralt": 3640,
//
"up": 57416,
"down": 57424,
"left": 57419,
"right": 57421,
*/
ret := make(map[string]interface{})
err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/kb/tap?str=%s", t), &ret)
return ret, err
}
func (a *Alto) Strings() []*AltoString {
ret := make([]*AltoString, 0)
for _, v := range a.Layout.Page.PrintSpace.ComposedBlock {
for _, v1 := range v.TextBlock {
for _, v2 := range v1.TextLine {
for _, v3 := range v2.String {
ret = append(ret, v3)
}
}
}
}
return ret
}
func (a *Alto) CalcAbsolute(q *Opts) {
for _, v := range a.Layout.Page.PrintSpace.ComposedBlock {
for _, v1 := range v.TextBlock {
for _, v2 := range v1.TextLine {
for _, v3 := range v2.String {
v3.AbsCoords(q)
}
}
}
}
func (c *Cli) KBType(t string) (map[string]interface{}, error) {
/* Semelhante a tap, mas envia textos completos.
***ATENCAO*** Esse metodo usa urlencoding, dessa forma caracteres serao codificados para envio. # virará %23
por exemplo. Ao chegar no robo passrão pelo decoding análogo. */
ret := make(map[string]interface{})
err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/kb/type?str=%s", t), &ret)
return ret, err
}
type Opts struct {
Ver string `json:"ver,omitempty"`
X int `json:"x"`
Y int `json:"y"`
H int `json:"h"`
W int `json:"w"`
Blur float64 `json:"blur"`
Sharpen float64 `json:"sharpen"`
Resizew int `json:"resizew"`
Resizeh int `json:"resizeh"`
Lang string `json:"lang"`
Tempfile string `json:"tempfile"`
Dispid int `json:"d"`
Gray bool `json:"gray"`
Src string `json:"src"`
Bytes []byte `json:"bytes"`
AddRects bool `json:"add_rects"`
Proportion float64 `json:"proportion"`
Encoding string `json:"encoding"`
Absolute bool `json:"absolute"`
func (c *Cli) ScreenWait(f string, m int) (ret map[string]interface{}, err error) {
ret = make(map[string]interface{})
err = c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/screen/wait?f=%s&m=%d", f, m), &ret)
return
}
type Cli struct {
*api.ApiCli
func (c *Cli) ScreenWaitClick(f string, m int) (ret map[string]interface{}, err error) {
ret = make(map[string]interface{})
err = c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/screen/waitclick?f=%s&m=%d", f, m), &ret)
return
}
func (c *Cli) OCR(opts *Opts) (*Alto, error) {
res := &Alto{}
err := c.HttpCli().JsonPost("/ipc/ocr/", opts, res)
return res, err
func (c *Cli) ScreenWaitClickCenter(f string, m int) (ret map[string]interface{}, err error) {
ret = make(map[string]interface{})
err = c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/screen/waitclickcenter?f=%s&m=%d", f, m), &ret)
return
}
func NewCli() *Cli {
ret := &Cli{ApiCli: api.NewApiCli()}
ret := &Cli{cli: api.NewCli()}
return ret
}

View File

@ -1,27 +0,0 @@
package ocr_test
import (
"go.digitalcircle.com.br/open/replaycli-go/api/ocr"
"log"
"testing"
)
func TestCli_OCR(t *testing.T) {
c := ocr.NewCli()
a, err := c.OCR(&ocr.Opts{
X: 0,
Y: 0,
H: 400,
W: 400,
Resizew: 1200,
Sharpen: 1,
Tempfile: "some_test.jpg",
Src: "ss",
AddRects: true,
Gray: true,
})
if err != nil {
t.Fatal(err.Error())
}
log.Printf("#%v", a)
}

View File

@ -1,11 +1,8 @@
package replay
import (
"encoding/json"
"fmt"
"os"
"runtime"
"time"
"go.digitalcircle.com.br/open/replaycli-go/api"
"go.digitalcircle.com.br/open/replaycli-go/types"
@ -13,168 +10,63 @@ import (
)
type Cli struct {
*api.ApiCli
cli *api.Cli
}
//Log saves log to database after populated
func (c *Cli) Log(l *types.Log) error {
l.Alias = c.ReplayEnvAlias()
l.Dtlogend = time.Now()
return c.HttpCli().JsonPost("/api/v1/log/add", l, nil)
}
//NewLog creates a new log instance in the client, capable of collecting data in memory for later saving it to the
//database by calling Log
func (c *Cli) NewLog() *types.Log {
ret := &types.Log{}
ret.Alias = c.ReplayEnvAlias()
ret.Dtlog = time.Now()
return ret
}
func (c *Cli) ReplayEnvQueueId() string {
return os.Getenv("REPLAY_QUEUEID")
}
func (c *Cli) ReplayEnvAlias() string {
return os.Getenv("REPLAY_ALIAS")
}
func (c *Cli) ReplayEnvFeatureDir() string {
return os.Getenv("REPLAY_FEATUREDIR")
}
func (c *Cli) ReplayEnvRoot() string {
return os.Getenv("REPLAY_ROOT")
}
func (c *Cli) ReplayEnvAddr() string {
return os.Getenv("REPLAY_ADDR")
}
func (c *Cli) ReplayEnvHomeDir() string {
return os.Getenv("REPLAY_HOMEDIR")
}
func (c *Cli) ReplayPort() string {
return os.Getenv("REPLAY_PORT")
}
func (c *Cli) ReplayEnvRepo() string {
return os.Getenv("REPLAY_REPO")
}
func (c *Cli) ReplayEnvVer() string {
return os.Getenv("REPLAY_VER")
}
func (c *Cli) ReplayEnvRepoDir() string {
return os.Getenv("REPLAY_REPODIR")
}
func (c *Cli) ReplayEnvDataDir() string {
return os.Getenv("REPLAY_DATADIR")
}
func (c *Cli) ReplayEnvInstanceAlias() string {
return os.Getenv("REPLAY_INSTANCE_ALIAS")
}
func (c *Cli) ReplayEnvApiKey() string {
return os.Getenv("REPLAY_APIKEY")
func (c *Cli) HttpCli() *api.Cli {
return c.cli
}
func (c *Cli) OpenApp(id uint) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/api/v1/app/run/%d", id), nil)
err := c.cli.HttpJsonGet(fmt.Sprintf("/api/v1/app/run/%d", id), nil)
return err
}
func (c *Cli) ConfigGet(k string) (ret string, err error) {
err = c.HttpCli().JsonGet("/api/v1/config/byrepo/"+util.Repo()+"/"+k, &ret)
return
}
func (c *Cli) ConfigGetGlobal(k string) (ret string, err error) {
err = c.HttpCli().JsonGet("/api/v1/config/global/"+k, &ret)
err = c.cli.HttpJsonGet("/api/v1/config/byrepo/"+util.Repo()+"/"+k, &ret)
return
}
func (c *Cli) ConfigGetAll() (ret []types.Config, err error) {
ret = make([]types.Config, 0)
err = c.HttpCli().JsonGet("/api/v1/config/byrepo/"+util.Repo(), &ret)
return
}
func (c *Cli) ConfigGetMap() (ret map[string]types.Config, err error) {
cfgs, err := c.ConfigGetAll()
if err != nil {
return
}
ret = make(map[string]types.Config)
for _, v := range cfgs {
ret[v.K] = v
}
err = c.cli.HttpJsonGet("/api/v1/config/byrepo/"+util.Repo(), &ret)
return
}
func (c *Cli) CronReload() error {
return c.HttpCli().JsonGet("/ipc/cron/reload", nil)
return c.cli.HttpJsonGet("/ipc/cron/reload", nil)
}
func (c *Cli) Exit() error {
err := c.HttpCli().JsonGet("/api/v1/exit", nil)
err := c.cli.HttpJsonGet("/api/v1/exit", nil)
return err
}
func (c *Cli) MenuGetAllEnabled() (ret []types.Menu, err error) {
ret = make([]types.Menu, 0)
err = c.HttpCli().JsonGet("/api/v1/menu/enabled", &ret)
err = c.cli.HttpJsonGet("/api/v1/menu/enabled", nil)
return ret, err
}
func (c *Cli) QueueAdd(job string, bs []byte) error {
_, err := c.HttpCli().RawPost("/api/v1/queue/add/"+job, bs)
return err
return c.cli.HttpJsonGet("/api/v1/queue/add/"+job, bs)
}
func (c *Cli) QueueGetData(id string) (ret []byte, err error) {
ret, err = c.HttpCli().RawGet("/api/v1/queue/getrequest/" + id)
return
}
func (c *Cli) QueueGetDataBody(id string) (ret []byte, err error) {
ret, err = c.HttpCli().RawGet("/api/v1/queue/getrequestbody/" + id)
ret, err = c.cli.HttpRawGet("/api/v1/queue/getrequest/" + id)
return
}
func (c *Cli) QueueGetMyData() ([]byte, error) {
return c.QueueGetData(os.Getenv("REPLAY_QUEUEID"))
}
func (c *Cli) QueueGetMyJson(i *interface{}) error {
bs, err := c.QueueGetData(os.Getenv("REPLAY_QUEUEID"))
if err != nil {
return err
}
err = json.Unmarshal(bs, &i)
return err
}
func (c *Cli) QueueAbort() error {
return c.HttpCli().JsonGet("/api/v1/queue/abort", nil)
return c.cli.HttpJsonGet("/api/v1/queue/abort", nil)
}
func (c *Cli) QueueEnqueue(id uint) error {
return c.HttpCli().JsonGet(fmt.Sprintf("/api/v1/robots/op/enqueue/%d", id), nil)
}
func (c *Cli) QueueEnqueueWData(id string, bs []byte) ([]byte, error) {
return c.HttpCli().RawPost(fmt.Sprintf("api/v1/queue/add/%s", id), bs)
}
func (c *Cli) QueueEnqueueWDataWait(id string, bs []byte) ([]byte, error) {
return c.HttpCli().RawPost(fmt.Sprintf("api/v1/queue/addwait?job=%s", id), bs)
return c.cli.HttpJsonGet(fmt.Sprintf("/api/v1/robots/op/enqueue/%d", id), nil)
}
func (c *Cli) ServiceStopAll() error {
return c.HttpCli().JsonGet("/api/v1/service/op/stopall", nil)
}
func (c *Cli) Err(err string, desc string) error {
bs := make([]byte, 4096)
n := runtime.Stack(bs, false)
cd, _ := c.QueueGetMyData()
e := &types.Error{
Feature: c.ReplayEnvAlias(),
Err: err,
When: time.Time{},
Stack: string(bs[:n]),
InputData: string(cd),
Details: desc,
}
return c.HttpCli().JsonPost("/api/v1/err", e, nil)
return c.cli.HttpJsonGet("/api/v1/service/op/stopall", nil)
}
type SQLReturn struct {
@ -187,11 +79,11 @@ func (c *Cli) SQL(s string) (*SQLReturn, error) {
Sql string `json:"sql"`
}{s}
out := &SQLReturn{}
err := c.HttpCli().JsonPost("/api/v1/sql", in, &out)
err := c.cli.HttpJsonPost("/api/v1/sql", in, &out)
return out, err
}
func NewCli() *Cli {
ret := &Cli{ApiCli: api.NewApiCli()}
ret := &Cli{cli: api.NewCli()}
return ret
}

View File

@ -7,102 +7,64 @@ import (
)
type Cli struct {
*api.ApiCli
cli *api.Cli
}
const (
CCHDEVICENAME = 32
CCHFORMNAME = 32
ENUM_CURRENT_SETTINGS uint32 = 0xFFFFFFFF
ENUM_REGISTRY_SETTINGS uint32 = 0xFFFFFFFE
DISP_CHANGE_SUCCESSFUL uint32 = 0
DISP_CHANGE_RESTART uint32 = 1
DISP_CHANGE_FAILED uint32 = 0xFFFFFFFF
DISP_CHANGE_BADMODE uint32 = 0xFFFFFFFE
)
type DEVMODE struct {
DmDeviceName [CCHDEVICENAME]uint16
DmSpecVersion uint16
DmDriverVersion uint16
DmSize uint16
DmDriverExtra uint16
DmFields uint32
DmOrientation int16
DmPaperSize int16
DmPaperLength int16
DmPaperWidth int16
DmScale int16
DmCopies int16
DmDefaultSource int16
DmPrintQuality int16
DmColor int16
DmDuplex int16
DmYResolution int16
DmTTOption int16
DmCollate int16
DmFormName [CCHFORMNAME]uint16
DmLogPixels uint16
DmBitsPerPel uint32
DmPelsWidth uint32
DmPelsHeight uint32
DmDisplayFlags uint32
DmDisplayFrequency uint32
DmICMMethod uint32
DmICMIntent uint32
DmMediaType uint32
DmDitherType uint32
DmReserved1 uint32
DmReserved2 uint32
DmPanningWidth uint32
DmPanningHeight uint32
func (c *Cli) HttpCli() *api.Cli {
return c.cli
}
/***************** Clip Functions *****************/
func (c *Cli) ClipRead() (string, error) {
bs, err := c.HttpCli().RawGet("/ipc/wingui/clip/read")
return string(bs), err
ret := ""
err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/clip/read"), &ret)
return ret, err
}
func (c *Cli) ClipWrite(site string) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/clip/write?str=%s", site), nil)
err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/clip/write?str=%s", site), nil)
return err
}
/***************** Mouse Functions *****************/
func (c *Cli) Ocr_screen(l string) (map[string]interface{}, error) {
d := 0
ret := make(map[string]interface{})
err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/ocr/screen?l=%s&d=%d", l, d), &ret)
return ret, err
}
func (c *Cli) MouseClick() error {
err := c.HttpCli().JsonGet("/ipc/wingui/mouse/click", nil)
err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/mouse/click"), nil)
return err
}
func (c *Cli) MouseMove(x, y int) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/mouse/move?x=%d&y=%d", x, y), nil)
err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/mouse/move?x=%d&y=%d", x, y), nil)
return err
}
func (c *Cli) MouseMoveRelative(x, y int) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/mouse/moverelative?x=%d&y=%d", x, y), nil)
err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/mouse/moverelative?x=%d&y=%d", x, y), nil)
return err
}
func (c *Cli) MouseClickRelative(x, y int) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/mouse/clickatrelative?x=%d&y=%d", x, y), nil)
err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/mouse/clickatrelative?x=%d&y=%d", x, y), nil)
return err
}
func (c *Cli) MouseClickAt(x, y int) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/mouse/clickat?x=%d&y=%d", x, y), nil)
err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/mouse/clickat?x=%d&y=%d", x, y), nil)
return err
}
func (c *Cli) MouseDrag(x, y int, btn string) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/mouse/drag?x=%d&y=%d&btn=%s", x, y, btn), nil)
func (c *Cli) ScreenClick(f string) error {
err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/screen/click?f=%s", f), nil)
return err
}
/***************** KB Functions *****************/
func (c *Cli) ScreenClickCenter(f string) error {
err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/screen/clickcenter?f=%s", f), nil)
return err
}
func (c *Cli) ScreenFind(f string) (ret map[string]interface{}, err error) {
ret = make(map[string]interface{})
err = c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/screen/find?f=%s", f), &ret)
return
}
func (c *Cli) KBTap(t string) (map[string]interface{}, error) {
/*Envia uma tecla ou teclas para serem clicadas no componente com foco onde o robo é executado
@ -199,7 +161,7 @@ func (c *Cli) KBTap(t string) (map[string]interface{}, error) {
*/
ret := make(map[string]interface{})
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/kb/tap?str=%s", t), &ret)
err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/kb/tap?str=%s", t), &ret)
return ret, err
}
@ -209,334 +171,27 @@ func (c *Cli) KBType(t string) (map[string]interface{}, error) {
por exemplo. Ao chegar no robo passrão pelo decoding análogo. */
ret := make(map[string]interface{})
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/kb/type?str=%s", t), &ret)
err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/kb/type?str=%s", t), &ret)
return ret, err
}
func (c *Cli) KBToggle(str string) error {
err := c.HttpCli().JsonGet("/ipc/wingui/kb/toggle?str="+str, nil)
return err
func (c *Cli) ScreenWait(f string, m int) (ret map[string]interface{}, err error) {
ret = make(map[string]interface{})
err = c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/screen/wait?f=%s&m=%d", f, m), &ret)
return
}
/***************** Display Functions *****************/
func (c *Cli) DisplayRes() (*DEVMODE, error) {
ret := &DEVMODE{}
err := c.HttpCli().JsonGet("/ipc/wingui/display/res", ret)
return ret, err
func (c *Cli) ScreenWaitClick(f string, m int) (ret map[string]interface{}, err error) {
ret = make(map[string]interface{})
err = c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/screen/waitclick?f=%s&m=%d", f, m), &ret)
return
}
func (c *Cli) DisplaySetRes(d *DEVMODE) error {
err := c.HttpCli().JsonPost("/ipc/wingui/display/setres", d, nil)
return err
}
/***************** Draw Functions *****************/
func (c *Cli) DrawCLear() error {
err := c.HttpCli().JsonGet("/ipc/draw/clear", nil)
return err
}
func (c *Cli) DrawBox(x, y, w, h, t int) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/draw/addbox?x=%d&y=%d&w=%d&h=%d&t=%d", x, y, w, h, t), nil)
return err
}
func (c *Cli) DrawRect(x, y, w, h int) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/draw/addrect?x=%d&y=%d&w=%d&h=%d", x, y, w, h), nil)
return err
}
func (c *Cli) DrawAddText(t string, x, y int) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/draw/addtext?t=%s&x=%d&y=%d", t, x, y), nil)
return err
}
/***************** Notify Functions *****************/
func (c *Cli) NotifyAlert(msg, title string) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/notify/alert?msg=%s&title=%s", msg, title), nil)
return err
}
func (c *Cli) NotifyBeep(msg, title string) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/notify/notify?msg=%s&title=%s", msg, title), nil)
return err
}
/***************** Window Functions *****************/
func (c *Cli) WindowList(s string) (ret []map[string]interface{}, err error) {
err = c.HttpCli().JsonGet("/ipc/wingui/window/list?s="+s, &ret)
return ret, err
}
func (c *Cli) WindowHwnd(s string) (ret []int, err error) {
err = c.HttpCli().JsonGet("/ipc/wingui/window/hwnd?s="+s, &ret)
return ret, err
}
func (c *Cli) WindowActivate(Hwnd string) error {
err := c.HttpCli().JsonGet("/ipc/wingui/window/activate?Hwnd="+Hwnd, nil)
return err
}
func (c *Cli) WindowClose(Hwnd string) error {
err := c.HttpCli().JsonGet("/ipc/wingui/window/close?Hwnd="+Hwnd, nil)
return err
}
func (c *Cli) WindowMax(Hwnd string) error {
err := c.HttpCli().JsonGet("/ipc/wingui/window/max?Hwnd="+Hwnd, nil)
return err
}
func (c *Cli) WindowMin(Hwnd string) error {
err := c.HttpCli().JsonGet("/ipc/wingui/window/min?Hwnd="+Hwnd, nil)
return err
}
func (c *Cli) WindowActiveHwnd() (ret int, err error) {
err = c.HttpCli().JsonGet("/ipc/wingui/window/activehwnd", &ret)
return ret, err
}
func (c *Cli) WindowWaitActiveTitle(t string, m int) (ret map[string]interface{}, err error) {
err = c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/window/waitactivetitle?t=%s&m=%d", t, m), &ret)
return ret, err
}
func (c *Cli) WindowActiveTitle() (ret string, err error) {
err = c.HttpCli().JsonGet("/ipc/wingui/window/activetitle", &ret)
return ret, err
}
/*func (c *Cli) WindowWinfo(w int) (ret interface{}, err error) {
err = c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/window/winfo?w=%d", w), &ret)
return ret, err
}
func (c *Cli) WindowSendMsg(w, m string) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/window/sendmsg?w=%s&m=%s", w, m), nil)
return err
}
func (c *Cli) WindowPostMsg(w, m string) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/window/postmsg?w=%s&m=%s", w, m), nil)
return err
}*/
/***************** Screen Functions *****************/
func (c *Cli) ScreenCapture(x, y, w, h int, f string) (ret interface{}, err error) {
err = c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/screen/capture?x=%d&y=%d&w=%d&h=%d&f=%s", x, y, w, h, f), &ret)
return ret, err
}
func (c *Cli) ScreenFindAll(f string) (ret map[string]int, err error) {
err = c.HttpCli().JsonGet("/ipc/wingui/screen/findall?f="+f, &ret)
return ret, err
}
func (c *Cli) ScreenClick(f string) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/screen/click?f=%s", f), nil)
return err
}
func (c *Cli) ScreenClickCenter(f string) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/screen/clickcenter?f=%s", f), nil)
return err
}
func (c *Cli) ScreenFind(f string) (ret []interface{}, err error) {
err = c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/screen/find?f=%s", f), &ret)
func (c *Cli) ScreenWaitClickCenter(f string, m int) (ret map[string]interface{}, err error) {
ret = make(map[string]interface{})
err = c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/screen/waitclickcenter?f=%s&m=%d", f, m), &ret)
return
}
func (c *Cli) ScreenWait(f string, m int) ([]byte, error) {
url := fmt.Sprintf("/ipc/wingui/screen/wait?f=%s&m=%d", f, m)
ret, err := c.HttpCli().RawGet(url)
if err != nil {
fmt.Printf(err.Error())
}
fmt.Println(ret)
return ret, err
}
func (c *Cli) ScreenWaitClick(f string, m int) ([]byte, error) {
url := fmt.Sprintf("/ipc/wingui/screen/waitclick?f=%s&m=%d", f, m)
ret, err := c.HttpCli().RawGet(url)
if err != nil {
fmt.Printf(err.Error())
}
fmt.Println(ret)
return ret, err
}
func (c *Cli) ScreenWaitClickCenter(f string, m int) ([]byte, error) {
url := fmt.Sprintf("/ipc/wingui/screen/waitclickcenter?f=%s&m=%d", f, m)
ret, err := c.HttpCli().RawGet(url)
if err != nil {
fmt.Printf(err.Error())
}
fmt.Println(ret)
return ret, err
}
func (c *Cli) ScreenRes() ([]byte, error) {
url := "/ipc/wingui/screen/res"
ret, err := c.HttpCli().RawGet(url)
if err != nil {
fmt.Printf(err.Error())
}
return ret, err
}
func (c *Cli) ScreenSetRes(x, y, cor int) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/screen/setres?x=%d&y=%d&c=%d", x, y, cor), nil)
return err
}
func (c *Cli) ScreenScale() (ret []int, err error) {
err = c.HttpCli().JsonGet("/ipc/wingui/screen/scale", &ret)
return ret, err
}
func (c *Cli) ScreenSize() (ret []int, err error) {
err = c.HttpCli().JsonGet("/ipc/wingui/screen/size", &ret)
return ret, err
}
func (c *Cli) ScreenShot(frmt string) (ret []byte, err error) {
url := fmt.Sprintf("/ipc/wingui/screen/shot?fmt=%s", frmt)
ret, err = c.HttpCli().RawGet(url)
if err != nil {
fmt.Print(err.Error())
}
return ret, err
}
func (c *Cli) ScreenDsInternal() error {
err := c.HttpCli().JsonGet("/ipc/wingui/screen/dsinternal", nil)
return err
}
func (c *Cli) ScreenDsExternal() error {
err := c.HttpCli().JsonGet("/ipc/wingui/screen/dsexternal", nil)
return err
}
func (c *Cli) ScreenDsClone() error {
err := c.HttpCli().JsonGet("/ipc/wingui/screen/dsclone", nil)
return err
}
func (c *Cli) ScreenDsExtend() error {
err := c.HttpCli().JsonGet("/ipc/wingui/screen/dsextend", nil)
return err
}
/***************** Dialog Functions *****************/
func (c *Cli) DialogColor(t, d string) (ret map[string]int, err error) {
err = c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/dialog/color?t=%s&d=%s", t, d), &ret)
return ret, err
}
func (c *Cli) DialogDate(t, m, d, f string) (ret string, err error) {
err = c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/dialog/date?t=%s&m=%s&d=%s&f=%s", t, m, d, f), &ret)
return ret, err
}
func (c *Cli) DialogEntry(t, m, d string) (ret string, err error) {
err = c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/dialog/entry?t=%s&m=%s&d=%s", t, m, d), &ret)
return ret, err
}
func (c *Cli) DialogError(t, m string) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/dialog/error?t=%s&m=%s", t, m), nil)
return err
}
func (c *Cli) DialogFile(t, f, d string) (ret string, err error) {
err = c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/dialog/file?t=%s&f=%s&d=%s", t, f, d), &ret)
return ret, err
}
func (c *Cli) DialogFileMulti(t, f string) (ret []string, err error) {
err = c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/dialog/filemulti?t=%s&f=%s", t, f), &ret)
return ret, err
}
func (c *Cli) DialogInfo(t, m string) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/dialog/info?t=%s&m=%s", t, m), nil)
return err
}
func (c *Cli) DialogList(t, m, f string) (ret string, err error) {
err = c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/dialog/list?t=%s&m=%s&f=%s", t, m, f), &ret)
return ret, err
}
func (c *Cli) DialogListMulti(t, m, f string) (ret []string, err error) {
err = c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/dialog/listmulti?t=%s&m=%s&f=%s", t, m, f), &ret)
return ret, err
}
func (c *Cli) DialogPassword(t, m string) (ret string, err error) {
err = c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/dialog/password?t=%s&m=%s", t, m), &ret)
return ret, err
}
func (c *Cli) DialogQuestion(t, m string) (ret bool, err error) {
err = c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/dialog/question?t=%s&m=%s", t, m), &ret)
return ret, err
}
func (c *Cli) DialogWarn(t, m string) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/dialog/warn?t=%s&m=%s", t, m), nil)
return err
}
/***************** Process Functions *****************/
func (c *Cli) ProcAll() (ret []map[string]interface{}, err error) {
err = c.HttpCli().JsonGet("/ipc/wingui/proc/all", &ret)
return ret, err
}
func (c *Cli) ProcPids() (ret []int, err error) {
err = c.HttpCli().JsonGet("/ipc/wingui/proc/pids", &ret)
return ret, err
}
func (c *Cli) ProcKill(cmd int) (ret string, err error) {
err = c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/proc/kill?cmd=%d", cmd), &ret)
return ret, err
}
func (c *Cli) ProcExec(cmd string) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/proc/exec?cmd=%s", cmd), nil)
return err
}
func (c *Cli) ProcName(pid int) (ret string, err error) {
err = c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/proc/name?pid=%d", pid), &ret)
return ret, err
}
func (c *Cli) ProcPath(pid int) (ret string, err error) {
err = c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/proc/path?pid=%d", pid), &ret)
return ret, err
}
func NewCli() *Cli {
ret := &Cli{ApiCli: api.NewApiCli()}
ret := &Cli{cli: api.NewCli()}
return ret
}

View File

@ -75,5 +75,4 @@ const (
ENV_REPLAY_ALIAS = "REPLAY_ALIAS"
ENV_REPLAY_VER = "REPLAY_VER"
ENV_REPLAY_QUEUEID = "REPLAY_QUEUEID"
ENV_REPLAY_PRECMDS = "REPLAY_PRECMDS"
)

8
go.mod
View File

@ -2,13 +2,9 @@ module go.digitalcircle.com.br/open/replaycli-go
go 1.17
//replace (
// go.digitalcircle.com.br/open/httpcli => ../httpcli
//)
require (
github.com/Microsoft/go-winio v0.5.2
github.com/Microsoft/go-winio v0.5.0
github.com/gorilla/websocket v1.4.2
github.com/mitchellh/go-ps v1.0.0
go.digitalcircle.com.br/open/httpcli v0.0.0-20211031093505-ecf33aed8afb
golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9 // indirect
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6 // indirect
)

20
go.sum
View File

@ -1,9 +1,5 @@
github.com/Microsoft/go-winio v0.5.0 h1:Elr9Wn+sGKPlkaBvwu4mTrxtmOp3F3yV9qhaHbXGjwU=
github.com/Microsoft/go-winio v0.5.0/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84=
github.com/Microsoft/go-winio v0.5.1 h1:aPJp2QD7OOrhO5tQXqQoGSJc+DjDtWTGLOmNyAm6FgY=
github.com/Microsoft/go-winio v0.5.1/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84=
github.com/Microsoft/go-winio v0.5.2 h1:a9IhgEQBCUEk6QCdml9CiJGhAws+YwffDHEMp1VMrpA=
github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
@ -13,17 +9,9 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
go.digitalcircle.com.br/open/httpcli v0.0.0-20211010235458-74d201454158 h1:vFm0G1b4hBDJ7y/s2NqRuX99lwuI8/sxxH3XLUOdi0o=
go.digitalcircle.com.br/open/httpcli v0.0.0-20211010235458-74d201454158/go.mod h1:e/6vw7F4vgfs+ThQoLeBbYCYLTH1b5thzFwkFixi+oA=
go.digitalcircle.com.br/open/httpcli v0.0.0-20211031093505-ecf33aed8afb h1:gv0FO26InL2ctmhCqthsOFEooi0FvA1rFT6VXzgveJE=
go.digitalcircle.com.br/open/httpcli v0.0.0-20211031093505-ecf33aed8afb/go.mod h1:e/6vw7F4vgfs+ThQoLeBbYCYLTH1b5thzFwkFixi+oA=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac h1:oN6lz7iLW/YC7un8pq+9bOLyXrprv2+DKfkJY+2LJJw=
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211031064116-611d5d643895 h1:iaNpwpnrgL5jzWS0vCNnfa8HqzxveCFpFx3uC/X4Tps=
golang.org/x/sys v0.0.0-20211031064116-611d5d643895/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211106132015-ebca88c72f68 h1:Ywe/f3fNleF8I6F6qv3MeFoSZ6CTf2zBMMa/7qVML8M=
golang.org/x/sys v0.0.0-20211106132015-ebca88c72f68/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9 h1:nhht2DYV/Sn3qOayu8lM+cU1ii9sTLUeBQwQQfUHtrs=
golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210921065528-437939a70204 h1:JJhkWtBuTQKyz2bd5WG9H8iUsJRU3En/KRfN8B2RnDs=
golang.org/x/sys v0.0.0-20210921065528-437939a70204/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6 h1:foEbQz/B0Oz6YIqu/69kfXPYeFQAuuMYFkjaqXzl5Wo=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

View File

@ -56,7 +56,7 @@ func (p *PSCli) GetConn() *websocket.Conn {
p.con = con
p.con.SetCloseHandler(func(code int, text string) error {
log.Printf("Connection closed: %d: %s", code, text)
p.Close()
p.con = nil
return nil
})
break
@ -95,17 +95,6 @@ func (p *PSCli) Read(i interface{}) error {
return json.Unmarshal(bs, i)
}
func (p *PSCli) Close() error {
if !p.closed {
p.closed = true
if p.ch != nil {
close(p.ch)
}
return p.con.Close()
}
return nil
}
func NewCli(q string) (*PSCli, error) {
ret := &PSCli{}
ret.q = q

View File

@ -1,10 +1,6 @@
package types
import (
"encoding/json"
"fmt"
"os"
"strconv"
"time"
)
@ -70,7 +66,6 @@ type Service struct {
Pid int `json:"pid" yaml:"-"`
Hostname string `json:"hostname" yaml:"hostname"`
Gui bool `json:"gui" yaml:"gui"`
Public bool `json:"public" yaml:"public"`
}
type Runtime struct {
@ -111,7 +106,6 @@ type ReplayDescriptor struct {
Hostname string `json:"hostname" yaml:"hostname"`
Ipcid string `json:"ipcid"`
Gui bool `json:"gui" yaml:"gui"`
Public bool `json:"public" yaml:"public"`
Link string `json:"link" yaml:"link"` //This prop allows redirect of repos
}
@ -144,55 +138,6 @@ type Config struct {
Repo uint `json:"repo"`
}
func (c *Config) AsInt64() int64 {
i, err := strconv.ParseInt(c.V, 10, 64)
if err != nil {
return 0
}
return i
}
func (c *Config) AsInt32() int32 {
i, err := strconv.ParseInt(c.V, 10, 32)
if err != nil {
return 0
}
return int32(i)
}
func (c *Config) AsUint() uint {
i, err := strconv.ParseInt(c.V, 10, 32)
if err != nil {
return 0
}
return uint(i)
}
func (c *Config) AsInt() int {
i, err := strconv.ParseInt(c.V, 10, 16)
if err != nil {
return 0
}
return int(i)
}
func (c *Config) AsFloat64() float64 {
i, err := strconv.ParseFloat(c.V, 64)
if err != nil {
return 0
}
return i
}
func (c *Config) AsFloat32() float32 {
i, err := strconv.ParseFloat(c.V, 32)
if err != nil {
return 0
}
return float32(i)
}
func (c *Config) AsBool() bool {
return c.V == "true" || c.V == "1" || c.V == "t"
}
func (c *Config) AsJson(i interface{}) error {
return json.Unmarshal([]byte(c.V), i)
}
type Credentials struct {
Model
Name string `json:"name"`
@ -203,47 +148,7 @@ type Credentials struct {
type Log struct {
Model
Alias string `json:"alias,omitempty"`
Title string `json:"title,omitempty"`
Tags string `json:"tags,omitempty"`
Dtlog time.Time `json:"dtlog"`
Dtlogend time.Time `json:"dtlogend"`
Data []byte `json:"data,omitempty"`
Err string `json:"err,omitempty"`
History string `json:"history,omitempty"`
}
func (l *Log) Write(p []byte) (n int, err error) {
_, err = os.Stdout.Write([]byte(fmt.Sprintf("- %s\n", string(p))))
if err != nil {
println(fmt.Sprintf("Log.Write:: Error writing log: %s", err.Error()))
return 0, err
}
l.AddHistory(string(p))
return len(p), nil
}
func (l *Log) AddHistory(s string) {
s = fmt.Sprintf("* %s: %s", time.Now().Format("02/01/06 - 15:04:05"), s)
if l.History == "" {
l.History = s
} else {
l.History = l.History + "\n" + s
}
}
func (l *Log) Printf(s string, i ...interface{}) {
l.AddHistory(fmt.Sprintf(s, i...))
s = fmt.Sprintf("* %s: %s", time.Now().Format("02/01/06 - 15:04:05"), s)
}
type LogQuery struct {
From time.Time `json:"from"`
Until time.Time `json:"until"`
Limit int `json:"limit"`
Title string `json:"title"`
Alias string `json:"alias"`
Tags string `json:"tags"`
Log []byte
}
type Job struct {
@ -310,13 +215,9 @@ type Options struct {
type Cron struct {
Model
Cron string `json:"cron"`
JobCode uint `json:"job"`
JobAlias string `json:"jobalias" gorm:"-"`
Enabled *bool `json:"enabled"`
Data string `json:"data"`
Comments string `json:"comments"`
Once bool `json:"once"`
Cron string `json:"cron"`
JobCode uint `json:"job"`
Enabled *bool `json:"enabled"`
}
//type Resource struct {
@ -437,15 +338,6 @@ type Series struct {
Year int `json:"year"`
}
type Error struct {
Feature string `json:"feature,omitempty"`
When time.Time `json:"when"`
Err string `json:"err,omitempty"`
Stack string `json:"stack,omitempty"`
InputData string `json:"input_data,omitempty"`
Details string `json:"details,omitempty"`
}
func (s *Series) SetTime(t time.Time) {
s.When = t
s.Day = t.Day()