DEFINITION C_Article_860027506 "Tv2oip"
DEFINITION C_TYPE_NORMAL_str_860027506 "NORMAL"
DEFINITION C_TYPE_FAILOVER_str_860027506 "FAILOVER"
DEFINITION C_TERM_FAILURE_860027506 0x29
DEFINITION C_TERM_NORMAL_860027506 0x10
DEFINITION C_ORIGINATING_str_860027506 "ORIGINATING"
DEFINITION C_TERMINATING_str_860027506 "TERMINATING"
DEFINITION C_ORIGINATING_860027506 0x00
DEFINITION C_TERMINATING_860027506 0x01
DEFINITION C_YES_str_860027506 "YES"
DEFINITION C_NO_str_860027506 "NO"
DEFINITION C_YES_POSTREDIR_str_860027506 "YES-POSTREDIRECTION"
DEFINITION C_SUCCESSFUL_860027506 0x01
DEFINITION C_UNSUCCESSFUL_860027506 0x02
DEFINITION C_NONE_str_860027506 "NONE"
DEFINITION C_LOCAL_str_860027506 "LOCAL"
DEFINITION C_NONE_860027506 0x00
DEFINITION C_LOCAL_860027506 0x01
DEFINITION C_REMOTE_860027506 0x02
DEFINITION C_SUCCESS_860027506 0x01
DEFINITION C_FAILURE_860027506 0x02
REGISTRE ENTIER res_860027506
REGISTRE ENTIER erreur_860027506
REGISTRE ENTIER efficiency_860027506
REGISTRE ENTIER EFFICACE_860027506
REGISTRE ENTIER code_errone_860027506
REGISTRE ENTIER b_PARTIEL_860027506
REGISTRE ENTIER b_FAILOVER_860027506
REGISTRE ENTIER result_860027506
REGISTRE ENTIER ROLE_OF_NODE_860027506
REGISTRE ENTIER EFFICIENCY_860027506
REGISTRE ENTIER longueur_860027506
REGISTRE ENTIER ASReleasingParty_860027506
REGISTRE ENTIER indice_860027506
REGISTRE ENTIER DATE_860027506
REGISTRE ENTIER SessEndTime_860027506
REGISTRE ENTIER DUREE_860027506
REGISTRE POINTEUR pt_indicator_860027506
REGISTRE POINTEUR pt_MESSAGE_860027506
REGISTRE POINTEUR pt_Type_860027506
REGISTRE POINTEUR pt_temp_860027506
REGISTRE POINTEUR pt_gisource_860027506
REGISTRE POINTEUR pt_RoleOfNodeStr_860027506
REGISTRE POINTEUR pt_Termination_860027506
REGISTRE POINTEUR pt_ASIdentifier_860027506
REGISTRE POINTEUR pt_ASReleasingParty_860027506
REGISTRE POINTEUR pt_TranslatedNb_860027506
REGISTRE POINTEUR pt_AnswerIndicat_860027506


#####################################################################
# TRAITEMENT
#
#	Tv2oipAS : DC plateforme SIP
#
##################################################################################################################
#
##################################################################################################################
#	HISTORIQUE
# 
# 16/07/2014 - THE - G4R7 Creation
# 22/08/2014 - THE - G4R7 QC838 [erreur i_strcmp] et utilisation UCASE
# 27/08/2014 - THE - G4R7 QC838 Pb AnswerIndicator
# 07/10/2014 - THE - # GAR8 Lot1 ####
# 30/10/2014 - THE - # G4R8 QC852
# 23/01/2015 - THE - G4R8 QC874 
#
####################################################################################################################

# Constantes


# Variables fonctionnelles


# Initialisation
result_860027506       = 0
ROLE_OF_NODE_860027506 = 0
b_PARTIEL_860027506    = 0
b_FAILOVER_860027506   = 0
EFFICIENCY_860027506   = 0
longueur_860027506     = 0
ASReleasingParty_860027506 = 0
indice_860027506       = 0
DATE_860027506         = 0
SessEndTime_860027506  = 0
DUREE_860027506        = 0
EFFICACE_860027506     = 2


# DECLARATION POINTEUR


