« Astreinte » : différence entre les versions
Apparence
Page créée avec « == par les statuts == == via script== Catégorie:3CX » |
|||
| Ligne 1 : | Ligne 1 : | ||
== par les statuts == | == par les statuts == | ||
== via script== | == via script== | ||
<code> | |||
using System; | |||
using System.Threading.Tasks; | |||
using TCX.Configuration; | |||
using CallFlow; | |||
using System.Linq; | |||
using System.Collections.Generic; | |||
namespace dummy | |||
{ | |||
public class SetDynamicAstreinte : ScriptBase<SetDynamicAstreinte> | |||
{ | |||
public override Task<bool> StartAsync() | |||
{ | |||
string targetExtNum = "111"; | |||
string mobileElu = "0743031843"; | |||
string profileName = "Away"; | |||
// --- AJOUT : Nommage de l'astreinte --- | |||
string prenomElu = "ASTREINTE"; | |||
string nomElu = "ELU 6"; // Changez ceci pour chaque élu (ex: "DUPONT", "MAIRE", etc.) | |||
try | |||
{ | |||
IPhoneSystem ps = PhoneSystem.Root; | |||
Extension targetExt = ps.GetDNByNumber(targetExtNum) as Extension; | |||
if (targetExt != null) | |||
{ | |||
// 1. Mise à jour du numéro de mobile | |||
targetExt.SetProperty("MOBILENUMBER", mobileElu); | |||
// 2. MISE À JOUR DU NOM (Affichage sur les téléphones) | |||
targetExt.FirstName = prenomElu; | |||
targetExt.LastName = nomElu; | |||
// 3. Changement du profil de statut | |||
var profile = targetExt.FwdProfiles.FirstOrDefault(p => p.Name.Equals(profileName, StringComparison.OrdinalIgnoreCase)); | |||
if (profile != null) | |||
{ | |||
targetExt.CurrentProfile = profile; | |||
} | |||
// 4. Sauvegarde globale | |||
targetExt.ResetCurrentProfileOverride(); | |||
targetExt.Save(); | |||
return Task.FromResult(true); | |||
} | |||
} | |||
catch (Exception) | |||
{ | |||
// Erreur silencieuse | |||
} | |||
return Task.FromResult(false); | |||
} | |||
} | |||
}</code> | |||
[[Catégorie:3CX]] | [[Catégorie:3CX]] | ||
Version du 1 avril 2026 à 16:56
par les statuts
via script
using System;
using System.Threading.Tasks;
using TCX.Configuration;
using CallFlow;
using System.Linq;
using System.Collections.Generic;
namespace dummy
{
public class SetDynamicAstreinte : ScriptBase<SetDynamicAstreinte>
{
public override Task<bool> StartAsync()
{
string targetExtNum = "111";
string mobileElu = "0743031843";
string profileName = "Away";
// --- AJOUT : Nommage de l'astreinte ---
string prenomElu = "ASTREINTE";
string nomElu = "ELU 6"; // Changez ceci pour chaque élu (ex: "DUPONT", "MAIRE", etc.)
try
{
IPhoneSystem ps = PhoneSystem.Root;
Extension targetExt = ps.GetDNByNumber(targetExtNum) as Extension;
if (targetExt != null)
{
// 1. Mise à jour du numéro de mobile
targetExt.SetProperty("MOBILENUMBER", mobileElu);
// 2. MISE À JOUR DU NOM (Affichage sur les téléphones)
targetExt.FirstName = prenomElu;
targetExt.LastName = nomElu;
// 3. Changement du profil de statut
var profile = targetExt.FwdProfiles.FirstOrDefault(p => p.Name.Equals(profileName, StringComparison.OrdinalIgnoreCase));
if (profile != null)
{
targetExt.CurrentProfile = profile;
}
// 4. Sauvegarde globale
targetExt.ResetCurrentProfileOverride();
targetExt.Save();
return Task.FromResult(true);
}
}
catch (Exception)
{
// Erreur silencieuse
}
return Task.FromResult(false);
}
}
}