public override void LoadInitialConfiguration()
 {
     lock (_lock)
     {
         Hashtable ht = new Hashtable();
         ClassQuery cq = new ClassQuery("Org.Reddragonit.FreeSwitchConfig.DataCore.DB.Trunks",
                 "SELECT DISTINCT gr.RouteContext.Name,gr.OutGateway.Name,gr.DestinationCondition,gr.ID FROM GatewayRoute gr ORDER BY gr.Context.Name,gr.Index");
         cq.Execute();
         string curContext = "";
         ArrayList gways = new ArrayList();
         while (cq.Read())
         {
             if (curContext != cq[0].ToString())
             {
                 if (gways.Count > 0)
                     ht.Add(curContext, gways);
                 gways = new ArrayList();
                 curContext = cq[0].ToString();
             }
             Hashtable gw = new Hashtable();
             gw.Add(_GATEWAY_NAME_FIELD_ID, cq[1].ToString());
             gw.Add(_NPANXX_FIELD_ID, cq[2].ToString());
             gw.Add(_ROUTE_ID_FIELD, cq.GetInt32(3));
             gways.Add(gw);
         }
         cq.Close();
         if (gways.Count > 0)
             ht.Add(curContext, gways);
         StoredConfiguration = ht;
     }
 }
 public List<string> GetAvailableExtensions()
 {
     ClassQuery cq = new ClassQuery("Org.Reddragonit.FreeSwitchConfig.DataCore.DB.Phones",
         "SELECT ext.Number FROM Extension ext WHERE ext.Domain = @domain");
     cq.Execute(new IDbDataParameter[]{cq.CreateParameter("@domain",Domain.Current)});
     List<string> ret = new List<string>();
     while (cq.Read())
     {
         ret.Add(cq[0].ToString());
     }
     return ret;
 }
 public List<string> GetAvailableExtensions()
 {
     List<string> ret = new List<string>();
     ClassQuery cq = new ClassQuery("Org.Reddragonit.FreeSwitchConfig.DataCore.DB.Phones",
         "SELECT ext.Number FROM Extension ext");
     cq.Execute();
     while (cq.Read())
     {
         ret.Add(cq[0].ToString());
     }
     cq.Close();
     return ret;
 }
Example #4
0
 private mPin(ClassQuery cq)
 {
     ID = cq.GetInt32(0);
     SetName = cq.GetString(1);
     Context = cq.GetString(2);
     if (!cq.IsDBNull(3))
     {
         ExtensionNumber = cq.GetString(3);
         ExtensionDomain = cq.GetString(4);
     }
     PinNumber = cq.GetString(5);
     _originalPin = PinNumber;
 }
