Example #1
0
        public override VoipPhone SaveOrUpdateNumber(VoipPhone phone)
        {
            var result = base.SaveOrUpdateNumber(phone);

            VoipDaoCache.ResetCache(TenantID);
            return(result);
        }
Example #2
0
 public virtual void DeleteNumber(VoipPhone phone)
 {
     using (var db = GetDb())
     {
         db.ExecuteNonQuery(Delete(numberTable).Where("id", phone.Id));
     }
 }
Example #3
0
 public override void DeleteNumber(VoipPhone phone)
 {
     notify.Publish(new CachedVoipItem {
         Tenant = TenantID
     }, CacheNotifyAction.Remove);
     base.DeleteNumber(phone);
 }
Example #4
0
 public override VoipPhone SaveOrUpdateNumber(VoipPhone phone)
 {
     notify.Publish(new CachedVoipItem {
         Tenant = TenantID
     }, CacheNotifyAction.InsertOrUpdate);
     return(base.SaveOrUpdateNumber(phone));
 }
Example #5
0
        public void DisablePhone(VoipPhone phone)
        {
            var result = client.UpdateIncomingPhoneNumber(phone.Id, new PhoneNumberOptions {
                VoiceUrl = null, VoiceApplicationSid = null
            });

            ThrowIfError(result);
        }
Example #6
0
        public void UpdateSettings(VoipPhone phone)
        {
            var result = client.UpdateIncomingPhoneNumber(phone.Id, new PhoneNumberOptions {
                VoiceUrl = phone.Settings.Connect(false), VoiceApplicationSid = null
            });

            ThrowIfError(result);
        }
Example #7
0
        public void DisablePhone(VoipPhone phone)
        {
            var result = client.UpdateIncomingPhoneNumber(phone.Id, new PhoneNumberOptions {
                VoiceUrl = "", SmsUrl = ""
            });

            ThrowIfError(result);
        }
        public override VoipPhone SaveOrUpdateNumber(VoipPhone phone)
        {
            var result = base.SaveOrUpdateNumber(phone);

            notify.Publish(new CachedVoipItem {
                Tenant = TenantID
            }, CacheNotifyAction.Any);
            return(result);
        }
        public VoipPhone DeleteNumber(VoipPhone phone)
        {
            var request = new RestRequest
            {
                Method     = Method.GET,
                Resource   = "DeactivatePhoneNumber/",
                Parameters = { new Parameter {
                                   Name = "phone_id", Value = phone.Id, Type = ParameterType.QueryString
                               } }
            };

            var result = Execute <VoxImplantBaseResponse>(request);

            ThrowIfError(result);
            return(phone);
        }
Example #10
0
        public virtual VoipPhone SaveOrUpdateNumber(VoipPhone phone)
        {
            using (var db = GetDb())
            {
                var insert = Insert(numberTable)
                             .InColumnValue("id", phone.Id)
                             .InColumnValue("number", phone.Number)
                             .InColumnValue("alias", phone.Alias);

                if (phone.Settings != null)
                {
                    insert.InColumnValue("settings", phone.Settings.ToString());
                }

                db.ExecuteNonQuery(insert);
            }
            return(phone);
        }
Example #11
0
        public virtual VoipPhone SaveOrUpdateNumber(VoipPhone phone)
        {
            if (!string.IsNullOrEmpty(phone.Number))
            {
                phone.Number = phone.Number.TrimStart('+');
            }

            var voipNumber = new VoipNumber
            {
                Id       = phone.Id,
                Number   = phone.Number,
                Alias    = phone.Alias,
                Settings = phone.Settings.ToString(),
                TenantId = TenantID
            };

            VoipDbContext.VoipNumbers.Add(voipNumber);
            VoipDbContext.SaveChanges();

            return(phone);
        }
