public static void PersistLocalizedGreetingSound(WOSI.CallButler.Data.CallButlerDataset.LocalizedGreetingsRow localizedGreeting)
        {
            global::Controls.LoadingDialog.ShowDialog(null, CallButler.Manager.Utils.PrivateLabelUtils.ReplaceProductName(Properties.LocalizedStrings.GreetingUtils_SavingSounds), Properties.Resources.loading, false, 1000);

            if (localizedGreeting.Type == (short)WOSI.CallButler.Data.GreetingType.SoundGreeting)
            {
                if (localizedGreeting.Data == "CallRecording")
                {
                    ManagementInterfaceClient.ManagementInterface.PersistLocalizedGreetingSound(ManagementInterfaceClient.AuthInfo, localizedGreeting.GreetingID, localizedGreeting.LocalizedGreetingID, null);
                }
                else
                {
                    string greetingFilename = WOSI.Utilities.FileUtils.GetApplicationRelativePath(Properties.Settings.Default.GreetingsSoundCache) + "\\" + localizedGreeting.LanguageID + "\\" + localizedGreeting.GreetingID.ToString() + ".snd";

                    if (File.Exists(greetingFilename))
                    {
                        byte[] soundBytes = WOSI.Utilities.FileUtils.GetFileBytes(greetingFilename);

                        ManagementInterfaceClient.ManagementInterface.PersistLocalizedGreetingSound(ManagementInterfaceClient.AuthInfo, localizedGreeting.GreetingID, localizedGreeting.LocalizedGreetingID, soundBytes);
                    }
                }
            }

            global::Controls.LoadingDialog.HideDialog();
        }
        private void EditPersonalizedGreeting(WOSI.CallButler.Data.CallButlerDataset.PersonalizedGreetingsRow pgRow)
        {
            // Get our localized greeting
            WOSI.CallButler.Data.CallButlerDataset.LocalizedGreetingsDataTable lgTable = ManagementInterfaceClient.ManagementInterface.GetLocalizedGreetingInDefaultLanguage(ManagementInterfaceClient.AuthInfo, pgRow.PersonalizedGreetingID);

            if (lgTable.Count == 0)
            {
                // If no localized greeting exists, add a new one
                WOSI.CallButler.Data.CallButlerDataset.LocalizedGreetingsRow lgRow = lgTable.NewLocalizedGreetingsRow();
                lgRow.LocalizedGreetingID = Guid.NewGuid();
                lgRow.GreetingID          = pgRow.PersonalizedGreetingID;
                lgRow.LanguageID          = ManagementInterfaceClient.ManagementInterface.GetDefaultLanguage(ManagementInterfaceClient.AuthInfo);
                lgRow.Type = (short)WOSI.CallButler.Data.GreetingType.SoundGreeting;
                lgTable.AddLocalizedGreetingsRow(lgRow);
            }

            Forms.PersonalizedGreetingForm pgForm = new CallButler.Manager.Forms.PersonalizedGreetingForm(pgRow, callButlerDataset.Extensions);

            pgForm.GreetingControl.LoadGreeting(lgTable[0], WOSI.Utilities.FileUtils.GetApplicationRelativePath(Properties.Settings.Default.GreetingsSoundCache));

            if (pgForm.ShowDialog(this) == DialogResult.OK)
            {
                pgForm.GreetingControl.SaveGreeting(WOSI.Utilities.FileUtils.GetApplicationRelativePath(Properties.Settings.Default.GreetingsSoundCache));

                // Persist remotely
                ManagementInterfaceClient.ManagementInterface.PersistPersonalizedGreeting(ManagementInterfaceClient.AuthInfo, Utils.TableUtils <WOSI.CallButler.Data.CallButlerDataset.PersonalizedGreetingsDataTable> .CreateTableFromRow(pgRow));
                ManagementInterfaceClient.ManagementInterface.PersistLocalizedGreeting(ManagementInterfaceClient.AuthInfo, lgTable);

                // Send our localized greeting sound file
                Utils.GreetingUtils.PersistLocalizedGreetingSound(lgTable[0]);

                callButlerDataset.AcceptChanges();
            }
        }
        private void EditExtension(WOSI.CallButler.Data.CallButlerDataset.ExtensionsRow extension)
        {
            short currentExt = extension.ExtensionNumber;

            // Get our extension contact numbers
            WOSI.CallButler.Data.CallButlerDataset.ExtensionContactNumbersDataTable contactNumbersTable = ManagementInterfaceClient.ManagementInterface.GetExtensionContactNumbers(ManagementInterfaceClient.AuthInfo, extension.ExtensionID);

            // Get our extension greeting
            WOSI.CallButler.Data.CallButlerDataset.LocalizedGreetingsDataTable voicemailGreetings = ManagementInterfaceClient.ManagementInterface.GetLocalizedGreeting(ManagementInterfaceClient.AuthInfo, extension.ExtensionID, ManagementInterfaceClient.ManagementInterface.GetDefaultLanguage(ManagementInterfaceClient.AuthInfo));
            WOSI.CallButler.Data.CallButlerDataset.LocalizedGreetingsRow       voicemailGreeting  = null;

            if (voicemailGreetings.Count > 0)
            {
                voicemailGreeting = voicemailGreetings[0];

                // Download our greeting sound if it exists
                Utils.GreetingUtils.GetLocalizedGreetingSound(voicemailGreeting);
            }
            else
            {
                // If the greeting doesn't exist, create a new one
                voicemailGreeting                     = voicemailGreetings.NewLocalizedGreetingsRow();
                voicemailGreeting.GreetingID          = extension.ExtensionID;
                voicemailGreeting.LocalizedGreetingID = Guid.NewGuid();
                voicemailGreeting.LanguageID          = ManagementInterfaceClient.ManagementInterface.GetDefaultLanguage(ManagementInterfaceClient.AuthInfo);
                voicemailGreeting.Type                = (short)WOSI.CallButler.Data.GreetingType.SoundGreeting;
                voicemailGreetings.AddLocalizedGreetingsRow(voicemailGreeting);
            }

            WOSI.CallButler.Data.CallButlerDataset.ExtensionsDataTable origExt = (WOSI.CallButler.Data.CallButlerDataset.ExtensionsDataTable)callButlerDataset.Extensions.Copy();


            // Show our extension editor form
            Forms.ExtensionEditorForm extensionForm = new CallButler.Manager.Forms.ExtensionEditorForm(callButlerDataset.Extensions, extension, contactNumbersTable, voicemailGreeting);

            if (extensionForm.ShowDialog(this) == DialogResult.OK)
            {
                // Check to make sure the extension isn't already taken
                if (currentExt != extension.ExtensionNumber && origExt.Select("ExtensionNumber = " + extension.ExtensionNumber).Length > 0)
                {
                    MessageBox.Show(this, String.Format(CallButler.Manager.Utils.PrivateLabelUtils.ReplaceProductName(Properties.LocalizedStrings.ExtensionView_ExtTaken), extension.ExtensionNumber, currentExt), CallButler.Manager.Utils.PrivateLabelUtils.ReplaceProductName(Properties.LocalizedStrings.ExtensionView_ExtConflict), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    extension.ExtensionNumber = currentExt;
                }

                // Edit our remote extension
                WOSI.CallButler.Data.CallButlerDataset.ExtensionsDataTable extensionDataTable = Utils.TableUtils <WOSI.CallButler.Data.CallButlerDataset.ExtensionsDataTable> .CreateTableFromRow(extension);

                ManagementInterfaceClient.ManagementInterface.PersistExtension(ManagementInterfaceClient.AuthInfo, extensionDataTable);

                // Edit our remote greeting
                ManagementInterfaceClient.ManagementInterface.PersistLocalizedGreeting(ManagementInterfaceClient.AuthInfo, voicemailGreetings);

                // Send our voicemail greeting sound file
                Utils.GreetingUtils.PersistLocalizedGreetingSound(voicemailGreeting);

                ManagementInterfaceClient.ManagementInterface.PersistExtensionContactNumbers(ManagementInterfaceClient.AuthInfo, contactNumbersTable);
            }
        }
Esempio n. 4
0
        public void SaveGreeting(string greetingSoundCache, WOSI.CallButler.Data.CallButlerDataset.LocalizedGreetingsRow localizedGreeting)
        {
            StopSounds();

            localizedGreeting.Type = (short)this.GreetingType;

            if (this.GreetingType == GreetingType.TextGreeting)
            {
                localizedGreeting.Data  = speechControl.SpeechText;
                localizedGreeting.Voice = speechControl.Voice;
            }
            else if (this.GreetingType == GreetingType.SoundGreeting)
            {
                if (mnuCall.Checked)
                {
                    localizedGreeting.Voice = "";
                    localizedGreeting.Data  = "CallRecording";
                }
                else if (recordingControl.NewFile && File.Exists(recordingControl.WorkingFile))
                {
                    localizedGreeting.Voice = "";

                    string greetingDirectory = greetingSoundCache + "\\" + localizedGreeting.LanguageID;
                    string greetingSoundFile = greetingDirectory + "\\" + localizedGreeting.GreetingID + ".snd";

                    if (!Directory.Exists(greetingDirectory))
                    {
                        Directory.CreateDirectory(greetingDirectory);
                    }

                    if (string.Compare(recordingControl.WorkingFile, greetingSoundFile, true) != 0)
                    {
                        File.Copy(recordingControl.WorkingFile, greetingSoundFile, true);
                        File.SetAttributes(greetingSoundFile, FileAttributes.Normal);
                    }

                    // Fill in our file checksum
                    localizedGreeting.Data = WOSI.Utilities.CryptoUtils.GetFileChecksum(greetingSoundFile);
                }
            }
        }
        public static string GetLocalizedGreetingSound(WOSI.CallButler.Data.CallButlerDataset.LocalizedGreetingsRow localizedGreeting)
        {
            global::Controls.LoadingDialog.ShowDialog(null, CallButler.Manager.Utils.PrivateLabelUtils.ReplaceProductName(Properties.LocalizedStrings.GreetingUtils_GettingSounds), Properties.Resources.loading, false, 1000);

            // First check to see if the greeting is a sound greeting
            if ((WOSI.CallButler.Data.GreetingType)localizedGreeting.Type == WOSI.CallButler.Data.GreetingType.SoundGreeting)
            {
                string greetingDirectory = WOSI.Utilities.FileUtils.GetApplicationRelativePath(Properties.Settings.Default.GreetingsSoundCache) + "\\" + localizedGreeting.LanguageID;
                string greetingFilename  = greetingDirectory + "\\" + localizedGreeting.GreetingID.ToString() + ".snd";

                // Check to see if we already have the latest greeting
                if (File.Exists(greetingFilename))
                {
                    string localFileChecksum = WOSI.Utilities.CryptoUtils.GetFileChecksum(greetingFilename);

                    if (localFileChecksum == localizedGreeting.Data)
                    {
                        global::Controls.LoadingDialog.HideDialog();
                        return(greetingFilename);
                    }
                }

                // If we don't have the greeting, download it
                byte[] soundBytes = ManagementInterfaceClient.ManagementInterface.GetLocalizedGreetingSound(ManagementInterfaceClient.AuthInfo, localizedGreeting.GreetingID, localizedGreeting.LocalizedGreetingID);

                if (!Directory.Exists(greetingDirectory))
                {
                    Directory.CreateDirectory(greetingDirectory);
                }

                WOSI.Utilities.FileUtils.SaveBytesToFile(greetingFilename, soundBytes);

                global::Controls.LoadingDialog.HideDialog();
                return(greetingFilename);
            }
            else
            {
                global::Controls.LoadingDialog.HideDialog();
                return(null);
            }
        }
Esempio n. 6
0
        public void LoadGreeting(WOSI.CallButler.Data.CallButlerDataset.LocalizedGreetingsRow greeting, string greetingSoundCache)
        {
            recordingControl.Reset();
            speechControl.SpeechText = "";

            greetingRow = greeting;

            if (greeting != null)
            {
                this.GreetingType = (WOSI.CallButler.Data.GreetingType)greetingRow.Type;

                if (this.GreetingType == GreetingType.TextGreeting)
                {
                    speechControl.SpeechText = greetingRow.Data;
                    speechControl.Voice      = greetingRow.Voice;
                }
                else if (this.GreetingType == GreetingType.SoundGreeting)
                {
                    recordingControl.LoadSoundFile(greetingSoundCache + "\\" + greetingRow.LanguageID + "\\" + greetingRow.GreetingID.ToString() + ".snd");
                }
            }
        }
        internal void AddPersonalizedGreeting()
        {
            // Create a new personalized greeting row and table
            WOSI.CallButler.Data.CallButlerDataset.PersonalizedGreetingsDataTable pgTable = new WOSI.CallButler.Data.CallButlerDataset.PersonalizedGreetingsDataTable();
            WOSI.CallButler.Data.CallButlerDataset.PersonalizedGreetingsRow       pgRow   = pgTable.NewPersonalizedGreetingsRow();
            pgRow.PersonalizedGreetingID = Guid.NewGuid();
            pgRow.Type = (short)WOSI.CallButler.Data.PersonalizedGreetingType.Continue;
            pgTable.AddPersonalizedGreetingsRow(pgRow);

            // Create a new localized greeting row and table
            WOSI.CallButler.Data.CallButlerDataset.LocalizedGreetingsDataTable lgTable = new WOSI.CallButler.Data.CallButlerDataset.LocalizedGreetingsDataTable();
            WOSI.CallButler.Data.CallButlerDataset.LocalizedGreetingsRow       lgRow   = lgTable.NewLocalizedGreetingsRow();
            lgRow.LocalizedGreetingID = Guid.NewGuid();
            lgRow.GreetingID          = pgRow.PersonalizedGreetingID;
            lgRow.LanguageID          = ManagementInterfaceClient.ManagementInterface.GetDefaultLanguage(ManagementInterfaceClient.AuthInfo);
            lgRow.Type = (short)WOSI.CallButler.Data.GreetingType.SoundGreeting;
            lgTable.AddLocalizedGreetingsRow(lgRow);

            Forms.PersonalizedGreetingForm pgForm = new CallButler.Manager.Forms.PersonalizedGreetingForm(pgRow, callButlerDataset.Extensions);

            pgForm.GreetingControl.LoadGreeting(lgRow, WOSI.Utilities.FileUtils.GetApplicationRelativePath(Properties.Settings.Default.GreetingsSoundCache));

            if (pgForm.ShowDialog(this) == DialogResult.OK)
            {
                pgForm.GreetingControl.SaveGreeting(WOSI.Utilities.FileUtils.GetApplicationRelativePath(Properties.Settings.Default.GreetingsSoundCache));

                // Add remotely
                ManagementInterfaceClient.ManagementInterface.PersistPersonalizedGreeting(ManagementInterfaceClient.AuthInfo, pgTable);
                ManagementInterfaceClient.ManagementInterface.PersistLocalizedGreeting(ManagementInterfaceClient.AuthInfo, lgTable);

                // Send our localized greeting sound file
                Utils.GreetingUtils.PersistLocalizedGreetingSound(lgRow);

                // Add locally
                callButlerDataset.PersonalizedGreetings.ImportRow(pgRow);

                callButlerDataset.AcceptChanges();
            }
        }
        /*void RenumberDepartmentOptions()
         * {
         *  WOSI.CallButler.Data.CallButlerDataset.DepartmentsRow[] departments = (WOSI.CallButler.Data.CallButlerDataset.DepartmentsRow[])vbData.Departments.Select("", "OptionNumber ASC");
         *
         *  int optionNumber = 1;
         *
         *  foreach (WOSI.CallButler.Data.CallButlerDataset.DepartmentsRow department in departments)
         *  {
         *      if (department.RowState != DataRowState.Deleted)
         *      {
         *          department.OptionNumber = optionNumber;
         *          optionNumber++;
         *      }
         *  }
         *
         *  ManagementInterfaceClient.ManagementInterface.PersistDepartment(ManagementInterfaceClient.AuthInfo, vbData.Departments);
         *  vbData.Departments.AcceptChanges();
         *  UpdateDepartments();
         * }*/

        void EditDepartment(WOSI.CallButler.Data.CallButlerDataset.DepartmentsRow department, CallFlowItem cfItem)
        {
            Forms.DepartmentForm dpForm = new CallButler.Manager.Forms.DepartmentForm(department, vbData);
            WOSI.CallButler.Data.CallButlerDataset.LocalizedGreetingsRow localizedGreeting = null;

            // Get and load our localized greeting if this is a greeting department
            if (department.Type == (short)WOSI.CallButler.Data.DepartmentTypes.Greeting)
            {
                WOSI.CallButler.Data.CallButlerDataset.LocalizedGreetingsDataTable localizedGreetings = ManagementInterfaceClient.ManagementInterface.GetLocalizedGreeting(ManagementInterfaceClient.AuthInfo, department.DepartmentID, GetCurrentLanguage());

                if (localizedGreetings.Count > 0)
                {
                    localizedGreeting = localizedGreetings[0];
                    Utils.GreetingUtils.GetLocalizedGreetingSound(localizedGreeting);
                    dpForm.GreetingControl.LoadGreeting(localizedGreeting, WOSI.Utilities.FileUtils.GetApplicationRelativePath(Properties.Settings.Default.GreetingsSoundCache));
                }
            }

            if (dpForm.ShowDialog(this) == DialogResult.OK)
            {
                vbData.AcceptChanges();

                // Update our department item remotely

                ManagementInterfaceClient.ManagementInterface.PersistDepartment(ManagementInterfaceClient.AuthInfo, Utils.TableUtils <WOSI.CallButler.Data.CallButlerDataset.DepartmentsDataTable> .CreateTableFromRow(department));

                PersistDepartmentGreeting(department, localizedGreeting, dpForm);


                //if ((WOSI.CallButler.Data.DepartmentTypes)department.Type == WOSI.CallButler.Data.DepartmentTypes.Greeting)
                //    dpForm.GreetingControl.SaveGreeting(WOSI.Utilities.FileUtils.GetApplicationRelativePath(Properties.Settings.Default.GreetingsSoundCache));


                UpdateDepartmentItem(cfItem);
                NotifyUpdateMenuGreeting();
            }
        }
        internal void AddNewExtension()
        {
            // Check to make sure we can add a new extension
            int maxExtensions = 100;

            if (maxExtensions > 0 && maxExtensions <= callButlerDataset.Extensions.Count)
            {
                MessageBox.Show(this, String.Format(CallButler.Manager.Utils.PrivateLabelUtils.ReplaceProductName(Properties.LocalizedStrings.ExtensionsView_ExtLimit), maxExtensions), CallButler.Manager.Utils.PrivateLabelUtils.ReplaceProductName(Properties.LocalizedStrings.Common_PermissionDenied), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            // Create a new Extension row
            WOSI.CallButler.Data.CallButlerDataset.ExtensionsRow extension = callButlerDataset.Extensions.NewExtensionsRow();

            extension.CustomerID  = Properties.Settings.Default.CustomerID;
            extension.ExtensionID = Guid.NewGuid();
            short extensionNum = 0;

            // Find us an unused extension number
            for (short index = Properties.Settings.Default.MinExtensionNumber; index < short.MaxValue; index++)
            {
                if (callButlerDataset.Extensions.Select("ExtensionNumber = " + index).Length == 0)
                {
                    extensionNum = index;
                    extension.ExtensionNumber = index;
                    break;
                }
            }

            // Create a new voicemail greeting
            WOSI.CallButler.Data.CallButlerDataset.LocalizedGreetingsDataTable voicemailGreetingTable = new WOSI.CallButler.Data.CallButlerDataset.LocalizedGreetingsDataTable();
            WOSI.CallButler.Data.CallButlerDataset.LocalizedGreetingsRow       voicemailGreeting      = voicemailGreetingTable.NewLocalizedGreetingsRow();
            voicemailGreeting.GreetingID          = extension.ExtensionID;
            voicemailGreeting.LocalizedGreetingID = Guid.NewGuid();
            voicemailGreeting.LanguageID          = ManagementInterfaceClient.ManagementInterface.GetDefaultLanguage(ManagementInterfaceClient.AuthInfo);
            voicemailGreeting.Type = (short)WOSI.CallButler.Data.GreetingType.SoundGreeting;
            voicemailGreetingTable.AddLocalizedGreetingsRow(voicemailGreeting);

            // Create a new extension contact numbers table
            WOSI.CallButler.Data.CallButlerDataset.ExtensionContactNumbersDataTable extensionContactNumbers = new WOSI.CallButler.Data.CallButlerDataset.ExtensionContactNumbersDataTable();

            // Show our extension editor form
            Forms.ExtensionEditorForm extensionForm = new CallButler.Manager.Forms.ExtensionEditorForm(callButlerDataset.Extensions, extension, extensionContactNumbers, voicemailGreeting);

            WOSI.CallButler.Data.CallButlerDataset.ExtensionsDataTable origExt = (WOSI.CallButler.Data.CallButlerDataset.ExtensionsDataTable)callButlerDataset.Extensions.Copy();

            if (extensionForm.ShowDialog(this) == DialogResult.OK)
            {
                // Check to make sure the extension isn't already taken
                if (origExt.Select("ExtensionNumber = " + extension.ExtensionNumber).Length > 0)
                {
                    MessageBox.Show(this, String.Format(CallButler.Manager.Utils.PrivateLabelUtils.ReplaceProductName(Properties.LocalizedStrings.ExtensionView_ExtTaken), extension.ExtensionNumber, extensionNum), CallButler.Manager.Utils.PrivateLabelUtils.ReplaceProductName(Properties.LocalizedStrings.ExtensionView_ExtConflict), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    extension.ExtensionNumber = extensionNum;
                }

                // Add our local extension
                callButlerDataset.Extensions.AddExtensionsRow(extension);

                // Add our remote extension
                WOSI.CallButler.Data.CallButlerDataset.ExtensionsDataTable extensionDataTable = Utils.TableUtils <WOSI.CallButler.Data.CallButlerDataset.ExtensionsDataTable> .CreateTableFromRow(extension);

                ManagementInterfaceClient.ManagementInterface.PersistExtension(ManagementInterfaceClient.AuthInfo, extensionDataTable);

                // Add our voicemail greeting
                ManagementInterfaceClient.ManagementInterface.PersistLocalizedGreeting(ManagementInterfaceClient.AuthInfo, voicemailGreetingTable);

                // Send our voicemail greeting sound file
                Utils.GreetingUtils.PersistLocalizedGreetingSound(voicemailGreeting);

                // Persist our contact numbers
                ManagementInterfaceClient.ManagementInterface.PersistExtensionContactNumbers(ManagementInterfaceClient.AuthInfo, extensionContactNumbers);
            }
        }
        public void ProcessExternalCommand(string command, string commandData, string eventToken, TelecomScriptInterface tsInterface, CallButler.Telecom.TelecomProviderBase telecomProvider, WOSI.CallButler.Data.DataProviders.CallButlerDataProviderBase dataProvider, Utilities.PluginManagement.PluginManager pluginManager, PBXRegistrarService pbxRegistrar)
        {
            // Parse out our external event action
            if (Enum.IsDefined(typeof(BaseExternalCommands), command))
            {
                BaseExternalCommands externalCommand = WOSI.Utilities.EnumUtils <BaseExternalCommands> .Parse(command);

                string languageID = "en";

                switch (externalCommand)
                {
                case BaseExternalCommands.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);
                            }
                        }
                    }

                    break;

                case BaseExternalCommands.CALLBUTLERINTERNAL_ReturnToCallFlowMainMenu:

                    // Return to the Call flow main menu.
                    tsInterface.ScriptProcessor = new StandardScriptProcessor(pluginManager, pbxRegistrar);
                    ((StandardScriptProcessor)tsInterface.ScriptProcessor).StartFromMainMenu(tsInterface);

                    break;

                case BaseExternalCommands.CALLBUTLERINTERNAL_PlayLicenseIntroGreeting:

                    // If the line isn't in use, don't do anything
                    if (!telecomProvider.IsLineInUse(tsInterface.LineNumber))
                    {
                        tsInterface.IMLInterpreter.SignalEventCallback(eventToken);
                        break;
                    }

                    // Read our intro sound bytes
                    byte[] introSoundBytes = null;

                    if (telecomProvider.AudioInputRate == 8000)
                    {
                        introSoundBytes = new byte[Properties.Resources.powered_by_8khz.Length];
                        Properties.Resources.powered_by_8khz.Read(introSoundBytes, 0, introSoundBytes.Length);
                    }
                    else if (telecomProvider.AudioInputRate == 16000)
                    {
                        introSoundBytes = new byte[Properties.Resources.powered_by_16khz.Length];
                        Properties.Resources.powered_by_16khz.Read(introSoundBytes, 0, introSoundBytes.Length);
                    }

                    // Play our license intro sound
                    if (introSoundBytes != null)
                    {
                        telecomProvider.PlaySound(tsInterface.LineNumber, introSoundBytes);
                    }

                    break;

                case BaseExternalCommands.CALLBUTLERINTERNAL_PlaySystemSound:

                    // If the line isn't in use, don't do anything
                    if (!telecomProvider.IsLineInUse(tsInterface.LineNumber))
                    {
                        tsInterface.IMLInterpreter.SignalEventCallback(eventToken);
                        break;
                    }

                    // Get the sound with the current language
                    languageID = tsInterface.IMLInterpreter.GetLocalVariable("LanguageID");

                    string soundFilename = GetSoundFileForLanguage(languageID, commandData);

                    if (soundFilename == null)
                    {
                        // If we don't get a sound with the current language, try the default language
                        soundFilename = GetSoundFileForLanguage(Properties.Settings.Default.DefaultLanguage, commandData);

                        if (soundFilename == null)
                        {
                            // If we don't get a sound file with the default language, try english
                            soundFilename = GetSoundFileForLanguage("en", commandData);

                            if (soundFilename == null)
                            {
                                if (!File.Exists(soundFilename))
                                {
                                    // If the sound still doesn't exist, tell the IML interpreter to move on
                                    tsInterface.IMLInterpreter.SignalEventCallback(eventToken);
                                    break;
                                }
                            }
                        }
                    }

                    // If we get here, our system sound should exist and we should play it.
                    if (string.Compare(commandData, "ring.snd", true) == 0)
                    {
                        telecomProvider.PlaySound(tsInterface.LineNumber, soundFilename, true);
                    }
                    else
                    {
                        telecomProvider.PlaySound(tsInterface.LineNumber, soundFilename, false);
                    }

                    LoggingService.AddLogEntry(LogLevel.Extended, "(Line " + tsInterface.LineNumber + ") Playing sound at " + soundFilename, false);

                    break;

                case BaseExternalCommands.CALLBUTLERINTERNAL_PlayGreeting:

                    // If the line isn't in use, don't do anything
                    if (!telecomProvider.IsLineInUse(tsInterface.LineNumber))
                    {
                        tsInterface.IMLInterpreter.SignalEventCallback(eventToken);
                        break;
                    }

                    // Get our current language
                    languageID = tsInterface.IMLInterpreter.GetLocalVariable("LanguageID");

                    // Create our greetingID
                    Guid greetingID = new Guid(commandData);

                    // Get the greeting in our selected language
                    WOSI.CallButler.Data.CallButlerDataset.GreetingsRow greeting = dataProvider.GetGreeting(Properties.Settings.Default.CustomerID, greetingID);

                    if (greeting != null)
                    {
                        // Get the greeting for our specified language
                        WOSI.CallButler.Data.CallButlerDataset.LocalizedGreetingsRow localizedGreeting = dataProvider.GetLocalizedGreeting(Properties.Settings.Default.CustomerID, greetingID, languageID);

                        if (localizedGreeting == null)
                        {
                            // If the greeting doesn't exist in the current language, try using the default language
                            localizedGreeting = dataProvider.GetLocalizedGreeting(Properties.Settings.Default.CustomerID, greetingID, Properties.Settings.Default.DefaultLanguage);

                            if (localizedGreeting == null)
                            {
                                // If the greeting doesn't exist in the default language, heck just return the first one that exists
                                WOSI.CallButler.Data.CallButlerDataset.LocalizedGreetingsRow[] localizedGreetings = greeting.GetLocalizedGreetingsRows();

                                if (localizedGreetings.Length > 0)
                                {
                                    localizedGreeting = localizedGreetings[0];
                                }
                            }
                        }

                        if (localizedGreeting != null)
                        {
                            // Determine how we should play this greeting
                            WOSI.CallButler.Data.GreetingType greetingType = (WOSI.CallButler.Data.GreetingType)localizedGreeting.Type;

                            switch (greetingType)
                            {
                            case WOSI.CallButler.Data.GreetingType.SoundGreeting:
                                // Create our sound file path
                                string soundFilePath = WOSI.Utilities.FileUtils.GetApplicationRelativePath(Properties.Settings.Default.GreetingSoundRootDirectory) + "\\" + localizedGreeting.LanguageID + "\\" + greetingID.ToString() + ".snd";

                                if (File.Exists(soundFilePath))
                                {
                                    telecomProvider.PlaySound(tsInterface.LineNumber, soundFilePath, false);
                                    LoggingService.AddLogEntry(LogLevel.Extended, "(Line " + tsInterface.LineNumber + ") Playing sound at " + soundFilePath, false);
                                }
                                else
                                {
                                    tsInterface.IMLInterpreter.SignalEventCallback(eventToken);
                                }

                                break;

                            case WOSI.CallButler.Data.GreetingType.TextGreeting:

                                // Speak our text
                                string textToSpeak = tsInterface.IMLInterpreter.ParseVariableTokens(localizedGreeting.Data);

                                // Take out any XML
                                if (!WOSI.Utilities.StringUtils.IsWellFormedXml(textToSpeak))
                                {
                                    textToSpeak = WOSI.Utilities.StringUtils.XmlEncodeString(textToSpeak);
                                }

                                if (textToSpeak.Length > 0)
                                {
                                    if (!localizedGreeting.IsVoiceNull() && localizedGreeting.Voice.Length > 0)
                                    {
                                        textToSpeak = "<voice required=\"Name=" + localizedGreeting.Voice + "\">" + textToSpeak + "</voice>";
                                    }
                                    else if (Properties.Settings.Default.DefaultTTSVoice != null && Properties.Settings.Default.DefaultTTSVoice.Length > 0)
                                    {
                                        textToSpeak = "<voice required=\"Name=" + Properties.Settings.Default.DefaultTTSVoice + "\">" + textToSpeak + "</voice>";
                                    }

                                    telecomProvider.SpeakText(tsInterface.LineNumber, textToSpeak);
                                    LoggingService.AddLogEntry(LogLevel.Extended, "(Line " + tsInterface.LineNumber + ") Speaking '" + textToSpeak + "'", false);
                                }
                                else
                                {
                                    tsInterface.IMLInterpreter.SignalEventCallback(eventToken);
                                }

                                break;
                            }
                        }
                        else
                        {
                            // If no greeting is found in the right language, tell the interpreter to move on
                            tsInterface.IMLInterpreter.SignalEventCallback(eventToken);
                        }
                    }
                    // If the greeting isn't found, tell the interpreter to go on
                    else
                    {
                        tsInterface.IMLInterpreter.SignalEventCallback(eventToken);
                    }

                    break;
                }
            }
            else
            {
                OnExternalCommand(command, commandData, eventToken, tsInterface, telecomProvider, dataProvider);

                if (linkedScriptProcessor != null)
                {
                    linkedScriptProcessor.OnLinkedExternalCommand(command, commandData, eventToken, tsInterface, telecomProvider, dataProvider);
                }
            }
        }
        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;
                }
                }
            }
        }
