/// <summary>
        /// Converts <see cref="System.Data.DataRow"/> to <see cref="LoadBalancingMapRow"/>.
        /// </summary>
        /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param>
        /// <returns>A reference to the <see cref="LoadBalancingMapRow"/> object.</returns>
        protected virtual LoadBalancingMapRow MapRow(DataRow row)
        {
            LoadBalancingMapRow mappedObject = new LoadBalancingMapRow();
            DataTable           dataTable    = row.Table;
            DataColumn          dataColumn;

            // Column "Node_id"
            dataColumn = dataTable.Columns["Node_id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Node_id = (short)row[dataColumn];
            }
            // Column "Customer_acct_id"
            dataColumn = dataTable.Columns["Customer_acct_id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Customer_acct_id = (short)row[dataColumn];
            }
            // Column "Max_calls"
            dataColumn = dataTable.Columns["Max_calls"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Max_calls = (int)row[dataColumn];
            }
            // Column "Current_calls"
            dataColumn = dataTable.Columns["Current_calls"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Current_calls = (int)row[dataColumn];
            }
            return(mappedObject);
        }
Exemple #2
0
 public static void Update(LoadBalancingMapRow pLoadBalancingMapRow)
 {
     using (Rbr_Db _db = new Rbr_Db()) {
         using (var _tx = new Transaction(_db, pLoadBalancingMapRow)) {
             LoadBalancingMapManager.Update(_db, pLoadBalancingMapRow);
             _tx.Commit();
         }
     }
 }
Exemple #3
0
 public static void Delete(NodeViewRow pNodeViewRow, CustomerAcctDto pCustomerAcct)
 {
     using (Rbr_Db _db = new Rbr_Db()) {
         using (Transaction _tx = new Transaction(_db, pNodeViewRow, pCustomerAcct)) {
             LoadBalancingMapRow _loadBalancingMapRow = LoadBalancingMapManager.Get(_db, pNodeViewRow.Node_id, pCustomerAcct.CustomerAcctId);
             LoadBalancingMapManager.Delete(_db, _loadBalancingMapRow);
             _tx.Commit();
         }
     }
 }
        /// <summary>
        /// Updates a record in the <c>LoadBalancingMap</c> table.
        /// </summary>
        /// <param name="value">The <see cref="LoadBalancingMapRow"/>
        /// object used to update the table record.</param>
        /// <returns>true if the record was updated; otherwise, false.</returns>
        public virtual bool Update(LoadBalancingMapRow value)
        {
            string sqlStr = "UPDATE [dbo].[LoadBalancingMap] SET " +
                            "[max_calls]=" + _db.CreateSqlParameterName("Max_calls") +
                            " WHERE " +
                            "[node_id]=" + _db.CreateSqlParameterName("Node_id") + " AND " +
                            "[customer_acct_id]=" + _db.CreateSqlParameterName("Customer_acct_id");
            IDbCommand cmd = _db.CreateCommand(sqlStr);

            AddParameter(cmd, "Max_calls", value.Max_calls);
            AddParameter(cmd, "Node_id", value.Node_id);
            AddParameter(cmd, "Customer_acct_id", value.Customer_acct_id);
            return(0 != cmd.ExecuteNonQuery());
        }