Example #12
0
        public void SetDefaultAudio(VoipPhone newPhone)
        {
            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.IsAbsoluteUri ? r.AbsolutePath.ToString() : r.ToString()).Name, true)
            }).ToList();

            var audio = files.Find(r => r.audioType == AudioType.Greeting);

            newPhone.Settings.GreetingAudio = audio != null ? audio.path : "";

            audio = files.Find(r => r.audioType == AudioType.HoldUp);
            newPhone.Settings.HoldAudio = audio != null ? audio.path : "";

            audio = files.Find(r => r.audioType == AudioType.VoiceMail);
            newPhone.Settings.VoiceMail = audio != null ? audio.path : "";

            audio = files.Find(r => r.audioType == AudioType.Queue);
            newPhone.Settings.Queue.WaitUrl = audio != null ? audio.path : "";
        }
Example #13
0
        public virtual VoipPhone SaveOrUpdateNumber(VoipPhone phone)
        {
            if (!string.IsNullOrEmpty(phone.Number))
            {
                phone.Number = phone.Number.TrimStart('+');
            }

            using (var db = GetDb())
            {
                var insert = Insert("crm_voip_number")
                             .InColumnValue("id", phone.Id)
                             .InColumnValue("number", phone.Number)
                             .InColumnValue("alias", phone.Alias);

                if (phone.Settings != null)
                {
                    insert.InColumnValue("settings", phone.Settings.ToString());
                }

                db.ExecuteNonQuery(insert);
            }
            return(phone);
        }
        public void SetDefaultAudio(VoipPhone newPhone)
        {
            var          storage = StorageFactory.GetStorage("", "crm");
            const string path    = "default/";
            var          files   = storage.ListFilesRelative("voip", path, "*.*", true)
                                   .Select(filePath => new
            {
                path      = CommonLinkUtility.GetFullAbsolutePath(storage.GetUri("voip", Path.Combine(path, filePath)).ToString()),
                audioType = (AudioType)Enum.Parse(typeof(AudioType), Directory.GetParent(filePath).Name, true)
            }).ToList();

            var audio = files.Find(r => r.audioType == AudioType.Greeting);

            newPhone.Settings.GreetingAudio = audio != null ? audio.path : "";

            audio = files.Find(r => r.audioType == AudioType.HoldUp);
            newPhone.Settings.HoldAudio = audio != null ? audio.path : "";

            audio = files.Find(r => r.audioType == AudioType.VoiceMail);
            newPhone.Settings.VoiceMail = audio != null ? audio.path : "";

            audio = files.Find(r => r.audioType == AudioType.Queue);
            newPhone.Settings.Queue.WaitUrl = audio != null ? audio.path : "";
        }
Example #15
0
 public VoipPhone DeleteNumber(VoipPhone phone)
 {
     client.DeleteIncomingPhoneNumber(phone.Id);
     return phone;
 }
Example #16
0
 public VoipPhone DeleteNumber(VoipPhone phone)
 {
     client.DeleteIncomingPhoneNumber(phone.Id);
     return(phone);
 }
Example #17
0
 public override VoipPhone SaveOrUpdateNumber(VoipPhone phone)
 {
     ResetCache();
     return(base.SaveOrUpdateNumber(phone));
 }
Example #18
0
        public virtual VoipPhone SaveOrUpdateNumber(VoipPhone phone)
        {
            using (var db = GetDb())
            {
                var insert = Insert(numberTable)
                    .InColumnValue("id", phone.Id)
                    .InColumnValue("number", phone.Number)
                    .InColumnValue("alias", phone.Alias);

                if (phone.Settings != null)
                {
                    insert.InColumnValue("settings", phone.Settings.ToString());
                }

                db.ExecuteNonQuery(insert);
            }
            return phone;
        }
Example #19
0
 public override void DeleteNumber(VoipPhone phone)
 {
     ResetCache();
     base.DeleteNumber(phone);
 }
 public void DisablePhone(VoipPhone phone)
 {
     IncomingPhoneNumberResource.Update(phone.Id, voiceUrl: new Uri("https://demo.twilio.com/welcome/voice/"), client: client);
 }
