public TransferConferenceScriptProcessor(int conferenceID, ScriptService scriptService, ScriptProcessing.TelecomScriptInterface callerTsInterface, PBXRegistrarService pbxRegistrar, WOSI.CallButler.Data.CallButlerDataset.ExtensionsRow extension, VoicemailMailerService vmMailerService)
 {
     this.callerTsInterface = callerTsInterface;
     this.vmMailerService = vmMailerService;
     this.scriptService = scriptService;
     this.conferenceID = conferenceID;
     this.pbxRegistrar = pbxRegistrar;
     this.extension = extension;
 }
 public TransferConferenceScriptProcessor(int conferenceID, ScriptService scriptService, ScriptProcessing.TelecomScriptInterface callerTsInterface, PBXRegistrarService pbxRegistrar, WOSI.CallButler.Data.CallButlerDataset.ExtensionsRow extension, VoicemailMailerService vmMailerService)
 {
     this.callerTsInterface = callerTsInterface;
     this.vmMailerService   = vmMailerService;
     this.scriptService     = scriptService;
     this.conferenceID      = conferenceID;
     this.pbxRegistrar      = pbxRegistrar;
     this.extension         = extension;
 }
        public override void OnIncomingTransfer(CallButler.Telecom.TelecomProviderBase telcomProvider, CallButler.Telecom.TransferEventArgs e)
        {
            if (e.ReplacementLineNumber != 0)
            {
                // Find the ts interface for the call from this extension to our remote caller
                TelecomScriptInterface remoteTsInterface = scriptService.TelecomScriptInterfaces[e.ReplacementLineNumber];

                // Find the ts interface for the remote caller
                if (remoteTsInterface.ScriptProcessor is TransferConferenceScriptProcessor)
                {
                    TransferConferenceScriptProcessor remoteProcessor = (TransferConferenceScriptProcessor)remoteTsInterface.ScriptProcessor;

                    int remoteLineNumber = remoteProcessor.callerTsInterface.LineNumber;

                    remoteProcessor.callerTsInterface = null;

                    if (scriptService.TelecomScriptInterfaces[remoteLineNumber].ScriptProcessor is TransferConferenceScriptProcessor)
                    {
                        remoteTsInterface = scriptService.TelecomScriptInterfaces[remoteLineNumber];
                        remoteProcessor   = (TransferConferenceScriptProcessor)remoteTsInterface.ScriptProcessor;

                        // Conference the two lines together
                        remoteProcessor.callerTsInterface = callerTsInterface;

                        if (callerTsInterface.ScriptProcessor is TransferConferenceScriptProcessor)
                        {
                            ((TransferConferenceScriptProcessor)callerTsInterface.ScriptProcessor).callerTsInterface = remoteProcessor.tsInterface;
                        }

                        remoteProcessor.conferenceID = conferenceID;

                        telcomProvider.AddLineToConference(conferenceID, remoteProcessor.tsInterface.LineNumber);
                        telcomProvider.RemoveLineFromConference(tsInterface.LineNumber);

                        // Tell the other caller to stop hold music
                        callerTsInterface.IMLInterpreter.SignalExternalEvent(TransferConferenceExternalEvents.CALLBUTLERINTERNAL_UnholdCall.ToString());

                        //this.conferenceID = 0;

                        this.callerTsInterface = null;

                        telcomProvider.EndCall(e.ReplacementLineNumber);
                        telcomProvider.EndCall(tsInterface.LineNumber);

                        return;
                    }
                }

                callerTsInterface.IMLInterpreter.SignalTransferFailure();
            }
            else
            {
                TransferCaller(telcomProvider, e.CallingToNumber);
            }
        }
        protected override void OnStartProcessing(TelecomScriptInterface tsInterface, CallButler.Telecom.TelecomProviderBase telecomProvider, WOSI.CallButler.Data.DataProviders.CallButlerDataProviderBase dataProvider)
        {
            this.tsInterface = tsInterface;

            string scriptLocation = WOSI.Utilities.FileUtils.GetApplicationRelativePath(Properties.Settings.Default.SystemScriptsRootDirectory) + "\\Transfer Conference.xml";

            if (File.Exists(scriptLocation))
            {
                IMLScript imlScript = IMLScript.OpenScript(scriptLocation);

                tsInterface.IMLInterpreter.SetLocalVariable("HoldMusicLocation", WOSI.Utilities.FileUtils.GetApplicationRelativePath(Properties.Settings.Default.HoldMusicRootDirectory));

                // Set our recording path
                tsInterface.IMLInterpreter.SetLocalVariable("RecordingPath", WOSI.Utilities.FileUtils.GetApplicationRelativePath(Properties.Settings.Default.CallRecordingSoundPath));
                tsInterface.IMLInterpreter.SetLocalVariable("ExtensionID", extension.ExtensionID.ToString());

                tsInterface.IMLInterpreter.StartScript(imlScript, WOSI.Utilities.FileUtils.GetApplicationRelativePath(Properties.Settings.Default.SystemScriptsRootDirectory));
            }
        }
        protected override void OnStartProcessing(TelecomScriptInterface tsInterface, CallButler.Telecom.TelecomProviderBase telecomProvider, WOSI.CallButler.Data.DataProviders.CallButlerDataProviderBase dataProvider)
        {
            this.tsInterface = tsInterface;

            string scriptLocation = WOSI.Utilities.FileUtils.GetApplicationRelativePath(Properties.Settings.Default.SystemScriptsRootDirectory) + "\\Transfer Conference.xml";

            if (File.Exists(scriptLocation))
            {
                IMLScript imlScript = IMLScript.OpenScript(scriptLocation);

                tsInterface.IMLInterpreter.SetLocalVariable("HoldMusicLocation", WOSI.Utilities.FileUtils.GetApplicationRelativePath(Properties.Settings.Default.HoldMusicRootDirectory));

                // Set our recording path
                tsInterface.IMLInterpreter.SetLocalVariable("RecordingPath", WOSI.Utilities.FileUtils.GetApplicationRelativePath(Properties.Settings.Default.CallRecordingSoundPath));
                tsInterface.IMLInterpreter.SetLocalVariable("ExtensionID", extension.ExtensionID.ToString());

                tsInterface.IMLInterpreter.StartScript(imlScript, WOSI.Utilities.FileUtils.GetApplicationRelativePath(Properties.Settings.Default.SystemScriptsRootDirectory));
            }
        }
        public override void OnIncomingTransfer(CallButler.Telecom.TelecomProviderBase telcomProvider, CallButler.Telecom.TransferEventArgs e)
        {
            if (e.ReplacementLineNumber != 0)
            {
                // Find the ts interface for the call from this extension to our remote caller
                TelecomScriptInterface remoteTsInterface = scriptService.TelecomScriptInterfaces[e.ReplacementLineNumber];

                // Find the ts interface for the remote caller
                if (remoteTsInterface.ScriptProcessor is TransferConferenceScriptProcessor)
                {
                    TransferConferenceScriptProcessor remoteProcessor = (TransferConferenceScriptProcessor)remoteTsInterface.ScriptProcessor;

                    int remoteLineNumber = remoteProcessor.callerTsInterface.LineNumber;

                    remoteProcessor.callerTsInterface = null;

                    if (scriptService.TelecomScriptInterfaces[remoteLineNumber].ScriptProcessor is TransferConferenceScriptProcessor)
                    {
                        remoteTsInterface = scriptService.TelecomScriptInterfaces[remoteLineNumber];
                        remoteProcessor = (TransferConferenceScriptProcessor)remoteTsInterface.ScriptProcessor;

                        // Conference the two lines together
                        remoteProcessor.callerTsInterface = callerTsInterface;

                        if (callerTsInterface.ScriptProcessor is TransferConferenceScriptProcessor)
                            ((TransferConferenceScriptProcessor)callerTsInterface.ScriptProcessor).callerTsInterface = remoteProcessor.tsInterface;

                        remoteProcessor.conferenceID = conferenceID;

                        telcomProvider.AddLineToConference(conferenceID, remoteProcessor.tsInterface.LineNumber);
                        telcomProvider.RemoveLineFromConference(tsInterface.LineNumber);

                        // Tell the other caller to stop hold music
                        callerTsInterface.IMLInterpreter.SignalExternalEvent(TransferConferenceExternalEvents.CALLBUTLERINTERNAL_UnholdCall.ToString());

                        //this.conferenceID = 0;

                        this.callerTsInterface = null;

                        telcomProvider.EndCall(e.ReplacementLineNumber);
                        telcomProvider.EndCall(tsInterface.LineNumber);

                        return;
                    }
                }

                callerTsInterface.IMLInterpreter.SignalTransferFailure();
            }
            else
            {
                TransferCaller(telcomProvider, e.CallingToNumber);
            }
        }