public async Task <ActionResult> Remove(int id) { using (VoiceMailDataProvider dataProvider = new VoiceMailDataProvider()) { if (!await dataProvider.RemoveItemByIdentityAsync(id)) { throw new Error(this.__ResStr("cantRemove", "Couldn't remove voice mail message with id {0}", id)); } return(Reload(null, Reload: ReloadEnum.ModuleParts)); } }
private GridDefinition GetGridModel() { return(new GridDefinition { SizeStyle = GridDefinition.SizeStyleEnum.SizeToFit, ModuleGuid = Module.ModuleGuid, //SettingsModuleGuid = Module.PermanentGuid, RecordType = typeof(BrowseItem), AjaxUrl = GetActionUrl(nameof(BrowseVoiceMails_GridData)), DirectDataAsync = async(int skip, int take, List <DataProviderSortInfo> sort, List <DataProviderFilterInfo> filters) => { List <string> extensions = new List <string>(); if (!Manager.HasSuperUserRole) { using (ExtensionEntryDataProvider extDP = new ExtensionEntryDataProvider()) { extensions = await extDP.GetExtensionsForUserAsync(Manager.UserId); } if (extensions.Count == 0) { throw new Error(this.__ResStr("noInbox", "No extension defined for the current user")); } } DisplayVoiceMailModule dispMod = (DisplayVoiceMailModule)await ModuleDefinition.LoadAsync(ModuleDefinition.GetPermanentGuid(typeof(DisplayVoiceMailModule))); using (VoiceMailDataProvider dataProvider = new VoiceMailDataProvider()) { List <DataProviderFilterInfo> extFilters = null; foreach (string extension in extensions) { extFilters = DataProviderFilterInfo.Join(extFilters, new DataProviderFilterInfo { Field = nameof(ExtensionEntry.Extension), Operator = "==", Value = extension }, SimpleLogic: "||"); } if (extFilters != null) { filters = DataProviderFilterInfo.Join(filters, new DataProviderFilterInfo { Filters = extFilters, Logic = "||" }); } DataProviderGetRecords <VoiceMailData> browseItems = await dataProvider.GetItemsAsync(skip, take, sort, filters); return new DataSourceResult { Data = (from s in browseItems.Data select new BrowseItem(Module, dispMod, s)).ToList <object>(), Total = browseItems.Total }; } }, }); }
public async Task <ActionResult> DisplayVoiceMail(int id) { using (VoiceMailDataProvider voiceMailDP = new VoiceMailDataProvider()) { VoiceMailData voiceMail = await voiceMailDP.GetItemByIdentityAsync(id); if (voiceMail == null) { throw new Error(this.__ResStr("notFound", "Voice mail entry with id {0} not found"), id); } voiceMail.Heard = true; await voiceMailDP.UpdateItemAsync(voiceMail); DisplayModel model = new DisplayModel() { Listen = await Module.GetAction_ListenAsync(voiceMail.RecordingUrl) }; model.SetData(voiceMail); return(View(model)); } }
private async Task <ActionResult> RunEntryAsync(IVRConfig ivrConfig, ScriptData script, string called, string extension, ScriptEntry entry, int errCount) { string extensionName = null; string extensionSpaced = null; if (!string.IsNullOrWhiteSpace(extension)) { extensionSpaced = Spaced(extension); Extension e = script.FindExtension(extension); if (e != null) { extensionName = e.Name; } } string digits; TryGetForm("Digits", out digits); string actionUrl = Utility.UrlFor(typeof(CallController), nameof(Process)); #if DEBUG actionUrl = Manager.CurrentSite.MakeFullUrl(actionUrl, SecurityType: YetaWF.Core.Pages.PageDefinition.PageSecurityType.Any); #else actionUrl = Manager.CurrentSite.MakeFullUrl(actionUrl, SecurityType: YetaWF.Core.Pages.PageDefinition.PageSecurityType.httpsOnly); #endif string token = DateTime.UtcNow.Ticks.ToString(); string encryptedToken; RSACrypto.Encrypt(ivrConfig.PublicKey, token, out encryptedToken); object parms = new { Url = actionUrl, Caller = GetForm("Caller"), CallerSpaced = Spaced(GetForm("Caller").TruncateStart("+1")), CallerCity = GetForm("CallerCity"), CallerCountry = GetForm("CallerCountry"), Digits = digits, Extension = extension, ExtensionSpaced = extensionSpaced, ExtensionName = extensionName, ErrCount = errCount, ErrCountPlus1 = errCount + 1, Token = encryptedToken, Voice = ivrConfig.Voice, VoiceInternal = ivrConfig.VoiceInternal, }; string text = entry.Text; Variables vars = new Variables(Manager, parms) { EncodingType = Variables.EncodingTypeEnum.XML }; Extension ext = script.FindExtension(digits); if (ext != null) { text = RepeatableNumbers(ext, text); } if (text.Contains("RECORDVOICEMAIL")) { text = text.Replace("RECORDVOICEMAIL", ""); VoiceMailData voiceMail; using (VoiceMailDataProvider voiceMailDP = new VoiceMailDataProvider()) { voiceMail = new VoiceMailData { Caller = GetForm("Caller").Truncate(Globals.MaxPhoneNumber), CallerCity = GetForm("CallerCity").Truncate(VoiceMailData.MaxCity), CallerState = GetForm("CallerState").Truncate(VoiceMailData.MaxState), CallerZip = GetForm("CallerZip").Truncate(VoiceMailData.MaxZip), CallerCountry = GetForm("CallerCountry").Truncate(VoiceMailData.MaxCountry), CallSid = GetForm("CallSid"), RecordingSid = GetForm("RecordingSid"), Duration = ConvertToInt(GetForm("RecordingDuration")), To = called, Extension = extension, RecordingUrl = GetForm("RecordingUrl").Truncate(Globals.MaxUrl) }; if (!await voiceMailDP.AddItemAsync(voiceMail)) { Logging.AddErrorLog($"Couldn't record voice mail status for call from {GetForm("Caller")}"); } } if (!string.IsNullOrWhiteSpace(extension)) { ext = script.FindExtension(extension); if (ext != null) { DisplayVoiceMailModule dispMod = (DisplayVoiceMailModule)await ModuleDefinition.LoadAsync(ModuleDefinition.GetPermanentGuid(typeof(DisplayVoiceMailModule))); ModuleAction displayAction = await dispMod.GetAction_DisplayAsync(null, voiceMail.Id); if (displayAction != null) { string viewUrl = displayAction.GetCompleteUrl(); foreach (ExtensionNumber extNumber in ext.Numbers) { if (extNumber.SendSMSVoiceMail) { SendSMS sendSMS = new SendSMS(); await sendSMS.SendMessageAsync(extNumber.Number, this.__ResStr("voiceSMS", "A voice mail was received for extension {0} ({1}) from {2}, {3}, {4}, {5} {6} - {7}", extension, GetForm("To"), GetForm("Caller"), GetForm("CallerCity"), GetForm("CallerState"), GetForm("CallerZip"), GetForm("CallerCountry"), viewUrl), ThrowError : false); } } } } } } text = vars.ReplaceVariables(text); Logging.AddLog($"{nameof(RunEntryAsync)}: {text}"); return(Content(text, "text/xml")); }