Example #5
0
 public static List<sModelSelectOptionValue> GetSelectList()
 {
     List<sModelSelectOptionValue> ret = new List<sModelSelectOptionValue>();
     ClassQuery cq = new ClassQuery("Org.Reddragonit.FreeSwitchConfig.DataCore.DB.Trunks.SIP",
         "SELECT ist.Name FROM IncomingSIPTrunk ist where ist.Domain.Name = @domainName UNION SELECT ost.Name FROM OutgoingSIPTrunk ost WHERE ost.Profile.Name = @internalProfileName OR ost.Profile.Name = @externalProfileName");
     cq.Execute(new IDbDataParameter[] { cq.CreateParameter("@domainName", Domain.Current.Name),
     cq.CreateParameter("@internalProfileName",Domain.Current.InternalProfile.Name),
     cq.CreateParameter("@externalProfileName",Domain.Current.ExternalProfile.Name)
     });
     while(cq.Read())
         ret.Add(new sModelSelectOptionValue(cq[0].ToString(),cq[0].ToString()));
     cq.Close();
     return ret;
 }
 internal static string GetSettingValue(SipProfileSettingTypes type, SipProfile profile)
 {
     string ret = null;
     ClassQuery cq = new ClassQuery("Org.Reddragonit.FreeSwitchConfig.DataCore.DB.Core",
         "Select sps.Value from SipProfileSetting sps WHERE sps.Profile.Name = @profileName AND sps.SettingType = @type");
     IDbDataParameter[] pars = new IDbDataParameter[]{
         cq.CreateParameter("@profileName",profile.Name),
         cq.CreateParameter("@type",type)
     };
     cq.Execute(pars);
     if (cq.Read())
         ret = cq.GetString(0);
     cq.Close();
     return ret;
 }
 public override void LoadInitialConfiguration()
 {
     lock (_lock)
     {
         Hashtable ht = new Hashtable();
         ClassQuery cq = new ClassQuery("Org.Reddragonit.FreeSwitchConfig.Site.BaseComponents",
                 "SELECT i.Number,i.Context.Name,i.OneWay FROM Intercom i ORDER BY i.Context.Name");
         cq.Execute();
         ClassQuery cqExts = new ClassQuery("Org.Reddragonit.FreeSwitchConfig.Site.BaseComponents",
             "SELECT i.Extensions.Number,i.Extensions.Domain.Name FROM Intercom i WHERE i.Number = @intercomNumber");
         ArrayList icoms = new ArrayList();
         string curContext = "";
         while (cq.Read())
         {
             cqExts.Execute(new IDbDataParameter[]{
             cqExts.CreateParameter("@intercomNumber",cq[0].ToString())
         });
             ArrayList pairs = new ArrayList();
             while (cqExts.Read())
             {
                 pairs.Add(cqExts[0].ToString() + "@" + cqExts[1].ToString());
             }
             cqExts.Close();
             if (curContext != cq[1].ToString())
             {
                 if (icoms.Count > 0)
                     ht.Add(curContext, icoms);
                 curContext = cq[1].ToString();
                 icoms = new ArrayList();
             }
             Hashtable icom = new Hashtable();
             icom.Add(_EXTENSION_FIELD_NAME, cq[0].ToString());
             icom.Add(_MAPS_FIELD_NAME, pairs);
             icom.Add(_ONE_WAY_FIELD_NAME, cq.GetBoolean(2));
             icoms.Add(icom);
         }
         cq.Close();
         if (icoms.Count > 0)
         {
             ht.Add(curContext, icoms);
         }
         StoredConfiguration = ht;
     }
 }
 public static sHttpAuthUsernamePassword[] GetAuthenticationInformationForUrl(Uri url, string username)
 {
     if (User.Current != null)
         return new sHttpAuthUsernamePassword[] { new sHttpAuthUsernamePassword(User.Current.UserName, null, User.Current.SecPass) };
     else
     {
         if (_loginCount>=_maxAttempts)
             return new sHttpAuthUsernamePassword[0];
         List<sHttpAuthUsernamePassword> ret = new List<sHttpAuthUsernamePassword>();
         ClassQuery cq = new ClassQuery("Org.Reddragonit.FreeSwitchConfig.DataCore.DB.Users",
             "SELECT u.UserName,u.SecPass FROM User u WHERE u.Locked = @locked AND u.Disabled = @locked AND u.UserName = @username");
         cq.Execute(new IDbDataParameter[]{cq.CreateParameter("@locked",false),
         cq.CreateParameter("@username",username)});
         while (cq.Read())
             ret.Add(new sHttpAuthUsernamePassword(cq[0].ToString(), null, cq[1].ToString()));
         cq.Close();
         return ret.ToArray();
     }
 }
 void IComponent.Append(ref Dictionary<string, object> variables, IOutputWriter writer)
 {
     ClassQuery cq = new ClassQuery(_namespace, _query);
     List<IDbDataParameter> pars = new List<IDbDataParameter>();
     StringOutputWriter swo = new StringOutputWriter();
     foreach (string str in _parameters.Keys)
     {
         string par = "";
         foreach (IComponent ic in _parameters[str])
         {
             swo.Clear();
             ic.Append(ref variables, swo);
             par += swo.ToString();
         }
         pars.Add(cq.CreateParameter(str, par));
     }
     cq.Execute(pars.ToArray());
     object var = new ArrayList();
     while (cq.Read())
     {
         Hashtable ht = new Hashtable();
         for (int x = 0; x < cq.FieldCount; x++)
         {
             if (!cq.IsDBNull(x))
             {
                 ht.Add(cq.GetName(x), cq[x]);
             }
         }
         ((ArrayList)var).Add(ht);
     }
     cq.Close();
     if (((ArrayList)var).Count == 1 && ((Hashtable)((ArrayList)var)[0]).Count == 1)
     {
         Hashtable tmp = (Hashtable)((ArrayList)var)[0];
         var = tmp;
         object[] objAr = new object[1];
         ((Hashtable)var).Values.CopyTo(objAr, 0);
         var = objAr[0];
     }
     if (variables.ContainsKey(_variableName))
         variables.Remove(_variableName);
     variables.Add(_variableName, var);
 }
 public ArrayList GetCurrentUsers()
 {
     ArrayList ret = new ArrayList();
     ClassQuery cq = new ClassQuery("Org.Reddragonit.FreeSwitchConfig.DataCore.DB.Users",
         "SELECT usr.UserName,usr.FirstName,usr.LastName,usr.Email,usr.UserExtension.Number as extNumber,usr.Locked,usr.Disabled,usr.ID FROM User usr");
     cq.Execute();
     while (cq.Read())
     {
         Hashtable ht = new Hashtable();
         ht.Add("UserName", cq[0].ToString());
         ht.Add("FirstName", cq[1].ToString());
         ht.Add("LastName", cq[2].ToString());
         if (!cq.IsDBNull(3))
             ht.Add("Email", cq[3].ToString());
         if (!cq.IsDBNull(4))
             ht.Add("Extension", cq[4].ToString());
         ht.Add("Locked", cq.GetBoolean(5));
         ht.Add("Disabled", cq.GetBoolean(6));
         ht.Add("ID", cq.GetInt64(7));
         ret.Add(ht);
     }
     cq.Close();
     return ret;
 }
