Beispiel #1
0
        public static void AddDialPeerByCountry(CarrierAcctDto pCarrierAcct, EndPointRow pEndPointRow, CountryDto pCountry)
        {
            using (var _db = new Rbr_Db()) {
                using (var _tx = new Transaction(_db, pCarrierAcct, pEndPointRow, pCountry)) {
                    var _countryCarrierRoutes = CarrierAcctManager.GetByCarrierAcctIdCountryId(_db, pCarrierAcct.CarrierAcctId, pCountry.CountryId);
                    var _list = new ArrayList();
                    foreach (var _carrierRouteRow in _countryCarrierRoutes)
                    {
                        var _carrierAcctEPMapRow = new CarrierAcctEPMapRow
                        {
                            Carrier_acct_id  = pCarrierAcct.CarrierAcctId,
                            Carrier_route_id = _carrierRouteRow.Carrier_route_id,
                            End_point_id     = pEndPointRow.End_point_id,
                            Priority         = 0
                        };

                        if (!_list.Contains(_carrierAcctEPMapRow))
                        {
                            _list.Add(_carrierAcctEPMapRow);
                        }
                    }

                    if (_list.Count > 0)
                    {
                        var _carrierAcctEPMapRows = (CarrierAcctEPMapRow[])_list.ToArray(typeof(CarrierAcctEPMapRow));
                        foreach (var _carrierAcctEPMapRow in _carrierAcctEPMapRows)
                        {
                            CarrierAcctManager.AddDialPeer(_db, _carrierAcctEPMapRow, pEndPointRow);
                        }
                    }

                    _tx.Commit();
                }
            }
        }
        public static string ExportOrigEndPoint(OrigEndpointCdrExportInfo pOrigEndpointCdrExportInfo, BackgroundWorker pBackgroundWorker)
        {
            EndPointRow _endpointRow = EndpointController.GetEndpoint(pOrigEndpointCdrExportInfo.OrigEndpointId);
            string      _alias;

            if (_endpointRow == null)
            {
                if (pOrigEndpointCdrExportInfo.OrigEndpointId > 0)
                {
                    throw new ArgumentException(string.Format("Orig Endpoint NOT FOUND Id: {0}", pOrigEndpointCdrExportInfo.OrigEndpointId));
                }
                _alias = "_UNKNOWN_ORIG_ENDPOINT_";
            }
            else
            {
                _alias = _endpointRow.Alias;
            }

            string _fileName = "[" + _alias + "] " + pOrigEndpointCdrExportInfo.DateStart.ToString("yyyyMMdd") + "-" + pOrigEndpointCdrExportInfo.DateEnd.ToString("yyyyMMdd");

            _fileName += "[format-" + pOrigEndpointCdrExportInfo.CdrExportMap.Name + "]";
            _fileName += ".OrigEndpoint.cdr";
            _fileName  = FileHelper.CleanupInvalidFileNameCharacters(_fileName, '_');

            string _filePath = Path.Combine(pOrigEndpointCdrExportInfo.ExportDirectory, _fileName);
            string _where    = CDRViewRow_Base.orig_end_point_id_DbName + " = " + pOrigEndpointCdrExportInfo.OrigEndpointId;

            export(_where, pOrigEndpointCdrExportInfo, _filePath, pBackgroundWorker);

            return(_filePath);
        }
