PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 25 → Windev - Socket central Telefônica IP
Windev - Socket central Telefônica IP
Débuté par adrianoboller, 10 fév. 2016 13:22 - 20 réponses
Membre enregistré
3 657 messages
Popularité : +175 (223 votes)
Posté le 10 février 2016 - 13:22
Prezados,

Segue abaixo exemplo de código O.O.P. trabalhando com Socket central telefônica IP.


CLASSE CFimChamadaAvancada

CFimChamadaAvancada is a Class
inherits from CProtocolo
m_Data is string
m_Hora is string
m_Tronco is string
m_Duracao is string
m_Ramal is string
END

//Formato:
//{ - Caracter Inicial
//599|030| - Cabeçalho
//Data - Data da ligação(dd/mm/yyyy)
//, - Separador
//Hora - Hora inicial da ligação(hh/mm/ss)
//, - Separador
//Tronco - Tronco utilizado
//, - Separador
//Duração - Duração total da ligação(hh/mm/ss)
//, - Separador
//Ramal - Ramal utilizado
//, - Separador
//DDD - DDD identificado
//, - Separador
//Telefone - Telefone identificado
//{ - Caracter Final
//
//Exemplo:
//Visys_FimChamadaAvancada
//TextoSocket = "{599|030|14/03/2014,11:21:55,99,00:00:10,8692,047,04730361010}"



Procedure Constructor(ln_DDD, ln_Telefone are int, ls_Data, ls_Hora, ls_Tronco, ls_Duracao, ls_Ramal)
Constructor CProtocolo(ln_DDD, ln_Telefone)
m_Data = ls_Data
m_Hora = ls_Hora
m_Tronco = ls_Tronco
m_Duracao = ls_Duracao
m_Ramal = ls_Ramal


Procedure Constructor(TextoSocket is string)
dbgAssert(TextoSocket <> "", "Construtor Vazio")

ls_Argumentos is string = Replace(ExtractString(TextoSocket,3,"|"), "}", "")

dbgAssert(StringCount(ls_Argumentos,",",IgnoreCase) = 6)

m_Data = ExtractString(ls_Argumentos, 1, ",")
m_Hora = ExtractString(ls_Argumentos, 2, ",")
m_Tronco = ExtractString(ls_Argumentos, 3, ",")
m_Duracao = ExtractString(ls_Argumentos,4, ",")
m_Ramal = ExtractString(ls_Argumentos, 5, ",")
m_DDD = ExtractString(ls_Argumentos, 6, ",")
AlimentaDDDTelefone(ExtractString(ls_Argumentos, 7, ","))


Procedure Destructor()


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.blogspot.com.br/
Membre enregistré
3 657 messages
Popularité : +175 (223 votes)
Posté le 10 février 2016 - 13:46
CLASSE CFimChamadaSimples

CFimChamadaSimples is a Class
inherits from CProtocolo
m_Duracao is string
m_GravacaoPath is string
END

//Utilizado para enviar a duração e o caminho onde a gravação está armazenada, no final da ligação.
//
//Formato:
//{ - Caracter Inicial
//599|003| - Cabeçalho
//Telefone - Telefone identificado
//, - Separador
//Duração - Duração total da ligação (hh:nn:ss)
//, - Separador
//Gravação - Caminho onde a gravação foi armazenada
//} - Caracter Final
//
//Exemplo:
//Visys_FimChamadaSimples
// 12345678901234567890
//TextoSocket = "{599|003|,04196755346,00:00:00,}"
//TextoSocket = "{599|003|4730361010, 00:12:32,\\Servidor\Gravação\3406_20130923_153231_04730361010.wav}"



Procedure Constructor(ln_DDD, ln_Telefone are int,ls_Duracao, ls_GravacaoPath are strings)
Constructor CProtocolo(ln_DDD, ln_Telefone)
m_Duracao = ls_Duracao
m_GravacaoPath = ls_GravacaoPath



Procedure Constructor(TextoSocket is string)
dbgAssert(TextoSocket <> "", "Construtor Vazio")

ls_Argumentos is string = Replace(ExtractString(TextoSocket,3,"|"), "}", "")

dbgAssert(StringCount(ls_Argumentos,",",IgnoreCase) = 2 OR StringCount(ls_Argumentos,",",IgnoreCase) = 3)

IF StringCount(ls_Argumentos,",",IgnoreCase) = 2 THEN
AlimentaDDDTelefone(ExtractString(ls_Argumentos, 1, ",")) // Telefone + DDD
m_Duracao = ExtractString(ls_Argumentos, 2, ",")
m_GravacaoPath = ExtractString(ls_Argumentos, 3, ",")
ELSE IF StringCount(ls_Argumentos,",",IgnoreCase) = 3
AlimentaDDDTelefone(ExtractString(ls_Argumentos, 2, ",")) // Telefone + DDD
m_Duracao = ExtractString(ls_Argumentos, 3, ",")
m_GravacaoPath = ExtractString(ls_Argumentos, 4, ",")
END



Procedure Destructor()


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.blogspot.com.br/
Membre enregistré
3 657 messages
Popularité : +175 (223 votes)
Posté le 10 février 2016 - 13:48
CLASSE CIniciarChamadaAvancada

CIniciarChamadaAvancada is a Class
inherits from CProtocolo
m_Data is string
m_Hora is string
m_Tronco is string
m_Ramal is string
END