Example #11
0
 public static List<sModelSelectOptionValue> SelectList()
 {
     List<sModelSelectOptionValue> ret = new List<sModelSelectOptionValue>();
     ClassQuery cq = new ClassQuery("Org.Reddragonit.FreeSwitchConfig.Site.BaseComponents.Data",
         "SELECT ps.Name,ps.Context.Name FROM PinSet ps WHERE ps.Context.Name = @contextName");
     cq.Execute(new IDbDataParameter[]{
         cq.CreateParameter("@contextName",Context.Current.Name)
     });
     while (cq.Read())
         ret.Add(new sModelSelectOptionValue(cq[0].ToString() + "@" + cq[1].ToString(), cq[0].ToString()));
     cq.Close();
     return ret;
 }
Example #12
0
 public View(string name, ClassQuery query)
 {
     _name = name;
     _query = query.QueryString;
     _requiredTypes = query.RequiredTypes;
 }
Example #13
0
 public void Sort(PhoneBookSortTypes[] order)
 {
     if (order != null)
     {
         string OrderBy = "ORDER BY ";
         bool useEntryTypes = false;
         foreach (PhoneBookSortTypes pbst in order)
         {
             switch (pbst)
             {
                 case PhoneBookSortTypes.FirstName:
                     OrderBy += "pb.Entries.FirstName, ";
                     break;
                 case PhoneBookSortTypes.LastName:
                     OrderBy += "pb.Entries.LastName, ";
                     break;
                 case PhoneBookSortTypes.EntryType:
                     useEntryTypes = true;
                     OrderBy += "(";
                     foreach (PhoneBookEntryType pbet in Enum.GetValues(typeof(PhoneBookEntryType)))
                         OrderBy += "CASE WHEN pb.Entries.Type = @" + pbet.ToString() + " THEN " + ((int)pbet).ToString() + " ";
                     OrderBy += "END), ";
                     break;
             }
         }
         OrderBy = OrderBy.Substring(0, OrderBy.Length - 2)+" ASC";
         ClassQuery cq = new ClassQuery("Org.Reddragonit.FreeSwitchConfig.DataCore.DB.Phones.PhoneBooks",
             "SELECT pb.Entries.ID FROM PhoneBook pb WHERE pb.Name = @Name " + OrderBy);
         List<IDbDataParameter> pars = new List<IDbDataParameter>();
         pars.Add(cq.CreateParameter("@Name", Name));
         if (useEntryTypes){
             foreach (PhoneBookEntryType pbet in Enum.GetValues(typeof(PhoneBookEntryType)))
                 pars.Add(cq.CreateParameter("@" + pbet.ToString(), pbet));
         }
         cq.Execute(pars.ToArray());
         List<PhoneBookEntry> newEntries = new List<PhoneBookEntry>();
         while (cq.Read())
             newEntries.Add(PhoneBookEntry.Load(cq[0].ToString()));
         cq.Close();
         Entries = newEntries.ToArray();
         this.Update();
     }
 }
 public sDeployedDomainGroup(string groupName,string domainName)
 {
     _name = groupName;
     _extensions = new List<string>();
     ClassQuery cq = new ClassQuery("Org.Reddragonit.FreeSwitchConfig.DataCore.DB.Phones", "SELECT egrp.Extensions.Number as Number FROM ExtensionGroup egrp WHERE egrp.Domain.Name = @domainName and egrp.Name = @groupName");
     IDbDataParameter[] pars = new IDbDataParameter[] { 
         cq.CreateParameter("@domainName", domainName),
         cq.CreateParameter("@groupName",groupName)
     };
     cq.Execute(pars);
     while (cq.Read())
         _extensions.Add(cq[0].ToString());
     cq.Close();
 }
 public override void LoadInitialConfiguration()
 {
     lock (_lock)
     {
         Hashtable ht = new Hashtable();
         ClassQuery cq = new ClassQuery("Org.Reddragonit.FreeSwitchConfig.Site.BaseComponents",
             "SELECT tr.RouteContext.Name,tr.Start,tr.End,tr.DestinationCondition,tr.PerformOnFail," +
             "tr.Type,tr.AudioFileString,tr.GatewayNumber,tr.OutGateway.Name,tr.BridgeExtension.Number,tr.BridgeExtension.Domain.Name, " +
             "tr.ExtensionReference "+
             "FROM TimedRoute tr ORDER BY tr.Context.Name");
         cq.Execute();
         string curContext = "";
         ArrayList trs = new ArrayList();
         while (cq.Read())
         {
             if (curContext != cq[0].ToString())
             {
                 if (trs.Count > 0)
                     ht.Add(curContext, trs);
                 trs = new ArrayList();
                 curContext = cq[0].ToString();
             }
             Hashtable tr = new Hashtable();
             tr.Add(_START_FIELD_ID, (sCallTime)cq[1].ToString());
             if (!cq.IsDBNull(2))
                 tr.Add(_END_FIELD_ID, (sCallTime)cq[2].ToString());
             tr.Add(_CONDITION_FIELD_ID, cq[3].ToString());
             tr.Add(_PERFORM_ON_FAIL_FIElD_ID, cq.GetBoolean(4));
             tr.Add(_TYPE_FIELD_ID, (VacationRouteRedirectTypes)cq[5]);
             switch ((VacationRouteRedirectTypes)cq[5])
             {
                 case VacationRouteRedirectTypes.PlayFile:
                     tr.Add(_AUDIO_FILE_FIELD_ID, cq[6].ToString());
                     break;
                 case VacationRouteRedirectTypes.OutGateway:
                     tr.Add(_GATEWAY_NUMBER_FIELD_ID, new sGatewayNumberPair(cq[7].ToString(), cq[8].ToString()).ToString());
                     break;
                 case VacationRouteRedirectTypes.PhoneExtension:
                     tr.Add(_EXTENSION_FIELD_ID, new sDomainExtensionPair(cq[9].ToString(), cq[10].ToString()).ToString());
                     break;
                 case VacationRouteRedirectTypes.TransferToExtension:
                     tr.Add(_CALL_EXTENSION_FIELD_ID, cq[11].ToString());
                     break;
             }
             trs.Add(tr);
         }
         if (trs.Count > 0)
             ht.Add(curContext, trs);
         StoredConfiguration = ht;
     }
 }
 public sDeployedDomain(Domain domain)
 {
     _name = domain.Name;
     _variables = new List<NameValuePair>();
     ClassQuery cq = new ClassQuery("Org.Reddragonit.FreeSwitchConfig.DataCore.DB.Core", "SELECT dv.Name,dv.Value FROM DomainVariable dv WHERE dv.Domain.Name = @domainName");
     IDbDataParameter[] pars = new IDbDataParameter[] { cq.CreateParameter("@domainName", domain.Name) };
     cq.Execute(pars);
     while (cq.Read())
         _variables.Add(new NameValuePair(cq[0].ToString(), cq[1].ToString()));
     cq.Close();
     _params = new List<NameValuePair>();
     cq.NewQuery("Org.Reddragonit.FreeSwitchConfig.DataCore.DB.Core", "SELECT dp.Name,dp.Value FROM DomainParameter dp WHERE dp.Domain.Name = @domainName");
     cq.Execute(pars);
     while (cq.Read())
         _params.Add(new NameValuePair(cq[0].ToString(), cq[1].ToString()));
     cq.Close();
     _groups = new List<sDeployedDomainGroup>();
     cq.NewQuery("Org.Reddragonit.FreeSwitchConfig.DataCore.DB.Phones", "SELECT egrp.Name FROM ExtensionGroup egrp WHERE egrp.Domain.Name = @domainName");
     cq.Execute(pars);
     while (cq.Read())
         _groups.Add(new sDeployedDomainGroup(cq[0].ToString(),_name));
     cq.Close();
     _internalProfile = domain.InternalProfile.Name;
     _externalProfile = domain.ExternalProfile.Name;
 }
 public static List<sModelSelectOptionValue> SelectList()
 {
     List<sModelSelectOptionValue> ret = new List<sModelSelectOptionValue>();
     ClassQuery cq = new ClassQuery("Org.Reddragonit.FreeSwitchConfig.DataCore.DB.Phones.PhoneBooks",
         "SELECT DISTINCT pbe.ID,pbe.FirstName,pbe.LastName,pbe.Number,pbe.Type FROM PhoneBookEntry pbe");
     cq.Execute();
     while (cq.Read())
         ret.Add(new sModelSelectOptionValue(cq[0].ToString(), cq[2].ToString()+", "+cq[1].ToString()+"["+cq[3].ToString()+"("+cq[4].ToString()+")]"));
     cq.Close();
     return ret;
 }