Beispiel #3
0
        public static void UpdateEndpoint(EndPointRow pEndPointRow, EndpointContext pEndpointContext)
        {
            //pEndpointContext.TransactionType = TxType.Delete;
            using (var _db = new Rbr_Db()) {
                using (var _tx = new Transaction(_db, pEndPointRow, pEndpointContext)) {
                    var _original = EndpointManager.Get(_db, pEndPointRow.End_point_id);
                    EndpointManager.Update(_db, _original, pEndPointRow);

                    if (pEndpointContext.CarrierAcctEPMapRowToDelete != null)
                    {
                        foreach (var _carrierAcctEPMapRow in pEndpointContext.CarrierAcctEPMapRowToDelete)
                        {
                            CarrierAcctManager.DeleteDialPeer(_db, _carrierAcctEPMapRow, pEndPointRow);
                        }
                    }

                    if (pEndpointContext.CarrierAcctEPMapRowToAdd != null)
                    {
                        foreach (var _carrierAcctEPMapRow in pEndpointContext.CarrierAcctEPMapRowToAdd)
                        {
                            if (_carrierAcctEPMapRow.Carrier_acct_EP_map_id <= 0)
                            {
                                _carrierAcctEPMapRow.End_point_id = pEndPointRow.End_point_id;
                                CarrierAcctManager.AddDialPeer(_db, _carrierAcctEPMapRow, pEndPointRow);
                            }
                        }
                    }
                    _tx.Commit();
                }
            }
        }
Beispiel #4
0
 public static void DeleteDialPeerByRoute(CarrierAcctDto pCarrierAcct, EndPointRow pEndPointRow, RatedRouteDto pCarrierRoute)
 {
     using (var _db = new Rbr_Db()) {
         using (var _tx = new Transaction(_db, pCarrierAcct, pEndPointRow, pCarrierRoute)) {
             var _carrierAcctEPMapRow = CarrierAcctManager.GetDialPeer(_db, pCarrierAcct.CarrierAcctId, pEndPointRow.End_point_id, pCarrierRoute.RatedRouteId);
             CarrierAcctManager.DeleteDialPeer(_db, _carrierAcctEPMapRow, pEndPointRow);
             _tx.Commit();
         }
     }
 }
        internal static void Update(Rbr_Db pDb, EndPointRow pOriginalEnpointRow, EndPointRow pNewEndpointRow)
        {
            if (pNewEndpointRow.IPAddressChanged(pOriginalEnpointRow))
            {
                updateIPAddress(pDb, pNewEndpointRow);
            }
            pDb.EndPointCollection.Update(pNewEndpointRow);

            //pDb.AddChangedObject(new EndpointKey(TxType.Delete, pOriginalEnpointRow.Ip_address_range));
            //pDb.AddChangedObject(new EndpointKey(TxType.Add, pNewEndpointRow.Ip_address_range));
        }
        internal static void Delete(Rbr_Db pDb, EndPointRow pEndPointRow)
        {
            if (pEndPointRow == null)
            {
                return;
            }
            pDb.IPAddressCollection.DeleteByEnd_point_id(pEndPointRow.End_point_id);
            pDb.EndPointCollection.Delete(pEndPointRow);

            //pDb.AddChangedObject(new EndpointKey(TxType.Delete, pEndPointRow.Ip_address_range));
        }
 static void addIPAddressCollection(Rbr_Db pDb, EndPointRow pEndPointRow)
 {
     if (pEndPointRow == null || pEndPointRow.Ip_address_range == null)
     {
         throw new ApplicationException("At least one IPAddress should be passed");
     }
     foreach (int _ip in pEndPointRow.IPAddressRange.IPAddressInt32List)
     {
         var _ipAddressRow = new IPAddressRow();
         _ipAddressRow.IP_address   = _ip;
         _ipAddressRow.End_point_id = pEndPointRow.End_point_id;
         pDb.IPAddressCollection.Insert(_ipAddressRow);
     }
 }
