public VoipPhone BuyNumber(string number) { if (!CRMSecurity.IsAdmin) { throw CRMSecurity.CreateSecurityException(); } var newPhone = VoipProvider.BuyNumber(number); newPhone.Settings = new VoipSettings { Queue = new Queue { Name = number, Size = 5, WaitTime = 30 } }; var files = StorageFactory.GetStorage("", "crm").ListFiles("voip/default/", "*", true) .Select(r => new { path = CommonLinkUtility.GetFullAbsolutePath(r.ToString()), audioType = (AudioType)Enum.Parse(typeof(AudioType), Directory.GetParent(r.ToString()).Name, true) }).ToList(); var audio = files.Find(r => r.audioType == AudioType.Greeting); if (audio != null) { newPhone.Settings.GreetingAudio = audio.path; } audio = files.Find(r => r.audioType == AudioType.HoldUp); if (audio != null) { newPhone.Settings.HoldAudio = audio.path; } audio = files.Find(r => r.audioType == AudioType.VoiceMail); if (audio != null) { newPhone.Settings.VoiceMail = new VoiceMail(audio.path, true); } audio = files.Find(r => r.audioType == AudioType.Queue); if (audio != null) { newPhone.Settings.Queue = new Queue(newPhone.Number, audio.path); } VoipProvider.UpdateSettings(newPhone); return(DaoFactory.GetVoipDao().SaveOrUpdateNumber(newPhone)); }
public VoipPhone BuyNumber(string number) { if (!CRMSecurity.IsAdmin) { throw CRMSecurity.CreateSecurityException(); } var newPhone = VoipProvider.BuyNumber(number); VoipProvider.CreateQueue(newPhone); SetDefaultAudio(newPhone); VoipProvider.UpdateSettings(newPhone); return(DaoFactory.VoipDao.SaveOrUpdateNumber(newPhone)); }
public VoipPhone LinkNumber(string id) { if (!CRMSecurity.IsAdmin) { throw CRMSecurity.CreateSecurityException(); } var newPhone = VoipProvider.GetPhone(id); VoipProvider.CreateQueue(newPhone); SetDefaultAudio(newPhone); VoipProvider.UpdateSettings(newPhone); return(DaoFactory.GetVoipDao().SaveOrUpdateNumber(newPhone)); }