Example #18
0
 public List<string> GetSettingsForModule(string moduleName)
 {
     List<string> ret = new List<string>();
     ClassQuery cq = new ClassQuery("Org.Reddragonit.FreeSwitchConfig.DataCore.DB.System",
         "SELECT ms.Name FROM ModuleSetting ms WHERE ms.ModuleName = @moduleName");
     cq.Execute(new IDbDataParameter[] { cq.CreateParameter("@moduleName", moduleName) });
     while (cq.Read())
         ret.Add(cq[0].ToString());
     cq.Close();
     return ret;
 }
 public static List<sModelSelectOptionValue> SelectList()
 {
     List<sModelSelectOptionValue> ret = new List<sModelSelectOptionValue>();
     ClassQuery cq = new ClassQuery("Org.Reddragonit.FreeSwitchConfig.DataCore.DB.Core",
         "SELECT ext.Number,ext.Context.Name FROM ExtensionNumber ext WHERE ext.Context.Name = @internalName OR ext.Context.Name = @externalName");
     cq.Execute(new IDbDataParameter[] { cq.CreateParameter("@internalName", Domain.Current.InternalProfile.Context.Name),
     cq.CreateParameter("@externalName", Domain.Current.ExternalProfile.Context.Name)});
     while (cq.Read())
         ret.Add(new sModelSelectOptionValue(cq[0].ToString() + "@" + cq[1].ToString(), cq[0].ToString() + "@" + cq[1].ToString()));
     cq.Close();
     return ret;
 }
 public override void LoadInitialConfiguration()
 {
     ClassQuery cq = new ClassQuery("Org.Reddragonit.FreeSwitchConfig.Site.BaseComponents",
         "SELECT hg.Number,hg.RingSequential,hg.Context.Name FROM HuntGroup hg ORDER BY hg.Context.Name");
     ClassQuery cqExts = new ClassQuery("Org.Reddragonit.FreeSwitchConfig.Site.BaseComponents",
         "SELECT hg.Extensions.Number,hg.Extensions.Domain.Name FROM HuntGroup hg WHERE hg.Number = @extNumber");
     lock (_lock)
     {
         Hashtable hgroups = new Hashtable();
         cq.Execute();
         string curContext = "";
         ArrayList groups = new ArrayList();
         while (cq.Read())
         {
             if (curContext != cq[2].ToString())
             {
                 if (groups.Count > 0)
                 {
                     hgroups.Add(curContext, groups);
                     groups = new ArrayList();
                     curContext = cq[2].ToString();
                 }
             }
             cqExts.Execute(new IDbDataParameter[]{
                 cqExts.CreateParameter("@extNumber",cq[0].ToString())
             });
             ArrayList exts = new ArrayList();
             while (cqExts.Read())
             {
                 exts.Add(cqExts[0].ToString()+"@"+ cqExts[1].ToString());
             }
             cqExts.Close();
             Hashtable hgroup = new Hashtable();
             hgroup.Add(_EXTENSION_FIELD_ID, cq[0].ToString());
             hgroup.Add(_EXTENSIONS_FIELD_ID, exts);
             hgroup.Add(_SEQUENTIAL_FIELD_ID, cq.GetBoolean(1));
             groups.Add(hgroup);
         }
         cq.Close();
         if (groups.Count > 0)
             hgroups.Add(curContext, groups);
     }
 }
