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

            // Column "Routing_plan_id"
            dataColumn = dataTable.Columns["Routing_plan_id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Routing_plan_id = (int)row[dataColumn];
            }
            // Column "Route_id"
            dataColumn = dataTable.Columns["Route_id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Route_id = (int)row[dataColumn];
            }
            // Column "Routing_algorithm"
            dataColumn = dataTable.Columns["Routing_algorithm"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Routing_algorithm = (byte)row[dataColumn];
            }
            return(mappedObject);
        }
示例#2
0
 internal static void AddRoutingPlanDetails(Rbr_Db pDb, RoutingPlanDto pRoutingPlan, int[] pSelectedBaseRouteIds, RoutingAlgorithmType pDefaultRoutingAlgorithmType)
 {
     if (pRoutingPlan != null && pSelectedBaseRouteIds != null && pSelectedBaseRouteIds.Length > 0)
     {
         foreach (var _baseRouteId in pSelectedBaseRouteIds)
         {
             var _routingPlanDetailRow = new RoutingPlanDetailRow();
             _routingPlanDetailRow.Routing_plan_id = pRoutingPlan.RoutingPlanId;
             _routingPlanDetailRow.Route_id        = _baseRouteId;
             _routingPlanDetailRow.Algorithm       = pDefaultRoutingAlgorithmType;
             AddRoutingPlanDetailRow(pDb, _routingPlanDetailRow);
         }
     }
 }
示例#3
0
        /// <summary>
        /// Updates a record in the <c>RoutingPlanDetail</c> table.
        /// </summary>
        /// <param name="value">The <see cref="RoutingPlanDetailRow"/>
        /// object used to update the table record.</param>
        /// <returns>true if the record was updated; otherwise, false.</returns>
        public virtual bool Update(RoutingPlanDetailRow value)
        {
            string sqlStr = "UPDATE [dbo].[RoutingPlanDetail] SET " +
                            "[routing_algorithm]=" + _db.CreateSqlParameterName("Routing_algorithm") +
                            " WHERE " +
                            "[routing_plan_id]=" + _db.CreateSqlParameterName("Routing_plan_id") + " AND " +
                            "[route_id]=" + _db.CreateSqlParameterName("Route_id");
            IDbCommand cmd = _db.CreateCommand(sqlStr);

            AddParameter(cmd, "Routing_algorithm", value.Routing_algorithm);
            AddParameter(cmd, "Routing_plan_id", value.Routing_plan_id);
            AddParameter(cmd, "Route_id", value.Route_id);
            return(0 != cmd.ExecuteNonQuery());
        }
示例#4
0
        static RoutingPlanDetailRow mapToRoutingPlanDetailRow(RoutingPlanDetailDto pRoutingPlanDetail)
        {
            if (pRoutingPlanDetail == null)
            {
                return(null);
            }

            var _routingPlanDetailRow = new RoutingPlanDetailRow();

            _routingPlanDetailRow.Routing_plan_id = pRoutingPlanDetail.RoutingPlanId;
            _routingPlanDetailRow.Route_id        = pRoutingPlanDetail.BaseRouteId;
            _routingPlanDetailRow.Algorithm       = pRoutingPlanDetail.Algorithm;

            return(_routingPlanDetailRow);
        }
示例#5
0
        /// <summary>
        /// Adds a new record into the <c>RoutingPlanDetail</c> table.
        /// </summary>
        /// <param name="value">The <see cref="RoutingPlanDetailRow"/> object to be inserted.</param>
        public virtual void Insert(RoutingPlanDetailRow value)
        {
            string sqlStr = "INSERT INTO [dbo].[RoutingPlanDetail] (" +
                            "[routing_plan_id], " +
                            "[route_id], " +
                            "[routing_algorithm]" +
                            ") VALUES (" +
                            _db.CreateSqlParameterName("Routing_plan_id") + ", " +
                            _db.CreateSqlParameterName("Route_id") + ", " +
                            _db.CreateSqlParameterName("Routing_algorithm") + ")";
            IDbCommand cmd = _db.CreateCommand(sqlStr);

            AddParameter(cmd, "Routing_plan_id", value.Routing_plan_id);
            AddParameter(cmd, "Route_id", value.Route_id);
            AddParameter(cmd, "Routing_algorithm", value.Routing_algorithm);
            cmd.ExecuteNonQuery();
        }