//Formato:
//{ - Caracter Inicial
//599|010| - Cabeçalho
//Data - Data da ligação(dd/mm/yyyy)
//, - Separador
//Hora - Hora inicial da ligação(hh/mm/ss)
//, - Separador
//Tronco - Tronco utilizado
//, - Separador
//Ramal - Ramal utilizado
//, - Separador
//DDD - DDD identificado
//, - Separador
//Telefone - Telefone identificado
//{ - Caracter Final
//
//Exemplo:
//Visys_IniciarChamadaAvancada
//TextoSocket = "{599|010|14/03/2014,11:21:45,99,8692,047,04730361010}"



Procedure Constructor(ln_DDD, ln_Telefone are int, ls_Data, ls_Hora, ls_Tronco, ls_Ramal are strings)
Constructor CProtocolo(ln_DDD, ln_Telefone)
m_Data = ls_Data
m_Hora = ls_Hora
m_Tronco = ls_Tronco
m_Ramal = ls_Ramal



Procedure Constructor(TextoSocket is string)
dbgAssert(TextoSocket <> "", "Construtor Vazio")

ls_Argumentos is string = Replace(ExtractString(TextoSocket,3,"|"), "}", "")

dbgAssert(StringCount(ls_Argumentos,",",IgnoreCase) = 5)

m_Data = ExtractString(ls_Argumentos, 1, ",")
m_Hora = ExtractString(ls_Argumentos, 2, ",")
m_Tronco = ExtractString(ls_Argumentos, 3, ",")
m_Ramal = ExtractString(ls_Argumentos, 4, ",")
m_DDD = ExtractString(ls_Argumentos, 5, ",")
AlimentaDDDTelefone(ExtractString(ls_Argumentos, 6, ","))



Procedure Destructor()


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.blogspot.com.br/
Membre enregistré
3 657 messages
Popularité : +175 (223 votes)
Posté le 10 février 2016 - 13:50
CLASSE CIniciarChamadaSimples

CIniciarChamadaSimples is a Class
inherits from CProtocolo
END

//Utilizado para efetuar uma chamada interna ou externa.
//
//Formato:
//{ - Caracter Inicial
//598|001| - Cabeçalho
//Numero - Número a ser discado. (Incluir a rota quando ligação externa)
//} - Caracter Final
//
//Exemplo:
//Visys_IniciarChamadaSimples
//TextoSocket = "{598|001|030361010}"



Procedure Constructor(ln_DDD, ln_Telefone are int)
Constructor CProtocolo(ln_DDD, ln_Telefone)



Procedure Constructor(TextoSocket is string)
dbgAssert(TextoSocket <> "", "Construtor Vazio")
dbgAssert(StringCount(TextoSocket,",",IgnoreCase) = 0)

AlimentaDDDTelefone(Replace(ExtractString(TextoSocket,3,"|"), "}", ""))



Procedure Destructor()


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.blogspot.com.br/
Membre enregistré
3 657 messages
Popularité : +175 (223 votes)
Posté le 10 février 2016 - 13:59
CLASSE CKeyboardKeys

CKeyboardKeys is Class

// Constants corresponding to "system" keys
CONSTANT
// Constants for specific keys
cnNumLock = 0x90
cnScrollLock = 0x91
cnCapsLock = 0x14
cnAltGr = 0xA5

// Names given to the keys
csTABKey = “<TAB>
csEnterKey = “<INPUT>
csNumLockKey = “<NUM_LOCK>
csCapsLockKey = “<CAPS_LOCK>
csScrollLockKey = “<SCROLL_LOCK>
csPauseKey = “<PAUSE>
csWindowsKey1 = “<WINDOWS_1>
csWindowsKey2 = “<WINDOWS_2>
csAltGrKey = “<ALT_GR>
csRightClickKey = “<RIGHT_CLICK>
csEscKey = “<ESC>
csSpaceKey = “<SPACE>
csDeleteKey = “<DELETE>
csControlKey = “<CTRL>
csShiftKey = “<SHIFT>

csLeftArrowKey = “<LEFT_ARROW>
csRightArrowKey = “<RIGHT_ARROW>
csUpArrowKey = “<UP_ARROW>
csDownArrowKey = “<DOWN_ARROW>

csInsertKey = “<INSERT>
csHomeKey = “<HOME>
csPageUpKey = “<PAGE_UP>
csPageDownKey = “<PAGE_DOWN>
csDelKey = “<DEL>
csEndKey = “<END>

csDivisionKey = “</>
csMultiplicationKey = “<*>
csMinusKey = “<->
csPlusKey = “<+>

csAmpersandKey = “&
csEAcuteAccentKey = “é”
csQuotationMarkKey = “""
csQuoteKey = “'
csLeftParenthesisKey = “(
csMinusKeyBis = “-
csEGraveAccentKey = “è”
csUnderscoreKey =“_”
csCCedillaKey = “ç”
csAAcuteAccentKey = “à”
csRightParenthesisKey = “)
csEqualKey = “=
csPlusKeyBis = “+
csATKey = “@
csSquareKey = “²
csDegreeKey = “°
csDieresisKey = Ҭ
csPoundKey = “£
csDollarKey = “$”
csAsteriskKey = “¤
csPercentageKey = “%
csUAccentKey = “ù”