Example #21
0
 public static List<sModelSelectOptionValue> SelectList()
 {
     List<sModelSelectOptionValue> ret = new List<sModelSelectOptionValue>();
     ClassQuery cq = new ClassQuery("Org.Reddragonit.FreeSwitchConfig.DataCore.DB.Users",
         "SELECT DISTINCT u.ID,u.UserName from User u "+(Domain.Current==null ? "" : "WHERE u.AttachedDomain.Name = @domainName OR u.AllowedDomains.Name = @domainName"));
     if (Domain.Current == null)
         cq.Execute();
     else
         cq.Execute(new IDbDataParameter[]{cq.CreateParameter("@domainName",Domain.Current.Name)});
     while (cq.Read())
         ret.Add(new sModelSelectOptionValue(cq[0].ToString(), cq[1].ToString()));
     cq.Close();
     return ret;
 }
Example #22
0
 public static List<mPin> GetPinsForPinset(string pinsetName)
 {
     List<mPin> ret = new List<mPin>();
     ClassQuery cq = new ClassQuery("Org.Reddragonit.FreeSwitchConfig.Site.BaseComponents.Data",
         "SELECT pn.ID,pn.OwningSet.Name,pn.OwningSet.Context.Name,pn.Extension.Number,pn.Extension.Domain.Name,pn.PinNumber FROM Pin pn " +
         "WHERE pn.OwningSet.Name = @setName AND pn.OwningSet.Context.Name = @contextName");
     cq.Execute(new IDbDataParameter[]{
         cq.CreateParameter("@setName",pinsetName),
         cq.CreateParameter("@contextName",Org.Reddragonit.FreeSwitchConfig.DataCore.DB.Core.Context.Current.Name)
     });
     while (cq.Read())
         ret.Add(new mPin(cq));
     cq.Close();
     return ret;
 }
        public override void LoadInitialConfiguration()
        {
            lock(_lock){
                Hashtable ht = new Hashtable();
                ClassQuery cq = new ClassQuery("Org.Reddragonit.FreeSwitchConfig.Site.BaseComponents",
                    "SELECT pr.RouteContext.Name,pr.Name,pr.DestinationCondition,pr.PinFile.Name FROM PinnedRoute pr ORDER BY pr.RouteContext.Name,pr.Index");
                cq.Execute();
                Hashtable routes = new Hashtable();
                string curContext = "";
                ArrayList prs = new ArrayList();
                while (cq.Read())
                {
                    if (curContext != cq[0].ToString())
                    {
                        if (prs.Count > 0)
                            routes.Add(curContext, prs);
                        prs = new ArrayList();
                        curContext = cq[0].ToString();
                    }
                    Hashtable pr = new Hashtable();
                    pr.Add(_NAME_FIELD_ID, cq[1].ToString());
                    pr.Add(_NPA_FIELD_ID, cq[2].ToString());
                    pr.Add(_PIN_SET_NAME_FIELD_ID, cq[3].ToString());
                    prs.Add(pr);
                }
                if (prs.Count > 0)
                    routes.Add(curContext, prs);
                cq.Close();

                Hashtable pins = new Hashtable();
                cq.NewQuery("Org.Reddragonit.FreeSwitchConfig.DataCore.DB.Phones",
                                "SELECT ps.Context.Name,ps.Advanced,ps.Name FROM PinSet ps");
                cq.Execute();
                curContext = "";
                Hashtable pinSets = new Hashtable();
                while (cq.Read())
                {
                    if (curContext!=cq[0].ToString()){
                        if (pinSets.Count>0)
                            pins.Add(curContext,pinSets);
                        pinSets = new Hashtable();
                        curContext = cq[0].ToString();
                    }
                    bool adv = cq.GetBoolean(1);
                    ClassQuery pinq = new ClassQuery("Org.Reddragonit.FreeSwitchConfig.DataCore.DB.Phones",
                        "SELECT pn.PinNumber" + (adv ? ",pn.Extension.Number,pn.Extension.Domain.Name" : "") + " Pin pn WHERE pn.OwningSet.Name = @name AND pn.OwningSet.Context.Name = @context");
                    pinq.Execute(new IDbDataParameter[]{
                        pinq.CreateParameter("@name",cq[1].ToString()),
                        pinq.CreateParameter("@context",cq[0].ToString())
                    });
                    ArrayList pinValues = new ArrayList();
                    while (pinq.Read())
                    {
                        if (adv)
                            pinValues.Add(cq[1].ToString()+"@"+cq[2].ToString() + ":" + cq[0].ToString());
                        else
                            pinValues.Add(cq[0].ToString());
                    }
                    pinq.Close();
                    Hashtable pset = new Hashtable();
                    pset.Add(_PINSET_ADVANCED_FIELD_ID, adv);
                    pset.Add(_PINSET_PINS_FIELD_ID, pinValues);
                    pinSets.Add(cq[2].ToString(), pset);
                }
                cq.Close();
                if (pinSets.Count>0)
                    pins.Add(curContext,pinSets);
                ht.Add(_SCONFIG_ROUTES_NAME, routes);
                ht.Add(_SCONFIG_PINS_NAME, pins);
                StoredConfiguration = ht;
            }
        }