# Initialisation
pt_indicator_860027506 = "00000000000000"
pt_MESSAGE_860027506          = "pt_MESSAGE12312312312312312312312312131213121312131213121312131232131213112131123112312131213112312131231123121"
pt_gisource_860027506         = "pt_gisource1234567890pt_gisource1234567890pt_gisource1234567890pt_gisource1234567890pt_gisource1234567890pt_gisource1234567890pt_gisource1234567890pt_gisource1234567890pt_gisource1234567890pt_gisource1234567890pt_gisource1234567890pt_gisource1234567890pt_gisource"
pt_temp_860027506             = "pt_temp34567890121345678901213456789012134567890121345678901213456789012134567890121345678901213456789012134567890121345678901213456789012134567890121345678901213456789012"
pt_Type_860027506             = "pt_Type01234567890123456789"
pt_Termination_860027506      = "pt_Termination12345678901234567890"
pt_RoleOfNodeStr_860027506    = "pt_RoleOfNodeStr456789012345678901234567890123"
pt_ASIdentifier_860027506     = "pt_ASIdentifier6789012345678901234567890123456789012345"
pt_ASReleasingParty_860027506 = "pt_ASReleasingParty789012345678901234567890123456"
pt_TranslatedNb_860027506     = "pt_TranslatedNb890123456789012345678901234567"
pt_AnswerIndicat_860027506    = "pt_AnswerIndicat9876543210"

i_strcpy(pt_indicator_860027506,"")
i_strcpy(pt_MESSAGE_860027506,"")
i_strcpy(pt_gisource_860027506,"")
i_strcpy(pt_temp_860027506,"")
i_strcpy(pt_Type_860027506,"")
i_strcpy(pt_Termination_860027506,"")
i_strcpy(pt_RoleOfNodeStr_860027506,"")
i_strcpy(pt_ASIdentifier_860027506,"")
i_strcpy(pt_ASReleasingParty_860027506,"")
i_strcpy(pt_TranslatedNb_860027506,"")
i_strcpy(pt_AnswerIndicat_860027506,"")


############################################################################################################################################
trace (" __LINE__ #### DEBUT du Pcode de Traitement :__FILE__ #### ")
############################################################################################################################################
erreur_860027506 = i_dup_art_id(g_iartin, g_iartout)


# Lors de larret dun AS, les communications en cours sont basculees (failover) sur un autre AS. 
# LAS en cours darret (primaire) emet un - ou deux en cas de renvoi dappel - DC partiels. 
# LAS qui reprend la communication (secondaire) emettra un ou deux DC ? failover ? en fonction des cas dappels.

# FD/Termination/Termination = C_TERM_FAILURE 
SI i_valid_field_n(g_iartout,$Tv2oip::T3Type)
ALORS
	erreur_860027506 = i_get_art_str(g_iartout, $Tv2oip::TYPE, pt_Type_860027506)
	SI ( ( i_strcmp(UCASE_860027343(pt_Type_860027506), C_TYPE_FAILOVER_str_860027506) != 0 ) && ( i_strcmp(UCASE_860027343(pt_Type_860027506), C_TYPE_NORMAL_str_860027506) != 0 ) )
	ALORS
		#E.TV2OIP.TC3
		i_strcpy(pt_MESSAGE_860027506," Valeur du champ 'Type' incorrecte ")	
		code_errone_860027506 = 0x5040
		code_errone_860027506 = code_errone_860027506 + EFFICACE_860027506
		erreur_860027506 = i_PlvMessEmettre(6384,2,g_iartin,"",3,code_errone_860027506,C_Article_860027506,pt_MESSAGE_860027506)
		SAUT STOCKE_ERRONE
	FINSI
SINON
	#E.TV2OIP.TC2
	i_strcpy(pt_MESSAGE_860027506," Champ 'Type' absent ")	
	code_errone_860027506 = 0x5040
	code_errone_860027506 = code_errone_860027506 + EFFICACE_860027506
	erreur_860027506 = i_PlvMessEmettre(6384,2,g_iartin,"",3,code_errone_860027506,C_Article_860027506,pt_MESSAGE_860027506)
	SAUT STOCKE_ERRONE
FINSI

SI i_valid_field_n(g_iartout,$Tv2oip::T3Termination)
ALORS
	result_860027506 = i_get_art_field(g_iartout, $Tv2oip::Termination )
