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; }
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 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); } }
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; } }
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 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; } }