Aller au contenu

« Astreinte » : différence entre les versions

De INDYWiki
Anthony (discussion | contributions)
Anthony (discussion | contributions)
 
(11 versions intermédiaires par le même utilisateur non affichées)
Ligne 1 : Ligne 1 :
===Principe===
===Principe===
On paramètre le statut choisi pour l'astreinte en renvoi vers '''mon mobile'''. Un script viendra modifier le statut de l'extension cible ainsi que son numéro de contact mobile, prénom et nom. Ce script déclenchable par l'appel à un code court, paramétrable si on le souhaite sur une BLF.  
On paramètre le statut choisi pour l'astreinte en renvoi vers '''mon mobile'''. Un script viendra modifier le statut de l'extension cible ainsi que son numéro de contact mobile, prénom et nom. Ce script déclenchable par l'appel à un code court, paramétrable si on le souhaite sur une BLF.  
===Paramétrage du statut de l'extension vers '''mon mobile'''===
[[Fichier:2026-04-03 13h29 01.png|vignette]]
#Réglages
#Transfert d'appels
#Choisir le statut de l'extension à activer pour enclencher le renvoi vers l'astreinte. Dans l'exemple '''Absent'''. Pas l'état '''Disponible''' évidemment.
#Dans "Transférer les appels externes à", choisir '''Mon mobile'''
#Cocher '''Rebond'''


===Déclaration du script===
===Déclaration du script===
Ligne 47 : Ligne 40 :
         // ============================================================
         // ============================================================
         private const string TARGET_EXT  = "111";
         private const string TARGET_EXT  = "111";
         private const string MOBILE_ELU   = "0612345678";
         private const string MOBILE_EXT   = "0612345678";
         private const string PRENOM_ELU   = "Claude";
         private const string PRENOM_EXT   = "Claude";
         private const string NOM_ELU     = "IA";
         private const string NOM_EXT     = "IA";
        private const string PROFILE_NAME = "Away";
// ============================================================
        // ============================================================
       
 
private const string PROFILE_NAME = "Away";
     
         public override Task<bool> StartAsync()
         public override Task<bool> StartAsync()
         {
         {
Ligne 63 : Ligne 57 :


                 // 1. Nom / Prénom
                 // 1. Nom / Prénom
                 ext.FirstName = PRENOM_ELU;
                 ext.FirstName = PRENOM_EXT;
                 ext.LastName  = NOM_ELU;
                 ext.LastName  = NOM_EXT;


                 // 2. Numéro mobile
                 // 2. Numéro mobile
                 ext.SetProperty("MOBILENUMBER", MOBILE_ELU);
                 ext.SetProperty("MOBILENUMBER", MOBILE_EXT);


                 // 3. Trouver le profil Away
                 // 3. Trouver le profil Away
Ligne 90 : Ligne 84 :
                     DestinationStruct destInternal = internalHours.AllHours;
                     DestinationStruct destInternal = internalHours.AllHours;
                     destInternal.To              = DestinationType.Boomerang;
                     destInternal.To              = DestinationType.Boomerang;
                     destInternal.External        = MOBILE_ELU;
                     destInternal.External        = MOBILE_EXT;
                     internalHours.AllHours        = destInternal;
                     internalHours.AllHours        = destInternal;


                     DestinationStruct destExternal = externalHours.AllHours;
                     DestinationStruct destExternal = externalHours.AllHours;
                     destExternal.To              = DestinationType.Boomerang;
                     destExternal.To              = DestinationType.Boomerang;
                     destExternal.External        = MOBILE_ELU;
                     destExternal.External        = MOBILE_EXT;
                     externalHours.AllHours        = destExternal;
                     externalHours.AllHours        = destExternal;
                 }
                 }
Ligne 128 : Ligne 122 :
</syntaxhighlight>
</syntaxhighlight>


====Table de correspondance des profileName====
===Le script de retour à la normale===
 
<syntaxhighlight lang="csharp" line highlight="14-16">
using System;
using System.Threading.Tasks;
using TCX.Configuration;
using CallFlow;
using System.Linq;


{| class="wikitable"
namespace dummy
|-
{
! Dans 3CX!! Dans le script
    public class ResetAstreinte : ScriptBase<ResetAstreinte>
|-
    {
| Disponible|| Available
        // ============================================================
|-
        // CONFIGURATION — modifier uniquement ces lignes par script
| Absent|| Away
        // ============================================================
|-
        private const string TARGET_EXT  = "111";
| Ne pas déranger|| Out of office
        private const string PRENOM_EXT  = "Accueil";
|-
        private const string NOM_EXT      = "Mairie";
| Custom 1|| Custom 1
        // ============================================================
|-
 
| Custom 2|| Custom 2
        public override Task<bool> StartAsync()
|}
        {
            try
            {
                IPhoneSystem ps = PhoneSystem.Root;
                Extension ext = ps.GetDNByNumber(TARGET_EXT) as Extension;
                if (ext == null)
                    return Task.FromResult(false);
 
                // 1. Remettre le nom générique
                ext.FirstName = PRENOM_EXT;
                ext.LastName  = NOM_EXT;
 
                // 2. Vider le numéro mobile
                ext.SetProperty("MOBILENUMBER", "");
 
                // 3. Résoudre le DN pour la messagerie vocale
                DN targetDN = ps.GetDNByNumber(TARGET_EXT);
 
                // 4. Remettre AwayRoute → messagerie vocale
                FwdProfile awayProfile = ext.FwdProfiles
                    .FirstOrDefault(p => p.Name.Equals(
                        "Away", StringComparison.OrdinalIgnoreCase));
 
                if (awayProfile != null)
                {
                    AwayRouting route = awayProfile.AwayRoute;


===Configuration concrète===
                    HoursDestination internalHours = route.Internal;
                    HoursDestination externalHours = route.External;


Il faut choisir un statut autre que "Disponible" qui sera activé pour l'astreinte, "Away" pour cet exemple
                    DestinationStruct destInternal = internalHours.AllHours;
                    destInternal.To              = DestinationType.VoiceMail;
                    destInternal.Internal        = targetDN;
                    destInternal.External        = "";
                    internalHours.AllHours        = destInternal;


On a besoin de gérer deux astreintes. Le poste Accueil reçoit les appels en temps normal
                    DestinationStruct destExternal = externalHours.AllHours;
                    destExternal.To              = DestinationType.VoiceMail;
                    destExternal.Internal        = targetDN;
                    destExternal.External        = "";
                    externalHours.AllHours        = destExternal;
                }
 
                // 5. Sauvegarder
                ext.Save();


{| class="wikitable"
                // 6. Recharger et basculer vers Available
|+ Texte de la légende
                ext = ps.GetDNByNumber(TARGET_EXT) as Extension;
|-
                if (ext == null)
|'''Marcel Patulacci''' || '''Jean-Michel Apeuprè'''|| '''Poste accueil ''' hors période d'astreinte
                    return Task.FromResult(false);
|-
| <syntaxhighlight lang="csharp" line highlight="3-5,8-9">
public override Task<bool> StartAsync()
        {
            string targetExtNum = "100";
            string mobileElu = "0699999999";
            string profileName = "Away";  


            // Nommage de l'astreinte
                FwdProfile profile = ext.FwdProfiles
            string prenomElu = "Marcel";
                    .FirstOrDefault(p => p.Name.Equals(
            string nomElu = "Patulacci";  
                        "Available", StringComparison.OrdinalIgnoreCase));


            try
                if (profile != null)
</syntaxhighlight> || <syntaxhighlight lang="csharp" line highlight="3-5,8-9">
                {
public override Task<bool> StartAsync()
                    ext.CurrentProfile = profile;
        {
                    ext.Save();
            string targetExtNum = "100";  
                }
            string mobileElu = "0688888888";
            string profileName = "Away";


             // Nommage de l'astreinte
                return Task.FromResult(true);
             string prenomElu = "Jean-Michel";  
            }
             string nomElu = "Apeuprè";
             catch (Exception)
             {
                return Task.FromResult(false);
             }
        }
    }
}
</syntaxhighlight>


            try
===Configuration concrète===
</syntaxhighlight>|| <syntaxhighlight lang="csharp" line highlight="3-5,8-9">
public override Task<bool> StartAsync()
        {
            string targetExtNum = "100";
            string mobileElu = "";
            string profileName = "Available";


            // Nommage de l'astreinte
On a besoin de gérer deux astreintes. Le poste Accueil reçoit les appels en temps normal
            string prenomElu = "Accueil";
            string nomElu = "";


            try
{| class="wikitable"
|+ Extraits de chaque script
|-
|'''Marcel Patulacci''' || '''Jean-Michel Apeuprè'''|| '''Poste accueil ''' hors période d'astreinte
|-
| <syntaxhighlight lang="csharp" line highlight="4-7">
public class SetDynamicAstreinte : ScriptBase<SetDynamicAstreinte>
{
// modifier uniquement ces lignes :
private const string TARGET_EXT  = "111";
private const string MOBILE_EXT  = "0612345678";
private const string PRENOM_EXT  = "Marcel";
private const string NOM_EXT      = "Patulacci";
</syntaxhighlight> || <syntaxhighlight lang="csharp" line highlight="4-7">
public class SetDynamicAstreinte : ScriptBase<SetDynamicAstreinte>
{
// Modifier uniquement ces lignes
private const string TARGET_EXT  = "111";
private const string MOBILE_EXT  = "0699999999";
private const string PRENOM_EXT  = "Jean-Michel";
private const string NOM_EXT      = "Apeuprè";
</syntaxhighlight>|| <syntaxhighlight lang="csharp" line highlight="4-6">
public class ResetAstreinte : ScriptBase<ResetAstreinte>
{
// Modifier uniquement ces lignes :
private const string TARGET_EXT  = "111";
private const string PRENOM_EXT  = "Accueil";
private const string NOM_EXT      = "Mairie";
</syntaxhighlight>
</syntaxhighlight>
|}
|}

Dernière version du 27 mai 2026 à 15:56

Principe

On paramètre le statut choisi pour l'astreinte en renvoi vers mon mobile. Un script viendra modifier le statut de l'extension cible ainsi que son numéro de contact mobile, prénom et nom. Ce script déclenchable par l'appel à un code court, paramétrable si on le souhaite sur une BLF.

Déclaration du script

Rendez-vous dans :

Admin / Intégrations / Scripts d'appels / + Ajouter personnalisé
  1. Donner un nom au traitement de l'appel. Exemple : astreinte_weekend
  2. Créer un code de raccourci, ce qui permettra d'exécuter le script simplement en appelant ce code, et in fine par une BLF. Exemple : *99
  3. OK
  4. Coller dans le champ script le script paramétré ( voir section suivante )
  5. Sauvegarder
  6. Un message doit indiquer Compilation réussie !



Le script d'astreinte

L'éxécution du script va modifier l'extension targetExtNum , il va le basculer sur le statut profileName , modifier son mobile de contact mobileElu , son nom et prénom.

Il faut donc seulement modifier les lignes surlignés dans le code ci-dessous :

using System;
using System.Threading.Tasks;
using TCX.Configuration;
using CallFlow;
using System.Linq;

namespace dummy
{
    public class SetDynamicAstreinte : ScriptBase<SetDynamicAstreinte>
    {
        // ============================================================
        // CONFIGURATION — modifier uniquement ces lignes par script
        // ============================================================
        private const string TARGET_EXT   = "111";
        private const string MOBILE_EXT   = "0612345678";
        private const string PRENOM_EXT   = "Claude";
        private const string NOM_EXT      = "IA";
		 // ============================================================
        
		private const string PROFILE_NAME = "Away";
       
        public override Task<bool> StartAsync()
        {
            try
            {
                IPhoneSystem ps = PhoneSystem.Root;
                Extension ext = ps.GetDNByNumber(TARGET_EXT) as Extension;
                if (ext == null)
                    return Task.FromResult(false);

                // 1. Nom / Prénom
                ext.FirstName = PRENOM_EXT;
                ext.LastName  = NOM_EXT;

                // 2. Numéro mobile
                ext.SetProperty("MOBILENUMBER", MOBILE_EXT);

                // 3. Trouver le profil Away
                FwdProfile targetProfile = ext.FwdProfiles
                    .FirstOrDefault(p => p.Name.Equals(
                        PROFILE_NAME, StringComparison.OrdinalIgnoreCase));

                if (targetProfile != null)
                {
                    // AwayRoute, Internal, External sont read-only
                    // mais ce sont des références : on peut modifier
                    // leurs membres si ceux-ci sont accessibles en écriture
                    AwayRouting route = targetProfile.AwayRoute;

                    // Capturer les HoursDestination comme variables locales
                    // (objets référence — la propriété est read-only,
                    //  mais l'objet pointé est modifiable)
                    HoursDestination internalHours = route.Internal;
                    HoursDestination externalHours = route.External;

                    // Capturer AllHours (struct) → modifier → réassigner
                    DestinationStruct destInternal = internalHours.AllHours;
                    destInternal.To               = DestinationType.Boomerang;
                    destInternal.External         = MOBILE_EXT;
                    internalHours.AllHours        = destInternal;

                    DestinationStruct destExternal = externalHours.AllHours;
                    destExternal.To               = DestinationType.Boomerang;
                    destExternal.External         = MOBILE_EXT;
                    externalHours.AllHours        = destExternal;
                }

                // 4. Sauvegarder
                ext.Save();

                // 5. Recharger et basculer le profil
                ext = ps.GetDNByNumber(TARGET_EXT) as Extension;
                if (ext == null)
                    return Task.FromResult(false);

                FwdProfile profile = ext.FwdProfiles
                    .FirstOrDefault(p => p.Name.Equals(
                        PROFILE_NAME, StringComparison.OrdinalIgnoreCase));

                if (profile != null)
                {
                    ext.CurrentProfile = profile;
                    ext.Save();
                }

                return Task.FromResult(true);
            }
            catch (Exception)
            {
                return Task.FromResult(false);
            }
        }
    }
}

Le script de retour à la normale

using System;
using System.Threading.Tasks;
using TCX.Configuration;
using CallFlow;
using System.Linq;

namespace dummy
{
    public class ResetAstreinte : ScriptBase<ResetAstreinte>
    {
        // ============================================================
        // CONFIGURATION — modifier uniquement ces lignes par script
        // ============================================================
        private const string TARGET_EXT   = "111";
        private const string PRENOM_EXT   = "Accueil";
        private const string NOM_EXT      = "Mairie";
        // ============================================================

        public override Task<bool> StartAsync()
        {
            try
            {
                IPhoneSystem ps = PhoneSystem.Root;
                Extension ext = ps.GetDNByNumber(TARGET_EXT) as Extension;
                if (ext == null)
                    return Task.FromResult(false);

                // 1. Remettre le nom générique
                ext.FirstName = PRENOM_EXT;
                ext.LastName  = NOM_EXT;

                // 2. Vider le numéro mobile
                ext.SetProperty("MOBILENUMBER", "");

                // 3. Résoudre le DN pour la messagerie vocale
                DN targetDN = ps.GetDNByNumber(TARGET_EXT);

                // 4. Remettre AwayRoute → messagerie vocale
                FwdProfile awayProfile = ext.FwdProfiles
                    .FirstOrDefault(p => p.Name.Equals(
                        "Away", StringComparison.OrdinalIgnoreCase));

                if (awayProfile != null)
                {
                    AwayRouting route = awayProfile.AwayRoute;

                    HoursDestination internalHours = route.Internal;
                    HoursDestination externalHours = route.External;

                    DestinationStruct destInternal = internalHours.AllHours;
                    destInternal.To               = DestinationType.VoiceMail;
                    destInternal.Internal         = targetDN;
                    destInternal.External         = "";
                    internalHours.AllHours        = destInternal;

                    DestinationStruct destExternal = externalHours.AllHours;
                    destExternal.To               = DestinationType.VoiceMail;
                    destExternal.Internal         = targetDN;
                    destExternal.External         = "";
                    externalHours.AllHours        = destExternal;
                }

                // 5. Sauvegarder
                ext.Save();

                // 6. Recharger et basculer vers Available
                ext = ps.GetDNByNumber(TARGET_EXT) as Extension;
                if (ext == null)
                    return Task.FromResult(false);

                FwdProfile profile = ext.FwdProfiles
                    .FirstOrDefault(p => p.Name.Equals(
                        "Available", StringComparison.OrdinalIgnoreCase));

                if (profile != null)
                {
                    ext.CurrentProfile = profile;
                    ext.Save();
                }

                return Task.FromResult(true);
            }
            catch (Exception)
            {
                return Task.FromResult(false);
            }
        }
    }
}

Configuration concrète

On a besoin de gérer deux astreintes. Le poste Accueil reçoit les appels en temps normal

Extraits de chaque script
Marcel Patulacci Jean-Michel Apeuprè Poste accueil hors période d'astreinte
public class SetDynamicAstreinte : ScriptBase<SetDynamicAstreinte>
{
 // modifier uniquement ces lignes :
private const string TARGET_EXT   = "111";
private const string MOBILE_EXT   = "0612345678";
private const string PRENOM_EXT   = "Marcel";
private const string NOM_EXT      = "Patulacci";
public class SetDynamicAstreinte : ScriptBase<SetDynamicAstreinte>
{
// Modifier uniquement ces lignes
private const string TARGET_EXT   = "111";
private const string MOBILE_EXT   = "0699999999";
private const string PRENOM_EXT   = "Jean-Michel";
private const string NOM_EXT      = "Apeuprè";
public class ResetAstreinte : ScriptBase<ResetAstreinte>
{
// Modifier uniquement ces lignes :
private const string TARGET_EXT   = "111";
private const string PRENOM_EXT   = "Accueil";
private const string NOM_EXT      = "Mairie";

Une fois les 3 scripts produits, passer à l'étape Déclaration du script qui va permettre d'affecter un code court à chaque script. Exemple :

  • *90 pour hors période d'astreinte
  • *91 pour Jean-Michel
  • *92 pour Marcel

On peut communiquer les codes aux personnes habilitées à gérer le système d'astreinte et aller jusqu'à paramétrer des BLF pour faciliter la vie d'une secrétaire par exemple.

Valide v20