SINON
	#E.TV2OIP.TC8
	i_strcpy(pt_MESSAGE_860027506," Champ 'Termination' absent ")	
	code_errone_860027506 = 0x5040
	code_errone_860027506 = code_errone_860027506 + EFFICACE_860027506
	erreur_860027506 = i_PlvMessEmettre(6384,2,g_iartin,"",3,code_errone_860027506,C_Article_860027506,pt_MESSAGE_860027506)
	SAUT STOCKE_ERRONE
FINSI

SI ( ( i_strcmp(UCASE_860027343(pt_Type_860027506), C_TYPE_NORMAL_str_860027506 ) == 0 ) && result_860027506 == C_TERM_FAILURE_860027506 )
ALORS
	b_PARTIEL_860027506 = 1
FINSI

SI ( i_strcmp(UCASE_860027343(pt_Type_860027506), C_TYPE_FAILOVER_str_860027506 ) == 0 )
ALORS
	b_FAILOVER_860027506 = 1
FINSI

##########################################################################
# Creer le T3 FD/DATE/DATE (DCB) et le renseigner

erreur_860027506 = i_ajoutChampNum(g_iartout, $Tv2oip::T3Date, $Tv2oip::DATE, 0 )
erreur_860027506 = i_ajoutChampNum(g_iartout, $Tv2oip::T3sessEndTime, $Tv2oip::sessionEndTime, 0 )

SI i_valid_field_n(g_iartout, $Tv2oip::T3sessEndTimstr )
ALORS
	erreur_860027506 = i_dup_chp_1val (g_iartout, g_iartout, $Tv2oip::SESSEndTime, $Tv2oip::sessionEndTime )
SINON
	#E.TV2OIP.TC4
	# G4R8 QC852
	i_strcpy(pt_MESSAGE_860027506," Champ 'SessEndTimestr' absent ")	
	code_errone_860027506 = 0x5040
	code_errone_860027506 = code_errone_860027506 + EFFICACE_860027506
	erreur_860027506 = i_PlvMessEmettre(6384, 2, g_iartin, "", 3, code_errone_860027506, C_Article_860027506, pt_MESSAGE_860027506 )
	SAUT STOCKE_ERRONE
FINSI

SI i_valid_field_n(g_iartout, $Tv2oip::ANSWERTime )
ALORS
	#erreur = i_get_art_field(g_iartout, $Tv2oip::ANSWERDate,pt_temp)
	erreur_860027506 = i_dup_chp_1val (g_iartout, g_iartout, $Tv2oip::ANSWERDate, $Tv2oip::DATE )
SINON
	erreur_860027506 = i_dup_chp_1val (g_iartout, g_iartout, $Tv2oip::SESSEndTime, $Tv2oip::DATE )
FINSI

# Creer le T3 FD/DUREE/DUREE (HEXA) et le renseigner
# exprime en secondes

DATE_860027506 = i_get_art_field(g_iartout,$Tv2oip::DATE)
SessEndTime_860027506 = i_get_art_field(g_iartout,$Tv2oip::SESSEndTime)

DUREE_860027506 = SessEndTime_860027506 - DATE_860027506

#Creer le T3 FD/DUREE/DUREE

erreur_860027506 = i_ajoutChampNum(g_iartout,$Tv2oip::T3Duree,$Tv2oip::DUREE,0 )
erreur_860027506 = i_set_art_field(g_iartout, $Tv2oip::DUREE, DUREE_860027506 )


# GAR8 Lot1 ####
# Les DC verifiant  (b_PARTIEL ou b_FAILOVER) doivent etre elimines (Elimination Explicite avec stockage)

SI b_FAILOVER_860027506
ALORS
	SI result_860027506 != C_TERM_FAILURE_860027506
	ALORS
		SAUT STOCKE_ELM
	SINON
		SI !i_valid_field_n(g_iartout, $Tv2oip::FAILOVERId )
		ALORS
			#E.TV2OIP.TC22
			i_strcpy(pt_MESSAGE_860027506," Valeur champ 'FailoverId ' absent ")	
			code_errone_860027506 = 0x5040
			code_errone_860027506 = code_errone_860027506 + EFFICACE_860027506
			erreur_860027506 = i_PlvMessEmettre(6384,2,g_iartin,"",3,code_errone_860027506,C_Article_860027506,pt_MESSAGE_860027506)
			SAUT STOCKE_ERRONE
		FINSI
		
		SI !i_valid_field_n(g_iartout, $Tv2oip::SESSEndTime )
		ALORS
			#E.TV2OIP.TC22
			i_strcpy(pt_MESSAGE_860027506," Valeur champ 'SessionEndTimeStr ' absent ")	
			code_errone_860027506 = 0x5040
			code_errone_860027506 = code_errone_860027506 + EFFICACE_860027506
			erreur_860027506 = i_PlvMessEmettre(6384,2,g_iartin,"",3,code_errone_860027506,C_Article_860027506,pt_MESSAGE_860027506)
			SAUT STOCKE_ERRONE
		FINSI

		SAUT STOCKE_OK
	FINSI
FINSI


##########################################################################
# Creer le T3 FD/RoleOfNode/RoleOfNode (HEXA) et le renseigner

SI i_valid_field_n(g_iartout, $Tv2oip::T3RoleOfNodeStr )
ALORS
	erreur_860027506 = i_get_art_str(g_iartout, $Tv2oip::ROLEOfNODEStr,pt_RoleOfNodeStr_860027506)
	SI ( (i_strcmp(UCASE_860027343(pt_RoleOfNodeStr_860027506), C_ORIGINATING_str_860027506) != 0 ) && (i_strcmp(UCASE_860027343(pt_RoleOfNodeStr_860027506), C_TERMINATING_str_860027506) != 0 ) )
	ALORS
		#E.TV2OIP.TC7
		i_strcpy(pt_MESSAGE_860027506," Valeur champ 'ROLEOfNODEStr' incorrecte ")	
		code_errone_860027506 = 0x5040
		code_errone_860027506 = code_errone_860027506 + EFFICACE_860027506
		erreur_860027506 = i_PlvMessEmettre(6384,2,g_iartin,"",3,code_errone_860027506,C_Article_860027506,pt_MESSAGE_860027506)
		SAUT STOCKE_ERRONE
	FINSI
SINON
	#E.TV2OIP.TC6
	i_strcpy(pt_MESSAGE_860027506," Champ 'ROLEOfNODEStr' absent ")	
	code_errone_860027506 = 0x5040
	code_errone_860027506 = code_errone_860027506 + EFFICACE_860027506
	erreur_860027506 = i_PlvMessEmettre(6384,2,g_iartin,"",3,code_errone_860027506,C_Article_860027506,pt_MESSAGE_860027506)
	SAUT STOCKE_ERRONE
FINSI

SI ( i_strcmp(UCASE_860027343(pt_RoleOfNodeStr_860027506), C_ORIGINATING_str_860027506 ) ==0 )
ALORS
	ROLE_OF_NODE_860027506 = C_ORIGINATING_860027506
SINON
	ROLE_OF_NODE_860027506 = C_TERMINATING_860027506
FINSI

erreur_860027506 = i_ajoutChampNum(g_iartout,$Tv2oip::T3roleOfNode,$Tv2oip::roleOfNode,0 )
erreur_860027506 = i_set_art_field(g_iartout, $Tv2oip::roleOfNode, ROLE_OF_NODE_860027506 )

##########################################################################
# Creer le T3 FD/Efficiency/Efficiency (HEXA) et le renseigner

result_860027506 = i_get_art_field(g_iartout, $Tv2oip::Termination )

SI result_860027506 == C_TERM_NORMAL_860027506
ALORS
	EFFICIENCY_860027506 = C_SUCCESSFUL_860027506
SINON
	EFFICIENCY_860027506 = C_UNSUCCESSFUL_860027506
FINSI

erreur_860027506 = i_ajoutChampNum(g_iartout,$Tv2oip::T3Efficiency,$Tv2oip::Efficiency,0 )
erreur_860027506 = i_set_art_field(g_iartout, $Tv2oip::Efficiency, EFFICIENCY_860027506 )

##########################################################################
# Creer le T3 FD/CSASId/CSASId (ASCII) et le renseigner
# Le nom du fichier en entree contenant le DC traite,  est de la forme BW-CDR-yyyymmddhhmmss-pri-ASIdentifier-seqnum.csv (ex : BW-CDR-20131006183000-2-u1si3as1-000166.csv)
# cest la chaine <ASIdentifier> (5eme information en partant de la droite, separateur ?-? ) (ex : u1si3as1), identifiant de lAS, qui doit etre recuperee

i_get_sub_str(g_isource,-255,-1,pt_gisource_860027506)