Beispiel #8
0
        /// <summary>
        /// Adds a new record into the <c>EndPoint</c> table.
        /// </summary>
        /// <param name="value">The <see cref="EndPointRow"/> object to be inserted.</param>
        public virtual void Insert(EndPointRow value)
        {
            string sqlStr = "INSERT INTO [dbo].[EndPoint] (" +
                            "[end_point_id], " +
                            "[alias], " +
                            "[with_alias_authentication], " +
                            "[status], " +
                            "[type], " +
                            "[protocol], " +
                            "[port], " +
                            "[registration], " +
                            "[is_registered], " +
                            "[ip_address_range], " +
                            "[max_calls], " +
                            "[password], " +
                            "[prefix_in_type_id], " +
                            "[virtual_switch_id]" +
                            ") VALUES (" +
                            _db.CreateSqlParameterName("End_point_id") + ", " +
                            _db.CreateSqlParameterName("Alias") + ", " +
                            _db.CreateSqlParameterName("With_alias_authentication") + ", " +
                            _db.CreateSqlParameterName("Status") + ", " +
                            _db.CreateSqlParameterName("Type") + ", " +
                            _db.CreateSqlParameterName("Protocol") + ", " +
                            _db.CreateSqlParameterName("Port") + ", " +
                            _db.CreateSqlParameterName("Registration") + ", " +
                            _db.CreateSqlParameterName("Is_registered") + ", " +
                            _db.CreateSqlParameterName("Ip_address_range") + ", " +
                            _db.CreateSqlParameterName("Max_calls") + ", " +
                            _db.CreateSqlParameterName("Password") + ", " +
                            _db.CreateSqlParameterName("Prefix_in_type_id") + ", " +
                            _db.CreateSqlParameterName("Virtual_switch_id") + ")";
            IDbCommand cmd = _db.CreateCommand(sqlStr);

            AddParameter(cmd, "End_point_id", value.End_point_id);
            AddParameter(cmd, "Alias", value.Alias);
            AddParameter(cmd, "With_alias_authentication", value.With_alias_authentication);
            AddParameter(cmd, "Status", value.Status);
            AddParameter(cmd, "Type", value.Type);
            AddParameter(cmd, "Protocol", value.Protocol);
            AddParameter(cmd, "Port", value.Port);
            AddParameter(cmd, "Registration", value.Registration);
            AddParameter(cmd, "Is_registered", value.Is_registered);
            AddParameter(cmd, "Ip_address_range", value.Ip_address_range);
            AddParameter(cmd, "Max_calls", value.Max_calls);
            AddParameter(cmd, "Password", value.Password);
            AddParameter(cmd, "Prefix_in_type_id", value.Prefix_in_type_id);
            AddParameter(cmd, "Virtual_switch_id", value.Virtual_switch_id);
            cmd.ExecuteNonQuery();
        }
Beispiel #9
0
        public static void AddEndpoint(EndPointRow pEndPointRow, EndpointContext pEndpointContext)
        {
            using (var _db = new Rbr_Db()) {
                using (var _tx = new Transaction(_db, pEndPointRow, pEndpointContext)) {
                    //TODO: NEW DAL - VirtualSwitch
                    pEndPointRow.Virtual_switch_id = AppConstants.DefaultVirtualSwitchId;

                    EndpointManager.Add(_db, pEndPointRow, pEndpointContext);
                    //CarrierAcctManager.AddDialPeer(_db, pEndPointRow, pEndpointContext);
                    if (pEndpointContext.CarrierAcctEPMapRowToAdd != null && pEndpointContext.CarrierAcctEPMapRowToAdd.Length > 0)
                    {
                        foreach (var _carrierAcctEPMapRow in pEndpointContext.CarrierAcctEPMapRowToAdd)
                        {
                            _carrierAcctEPMapRow.End_point_id = pEndPointRow.End_point_id;
                            CarrierAcctManager.AddDialPeer(_db, _carrierAcctEPMapRow, pEndPointRow);
                        }
                    }

                    if (pEndpointContext.CustomerAcct != null)
                    {
                        if (pEndpointContext.CustomerAcct.ServiceDto.AccessNumbers != null && pEndpointContext.CustomerAcct.ServiceDto.AccessNumbers.Length > 0)
                        {
                            foreach (var _accessNumber in pEndpointContext.CustomerAcct.ServiceDto.AccessNumbers)
                            {
                                var _newDialPeer = new DialPeerRow
                                {
                                    End_point_id     = pEndPointRow.End_point_id,
                                    Prefix_in        = _accessNumber.Number.ToString(),
                                    Customer_acct_id = pEndpointContext.CustomerAcct.CustomerAcctId
                                };
                                CustomerAcctManager.AddDialPeer(_db, _newDialPeer, pEndPointRow);
                            }
                        }
                        else
                        {
                            var _newDialPeer = new DialPeerRow
                            {
                                End_point_id     = pEndPointRow.End_point_id,
                                Prefix_in        = pEndpointContext.CustomerAcct.PrefixIn,
                                Customer_acct_id = pEndpointContext.CustomerAcct.CustomerAcctId
                            };
                            CustomerAcctManager.AddDialPeer(_db, _newDialPeer, pEndPointRow);
                        }
                    }

                    _tx.Commit();
                }
            }
        }