csTildeKey = “~
csNumberSignKey = “#”
csLeftCurlyBraceKey = “{
csLeftSquareBracketKey = “[
csMoreKey = “|
csApostropheKey = “`
csBackslashKey = “\
csCircumflexKey = “^
csCommercialAtKey = “@
csRightSquareBracketKey = “]
csRightCurlyBraceKey = “}

csGreaterThanKey = “>
csLessThanKey = “<
csCommaKey = “<,>
csQuestionMarkKey = “<?>
csSemicolonKey = “<;>
csPeriodKey = “<.>
csSlashKey = “</>
csColonKey = “<:>
csExclamationMarkKey = “<!>
csChapterKey = “<§>
csMuKey = “<µ>
csMultiplicationKeyBis = “<*>


csUnknownKey = “<UNKNOWN>
csInactiveKey = “<DISABLED>
END

END


Procedure Constructor()



Procedure Destructor()



Procedure sReturnKey(nKeyNum=_EVE.wParam)

// Alphanumeric keys
IF nKeyNum >=65 AND nKeyNum <=90
IF KeyPressed(kpShift,True) OR :bActiveKey(::cnCapsLock)
// Uppercase characters
RESULT Charact(Asc(“A”)+nKeyNum-65)
ELSE
// Lowercase Characters
RESULT Charact(Asc(“a”)+nKeyNum-65)
END

END

// Keys on the numeric keypad
IF (nKeyNum >=96 AND nKeyNum <=105) OR nKeyNum = 110
RESULT :_GetNumericKey(nKeyNum)
END

// Function keys (F1-F12)
IF nKeyNum >= 112 AND nKeyNum <= 123
RESULT “F”+(nKeyNum+1-112)
END

// Numeric keys on keyboard
IF nKeyNum >=48 AND nKeyNum <=57
// Depends on ALT-GR and SHIFT!
RESULT :_GetNumericKeyUp(nKeyNum)

END

// cursors
IF nKeyNum>=37 AND nKeyNum<=40
IF nKeyNum = 37 RESULT ::csLeftArrowKey
IF nKeyNum = 38 RESULT ::csUpArrowKey
IF nKeyNum = 39 RESULT ::csRightArrowKey
IF nKeyNum = 40 RESULT ::csDownArrowKey
END





sKey is string
sKey = :_GetPunctuationKey(nKeyNum)
IF sKey <> “
RESULT sKey
END



sKey = :_GetSpecialKey(nKeyNum)
IF sKey <> “
RESULT sKey
END


// Unrecognized key
RESULT ::csUnknownKey



Procedure bActiveKey(nValSpecificKey is int)

RESULT BinaryAND(API(user32,GetKeyState,nValSpecificKey),1)



// Summary: <specify the action of the procedure>
// Syntax:
//[ <Result> = ] _GetNumericKey (<nKeyNum>)
//
// Parameters:
// nKeyNum: <specify the role of nKeyNum>
// Return value:
// string: // None
//// Example:
// Indicate an example.
//
Procedure _GetNumericKey(nKeyNum)

// Depends on the status of Num Lock
IF :bActiveKey(::cnNumLock) = True
// Num Lock is turned on
IF nKeyNum = 110 RESULT ::csPeriodKey
RESULT Charact(Asc(0)+nKeyNum-96)
ELSE
// Num Lock is turned off
IF nKeyNum = 96 RESULT ::csInsertKey
IF nKeyNum = 97 RESULT ::csEndKey
IF nKeyNum = 98 RESULT ::csDownArrowKey
IF nKeyNum = 99 RESULT ::csPageDownKey
IF nKeyNum = 100 RESULT ::csLeftArrowKey
IF nKeyNum = 101 RESULT ::csInactiveKey
IF nKeyNum = 102 RESULT ::csRightArrowKey
IF nKeyNum = 103 RESULT ::csHomeKey
IF nKeyNum = 104 RESULT ::csUpArrowKey
IF nKeyNum = 105 RESULT ::csPageUpKey
IF nKeyNum = 110 RESULT ::csDelKey
END


RESULT



// Summary: <specify the action of the procedure>
// Syntax:
//[ <Result> = ] _GetNumericKeyUp (<nKeyNum>)
//
// Parameters:
// nKeyNum: <specify the role of nKeyNum>
// Return value:
// string: // None
//// Example:
// Indicate an example.
//
Procedure _GetNumericKeyUp(nKeyNum)

IF KeyPressed(::cnAltGr,True)
IF nKeyNum = 48 RESULT ::csCommercialAtKey
IF nKeyNum = 49 RESULT ::csInactiveKey
IF nKeyNum = 50 RESULT ::csTildeKey
IF nKeyNum = 51 RESULT ::csNumberSignKey
IF nKeyNum = 52 RESULT ::csLeftCurlyBraceKey
IF nKeyNum = 53 RESULT ::csLeftSquareBracketKey
IF nKeyNum = 54 RESULT ::csMoreKey
IF nKeyNum = 55 RESULT ::csApostropheKey
IF nKeyNum = 56 RESULT ::csBackslashKey
IF nKeyNum = 57 RESULT ::csCircumflexKey
END


IF KeyPressed(kpShift,True) OR :bActiveKey(::cnCapsLock)
RESULT Charact(Asc(0)+nKeyNum-48)+_BIS
END

IF nKeyNum = 48 RESULT ::csAAcuteAccentKey
IF nKeyNum = 49 RESULT ::csAmpersandKey
IF nKeyNum = 50 RESULT ::csEAcuteAccentKey
IF nKeyNum = 51 RESULT ::csQuotationMarkKey
IF nKeyNum = 52 RESULT ::csQuoteKey
IF nKeyNum = 53 RESULT ::csLeftParenthesisKey
IF nKeyNum = 54 RESULT ::csMinusKeyBis
IF nKeyNum = 55 RESULT ::csEGraveAccentKey
IF nKeyNum = 56 RESULT ::csUnderscoreKey
IF nKeyNum = 57 RESULT ::csCCedillaKey


RESULT



// Summary: <specify the action of the procedure>
// Syntax:
//[ <Result> = ] _GetPunctuationKey (<nKeyNum>)
//
// Parameters:
// nKeyNum: <specify the role of nKeyNum>
// Return value:
// string: // None
//// Example:
// Indicate an example.
//
Procedure _GetPunctuationKey(nKeyNum)


// Keys , and?
IF nKeyNum = 188
// Shift key
IF KeyPressed(kpShift,True) OR :bActiveKey(::cnCapsLock)
RESULT ::csQuestionMarkKey
ELSE
RESULT ::csCommaKey
END
END

// Keys; and.
IF nKeyNum = 190
// Shift key
IF KeyPressed(kpShift,True) OR :bActiveKey(::cnCapsLock)
RESULT ::csPeriodKey
ELSE
RESULT ::csSemicolonKey
END
END

// Keys / and:
IF nKeyNum = 191
// Shift key
IF KeyPressed(kpShift,True) OR :bActiveKey(::cnCapsLock)
RESULT ::csSlashKey
ELSE
RESULT ::csColonKey
END
END
// Keys < and >
IF nKeyNum = 226
// Shift key
IF KeyPressed(kpShift,True) OR :bActiveKey(::cnCapsLock)
RESULT ::csGreaterThanKey
ELSE
RESULT ::csLessThanKey
END
END

// Key ° ) ]
IF nKeyNum = 219
IF KeyPressed(::cnAltGr,True)
RESULT ::csRightSquareBracketKey
END

// Shift key
IF KeyPressed(kpShift,True) OR :bActiveKey(::cnCapsLock)
RESULT ::csDegreeKey
ELSE
RESULT ::csRightParenthesisKey
END
END

// Key + = }
IF nKeyNum = 187
IF KeyPressed(::cnAltGr,True)
RESULT ::csRightCurlyBraceKey
END

// Shift key
IF KeyPressed(kpShift,True) OR :bActiveKey(::cnCapsLock)
RESULT ::csPlusKeyBis
ELSE
RESULT ::csEqualKey
END
END

// Key ¨^
IF nKeyNum = 221
// Shift key
IF KeyPressed(kpShift,True) OR :bActiveKey(::cnCapsLock)
RESULT ::csDieresisKey
ELSE
RESULT ::csCircumflexKey
END
END

// Key £ $ ¤
IF nKeyNum = 186
IF KeyPressed(::cnAltGr,True)
RESULT ::csAsteriskKey
END

// Shift key
IF KeyPressed(kpShift,True) OR :bActiveKey(::cnCapsLock)
RESULT ::csPoundKey
ELSE
RESULT ::csDollarKey
END
END

// Keys % and ù
IF nKeyNum = 192
// Shift key
IF KeyPressed(kpShift,True) OR :bActiveKey(::cnCapsLock)
RESULT ::csPercentageKey
ELSE
RESULT ::csUAccentKey
END
END

// Key µ *
IF nKeyNum = 220
// Shift key
IF KeyPressed(kpShift,True) OR :bActiveKey(::cnCapsLock)
RESULT ::csMuKey
ELSE
RESULT ::csMultiplicationKeyBis
END
END

// Key §!
IF nKeyNum = 223
// Shift key
IF KeyPressed(kpShift,True) OR :bActiveKey(::cnCapsLock)
RESULT ::csChapterKey
ELSE
RESULT ::csExclamationMarkKey
END
END

RESULT



// Summary: <specify the action of the procedure>
// Syntax:
//[ <Result> = ] _GetSpecialKey (<nKeyNum>)
//
// Parameters:
// nKeyNum: <specify the role of nKeyNum>
// Return value:
// string: // None
//// Example:
// Indicate an example.
//
Procedure _GetSpecialKey(nKeyNum)


// Other keys
IF nKeyNum = 33 RESULT ::csPageUpKey
IF nKeyNum = 34 RESULT ::csPageDownKey
IF nKeyNum = 35 RESULT ::csEndKey
IF nKeyNum = 36 RESULT ::csHomeKey
IF nKeyNum = 45 RESULT ::csInsertKey
IF nKeyNum = 46 RESULT ::csDelKey
IF nKeyNum = 144 RESULT ::csNumLockKey

IF nKeyNum = 8 RESULT ::csDeleteKey
IF nKeyNum = 9 RESULT ::csTABKey
IF nKeyNum = 13 RESULT ::csEnterKey
IF nKeyNum = 16 RESULT ::csShiftKey
IF nKeyNum = 17 RESULT ::csControlKey
IF nKeyNum = 18 RESULT ::csAltGrKey
IF nKeyNum = 19 RESULT ::csPauseKey
IF nKeyNum = 20 RESULT ::csCapsLockKey
IF nKeyNum = 27 RESULT ::csEscKey
IF nKeyNum = 32 RESULT ::csSpaceKey
IF nKeyNum = 91 RESULT ::csWindowsKey1
IF nKeyNum = 92 RESULT ::csWindowsKey2
IF nKeyNum = 93 RESULT ::csRightClickKey
IF nKeyNum = 222 RESULT ::csSquareKey

IF nKeyNum = 106 RESULT ::csMultiplicationKey
IF nKeyNum = 107 RESULT ::csPlusKey
IF nKeyNum = 109 RESULT ::csMinusKey
IF nKeyNum = 111 RESULT ::csDivisionKey
IF nKeyNum = 144 RESULT ::csNumLockKey
IF nKeyNum = 145 RESULT ::csScrollLockKey

RESULT


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.blogspot.com.br/
Membre enregistré
3 657 messages
Popularité : +175 (223 votes)
Posté le 10 février 2016 - 14:39
CLASSE CNovaLigacao

CNovaLigacao is a Class
inherits from CProtocolo
m_Atividade is string
m_Cidade is string
END

//Enviado sempre que o operador recebe uma ligação.
//
//Formato:
//{ - Caracter Inicial
//599|001| - Cabeçalho
//Atividade - Atividade que esta recebendo a ligação
//, - Separador
//Telefone - Telefone identificado
//, - Separador
//Cidade - Cidade identificada através do número de telefone
//} - Caracter Final
//EX
//Visys_NovaLigacao
//TextoSocket = "{599|001|Atendimento Representantes,4730361010,BLUMENAU}"



Procedure Constructor(ln_DDD, ln_Telefone are int, ls_Atividade is string, ls_Cidade is string)
Constructor CProtocolo(ln_DDD, ln_Telefone)
m_Atividade = ls_Atividade
m_Cidade = ls_Cidade



Procedure Constructor(TextoSocket is string)
dbgAssert(TextoSocket <> "", "Construtor Vazio")

ls_Argumentos is string = Replace(ExtractString(TextoSocket,3,"|"), "}", "")

dbgAssert(StringCount(ls_Argumentos,",",IgnoreCase) = 2)

m_Atividade = ExtractString(ls_Argumentos, 1, ",")
AlimentaDDDTelefone(ExtractString(ls_Argumentos, 2, ",")) // Telefone + DDD
m_Cidade = ExtractString(ls_Argumentos, 3, ",")



Procedure Destructor()


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.blogspot.com.br/
Membre enregistré
3 657 messages
Popularité : +175 (223 votes)
Posté le 10 février 2016 - 14:42
CLASSE CProtocolo

CProtocolo is a Class
m_DDD, m_Telefone are int
END



Procedure Constructor(DDD, Telefone are int)
m_DDD = DDD
m_Telefone = Telefone



Procedure Constructor()



Procedure Destructor()



Procedure PROTECTED AlimentaDDDTelefone(Telefone is string)
DDD is string
Telefone = Replace(NoSpace(NoAccent(Telefone)),[" ",",","-"],"")

IF Length(Telefone) > 9
//12345678901
//04199491800
IF Telefone[[1]] = "0" AND Telefone <> ""
DDD = Telefone[[2 on 2]]
Telefone = Telefone[[4 TO]]
//1234567890
//4199491800
ELSE IF Telefone[[1]] <> "0" AND Telefone <> ""
DDD = Telefone[[TO 2]]
Telefone = Telefone[[3 TO]]
END

IF Val(DDD) > 0 AND Val(Telefone) > 0 AND Length(DDD) >=2 AND Length(Telefone) >= 8
m_Telefone = Val(Telefone)
m_DDD = Val(DDD)
END
ELSE
m_Telefone = Val(Telefone)
END


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.blogspot.com.br/
Membre enregistré
3 657 messages
Popularité : +175 (223 votes)
Posté le 10 février 2016 - 14:43
PROCEDURES GLOBAIS

Procedure Visys_AValidacaoString(TextoSocket,DebugSN)

TextoSocket += "}"

IF DebugSN = "S"
ToastDisplay("Avalia String da Central Telefônica.",toastShort,vaTop,haCenter)
END

// Se a string for vazia ou não há {
IF TextoSocket = "" OR NOT (TextoSocket [=] "{") THEN
RESULT False
END

Cabecalho is string = ""

dbgAssert(StringCount(TextoSocket,"{",IgnoreCase) = 1, "String não contem um {")

IF StringCount(TextoSocket,"{",IgnoreCase) = 1 AND StringCount(TextoSocket,"}",IgnoreCase) = 1
//EX.:
//{599|001|Atendimento Representantes,4730361010,BLUMENAU}
IF StringCount(TextoSocket,"|",IgnoreCase) > 1 AND Length(TextoSocket) >= 12
//{599|001|...} = Screen Popup = Tela Popup
//{599|010|...} = Begin Call Advanced = Iniciar Chamada avançada
//{599|030|...} = End Call Advanced = Fim da Chamada avançada
//{598|001|...} = Make Call = Iniciar Chamada simples
//{599|003|...} = End Call = Fim da Chamada simples

//só tirou do gacho e nao discou pra ninguem
IF TextoSocket = "{599|002|,,}" OR TextoSocket = "{599|003|,,00:00:00,}"
TextoSocket = ""
RESULT False
ELSE
Cabecalho = Middle(TextoSocket,2,8)
END

//Debug
IF DebugSN = "S"
//WIN_0002_CallCenter.EDT_Informacao_Interna += "CABECALHO: " +Cabecalho + CRLF
WIN_0002_CallCenter.EDT_Obs_Inf_Interna += "TEXTOSOCKET: " +TextoSocket + CRLF
END

resultado is dynamic CProtocolo

SWITCH Cabecalho
CASE "599|001|", "599|002|":
resultado = new CNovaLigacao(TextoSocket)
CASE "599|010|":
resultado = new CIniciarChamadaAvancada(TextoSocket)
CASE "599|030|":
resultado = new CFimChamadaAvancada(TextoSocket)
CASE "598|001|":
resultado = new CIniciarChamadaSimples(TextoSocket)
CASE "599|003|":
resultado = new CFimChamadaSimples(TextoSocket)
END

dbgAssert(resultado <> Null, "Resultado não esperado")

IF resultado is CFimChamadaSimples THEN
lcl_Chm is CFimChamadaSimples <- resultado
//lcl_Chm.m_GravacaoPath
END

IF resultado is CNovaLigacao THEN
lcl_ChmP is CNovaLigacao <- resultado
//lcl_ChmP.m_Atividade
END

//Interpreta string
IF resultado <> Null AND (resultado.m_DDD > 0 AND resultado.m_Telefone > 0)
ExecuteMainThread(WIN_0002_CallCenter.CentralTelefonica,resultado, "S")
ToastDisplay("Retorno: "+resultado.m_DDD +" "+ resultado.m_Telefone, toastShort, vaTop,haCenter)
WIN_0002_CallCenter.EDT_Obs_Inf_Interna += "Retorno>>>>>: "+resultado.m_DDD +" "+ resultado.m_Telefone + CRLF
END
RESULT True
ELSE
IF DebugSN = "S"
ToastDisplay("String fora do padrão",toastShort,vaTop,haCenter)
END
END
ELSE
IF DebugSN = "S"
ToastDisplay("Mais de uma string de socket no retorno",toastShort,vaTop,haCenter)
END
END

RESULT False


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.blogspot.com.br/
Membre enregistré
3 657 messages
Popularité : +175 (223 votes)
Posté le 10 février 2016 - 14:44
Procedure Visys_Socket_Read(DebugSN)

IF gb_SocketStart = True
IF DebugSN = "S"
ToastDisplay("Socket Read",toastShort,vaTop,haCenter)
END

//ThreadPause(300)

RetornoSocket is string = ""

WHILE SocketExist("VISYS") = True AND gb_SocketStart = True
RetornoSocket = SocketRead("VISYS", True)

IF RetornoSocket <> "" AND CT_InicializarAtendimento = True
RetornoSocket = NoSpace(RetornoSocket)
RetornoSocket = NoAccent(RetornoSocket)
RetornoSocket = Replace(RetornoSocket,CRLF,"")
RetornoSocket = Replace(RetornoSocket,CR,"")

Visys_AValidacaoString(RetornoSocket,DebugSN)

RetornoSocket = ""

END
END
END


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.blogspot.com.br/
Membre enregistré
3 657 messages
Popularité : +175 (223 votes)
Posté le 10 février 2016 - 14:44
Procedure Visys_Socket_Start(DebugSN)

Socket_IP is string = ""
Socket_Porta is int = 0
Socket_TimeOut is int = 0

IF DebugSN = "S"
ToastDisplay("Inicializando Conexão com o Socket TCP/IP",toastShort,vaTop,haCenter)
END

PathFile_INI is string = fCurrentDir(fCurrentDrive()) +"\Nagyro.ini"

IF fFileExist(PathFile_INI) = True

//AMBIENTE (PRODUCAO/TESTE)
Modo is string = INIRead("Socket", "Socket_Ambiente", "", PathFile_INI)
IF ErrorOccurred = True
Socket_IP = INIRead("Socket", "Socket_IP", "", PathFile_INI)
INIWrite("Socket", "Socket_Ambiente", "TESTE", PathFile_INI)
INIWrite("Socket", "Socket_IP", Socket_IP, PathFile_INI)
ELSE
IF Modo = "PRODUCAO"
Socket_IP = NetIPAddress()
INIWrite("Socket", "Socket_Ambiente", "PRODUCAO", PathFile_INI)
INIWrite("Socket", "Socket_IP", Socket_IP, PathFile_INI)
ELSE
Socket_IP = INIRead("Socket", "Socket_IP", "", PathFile_INI)
INIWrite("Socket", "Socket_Ambiente", "TESTE", PathFile_INI)
INIWrite("Socket", "Socket_IP", Socket_IP, PathFile_INI)
END
END

//LEITURA DO Socket_IP DO ARQUIVO INI
Socket_IP = INIRead("Socket", "Socket_IP", "", PathFile_INI)
IF ErrorOccurred = True OR Socket_IP = ""
Socket_IP = "192.168.1.20"
INIWrite("Socket", "Socket_IP", Socket_IP, PathFile_INI)
END

//LEITURA DO Socket_Porta DO ARQUIVO INI
Socket_Porta = INIRead("Socket", "Socket_Porta", "", PathFile_INI)
IF ErrorOccurred = True OR Socket_Porta = 0
Socket_Porta = 9965
INIWrite("Socket", "Socket_Porta", Socket_Porta, PathFile_INI)
END

//LEITURA DO Socket_TimeOut DO ARQUIVO INI
Socket_TimeOut = INIRead("Socket", "Socket_TimeOut", "", PathFile_INI)
IF ErrorOccurred = True OR Socket_TimeOut = 0
Socket_TimeOut = 5000
INIWrite("Socket", "Socket_TimeOut", Socket_TimeOut, PathFile_INI)
END

//CONEXAO COM O SOCKET - INICIO DO PROCEDIMENTO DE LEITURA DO SOCKET
IF DebugSN = "S"
ToastDisplay("Conexão Socket Porta: "+ Socket_Porta +" IP: "+ Socket_IP +" Time Out: "+ Socket_TimeOut,toastShort,vaTop,haCenter)
END

IF Socket_Porta > 0 AND Socket_IP <> "" AND Socket_TimeOut > 0
IF SocketExist("VISYS") = False
IF SocketConnect("VISYS",Socket_Porta,Socket_IP,Socket_TimeOut) = True
IF SocketChangeTransmissionMode("VISYS",SocketEndTagBuffer,"}") = True
IF DebugSN = "S"
ToastDisplay("Conexão com Sucesso com a Central Telefônica!!!!",toastShort,vaTop,haCenter)
END

gb_SocketStart = True

ELSE
gb_SocketStart = False

IF DebugSN = "S"
ToastDisplay("ERRO 02 ao tentar conetar com a Central Telefônica!!!!",toastShort,vaTop,haCenter)
END
END
ELSE

gb_SocketStart = False

IF DebugSN = "S"
ToastDisplay("ERRO 03 de Conexão com a Central Telefônica.",toastShort,vaTop,haCenter)
END
END
END
ELSE
gb_SocketStart = False
IF DebugSN = "S"
ToastDisplay("ERRO 04 Informações incompletas!!!!",toastShort,vaTop,haCenter)
END
END
ELSE
gb_SocketStart = False
IF DebugSN = "S"
ToastDisplay("ERRO 05 Path do arquivo nagyro.ini nao existente!!!!",toastShort,vaTop,haCenter)
END
END

RESULT(gb_SocketStart)


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.blogspot.com.br/
Membre enregistré
3 657 messages
Popularité : +175 (223 votes)
Posté le 10 février 2016 - 14:47
INICIAR A CLASSE NO OPEN WINDOW DA JANELA QUE TEM O CAMPO DDD E TELEFONE
QUE SERÁ IDENTIFICADO PELA CENTRAL TELEFONICA PANASONIC E SISTEMA VISYS

SocketStartThread("N") //CENTRAL TELEFONICA


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.blogspot.com.br/
Membre enregistré
3 657 messages
Popularité : +175 (223 votes)
Posté le 10 février 2016 - 14:48
AO SAIR DA TELA

SocketConnectedTimerList_End()


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.blogspot.com.br/
Membre enregistré
3 657 messages
Popularité : +175 (223 votes)
Posté le 10 février 2016 - 14:49
PROCEDURE LOCAL

Procedure SocketStartThread(DebugSN)

IF Visys_Socket_Start(DebugSN) = True

gbSocketOk = True
CT_InicializarAtendimento = True
IF DebugSN = "S"
ToastDisplay("Conexão com o Socket TCP/IP: OK",toastShort,vaTop,haCenter)
END
//Central telefônica
IF gb_SocketStart = True
IMG_Status = IMG_Verde
ELSE
IMG_Status = IMG_Vermelho
END

SocketConnectedTimerList(DebugSN)

ELSE

gbSocketOk = False
IF DebugSN = "S"
ToastDisplay("ERRO 01: Não foi possivel inicializar a Conexão com o Socket TCP/IP",toastShort,vaTop,haCenter)
END

END


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.blogspot.com.br/
Membre enregistré
3 657 messages
Popularité : +175 (223 votes)
Posté le 10 février 2016 - 14:50
PROCEDURE LOCAL

Procedure SocketConnectedTimerList(DebugSN)

//Nome da Thread
sThreadName is string = "TaskSocketNagyro"+Now()

// Fill the list of connected users
ThreadExecute(sThreadName,threadNormal,Visys_Socket_Read,DebugSN) //passagem de parametro depois da virgula

// This thread does not have priority
ThreadPriority(sThreadName,PriorityNormal)


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.blogspot.com.br/
Membre enregistré
3 657 messages
Popularité : +175 (223 votes)
Posté le 10 février 2016 - 14:51
PROCEDURE LOCAL

Procedure SocketConnectedTimerList_End()

// end of timer for refreshing the connected users
EndTimerSys(gnIdTimer)

gb_SocketStart = False

CT_InicializarAtendimento = False

// Stop the threads
ThreadStop("TaskSocketNagyro",500)
ThreadStop("TaskSocketNa


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.blogspot.com.br/
Membre enregistré
3 657 messages
Popularité : +175 (223 votes)
Posté le 10 février 2016 - 14:53
PROCEDURE LOCAL

Procedure SocketStartThread(DebugSN)

IF Visys_Socket_Start(DebugSN) = True

gbSocketOk = True
CT_InicializarAtendimento = True
IF DebugSN = "S"
ToastDisplay("Conexão com o Socket TCP/IP: OK",toastShort,vaTop,haCenter)
END
//Central telefônica
IF gb_SocketStart = True
IMG_Status = IMG_Verde
ELSE
IMG_Status = IMG_Vermelho
END

SocketConnectedTimerList(DebugSN)

ELSE

gbSocketOk = False
IF DebugSN = "S"
ToastDisplay("ERRO 01: Não foi possivel inicializar a Conexão com o Socket TCP/IP",toastShort,vaTop,haCenter)
END

END


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.blogspot.com.br/
Membre enregistré
3 657 messages
Popularité : +175 (223 votes)
Posté le 10 février 2016 - 14:58








--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.blogspot.com.br/
Membre enregistré
3 657 messages
Popularité : +175 (223 votes)
Posté le 10 février 2016 - 15:04
PROCEDURE DE LEITURA DO ARQUIVO INI PARA CONFIGURAÇÃO DO SOCKET

Procedure ReadIni()

Socket_IP,Modo is string = ""
Socket_Porta is int = 0
Socket_TimeOut is int = 0

PathFile_INI is string = fCurrentDir(fCurrentDrive()) +"\CENTRALTELEFONICA.INI"

IF fFileExist(PathFile_INI) = True

gsTitulo = "SISEMA CENTRAL TELEFONICA"
gsTitulo += " - Servidor: "+ INIRead("CENTRALTELEFONICA", "Server", "", PathFile_INI)
IF ErrorOccurred = True
Error()
END

gsTitulo += " - Base de Dados: "+ INIRead("CENTRALTELEFONICA", "BD", "", PathFile_INI)
IF ErrorOccurred = True
Error()
END

gsTitulo += " - Usuário: "+ INIRead("CENTRALTELEFONICA", "User", "", PathFile_INI)
IF ErrorOccurred = True
Error()
END

gsTitulo += " - Atendimentos: "

STC_Desc = gsTitulo

Modo = INIRead("Socket", "Socket_Ambiente", "", PathFile_INI)
IF ErrorOccurred = True
gw_IP4 = INIRead("Socket", "Socket_IP", "", PathFile_INI)
INIWrite("Socket", "Socket_Ambiente", "TESTE", PathFile_INI)
INIWrite("Socket", "Socket_IP", gw_IP4, PathFile_INI)
ELSE
IF Modo = "PRODUCAO"
gw_IP4 = NetIPAddress()
INIWrite("Socket", "Socket_Ambiente", "PRODUCAO", PathFile_INI)
INIWrite("Socket", "Socket_IP", gw_IP4, PathFile_INI)
ELSE
gw_IP4 = INIRead("Socket", "Socket_IP", "", PathFile_INI)
INIWrite("Socket", "Socket_Ambiente", "TESTE", PathFile_INI)
INIWrite("Socket", "Socket_IP", gw_IP4, PathFile_INI)
END
END


//LEITURA DO Socket_IP DO ARQUIVO INI
Socket_IP = INIRead("Socket", "Socket_IP", "", PathFile_INI)
IF ErrorOccurred = True OR Socket_IP = ""
Socket_IP = "192.168.1.110"
INIWrite("Socket", "Socket_IP", Socket_IP, PathFile_INI)
END

//LEITURA DO Socket_Porta DO ARQUIVO INI
Socket_Porta = INIRead("Socket", "Socket_Porta", "", PathFile_INI)
IF ErrorOccurred = True OR Socket_Porta = 0
Socket_Porta = 9965
INIWrite("Socket", "Socket_Porta", Socket_Porta, PathFile_INI)
END

//LEITURA DO Socket_TimeOut DO ARQUIVO INI
Socket_TimeOut = INIRead("Socket", "Socket_TimeOut", "", PathFile_INI)
IF ErrorOccurred = True OR Socket_TimeOut = 0
Socket_TimeOut = 5000
INIWrite("Socket", "Socket_TimeOut", Socket_TimeOut, PathFile_INI)
END

END

//Atualiza Titulo
ok is boolean = Titulo_Principal()
IF ok =False
Nao_Existe() //Mensagem
END

CallCenter(gw_num_call_center)


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.blogspot.com.br/
Membre enregistré
3 657 messages
Popularité : +175 (223 votes)
Posté le 10 février 2016 - 15:09
PROCEDURE QUE RECEBE DA CLASSE O VALOR LIDO VIA SOCKET DA CENTRAL TELEFONICA

Procedure CentralTelefonica(resultado is dynamic CProtocolo, DebugSN)

IF EDT_Telefone_Origem = "" AND
(resultado is CNovaLigacao OR resultado is CIniciarChamadaSimples OR
resultado is CIniciarChamadaAvancada)

//RETORNO DO SOCKET E DAS CLASSES OOP
EDT_DDD = resultado.m_DDD
EDT_Telefone_Origem = resultado.m_Telefone

//Debug
IF DebugSN = "S"
ToastDisplay("Nova Ligacao Numero: "+ EDT_DDD +" - "+ EDT_Telefone_Origem,toastShort,vaTop,haCenter)
WIN_0002_CallCenter.EDT_Obs_Inf_Interna += "RESULTADO: Nova Ligacao Numero: "+ EDT_DDD +" - "+ EDT_Telefone_Origem + CRLF
END

BuscarCliente(EDT_DDD, EDT_Telefone_Origem) // BUSCA NO CADASTRO DOS CLIENTES PELO NUMERO IDENTIFICADO

ELSE IF EDT_Telefone_Origem <> "" AND
(resultado is CFimChamadaSimples OR resultado is CFimChamadaAvancada)

//Debug
IF DebugSN = "S"
ToastDisplay("Fim da Chamada",toastShort,vaTop,haCenter)
WIN_0002_CallCenter.EDT_Obs_Inf_Interna += "RESULTADO: Final da Chamada" + CRLF
ExecuteProcess(BTN_NovoAtendimento,trtClick)
SetFocus(EDT_Telefone_Origem)
END

//Quem finaliza é a telefonista
END


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.blogspot.com.br/
Membre enregistré
3 657 messages
Popularité : +175 (223 votes)
Posté le 10 février 2016 - 15:14
CLASSES









--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.blogspot.com.br/
Membre enregistré
3 657 messages
Popularité : +175 (223 votes)
Posté le 10 février 2016 - 15:15
//Central Telefonica
CT_InicializarAtendimento is boolean
CT_FinalizarAtendimento is boolean

:merci:

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