private void ChangePriority(FindMeNumberDiagramShape fmd, short prChange) { WOSI.CallButler.Data.CallButlerDataset.ExtensionContactNumbersRow contactRow = fmd.ContactRow; short oldPriority = contactRow.Priority; // Increase the priority of the current contactRow. Zero is highest priority. contactRow.Priority += prChange; // Get all or our contacts in order of priority WOSI.CallButler.Data.CallButlerDataset.ExtensionContactNumbersRow[] contactRows = (WOSI.CallButler.Data.CallButlerDataset.ExtensionContactNumbersRow[])ExtensionContactTable.Select("ExtensionID = '" + extension.ExtensionID + "'", "Priority ASC"); foreach (WOSI.CallButler.Data.CallButlerDataset.ExtensionContactNumbersRow contact in contactRows) { if (contact != contactRow && contact.Priority >= contactRow.Priority) { contact.Priority = oldPriority; break; } } UpdatePriorityNumbers(); int childIndex = pnlFlow.Controls.GetChildIndex(fmd); if ((prChange > 0 && childIndex > 1) || (prChange < 0 && childIndex < pnlFlow.Controls.Count)) { childIndex -= prChange; pnlFlow.Controls.SetChildIndex(fmd, childIndex); } }
private void DeleteContactItem(FindMeNumberDiagramShape fmd) { WOSI.CallButler.Data.CallButlerDataset.ExtensionContactNumbersRow contactRow = fmd.ContactRow; Guid extensionId = contactRow.ExtensionID; Guid extContactId = contactRow.ExtensionContactNumberID; contactRow.Delete(); pnlFlow.Controls.Remove(fmd); }
private void AddContactItem() { // Update our current contact numbers priority and return the highest priority number short priorityNumber = UpdatePriorityNumbers(); WOSI.CallButler.Data.CallButlerDataset.ExtensionContactNumbersRow contactRow = ExtensionContactTable.NewExtensionContactNumbersRow(); contactRow.ExtensionContactNumberID = Guid.NewGuid(); contactRow.ExtensionID = extension.ExtensionID; contactRow.Priority = priorityNumber; contactRow.Timeout = 20; ExtensionContactTable.AddExtensionContactNumbersRow(contactRow); AddContactControl(extensions, contactRow, true); }
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(ScheduleReminderExternalCommands), command)) { ScheduleReminderExternalCommands externalCommand = WOSI.Utilities.EnumUtils <ScheduleReminderExternalCommands> .Parse(command); switch (externalCommand) { case ScheduleReminderExternalCommands.CALLBUTLERINTERNAL_GetNextNumber: { // If we have a previous call, end it if (telecomProvider.IsLineInUse(tsInterface.LineNumber)) { telecomProvider.EndCall(tsInterface.LineNumber); } extensionNumberIndex++; // Get our extension contact numbers WOSI.CallButler.Data.CallButlerDataset.ExtensionContactNumbersRow[] contactNumbers = (WOSI.CallButler.Data.CallButlerDataset.ExtensionContactNumbersRow[])dataProvider.GetExtensionContactNumbers(extension.ExtensionID).Select("", "Priority ASC"); while (extensionNumberIndex < contactNumbers.Length) { WOSI.CallButler.Data.CallButlerDataset.ExtensionContactNumbersRow contactNumber = contactNumbers[extensionNumberIndex]; // Is the number online? if (contactNumber.Online) { // Does the number have hours? if (!contactNumber.HasHoursOfOperation || (contactNumber.HasHoursOfOperation && ScriptUtils.IsInHoursOfOperation(contactNumber.HoursOfOperation, contactNumber.HoursOfOperationUTCOffset))) { // If we get here, try the number tsInterface.IMLInterpreter.SetLocalVariable("NumberToCall", contactNumber.ContactNumber); tsInterface.IMLInterpreter.SetLocalVariable("ExtensionTimeout", contactNumber.Timeout.ToString()); string introDetails = "You have " + reminders.Length + " upcoming appointment"; if (reminders.Length > 1) { introDetails += "s"; } introDetails += "."; tsInterface.IMLInterpreter.SetLocalVariable("IntroDetails", introDetails); tsInterface.IMLInterpreter.SignalEventCallback(eventToken); return; } } extensionNumberIndex++; } if (telecomProvider.IsLineInUse(tsInterface.LineNumber)) { telecomProvider.EndCall(tsInterface.LineNumber); } tsInterface.IMLInterpreter.StopScript(); break; } case ScheduleReminderExternalCommands.CALLBUTLERINTERNAL_FetchNextReminder: { reminderIndex++; if (reminderIndex < reminders.Length) { OutlookReminder reminder = reminders[reminderIndex]; tsInterface.IMLInterpreter.SetLocalVariable("ScheduleDetails", GetReminderDetails(reminder)); if (reminderIndex == reminders.Length - 1) { tsInterface.IMLInterpreter.SignalExternalEvent(ScheduleReminderExternalEvents.CALLBUTLERINTERNAL_LastReminder.ToString()); } else { tsInterface.IMLInterpreter.SignalEventCallback(eventToken); } } else { tsInterface.IMLInterpreter.SignalExternalEvent(ScheduleReminderExternalEvents.CALLBUTLERINTERNAL_EndOfReminders.ToString()); } break; } } } }
private void AddContactControl(WOSI.CallButler.Data.CallButlerDataset.ExtensionsDataTable extensions, WOSI.CallButler.Data.CallButlerDataset.ExtensionContactNumbersRow contactRow, bool scrollIntoView) { // Create our contact number shape FindMeNumberDiagramShape fmd = new FindMeNumberDiagramShape(extensions, contactRow); fmd.Dock = DockStyle.Top; fmd.NumberType = numberType; fmd.UsingCallBlast = cbCallBlast.Checked; fmd.EnableCallIPPhone = enableCallIPPhone; fmd.Visible = false; fmd.DeletePressed += new EventHandler(fmd_DeletePressed); fmd.MoveDownPressed += new EventHandler(fmd_MoveDownPressed); fmd.MoveUpPressed += new EventHandler(fmd_MoveUpPressed); fmd.SizeChanged += new EventHandler(fmd_SizeChanged); pnlFlow.Controls.Add(fmd); pnlFlow.Controls.SetChildIndex(fmd, 1); fmd.Visible = true; if (scrollIntoView) { fmd.Expanded = true; //pnlFlow.ScrollControlIntoView(fmd); //pnlFlow.AutoScrollPosition = new Point(pnlFlow.AutoScrollPosition.X, fmd.Top); } }
public FindMeNumberDiagramShape(WOSI.CallButler.Data.CallButlerDataset.ExtensionsDataTable extensions, WOSI.CallButler.Data.CallButlerDataset.ExtensionContactNumbersRow contactRow) { this.contactRow = contactRow; this.extensions = extensions; InitializeComponent(); Expanded = false; WOSI.Utilities.TimeUtils timeUtils = new WOSI.Utilities.TimeUtils(); cboTimeZone.DataSource = timeUtils.TimeZones; cboTimeZone.SelectedIndex = timeUtils.CurrentTimeZoneIndex; numTimeout.Value = contactRow.Timeout; cbExtensionHours.Checked = contactRow.HasHoursOfOperation; scheduleControl.DeserializeSelection(contactRow.HoursOfOperation); // For compatibility with old data model if (contactRow.CallPBXPhone) { contactRow.CallPBXPhone = false; SelectIPPhone(); } else { switch ((WOSI.CallButler.Data.ExtensionContactNumberType)contactRow.Type) { case WOSI.CallButler.Data.ExtensionContactNumberType.TelephoneNumber: SelectTelephone(); txtContactNumber.Text = contactRow.ContactNumber; break; case WOSI.CallButler.Data.ExtensionContactNumberType.Extension: SelectExtension(); // Select the proper extension try { Guid extensionID = new Guid(contactRow.ContactNumber); foreach (global::Controls.ListBoxExItem item in cboExtension.Items) { WOSI.CallButler.Data.CallButlerDataset.ExtensionsRow extension = (WOSI.CallButler.Data.CallButlerDataset.ExtensionsRow)item.Tag; if (extension.ExtensionID == extensionID) { cboExtension.SelectedItem = item; } } } catch { } break; case WOSI.CallButler.Data.ExtensionContactNumberType.IPPhone: SelectIPPhone(); txtContactNumber.Text = ""; break; } } // Select the proper time zone if (!contactRow.IsHoursOfOperationUTCOffsetNull()) { int tzIndex = timeUtils.GetTimeZoneIndexFromStandardOffset(contactRow.HoursOfOperationUTCOffset); if (tzIndex >= 0) { cboTimeZone.SelectedIndex = tzIndex; } } loading = false; }
private void Wizard_BeforePageChanged(object sender, global::Controls.Wizard.PageChangedEventArgs e) { switch (Wizard.PageIndex) { case 0: // Validate our Email address if (!System.Text.RegularExpressions.Regex.IsMatch(txtEmail.Text, @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$")) { MessageBox.Show(this, CallButler.Manager.Utils.PrivateLabelUtils.ReplaceProductName(Properties.LocalizedStrings.Common_EnterValidEmail), CallButler.Manager.Utils.PrivateLabelUtils.ReplaceProductName(Properties.LocalizedStrings.Common_InvalidEmail), MessageBoxButtons.OK, MessageBoxIcon.Warning); txtEmail.Clear(); txtEmail.Select(); e.Cancel = true; return; } // Validate the user name if (txtName.Text.Length == 0) { MessageBox.Show(this, CallButler.Manager.Utils.PrivateLabelUtils.ReplaceProductName(Properties.LocalizedStrings.Common_NameRequired), "", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtName.Select(); e.Cancel = true; return; } // Validate the user name if (txtPhone.Text.Length == 0) { MessageBox.Show(this, CallButler.Manager.Utils.PrivateLabelUtils.ReplaceProductName(Properties.LocalizedStrings.Common_PhoneNumberRequired), "", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtPhone.Select(); e.Cancel = true; return; } // Validate the country if (cboCountry.SelectedIndex == 0) { MessageBox.Show(this, CallButler.Manager.Utils.PrivateLabelUtils.ReplaceProductName(Properties.LocalizedStrings.Common_SelectCountry), "", MessageBoxButtons.OK, MessageBoxIcon.Warning); e.Cancel = true; return; } /*if (txtEmail.Text != "*****@*****.**") * { * // Send the registration to our webservice * RegistrationServices.RegistrationService regService = new CallButler.Manager.RegistrationServices.RegistrationService(); * * //Controls.LoadingDialog.ShowDialog(this, Properties.LocalizedStrings.Common_SendingData, Properties.Resources.loading, false, 2000); * * try * { * regService.Register2(txtName.Text, txtEmail.Text, txtCompanyName.Text, ManagementInterfaceClient.ManagementInterface.ProductID, true, cboCountry.Text, txtPhone.Text); * } * catch(Exception exp) * { * } * * //Controls.LoadingDialog.HideDialog(); * }*/ ManagementInterfaceClient.ManagementInterface.IsDownloadRegistered = true; // Create a new default extension if one doesn't exist WOSI.CallButler.Data.CallButlerDataset.ExtensionsDataTable extensionDataTable = ManagementInterfaceClient.ManagementInterface.GetExtensionNumber(ManagementInterfaceClient.AuthInfo, 100); if (extensionDataTable == null || extensionDataTable.Count == 0) { // Create a new Extension row extensionDataTable = new WOSI.CallButler.Data.CallButlerDataset.ExtensionsDataTable(); WOSI.CallButler.Data.CallButlerDataset.ExtensionsRow extension = extensionDataTable.NewExtensionsRow(); extension.CustomerID = Properties.Settings.Default.CustomerID; extension.ExtensionID = Guid.NewGuid(); extension.EmailAddress = txtEmail.Text; extension.EmailAttachment = true; extension.EmailNotification = true; extension.EnableSearch = true; extension.ExtensionNumber = 100; string[] name = txtName.Text.Split(' '); extension.FirstName = name[0]; if (name.Length > 1) { for (int index = 1; index < name.Length; index++) { extension.LastName += name[index] + " "; } } extensionDataTable.AddExtensionsRow(extension); // Persist our extension ManagementInterfaceClient.ManagementInterface.PersistExtension(ManagementInterfaceClient.AuthInfo, extensionDataTable); // Create a new extension contact numbers table WOSI.CallButler.Data.CallButlerDataset.ExtensionContactNumbersDataTable extensionContactNumbers = new WOSI.CallButler.Data.CallButlerDataset.ExtensionContactNumbersDataTable(); WOSI.CallButler.Data.CallButlerDataset.ExtensionContactNumbersRow contactNumber = extensionContactNumbers.NewExtensionContactNumbersRow(); contactNumber.ContactNumber = txtPhone.Text; contactNumber.ExtensionContactNumberID = Guid.NewGuid(); contactNumber.ExtensionID = extension.ExtensionID; contactNumber.Timeout = 20; extensionContactNumbers.AddExtensionContactNumbersRow(contactNumber); // Persist our contact numbers ManagementInterfaceClient.ManagementInterface.PersistExtensionContactNumbers(ManagementInterfaceClient.AuthInfo, extensionContactNumbers); } break; } }
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(ExtensionExternalCommands), command)) { ExtensionExternalCommands externalCommand = WOSI.Utilities.EnumUtils <ExtensionExternalCommands> .Parse(command); switch (externalCommand) { case ExtensionExternalCommands.CALLBUTLERINTERNAL_ForwardCall: { onholdTsInterface.IMLInterpreter.SetLocalVariable("TransferNumber", commandData); onholdTsInterface.IMLInterpreter.SignalExternalEvent(VoicemailExternalEvents.CALLBUTLERINTERNAL_CallForwarded.ToString()); break; } case ExtensionExternalCommands.CALLBUTLERINTERNAL_ConfirmingTransfer: { if (disableCallScreening || !extension.EnableCallScreening) { tsInterface.IMLInterpreter.SignalExternalEvent(ExtensionExternalEvents.CALLBUTLERINTERNAL_SkipConfirmation.ToString()); } else { tsInterface.IMLInterpreter.SignalEventCallback(eventToken); } break; } case ExtensionExternalCommands.CALLBUTLERINTERNAL_GetNextNumber: { string callerID = onholdTsInterface.IMLInterpreter.CallerDisplayName; string callerNumber = onholdTsInterface.IMLInterpreter.CallerUsername; if (callerID == null || callerID.Length == 0) { callerID = "Unknown Caller"; } if (callerNumber == null || callerNumber.Length == 0) { callerNumber = ""; } // If we have a previous call, end it if (telecomProvider.IsLineInUse(tsInterface.LineNumber)) { telecomProvider.EndCall(tsInterface.LineNumber); } else { // Get our extension contact numbers List <WOSI.CallButler.Data.CallButlerDataset.ExtensionContactNumbersRow> contactNumbers = new List <WOSI.CallButler.Data.CallButlerDataset.ExtensionContactNumbersRow>((WOSI.CallButler.Data.CallButlerDataset.ExtensionContactNumbersRow[])dataProvider.GetExtensionContactNumbers(extension.ExtensionID).Select("", "Priority ASC")); if (extensionNumberIndex + 1 >= contactNumbers.Count && parentExtension != null) { extensionNumberIndex = parentExtensionIndex; parentExtensionIndex = -1; extension = parentExtension; parentExtension = null; contactNumbers.Clear(); contactNumbers.AddRange((WOSI.CallButler.Data.CallButlerDataset.ExtensionContactNumbersRow[])dataProvider.GetExtensionContactNumbers(extension.ExtensionID).Select("", "Priority ASC")); } extensionNumberIndex++; List <string> callBlastNumbers = new List <string>(); List <string> callBlastProfiles = new List <string>(); int callBlastTimeout = Properties.Settings.Default.CallBlastTimeout; while (extensionNumberIndex < contactNumbers.Count) { WOSI.CallButler.Data.CallButlerDataset.ExtensionContactNumbersRow contactNumber = contactNumbers[extensionNumberIndex]; // Is the number online? if (contactNumber.Online) { // Does the number have hours? TimeSpan utcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now); if (!contactNumber.IsHoursOfOperationUTCOffsetNull()) { utcOffset = contactNumber.HoursOfOperationUTCOffset; } if (!contactNumber.HasHoursOfOperation || (contactNumber.HasHoursOfOperation && ScriptUtils.IsInHoursOfOperation(contactNumber.HoursOfOperation, utcOffset))) { // Check to see if this number is a PBX IP line if ((contactNumber.CallPBXPhone || (WOSI.CallButler.Data.ExtensionContactNumberType)contactNumber.Type == WOSI.CallButler.Data.ExtensionContactNumberType.IPPhone) && registrarService != null) { int extNumber = extension.ExtensionNumber; // If this was filled in from another extension, we'll need to check the status of that extension if (contactNumber.ExtensionID != extension.ExtensionID) { WOSI.CallButler.Data.CallButlerDataset.ExtensionsRow tmpExtension = dataProvider.GetExtension(Properties.Settings.Default.CustomerID, contactNumber.ExtensionID); if (tmpExtension != null) { extNumber = tmpExtension.ExtensionNumber; } } // Check to see if this pbx phone is online PBXPresenceInfo[] presInfos = registrarService.GetPresenceInfoForExtension(extNumber); if (presInfos != null && presInfos.Length > 0) { foreach (PBXPresenceInfo presInfo in presInfos) { if (presInfo.Status == PBXPresenceStatus.Online) { if (presInfos.Length > 1 || extension.UseCallBlast) { if (contactNumbers.Count == 1) { callBlastTimeout = contactNumber.Timeout; } string callBlastNumber = string.Format("sip:{0}@{1}:{2}", presInfo.ExtensionNumber, presInfo.RemoteAddress, presInfo.RemotePort); if (!callBlastNumbers.Contains(callBlastNumber)) { callBlastNumbers.Add(callBlastNumber); callBlastProfiles.Add(TelecomScriptInterface.InternalProviderProfileName); } } else { TryContactNumber(tsInterface, string.Format("sip:{0}@{1}:{2}", presInfo.ExtensionNumber, presInfo.RemoteAddress, presInfo.RemotePort), callerID, callerNumber, TelecomScriptInterface.InternalProviderProfileName, contactNumber.Timeout.ToString(), eventToken); return; } } } if (!extension.UseCallBlast && callBlastNumbers.Count > 0) { break; } } } else if ((WOSI.CallButler.Data.ExtensionContactNumberType)contactNumber.Type == WOSI.CallButler.Data.ExtensionContactNumberType.TelephoneNumber) { if (extension.UseCallBlast) { if (!callBlastNumbers.Contains(contactNumber.ContactNumber)) { callBlastNumbers.Add(contactNumber.ContactNumber); callBlastProfiles.Add(""); } } else { TryContactNumber(tsInterface, contactNumber.ContactNumber, callerID, callerNumber, "", contactNumber.Timeout.ToString(), eventToken); return; } } else if ((WOSI.CallButler.Data.ExtensionContactNumberType)contactNumber.Type == WOSI.CallButler.Data.ExtensionContactNumberType.Extension && parentExtension == null) { try { // Get our new extension WOSI.CallButler.Data.CallButlerDataset.ExtensionsRow newExtension = dataProvider.GetExtension(Properties.Settings.Default.CustomerID, new Guid(contactNumber.ContactNumber)); if (newExtension != null) { if (extension.UseCallBlast) { WOSI.CallButler.Data.CallButlerDataset.ExtensionContactNumbersRow[] newContacts = (WOSI.CallButler.Data.CallButlerDataset.ExtensionContactNumbersRow[])dataProvider.GetExtensionContactNumbers(newExtension.ExtensionID).Select("Type <> " + (int)WOSI.CallButler.Data.ExtensionContactNumberType.Extension, "Priority ASC"); contactNumbers.AddRange(newContacts); } else { parentExtension = extension; parentExtensionIndex = extensionNumberIndex; extensionNumberIndex = -1; extension = newExtension; tsInterface.IMLInterpreter.SignalExternalEvent(ExtensionExternalEvents.CALLBUTLERINTERNAL_GetNextNumber.ToString()); return; } } } catch { } } } } extensionNumberIndex++; } if (callBlastNumbers.Count > 0) { TryCallBlast(telecomProvider, tsInterface, callBlastNumbers.ToArray(), callBlastProfiles.ToArray(), callerID, callerNumber, callBlastTimeout.ToString()); return; } else { tsInterface.IMLInterpreter.SignalExternalEvent(ExtensionExternalEvents.CALLBUTLERINTERNAL_NoMoreNumbers.ToString()); } } break; } case ExtensionExternalCommands.CALLBUTLERINTERNAL_SendToVoicemail: { onholdTsInterface.IMLInterpreter.SyncExternalAction -= IMLInterpreter_SyncExternalAction; // Allow this line to answer calls again tsInterface.Locked = false; if (telecomProvider.IsLineInUse(onholdTsInterface.LineNumber)) { telecomProvider.SendingToVoicemail(onholdTsInterface.LineNumber); } onholdTsInterface.IMLInterpreter.SignalExternalEvent(VoicemailExternalEvents.CALLBUTLERINTERNAL_ExtensionNotAvailable.ToString()); tsInterface.IMLInterpreter.SignalEventCallback(eventToken); break; } case ExtensionExternalCommands.CALLBUTLERINTERNAL_ConnectCalls: { onholdTsInterface.IMLInterpreter.SyncExternalAction -= IMLInterpreter_SyncExternalAction; onholdTsInterface.IMLInterpreter.SignalExternalEvent(ExtensionExternalCommands.CALLBUTLERINTERNAL_ConnectCalls.ToString()); // Allow this line to answer calls again tsInterface.Locked = false; if (autoConnect) { if (telecomProvider.IsLineInUse(tsInterface.LineNumber) && telecomProvider.IsLineInUse(onholdTsInterface.LineNumber)) { if (extension.IsUseConferenceTransferNull() || !extension.UseConferenceTransfer /*|| !Licensing.Management.AppPermissions.StatIsPermitted("Handoff")*/) { telecomProvider.TransferCallAttended(onholdTsInterface.LineNumber, tsInterface.LineNumber, Properties.Settings.Default.UseBridgedTransfers); tsInterface.IMLInterpreter.SignalEventCallback(eventToken); } else { telecomProvider.StopSound(tsInterface.LineNumber); telecomProvider.StopSound(onholdTsInterface.LineNumber); int conferenceID = telecomProvider.ConferenceLines(tsInterface.LineNumber, onholdTsInterface.LineNumber); // Check to see if the person calling is an internal extension if (onholdTsInterface.Extension != null) { onholdTsInterface.ScriptProcessor = new TransferConferenceScriptProcessor(conferenceID, scriptService, tsInterface, registrarService, extension, vmMailerService); } else { onholdTsInterface.ScriptProcessor = new TransferConferenceParticipantScriptProcessor(conferenceID, tsInterface, extension, vmMailerService); } tsInterface.ScriptProcessor = new TransferConferenceScriptProcessor(conferenceID, scriptService, onholdTsInterface, registrarService, extension, vmMailerService); onholdTsInterface.ScriptProcessor.StartProcessing(onholdTsInterface, telecomProvider, dataProvider); tsInterface.ScriptProcessor.StartProcessing(tsInterface, telecomProvider, dataProvider); } } else { tsInterface.IMLInterpreter.SignalEventCallback(eventToken); } } break; } } } }