IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

WinDev Discussion :

Création d'un fichier sans analyse


Sujet :

WinDev

  1. #1
    Membre expérimenté
    Profil pro
    Inscrit en
    Avril 2010
    Messages
    915
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2010
    Messages : 915
    Points : 1 497
    Points
    1 497
    Par défaut Création d'un fichier sans analyse
    Bonsoir
    Dans un projet d'essai je veux accéder à un fichier créé dans un autre projet.
    Si je copie ce fichier en local ou Client/Serveur ce code me permet de manipuler le fichier avec HDéclareExterne. S'il n'existe pas, je veux le créé à partir d'une table où je décris toutes les rubriques du fichier.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    cnxConexion est une Connexion
     
    // Paramètres de la connexion
    cnxConexion..Provider = hAccèsHFClientServeur
    cnxConexion..Utilisateur = "admin"
    cnxConexion..MotDePasse = ""
    cnxConexion..Serveur = "192.168.1.53"
    cnxConexion..BaseDeDonnées = "MODELOS"
    cnxConexion..Cryptage = hCryptageNon
     
     
    sdHALU est une Source de Données
     
     
    SI HChangeConnexion(".\HALU.FIC", cnxConexion) = Faux ALORS
        // CONEXION FALLA
        //bConnexionDistante = Faux
        Erreur(HErreurInfo())
    SINON
        // CONEXION CORRECTA
        SI HOuvreConnexion(cnxConexion) = Faux ALORS
            //bConnexionDistante = Faux
            Erreur(HErreurInfo())
        SINON
            // CONEXION CORRECTA
            //bConnexionDistante = Vrai
            // ******************************************
            // QUAND LE FICHIER N'EXISTE PAS LE CREER AVEC HDécritFichier
            // OU PLACER LE CODE DE CREATION : CrearFic(Vrai, TABLE_Ficheros.COL_APLICACION, "", sdHALU)
            // ******************************************
            //HDéclareExterne(<Nom du fichier> , <Nom alias> , <Nom de la connexion>) 
            SI HDéclareExterne(".\HALU.FIC", sdHALU, cnxConexion) ALORS
                SI PAS HCréationSiInexistant(sdHALU) ALORS
                    Erreur(HErreurInfo())
                SINON
                    //Info(sdHALU+" creado")
                FIN
                sdHALU.DNI="12345678W"
                SI PAS HAjoute(sdHALU) ALORS
                    Erreur(HErreurInfo())
                SINON
                    Info(sdHALU.DNI+" creado")
                FIN
            SINON
                Erreur(HErreurInfo())
            FIN
        FIN
    FIN
    HAnnuleDéclaration(sdHALU)
    Mais je ne réussi pas à utiliser correctement HDécritRubrique et HDécritFichier à l'appel de la procédure :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    PROCEDURE CrearFic(bCrearFicWD15, Aplicacion, CodigoCli, FicWD15 est une Source de Données)
     
    ni est un entier
    NbreEnr est un entier
    i est un entier
    MiFichero est une Description de Fichier
    NombreFicheroFIC est une Source de Données
    MiCampo est une Description de Rubrique
    NombreMiCampo est une chaîne
     
     
    sListeFichier est une chaîne
    sListeRubrique est une chaîne
     
     
    SI bCrearFicWD15=Vrai ALORS
        // CREAR EL FICHERO FIC A PARTIR DE WDHFSQL
        // Valide la description du fichier
        NbreEnr = TableOccurrence(TABLE_HFSQL,toTotal)
        POUR ni = 1 A NbreEnr
            // Parcours du fichier
            Jauge(ni,NbreEnr)
            // Traitement pour chaque registre
                // Description du fichier COL_FICHERO
                NombreFicheroFIC={"TABLE_HFSQL"+"._COL3",indChamp}[ni]
                MiFichero..Nom = NombreFicheroFIC
                MiFichero..Type = hFichierNormal
                MiFichero..CryptageFic = hCryptageStandard
                // Description de la rubrique COL_CAMPO
                MiCampo..Nom = {"TABLE_HFSQL"+"._COL5",indChamp}[ni]
                //    SELON SansEspace(WDNUM.TIPO)
                //        CAS "T"
                //            MiCampo..Type = hRubTexte
                //        CAS "N"
                //            MiCampo..Type = hRubNumérique
                //        CAS "D"
                //            MiCampo..Type = hRubDate8
                //        AUTRE CAS
                //            
                //    FIN
                MiCampo..Type = {"TABLE_HFSQL"+"._COL8",indChamp}[ni]
                MiCampo..Taille = {"TABLE_HFSQL"+"._COL9",indChamp}[ni]
                SI{"TABLE_HFSQL"+"._COL10",indChamp}[ni]=Vrai ALORS
                    MiCampo..TypeClé = hCléUnique
                SINON
                    MiCampo..TypeClé = hNonClé
                FIN
                HDécritRubrique(MiFichero, MiCampo)
                NombreMiCampo={"TABLE_HFSQL"+"._COL5",indChamp}[ni]
            //FIN
        FIN
        Jauge()
            SI PAS HDécritFichier(MiFichero) ALORS
                Erreur(hErrEnCours)
            FIN
            // Création du fichier COL_FICHERO (reconnu car déclaré comme source de données)
            SI HCréationSiInexistant(NombreFicheroFIC) ALORS
                Info("FICHERO "+FicWD15+" CREADO.")
            SINON
                ERREUR("FICHERO "+FicWD15+" NO CREADO.")
            FIN
        //FIN
    SINON
        // COPIAR LA Estructura DE FicWD15 A WDHFSQL
        sListeFichier=HListeFichier()
        SI Position(sListeFichier, FicWD15)=0 ALORS
            //sdFicWD15 est une Source de Données
            HDéclareExterne(".\"+FicWD15+".FIC", FicWD15)
        SINON
        FIN
        // Récupérer les rubriques d'un fichier de l'analyse en cours
        HCréationSiInexistant(FicWD15)
        // Importe la description du fichier HNUM sous le nom WDHNUM
        sListeRubrique = HListeRubrique(FicWD15, hLstDétail)
        HCréationSiInexistant("WD"+FicHFSQL)
        //Pour chaque enregistrement, il faut parcourir les rubriques. 
        POUR TOUTE CHAINE sUneRubrique DE sListeRubrique SEPAREE PAR RC
            Trace(sUneRubrique)
            i ++
            {"WD"+FicHFSQL+".APLICACION"}=Aplicacion
            {"WD"+FicHFSQL+".CODIGO_CLI"}=CodigoCli
            {"WD"+FicHFSQL+".Fichero"}=FicWD15
            {"WD"+FicHFSQL+".ORDEN"}=NumériqueVersChaîne(i, "02d")
            {"WD"+FicHFSQL+".CAMPO"}=ExtraitChaîne(sUneRubrique,1,TAB)
            {"WD"+FicHFSQL+".ETIQUETA"}=ExtraitChaîne(sUneRubrique,6,TAB)
            {"WD"+FicHFSQL+".TIPO"}=ExtraitChaîne(sUneRubrique,2,TAB)
            {"WD"+FicHFSQL+".TIPOHF"}=ExtraitChaîne(sUneRubrique,3,TAB)
            {"WD"+FicHFSQL+".TAMANO"}=ExtraitChaîne(sUneRubrique,4,TAB)
            SI i=1 ALORS
                {"WD"+FicHFSQL+".INDEX"}=Vrai
            SINON
                {"WD"+FicHFSQL+".INDEX"}=Faux
            FIN
            HAjoute({"WD"+FicHFSQL})
        FIN
        Info("ESTRUCTURA DEL FICHERO "+FicWD15+" IMPORTADA.")
    FIN

  2. #2
    Expert confirmé
    Avatar de Voroltinquo
    Homme Profil pro
    Chef de projet en SSII
    Inscrit en
    Juin 2017
    Messages
    2 812
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Chef de projet en SSII

    Informations forums :
    Inscription : Juin 2017
    Messages : 2 812
    Points : 5 271
    Points
    5 271
    Billets dans le blog
    1
    Par défaut
    Bonjour,
    Dans la mesure où le fichier existe, pourquoi ne pas utiliser HAlias ?
    Il y a peut-être plus simple, mais ça tourne.
    Quand tout a échoué utilisez l'option RTFM

  3. #3
    Membre actif
    Homme Profil pro
    Inscrit en
    Janvier 2011
    Messages
    174
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations forums :
    Inscription : Janvier 2011
    Messages : 174
    Points : 287
    Points
    287
    Par défaut
    Bonjour;

    Ce que j'ai compris d’après le code de la procédure :

    1 - La colonne "COL3" de la table "TABLE_HFSQL" contient la même valeur, qui est le nom du fichier, pourquoi ?? je ne vois pas sa place dans cette table.
    2 - Pourquoi introduire la Description du fichier "COL_FICHERO" dans la boucle "POUR" qui est sensée de décrire les rubriques ? (ligne 24 à 28) à faire sortir de la boucle
    3 - La ligne 26 : MiFichero..Nom = NombreFicheroFIC , le nom du fichier doit être une chaine de caractère donc à le mettre entre guillemets => MiFichero..Nom = "NombreFicheroFIC"

    j’espère que ça résout l'utilisation de HDécritRubrique et HDécritFichier.

    Bon Dev

  4. #4
    Membre expérimenté
    Profil pro
    Inscrit en
    Avril 2010
    Messages
    915
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2010
    Messages : 915
    Points : 1 497
    Points
    1 497
    Par défaut
    Citation Envoyé par Voroltinquo Voir le message
    Bonjour,
    Dans la mesure où le fichier existe, pourquoi ne pas utiliser HAlias ?
    Il n'existe pas. Je veux le creer manuellement.

  5. #5
    Rédacteur/Modérateur

    Homme Profil pro
    Ingénieur qualité méthodes
    Inscrit en
    Décembre 2013
    Messages
    4 058
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur qualité méthodes
    Secteur : Conseil

    Informations forums :
    Inscription : Décembre 2013
    Messages : 4 058
    Points : 9 397
    Points
    9 397
    Par défaut
    Ton programme plante où ?

    Tu fais une boucle avec plusieurs appels à hDécritRubrique. Ok.
    Teste à chaque fois si hDécritRubrique a fonctionné correctement.
    N'oubliez pas le bouton Résolu si vous avez obtenu une réponse à votre question.

  6. #6
    Membre expérimenté
    Profil pro
    Inscrit en
    Avril 2010
    Messages
    915
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2010
    Messages : 915
    Points : 1 497
    Points
    1 497
    Par défaut
    Enfin, en changeant l'ordre des instructions, j'ai réussi.
    Je peux utiliser les fichiers d'une analyse ou créer de toutes pièces des fichiers inexistants dans l'analyse et les créer à partir d'une table contenant les paramêtres des rubriques.
    J'ai fais une procedure qui traite la majorité des types de connexion à partir d'un fichier .INI.
    Si vous pouvez m'aider à l'améliorer, je vous en remercie par avance. Je ne suis pas un vrai professionnel, je suis autodidacte.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    sClave est une chaîne 
    sTipoID est une chaîne
    sCampo est une chaîne
    sFiltro est une chaîne
    sServidor, sProvider, sBaseDatos, sDirDatos, sFichero, sUsuario, sPassword sont des chaînes
    cnxConexion est une Connexion
    bConnexionDistante est booléen
     
     
    //sServidor="local"
    //sProvider="hAccèsHF7"
    sServidor="192.168.1.53"
    sProvider="hAccèsHFClientServeur"
     
     
    sBaseDatos="MODELOS"
    sDirDatos=".\"
    sFichero=""
    sUsuario="admin"
    sPassword=""
     
     
    sFichero=TABLE_Ficheros.COL_FICHERO
    sClave={"TABLE_HFSQL"+"._COL5",indChamp}[1]
    sTipoID="00"
    sFiltro=""
     
     
    sdFichero est une Source de Données
     
     
    ConectarFIC(sServidor, sProvider, sBaseDatos, sDirDatos, sFichero, sUsuario, sPassword, cnxConexion, bConnexionDistante)
     
     
    HFerme(sFichero)
    //Erreur(HErreur(hErrEnCours))
    SI PAS HDéclareExterne(sFichero+".FIC", "sdFichero", cnxConexion) ALORS
        Erreur(ErreurInfo())
    FIN
     
     
    Ouvre(FEN_Table_REQ_Modelo, sFichero, sClave, sTipoID, sFiltro, TABLE_Ficheros.COL_DESCRIPCION, sdFichero)
    Fonction ConectarFIC :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    PROCEDURE ConectarFIC(sServidor, sProvider, sBaseDatos, sDirDatos, sFichero, sUsuario, sPassword sont des chaînes, sConexion est une Connexion, bConnexionDistante est booléen)
     
    // CONFIGURAR TODAS LAS CONEXIONES CON sConexion..
    //SI PAS HFerme(sFichero) ALORS
    //    HErreurInfo()
    //FIN
    // Fermer la connexion 
    //SI PAS HFermeConnexion(sConexion) ALORS
    //    HErreurInfo()
    //FIN
     
     
    //Ainsi il faudra préférer l'enchaînement : 
    //HChangeConnexion 
    //HChangeRep 
    //HPasse 
    //HOuvreConnexion
     
     
    // Paramètres de la connexion
    SELON sProvider
        CAS "hAccèsHF7"
            sConexion..Provider = hAccèsHF7
        CAS "hAccèsHFClientServeur"
            sConexion..Provider = hAccèsHFClientServeur
        CAS "hOledbSQLServer"
            sConexion..Provider = hOledbSQLServer
        CAS "hOledbAccess97"
            sConexion..Provider = hOledbAccess97
        CAS "hOledbAccess2000"
            sConexion..Provider = hOledbAccess2000
        CAS "hAccèsNatifXBase"
            sConexion..Provider = hAccèsNatifXBase
        CAS "hAccèsNatifMySQL"
            sConexion..Provider = hAccèsNatifMySQL
        CAS "hAccèsNatifSQLServer"
            sConexion..Provider = hAccèsNatifSQLServer
        CAS "hAccèsNatifXML"
            sConexion..Provider = hAccèsNatifXML
        CAS "hODBC"
            sConexion..Provider = hODBC
        AUTRE CAS
            // 
    FIN
    sConexion..Utilisateur = sUsuario // "sa"
    sConexion..MotDePasse = sPassword // "sasa1234"
    sConexion..Serveur = sServidor // "JAG\SQLEXPRESS"
    sConexion..BaseDeDonnées = sBaseDatos // "IFEX"
    sConexion..Accès = hOLectureEcriture
     
     
    // Ouverture de la connexion
    SELON sProvider
        CAS "hAccèsHF7"
            sConexion..Utilisateur = ""
            sConexion..MotDePasse = ""
            sConexion..Serveur = sDirDatos
            sConexion..BaseDeDonnées = ""
            sConexion..Cryptage = hCryptageNon
            sConexion..Accès = hOLectureEcriture 
            sConexion..InfosEtendues = "Infos étendues" 
            sConexion..OptionsCurseur = hCurseurClient 
            sConexion..Compression = Vrai
            sConexion..Source = sDirDatos
            SI HChangeConnexion(sFichero, sConexion) = Faux ALORS
                // CONEXION FALLA
                bConnexionDistante = Faux
                Erreur(HErreurInfo())
            SINON
                // CONEXION CORRECTA
                SI HChangeRep(sFichero, sDirDatos) = Faux
                    bConnexionDistante = Faux
                    Erreur(HErreurInfo())
                FIN
                SI HOuvreConnexion(sConexion) = Faux ALORS
                    bConnexionDistante = Faux
                    Erreur(HErreurInfo())
                SINON
                    // CONEXION CORRECTA
                    bConnexionDistante = Vrai
                FIN
            FIN
        CAS "hAccèsNatifXBase"
            sConexion..Source = ComplèteRep(sDirDatos)+sFichero+".DBF"//sBaseDatos//"D:\GrupoSP\CON2013\EMP0018\Diario.dbf"
            SI HChangeConnexion(sFichero, sConexion) = Faux ALORS
                // CONEXION FALLA
                bConnexionDistante = Faux
                Erreur(HErreurInfo())
            SINON
                // CONEXION CORRECTA
                SI HChangeRep(sFichero, sDirDatos) = Faux
                    bConnexionDistante = Faux
                    Erreur(HErreurInfo())
                FIN
                SI HOuvreConnexion(sConexion) = Faux ALORS
                    bConnexionDistante = Faux
                    Erreur(HErreurInfo())
                SINON
                    // CONEXION CORRECTA
                    bConnexionDistante = Vrai
                    SI PAS HDBOuvre(sFichero,Gauche(sFichero,2),ComplèteRep(sDirDatos)+sFichero+".DBF") ALORS
                        Info(sFichero,Gauche(sFichero,2),ComplèteRep(sDirDatos)+sFichero+".DBF")
                        Erreur(HErreurInfo())
                    SINON
                        // CONEXION CORRECTA
                        //info(sFichero,Gauche(sFichero,2),ComplèteRep(sDirDatos)+sFichero+".DBF")
                    FIN
                FIN
            FIN
        CAS "hOledbAccess2000"
            sConexion..BaseDeDonnées = ""
            sConexion..Source = ComplèteRep(sDirDatos)+gsFicheroBDD+".MDB"//sBaseDatos//"D:\GrupoSP\CON2013\EMP0018\Diario.dbf"
            SI HChangeConnexion(sFichero, sConexion) = Faux ALORS
                // CONEXION FALLA
                bConnexionDistante = Faux
                Erreur(HErreurInfo())
            SINON
                // CONEXION CORRECTA
                SI HChangeRep(sFichero, sDirDatos) = Faux
                    bConnexionDistante = Faux
                    Erreur(HErreurInfo())
                FIN
                SI HOuvreConnexion(sConexion) = Faux ALORS
                    bConnexionDistante = Faux
                    Erreur(HErreurInfo())
                SINON
                    // CONEXION CORRECTA
                    bConnexionDistante = Vrai
                FIN
            FIN
        CAS "hAccèsNatifXML"
            sConexion..BaseDeDonnées = ""
            sConexion..Source = ComplèteRep(sDirDatos)+gsFicheroBDD+".XML"
            SI HChangeConnexion(sFichero, sConexion) = Faux ALORS
                // CONEXION FALLA
                bConnexionDistante = Faux
                Erreur(HErreurInfo())
            SINON
                // CONEXION CORRECTA
                SI HChangeRep(sFichero, sDirDatos) = Faux
                    bConnexionDistante = Faux
                    Erreur(HErreurInfo())
                FIN
                SI HOuvreConnexion(sConexion) = Faux ALORS
                    bConnexionDistante = Faux
                    Erreur(HErreurInfo())
                SINON
                    // CONEXION CORRECTA
                    bConnexionDistante = Vrai
                FIN
            FIN
        AUTRE CAS
            SI HChangeConnexion(sFichero, sConexion) = Faux ALORS
                // CONEXION FALLA
                bConnexionDistante = Faux
                Erreur(HErreurInfo())
            SINON
                // CONEXION CORRECTA
                SI HOuvreConnexion(sConexion) = Faux ALORS
                    bConnexionDistante = Faux
                    Erreur(HErreurInfo())
                SINON
                    // CONEXION CORRECTA
                    bConnexionDistante = Vrai
                FIN
            FIN
    FIN
     
     
    SI bConnexionDistante = Vrai ALORS
        SI EnModeTest() ALORS
            Trace("**********************************************")
            Trace("Conexión correcta:")
            Trace("Servidor: "+sServidor)
            Trace("Base de Datos: "+sBaseDatos)
            Trace("Fichero: "+sFichero)
        FIN
        CrearFichero(1, sFichero, sConexion, "")
        //Erreur(HErreur(hErrEnCours))
        //INFO(HListeFichier(sFichero))
    //    POUR TOUTE CHAINE sFicheroHF DE HListeFichier(sFichero) SEPAREE PAR rc
    //        SELON GAUCHE(sFicheroHF,1)
    //            CAS "X", "SUB"
    //                // NO ABRIR DBF
    //                AUTRE CAS
    //                    sELON majuscule(gauche(sFicheroHF,3))
    //                        CAS "TDB", "SUB"
    //                            // NO ABRIR
    //                        AUTRE CAS
    //                            //HCréationSiInexistant(sFicheroHF, hOuvertureDifférée)
    //                    FIN
    //                    //SI EnModeTest() et FenEtat(FEN_Info2)=Actif ALORS
    //                        //FEN_Info2.LIB_Libellé1=sFicheroHF
    //                    //FIN
    //        FIN
    //    FIN
    SINON
        Trace("************************************************************************")
        SI EnModeTest() ALORS
            Trace("Modo Test. Cuidado, trabaja con la Base de Datos en local.")
        SINON
            Trace("Cuidado, trabaja con la Base de Datos en local.")
            //    EnviarGmail (<UsuarioSMTP>, <Mot_de_passe>, <ServidorSMTP>, <CuentaCliente>, <CuentaTecnico>, <Asunto>, <Cuerpo> [, <Adjuntos>])
            //EnviarGmail("info.formap", "965402760", "smtp.gmail.com", "info.formap@gmail.com", "cetcrevillente@gmail.com", "Seguimiento Aplicación "+sBaseDatos, "Pérdida de conexión con el Servidor en: " + RC + sServidor)
            //EnviarGmail(gsUsuarioSMTPCliente, gsPasswordCliente, gsServidorSMTPCliente, gsCuentaCliente, gsCuentaTecnico, "Seguimiento Aplicación "+sBaseDatos, "Pérdida de conexión con el Servidor en: " + RC + sServidor)
        FIN
        Trace("Si no debe así, avise")
        Trace("el Administrador de que hay una perdida")
        Trace("de conexión con el Servidor: "+sServidor)
        Trace("Conexión: ",sConexion)
    FIN
    Fonction CrearFichero(1, sFichero, sConexion, "")

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    PROCEDURE CrearFichero(NbreEnr, sdFIC, cnxConexion, sClave)
     
    MiFichero est une Description de Fichier
    MiCampo est une Description de Rubrique
    NombreMiCampo est une chaîne
     
     
    // QUAND LE FICHIER N'EXISTE PAS LE CREER AVEC HDécritFichier
    NbreEnr = TableOccurrence(TABLE_HFSQL,toTotal)
    // Création du fichier COL_FICHERO (reconnu car déclaré comme source de données)
    //HDéclareExterne(<Nom du fichier> , <Nom alias> , <Nom de la connexion>) 
    SI PAS HDéclareExterne(".\"+sdFIC+".FIC", "sdFIC", cnxConexion) ALORS
        //Erreur(HErreur(hErrEnCours))
        SELON HErreur(hErrEnCours)
            CAS "70207" // DESCRIPTION DÉJÀ EXISTANTE
     
            CAS "70003", "70018" // FICHIER INCONNU
                SI OuiNon(Non,"El fichero "+sdFIC+" no existe, ¿desea crearlo a partir de la definición de la estructura?")=Oui ALORS
                    POUR ni = 1 _A_ NbreEnr
                        // Parcours du fichier
                        //Jauge(ni,NbreEnr)
                        // Traitement pour chaque registre
                        // Description du fichier COL_FICHERO
                        MiFichero..Nom = sdFIC
                        MiFichero..Type = hFichierNormal
                        MiFichero..CryptageFic = hCryptageStandard
                        // Description de la rubrique COL_CAMPO
                        MiCampo..Nom = {"TABLE_HFSQL"+"._COL5",indChamp}[ni]
                        MiCampo..Type = {"TABLE_HFSQL"+"._COL8",indChamp}[ni]
                        MiCampo..Taille = {"TABLE_HFSQL"+"._COL9",indChamp}[ni]
                        SI{"TABLE_HFSQL"+"._COL10",indChamp}[ni]=Vrai ALORS
                            SI {"TABLE_HFSQL"+"._COL4",indChamp}[ni]="01" ALORS
                                MiCampo..TypeClé = hCléUnique
                                sClave = MiCampo..Nom
                            SINON
                                MiCampo..TypeClé = hCléDoublon
                            FIN
                        SINON
                            MiCampo..TypeClé = hNonClé
                        FIN
                        SI PAS HDécritRubrique(MiFichero, MiCampo) ALORS
                            Erreur(hErrEnCours)
                        FIN
                        NombreMiCampo={"TABLE_HFSQL"+"._COL5",indChamp}[ni]
                    FIN
                    //Jauge()
                    SI PAS HDécritFichier(MiFichero) ALORS
                        Erreur(hErrEnCours)
                    FIN
                    SI PAS HCréationSiInexistant(sdFIC) ALORS
                        Erreur(HErreurInfo())
                    FIN
                    //INFO(HListeRubrique("sdFIC", hLstDétail+hLstTout+hLstOrdreLogique))
                    //ConstruitTableFichier(TABLE_Contenido, "sdFIC", taParOrdreLogique)
                FIN
            AUTRE CAS
                Erreur(HErreur(hErrEnCours))
        FIN
    FIN
    HAnnuleDéclaration("sdFIC")

  7. #7
    Membre expérimenté
    Profil pro
    Inscrit en
    Avril 2010
    Messages
    915
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2010
    Messages : 915
    Points : 1 497
    Points
    1 497
    Par défaut
    Personne pour m'aider?

  8. #8
    Membre expérimenté
    Profil pro
    Inscrit en
    Avril 2010
    Messages
    915
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2010
    Messages : 915
    Points : 1 497
    Points
    1 497
    Par défaut
    Bon, il semble que personne n'a le temps de voir mon code.
    J'attendrai que tout le monde rentre de vacances et alors je passerai en résolu si pas de réponse.
    Merci à ceux qui ont participés.

  9. #9
    Rédacteur/Modérateur

    Homme Profil pro
    Ingénieur qualité méthodes
    Inscrit en
    Décembre 2013
    Messages
    4 058
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur qualité méthodes
    Secteur : Conseil

    Informations forums :
    Inscription : Décembre 2013
    Messages : 4 058
    Points : 9 397
    Points
    9 397
    Par défaut
    Dans la procedure conectarFIC, je n'aime pas trop l'utilisation de hChangeRep()

    Ce que tu as fait doit marcher, mais c'est bizarre.

    hChangeRep est utile uniquement si on est en HyperFile. Dans tous les autres cas, cette instruction ne sert à rien.
    Donc, dans le SELON qui commence en ligne 53 et qui finit en ligne 160, je laisserais le 1er hChangeRep (on est dans le cas hAccesHF7) et je l'enlèverais dans tous les autres cas.

    Et toujours dans ce même SELON, tu peux regrouper les cas Xbase Access et XML.
    C'est le même code pour ces 3 cas. La seule ligne qui change, c'est l'extension du fichier de données.
    Donc, comme c'est le même code, c'est plus simple de ne pas tout reproduire 3 fois. En cas d'évolution, tu auras un seul changement à faire au lieu de 3.
    Pour regrouper ces 3 cas dans une seule ligne, on peut faire CAS "hAccèsNatifXBase" , "hOledbAccess2000" , "hAccèsNatifXML"Tu peux même regrouper ces 3 cas avec le dernier 'AUTRES CAS' .

    Dernier point.
    Au tout début, tu t'embêtes avec :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    SELON sProvider
        CAS "hAccèsHF7"
            sConexion..Provider = hAccèsHF7
        CAS "hAccèsHFClientServeur"
            sConexion..Provider = hAccèsHFClientServeur
        CAS "hOledbSQLServer"
            sConexion..Provider = hOledbSQLServer
        CAS "hOledbAccess97"
            sConexion..Provider = hOledbAccess97
        CAS "hOledbAccess2000"
            sConexion..Provider = hOledbAccess2000
        CAS "hAccèsNatifXBase"
            sConexion..Provider = hAccèsNatifXBase
        CAS "hAccèsNatifMySQL"
            sConexion..Provider = hAccèsNatifMySQL
        CAS "hAccèsNatifSQLServer"
            sConexion..Provider = hAccèsNatifSQLServer
        CAS "hAccèsNatifXML"
            sConexion..Provider = hAccèsNatifXML
        CAS "hODBC"
            sConexion..Provider = hODBC
        AUTRE CAS
            // 
    FIN
    Maintenant que c'est fait, et que ça marche, il n'y a pas de raison de changer quoi que ce soit.
    Mais je pense que tu aurais pu économiser cela, en disant que ta variable sProvider était un entier et non une chaine.
    Dans le programme qui appelle la fonction conectarFIC() , tu pouvais dire directement sProvider = hAccesHF7, au lieu de dire sProvider = "hAccesHF7".
    Tu économisais une vingtaine de lignes dans cette procédure ConectarFIC.

    PS : Sur ce dernier point, je n'ai pas vérifié, je suppose que cette suggestion est possible, mais je n'ai rien testé.
    N'oubliez pas le bouton Résolu si vous avez obtenu une réponse à votre question.

  10. #10
    Membre expérimenté
    Profil pro
    Inscrit en
    Avril 2010
    Messages
    915
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2010
    Messages : 915
    Points : 1 497
    Points
    1 497
    Par défaut
    Merci pour vos conseils, je vais essayer de réduire le code, en particulier vous avez raison sur le dernier point,
    Citation Envoyé par tbc92 Voir le message
    Dernier point.
    Au tout début, tu t'embêtes avec :
    ......
    Citation Envoyé par tbc92 Voir le message

    Mais je pense que tu aurais pu économiser cela, en disant que ta variable sProvider était un entier et non une chaine.
    sauf que l'aide dit :
    <Nom du provider> : Constante de type Chaîne

Discussions similaires

  1. Réponses: 3
    Dernier message: 16/04/2017, 21h22
  2. [ODS] Création d'un rapport sans ouvrir le fichier
    Par laurent_42 dans le forum ODS et reporting
    Réponses: 2
    Dernier message: 04/06/2015, 14h16
  3. Comment récupérer le nom du fichier sans l'extension ?
    Par altahir007 dans le forum Langage
    Réponses: 16
    Dernier message: 13/11/2009, 13h20
  4. [Kylix] Création d'un fichier lien
    Par DrQ dans le forum EDI
    Réponses: 2
    Dernier message: 14/05/2002, 21h30

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo