private void StopSound(bool markAsRead)
        {
            soundPlayer.StopSound();

            progSound.LowerValue = 0;
            progSound.UpperValue = 0;

            btnStop.Enabled = false;
            btnPlay.Enabled = true;

            // If our current voicemail is new, mark it old
            if (markAsRead)
            {
                WOSI.CallButler.Data.CallButlerDataset.VoicemailsRow voicemail = GetSelectedVoicemail();

                if (voicemail != null & voicemail.IsNew)
                {
                    voicemail.IsNew = false;

                    if (VoicemailRead != null)
                    {
                        VoicemailRead(this, new VoicemailEventArgs(voicemail));
                    }
                }
            }

            if (fastUpdateTable != null)
            {
                RefreshVoicemails(fastUpdateTable);
                fastUpdateTable = null;
            }
        }
        private void btnPlay_Click(object sender, EventArgs e)
        {
            StopSound(false);

            // Check to see if our voicemail already exists
            WOSI.CallButler.Data.CallButlerDataset.VoicemailsRow voicemail = GetSelectedVoicemail();

            if (voicemail != null)
            {
                if (GetVoicemailSound != null)
                {
                    VoicemailEventArgs vmArgs = new VoicemailEventArgs(voicemail);
                    GetVoicemailSound(this, vmArgs);

                    if (File.Exists(vmArgs.SoundFilename))
                    {
                        btnStop.Enabled = true;
                        btnPlay.Enabled = false;

                        // Finally play our file
                        soundPlayer.PlaySoundAsync(vmArgs.SoundFilename);
                    }
                }
            }
        }
        public void SelectVoicemailByID(Guid voicemailID)
        {
            for (int index = 0; index < dgVoicemails.Rows.Count; index++)
            {
                WOSI.CallButler.Data.CallButlerDataset.VoicemailsRow voicemail = (WOSI.CallButler.Data.CallButlerDataset.VoicemailsRow)((DataRowView)dgVoicemails.Rows[index].DataBoundItem).Row;

                if (voicemail.VoicemailID == voicemailID)
                {
                    dgVoicemails.Rows[index].Selected = true;
                    return;
                }
            }
        }
        private void btnImportOutlook_Click(object sender, EventArgs e)
        {
            WOSI.CallButler.Data.CallButlerDataset.VoicemailsRow voicemail = GetSelectedVoicemail();

            if (voicemail != null)
            {
                global::Utilities.ContactManagement.IContactItem item = contactManager.SearchContact(voicemail.CallerUsername, voicemail.CallerDisplayName);
                if (item == null)
                {
                    item = global::Utilities.ContactManagement.ContactItemFactory.CreateContactItem(contactManager, voicemail.CallerDisplayName, voicemail.CallerUsername);
                }

                contactManager.ShowContactForm(item);
            }
        }
        private void dgVoicemails_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if (e.ColumnIndex == callerUsernameDataGridViewTextBoxColumn.Index)
            {
                e.Value = WOSI.Utilities.StringUtils.FormatPhoneNumber((string)e.Value);
            }
            else if (e.ColumnIndex == colVoicemailImage.Index)
            {
                WOSI.CallButler.Data.CallButlerDataset.VoicemailsRow voicemail = (WOSI.CallButler.Data.CallButlerDataset.VoicemailsRow)((DataRowView)dgVoicemails.Rows[e.RowIndex].DataBoundItem).Row;

                if (voicemail.IsNew)
                {
                    e.Value = Properties.Resources.message_information_16;
                }
            }
        }
        public byte[] GetVoicemailBytes(Guid extensionID, Guid voicemailId)
        {
            // Get our voicemail row first
            WOSI.CallButler.Data.CallButlerDataset.VoicemailsRow voicemail = dataProvider.GetVoicemail(extensionID, voicemailId);

            if (voicemail != null)
            {
                string path          = @"{0}\{1}\{2}.snd";
                string voicemailPath = String.Format(path, WOSI.Utilities.FileUtils.GetApplicationRelativePath(Properties.Settings.Default.VoicemailRootDirectory), voicemail.ExtensionID.ToString(), voicemailId.ToString());
                return(WOSI.Utilities.FileUtils.GetFileBytes(voicemailPath));
            }
            else
            {
                return(null);
            }
        }
        public void CreateVoicemail(Guid voicemailID, Guid extensionID, string callerDisplayName, string callerHost, string callerUsername)
        {
            // Get our extension
            WOSI.CallButler.Data.CallButlerDataset.ExtensionsRow extension = dataProvider.GetExtension(Properties.Settings.Default.CustomerID, extensionID);

            if (extension != null)
            {
                // Create a new voicemail record
                WOSI.CallButler.Data.CallButlerDataset.VoicemailsDataTable voicemailsTable = new WOSI.CallButler.Data.CallButlerDataset.VoicemailsDataTable();
                WOSI.CallButler.Data.CallButlerDataset.VoicemailsRow       voicemail       = voicemailsTable.NewVoicemailsRow();
                voicemail.CallerDisplayName = callerDisplayName;
                voicemail.CallerHost        = callerHost;
                voicemail.CallerUsername    = callerUsername;
                voicemail.ExtensionID       = extensionID;
                voicemail.VoicemailID       = voicemailID;
                voicemail.Timestamp         = DateTime.Now;
                voicemailsTable.AddVoicemailsRow(voicemail);

                dataProvider.PersistVoicemail(voicemail);

                // Run the voicemail through any VM plugins
                CallButler.Service.Plugin.CallButlerVoicemailHandlerPlugin[] vmHandlers = pluginManager.GetAllPluginsOfType <CallButler.Service.Plugin.CallButlerVoicemailHandlerPlugin>();
                foreach (CallButler.Service.Plugin.CallButlerVoicemailHandlerPlugin vmHandler in vmHandlers)
                {
                    try
                    {
                        vmHandler.OnNewVoicemail(voicemail.CallerDisplayName, voicemail.CallerHost, voicemail.ExtensionID.ToString(), voicemail.VoicemailID.ToString(), WOSI.Utilities.FileUtils.GetApplicationRelativePath(Properties.Settings.Default.VoicemailRootDirectory) + "\\" + voicemail.ExtensionID.ToString() + "\\" + voicemail.VoicemailID.ToString() + ".snd");
                    }
                    catch (Exception e)
                    {
                        LoggingService.AddLogEntry(WOSI.CallButler.ManagementInterface.LogLevel.ErrorsOnly, string.Format("Voicemail Handler Plugin Failed\r\n\r\n{0} ({1})\r\n\r\n{2}", vmHandler.PluginName, vmHandler.PluginID.ToString(), e.Message), true);
                    }
                }

                // Queue our voicemail Email
                vmMailerService.QueueVoicemailEmail(extension, voicemail);

                // Notify the any PBX phones of a new message
                if (registrarService != null)
                {
                    registrarService.SendMessageWaitingNotification(extension.ExtensionNumber);
                }

                // Notify anyone else of the new message
                WOSI.Utilities.EventUtils.FireAsyncEvent(NewVoicemail, this, new VoicemailEventArgs(voicemail));
            }
        }
        private void btnDeleteMessage_Click(object sender, EventArgs e)
        {
            StopSound(false);

            if (MessageBox.Show(this, Properties.LocalizedStrings.VoicemailControl_ConfirmDelete, Properties.LocalizedStrings.VoicemailControl_ConfirmDelete, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                WOSI.CallButler.Data.CallButlerDataset.VoicemailsRow voicemail = GetSelectedVoicemail();

                if (voicemail != null)
                {
                    // Delete remotely
                    if (VoicemailDeleted != null)
                    {
                        VoicemailDeleted(this, new VoicemailEventArgs(voicemail));
                    }

                    // Delete locally
                    voicemail.Delete();
                }
            }
        }
        private void btnSaveMessage_Click(object sender, EventArgs e)
        {
            WOSI.CallButler.Data.CallButlerDataset.VoicemailsRow vRow = GetSelectedVoicemail();
            if (vRow != null)
            {
                saveFileDialog.FileName = vRow.CallerUsername + ".snd";
                if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
                {
                    // Check to see if our voicemail already exists
                    if (GetVoicemailSound != null)
                    {
                        VoicemailEventArgs vmArgs = new VoicemailEventArgs(vRow);
                        GetVoicemailSound(this, vmArgs);

                        if (vmArgs.SoundFilename != String.Empty)
                        {
                            System.IO.File.Copy(vmArgs.SoundFilename, saveFileDialog.FileName, true);
                        }
                    }
                }
            }
        }
Beispiel #10
0
 public VoicemailEventArgs(WOSI.CallButler.Data.CallButlerDataset.VoicemailsRow voicemail, string soundFilename)
 {
     this.Voicemail = voicemail;
     this.SoundFilename = soundFilename;
 }
Beispiel #11
0
        public void QueueVoicemailEmail(WOSI.CallButler.Data.CallButlerDataset.ExtensionsRow extension, WOSI.CallButler.Data.CallButlerDataset.VoicemailsRow voicemail)
        {
            VoicemailData vmData = new VoicemailData();

            vmData.Extension = extension;
            vmData.Voicemail = voicemail;

            vmMailQueue.Enqueue(vmData);
        }
Beispiel #12
0
 public VoicemailEventArgs(WOSI.CallButler.Data.CallButlerDataset.VoicemailsRow voicemail)
 {
     this.Voicemail = voicemail;
 }
        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;
                }
                }
            }
        }
 public VoicemailEventArgs(WOSI.CallButler.Data.CallButlerDataset.VoicemailsRow voicemail, string soundFilename)
 {
     this.Voicemail     = voicemail;
     this.SoundFilename = soundFilename;
 }
 public VoicemailEventArgs(WOSI.CallButler.Data.CallButlerDataset.VoicemailsRow voicemail)
 {
     this.Voicemail = voicemail;
 }
 private string GetVoicemailFilePath(WOSI.CallButler.Data.CallButlerDataset.VoicemailsRow voicemail)
 {
     return(WOSI.Utilities.FileUtils.GetApplicationRelativePath(Properties.Settings.Default.VoicemailSoundCache) + "\\" + voicemail.ExtensionID.ToString() + "\\" + voicemail.VoicemailID.ToString() + ".snd");
 }
        private void UpdateUI()
        {
            UpdateMessageCount();

            if (dgVoicemails.SelectedRows.Count > 0)
            {
                WOSI.CallButler.Data.CallButlerDataset.VoicemailsRow voicemail = GetSelectedVoicemail();

                if (voicemail.IsNew)
                {
                    lblNewMessage.Text = Properties.LocalizedStrings.VoicemailControl_New;
                }
                else
                {
                    lblNewMessage.Text = "";
                }

                lblDateTime.Text = voicemail.Timestamp.ToString("MMM d yyyy, h:mm tt");

                if (voicemail.CallerDisplayName.Length > 0)
                {
                    lblCallerID.Text = voicemail.CallerDisplayName;
                }
                else
                {
                    lblCallerID.Text = Properties.LocalizedStrings.VoicemailControl_UnknownCaller;
                }

                lblTelephoneNumber.Text = WOSI.Utilities.StringUtils.FormatPhoneNumber(voicemail.CallerUsername);

                btnPlay.Enabled          = !soundPlayer.Playing;
                btnSaveMessage.Enabled   = true;
                btnDeleteMessage.Enabled = true;

                if (dgVoicemails.SelectedRows[0].Index > 0)
                {
                    btnPrevious.Enabled = true;
                }
                else
                {
                    btnPrevious.Enabled = false;
                }

                if (dgVoicemails.SelectedRows[0].Index < bsVoicemails.Count - 1)
                {
                    btnNext.Enabled = true;
                }
                else
                {
                    btnNext.Enabled = false;
                }

                if (contactManager != null)
                {
                    if (contactManager.IsInstalled)
                    {
                        btnImportOutlook.Enabled = true;
                    }
                    else
                    {
                        btnImportOutlook.Enabled = false;
                    }
                }
            }
            else
            {
                lblNewMessage.Text = "";

                lblDateTime.Text = "";
                lblCallerID.Text = "";

                lblTelephoneNumber.Text = "";


                btnPlay.Enabled          = false;
                btnStop.Enabled          = false;
                btnSaveMessage.Enabled   = false;
                btnDeleteMessage.Enabled = false;
                btnNext.Enabled          = false;
                btnPrevious.Enabled      = false;

                btnImportOutlook.Enabled = false;
            }
        }