« Astreinte » : différence entre les versions
mAucun résumé des modifications |
|||
| (14 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. | ||
===Déclaration du script=== | ===Déclaration du script=== | ||
| Ligne 42 : | Ligne 19 : | ||
===Le script=== | ===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. | 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. | ||
| Ligne 48 : | Ligne 25 : | ||
Il faut donc seulement modifier les lignes surlignés dans le code ci-dessous : | Il faut donc seulement modifier les lignes surlignés dans le code ci-dessous : | ||
<syntaxhighlight lang="csharp" line highlight="14- | <syntaxhighlight lang="csharp" line highlight="14-17"> | ||
using System; | using System; | ||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||
| Ligne 54 : | Ligne 31 : | ||
using CallFlow; | using CallFlow; | ||
using System.Linq; | using System.Linq; | ||
namespace dummy | namespace dummy | ||
| Ligne 60 : | Ligne 36 : | ||
public class SetDynamicAstreinte : ScriptBase<SetDynamicAstreinte> | 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() | public override Task<bool> StartAsync() | ||
{ | { | ||
try | try | ||
{ | { | ||
IPhoneSystem ps = PhoneSystem.Root; | IPhoneSystem ps = PhoneSystem.Root; | ||
Extension | 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 ( | 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; | |||
} | |||
return Task.FromResult( | // 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) | catch (Exception) | ||
{ | { | ||
return Task.FromResult(false); | |||
} | } | ||
} | } | ||
} | } | ||
| Ligne 109 : | Ligne 122 : | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== | ===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; | |||
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); | |||
} | |||
} | |||
} | |||
} | |||
</syntaxhighlight> | |||
===Configuration concrète=== | |||
On a besoin de gérer deux astreintes. Le poste Accueil reçoit les appels en temps normal | |||
{| 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é
- Donner un nom au traitement de l'appel. Exemple : astreinte_weekend
- 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
- OK
- Coller dans le champ script le script paramétré ( voir section suivante )
- Sauvegarder
- 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
| 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.
| v20 |