Beispiel #10
0
 public static void DeleteDialPeerByCountry(CarrierAcctDto pCarrierAcct, EndPointRow pEndPointRow, CountryDto pCountry)
 {
     using (var _db = new Rbr_Db()) {
         using (var _tx = new Transaction(_db, pCarrierAcct, pEndPointRow, pCountry)) {
             //CarrierAcctManager.DeleteDialPeerByCountry(_db, pCarrierAcct, pCountry, pEndPointRow);
             var _countryCarrierRoutes = CarrierAcctManager.GetByCarrierAcctIdCountryId(_db, pCarrierAcct.CarrierAcctId, pCountry.CountryId);
             var _carrierAcctEPMapRows = CarrierAcctManager.GetByCountry(_db, _countryCarrierRoutes, pCarrierAcct.CarrierAcctId, pEndPointRow.End_point_id);
             foreach (var _carrierAcctEPMapRow in _carrierAcctEPMapRows)
             {
                 CarrierAcctManager.DeleteDialPeer(_db, _carrierAcctEPMapRow, pEndPointRow);
             }
             _tx.Commit();
         }
     }
 }
Beispiel #11
0
 public static void AddDialPeerByRoute(CarrierAcctDto pCarrierAcct, EndPointRow pEndPointRow, RatedRouteDto pCarrierRoute)
 {
     using (var _db = new Rbr_Db()) {
         using (var _tx = new Transaction(_db, pCarrierAcct, pEndPointRow, pCarrierRoute)) {
             var _carrierAcctEPMapRow = new CarrierAcctEPMapRow
             {
                 Carrier_acct_id  = pCarrierAcct.CarrierAcctId,
                 Carrier_route_id = pCarrierRoute.RatedRouteId,
                 End_point_id     = pEndPointRow.End_point_id,
                 Priority         = 0
             };
             CarrierAcctManager.AddDialPeer(_db, _carrierAcctEPMapRow, pEndPointRow);
             _tx.Commit();
         }
     }
 }
Beispiel #12
0
 public static void DeleteDialPeer(EndPointRow pEndpointRow, CustomerAcctDto pCustomerAcct)
 {
     using (var _db = new Rbr_Db()) {
         using (var _tx = new Transaction(_db, pEndpointRow, pCustomerAcct)) {
             CustomerAcctManager.DeleteDialPeer(_db, pEndpointRow.End_point_id, pCustomerAcct.PrefixIn);
             if (pCustomerAcct.ServiceDto.ServiceType == ServiceType.Retail)
             {
                 foreach (var _accessNumberDto in pCustomerAcct.ServiceDto.AccessNumbers)
                 {
                     CustomerAcctManager.DeleteDialPeer(_db, pEndpointRow.End_point_id, _accessNumberDto.Number.ToString());
                 }
             }
             _tx.Commit();
         }
     }
 }
        internal static void UpdatePrefixType(Rbr_Db pDb, EndPointRow pEndpointRow, short pNewPrefixTypeId)
        {
            if (pEndpointRow == null)
            {
                throw new Exception("Invalid operation: Endpoint should not be NULL.");
            }

            bool _endpointHasDialPeers = CustomerAcctManager.GetDialPeerCountByEndpointId(pDb, pEndpointRow.End_point_id) > 0;

            if (_endpointHasDialPeers)
            {
                throw new Exception("Invalid operation: expecting Endpoint without DialPeers.");
            }

            //pDb.AddChangedObject(new EndpointKey(TxType.Delete, pEndpointRow.Ip_address_range));

            pEndpointRow.Prefix_in_type_id = pNewPrefixTypeId;
            pDb.EndPointCollection.Update(pEndpointRow);

            //pDb.AddChangedObject(new EndpointKey(TxType.Add, pEndpointRow.Ip_address_range));
        }