# test avec nom de fichier
#i_strcpy(pt_gisource, "/home/envded9/envtest/echange/BW-CDR-20131006183000-2-u1si3as1-000166.csv" )

longueur_860027506 = i_strlen(pt_gisource_860027506)
indice_860027506 = 0

POINT boucle

SI indice_860027506 < 5
ALORS
	erreur_860027506 = i_recupererValeur(pt_gisource_860027506,pt_ASIdentifier_860027506,longueur_860027506,'-')
	SI erreur_860027506
	ALORS
		i_strcpy(pt_ASIdentifier_860027506," ")
		SAUT fin_boucle
	FINSI

	indice_860027506 = indice_860027506 + 1
	SAUT boucle
FINSI

POINT fin_boucle

longueur_860027506 = i_strlen(pt_ASIdentifier_860027506)
erreur_860027506 = i_ajoutChampNum(g_iartout,$Tv2oip::T3CSASId,$Tv2oip::CSASId,0 )
erreur_860027506 = i_set_art_str(g_iartout, $Tv2oip::CSASId, pt_ASIdentifier_860027506 )
erreur_860027506 = i_resize_tlv(g_iartout, "T3CSASId", "CSASId", longueur_860027506)

##########################################################################
# Creer le T3 FD/ASReleasingParty/ASReleasingParty (HEXA) et le renseigner

erreur_860027506 = i_get_art_str(g_iartout, $Tv2oip::ASRELEAPARStr, pt_ASReleasingParty_860027506)

SI ( i_strcmp(UCASE_860027343(pt_ASReleasingParty_860027506), C_NONE_str_860027506 ) == 0 )
ALORS
	ASReleasingParty_860027506 = C_NONE_860027506
SINON
	SI ( i_strcmp(UCASE_860027343(pt_ASReleasingParty_860027506), C_LOCAL_str_860027506 ) == 0 )
	ALORS
		ASReleasingParty_860027506 = C_LOCAL_860027506
	SINON
		ASReleasingParty_860027506 = C_REMOTE_860027506
	FINSI
FINSI

erreur_860027506 = i_ajoutChampNum(g_iartout,$Tv2oip::T3ASReleasParty,$Tv2oip::ASReleasParty,0 )
erreur_860027506 = i_set_art_field(g_iartout, $Tv2oip::ASReleasParty, ASReleasingParty_860027506 )

##########################################################################
# Si il est absent, creer le T3 FD/CalledNb/CalledNb et le renseigner
# G4R8 QC874
SI !( i_valid_field_n(g_iartout, $Tv2oip::CalledNb ) ) && ( i_strcmp(UCASE_860027343(pt_RoleOfNodeStr_860027506), C_TERMINATING_str_860027506 ) == 0 )
ALORS
	erreur_860027506 = i_get_art_str(g_iartout, $Tv2oip::TranslatedNb, pt_TranslatedNb_860027506)
	erreur_860027506 = i_ajoutChampNum(g_iartout,$Tv2oip::T3CalledNb,$Tv2oip::CalledNb,0 )
	longueur_860027506 = i_strlen( pt_TranslatedNb_860027506 )
	erreur_860027506 = i_resize_tlv( g_iartout, "T3CalledNb", "CalledNb", longueur_860027506 )
	erreur_860027506 = i_set_art_str(g_iartout, $Tv2oip::CalledNb, pt_TranslatedNb_860027506 )
FINSI


################################################################
#
#	Tests semantiques
#
################################################################
#
EFFICACE_860027506 = 0

#Modification de la methode de calcul EFFICACE #

DUREE_860027506=i_get_art_field(g_iartout, $Tv2oip::DUREE)
SI ( DUREE_860027506 != 0 )
ALORS
	EFFICACE_860027506 = 1
FINSI


SI i_strcmp(UCASE_860027343(pt_Type_860027506), C_TYPE_NORMAL_str_860027506 ) == 0
ALORS
	SI !i_valid_field_n(g_iartout, $Tv2oip::T3ChargingId )
	ALORS
		#E.TV2OIP.TC14
		i_strcpy(pt_MESSAGE_860027506," Champ 'Type' = normal et champ 'ChargingId' absent ")	
		code_errone_860027506 = 0x5040
		code_errone_860027506 = code_errone_860027506 + EFFICACE_860027506
		erreur_860027506 = i_PlvMessEmettre(6384,2,g_iartin,"",3,code_errone_860027506,C_Article_860027506,pt_MESSAGE_860027506)
		SAUT STOCKE_ERRONE
	FINSI
