Ejemplo n.º 1
0
        internal static void SetProcessTopologyMode(TopologyMode mode)
        {
            if (TopologyMode.Adam == mode)
            {
                throw new ArgumentException("mode. Adam topology mode can't be specified");
            }
            if (TopologyMode.Ldap == mode && TopologyProvider.IsTopologyServiceProcess())
            {
                TopologyProvider.isRunningOnTopologyService = true;
            }
            ExTraceGlobals.TopologyProviderTracer.TraceDebug <TopologyMode, TopologyMode>(0L, "User set topology mode from {0} to {1}", (TopologyProvider.userSetTopologyMode != null) ? TopologyProvider.userSetTopologyMode.Value : TopologyProvider.CurrentTopologyMode, mode);
            TopologyProvider.userSetTopologyMode = new TopologyMode?(mode);
            int          num;
            TopologyMode topologyMode = TopologyProvider.SelectTopologyMode(out num);

            if (TopologyProvider.staticInstance != null && (TopologyProvider.userSetTopologyMode.Value != TopologyProvider.staticInstance.TopologyMode || TopologyProvider.userSetTopologyMode.Value != topologyMode))
            {
                IDisposable      disposable       = TopologyProvider.staticInstance as IDisposable;
                TopologyProvider topologyProvider = TopologyProvider.InitializeInstance();
                topologyProvider.PopulateConfigNamingContextsForLocalForest();
                topologyProvider.PopulateDomainNamingContextsForLocalForest();
                ConnectionPoolManager.Reset();
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
        }
Ejemplo n.º 2
0
        public static new Extension Load(string number)
        {
            Extension  ret  = null;
            Connection conn = ConnectionPoolManager.GetConnection(typeof(Extension));
            List <Org.Reddragonit.Dbpro.Structure.Table> tmp = null;

            if (number.Contains("@"))
            {
                tmp = conn.Select(typeof(Extension),
                                  new SelectParameter[] { new EqualParameter("Number", number.Substring(0, number.IndexOf('@'))),
                                                          new EqualParameter("Domain.Name", number.Substring(number.IndexOf('@') + 1)) });
            }
            else
            {
                tmp = conn.Select(typeof(Extension),
                                  new SelectParameter[] { new EqualParameter("Number", number),
                                                          new EqualParameter("Context", Context.Current) });
            }
            if (tmp.Count > 0)
            {
                ret = (Extension)tmp[0];
            }
            conn.CloseConnection();
            return(ret);
        }
Ejemplo n.º 3
0
        internal static CDR Create(string domainName, string callerIDName, string callerIDNumber, string DestinationNumber,
                                   DateTime callStart, DateTime?answerTime, DateTime endTime, long duration, long billableSecs,
                                   Context context, string uniqueID, string coreUUID, string hangupCause, Extension internalExtension, string pin)
        {
            CDR ret = new CDR();

            ret.OwningDomain      = Domain.Load(domainName);
            ret.CallerIDName      = callerIDName;
            ret.CallerIDNumber    = callerIDNumber;
            ret.DestinationNumber = DestinationNumber;
            ret.CallStart         = callStart;
            ret.CallAnswerTime    = answerTime;
            ret.CallEndTime       = endTime;
            ret.Duration          = duration;
            ret.BillableDuration  = billableSecs;
            ret.CallContext       = context;
            ret.UniqueID          = uniqueID;
            ret.CoreUUID          = coreUUID;
            ret.InternalExtension = internalExtension;
            ret.HangupCause       = hangupCause;
            ret.Pin = pin;
            Connection conn = ConnectionPoolManager.GetConnection(typeof(CDR));

            ret = (CDR)conn.Save(ret);
            conn.Commit();
            conn.CloseConnection();
            return(ret);
        }
Ejemplo n.º 4
0
        public NspiRpcClientConnection GetNspiRpcClientConnection()
        {
            string text = base.ServerSettings.PreferredGlobalCatalog(base.SessionSettings.GetAccountOrResourceForestFqdn());
            string domainController;

            if (!string.IsNullOrEmpty(text))
            {
                domainController = text;
            }
            else
            {
                PooledLdapConnection pooledLdapConnection = null;
                try
                {
                    pooledLdapConnection = ConnectionPoolManager.GetConnection(ConnectionType.GlobalCatalog, base.SessionSettings.GetAccountOrResourceForestFqdn());
                    domainController     = pooledLdapConnection.ServerName;
                }
                finally
                {
                    if (pooledLdapConnection != null)
                    {
                        pooledLdapConnection.ReturnToPool();
                    }
                }
            }
            return(NspiRpcClientConnection.GetNspiRpcClientConnection(domainController));
        }
Ejemplo n.º 5
0
        public static List <PhoneBookEntry> GetPagedList(string firstName, string lastName, string number, string organization, string type, ulong startIndex, ulong pageSize, out int totalPages)
        {
            List <PhoneBookEntry>  ret  = new List <PhoneBookEntry>();
            Connection             conn = ConnectionPoolManager.GetConnection(typeof(PhoneBookEntry));
            List <SelectParameter> pars = new List <SelectParameter>();

            if (firstName != null)
            {
                pars.Add(new LikeParameter("FirstName", firstName));
            }
            if (lastName != null)
            {
                pars.Add(new LikeParameter("LastName", lastName));
            }
            if (number != null)
            {
                pars.Add(new LikeParameter("Number", number));
            }
            if (organization != null)
            {
                pars.Add(new LikeParameter("Organization", organization));
            }
            if (type != null)
            {
                pars.Add(new EqualParameter("Type", (PhoneBookEntryType)Enum.Parse(typeof(PhoneBookEntryType), type)));
            }
            totalPages = (int)Math.Ceiling((decimal)conn.SelectCount(typeof(PhoneBookEntry), pars.ToArray()) / (decimal)pageSize);
            foreach (PhoneBookEntry pbe in conn.SelectPaged(typeof(PhoneBookEntry), pars.ToArray(), startIndex, pageSize))
            {
                ret.Add(pbe);
            }
            conn.CloseConnection();
            return(ret);
        }
Ejemplo n.º 6
0
        public static DirectLine Load(string dialedNumber)
        {
            List <SelectParameter> pars = new List <SelectParameter>();

            if (dialedNumber.Contains("@"))
            {
                pars.Add(new EqualParameter("DialedContext.Name", dialedNumber.Substring(dialedNumber.LastIndexOf('@') + 1)));
                pars.Add(new EqualParameter("DialedNumber", dialedNumber.Substring(0, dialedNumber.LastIndexOf('@'))));
            }
            else
            {
                pars.Add(new EqualParameter("DialedContext", Context.Current));
                pars.Add(new EqualParameter("DialedNumber", dialedNumber));
            }

            DirectLine ret  = null;
            Connection conn = ConnectionPoolManager.GetConnection(typeof(DirectLine));
            List <Org.Reddragonit.Dbpro.Structure.Table> tmp = conn.Select(typeof(DirectLine), pars.ToArray());

            conn.CloseConnection();
            if (tmp.Count > 0)
            {
                ret = (DirectLine)tmp[0];
            }
            return(ret);
        }
Ejemplo n.º 7
0
        internal override Guid SelectDomainController(PartitionId partitionId)
        {
            ExTraceGlobals.ActiveDirectoryTracer.TraceDebug <Guid>((long)base.TenantExternalDirectoryId.GetHashCode(), "Selecting a DC for Merge operation of {0}. Will examine all DCs in the local site AND domain", base.TenantExternalDirectoryId);
            if (base.InvocationId != Guid.Empty)
            {
                ExTraceGlobals.ActiveDirectoryTracer.TraceError <Guid>((long)base.TenantExternalDirectoryId.GetHashCode(), "MergePageToken.SelectDomainController this.InvocationId {0} is not Guid.Empty", base.InvocationId);
                throw new InvalidOperationException("InvocationId");
            }
            ITopologyConfigurationSession session        = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromAccountPartitionRootOrgScopeSet(partitionId), 390, "SelectDomainController", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\Sync\\BackSync\\MergePageToken.cs");
            IList <ADServerInfo>          serversForRole = TopologyProvider.GetInstance().GetServersForRole(partitionId.ForestFQDN, new List <string>(0), ADServerRole.DomainController, int.MaxValue, false);

            ExTraceGlobals.ActiveDirectoryTracer.TraceDebug((long)base.TenantExternalDirectoryId.GetHashCode(), "MergePageToken.SelectDomainController searching dcs in preferred site");
            foreach (ADServerInfo adserverInfo in serversForRole)
            {
                Guid result;
                if (this.TrySelectDomainController(session, adserverInfo.Fqdn, partitionId, false, out result))
                {
                    return(result);
                }
            }
            ReadOnlyCollection <ADServer> readOnlyCollection = ADForest.GetForest(partitionId).FindRootDomain().FindAllDomainControllers();

            ExTraceGlobals.ActiveDirectoryTracer.TraceDebug((long)base.TenantExternalDirectoryId.GetHashCode(), "MergePageToken.SelectDomainController searching dcs in other sites");
            foreach (ADServer adserver in readOnlyCollection)
            {
                Guid result2;
                if (!ConnectionPoolManager.IsServerInPreferredSite(partitionId.ForestFQDN, adserver) && this.TrySelectDomainController(session, adserver.DnsHostName, partitionId, true, out result2))
                {
                    return(result2);
                }
            }
            ExTraceGlobals.ActiveDirectoryTracer.TraceError <Guid, string>((long)base.TenantExternalDirectoryId.GetHashCode(), "Could not find any DC that has all changes reported by the Tenant Full Sync Watermarks for {0}. \r\nFull sync watermarks: \r\n{1}", base.TenantExternalDirectoryId, base.Watermarks.SerializeToString());
            throw new BackSyncDataSourceUnavailableException();
        }
Ejemplo n.º 8
0
        public static ExtensionNumber Load(string number)
        {
            ExtensionNumber        ret  = null;
            List <SelectParameter> pars = new List <SelectParameter>();

            if (number.Contains("@"))
            {
                pars.Add(new EqualParameter("Number", number.Substring(0, number.LastIndexOf('@'))));
                pars.Add(new EqualParameter("Context.Name", number.Substring(number.LastIndexOf('@') + 1)));
            }
            else
            {
                pars.Add(new EqualParameter("Number", number));
                pars.Add(new EqualParameter("Context.Name", Context.Current.Name));
            }
            Connection conn = ConnectionPoolManager.GetConnection(typeof(ExtensionNumber));
            List <Org.Reddragonit.Dbpro.Structure.Table> tmp = conn.Select(typeof(ExtensionNumber), pars.ToArray());

            if (tmp.Count > 0)
            {
                ret = (ExtensionNumber)tmp[0];
            }
            conn.CloseConnection();
            return(ret);
        }
Ejemplo n.º 9
0
        internal static void SetSettingValue(SipProfileSettingTypes type, string value, SipProfile profile)
        {
            Connection conn = ConnectionPoolManager.GetConnection(typeof(SipProfileSetting));

            if (GetSettingValue(type, profile) != null)
            {
                Dictionary <string, object> fields = new Dictionary <string, object>();
                fields.Add("Value", value);
                conn.Update(typeof(SipProfileSetting),
                            fields,
                            new SelectParameter[] {
                    new EqualParameter("Profile", profile),
                    new EqualParameter("SettingType", type)
                });
            }
            else
            {
                SipProfileSetting sps = new SipProfileSetting();
                sps.Profile     = profile;
                sps.SettingType = type;
                sps.Value       = value;
                conn.Save(sps);
            }
            conn.CloseConnection();
        }
        // Token: 0x06000595 RID: 1429 RVA: 0x0001EE98 File Offset: 0x0001D098
        internal static ADServerInfo GetServerInfoFromFqdn(string fqdn, ConnectionType connectionType)
        {
            PooledLdapConnection pooledLdapConnection = null;
            string       empty = string.Empty;
            ADServerInfo adserverInfo;

            try
            {
                string partitionFqdn = Globals.IsMicrosoftHostedOnly ? ADServerSettings.GetPartitionFqdnFromADServerFqdn(fqdn) : TopologyProvider.LocalForestFqdn;
                pooledLdapConnection = ConnectionPoolManager.GetConnection(connectionType, partitionFqdn, null, fqdn, (connectionType == ConnectionType.GlobalCatalog) ? TopologyProvider.GetInstance().DefaultGCPort : TopologyProvider.GetInstance().DefaultDCPort);
                string writableNC = pooledLdapConnection.ADServerInfo.WritableNC;
                if (!pooledLdapConnection.SessionOptions.HostName.Equals(fqdn, StringComparison.OrdinalIgnoreCase))
                {
                    throw new ADOperationException(DirectoryStrings.ErrorInvalidServerFqdn(fqdn, pooledLdapConnection.SessionOptions.HostName));
                }
                adserverInfo = pooledLdapConnection.ADServerInfo;
            }
            finally
            {
                if (pooledLdapConnection != null)
                {
                    pooledLdapConnection.ReturnToPool();
                }
            }
            return(adserverInfo);
        }
Ejemplo n.º 11
0
        public static bool ExtensionExists(string number)
        {
            Connection conn = ConnectionPoolManager.GetConnection(typeof(ExtensionNumber));
            bool       ret  = conn.SelectCount(typeof(ExtensionNumber), new SelectParameter[] { new EqualParameter("Number", number), new EqualParameter("Context", Context.Current) }) > 0;

            conn.CloseConnection();
            return(ret);
        }
Ejemplo n.º 12
0
        public static List <CDR> SearchCDRs(string extension,
                                            string callerID,
                                            string destination,
                                            string callerName,
                                            DateTime?startDate,
                                            DateTime?endDate,
                                            long startIndex,
                                            int pageSize,
                                            out int totalPages)
        {
            totalPages = 0;
            if (User.Current == null)
            {
                return(null);
            }
            if (!User.Current.HasRight(Constants.CDR_RIGHT))
            {
                return(null);
            }
            List <CDR>             ret  = new List <CDR>();
            List <SelectParameter> pars = new List <SelectParameter>();

            if ((extension != null) && (extension.Length > 0))
            {
                pars.Add(new EqualParameter("InternalExtension", Extension.Load(extension, Domain.Current)));
            }
            if ((callerID != null) && (callerID.Length > 0))
            {
                pars.Add(new EqualParameter("CallerIDNumber", callerID));
            }
            if ((callerName != null) && (callerName.Length > 0))
            {
                pars.Add(new EqualParameter("CallerIDName", callerName));
            }
            if ((destination != null) && (destination.Length > 0))
            {
                pars.Add(new EqualParameter("DestinationNumber", destination));
            }
            if (startDate.HasValue)
            {
                pars.Add(new GreaterThanEqualToParameter("CallStart", startDate.Value));
            }
            if (endDate.HasValue)
            {
                pars.Add(new LessThanEqualToParameter("CallStart", endDate.Value));
            }
            pars.Add(new EqualParameter("OwningDomain", Domain.Current));
            Connection conn = ConnectionPoolManager.GetConnection(typeof(CDR));

            totalPages = (int)Math.Ceiling((decimal)conn.SelectCount(typeof(CDR), pars.ToArray()) / (decimal)pageSize);
            foreach (CDR c in conn.SelectPaged(typeof(CDR), pars.ToArray(), (ulong)startIndex, (ulong)pageSize))
            {
                ret.Add(c);
            }
            conn.CloseConnection();
            return(ret);
        }
Ejemplo n.º 13
0
        private Settings()
        {
            _cache = new Dictionary <string, CachedItemContainer>();
            ConnectionPool pool = ConnectionPoolManager.GetPool(typeof(SystemSetting));

            if (pool == null)
            {
                Log.Trace("Unable to obtain a pool for the type " + typeof(SystemSetting).FullName);
            }
            _conn = pool.GetConnection();
        }
Ejemplo n.º 14
0
 private void UpdateServicePoint(ServicePoint servicePoint)
 {
     if (this.lastUsedServicePoint == null)
     {
         this.lastUsedServicePoint = servicePoint;
     }
     else if ((this.lastUsedServicePoint.Host != servicePoint.Host) || (this.lastUsedServicePoint.Port != servicePoint.Port))
     {
         ConnectionPoolManager.CleanupConnectionPool(servicePoint, "");
         this.lastUsedServicePoint = servicePoint;
     }
 }
Ejemplo n.º 15
0
        public static List <Context> LoadAll()
        {
            List <Context> ret  = new List <Context>();
            Connection     conn = ConnectionPoolManager.GetConnection(typeof(Context));

            foreach (Context con in conn.SelectAll(typeof(Context)))
            {
                ret.Add(con);
            }
            conn.CloseConnection();
            return(ret);
        }
Ejemplo n.º 16
0
        public static new List <OutgoingSIPTrunk> LoadAll()
        {
            List <OutgoingSIPTrunk> ret = new List <OutgoingSIPTrunk>();
            Connection conn             = ConnectionPoolManager.GetConnection(typeof(OutgoingSIPTrunk));

            foreach (OutgoingSIPTrunk ost in conn.SelectAll(typeof(OutgoingSIPTrunk)))
            {
                ret.Add(ost);
            }
            conn.CloseConnection();
            return(ret);
        }
Ejemplo n.º 17
0
        public static List <Gateway> LoadAll()
        {
            List <Gateway> ret  = new List <Gateway>();
            Connection     conn = ConnectionPoolManager.GetConnection(typeof(Gateway));

            foreach (Gateway gt in conn.SelectAll(typeof(Gateway)))
            {
                ret.Add(gt);
            }
            conn.CloseConnection();
            return(ret);
        }
Ejemplo n.º 18
0
        public static List <DirectLine> LoadAll()
        {
            List <DirectLine> ret  = new List <DirectLine>();
            Connection        conn = ConnectionPoolManager.GetConnection(typeof(DirectLine));

            foreach (DirectLine dl in  conn.Select(typeof(DirectLine), new SelectParameter[] { new EqualParameter("DialedContext", Context.Current) }))
            {
                ret.Add(dl);
            }
            conn.CloseConnection();
            return(ret);
        }
        public static List <FreeSwitchModuleFile> LoadAll()
        {
            List <FreeSwitchModuleFile> ret = new List <FreeSwitchModuleFile>();
            Connection conn = ConnectionPoolManager.GetConnection(typeof(FreeSwitchModuleFile));

            foreach (FreeSwitchModuleFile fsmf in conn.SelectAll(typeof(FreeSwitchModuleFile)))
            {
                ret.Add(fsmf);
            }
            conn.CloseConnection();
            return(ret);
        }
Ejemplo n.º 20
0
        public static List <SipProfile> LoadAll()
        {
            List <SipProfile> ret  = new List <SipProfile>();
            Connection        conn = ConnectionPoolManager.GetConnection(typeof(SipProfile));

            foreach (SipProfile con in conn.SelectAll(typeof(SipProfile)))
            {
                ret.Add(con);
            }
            conn.CloseConnection();
            return(ret);
        }
Ejemplo n.º 21
0
        public static List <PhoneBookEntry> LoadAll()
        {
            List <PhoneBookEntry> ret  = new List <PhoneBookEntry>();
            Connection            conn = ConnectionPoolManager.GetConnection(typeof(PhoneBookEntry));

            foreach (Org.Reddragonit.Dbpro.Structure.Table tbl in conn.SelectAll(typeof(PhoneBookEntry)))
            {
                ret.Add((PhoneBookEntry)tbl);
            }
            conn.CloseConnection();
            return(ret);
        }
Ejemplo n.º 22
0
        public static List <PhoneBook> LoadAll()
        {
            List <PhoneBook> ret  = new List <PhoneBook>();
            Connection       conn = ConnectionPoolManager.GetConnection(typeof(PhoneBook));

            foreach (PhoneBook pb in conn.SelectAll(typeof(PhoneBook)))
            {
                ret.Add(pb);
            }
            conn.CloseConnection();
            return(ret);
        }
Ejemplo n.º 23
0
        public new static List <VacationRoute> LoadAll()
        {
            List <VacationRoute> ret  = new List <VacationRoute>();
            Connection           conn = ConnectionPoolManager.GetConnection(typeof(VacationRoute));

            foreach (VacationRoute vr in conn.Select(typeof(VacationRoute),
                                                     new SelectParameter[] { new EqualParameter("Context", Context.LoadByName("Internal")) }))
            {
                ret.Add(vr);
            }
            conn.CloseConnection();
            return(ret);
        }
Ejemplo n.º 24
0
        public static new List <Intercom> LoadAll()
        {
            List <Intercom> ret  = new List <Intercom>();
            Connection      conn = ConnectionPoolManager.GetConnection(typeof(Intercom));

            foreach (Intercom icom in  conn.Select(typeof(Intercom),
                                                   new SelectParameter[] { new EqualParameter("Context", Context.LoadByName("Internal")) }))
            {
                ret.Add(icom);
            }
            conn.CloseConnection();
            return(ret);
        }
Ejemplo n.º 25
0
        public static new List <HuntGroup> LoadAll()
        {
            List <HuntGroup> ret  = new List <HuntGroup>();
            Connection       conn = ConnectionPoolManager.GetConnection(typeof(HuntGroup));

            foreach (HuntGroup ht in conn.Select(typeof(HuntGroup),
                                                 new SelectParameter[] { new EqualParameter("Context", Context.Current) }))
            {
                ret.Add(ht);
            }
            conn.CloseConnection();
            return(ret);
        }
 // check to see if we're using a different servicepoint than the last
 // servicepoint used to get a connectionpool
 //
 // preconditions: servicePoint must have valid host and port (checked in SmtpClient)
 //
 // postconditions: if servicePoint is different than the last servicePoint used by this object,
 // the connection pool for the previous servicepoint will be cleaned up and servicePoint will be
 // cached to identify if it has changed in future uses of this SmtpTransport object
 private void UpdateServicePoint(ServicePoint servicePoint)
 {
     if (lastUsedServicePoint == null)
     {
         lastUsedServicePoint = servicePoint;
     }
     else if (lastUsedServicePoint.Host != servicePoint.Host ||
              lastUsedServicePoint.Port != servicePoint.Port)
     {
         ConnectionPoolManager.CleanupConnectionPool(servicePoint, "");
         lastUsedServicePoint = servicePoint;
     }
 }
Ejemplo n.º 27
0
        public static new List <Extension> LoadAll()
        {
            List <Extension> ret  = new List <Extension>();
            Connection       conn = ConnectionPoolManager.GetConnection(typeof(Extension));

            foreach (Extension ext in conn.Select(typeof(Extension),
                                                  new SelectParameter[] { new EqualParameter("Context", Context.Current) }))
            {
                ret.Add(ext);
            }
            conn.CloseConnection();
            return(ret);
        }
Ejemplo n.º 28
0
        public static List <TimedRoute> LoadAll()
        {
            List <TimedRoute> ret  = new List <TimedRoute>();
            Connection        conn = ConnectionPoolManager.GetConnection(typeof(TimedRoute));

            foreach (TimedRoute tr in conn.Select(typeof(TimedRoute),
                                                  new SelectParameter[] { new EqualParameter("RouteContext", Context.Current) }))
            {
                ret.Add(tr);
            }
            conn.CloseConnection();
            return(ret);
        }
Ejemplo n.º 29
0
        public static ExtensionNumber Load(string number, string context)
        {
            ExtensionNumber ret  = null;
            Connection      conn = ConnectionPoolManager.GetConnection(typeof(ExtensionNumber));
            List <Org.Reddragonit.Dbpro.Structure.Table> tmp = conn.Select(typeof(ExtensionNumber), new SelectParameter[] { new EqualParameter("Number", number), new EqualParameter("Context.Name", context) });

            if (tmp.Count > 0)
            {
                ret = (ExtensionNumber)tmp[0];
            }
            conn.CloseConnection();
            return(ret);
        }
Ejemplo n.º 30
0
        public static new OutgoingSIPTrunk Load(string name)
        {
            OutgoingSIPTrunk ret  = null;
            Connection       conn = ConnectionPoolManager.GetConnection(typeof(Gateway));
            List <Org.Reddragonit.Dbpro.Structure.Table> tmp = conn.Select(typeof(Gateway),
                                                                           new SelectParameter[] { new EqualParameter("Name", name) });

            if (tmp.Count > 0)
            {
                ret = (OutgoingSIPTrunk)tmp[0];
            }
            conn.CloseConnection();
            return(ret);
        }