Exemplo n.º 1
0
        private void validateByIPAddressRange(EndPointRow pEndPointRow)
        {
            string _ipAddressRange = string.Empty;

            foreach (int _intIP in pEndPointRow.IPAddressRange.IPAddressInt32List)
            {
                _ipAddressRange += _intIP.ToString() + ",";
            }
            _ipAddressRange = _ipAddressRange.TrimEnd(',');

            string _sqlStr = "SELECT [" + IPAddressRow.end_point_id_DbName + "] FROM [dbo].[IPAddress] WHERE " +
                             "[" + IPAddressRow.IP_address_DbName + "] IN(" + _ipAddressRange + ") " +
                             " AND " +
                             "[" + IPAddressRow.end_point_id_DbName + "]<>" + base.Database.CreateSqlParameterName(IPAddressRow.end_point_id_PropName);
            IDbCommand _cmd = Database.CreateCommand(_sqlStr);

            AddParameter(_cmd, IPAddressRow.end_point_id_PropName, pEndPointRow.End_point_id);

            object _existingEPID = _cmd.ExecuteScalar();
            short  _endPointID   = 0;

            if (_existingEPID != null)
            {
                _endPointID = (short)_existingEPID;
            }

            if (_endPointID > 0)
            {
                //get Alias;
                EndPointRow _existingEndPoint = GetByPrimaryKey(_endPointID);
                throw new Exception("IP Address in the provided IP Range already in use by other End Point ID=[" + _existingEndPoint.End_point_id + "] Alias=[" + _existingEndPoint.Alias + "] IP Range[" + _existingEndPoint.Ip_address_range + "] .");
            }
        }
Exemplo n.º 2
0
 private void validateByAlias(EndPointRow pEndPointRow)
 {
     if (exists(pEndPointRow.Alias, pEndPointRow.End_point_id))
     {
         throw new ApplicationException(
                   "Alias [" + pEndPointRow.Alias + "] already in use by other End Point ID=[" + pEndPointRow.End_point_id + "] IP Range[" + pEndPointRow.Ip_address_range + "] .");
     }
 }
Exemplo n.º 3
0
 private void validate(short pEndPointID, string pPrefixIn)
 {
     if (this.exists(pEndPointID, pPrefixIn))
     {
         EndPointRow _ep = Database.EndPointCollection.GetByPrimaryKey(pEndPointID);
         throw new Exception("End Point " + _ep.ToString() + "\r\n" +
                             "already defines Dial Peer with provided Prefix [" + pPrefixIn + "].\r\n");
     }
 }
