示例#1
0
        public static void RegenerateSIPProfile(SipProfile profile)
        {
            sDeployedProfile prof = new sDeployedProfile(profile);

            Lock();
            List <sDeployedProfile> profs = profiles;
            bool add = true;

            for (int x = 0; x < profs.Count; x++)
            {
                if (profs[x].Name == prof.Name)
                {
                    profs[x] = prof;
                    add      = false;
                    break;
                }
            }
            if (add)
            {
                profs.Add(prof);
            }
            profiles = profs;
            UnLock();
            _deployer.DeploySipProfile(prof);
            EventController.TriggerEvent(new SipProfileDeploymentEvent(prof));
        }
示例#2
0
        public sDeployedProfile(SipProfile profile)
        {
            _name        = profile.Name;
            _contextName = profile.Context.Name;
            _settings    = new List <NameValuePair>();
            ClassQuery cq = new ClassQuery("Org.Reddragonit.FreeSwitchConfig.DataCore.DB.Core",
                                           "Select sps.SettingType,sps.Value from SipProfileSetting sps WHERE sps.Profile.Name = @profileName");

            IDbDataParameter[] pars = new IDbDataParameter[] {
                cq.CreateParameter("@profileName", profile.Name)
            };
            cq.Execute(pars);
            while (cq.Read())
            {
                _settings.Add(new NameValuePair(cq[0].ToString(), cq[1].ToString()));
            }
            cq.Close();
        }
示例#3
0
        public void ProcessRequest(HttpRequest request, Org.Reddragonit.EmbeddedWebServer.Interfaces.Site site)
        {
            bool isComplete = false;

            try
            {
                if (Domain.AllDomainNames.Count == 0)
                {
                    throw new Exception("No Domains have been created");
                }

                if (Context.AllContextNames.Count < 2)
                {
                    throw new Exception("You need a minimum of 2 contexts");
                }

                if (SipProfile.AllSipProfileNames.Count < 2)
                {
                    throw new Exception("You need a minimum of 2 sip profiles");
                }

                User usr = User.Create(request.Parameters["UserName"],
                                       request.Parameters["FirstName"],
                                       request.Parameters["LastName"],
                                       request.Parameters["Password"],
                                       null,
                                       null,
                                       UserRight.All.ToArray());
                if (usr == null)
                {
                    throw new Exception("Unable to create primary user");
                }
                else
                {
                    usr.AllowedDomains = Domain.LoadAll().ToArray();
                    usr.Update();
                }

                foreach (string c in Context.AllContextNames)
                {
                    CoreGenerator.RegenerateContextFile(c);
                }
                foreach (SipProfile sp in SipProfile.LoadAll())
                {
                    CoreGenerator.RegenerateSIPProfile(sp);
                }
                foreach (Domain d in Domain.LoadAll())
                {
                    CoreGenerator.RegenerateDomainFile(d);
                }

                isComplete = true;
            }
            catch (Exception e)
            {
                request.ResponseWriter.WriteLine(e.Message);
            }
            if (!isComplete)
            {
                request.ResponseStatus = HttpStatusCodes.Forbidden;
            }
            else
            {
                request.ResponseStatus = HttpStatusCodes.OK;
                EventController.TriggerEvent(new SetupCompleteEvent());
            }
            request.SendResponse();
        }