Esempio n. 12
0
        private void PersistDepartmentGreeting(WOSI.CallButler.Data.CallButlerDataset.DepartmentsRow department, WOSI.CallButler.Data.CallButlerDataset.LocalizedGreetingsRow localizedGreeting, Forms.DepartmentForm dpForm)
        {
            // If the department is a greeting, add a new localized greeting
            if (department.Type == (short)WOSI.CallButler.Data.DepartmentTypes.Greeting)
            {
                WOSI.CallButler.Data.CallButlerDataset.LocalizedGreetingsDataTable localizedGreetingTable = new WOSI.CallButler.Data.CallButlerDataset.LocalizedGreetingsDataTable();

                bool newRowCreated = false;
                if (localizedGreeting == null)
                {
                    localizedGreeting = localizedGreetingTable.NewLocalizedGreetingsRow();
                    localizedGreeting.LocalizedGreetingID = Guid.NewGuid();
                    localizedGreeting.GreetingID          = department.DepartmentID;
                    localizedGreeting.LanguageID          = GetCurrentLanguage();

                    localizedGreetingTable.AddLocalizedGreetingsRow(localizedGreeting);
                    newRowCreated = true;
                }
                //else


                dpForm.GreetingControl.SaveGreeting(WOSI.Utilities.FileUtils.GetApplicationRelativePath(Properties.Settings.Default.GreetingsSoundCache), localizedGreeting);
                if (newRowCreated == false)
                {
                    localizedGreetingTable.ImportRow(localizedGreeting);
                }

                ManagementInterfaceClient.ManagementInterface.PersistLocalizedGreeting(ManagementInterfaceClient.AuthInfo, localizedGreetingTable);

                // Send our greeting sound file
                Utils.GreetingUtils.PersistLocalizedGreetingSound(localizedGreeting);
            }
        }
        public ExtensionEditorForm(WOSI.CallButler.Data.CallButlerDataset.ExtensionsDataTable extensions, WOSI.CallButler.Data.CallButlerDataset.ExtensionsRow extension, WOSI.CallButler.Data.CallButlerDataset.ExtensionContactNumbersDataTable extensionContacts, WOSI.CallButler.Data.CallButlerDataset.LocalizedGreetingsRow voicemailGreeting)
        {
            InitializeComponent();

            this.extensions        = extensions;
            this.extension         = extension;
            this.extensionContacts = extensionContacts;


            CallButler.Manager.Plugin.CallButlerManagementPlugin plugin = PluginManager.GetPluginFromID(new Guid(Properties.Settings.Default.DefaultFindMePluginID));

            if (plugin != null)
            {
                CallButler.Manager.Plugin.CallButlerManagementPluginViewControl c = plugin.GetNewViewControl();
                c.Load(new object[] { extension, extensionContacts, ManagementInterfaceClient.ManagementInterface.TelephoneNumberDescription, true, true, extensions });
                c.Dock = DockStyle.Fill;
                pnlFindMe.Controls.Add(c);
            }
            else
            {
                NoPluginFoundView c = new NoPluginFoundView();
                c.PluginType = "Find me/Follow me plugin";

                c.Dock = DockStyle.Fill;
                pnlFindMe.Controls.Add(c);
            }

            wizard.PageIndex = 0;

            // Update our UI
            numExtNum.Value             = extension.ExtensionNumber;
            txtFirstName.Text           = extension.FirstName;
            txtLastName.Text            = extension.LastName;
            cbEnableSearch.Checked      = extension.EnableSearch;
            cbEnableManagement.Checked  = extension.EnableManagement;
            cbEmailNotification.Checked = extension.EmailNotification;
            cbAttach.Checked            = extension.EmailAttachment;
            txtEmailAddress.Text        = extension.EmailAddress;
            cbCallScreening.Checked     = extension.EnableCallScreening;
            cbEnableOutbound.Checked    = extension.EnableOutboundCalls;

            if (!extension.IsUseConferenceTransferNull())
            {
                cbHandOff.Checked = !extension.UseConferenceTransfer;
            }
            else
            {
                cbHandOff.Checked = true;
            }

            greetingControl.LoadGreeting(voicemailGreeting, WOSI.Utilities.FileUtils.GetApplicationRelativePath(Properties.Settings.Default.GreetingsSoundCache));

            if (!extension.IsPasswordNull() && extension.Password.Length > 0)
            {
                txtPassword.Text        = blankPassword;
                txtConfirmPassword.Text = blankPassword;
            }

            if (!extension.IsPBXPasswordNull() && extension.PBXPassword.Length > 0)
            {
                txtPBXPassword.Text        = blankPassword;
                txtConfirmPBXPassword.Text = blankPassword;
            }

            txtFirstName.Select();

            btnImportOutlook.Enabled = Utilities.ContactManagement.ContactManagerFactory.CreateContactManager(Utilities.ContactManagement.ContactType.Outlook).IsInstalled;

            loading = false;
            greetingControl.LoadVoices(ManagementInterfaceClient.ManagementInterface.GetTTSVoices());

            pgFindme.Enabled       = true;
            pnlHandoff.Visible     = true;
            pnlPBXPassword.Visible = true;

            Utils.PrivateLabelUtils.ReplaceProductNameControl(this);
        }
Esempio n. 14
0
        public void LoadGreeting(WOSI.CallButler.Data.CallButlerDataset.LocalizedGreetingsRow greeting, string greetingSoundCache)
        {
            recordingControl.Reset();
            speechControl.SpeechText = "";

            greetingRow = greeting;

            if (greeting != null)
            {
                this.GreetingType = (WOSI.CallButler.Data.GreetingType)greetingRow.Type;

                if (this.GreetingType == GreetingType.TextGreeting)
                {
                    speechControl.SpeechText = greetingRow.Data;
                    speechControl.Voice = greetingRow.Voice;
                }
                else if (this.GreetingType == GreetingType.SoundGreeting)
                {
                    recordingControl.LoadSoundFile(greetingSoundCache + "\\" + greetingRow.LanguageID + "\\" + greetingRow.GreetingID.ToString() + ".snd");
                }
            }
        }