//private ExtensionStateService extStateService; public ScriptService(TelecomProviderBase telecomProvider, CallButlerDataProviderBase dataProvider, VoicemailService vmService, VoicemailMailerService vmMailerService, Utilities.PluginManagement.PluginManager pluginManager, PBXRegistrarService registrarService/*, ExtensionStateService extStateService*/) { this.registrarService = registrarService; this.dataProvider = dataProvider; this.telecomProvider = telecomProvider; this.pluginManager = pluginManager; //this.extStateService = extStateService; // Create our services this.vmService = vmService; this.vmMailerService = vmMailerService; // Create a new script processor for each of our inbound lines tsInterfaces = new Dictionary<int, TelecomScriptInterface>(); int lineCount = Properties.Settings.Default.LineCount; // Math.Min(Properties.Settings.Default.LineCount, Licensing.Management.AppPermissions.StatGetPermissionScalar("MaxLineCount")); for (int index = 1; index <= lineCount; index++) { TelecomScriptInterface tsInterface = new TelecomScriptInterface(telecomProvider, dataProvider, pluginManager, registrarService/*, extStateService*/, index); tsInterfaces.Add(index, tsInterface); tsInterface.TransferCall += new EventHandler<WOSI.IVR.IML.TransferEventArgs>(tsInterface_TransferCall); tsInterface.IMLInterpreter.ScriptStarted += new EventHandler(IMLInterpreter_ScriptStarted); tsInterface.IMLInterpreter.ScriptFinished += new EventHandler(IMLInterpreter_ScriptFinished); tsInterface.IMLInterpreter.DtmfTimeoutInMs = Properties.Settings.Default.DTMFTimeoutInMs; } // Add a startup entry in our log LoggingService.AddLogEntry(LogLevel.Basic, Services.PrivateLabelService.ReplaceProductName(Services.PrivateLabelService.ReplaceProductName("CallButler Service Started")), false); // Attach to our telecom provider events telecomProvider.IncomingCall += new EventHandler<CallEventArgs>(telecomProvider_IncomingCall); telecomProvider.Error += new EventHandler<CallButler.Telecom.ErrorEventArgs>(telecomProvider_Error); telecomProvider.CallConnected += new EventHandler<CallEventArgs>(telecomProvider_CallConnected); telecomProvider.CallEnded += new EventHandler<LineEventArgs>(telecomProvider_CallEnded); telecomProvider.CallFailed += new EventHandler<CallFailureEventArgs>(telecomProvider_CallFailed); telecomProvider.IncomingBusyCall += new EventHandler<BusyCallEventArgs>(telecomProvider_IncomingBusyCall); }
//private ExtensionStateService extStateService; public ScriptService(TelecomProviderBase telecomProvider, CallButlerDataProviderBase dataProvider, VoicemailService vmService, VoicemailMailerService vmMailerService, Utilities.PluginManagement.PluginManager pluginManager, PBXRegistrarService registrarService /*, ExtensionStateService extStateService*/) { this.registrarService = registrarService; this.dataProvider = dataProvider; this.telecomProvider = telecomProvider; this.pluginManager = pluginManager; //this.extStateService = extStateService; // Create our services this.vmService = vmService; this.vmMailerService = vmMailerService; // Create a new script processor for each of our inbound lines tsInterfaces = new Dictionary <int, TelecomScriptInterface>(); int lineCount = Properties.Settings.Default.LineCount; // Math.Min(Properties.Settings.Default.LineCount, Licensing.Management.AppPermissions.StatGetPermissionScalar("MaxLineCount")); for (int index = 1; index <= lineCount; index++) { TelecomScriptInterface tsInterface = new TelecomScriptInterface(telecomProvider, dataProvider, pluginManager, registrarService /*, extStateService*/, index); tsInterfaces.Add(index, tsInterface); tsInterface.TransferCall += new EventHandler <WOSI.IVR.IML.TransferEventArgs>(tsInterface_TransferCall); tsInterface.IMLInterpreter.ScriptStarted += new EventHandler(IMLInterpreter_ScriptStarted); tsInterface.IMLInterpreter.ScriptFinished += new EventHandler(IMLInterpreter_ScriptFinished); } // Add a startup entry in our log LoggingService.AddLogEntry(LogLevel.Basic, Services.PrivateLabelService.ReplaceProductName(Services.PrivateLabelService.ReplaceProductName("CallButler Service Started")), false); // Attach to our telecom provider events telecomProvider.IncomingCall += new EventHandler <CallEventArgs>(telecomProvider_IncomingCall); telecomProvider.Error += new EventHandler <CallButler.Telecom.ErrorEventArgs>(telecomProvider_Error); telecomProvider.CallConnected += new EventHandler <CallEventArgs>(telecomProvider_CallConnected); telecomProvider.CallEnded += new EventHandler <LineEventArgs>(telecomProvider_CallEnded); telecomProvider.CallFailed += new EventHandler <CallFailureEventArgs>(telecomProvider_CallFailed); telecomProvider.IncomingBusyCall += new EventHandler <BusyCallEventArgs>(telecomProvider_IncomingBusyCall); }
private void Initialize() { if (Properties.Settings.Default.ProductID != null && Properties.Settings.Default.ProductID.Length > 0) { lastErrorMessage = null; notifyIcon.Text = Properties.Settings.Default.ProductDescription; // Load our application permissions //Licensing.Management.AppPermissions.LoadPermissionData(Properties.Settings.Default.ProductID, Properties.Resources.Permissions); // Load our dataprovider System.Collections.Specialized.NameValueCollection settings = new System.Collections.Specialized.NameValueCollection(); switch (Properties.Settings.Default.DataProviderType) { case LocalCallButlerDataProviderTypes.XmlDataProvider: // Create our settings settings["RootDataDirectory"] = WOSI.Utilities.FileUtils.GetApplicationRelativePath(Properties.Settings.Default.XmlDataRootDirectory); settings["RootGreetingSoundDirectory"] = WOSI.Utilities.FileUtils.GetApplicationRelativePath(Properties.Settings.Default.GreetingSoundRootDirectory); dataProvider = new CallButlerXmlDataProvider(); dataProvider.Connect(settings); break; /*case LocalCallButlerDataProviderTypes.SqlServerDataProvider: settings["RootDataDirectory"] = WOSI.Utilities.FileUtils.GetApplicationRelativePath(Properties.Settings.Default.XmlDataRootDirectory); settings["RootGreetingSoundDirectory"] = WOSI.Utilities.FileUtils.GetApplicationRelativePath(Properties.Settings.Default.GreetingSoundRootDirectory); settings["ConnectionString"] = Properties.Settings.Default.SqlConnectionString; dataProvider = new CallButlerSQLServerDataProvider(); dataProvider.Connect(settings); break;*/ } /*if (Properties.Settings.Default.EnableKinesisServer) { extStateService = new ExtensionStateService(dataProvider); }*/ // Create our telecom provider int lineCount = /*Math.Min(*/ Properties.Settings.Default.LineCount; /*, Licensing.Management.AppPermissions.StatGetPermissionScalar("MaxLineCount"));*/ switch (Properties.Settings.Default.TelecomProviderType) { case TelecomProviders.inTELIPhoneTelecomProvider: { telecomProvider = new inTELIPhoneTelecomProvider(mnuServiceOptions, notifyIcon, lineCount, Properties.Settings.Default.UseStun, Properties.Settings.Default.StunServer, Properties.Settings.Default.SipPort, Properties.Settings.Default.UseInternalAddressForSIPMessages); // Register all of our profiles //if (Licensing.Management.AppPermissions.StatIsPermitted("Providers")) //{ WOSI.CallButler.Data.CallButlerDataset.ProvidersDataTable providers = dataProvider.GetProviders(Properties.Settings.Default.CustomerID); foreach (WOSI.CallButler.Data.CallButlerDataset.ProvidersRow provider in providers) { if (provider.IsEnabled) { telecomProvider.Register(provider.ProviderID, provider); } } //} // Start our PBX registrar engine if (Properties.Settings.Default.EnablePBX /*&& Licensing.Management.AppPermissions.StatIsPermitted("PBX.Registrar")*/) { pbxRegistrar = new PBXRegistrarService(telecomProvider, dataProvider/*, extStateService*/); } break; } } // Initialize our codecs if (Properties.Settings.Default.AudioCodecs != null && Properties.Settings.Default.AudioCodecs.Length > 0) telecomProvider.SetAudioCodecs(Properties.Settings.Default.AudioCodecs); // Create our plugin manager object pluginManager = new Utilities.PluginManagement.PluginManager(); // Create our voicemail mailer service vmMailerService = new VoicemailMailerService(); // Initialize our voicemail service vmService = new VoicemailService(dataProvider, pbxRegistrar, pluginManager, vmMailerService); // Create our script server scriptService = new ScriptService(telecomProvider, dataProvider, vmService, vmMailerService, pluginManager, pbxRegistrar/*, extStateService*/); // Load our plugins CallButler.Service.Plugin.CallButlerServiceContext serviceContext = new CallButler.Service.Plugin.CallButlerServiceContext(scriptService); pluginManager.LoadPlugins(WOSI.Utilities.FileUtils.GetApplicationRelativePath(Properties.Settings.Default.PluginDirectory), "*.dll", true, typeof(CallButler.Service.Plugin.CallButlerServicePlugin)); foreach (CallButler.Service.Plugin.CallButlerServicePlugin plugin in pluginManager.Plugins) { try { plugin.Load(serviceContext); } catch { } } try { mnuPlugins.Visible = false; mnuSeparator4.Visible = false; } catch { } // Initialize our management interface managementInterfaceServer.Initialize(this, dataProvider, telecomProvider, scriptService, pluginManager, pbxRegistrar, vmService); // Create our default greetings if this the first time we've run if (Properties.Settings.Default.FirstTimeRun) { WOSI.CallButler.Data.CallButlerDataset.LocalizedGreetingsDataTable lgTable = new CallButlerDataset.LocalizedGreetingsDataTable(); WOSI.CallButler.Data.CallButlerDataset.LocalizedGreetingsRow lgRow; if (dataProvider.GetGreeting(Properties.Settings.Default.CustomerID, WOSI.CallButler.Data.Constants.WelcomeGreetingGuid) == null) { lgRow = lgTable.NewLocalizedGreetingsRow(); lgRow.GreetingID = WOSI.CallButler.Data.Constants.WelcomeGreetingGuid; lgRow.LanguageID = "en"; lgRow.LocalizedGreetingID = Guid.NewGuid(); lgRow.Type = (short)WOSI.CallButler.Data.GreetingType.SoundGreeting; lgTable.AddLocalizedGreetingsRow(lgRow); } if (dataProvider.GetGreeting(Properties.Settings.Default.CustomerID, WOSI.CallButler.Data.Constants.MainMenuGreetingGuid) == null) { lgRow = lgTable.NewLocalizedGreetingsRow(); lgRow.GreetingID = WOSI.CallButler.Data.Constants.MainMenuGreetingGuid; lgRow.LanguageID = "en"; lgRow.LocalizedGreetingID = Guid.NewGuid(); lgRow.Type = (short)WOSI.CallButler.Data.GreetingType.SoundGreeting; lgTable.AddLocalizedGreetingsRow(lgRow); } managementInterfaceServer.PersistLocalizedGreeting(Properties.Settings.Default.CustomerID, lgTable); Properties.Settings.Default.FirstTimeRun = false; Properties.Settings.Default.Save(); } // Setup our default language if (Properties.Settings.Default.DefaultLanguage.Length == 0) { Properties.Settings.Default.DefaultLanguage = System.Globalization.CultureInfo.CurrentCulture.IetfLanguageTag; Properties.Settings.Default.Save(); } telecomProvider.Startup(); CallButlerService.DialPlanManager = new DialPlanManagerService(pbxRegistrar, dataProvider, telecomProvider); if (tcpManagementDataServer != null) tcpManagementDataServer.StartServer(); // Create our extension management service /*if (Properties.Settings.Default.EnableKinesisServer) { emService = new KinesisService(dataProvider, extStateService, scriptService, vmService); emService.Start(); }*/ } }
private void DeInitialize() { if (mnuMain.InvokeRequired) mnuMain.Invoke(clearMenuItemsHandler); else mnuServiceOptions.DropDownItems.Clear(); /*if (extStateService != null) { extStateService.ClearState(); extStateService = null; } if (emService != null) { emService.Stop(); emService.Dispose(); emService = null; }*/ if (pluginManager != null) { // Unload our plugins foreach (CallButler.Service.Plugin.CallButlerServicePlugin plugin in pluginManager.Plugins) { plugin.Unload(); } pluginManager.UnloadPlugins(); pluginManager = null; } if (scriptService != null) { scriptService.Shutdown(); scriptService = null; } if (vmMailerService != null) { vmMailerService = null; } if (vmService != null) { vmService = null; } dataProvider = null; if (CallButlerService.DialPlanManager != null) { CallButlerService.DialPlanManager = null; } if (pbxRegistrar != null) { pbxRegistrar.Shutdown(); pbxRegistrar = null; } if (telecomProvider != null) { telecomProvider.Shutdown(); telecomProvider = null; } if (tcpManagementDataServer != null) tcpManagementDataServer.StopServer(); GC.Collect(); }
internal void Initialize(CallButlerService cbService, CallButlerDataProviderBase dataProvider, Telecom.TelecomProviderBase telecomProvider, ScriptService scriptService, Utilities.PluginManagement.PluginManager pluginManager, PBXRegistrarService registrarService, VoicemailService vmService) { this.cbService = cbService; this.dataProvider = dataProvider; this.telecomProvider = telecomProvider; this.scriptService = scriptService; this.pluginManager = pluginManager; this.registrarService = registrarService; this.tts = new SpVoiceClass(); this.vmService = vmService; }