Exemple #5
0
        internal static void Add(Rbr_Db pDb, short pNodeId, short pCustomerAcctId)
        {
            LoadBalancingMapRow _loadBalancingMapRow = pDb.LoadBalancingMapCollection.GetByPrimaryKey(pNodeId, pCustomerAcctId);

            if (_loadBalancingMapRow == null)
            {
                _loadBalancingMapRow                  = new LoadBalancingMapRow();
                _loadBalancingMapRow.Node_id          = pNodeId;
                _loadBalancingMapRow.Customer_acct_id = pCustomerAcctId;
                _loadBalancingMapRow.Max_calls        = int.MaxValue;
                _loadBalancingMapRow.Current_calls    = 0;
                add(pDb, _loadBalancingMapRow);
            }
        }
        /// <summary>
        /// Adds a new record into the <c>LoadBalancingMap</c> table.
        /// </summary>
        /// <param name="value">The <see cref="LoadBalancingMapRow"/> object to be inserted.</param>
        public virtual void Insert(LoadBalancingMapRow value)
        {
            string sqlStr = "INSERT INTO [dbo].[LoadBalancingMap] (" +
                            "[node_id], " +
                            "[customer_acct_id], " +
                            "[max_calls]" +
                            ") VALUES (" +
                            _db.CreateSqlParameterName("Node_id") + ", " +
                            _db.CreateSqlParameterName("Customer_acct_id") + ", " +
                            _db.CreateSqlParameterName("Max_calls") + ")";
            IDbCommand cmd = _db.CreateCommand(sqlStr);

            AddParameter(cmd, "Node_id", value.Node_id);
            AddParameter(cmd, "Customer_acct_id", value.Customer_acct_id);
            AddParameter(cmd, "Max_calls", value.Max_calls);
            cmd.ExecuteNonQuery();
        }
        /// <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="LoadBalancingMapRow"/> objects.</returns>
        protected virtual LoadBalancingMapRow[] 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 node_idColumnIndex          = reader.GetOrdinal("node_id");
            int customer_acct_idColumnIndex = reader.GetOrdinal("customer_acct_id");
            int max_callsColumnIndex        = reader.GetOrdinal("max_calls");
            int current_callsColumnIndex    = reader.GetOrdinal("current_calls");

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

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

                    record.Node_id          = Convert.ToInt16(reader.GetValue(node_idColumnIndex));
                    record.Customer_acct_id = Convert.ToInt16(reader.GetValue(customer_acct_idColumnIndex));
                    record.Max_calls        = Convert.ToInt32(reader.GetValue(max_callsColumnIndex));
                    record.Current_calls    = Convert.ToInt32(reader.GetValue(current_callsColumnIndex));

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

            totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1;
            return((LoadBalancingMapRow[])(recordList.ToArray(typeof(LoadBalancingMapRow))));
        }
 /// <summary>
 /// Deletes the specified object from the <c>LoadBalancingMap</c> table.
 /// </summary>
 /// <param name="value">The <see cref="LoadBalancingMapRow"/> object to delete.</param>
 /// <returns>true if the record was deleted; otherwise, false.</returns>
 public bool Delete(LoadBalancingMapRow value)
 {
     return(DeleteByPrimaryKey(value.Node_id, value.Customer_acct_id));
 }
Exemple #9
0
 internal static void Delete(Rbr_Db pDb, LoadBalancingMapRow pLoadBalancingMapRow)
 {
     delete(pDb, pLoadBalancingMapRow);
     //pDb.AddChangedObject(new CustomerAcctKey(TxType.Delete, pLoadBalancingMapRow.Customer_acct_id));
 }
Exemple #10
0
 internal static void Update(Rbr_Db pDb, LoadBalancingMapRow pLoadBalancingMapRow)
 {
     pLoadBalancingMapRow.Current_calls = 0;
     pDb.LoadBalancingMapCollection.Update(pLoadBalancingMapRow);
     //pDb.AddChangedObject(new CustomerAcctKey(TxType.Delete, pLoadBalancingMapRow.Customer_acct_id));
 }
Exemple #11
0
 internal static void Add(Rbr_Db pDb, LoadBalancingMapRow pLoadBalancingMapRow)
 {
     add(pDb, pLoadBalancingMapRow);
 }
Exemple #12
0
 static void delete(Rbr_Db pDb, LoadBalancingMapRow pLoadBalancingMapRow)
 {
     pDb.LoadBalancingMapCollection.Delete(pLoadBalancingMapRow);
 }
Exemple #13
0
 static void add(Rbr_Db pDb, LoadBalancingMapRow pLoadBalancingMapRow)
 {
     pDb.LoadBalancingMapCollection.Insert(pLoadBalancingMapRow);
 }