protected override void OnExternalCommand(string command, string commandData, string eventToken, TelecomScriptInterface tsInterface, CallButler.Telecom.TelecomProviderBase telecomProvider, WOSI.CallButler.Data.DataProviders.CallButlerDataProviderBase dataProvider) { // Parse out our external event action if (Enum.IsDefined(typeof(VoicemailExternalCommands), command)) { VoicemailExternalCommands externalCommand = WOSI.Utilities.EnumUtils <VoicemailExternalCommands> .Parse(command); switch (externalCommand) { case VoicemailExternalCommands.CALLBUTLERINTERNAL_NewVoicemail: { // Create a new voicemail record vmService.CreateVoicemail(new Guid(commandData), new Guid(tsInterface.IMLInterpreter.GetLocalVariable("ExtensionID")), tsInterface.IMLInterpreter.CallerDisplayName, tsInterface.IMLInterpreter.CallerHost, tsInterface.IMLInterpreter.CallerUsername); break; } case VoicemailExternalCommands.CALLBUTLERINTERNAL_VoicemailManagement: { tsInterface.ScriptProcessor = new VoicemailManagementScriptProcessor(extension, registrarService); tsInterface.ScriptProcessor.StartProcessing(tsInterface, telecomProvider, dataProvider); break; } } tsInterface.IMLInterpreter.SignalEventCallback(eventToken); } }
void IMLInterpreter_SyncExternalAction(object sender, WOSI.IVR.IML.SyncExternalActionEventArgs e) { // Parse out our external event action if (Enum.IsDefined(typeof(VoicemailExternalCommands), e.Action)) { VoicemailExternalCommands externalCommand = WOSI.Utilities.EnumUtils <VoicemailExternalCommands> .Parse(e.Action); switch (externalCommand) { case VoicemailExternalCommands.CALLBUTLERINTERNAL_EndExtensionFinder: { // Allow this line to answer calls again tsInterface.Locked = false; tsInterface.IMLInterpreter.SignalExternalEvent(ExtensionExternalEvents.CALLBUTLERINTERNAL_OtherCallerHungUp.ToString()); // Don't subscribe to this event anymore after the call has ended ((WOSI.IVR.IML.IMLInterpreter)sender).SyncExternalAction -= IMLInterpreter_SyncExternalAction; break; } } ((WOSI.IVR.IML.IMLInterpreter)sender).SignalEventCallback(e.EventToken); } }
protected override void OnExternalCommand(string command, string commandData, string eventToken, TelecomScriptInterface tsInterface, CallButler.Telecom.TelecomProviderBase telecomProvider, WOSI.CallButler.Data.DataProviders.CallButlerDataProviderBase dataProvider) { // Parse out our external event action if (Enum.IsDefined(typeof(VoicemailExternalCommands), command)) { VoicemailExternalCommands externalCommand = WOSI.Utilities.EnumUtils <VoicemailExternalCommands> .Parse(command); switch (externalCommand) { case VoicemailExternalCommands.CALLBUTLERINTERNAL_AuthenticatePasscode: { // Check to make sure our passcode matches our extension string enteredPasscodeHash = WOSI.Utilities.CryptoUtils.CreateMD5Hash(commandData); if (enteredPasscodeHash != extension.Password) { tsInterface.IMLInterpreter.SignalExternalEvent(VoicemailExternalEvents.CALLBUTLERINTERNAL_InvalidPasscode.ToString()); } else { // Get our new voicemail count int newVoicemailCount = dataProvider.GetNewVoicemailCount(extension.ExtensionID); tsInterface.IMLInterpreter.SetLocalVariable("NewVoicemailCount", newVoicemailCount.ToString()); tsInterface.IMLInterpreter.SignalExternalEvent(VoicemailExternalEvents.CALLBUTLERINTERNAL_ValidPasscode.ToString()); } break; } case VoicemailExternalCommands.CALLBUTLERINTERNAL_SaveNewGreeting: { WOSI.CallButler.Data.CallButlerDataset.LocalizedGreetingsRow voicemailGreeting = dataProvider.GetLocalizedGreeting(Properties.Settings.Default.CustomerID, extension.ExtensionID, Properties.Settings.Default.DefaultLanguage); string tmpGreetingFilename = commandData; if (File.Exists(tmpGreetingFilename) && voicemailGreeting != null) { // Change our voicemail greeting to a sound file voicemailGreeting.Type = (short)WOSI.CallButler.Data.GreetingType.SoundGreeting; // Move our greeting sound over string greetingDirectory = WOSI.Utilities.FileUtils.GetApplicationRelativePath(Properties.Settings.Default.GreetingSoundRootDirectory) + "\\" + Properties.Settings.Default.DefaultLanguage; string greetingFilename = greetingDirectory + "\\" + voicemailGreeting.GreetingID.ToString() + ".snd"; if (!Directory.Exists(greetingDirectory)) { Directory.CreateDirectory(greetingDirectory); } File.Copy(tmpGreetingFilename, greetingFilename, true); File.Delete(tmpGreetingFilename); voicemailGreeting.Data = WOSI.Utilities.CryptoUtils.GetFileChecksum(greetingFilename); dataProvider.PersistLocalizedGreeting(Properties.Settings.Default.CustomerID, voicemailGreeting); } tsInterface.IMLInterpreter.SignalEventCallback(eventToken); break; } case VoicemailExternalCommands.CALLBUTLERINTERNAL_FetchNextVoicemail: { // Get our voicemail rows WOSI.CallButler.Data.CallButlerDataset.VoicemailsRow[] voicemails = (WOSI.CallButler.Data.CallButlerDataset.VoicemailsRow[])dataProvider.GetVoicemails(extension.ExtensionID).Select("", "Timestamp DESC"); // Get our voicemail message index int voicemailIndex = Convert.ToInt32(tsInterface.IMLInterpreter.GetLocalVariable("VoicemailIndex")); voicemailIndex++; if (voicemailIndex < voicemails.Length) { WOSI.CallButler.Data.CallButlerDataset.VoicemailsRow voicemail = voicemails[voicemailIndex]; // Create our voicemail intro string voicemailIntro = ""; if (voicemailIndex == 0) { voicemailIntro = "First "; } else { voicemailIntro = "Next "; } if (voicemail.IsNew) { voicemailIntro += "New "; } voicemailIntro += "Message received on " + voicemail.Timestamp.ToShortDateString() + " " + voicemail.Timestamp.ToShortTimeString(); tsInterface.IMLInterpreter.SetLocalVariable("VoicemailIntro", voicemailIntro); string voicemailFilename = WOSI.Utilities.FileUtils.GetApplicationRelativePath(Properties.Settings.Default.VoicemailRootDirectory) + "\\" + voicemail.ExtensionID.ToString() + "\\" + voicemail.VoicemailID + ".snd"; tsInterface.IMLInterpreter.SetLocalVariable("VoicemailSound", voicemailFilename); tsInterface.IMLInterpreter.SetLocalVariable("VoicemailIndex", voicemailIndex.ToString()); // Mark the voicemail as read dataProvider.MarkVoicemailRead(voicemail.ExtensionID, voicemail.VoicemailID); if (pbxRegistrar != null) { pbxRegistrar.SendMessageWaitingNotification(voicemail.ExtensionID); } tsInterface.IMLInterpreter.SignalEventCallback(eventToken); } else { tsInterface.IMLInterpreter.SignalExternalEvent(VoicemailExternalEvents.CALLBUTLERINTERNAL_EndOfMessages.ToString()); } break; } case VoicemailExternalCommands.CALLBUTLERINTERNAL_DeleteVoicemail: { // Get our voicemail rows WOSI.CallButler.Data.CallButlerDataset.VoicemailsRow[] voicemails = (WOSI.CallButler.Data.CallButlerDataset.VoicemailsRow[])dataProvider.GetVoicemails(extension.ExtensionID).Select("", "Timestamp DESC"); // Get our voicemail message index int voicemailIndex = Convert.ToInt32(tsInterface.IMLInterpreter.GetLocalVariable("VoicemailIndex")); if (voicemailIndex < voicemails.Length) { WOSI.CallButler.Data.CallButlerDataset.VoicemailsRow voicemail = voicemails[voicemailIndex]; // Delete our voicemail dataProvider.DeleteVoicemail(voicemail.ExtensionID, voicemail.VoicemailID); // Delete our voicemail sound string voicemailFilename = WOSI.Utilities.FileUtils.GetApplicationRelativePath(Properties.Settings.Default.VoicemailRootDirectory) + "\\" + voicemail.ExtensionID.ToString() + "\\" + voicemail.VoicemailID + ".snd"; if (File.Exists(voicemailFilename)) { File.Delete(voicemailFilename); } voicemailIndex--; tsInterface.IMLInterpreter.SetLocalVariable("VoicemailIndex", voicemailIndex.ToString()); if (pbxRegistrar != null) { pbxRegistrar.SendMessageWaitingNotification(voicemail.ExtensionID); } } tsInterface.IMLInterpreter.SignalEventCallback(eventToken); break; } } } }