From 6ef42d1ccbe0c6d26193dcbca46aaa04d082d2aa Mon Sep 17 00:00:00 2001 From: Leonardo Domingues Date: Fri, 5 Nov 2021 18:03:02 -0300 Subject: [PATCH 1/5] =?UTF-8?q?Implementa=C3=A7=C3=A3o=20de=20Registro=20s?= =?UTF-8?q?implificado=20da=20LCR?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/dataapi/lib_test.go | 65 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/api/dataapi/lib_test.go b/api/dataapi/lib_test.go index a4b0dab..7c03e6a 100644 --- a/api/dataapi/lib_test.go +++ b/api/dataapi/lib_test.go @@ -1,9 +1,10 @@ package dataapi_test import ( - "go.digitalcircle.com.br/open/replaycli-go/api/dataapi" "log" "testing" + + "go.digitalcircle.com.br/open/replaycli-go/api/dataapi" ) func TestAPIRetrieve(t *testing.T) { @@ -80,3 +81,65 @@ func TestAPICreate(t *testing.T) { log.Printf("%#v", res) } + +func LCR_Create(t *testing.T) { + c := dataapi.NewCli("RnJpIDA1IE5vdiAyMDIxIDExOjE1OjIyIEFNIFVUQwo") + + res, err := c.Do(&dataapi.DataAPIRequest{ + Col: "LCR_Bot", + Op: dataapi.CREATE, + Data: map[string]interface{}{ + "Registro": "1", + }, + }) + if err != nil { + t.Fatal(err.Error()) + } + + log.Printf("%#v", res) +} + +/*func CreateControl(t *testing.T, table string) { + c := dataapi.NewCli("RnJpIDA1IE5vdiAyMDIxIDExOjE1OjIyIEFNIFVUQwo") + current := time.Now().Format("2006-01") + res, err := c.Do(&dataapi.DataAPIRequest{ + Col: table, + Op: dataapi.CREATE, + Data: map[string]interface{}{ + "date": current, + "qtd": 0, + }, + }) + if err != nil { + t.Fatal(err.Error()) + } + + log.Printf("%#v", res) +} + +func UpdateControl(t *testing.T, table string) { + c := dataapi.NewCli("RnJpIDA1IE5vdiAyMDIxIDExOjE1OjIyIEFNIFVUQwo") + current := time.Now().Format("2006-01") + res, err := c.Do(&dataapi.DataAPIRequest{ + Col: table, + Op: dataapi.RETRIEVE, + Q: "@[?date=="+current+"]", + }) + if err != nil { + t.Fatal(err.Error()) + } + res.Data()[0] + 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) +}*/ From f8acbf0c036dade6bd3a7f4a34c4b54a03630752 Mon Sep 17 00:00:00 2001 From: Leonardo Domingues Date: Fri, 5 Nov 2021 18:09:09 -0300 Subject: [PATCH 2/5] =?UTF-8?q?Adi=C3=A7=C3=A3o=20da=20fun=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/dataapi/lib.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/api/dataapi/lib.go b/api/dataapi/lib.go index ab5815b..aae3cc4 100644 --- a/api/dataapi/lib.go +++ b/api/dataapi/lib.go @@ -43,3 +43,18 @@ func NewCli(apikey string) *Cli { ret.Httpcli.SetBasePath("https://dataapi.digitalcircle.com.br") return ret } + +func LCR_Create() { + c := NewCli("RnJpIDA1IE5vdiAyMDIxIDExOjE1OjIyIEFNIFVUQwo") + + _, err := c.Do(&DataAPIRequest{ + Col: "LCR_Bot", + Op: CREATE, + Data: map[string]interface{}{ + "Registro": "1", + }, + }) + if err != nil { + panic(err) + } +} From 2543c4bf9af9242d5bb333805861bcc1e00abe3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paulo=20Sim=C3=A3o?= Date: Sat, 6 Nov 2021 13:55:42 -0300 Subject: [PATCH 3/5] added wingui-display cli --- api/wingui/cli.go | 62 ++++++++++++++++++++++++++++++++++++++++++++--- go.mod | 2 +- go.sum | 2 ++ 3 files changed, 62 insertions(+), 4 deletions(-) diff --git a/api/wingui/cli.go b/api/wingui/cli.go index f35c73c..f6893d1 100644 --- a/api/wingui/cli.go +++ b/api/wingui/cli.go @@ -10,9 +10,53 @@ type Cli struct { *api.ApiCli } -//func (c *Cli) HttpCli() *api.Cli { -// return c.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) ClipRead() (string, error) { ret := "" @@ -208,11 +252,23 @@ func (c *Cli) ScreenRes() ([]byte, 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) DisplayRes() (*DEVMODE, error) { + ret := &DEVMODE{} + err := c.HttpCli().JsonGet("/ipc/wingui/display/res", ret) + return ret, err +} + +func (c *Cli) DisplaySetRes(d *DEVMODE) error { + err := c.HttpCli().JsonPost("/ipc/wingui/display/setres", d, nil) + return err +} + func NewCli() *Cli { ret := &Cli{ApiCli: api.NewApiCli()} return ret diff --git a/go.mod b/go.mod index e2159fe..95ff4f2 100644 --- a/go.mod +++ b/go.mod @@ -10,5 +10,5 @@ require ( 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-20211031064116-611d5d643895 // indirect + golang.org/x/sys v0.0.0-20211106132015-ebca88c72f68 // indirect ) diff --git a/go.sum b/go.sum index e194fcc..e3c6a5e 100644 --- a/go.sum +++ b/go.sum @@ -21,3 +21,5 @@ golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac h1:oN6lz7iLW/YC7un8pq+9bOLyX 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= From a8daeabffbf39364230544a36ba8ee725bcd8c83 Mon Sep 17 00:00:00 2001 From: Leonardo Domingues Date: Mon, 8 Nov 2021 10:32:29 -0300 Subject: [PATCH 4/5] =?UTF-8?q?Fun=C3=A7=C3=A3o=20para=20contar=20execu?= =?UTF-8?q?=C3=A7=C3=B5es=20mensais=20de=20rob=C3=B4s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/dataapi/lib.go | 47 +++++++++++++++++++++++++++++++++++++++++ api/dataapi/lib_test.go | 45 --------------------------------------- 2 files changed, 47 insertions(+), 45 deletions(-) diff --git a/api/dataapi/lib.go b/api/dataapi/lib.go index aae3cc4..1909cc3 100644 --- a/api/dataapi/lib.go +++ b/api/dataapi/lib.go @@ -1,6 +1,9 @@ package dataapi import ( + "strconv" + "time" + "go.digitalcircle.com.br/open/httpcli" ) @@ -58,3 +61,47 @@ func LCR_Create() { panic(err) } } + +func RegistrarExec(table string) { + //Para robôs, age como contador e registra cada repetição no mês + c := NewCli("RnJpIDA1IE5vdiAyMDIxIDExOjE1OjIyIEFNIFVUQwo") + 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 { + result := res.Data[0].(map[string]interface{}) + registros := result["exec"].(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{}{ + "exec": registros, + }, + }) + if err != nil { + panic(err) + } + } else { + _, err = c.Do(&DataAPIRequest{ + Col: table, + Op: CREATE, + Data: map[string]interface{}{ + "date": current, + "exec": 1, + }, + }) + if err != nil { + panic(err) + } + } +} diff --git a/api/dataapi/lib_test.go b/api/dataapi/lib_test.go index 7c03e6a..953ff4f 100644 --- a/api/dataapi/lib_test.go +++ b/api/dataapi/lib_test.go @@ -98,48 +98,3 @@ func LCR_Create(t *testing.T) { log.Printf("%#v", res) } - -/*func CreateControl(t *testing.T, table string) { - c := dataapi.NewCli("RnJpIDA1IE5vdiAyMDIxIDExOjE1OjIyIEFNIFVUQwo") - current := time.Now().Format("2006-01") - res, err := c.Do(&dataapi.DataAPIRequest{ - Col: table, - Op: dataapi.CREATE, - Data: map[string]interface{}{ - "date": current, - "qtd": 0, - }, - }) - if err != nil { - t.Fatal(err.Error()) - } - - log.Printf("%#v", res) -} - -func UpdateControl(t *testing.T, table string) { - c := dataapi.NewCli("RnJpIDA1IE5vdiAyMDIxIDExOjE1OjIyIEFNIFVUQwo") - current := time.Now().Format("2006-01") - res, err := c.Do(&dataapi.DataAPIRequest{ - Col: table, - Op: dataapi.RETRIEVE, - Q: "@[?date=="+current+"]", - }) - if err != nil { - t.Fatal(err.Error()) - } - res.Data()[0] - 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) -}*/ From eaaa1a62245bbb60951c2a2318b5799193ce84b0 Mon Sep 17 00:00:00 2001 From: Leonardo Domingues Date: Tue, 9 Nov 2021 09:43:25 -0300 Subject: [PATCH 5/5] =?UTF-8?q?Inclus=C3=A3o=20de=20erro?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/dataapi/lib.go | 61 ++++++++++++++++++++------- api/dataapi/lib_test.go | 93 ++++++++++++++++++++++++++++++----------- 2 files changed, 114 insertions(+), 40 deletions(-) diff --git a/api/dataapi/lib.go b/api/dataapi/lib.go index 1909cc3..bb1e1ba 100644 --- a/api/dataapi/lib.go +++ b/api/dataapi/lib.go @@ -62,9 +62,11 @@ func LCR_Create() { } } -func RegistrarExec(table string) { +func RegistrarExec(table string, check bool) { //Para robôs, age como contador e registra cada repetição no mês c := NewCli("RnJpIDA1IE5vdiAyMDIxIDExOjE1OjIyIEFNIFVUQwo") + var registros int + var erro int current := time.Now().Format("2006-01") res, err := c.Do(&DataAPIRequest{ Col: table, @@ -75,29 +77,56 @@ func RegistrarExec(table string) { panic(err) } if len(res.Data) > 0 { - result := res.Data[0].(map[string]interface{}) - registros := result["exec"].(float64) - registros = registros + 1 - ident := strconv.Itoa(int(result["ID"].(float64))) + 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(&DataAPIRequest{ - Col: table, - Op: UPDATE, - Id: ident, - Data: map[string]interface{}{ - "exec": registros, - }, - }) - if err != nil { - panic(err) + _, err = c.Do(&DataAPIRequest{ + Col: table, + Op: 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(&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 + } else { + registros = 0 + erro = 1 + } _, err = c.Do(&DataAPIRequest{ Col: table, Op: CREATE, Data: map[string]interface{}{ "date": current, - "exec": 1, + "exec": registros, + "err": erro, }, }) if err != nil { diff --git a/api/dataapi/lib_test.go b/api/dataapi/lib_test.go index 953ff4f..7893da8 100644 --- a/api/dataapi/lib_test.go +++ b/api/dataapi/lib_test.go @@ -2,7 +2,9 @@ package dataapi_test import ( "log" + "strconv" "testing" + "time" "go.digitalcircle.com.br/open/replaycli-go/api/dataapi" ) @@ -10,7 +12,7 @@ import ( func TestAPIRetrieve(t *testing.T) { c := dataapi.NewCli("RnJpIDA1IE5vdiAyMDIxIDExOjE1OjIyIEFNIFVUQwo") res, err := c.Do(&dataapi.DataAPIRequest{ - Col: "C1", + Col: "teste3", Op: dataapi.RETRIEVE, }) if err != nil { @@ -66,35 +68,78 @@ func TestAPIDelete(t *testing.T) { } func TestAPICreate(t *testing.T) { + if true { + print("a") + print("b") + } c := dataapi.NewCli("RnJpIDA1IE5vdiAyMDIxIDExOjE1OjIyIEFNIFVUQwo") - + var registros int + var erro int + current := time.Now().Format("2006-01") res, err := c.Do(&dataapi.DataAPIRequest{ - Col: "C1", - Op: dataapi.CREATE, - Data: map[string]interface{}{ - "MSG": "OI LEO", - }, + Col: "teste3", + Op: dataapi.RETRIEVE, + Q: "@[?date=='" + current + "']", }) if err != nil { - t.Fatal(err.Error()) + 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))) - log.Printf("%#v", res) -} + _, 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))) -func LCR_Create(t *testing.T) { - c := dataapi.NewCli("RnJpIDA1IE5vdiAyMDIxIDExOjE1OjIyIEFNIFVUQwo") - - res, err := c.Do(&dataapi.DataAPIRequest{ - Col: "LCR_Bot", - Op: dataapi.CREATE, - Data: map[string]interface{}{ - "Registro": "1", - }, - }) - if err != nil { - t.Fatal(err.Error()) + _, 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) + } } - - log.Printf("%#v", res) }