Example #24
0
 internal ViewResultRow(Connection conn,ClassQuery cq)
 {
     _conn = conn;
     _cq = cq;
 }
 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();
 }
 public override void LoadInitialConfiguration()
 {
     lock (_lock)
     {
         Hashtable ht = new Hashtable();
         ClassQuery cq = new ClassQuery("Org.Reddragonit.FreeSwitchConfig.Site.BaseComponents",
             "SELECT vr.AttachedExtension.Context.Name, vr.AttachedExtension.Domain.Name, vr.AttachedExtension.Number, " +
             "vr.Type,vr.AttachedExtension.Domain.VoicemailTimeout, vr.EndWithVoicemail, vr.StartDate, " +
             "vr.EndDate, vr.BridgeExtension.Number, vr.BridgeExtension.Domain.Name, " +
             "vr.GatewayNumber, vr.OutGateway.Name, vr.AudioFileString, vr.ExtensionReference " +
         " FROM VacationRoute vr " +
         " ORDER BY vr.AttachedExtension.Context.Name");
         cq.Execute();
         string curContext = "";
         ArrayList vcrs = new ArrayList();
         while (cq.Read())
         {
             if (curContext != cq[0].ToString())
             {
                 if (vcrs.Count > 0)
                     ht.Add(curContext, vcrs);
                 vcrs = new ArrayList();
                 curContext = cq[0].ToString();
             }
             Hashtable vcr = new Hashtable();
             vcr.Add(_OWNING_EXTENSION_FIELD_ID, new sDomainExtensionPair(cq[2].ToString(), cq[1].ToString()).ToString());
             vcr.Add(_TYPE_FIELD_ID, (VacationRouteRedirectTypes)cq[3]);
             vcr.Add(_VOICEMAIL_TIMEOUT_FIELD_ID, cq.GetInt32(4));
             vcr.Add(_END_WITH_VM_FIELD_ID, cq.GetBoolean(5));
             vcr.Add(_START_DATE_FIELD_ID, cq.GetDateTime(6));
             vcr.Add(_END_DATE_FIELD_ID, cq.GetDateTime(7));
             switch ((VacationRouteRedirectTypes)cq[3])
             {
                 case VacationRouteRedirectTypes.PhoneExtension:
                     vcr.Add(_BRIDGE_EXTENSION_FIELD_ID, new sDomainExtensionPair(cq[8].ToString(), cq[9].ToString()).ToString());
                     break;
                 case VacationRouteRedirectTypes.OutGateway:
                     vcr.Add(_GATEWAY_NUMBER_FIELD_ID, new sGatewayNumberPair(cq[10].ToString(), cq[11].ToString()).ToString());
                     break;
                 case VacationRouteRedirectTypes.PlayFile:
                     vcr.Add(_AUDIO_FILE_FIELD_ID, cq[12].ToString());
                     break;
                 case VacationRouteRedirectTypes.TransferToExtension:
                     vcr.Add(_CALL_EXTENSION_FIELD_ID, cq[13].ToString());
                     break;
             }
             vcrs.Add(vcr);
         }
         if (vcrs.Count > 0)
             ht.Add(curContext, vcrs);
         StoredConfiguration = ht;
     }
 }
 public override void LoadInitialConfiguration()
 {
     lock (_lock)
     {
         Hashtable ht = new Hashtable();
         ClassQuery cq = new ClassQuery("Org.Reddragonit.FreeSwitchConfig.DataCore.DB.Phones",
         "SELECT ext.Number,ext.VoicemailTimeout,vm.Number,ext.Context.Name,ext.Domain.Name FROM Extension ext LEFT JOIN VoiceMail vm ON ext.Number = vm.Number ORDER BY ext.Context.Name");
         cq.Execute();
         string curContext = "";
         ArrayList exts = new ArrayList();
         while (cq.Read())
         {
             if (curContext != cq[3].ToString())
             {
                 if (exts.Count > 0)
                 {
                     ht.Add(curContext, exts);
                     exts = new ArrayList();
                     curContext = cq[3].ToString();
                 }
             }
             Hashtable ext = new Hashtable();
             ext.Add(_EXTENSION_FIELD_ID, cq[0].ToString());
             ext.Add(_HAS_VOICEMAIL_FIELD_ID, !cq.IsDBNull(2));
             ext.Add(_TIMEOUT_FIELD_ID, (cq.IsDBNull(1) ? DEFAULT_TIMEOUT : cq.GetInt32(1)));
             ext.Add(_DOMAIN_FIELD_ID, cq[4].ToString());
             exts.Add(ext);
         }
         if (exts.Count > 0)
             ht.Add(curContext, exts);
         cq.Close();
         StoredConfiguration = ht;
     }
 }
 public override void LoadInitialConfiguration()
 {
     lock (_lock)
     {
         Hashtable ht = new Hashtable();
         ClassQuery cq = new ClassQuery("Org.Reddragonit.FreeSwitchConfig.DataCore.DB.Phones",
             "SELECT dl.DialedContext.Name,dl.ExternalNumber,dl.Number,dl.Context.Name FROM DirectLine dl ORDER BY dl.DialedContext.Name");
         cq.Execute();
         string curContext = "";
         ArrayList lines = new ArrayList();
         while (cq.Read())
         {
             if (curContext != cq[0].ToString())
             {
                 if (lines.Count > 0)
                     ht.Add(curContext, lines);
                 curContext = cq[0].ToString();
                 lines = new ArrayList();
             }
             Hashtable dline = new Hashtable();
             dline.Add(_DIALED_NUMBER_FIELD_NAME, cq[1].ToString());
             dline.Add(_EXTENSION_FIELD_NAME, cq[2].ToString());
             dline.Add(_CONTEXT_FIELD_NAME, cq[3].ToString());
         }
         cq.Close();
         if (lines.Count > 0)
             ht.Add(curContext, lines);
         StoredConfiguration = ht;
     }
 }
Example #29
0
 public static mPin Load(string id)
 {
     mPin ret = null;
     ClassQuery cq = new ClassQuery("Org.Reddragonit.FreeSwitchConfig.Site.BaseComponents.Data",
         "SELECT pn.ID,pn.OwningSet.Name,pn.OwningSet.Context.Name,pn.Extension.Number,pn.Extension.Domain.Name,pn.PinNumber FROM Pin pn " +
         "WHERE pn.OwningSet.Name = @setName AND pn.OwningSet.Context.Name = @contextName AND pn.ID = @id");
     cq.Execute(new IDbDataParameter[]{
         cq.CreateParameter("@setName",id.Substring(0,id.IndexOf("@"))),
         cq.CreateParameter("@contextName",id.Substring(id.IndexOf("@")+1,id.IndexOf(":")-id.IndexOf("@"))),
         cq.CreateParameter("@id",id.Substring(id.IndexOf(":")+1))
     });
     if (cq.Read())
         ret = new mPin(cq);
     cq.Close();
     return ret;
 }