Example #21
0
 public virtual void DeleteNumber(VoipPhone phone)
 {
     using (var db = GetDb())
     {
         db.ExecuteNonQuery(Delete(numberTable).Where("id", phone.Id));
     }
 }
Example #22
0
 public VoipPhone DeleteNumber(VoipPhone phone)
 {
     IncomingPhoneNumberResource.Delete(phone.Id, client: client);
     return(phone);
 }
Example #23
0
 public override void DeleteNumber(VoipPhone phone)
 {
     ResetCache();
     base.DeleteNumber(phone);
 }
        public void UpdateSettings(VoipPhone phone)
        {
            ApplicationInfoType application;
            RuleInfoType        rule;
            ScenarioInfoType    scenario;
            var attachedPhone = GetPhone(phone.Id);

            if (attachedPhone.ApplicationID != 0)
            {
                application = GetApplications(attachedPhone.ApplicationName).First();
            }
            else
            {
                application = AddApplication(phone.Settings.Name);
                BindApplication(application, attachedPhone);
            }

            var users = GetUsers();

            foreach (var oper in phone.Settings.Operators)
            {
                var user = users.Find(r => r.UserName == phone.Settings.Name + oper.ClientID);

                if (user == null)
                {
                    user = AddUser(new UserInfoType {
                        UserName = phone.Settings.Name + oper.ClientID, UserDisplayName = phone.Settings.Name + oper.ClientID
                    }, "111111");
                    users.Add(user);
                }

                if (user.Applications == null || !user.Applications.Any())
                {
                    BindUser(user.UserID, application.ApplicationID);
                    user.Applications = new List <ApplicationInfoType> {
                        application
                    };
                }
            }

            var rules = GetRules(attachedPhone.ApplicationID);

            if (!rules.Any())
            {
                rule = AddRule(new RuleInfoType {
                    ApplicationID = attachedPhone.ApplicationID, RuleName = phone.Settings.Name, RulePattern = ".*"
                });
                rules.Add(rule);
            }

            rule = rules.First();
            if (rule.Scenarios == null || !rule.Scenarios.Any())
            {
                rule.Scenarios = new List <ScenarioInfoType>();
                scenario       = AddScenario(new ScenarioInfoType {
                    ScenarioName = phone.Settings.Name, ScenarioScript = phone.Settings.Connect()
                });
                BindScenario(scenario.ScenarioID, rule.RuleID);

                rule.Scenarios.Add(scenario);
            }
            else
            {
                scenario = rule.Scenarios.First();
                scenario.ScenarioScript = phone.Settings.Connect();
                UpdateScenario(scenario);
            }
        }
Example #25
0
 public void UpdateSettings(VoipPhone phone)
 {
     var result = client.UpdateIncomingPhoneNumber(phone.Id, new PhoneNumberOptions { VoiceUrl = phone.Settings.Connect(false), VoiceApplicationSid = null });
     ThrowIfError(result);
 }
Example #26
0
 public void DisablePhone(VoipPhone phone)
 {
     var result = client.UpdateIncomingPhoneNumber(phone.Id, new PhoneNumberOptions { VoiceUrl = null, VoiceApplicationSid = null });
     ThrowIfError(result);
 }
Example #27
0
 public override VoipPhone SaveOrUpdateNumber(VoipPhone phone)
 {
     ResetCache();
     return base.SaveOrUpdateNumber(phone);
 }
Example #28
0
 public void CreateQueue(VoipPhone newPhone)
 {
     newPhone.Settings.Queue = ((TwilioPhone)newPhone).CreateQueue(newPhone.Number, 5, string.Empty, 5);
 }
 public void UpdateSettings(VoipPhone phone)
 {
     IncomingPhoneNumberResource.Update(phone.Id, voiceUrl: new Uri(phone.Settings.Connect(false)), client: client);
 }