FINSI

SI i_strcmp(UCASE_860027343(pt_RoleOfNodeStr_860027506), C_ORIGINATING_str_860027506 ) == 0
ALORS
	SI !i_valid_field_n(g_iartout, $Tv2oip::CalledNb)
	ALORS
		#E.TV2OIP.TC15
		i_strcpy(pt_MESSAGE_860027506," Champ 'RoleOfNodeStr' = originating et champ 'CalledNb' absent ")	
		code_errone_860027506 = 0x5040
		code_errone_860027506 = code_errone_860027506 + EFFICACE_860027506
		erreur_860027506 = i_PlvMessEmettre(6384,2,g_iartin,"",3,code_errone_860027506,C_Article_860027506,pt_MESSAGE_860027506)
		SAUT STOCKE_ERRONE
	FINSI
SINON
	SI !i_valid_field_n(g_iartout, $Tv2oip::T3TranslatedNb )
	ALORS
		#E.TV2OIP.TC16
		i_strcpy(pt_MESSAGE_860027506," Champ 'RoleOfNodeStr' = terminating et champ 'TranslateNb' absent ")	
		code_errone_860027506 = 0x5040
		code_errone_860027506 = code_errone_860027506 + EFFICACE_860027506
		erreur_860027506 = i_PlvMessEmettre(6384,2,g_iartin,"",3,code_errone_860027506,C_Article_860027506,pt_MESSAGE_860027506)
		SAUT STOCKE_ERRONE
	FINSI
FINSI


## Efficiency ##
efficiency_860027506 =i_get_art_field(g_iartout, $Tv2oip::Efficiency)

SI (efficiency_860027506 != 0x01 && efficiency_860027506 != 0x02)
ALORS
	code_errone_860027506 = 0x5040
	code_errone_860027506 = code_errone_860027506 + EFFICACE_860027506
	erreur_860027506 = i_PlvMessEmettre(6370,2,g_iartout,"",3,code_errone_860027506,C_Article_860027506,efficiency_860027506)
	SAUT STOCKE_ERRONE
FINSI

## roleOfNode ##

res_860027506 =i_get_art_field(g_iartout, $Tv2oip::roleOfNode)
SI (res_860027506 != 0x00 && res_860027506 != 0x01)
ALORS
	code_errone_860027506 = 0x5040
	code_errone_860027506 = code_errone_860027506 + EFFICACE_860027506
	erreur_860027506 = i_PlvMessEmettre(6371,2,g_iartout,"",3,code_errone_860027506,C_Article_860027506,res_860027506)
	SAUT STOCKE_ERRONE
FINSI

#Rajout des tests syntaxique pour chargeIndicator et ASFacresult#
# Chargindicator ##
# Test de presence du champ ChargeIndicator
SI (i_valid_field_n(g_iartout,$Tv2oip::ChargeIndicator))
ALORS
	erreur_860027506 = i_get_art_str(g_iartout, $Tv2oip::ChargeIndicator,pt_indicator_860027506)
	# G4R8 QC852
	SI (i_strcmp(UCASE_860027343(pt_indicator_860027506), "Y") != 0 && i_strcmp(UCASE_860027343(pt_indicator_860027506), "N") != 0 && i_strcmp(UCASE_860027343(pt_indicator_860027506), "O") != 0 )
	ALORS
		#E.TV2OIP.TC20
		code_errone_860027506 = 0x5040
		code_errone_860027506 = code_errone_860027506 + EFFICACE_860027506
		erreur_860027506 = i_PlvMessEmettre(6381,2,g_iartout,"",3,code_errone_860027506,C_Article_860027506,pt_indicator_860027506)
		SAUT STOCKE_ERRONE
	FINSI
SINON
	#E.TV2OIP.TC12
	i_strcpy(pt_MESSAGE_860027506," Champ 'ChargeIndicator' absent ")	
	code_errone_860027506 = 0x5040
	code_errone_860027506 = code_errone_860027506 + EFFICACE_860027506
	erreur_860027506 = i_PlvMessEmettre(6384,2,g_iartout,"",3,code_errone_860027506,C_Article_860027506,pt_MESSAGE_860027506)
	SAUT STOCKE_ERRONE
