Ejemplo n.º 1
0
        public NodeRow ToNodeRow()
        {
            NodeRow _nodeRow = new NodeRow();

            _nodeRow.Node_id     = this.Node_id;
            _nodeRow.Platform_id = this.Platform_id;

            if (this.Description != null)
            {
                _nodeRow.Description = (string)this.Description.Clone();
            }
            _nodeRow.Node_config              = this.Node_config;
            _nodeRow.Transport_type           = this.Transport_type;
            _nodeRow.User_name                = this.User_name;
            _nodeRow.Password                 = this.Password;
            _nodeRow.Ip_address               = this.Ip_address;
            _nodeRow.Port                     = this.Port;
            _nodeRow.Status                   = this.Node_status;
            _nodeRow.Billing_export_frequency = this.Billing_export_frequency;
            _nodeRow.Cdr_publishing_frequency = this.Cdr_publishing_frequency;

            return(_nodeRow);
        }
Ejemplo n.º 2
0
        public override void Insert(NodeRow value)
        {
            NodeRow _existing = GetByIPAddress(value.Ip_address);

            if (_existing != null)
            {
                throw new Exception("Node with the same IP Address [" + value.DottedIPAddress + "] already exists.");
            }


            string sqlStr = "DECLARE " + base.Database.CreateSqlParameterName(NodeRow.node_id_PropName) + " smallint " +
                            "SET " + base.Database.CreateSqlParameterName(NodeRow.node_id_PropName) +
                            " = COALESCE((SELECT MAX(" + NodeRow.node_id_DbName + ") FROM Node) + 1, 1) " +

                            "INSERT INTO [dbo].[Node] (" +
                            "[" + NodeRow.node_id_DbName + "], " +
                            "[" + NodeRow.platform_id_DbName + "], " +
                            "[" + NodeRow.description_DbName + "], " +
                            "[" + NodeRow.node_config_DbName + "], " +
                            "[" + NodeRow.transport_type_DbName + "], " +
                            "[" + NodeRow.user_name_DbName + "], " +
                            "[" + NodeRow.password_DbName + "], " +
                            "[" + NodeRow.ip_address_DbName + "], " +
                            "[" + NodeRow.port_DbName + "], " +
                            "[" + NodeRow.status_DbName + "], " +
                            "[" + NodeRow.billing_export_frequency_DbName + "], " +
                            "[" + NodeRow.cdr_publishing_frequency_DbName + "]" +
                            ") VALUES (" +
                            base.Database.CreateSqlParameterName(NodeRow.node_id_PropName) + ", " +
                            base.Database.CreateSqlParameterName(NodeRow.platform_id_PropName) + ", " +
                            base.Database.CreateSqlParameterName(NodeRow.description_PropName) + ", " +
                            base.Database.CreateSqlParameterName(NodeRow.node_config_PropName) + ", " +
                            base.Database.CreateSqlParameterName(NodeRow.transport_type_PropName) + ", " +
                            base.Database.CreateSqlParameterName(NodeRow.user_name_PropName) + ", " +
                            base.Database.CreateSqlParameterName(NodeRow.password_PropName) + ", " +
                            base.Database.CreateSqlParameterName(NodeRow.ip_address_PropName) + ", " +
                            base.Database.CreateSqlParameterName(NodeRow.port_PropName) + ", " +
                            base.Database.CreateSqlParameterName(NodeRow.status_PropName) + ", " +
                            base.Database.CreateSqlParameterName(NodeRow.billing_export_frequency_PropName) + ", " +
                            base.Database.CreateSqlParameterName(NodeRow.cdr_publishing_frequency_PropName) + ")" +
                            " SELECT " + base.Database.CreateSqlParameterName(NodeRow.node_id_PropName);

            IDbCommand cmd = base.Database.CreateCommand(sqlStr);

            //base.Database.AddParameter(cmd, NodeRow.node_id_PropName, DbType.Int16, value.Node_id);
            base.Database.AddParameter(cmd, NodeRow.platform_id_PropName, DbType.Int16, value.Platform_id);
            base.Database.AddParameter(cmd, NodeRow.description_PropName, DbType.AnsiString, value.Description);
            base.Database.AddParameter(cmd, NodeRow.node_config_PropName, DbType.Int32, value.Node_config);
            base.Database.AddParameter(cmd, NodeRow.transport_type_PropName, DbType.Byte, value.Transport_type);
            base.Database.AddParameter(cmd, NodeRow.user_name_PropName, DbType.AnsiString, value.User_name);
            base.Database.AddParameter(cmd, NodeRow.password_PropName, DbType.AnsiString, value.Password);
            base.Database.AddParameter(cmd, NodeRow.ip_address_PropName, DbType.Int32, value.Ip_address);
            base.Database.AddParameter(cmd, NodeRow.port_PropName, DbType.Int32, value.Port);
            base.Database.AddParameter(cmd, NodeRow.status_PropName, DbType.Byte, value.Status);

            base.Database.AddParameter(cmd, NodeRow.billing_export_frequency_PropName, DbType.Int32, value.Billing_export_frequency);
            base.Database.AddParameter(cmd, NodeRow.cdr_publishing_frequency_PropName, DbType.Int32, value.Cdr_publishing_frequency);

            object _res = cmd.ExecuteScalar();

            value.Node_id = (short)_res;
        }