// immer alles zwischen dem 'try' und dem folgenden '{' (so in etwa ab Zeile 22) und dem abschließenden '}' mit felgendem Inhalt ersetzen
// #60 reset all departments to default hours operation
PhoneSystem ps = MyCall.PS as PhoneSystem;
ps.GetAll<Group>().Where(x=>x.AllowCallService).Select(x=>
{
//WARNING: time check will be available in v20 SP1+
//This script will not be compilable in earlier versions
// x.OverrideExpiresAt=x.Now(out var utc, out var timezone, out var groupmode);
//it is not required to update mode, because it is ignored after OverrideExpiresAt time
var timezone=TimeZoneInfo.Local;
x.CurrentGroupHours = x.CurrentGroupHours & ~GroupHoursMode.HasForcedMask;
// MyCall.Info($"{x.Name} reset to '{x.CurrentGroupHours}' until {x.OverrideExpiresAt} @ time:utc={utc}, timezone={timezone}, groupmode={groupmode}");
return x;
}).OMSave();
var result = await MyCall.AssureMedia().ContinueWith(_ => MyCall.PlayPrompt(null, new[] { "Empty.wav", "ST_AWAY_SET" }, PlayPromptOptions.Blocked), TaskContinuationOptions.OnlyOnRanToCompletion).Unwrap();
MyCall.Return(true);
// #61 force all departments to In-office hours.
PhoneSystem ps = MyCall.PS as PhoneSystem;
//in this example, all groups will be overrides to the end of the day in "global" PBX timezone
var PBXLocalTimeEndOfOverride = DateTime.Now.Date+new TimeSpan(23, 59,59);
ps.GetAll<Group>().Where(x=>x.AllowCallService).Select(x=>
{
//WARNING: time check will be available in v20 SP1+
//This script will not be compilable in earlier versions
// var groupCurrentTime = x.Now(out var utc, out var timezone, out var groupmode);
var timezone=TimeZoneInfo.Local;
x.OverrideExpiresAt = TimeZoneInfo.ConvertTime(PBXLocalTimeEndOfOverride, timezone);
x.CurrentGroupHours = GroupHoursMode.ForceOpened;
// MyCall.Info($"{x.Name} reset to '{x.CurrentGroupHours}' until {x.OverrideExpiresAt} @ time:utc={utc}, timezone={timezone}, groupmode={groupmode}");
return x;
}).OMSave();
var result = await MyCall.AssureMedia().ContinueWith(_ => MyCall.PlayPrompt(null, new[] { "Empty.wav", "ST_AVAILABLE_SET" }, PlayPromptOptions.Blocked), TaskContinuationOptions.OnlyOnRanToCompletion).Unwrap();
MyCall.Return(true);
// #62 force all departments to Out-of office hours.
PhoneSystem ps = MyCall.PS as PhoneSystem;
//in this example, all groups will be overrides to the end of the day in "global" PBX timezone
var PBXLocalTimeEndOfOverride = DateTime.Now.Date+new TimeSpan(23, 59,59);
ps.GetAll<Group>().Where(x=>x.AllowCallService).Select(x=>
{
//WARNING: time check will be available in v20 SP1+
//This script will not be compilable in earlier versions
// groupCurrentTime = x.Now(out var utc, out var timezone, out var groupmode);
var timezone=TimeZoneInfo.Local;
x.OverrideExpiresAt = TimeZoneInfo.ConvertTime(PBXLocalTimeEndOfOverride, timezone);
x.CurrentGroupHours = GroupHoursMode.ForceClosed;
// MyCall.Info($"{x.Name} reset to '{x.CurrentGroupHours}' until {x.OverrideExpiresAt} @ time:utc={utc}, timezone={timezone}, groupmode={groupmode}");
return x;
}).OMSave();
var result = await MyCall.AssureMedia().ContinueWith(_ => MyCall.PlayPrompt(null, new[] { "Empty.wav", "ST_AWAY_SET" }, PlayPromptOptions.Blocked), TaskContinuationOptions.OnlyOnRanToCompletion).Unwrap();
MyCall.Return(true);
// #63 force all departments to Break- time.
PhoneSystem ps = MyCall.PS as PhoneSystem;
//in this example, all groups will be overrides to the end of the day in "global" PBX timezone
var PBXLocalTimeEndOfOverride = DateTime.Now.Date+new TimeSpan(23, 59,59);
ps.GetAll<Group>().Where(x=>x.AllowCallService).Select(x=>
{
//WARNING: time check will be available in v20 SP1+
//This script will not be compilable in earlier versions
// var groupCurrentTime = x.Now(out var utc, out var timezone, out var groupmode);
var timezone=TimeZoneInfo.Local;
x.OverrideExpiresAt = TimeZoneInfo.ConvertTime(PBXLocalTimeEndOfOverride, timezone);
x.CurrentGroupHours = GroupHoursMode.ForceBreak;
// MyCall.Info($"{x.Name} reset to '{x.CurrentGroupHours}' until {x.OverrideExpiresAt} @ time:utc={utc}, timezone={timezone}, groupmode={groupmode}");
return x;
}).OMSave();
var result = await MyCall.AssureMedia().ContinueWith(_ => MyCall.PlayPrompt(null, new[] { "Empty.wav", "ST_AWAY_SET" }, PlayPromptOptions.Blocked), TaskContinuationOptions.OnlyOnRanToCompletion).Unwrap();
MyCall.Return(true);
// #64 force all departments to Holiday-time.
PhoneSystem ps = MyCall.PS as PhoneSystem;
//in this example, all groups will be overrides to the end of the day in "global" PBX timezone
var PBXLocalTimeEndOfOverride = DateTime.Now.Date+new TimeSpan(23, 59,59);
ps.GetAll<Group>().Where(x=>x.AllowCallService).Select(x=>
{
//WARNING: time check will be available in v20 SP1+
//This script will not be compilable in earlier versions
//var groupCurrentTime = x.Now(out var utc, out var timezone, out var groupmode);
//var timezone=TimeZoneInfo.Local;
//x.OverrideExpiresAt = TimeZoneInfo.ConvertTime(PBXLocalTimeEndOfOverride, timezone);
x.CurrentGroupHours = GroupHoursMode.ForceHoliday;
// MyCall.Info($"{x.Name} reset to '{x.CurrentGroupHours}' until {x.OverrideExpiresAt} @ time:utc={utc}, timezone={timezone}, groupmode={groupmode}");
return x;
}).OMSave();
var result = await MyCall.AssureMedia().ContinueWith(_ => MyCall.PlayPrompt(null, new[] { "Empty.wav", "ST_AWAY_SET" }, PlayPromptOptions.Blocked), TaskContinuationOptions.OnlyOnRanToCompletion).Unwrap();
MyCall.Return(true);