FINSI

# G4R8 QC852
SI i_valid_field_n(g_iartout,$Tv2oip::T3ASService1)
ALORS
	## ASServiceName  ##
	# Test de presence du champ ASServiceName
	SI !i_valid_field_n(g_iartout,$Tv2oip::ASServiceName)
	ALORS  
		#E.TV2OIP.TC17
		i_strcpy(pt_MESSAGE_860027506," Champ 'ASServiceName' absent ")	
		code_errone_860027506 = 0x5040
		code_errone_860027506 = code_errone_860027506 + EFFICACE_860027506
		erreur_860027506 = i_PlvMessEmettre(6384,2,g_iartout,"",3,code_errone_860027506,C_Article_860027506,pt_MESSAGE_860027506)
		SAUT STOCKE_ERRONE
	FINSI
	
	## ASFacresult  ##
	# Test de presence du champ ASFacResult
	SI (i_valid_field_n(g_iartout,$Tv2oip::ASFacResult))
	ALORS  
		res_860027506 = i_get_art_field(g_iartout, $Tv2oip::ASFacResult)
		SI ( res_860027506 != C_SUCCESS_860027506 && res_860027506 != C_FAILURE_860027506 )
		ALORS
			#E.TV2OIP.TC13
			code_errone_860027506 = 0x5040
			code_errone_860027506 = code_errone_860027506 + EFFICACE_860027506
			erreur_860027506 = i_PlvMessEmettre(6382,2,g_iartout,"",3,code_errone_860027506,C_Article_860027506,res_860027506)
			SAUT STOCKE_ERRONE
		FINSI
	SINON
		#E.TV2OIP.TC18
		i_strcpy(pt_MESSAGE_860027506," Champ 'ASFacResult' absent ")	
		code_errone_860027506 = 0x5040
		code_errone_860027506 = code_errone_860027506 + EFFICACE_860027506
		erreur_860027506 = i_PlvMessEmettre(6384,2,g_iartout,"",3,code_errone_860027506,C_Article_860027506,pt_MESSAGE_860027506)
		SAUT STOCKE_ERRONE
	FINSI
FINSI
# ASServicename = 20 et answerIndicator = "Yes"
SI (i_valid_field_n(g_iartout,$Tv2oip::T3AnswerIndicat))
ALORS
	erreur_860027506 = i_get_art_str(g_iartout, $Tv2oip::AnswerIndicator, pt_AnswerIndicat_860027506 ) 
	SI ( i_strcmp(UCASE_860027343(pt_AnswerIndicat_860027506), C_YES_str_860027506) != 0 && i_strcmp(UCASE_860027343(pt_AnswerIndicat_860027506), C_NO_str_860027506) !=0 && i_strcmp(UCASE_860027343(pt_AnswerIndicat_860027506), C_YES_POSTREDIR_str_860027506) != 0 )
	ALORS
		#E.TV2OIP.TC10
		erreur_860027506 = i_format_str2( pt_MESSAGE_860027506, " Valeur du champ 'AnswerIndicator' < %s > non autorise ", pt_AnswerIndicat_860027506, 0 )
		code_errone_860027506 = 0x5040
		code_errone_860027506 = code_errone_860027506 + EFFICACE_860027506
		erreur_860027506 = i_PlvMessEmettre(6384, 2, g_iartout, "", 3, code_errone_860027506, C_Article_860027506, pt_MESSAGE_860027506)
		SAUT STOCKE_ERRONE
	FINSI
SINON
	#E.TV2OIP.TC9
	i_strcpy(pt_MESSAGE_860027506," Champ 'AnswerIndicator' absent ")	
	code_errone_860027506 = 0x5040
	code_errone_860027506 = code_errone_860027506 + EFFICACE_860027506
	erreur_860027506 = i_PlvMessEmettre(6384,2,g_iartin,"",3,code_errone_860027506,C_Article_860027506,pt_MESSAGE_860027506)
	SAUT STOCKE_ERRONE
FINSI

