PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 25 → WX - Exemplo de Groupware com Ms SQL Server
WX - Exemplo de Groupware com Ms SQL Server
Débuté par BOLLER, 29 mar. 2017 18:17 - 2 réponses
Membre enregistré
3 651 messages
Popularité : +175 (223 votes)
Posté le 29 mars 2017 - 18:17
//Conexao com o Groupware com Ms SQL Server

NextTitle("Atenção")
ok1, ok2, ok3, ok4, ok5, ok6, ok7 is boolean

//Chumbado
gbIsSupervisor is boolean = False
gsLoginUser is string = "SUPERVISOR"
gsSenhaBanco is string = ""
sGsSENHA_Descriptografada is string = "SUPERVISOR"
gsSENHA_Criptografada is string = "5478912705504311106505606512519607210513408801321103304"
sGsPaginaInicial is string = "PAGE_Logado"
nReturnedValue is int = 0

gpwUser is Data Source
CNT_GPW is Connection
CNT_GPW..Provider = hNativeAccessSQLServer
CNT_GPW..User = "sa"
CNT_GPW..Password = "senhahipersecreta"
CNT_GPW..Source = "192.168.0.1\nomedasuabasededados"
CNT_GPW..Database = "nomedasuabasededados"
CNT_GPW..CryptMethod = hCryptNo


// Open the connection
ok1 = gpwOpenConnection(CNT_GPW)

ok2 = HOpenConnection(CNT_GPW)
IF ok2 = False THEN
Info(ErrorOccurred() +" - "+ HErrorInfo())
END

ok3 = HChangeConnection(gpwUser,CNT_GPW)

IF ErrorInfo() > 0 OR ok3 = False
Error(HErrorInfo() + CR + ErrorInfo())
END

ok4 = HReadSeekFirst(GPU_User,Login,gsLoginUser)

IF ok1 = True AND ok2 = True AND ok3 = True AND ok4 = True

gsLoginUser = GPU_User.Login
gsSenhaBanco = GPU_User.Password
gbIsSupervisor = GPU_User.Supervisor

IF gpwInitAnalysis() = False THEN

Error(ErrorInfo())

ok5 = False

ELSE

ok5 = True

//checa login e senha
nRes is int = gpwCheckUser(gsLoginUser,gsSENHA_Criptografada)

IF nRes = 0

ok6 = True //100%

nReturnedValue = gpwConnectUser(gsLoginUser, gsSENHA_Criptografada)

IF nReturnedValue <> gpwOk AND nReturnedValue <> 0 THEN

SWITCH nReturnedValue
CASE gpwError: Error("Unable to connect.")
CASE gpwUnknownUser, gpwInvalidPassword:
Error("Usuário inválido ou senha.")
END

ok7 = False

ToastDisplay("Login não encontrado",toastLong,vaMiddle,haCenter)

ELSE IF nReturnedValue = gpwOk OR nReturnedValue = 0

ok7 = True

// Connect as administrator
IF gpwGetUserInfo(gpwInfoSupervisor) = True
PageDisplay(PAGE_Default)
ELSE
PageDisplay(PAGE_Default)
END

END

ELSE
ToastDisplay("Login não encontrado",toastLong,vaMiddle,haCenter)
END

END

ELSE
Info("Tabela GPU_User não localizada!")
END


OBS.: As tabelas do groupware pode ter novos campos, mas não pode alterar os ja existentes.

Bons estudos!

:merci:

--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Membre enregistré
3 651 messages
Popularité : +175 (223 votes)
Posté le 10 avril 2017 - 19:43
VERSAO FINAL

//Conexao com o Groupware

NextTitle("Atenção")
ok1, ok2, ok3, ok4, ok5, ok6, ok7, ok8, LoginOK is boolean

//Chumbado
sGsPaginaInicial is string = "PAGE_Logado"
nReturnedValue is int = 0

gpwUser is Data Source
CNT_GPW is Connection
CNT_GPW..Provider = hNativeAccessSQLServer
CNT_GPW..User = "integracao-wd"
CNT_GPW..Password = "4s31nt!360"
CNT_GPW..Source = "192.168.0.217\360"
CNT_GPW..Database = "360_catalogo" //conectar primeiro no catalogo
CNT_GPW..CryptMethod = hCryptNo


// Open the connection
ok1 = gpwOpenConnection(CNT_GPW)

ok2 = HOpenConnection(CNT_GPW)
IF ok2 = False THEN
Info(ErrorOccurred() +" - "+ HErrorInfo())
END

ok3 = HChangeConnection(gpwUser,CNT_GPW)

IF ErrorInfo() > 0 OR ok3 = False
Error(HErrorInfo() + CR + ErrorInfo())
END

gsLoginUser = INP_Login

gsSENHA_Criptografada is string = SET_New_GPU.GPW_StringToInteger(INP_senha)