示例#6
0
        static RoutingPlanDetailDto mapToRoutingPlanDetail(RoutingPlanDetailRow pRoutingPlanDetailRow, BaseRouteDto pBaseRoute, RoutingPlanDto pRoutingPlan, RouteState pRoutingPlanDetailRouteState)
        {
            if (pRoutingPlanDetailRow == null)
            {
                return(null);
            }

            var _routingPlanDetail = new RoutingPlanDetailDto();

            _routingPlanDetail.RoutingPlan = pRoutingPlan;
            _routingPlanDetail.BaseRoute   = pBaseRoute;
            _routingPlanDetail.Algorithm   = pRoutingPlanDetailRow.Algorithm;

            _routingPlanDetail.RouteState = pRoutingPlanDetailRouteState;

            return(_routingPlanDetail);
        }
示例#7
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="RoutingPlanDetailRow"/> objects.</returns>
        protected virtual RoutingPlanDetailRow[] 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 routing_plan_idColumnIndex   = reader.GetOrdinal("routing_plan_id");
            int route_idColumnIndex          = reader.GetOrdinal("route_id");
            int routing_algorithmColumnIndex = reader.GetOrdinal("routing_algorithm");

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

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

                    record.Routing_plan_id   = Convert.ToInt32(reader.GetValue(routing_plan_idColumnIndex));
                    record.Route_id          = Convert.ToInt32(reader.GetValue(route_idColumnIndex));
                    record.Routing_algorithm = Convert.ToByte(reader.GetValue(routing_algorithmColumnIndex));

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

            totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1;
            return((RoutingPlanDetailRow[])(recordList.ToArray(typeof(RoutingPlanDetailRow))));
        }
示例#8
0
        public static void CloneRoutingPlanDetails(Rbr_Db pDb, RoutingPlanDto pNewRoutingPlan, RoutingPlanDto pRoutingPlanToClone)
        {
            //1. get Details for existing RoutingPlan
            var _existingRoutingPlanDetailRows = pDb.RoutingPlanDetailCollection.GetByRouting_plan_id(pRoutingPlanToClone.RoutingPlanId);

            foreach (var _existingRoutingPlanDetailRow in _existingRoutingPlanDetailRows)
            {
                //1.1 clone/insert RoutingPlanDetail for a new RoutingPlan
                var _newRoutingPlanDetail = new RoutingPlanDetailRow();
                _newRoutingPlanDetail.Routing_plan_id   = pNewRoutingPlan.RoutingPlanId;
                _newRoutingPlanDetail.Route_id          = _existingRoutingPlanDetailRow.Route_id;
                _newRoutingPlanDetail.Routing_algorithm = _existingRoutingPlanDetailRow.Routing_algorithm;
                pDb.RoutingPlanDetailCollection.Insert(_newRoutingPlanDetail);

                //1.2 get TermChoices for existing RoutingPlanDetail
                var _existingTermChoiceRows = pDb.TerminationChoiceCollection.GetByRoutingPlanIdRouteId_OrderByPriority(_existingRoutingPlanDetailRow.Routing_plan_id, _existingRoutingPlanDetailRow.Route_id);
                foreach (var _existingTermChoiceRow in _existingTermChoiceRows)
                {
                    //1.2.1 clone/insert TermChoice for a new RoutingPlan
                    var _newTermChoiceRow = new TerminationChoiceRow();
                    _newTermChoiceRow.Routing_plan_id  = _newRoutingPlanDetail.Routing_plan_id;
                    _newTermChoiceRow.Route_id         = _newRoutingPlanDetail.Route_id;
                    _newTermChoiceRow.Priority         = _existingTermChoiceRow.Priority;
                    _newTermChoiceRow.Carrier_route_id = _existingTermChoiceRow.Carrier_route_id;
                    pDb.TerminationChoiceCollection.Insert(_newTermChoiceRow);
                }

                ////1.3 get LCRBlackList for existing RoutingPlanDetail
                //LCRBlackListRow[] _existingLCRBlackListRows = pDb.LCRBlackListCollection.GetByRouting_plan_id_Route_id(_existingRoutingPlanDetailRow.Routing_plan_id, _existingRoutingPlanDetailRow.Route_id);
                //foreach (LCRBlackListRow _existingLCRBlackListRow in _existingLCRBlackListRows) {
                //  //1.3.1 clone/insert LCRBlackList for a new RoutingPlan
                //  LCRBlackListRow _newLCRBlackListRow = new LCRBlackListRow();
                //  _newLCRBlackListRow.Routing_plan_id = _newRoutingPlanDetail.Routing_plan_id;
                //  _newLCRBlackListRow.Route_id = _newRoutingPlanDetail.Route_id;
                //  _newLCRBlackListRow.Carrier_acct_id = _existingLCRBlackListRow.Carrier_acct_id;
                //  pDb.LCRBlackListCollection.Insert(_newLCRBlackListRow);
                //}
            }
        }
