public WOSI.CallButler.Data.CallButlerPhoneStatusDataset GetPhoneStatus() { WOSI.CallButler.Data.CallButlerPhoneStatusDataset psData = new WOSI.CallButler.Data.CallButlerPhoneStatusDataset(); WOSI.CallButler.Data.CallButlerDataset.ExtensionsDataTable extensions = dataProvider.GetExtensions(Properties.Settings.Default.CustomerID); // Loop through each extension and get a status for it foreach (WOSI.CallButler.Data.CallButlerDataset.ExtensionsRow extension in extensions) { WOSI.CallButler.Data.CallButlerPhoneStatusDataset.PhoneStatusRow statusRow = psData.PhoneStatus.NewPhoneStatusRow(); PBXPresenceInfo[] presenceInfo = GetPresenceInfoForExtension(extension.ExtensionNumber); statusRow.ExtensionID = extension.ExtensionID; statusRow.ExtensionNumber = extension.ExtensionNumber; statusRow.FirstName = extension.FirstName; statusRow.LastName = extension.LastName; statusRow.StatusCode = (int)WOSI.CallButler.Data.PhoneExtensionStatus.Offline; if (presenceInfo != null && presenceInfo.Length > 0) { foreach (PBXPresenceInfo tmpPInfo in presenceInfo) { if (tmpPInfo.Status != PBXPresenceStatus.Offline) { statusRow.StatusCode = (int)WOSI.CallButler.Data.PhoneExtensionStatus.Online; statusRow.RemoteAddress += tmpPInfo.RemoteAddress + " "; break; } } statusRow.RemoteAddress = statusRow.RemoteAddress.Trim(); } psData.PhoneStatus.AddPhoneStatusRow(statusRow); } return(psData); }
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(StandardExternalCommands), command)) { StandardExternalCommands externalCommand = WOSI.Utilities.EnumUtils <StandardExternalCommands> .Parse(command); switch (externalCommand) { case StandardExternalCommands.CALLBUTLERINTERNAL_ChooseLanguage: { if (!Properties.Settings.Default.Multilingual) { tsInterface.IMLInterpreter.SignalExternalEvent(StandardExternalEvents.CALLBUTLERINTERNAL_NotMultilingual.ToString()); } else { tsInterface.IMLInterpreter.SignalEventCallback(eventToken); } break; } case StandardExternalCommands.CALLBUTLERINTERNAL_SetLanguageID: { List <string> languages = new List <string>(); languages.Add(Properties.Settings.Default.DefaultLanguage); languages.AddRange(Properties.Settings.Default.Languages.Split(';')); int languageNumber = Convert.ToInt32(commandData); if (languageNumber > 0 && languageNumber <= languages.Count) { // Set our language ID variable tsInterface.IMLInterpreter.SetLocalVariable("LanguageID", languages[languageNumber - 1]); tsInterface.IMLInterpreter.SignalEventCallback(eventToken); } else { tsInterface.IMLInterpreter.SignalExternalEvent(StandardExternalEvents.CALLBUTLERINTERNAL_InvalidLanguage.ToString()); } break; } case StandardExternalCommands.CALLBUTLERINTERNAL_ProcessMainMenuOption: { WOSI.CallButler.Data.CallButlerDataset.DepartmentsDataTable departments = dataProvider.GetDepartments(Properties.Settings.Default.CustomerID); WOSI.CallButler.Data.CallButlerDataset.DepartmentsRow[] choosenDepartments = (WOSI.CallButler.Data.CallButlerDataset.DepartmentsRow[])departments.Select("OptionNumber = " + commandData); if (choosenDepartments.Length > 0) { WOSI.CallButler.Data.CallButlerDataset.DepartmentsRow choosenDepartment = choosenDepartments[0]; switch (choosenDepartment.Type) { case (short)WOSI.CallButler.Data.DepartmentTypes.Greeting: tsInterface.IMLInterpreter.SetLocalVariable("MainMenuOptionGreetingID", choosenDepartment.DepartmentID.ToString()); tsInterface.IMLInterpreter.SignalExternalEvent(StandardExternalEvents.CALLBUTLERINTERNAL_GreetingMenuOption.ToString()); break; case (short)WOSI.CallButler.Data.DepartmentTypes.Extension: // Find our extension number try { WOSI.CallButler.Data.CallButlerDataset.ExtensionsRow extension = dataProvider.GetExtension(Properties.Settings.Default.CustomerID, new Guid(choosenDepartment.Data1)); if (extension != null) { tsInterface.IMLInterpreter.SetLocalVariable("Extension", extension.ExtensionNumber.ToString()); } } catch { } tsInterface.IMLInterpreter.SignalExternalEvent(StandardExternalEvents.CALLBUTLERINTERNAL_ExtensionMenuOption.ToString()); break; case (short)WOSI.CallButler.Data.DepartmentTypes.Script: tsInterface.IMLInterpreter.SetLocalVariable("CustomScriptPath", choosenDepartment.Data1); tsInterface.IMLInterpreter.SignalExternalEvent(StandardExternalEvents.CALLBUTLERINTERNAL_ScriptMenuOption.ToString()); break; case (short)WOSI.CallButler.Data.DepartmentTypes.Number: tsInterface.IMLInterpreter.SetLocalVariable("TransferToNumber", choosenDepartment.Data1); tsInterface.IMLInterpreter.SignalExternalEvent(StandardExternalEvents.CALLBUTLERINTERNAL_NumberTransferMenuOption.ToString()); break; case (short)WOSI.CallButler.Data.DepartmentTypes.Module: tsInterface.IMLInterpreter.SetLocalVariable("AddonModuleID", choosenDepartment.Data1); tsInterface.IMLInterpreter.SignalExternalEvent(StandardExternalEvents.CALLBUTLERINTERNAL_AddonModuleMenuOption.ToString()); break; } } else { tsInterface.IMLInterpreter.SignalExternalEvent(StandardExternalEvents.CALLBUTLERINTERNAL_InvalidMenuOption.ToString()); } break; } case StandardExternalCommands.CALLBUTLERINTERNAL_DialByNameSearch: // Find our extensions for this search string WOSI.CallButler.Data.CallButlerDataset.ExtensionsDataTable extensions = dataProvider.GetExtensions(Properties.Settings.Default.CustomerID); WOSI.CallButler.Data.CallButlerDataset.ExtensionsRow[] matchingExtensions = (WOSI.CallButler.Data.CallButlerDataset.ExtensionsRow[])extensions.Select("SearchNumber LIKE '" + commandData + "*' AND EnableSearch = True"); // Get our extension search index int searchIndex = Convert.ToInt32(tsInterface.IMLInterpreter.GetLocalVariable("ExtensionSearchIndex")); searchIndex++; if (matchingExtensions.Length > 0 && searchIndex < matchingExtensions.Length) { tsInterface.IMLInterpreter.SetLocalVariable("Extension", matchingExtensions[searchIndex].ExtensionNumber.ToString()); tsInterface.IMLInterpreter.SetLocalVariable("ExtensionName", matchingExtensions[searchIndex].FirstName + " " + matchingExtensions[searchIndex].LastName); tsInterface.IMLInterpreter.SetLocalVariable("ExtensionSearchIndex", searchIndex.ToString()); } else { tsInterface.IMLInterpreter.SignalExternalEvent(StandardExternalEvents.CALLBUTLERINTERNAL_ExtensionNotFound.ToString()); } tsInterface.IMLInterpreter.SignalEventCallback(eventToken); break; case StandardExternalCommands.CALLBUTLERINTERNAL_VoicemailManagement: { try { WOSI.CallButler.Data.CallButlerDataset.ExtensionsRow extension = dataProvider.GetExtensionNumber(Properties.Settings.Default.CustomerID, Convert.ToInt32(tsInterface.IMLInterpreter.GetLocalVariable("Extension"))); if (extension != null) { tsInterface.ScriptProcessor = new VoicemailManagementScriptProcessor(extension, pbxRegistrar); tsInterface.ScriptProcessor.StartProcessing(tsInterface, telecomProvider, dataProvider); break; } } catch { } tsInterface.IMLInterpreter.SignalTransferFailure(); break; } /*case StandardExternalCommands.CALLBUTLERINTERNAL_StartAddonModule: * { * CallButler.Service.Plugin.CallButlerAddonModulePlugin[] addonModules = pluginManager.GetAllPluginsOfType<CallButler.Service.Plugin.CallButlerAddonModulePlugin>(); * * foreach (CallButler.Service.Plugin.CallButlerAddonModulePlugin addonModule in addonModules) * { * if (addonModule.PluginID.ToString() == commandData) * { * try * { * // Make sure the module is licensed * if (!addonModule.IsLicensed) * break; * * // We found our module and we should load the script it uses * tsInterface.ScriptProcessor = new AddonModuleScriptProcessor(addonModule); * tsInterface.ScriptProcessor.StartProcessing(tsInterface, telecomProvider, dataProvider); * return; * * } * catch (Exception e) * { * LoggingService.AddLogEntry(WOSI.CallButler.ManagementInterface.LogLevel.ErrorsOnly, "Failed to load Addon-Module '" + addonModule.PluginName + "'\r\n\r\n" + e.Message + "\r\n\r\n" + e.StackTrace, true); * } * } * } * * tsInterface.ScriptProcessor = this; * tsInterface.IMLInterpreter.SignalExternalEvent(StandardExternalEvents.CALLBUTLERINTERNAL_AddonModuleFailed.ToString()); * * break; * }*/ } } }