SI ((i_get_art_field(g_iartout, $Tv2oip::T3ASService1 + 4) == 20) && (i_strcmp(UCASE_860027343(pt_indicator_860027506),"YES") == 0))
ALORS
	#TranslatedNb doit etre present
	SI (i_valid_field_n(g_iartout,$Tv2oip::TranslatedNb) == 0)
	ALORS
		code_errone_860027506 = 0x5040
		code_errone_860027506 = code_errone_860027506 + EFFICACE_860027506
		i_strcpy (pt_MESSAGE_860027506, "champ TranslatedNb absent")
		erreur_860027506 = i_PlvMessEmettre(6384,2,g_iartout,"",3,code_errone_860027506,C_Article_860027506,pt_MESSAGE_860027506)
		SAUT STOCKE_ERRONE
	FINSI
FINSI

#Test sur presence du champ CallingNb
#sans emission de message simple 
SI (! i_valid_field_n(g_iartout,$Tv2oip::CallingNb))
ALORS
	#E.TV2OIP.TC11
	#trace ("champ CallingNb absent envoi en elimine")
	SAUT STOCKE_ELM
FINSI

# Creation Enveloppe Optionnelle avec Compteur Recyclage pour symphonie
#==============================================================================
erreur_860027506 = i_add_opt( "E_V2OIP" )

# champ T1 (renseigne par l'ATP)
# Champ L1 (calculee par ATP)
# Champ CptRecy
erreur_860027506 = i_set_attr_val_n($E_V2OIP::CptRecy,3)

#G4R7 Lot4  Suppression des champs 8050 a 8056
#==============================================================================
# GAR8 Lot1 ####
#SI i_valid_field_n(g_iartout,$Tv2oip::T3Type)
#ALORS
#	erreur = i_supprChamp(g_iartout,"T3Type")
#FINSI

#SI i_valid_field_n(g_iartout,$Tv2oip::T3NetworkCallId)
#ALORS
#	erreur = i_supprChamp(g_iartout,"T3NetworkCallId")
#FINSI

#SI i_valid_field_n(g_iartout,$Tv2oip::T3FailoverId)
#ALORS
#	erreur = i_supprChamp(g_iartout,"T3FailoverId")
#FINSI

SI i_valid_field_n(g_iartout,$Tv2oip::T3RoleOfNodeStr)
ALORS
	erreur_860027506 = i_supprChamp(g_iartout,"T3RoleOfNodeStr")
FINSI

SI i_valid_field_n(g_iartout,$Tv2oip::T3ASReleaParStr)
ALORS
	erreur_860027506 = i_supprChamp(g_iartout,"T3ASReleaParStr")
FINSI

SI i_valid_field_n(g_iartout,$Tv2oip::T3AnswerTime)
ALORS
	erreur_860027506 = i_supprChamp(g_iartout,"T3AnswerTime")
FINSI

SI i_valid_field_n(g_iartout,$Tv2oip::T3sessEndTimstr)
ALORS
	erreur_860027506 = i_supprChamp(g_iartout,"T3sessEndTimstr")
FINSI

SAUT STOCKE_OK

#==============================================================================
#	Stockage en valide
#==============================================================================

POINT   STOCKE_OK

SI b_PARTIEL_860027506 || b_FAILOVER_860027506
ALORS
	erreur_860027506 = i_ajoutChampNum(g_iartout, $Tv2oip::T3CptCorr, $Tv2oip::Cpt_CORR, 0 )
	erreur_860027506 = i_set_art_field(g_iartout, $Tv2oip::Cpt_CORR, 0 )
FINSI

#trace("[Tv2oip_tr] #trace Stockage en valide")
erreur_860027506 = i_stocke_art(g_iartout, 0, PT_OK, 0)

RETOUR TRAIT_OK

#==============================================================================
#	Stockage en errone
#==============================================================================

POINT  STOCKE_ERRONE

#trace("[Tv2oip_tr] Stockage en ERRONE ")

erreur_860027506 = i_make_art_rej(g_iartin, g_iartout5, code_errone_860027506)
erreur_860027506 = i_stocke_art(g_iartout5, 0, PT_ERRONE, 0)

RETOUR TRAIT_OK

#==============================================================================
#	Stockage en elimine
#==============================================================================

POINT  STOCKE_ELM

#trace("[Tv2oip_tr] Stockage en ELIMINE ")

#erreur = i_stocke_art(g_iartin, 0, PT_ELIMINE, 0)
erreur_860027506 = i_stocke_art(g_iartin, 0, PT_DIVERS, 0)

RETOUR TRAIT_OK

#--------------Fin Pcode Traitement Tv2oip_tr.src-------------------------