Beispiel #14
0
        public static void DeleteEndpoint(EndPointRow pEndPointRow)
        {
            using (var _db = new Rbr_Db()) {
                using (var _tx = new Transaction(_db, pEndPointRow)) {
                    CustomerAcctManager.DeleteDialPeersByEndpointId(_db, pEndPointRow.End_point_id);

                    //- Delete Carrier Dialpeers
                    var _dialPeers = _db.CarrierAcctEPMapCollection.GetByEnd_point_id(pEndPointRow.End_point_id);
                    if (_dialPeers != null && _dialPeers.Length > 0)
                    {
                        foreach (var _carrierAcctEPMapRow in _dialPeers)
                        {
                            CarrierAcctManager.DeleteDialPeer(_db, _carrierAcctEPMapRow, pEndPointRow);
                        }
                    }

                    EndpointManager.Delete(_db, pEndPointRow);
                    _tx.Commit();
                }
            }
        }
Beispiel #15
0
        public static void ReassignDialPeer(EndPointRow pEndpointRow, CustomerAcctDto pFromCustomerAcct, CustomerAcctDto pToCustomerAcct)
        {
            if (pEndpointRow.WithInPrefixes || pFromCustomerAcct.WithPrefixes || pToCustomerAcct.WithPrefixes)
            {
                throw new Exception("Invalid operation: expecting Endpoint and Customer without Prefixes ONLY.");
            }

            using (var _db = new Rbr_Db()) {
                using (var _tx = new Transaction(_db, pEndpointRow, pFromCustomerAcct, pToCustomerAcct)) {
                    CustomerAcctManager.DeleteDialPeer(_db, pEndpointRow.End_point_id, pFromCustomerAcct.PrefixIn);

                    var _newDialPeerRow = new DialPeerRow
                    {
                        End_point_id     = pEndpointRow.End_point_id,
                        Prefix_in        = pToCustomerAcct.PrefixIn,
                        Customer_acct_id = pToCustomerAcct.CustomerAcctId
                    };
                    CustomerAcctManager.AddDialPeer(_db, _newDialPeerRow, pEndpointRow);
                    _tx.Commit();
                }
            }
        }
Beispiel #16
0
        public static void AddChangingEndpointPrefixType(EndPointRow pEndpointRow, CustomerAcctDto pCustomerAcct)
        {
            using (var _db = new Rbr_Db()) {
                using (var _tx = new Transaction(_db, pEndpointRow, pCustomerAcct)) {
                    EndpointManager.UpdatePrefixType(_db, pEndpointRow, pCustomerAcct.PrefixInTypeId);

                    var _endpointContext = new EndpointContext {
                        CustomerAcct = pCustomerAcct
                    };
                    if (_endpointContext.CustomerAcct != null)
                    {
                        var _newDialPeer = new DialPeerRow
                        {
                            End_point_id     = pEndpointRow.End_point_id,
                            Prefix_in        = _endpointContext.CustomerAcct.PrefixIn,
                            Customer_acct_id = _endpointContext.CustomerAcct.CustomerAcctId
                        };
                        CustomerAcctManager.AddDialPeer(_db, _newDialPeer, pEndpointRow);
                    }
                    _tx.Commit();
                }
            }
        }