示例#9
0
        void exportDialPlan()
        {
            countries = new SortedList <string, CountryRecord>();

            using (var _db = new Rbr_Db()) {
                RouteRow[] _baseRouteRows = getBaseRouteRows(_db);
                if (_baseRouteRows == null || _baseRouteRows.Length <= 0)
                {
                    reportStatus(LogSeverity.Status, "DialPlanExporter.exportDialPlan", "No Routes to Process...");
                    return;
                }

                _baseRouteRows = RoutingManager.SortRouteRows(_baseRouteRows);

                string _filePath = getFilePath();

                using (var _swDialPlan = new StreamWriter(_filePath, false)) {
                    int           _index         = 0;
                    CountryRecord _countryRecord = null;
                    foreach (RouteRow _baseRouteRow in _baseRouteRows)
                    {
                        host.ReportProgress(_index++ *100 / _baseRouteRows.Length);

                        if (args.RoutingPlanId > 0)
                        {
                            RoutingPlanDetailRow _routingPlanDetailRow = _db.RoutingPlanDetailCollection.GetByPrimaryKey(args.RoutingPlanId, _baseRouteRow.Route_id);
                            if (_routingPlanDetailRow == null)
                            {
                                continue;                                 //NOTE: skip this route
                            }
                        }

                        if (_countryRecord == null || _countryRecord.Name != _baseRouteRow.Name)
                        {
                            _countryRecord = getCountryRecord(_db, _baseRouteRow);
                        }

                        if (_countryRecord.Routes.ContainsKey(_baseRouteRow.Name))
                        {
                            throw new Exception(string.Format("Unexpected: Route already processed? {0}", _baseRouteRow.Name));
                        }

                        RouteRecord _routeRecord = getRouteRecord(_baseRouteRow, _countryRecord);
                        _countryRecord.Routes.Add(_routeRecord.FullName, _routeRecord);

                        reportStatus(LogSeverity.Status, "DialPlanExporter.exportDialPlanToFile", string.Format("Exporting DialCodes for Route: {0}", _routeRecord.FullName));

                        DialCodeRow[] _dialCodeRows = _db.DialCodeCollection.GetByRoute_id(_baseRouteRow.Route_id);
                        if (_dialCodeRows != null && _dialCodeRows.Length > 0)
                        {
                            var _dialCodesAsStringArray = new string[_dialCodeRows.Length];
                            for (int _i = 0; _i < _dialCodeRows.Length; _i++)
                            {
                                _dialCodesAsStringArray[_i] = _dialCodeRows[_i].Dial_code.ToString();
                            }
                            _routeRecord.AddDialCodes(_dialCodesAsStringArray);
                        }
                        _swDialPlan.Write(_routeRecord.DialCodesAsString);
                    }
                }
            }
        }
示例#10
0
 /// <summary>
 /// Deletes the specified object from the <c>RoutingPlanDetail</c> table.
 /// </summary>
 /// <param name="value">The <see cref="RoutingPlanDetailRow"/> object to delete.</param>
 /// <returns>true if the record was deleted; otherwise, false.</returns>
 public bool Delete(RoutingPlanDetailRow value)
 {
     return(DeleteByPrimaryKey(value.Routing_plan_id, value.Route_id));
 }
示例#11
0
 internal static void AddRoutingPlanDetailRow(Rbr_Db pDb, RoutingPlanDetailRow pRoutingPlanDetailRow)
 {
     pDb.RoutingPlanDetailCollection.Insert(pRoutingPlanDetailRow);
 }