Exemplo n.º 4
0
        public override void Insert(EndPointRow value)
        {
            validateByIPAddressRange(value);
            validateByAlias(value);

            //SET @end_point_id = COALESCE((SELECT MAX(end_point_id) FROM EndPoint) + 1, 4000)
            string _id_param = base.Database.CreateSqlParameterName(EndPointRow.end_point_id_PropName);
            string _sqlStr   = "DECLARE " + _id_param + " smallint " +
                               "SET " + _id_param + " = COALESCE((SELECT MAX(" + EndPointRow.end_point_id_DbName + ") FROM EndPoint) + 1, 7000) " +

                               "INSERT INTO [dbo].[EndPoint] (" +
                               "[" + EndPointRow.end_point_id_DbName + "], " +
                               "[" + EndPointRow.alias_DbName + "], " +
                               "[" + EndPointRow.with_alias_authentication_DbName + "], " +
                               "[" + EndPointRow.status_DbName + "], " +
                               "[" + EndPointRow.type_DbName + "], " +
                               "[" + EndPointRow.protocol_DbName + "], " +
                               "[" + EndPointRow.port_DbName + "], " +
                               "[" + EndPointRow.registration_DbName + "], " +
                               "[" + EndPointRow.is_registered_DbName + "], " +
                               "[" + EndPointRow.ip_address_range_DbName + "], " +
                               "[" + EndPointRow.max_calls_DbName + "], " +
                               "[" + EndPointRow.password_DbName + "], " +
                               "[" + EndPointRow.prefix_in_type_id_DbName + "], " +
                               "[" + EndPointRow.virtual_switch_id_DbName + "] " +
                               ") VALUES (" +
                               base.Database.CreateSqlParameterName(EndPointRow.end_point_id_PropName) + ", " +
                               base.Database.CreateSqlParameterName(EndPointRow.alias_PropName) + ", " +
                               base.Database.CreateSqlParameterName(EndPointRow.with_alias_authentication_PropName) + ", " +
                               base.Database.CreateSqlParameterName(EndPointRow.status_PropName) + ", " +
                               base.Database.CreateSqlParameterName(EndPointRow.type_PropName) + ", " +
                               base.Database.CreateSqlParameterName(EndPointRow.protocol_PropName) + ", " +
                               base.Database.CreateSqlParameterName(EndPointRow.port_PropName) + ", " +
                               base.Database.CreateSqlParameterName(EndPointRow.registration_PropName) + ", " +
                               base.Database.CreateSqlParameterName(EndPointRow.is_registered_PropName) + ", " +
                               base.Database.CreateSqlParameterName(EndPointRow.ip_address_range_PropName) + ", " +
                               base.Database.CreateSqlParameterName(EndPointRow.max_calls_PropName) + ", " +
                               base.Database.CreateSqlParameterName(EndPointRow.password_PropName) + ", " +
                               base.Database.CreateSqlParameterName(EndPointRow.prefix_in_type_id_PropName) + ", " +
                               base.Database.CreateSqlParameterName(EndPointRow.virtual_switch_id_PropName) + ") " +
                               "SELECT " + base.Database.CreateSqlParameterName(EndPointRow.end_point_id_PropName);

            IDbCommand _cmd = base.Database.CreateCommand(_sqlStr);

            //_db.AddParameter(cmd, end_point_id_PropName, value.end_point_id);
            AddParameter(_cmd, EndPointRow.alias_PropName, value.Alias);
            AddParameter(_cmd, EndPointRow.with_alias_authentication_PropName, value.With_alias_authentication);
            AddParameter(_cmd, EndPointRow.status_PropName, value.Status);
            AddParameter(_cmd, EndPointRow.type_PropName, value.Type);
            AddParameter(_cmd, EndPointRow.protocol_PropName, value.Protocol);
            AddParameter(_cmd, EndPointRow.port_PropName, value.Port);
            AddParameter(_cmd, EndPointRow.registration_PropName, value.Registration);
            AddParameter(_cmd, EndPointRow.is_registered_PropName, 0);
            AddParameter(_cmd, EndPointRow.ip_address_range_PropName, value.Ip_address_range);
            AddParameter(_cmd, EndPointRow.max_calls_PropName, value.Max_calls);
            AddParameter(_cmd, EndPointRow.password_PropName, value.Password);
            AddParameter(_cmd, EndPointRow.prefix_in_type_id_PropName, value.Prefix_in_type_id);
            AddParameter(_cmd, EndPointRow.virtual_switch_id_PropName, value.Virtual_switch_id);

            object _res = _cmd.ExecuteScalar();

            value.End_point_id = (short)_res;
        }
Exemplo n.º 5
0
 public override bool Update(EndPointRow value)
 {
     validateByIPAddressRange(value);
     validateByAlias(value);
     return(base.Update(value));
 }
Exemplo n.º 6
0
		public bool IPAddressChanged(EndPointRow pOriginal) {
			if (Ip_address_range != pOriginal.Ip_address_range) {
				return true;
			}
			return false;
		}
Exemplo n.º 7
0
		public bool IsDeactivated(EndPointRow pOriginal) {
			if (EPStatus != pOriginal.EPStatus && pOriginal.EPStatus == Core.Config.Status.Active) {
				return true;
			}
			return false;
		}