Beispiel #17
0
        /// <summary>
        /// Updates a record in the <c>EndPoint</c> table.
        /// </summary>
        /// <param name="value">The <see cref="EndPointRow"/>
        /// object used to update the table record.</param>
        /// <returns>true if the record was updated; otherwise, false.</returns>
        public virtual bool Update(EndPointRow value)
        {
            string sqlStr = "UPDATE [dbo].[EndPoint] SET " +
                            "[alias]=" + _db.CreateSqlParameterName("Alias") + ", " +
                            "[with_alias_authentication]=" + _db.CreateSqlParameterName("With_alias_authentication") + ", " +
                            "[status]=" + _db.CreateSqlParameterName("Status") + ", " +
                            "[type]=" + _db.CreateSqlParameterName("Type") + ", " +
                            "[protocol]=" + _db.CreateSqlParameterName("Protocol") + ", " +
                            "[port]=" + _db.CreateSqlParameterName("Port") + ", " +
                            "[registration]=" + _db.CreateSqlParameterName("Registration") + ", " +
                            "[is_registered]=" + _db.CreateSqlParameterName("Is_registered") + ", " +
                            "[ip_address_range]=" + _db.CreateSqlParameterName("Ip_address_range") + ", " +
                            "[max_calls]=" + _db.CreateSqlParameterName("Max_calls") + ", " +
                            "[password]=" + _db.CreateSqlParameterName("Password") + ", " +
                            "[prefix_in_type_id]=" + _db.CreateSqlParameterName("Prefix_in_type_id") + ", " +
                            "[virtual_switch_id]=" + _db.CreateSqlParameterName("Virtual_switch_id") +
                            " WHERE " +
                            "[end_point_id]=" + _db.CreateSqlParameterName("End_point_id");
            IDbCommand cmd = _db.CreateCommand(sqlStr);

            AddParameter(cmd, "Alias", value.Alias);
            AddParameter(cmd, "With_alias_authentication", value.With_alias_authentication);
            AddParameter(cmd, "Status", value.Status);
            AddParameter(cmd, "Type", value.Type);
            AddParameter(cmd, "Protocol", value.Protocol);
            AddParameter(cmd, "Port", value.Port);
            AddParameter(cmd, "Registration", value.Registration);
            AddParameter(cmd, "Is_registered", value.Is_registered);
            AddParameter(cmd, "Ip_address_range", value.Ip_address_range);
            AddParameter(cmd, "Max_calls", value.Max_calls);
            AddParameter(cmd, "Password", value.Password);
            AddParameter(cmd, "Prefix_in_type_id", value.Prefix_in_type_id);
            AddParameter(cmd, "Virtual_switch_id", value.Virtual_switch_id);
            AddParameter(cmd, "End_point_id", value.End_point_id);
            return(0 != cmd.ExecuteNonQuery());
        }
Beispiel #18
0
        /// <summary>
        /// Converts <see cref="System.Data.DataRow"/> to <see cref="EndPointRow"/>.
        /// </summary>
        /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param>
        /// <returns>A reference to the <see cref="EndPointRow"/> object.</returns>
        protected virtual EndPointRow MapRow(DataRow row)
        {
            EndPointRow mappedObject = new EndPointRow();
            DataTable   dataTable    = row.Table;
            DataColumn  dataColumn;

            // Column "End_point_id"
            dataColumn = dataTable.Columns["End_point_id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.End_point_id = (short)row[dataColumn];
            }
            // Column "Alias"
            dataColumn = dataTable.Columns["Alias"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Alias = (string)row[dataColumn];
            }
            // Column "With_alias_authentication"
            dataColumn = dataTable.Columns["With_alias_authentication"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.With_alias_authentication = (byte)row[dataColumn];
            }
            // Column "Status"
            dataColumn = dataTable.Columns["Status"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Status = (byte)row[dataColumn];
            }
            // Column "Type"
            dataColumn = dataTable.Columns["Type"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Type = (byte)row[dataColumn];
            }
            // Column "Protocol"
            dataColumn = dataTable.Columns["Protocol"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Protocol = (byte)row[dataColumn];
            }
            // Column "Port"
            dataColumn = dataTable.Columns["Port"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Port = (int)row[dataColumn];
            }
            // Column "Registration"
            dataColumn = dataTable.Columns["Registration"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Registration = (byte)row[dataColumn];
            }
            // Column "Is_registered"
            dataColumn = dataTable.Columns["Is_registered"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Is_registered = (byte)row[dataColumn];
            }
            // Column "Ip_address_range"
            dataColumn = dataTable.Columns["Ip_address_range"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Ip_address_range = (string)row[dataColumn];
            }
            // Column "Max_calls"
            dataColumn = dataTable.Columns["Max_calls"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Max_calls = (int)row[dataColumn];
            }
            // Column "Password"
            dataColumn = dataTable.Columns["Password"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Password = (string)row[dataColumn];
            }
            // Column "Prefix_in_type_id"
            dataColumn = dataTable.Columns["Prefix_in_type_id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Prefix_in_type_id = (short)row[dataColumn];
            }
            // Column "Virtual_switch_id"
            dataColumn = dataTable.Columns["Virtual_switch_id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Virtual_switch_id = (int)row[dataColumn];
            }
            return(mappedObject);
        }