ok4 = HReadSeekFirst(GPU_User,GPU_User.Login,gsLoginUser)
IF ok4 = True
FOR EACH GPU_User
IF HFound(GPU_User) = True AND GPU_User.Login = gsLoginUser AND GPU_User.Password = gsSENHA_Criptografada OR
HFound(GPU_User) = True AND GPU_User.Login = Upper(gsLoginUser) AND GPU_User.Password = gsSENHA_Criptografada
LoginOK = True
gsLoginUser = GPU_User.Login
gsSenhaCript = GPU_User.Password
gsSenha = SET_New_GPU.GPW_IntegerToString(GPU_User.Password)
gbIsSupervisor = GPU_User.Supervisor
gsCNPJ = GPU_User.CNPJ //FILTRO DE LISTAGEM SÓ DO CLIENTE
gsGPU_UserDataSource = GPU_User.DatabaseName
gsGPU_UserPortaDB = GPU_User.PortaDB
gsGPU_UserDatabaseName = GPU_User.DatabaseName
gsGPU_UserUserDataBase = GPU_User.UserDataBase
gsGPU_UserPassWordDataBase = GPU_User.PassWordDataBase
END
END
END

IF LoginOK = True

IF ok1 = True AND ok2 = True AND ok3 = True AND ok4 = True

IF gpwInitAnalysis() = False THEN

Error(ErrorInfo())

ok5 = False

ELSE

ok5 = True

//checa login e senha
nRes is int = gpwCheckUser(gsLoginUser,gsSENHA_Criptografada)

IF nRes = 0

ok6 = True //100%

nReturnedValue = gpwConnectUser(gsLoginUser, gsSENHA_Criptografada)

IF nReturnedValue <> gpwOk AND nReturnedValue <> 0 THEN

SWITCH nReturnedValue
CASE gpwError: Error("Unable to connect.")
CASE gpwUnknownUser, gpwInvalidPassword:
Error("Usuário inválido ou senha.")
END

ok7 = False

ToastDisplay("Login não encontrado",toastLong,vaMiddle,haCenter)

ELSE IF nReturnedValue = gpwOk OR nReturnedValue = 0

ok7 = True

ok8 = gpwGetUserInfo(gpwInfoSupervisor)

// Connect as administrator
IF ok8=True AND gsLoginUser = "SUPERVISOR" THEN

// Open the connection
ok1 = gpwOpenConnection(ConnCatalogo) //catalogo

ok2 = HOpenConnection(ConnCatalogo)
IF ok2 = False THEN
Info(ErrorOccurred() +" - "+ HErrorInfo())
END

ok3 = HChangeConnection("*",ConnCatalogo)

IF ErrorInfo() > 0 OR ok3 = False
Error(HErrorInfo() + CR + ErrorInfo())
END

//PAGINA DO GROUPWARE
PageDisplay(PAGE_GPU_UsersAndGroups)

ELSE IF ok8 = True AND gsLoginUser <> "SUPERVISOR"

// Open the connection
ok1 = gpwOpenConnection(Conn360) //user normal

ok2 = HOpenConnection(Conn360)
IF ok2 = False THEN
Info(ErrorOccurred() +" - "+ HErrorInfo())
END

ok3 = HChangeConnection("*",Conn360)

IF ErrorInfo() > 0 OR ok3 = False
Error(HErrorInfo() + CR + ErrorInfo())
END

//PAGINA INICIAL DO PROJETO
PageDisplay(PAGE_Default)

ELSE

ToastDisplay("Usuário não localizado",toastLong,vaMiddle,haCenter)

END

END

ELSE

ToastDisplay("Login não encontrado",toastLong,vaMiddle,haCenter)

END

END

ELSE

ToastDisplay("Usuário não localizado!",toastLong,vaMiddle,haCenter)

END

ELSE

ToastDisplay("Senha invalida!",toastLong,vaMiddle,haCenter)

END


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Membre enregistré
3 651 messages
Popularité : +175 (223 votes)
Posté le 28 août 2017 - 15:47
HCS.Timeout & HCS.FrameSize
Um variável HCS.Timeout é usado para modificar o tempo limite de conexão:
Para como conexões estabelecidas pelo HOpenConnection.
Para como aberturas de conexão automática.
Nota: Um variável HCS.Timeout é ignorado para os acessos ao servidor que não é uma conexão. Um pedido de execução é maior DO que o valor específico na variável HCS.Timeout não seria interrompida, por exemplo. Esse tempo limite deve ser especificado No aplicativo cliente, antes que seja uma conexão aberta sem servidor.
Exemplo

HCS.Timeout = INTRANET

Um variável HCS.FrameSize é usado para redimensionar o quadro de dados de saída. Em alguns casos, o redimensionamento dos quadros pode ser usado para adaptar o fluxo de dados de saída e de entrada aos desempenhos DO hardware usado. Por exemplo, se uma conexão entre os computadores e o cliente HFSQL Client / Server para através de redes de configuração (placa de rede, SWITCH, roteador, vpn, ...)

HCS.FrameSize = hInternetFrame


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/