Beispiel #19
0
        /// <summary>
        /// Reads data from the provided data reader and returns
        /// an array of mapped objects.
        /// </summary>
        /// <param name="reader">The <see cref="System.Data.IDataReader"/> object to read data from the table.</param>
        /// <param name="startIndex">The index of the first record to map.</param>
        /// <param name="length">The number of records to map.</param>
        /// <param name="totalRecordCount">A reference parameter that returns the total number
        /// of records in the reader object if 0 was passed into the method; otherwise it returns -1.</param>
        /// <returns>An array of <see cref="EndPointRow"/> objects.</returns>
        protected virtual EndPointRow[] MapRecords(IDataReader reader,
                                                   int startIndex, int length, ref int totalRecordCount)
        {
            if (0 > startIndex)
            {
                throw new ArgumentOutOfRangeException("startIndex", startIndex, "StartIndex cannot be less than zero.");
            }
            if (0 > length)
            {
                throw new ArgumentOutOfRangeException("length", length, "Length cannot be less than zero.");
            }

            int end_point_idColumnIndex = reader.GetOrdinal("end_point_id");
            int aliasColumnIndex        = reader.GetOrdinal("alias");
            int with_alias_authenticationColumnIndex = reader.GetOrdinal("with_alias_authentication");
            int statusColumnIndex            = reader.GetOrdinal("status");
            int typeColumnIndex              = reader.GetOrdinal("type");
            int protocolColumnIndex          = reader.GetOrdinal("protocol");
            int portColumnIndex              = reader.GetOrdinal("port");
            int registrationColumnIndex      = reader.GetOrdinal("registration");
            int is_registeredColumnIndex     = reader.GetOrdinal("is_registered");
            int ip_address_rangeColumnIndex  = reader.GetOrdinal("ip_address_range");
            int max_callsColumnIndex         = reader.GetOrdinal("max_calls");
            int passwordColumnIndex          = reader.GetOrdinal("password");
            int prefix_in_type_idColumnIndex = reader.GetOrdinal("prefix_in_type_id");
            int virtual_switch_idColumnIndex = reader.GetOrdinal("virtual_switch_id");

            System.Collections.ArrayList recordList = new System.Collections.ArrayList();
            int ri = -startIndex;

            while (reader.Read())
            {
                ri++;
                if (ri > 0 && ri <= length)
                {
                    EndPointRow record = new EndPointRow();
                    recordList.Add(record);

                    record.End_point_id = Convert.ToInt16(reader.GetValue(end_point_idColumnIndex));
                    record.Alias        = Convert.ToString(reader.GetValue(aliasColumnIndex));
                    record.With_alias_authentication = Convert.ToByte(reader.GetValue(with_alias_authenticationColumnIndex));
                    record.Status            = Convert.ToByte(reader.GetValue(statusColumnIndex));
                    record.Type              = Convert.ToByte(reader.GetValue(typeColumnIndex));
                    record.Protocol          = Convert.ToByte(reader.GetValue(protocolColumnIndex));
                    record.Port              = Convert.ToInt32(reader.GetValue(portColumnIndex));
                    record.Registration      = Convert.ToByte(reader.GetValue(registrationColumnIndex));
                    record.Is_registered     = Convert.ToByte(reader.GetValue(is_registeredColumnIndex));
                    record.Ip_address_range  = Convert.ToString(reader.GetValue(ip_address_rangeColumnIndex));
                    record.Max_calls         = Convert.ToInt32(reader.GetValue(max_callsColumnIndex));
                    record.Password          = Convert.ToString(reader.GetValue(passwordColumnIndex));
                    record.Prefix_in_type_id = Convert.ToInt16(reader.GetValue(prefix_in_type_idColumnIndex));
                    record.Virtual_switch_id = Convert.ToInt32(reader.GetValue(virtual_switch_idColumnIndex));

                    if (ri == length && 0 != totalRecordCount)
                    {
                        break;
                    }
                }
            }

            totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1;
            return((EndPointRow[])(recordList.ToArray(typeof(EndPointRow))));
        }
Beispiel #20
0
 /// <summary>
 /// Deletes the specified object from the <c>EndPoint</c> table.
 /// </summary>
 /// <param name="value">The <see cref="EndPointRow"/> object to delete.</param>
 /// <returns>true if the record was deleted; otherwise, false.</returns>
 public bool Delete(EndPointRow value)
 {
     return(DeleteByPrimaryKey(value.End_point_id));
 }
Beispiel #21
0
 public Endpoint(EndPointRow pEndPointRow)
 {
     endPointRow = pEndPointRow;
     cpsMeter    = new CPSMeter(IPAddressRangeAndPort, endPointRow.Max_calls <= 0 ? 75 : endPointRow.Max_calls, TimokLogger.Instance.LogRbr);
 }
 static void updateIPAddress(Rbr_Db pDb, EndPointRow pEndPointRow)
 {
     pDb.IPAddressCollection.DeleteByEnd_point_id(pEndPointRow.End_point_id);
     addIPAddressCollection(pDb, pEndPointRow);
 }
Beispiel #23
0
 internal static void DeleteDialPeer(Rbr_Db pDb, CarrierAcctEPMapRow pCarrierAcctEPMapRow, EndPointRow pEndPointRow)
 {
     pDb.CarrierAcctEPMapCollection.Delete(pCarrierAcctEPMapRow);
     //pDb.AddChangedObject(new CarrierDialPeerKey(TxType.Delete, pCarrierAcctEPMapRow.Carrier_acct_id, pCarrierAcctEPMapRow.Carrier_route_id));
 }
 internal static void Add(Rbr_Db pDb, EndPointRow pEndPointRow, EndpointContext pEndpointContext)
 {
     pDb.EndPointCollection.Insert(pEndPointRow);
     addIPAddressCollection(pDb, pEndPointRow);
     //pDb.AddChangedObject(new EndpointKey(TxType.Add, pEndPointRow.Ip_address_range));
 }
Beispiel #25
0
 internal static void AddDialPeer(Rbr_Db pDb, DialPeerRow pDialPeerRow, EndPointRow pEndPointRow)
 {
     pDb.DialPeerCollection.Insert(pDialPeerRow);
     //pDb.AddChangedObject(new EndpointKey(TxType.Add, pDialPeerRow.End_point_id));
 }
Beispiel #26
0
 //---------------- Carrier DialPeers ------------------------------------------------------------
 internal static void AddDialPeer(Rbr_Db pDb, CarrierAcctEPMapRow pCarrierAcctEPMapRow, EndPointRow pEndPointRow)
 {
     pDb.CarrierAcctEPMapCollection.Insert(pCarrierAcctEPMapRow);
     //pDb.AddChangedObject(new EndpointKey(TxType.Add, pCarrierAcctEPMapRow.End_point_id));
 }