protected CountryRecord getCountryRecord(Rbr_Db pDb, RouteRow pBaseRouteRow) { CountryRow _countryRow = pDb.CountryCollection.GetByPrimaryKey(pBaseRouteRow.Country_id); if (_countryRow == null) { throw new Exception(string.Format("Country NOT FOUND CountryId: {0}", pBaseRouteRow.Country_id)); } CountryRecord _countryRecord; if (countries.ContainsKey(_countryRow.Name)) { _countryRecord = countries[_countryRow.Name]; } else { _countryRecord = new CountryRecord(_countryRow.Country_code, _countryRow.Name); countries.Add(_countryRecord.Name, _countryRecord); } if (_countryRecord.Routes.ContainsKey(pBaseRouteRow.Name)) { throw new Exception(string.Format("Unexpected: Route already processed? {0}", pBaseRouteRow.Name)); } return(_countryRecord); }
private void PrintRoute(Application application, ref int currentExcelRow, RouteRow row) { SetCellValue(application.Range[$"A{currentExcelRow}"], row.Route_name); CenteredCellValue(application.Range[$"A{currentExcelRow}"]); SetCellValue(application.Range[$"B{currentExcelRow}"], row.Route_date.ToShortDateString()); CenteredCellValue(application.Range[$"B{currentExcelRow}"]); SetCellValue(application.Range[$"C{currentExcelRow}"], row.FullCar); CenteredCellValue(application.Range[$"C{currentExcelRow}"]); SetCellValue(application.Range[$"D{currentExcelRow}"], row.Car_type_name); CenteredCellValue(application.Range[$"D{currentExcelRow}"]); SetCellValue(application.Range[$"E{currentExcelRow}"], row.Route_distance.ToString()); CenteredCellValue(application.Range[$"E{currentExcelRow}"]); Route_structViewTableAdapter route_StructTA = new Route_structViewTableAdapter(); Route_structViewDataTable routeStructTable = route_StructTA.GetDataByRoute(row.Id_route); foreach (Route_structViewRow structRow in routeStructTable.Rows) { PrintRouteStruct(application, ref currentExcelRow, structRow); } }
//-------------------------------------------- Private ----------------------------------- CustomerRoute getCustomerRoute(short pServiceId, int pBaseRouteId) { CustomerRoute _customerRoute = null; using (Rbr_Db _db = new Rbr_Db()) { RouteRow _routeRow = _db.RouteCollection.GetByPrimaryKey(pBaseRouteId); if (_routeRow != null) { WholesaleRouteRow _wholesaleRouteRow = _db.WholesaleRouteCollection.GetByServiceIdBaseRouteId(pServiceId, pBaseRouteId); if (_wholesaleRouteRow != null) { _customerRoute = new CustomerRoute(_wholesaleRouteRow, _routeRow); } else { T.LogRbr(LogSeverity.Error, "CustomerRouteImdbRepository.getCustomerRoute", string.Format("ServiceRouteRow NOT FOUND: {0}, {1}", pServiceId, pBaseRouteId)); } } else { T.LogRbr(LogSeverity.Error, "CustomerRouteImdbRepository.getCustomerRoute", string.Format("CustomerRouteRow NOT FOUND: {0}, {1}", pServiceId, pBaseRouteId)); } } return(_customerRoute); }
protected RouteRecord getRouteRecord(RouteRow _baseRouteRow, CountryRecord _countryRecord) { var _routeRecord = new RouteRecord(_baseRouteRow.Name); _routeRecord.CountryName = _countryRecord.Name; _routeRecord.CountryCode = _countryRecord.Code; return(_routeRecord); }
internal static void MoveDialCode(Rbr_Db pDb, DialCodeDto pDialCode, RouteRow pToRouteRow) { //NOTE: no more TermChoices deletion on DialCode change/delete, //we will run BG process to show/mark PartialCovarage and NoCovarage TermChoces in the GUI var _dialCodeRow = mapToDialCodeRow(pDialCode); _dialCodeRow.Route_id = pToRouteRow.Route_id; UpdateDialCode(pDb, _dialCodeRow); }
protected Route(RouteRow pRouteRow) { routeRow = pRouteRow; using (var _db = new Rbr_Db()) { var _countryRow = _db.CountryCollection.GetByPrimaryKey(routeRow.Country_id); if (_countryRow == null) { throw new Exception("Route.Ctor | CountryRow NOT FOUND: [routeId: " + routeRow.Route_id + "][countryId: " + routeRow.Country_id + "]"); } countryCode = _countryRow.Country_code; } }
public RouteRow AddRouteRow(string ID, string Team, string Radius, string Actions, string PathActions) { RouteRow rowRouteRow = ((RouteRow)(this.NewRow())); rowRouteRow.ItemArray = new object[] { ID, Team, Radius, Actions, PathActions }; this.Rows.Add(rowRouteRow); return(rowRouteRow); }
//public static void AddDialCodes(DialCodeDto[] pDialCodes) { // using (var _db = new Rbr_Db()) { // using (var _tx = new Transaction(_db, pDialCodes)) { // foreach (DialCodeDto _dialCode in pDialCodes) { // CallingPlanManager.AddDialCode(_db, _dialCode); // } // _tx.Commit(); // } // } //} public static void MoveDialCodes(DialCodeDto[] pDialCodes, BaseRouteDto pFromRoute, BaseRouteDto pToRoute) { using (var _db = new Rbr_Db()) { using (var _tx = new Transaction(_db, pDialCodes, pFromRoute, pToRoute)) { //NOTE: not used? RouteRow _fromRouteRow = RoutingManager.MapToRouteRow(pFromRoute); RouteRow _toRouteRow = RoutingManager.MapToRouteRow(pToRoute); foreach (DialCodeDto _dialCode in pDialCodes) { CallingPlanManager.MoveDialCode(_db, _dialCode, _toRouteRow); } _tx.Commit(); } } }
/// <summary> /// Converts <see cref="System.Data.DataRow"/> to <see cref="RouteRow"/>. /// </summary> /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param> /// <returns>A reference to the <see cref="RouteRow"/> object.</returns> protected virtual RouteRow MapRow(DataRow row) { RouteRow mappedObject = new RouteRow(); DataTable dataTable = row.Table; DataColumn dataColumn; // Column "Route_id" dataColumn = dataTable.Columns["Route_id"]; if (!row.IsNull(dataColumn)) { mappedObject.Route_id = (int)row[dataColumn]; } // Column "Name" dataColumn = dataTable.Columns["Name"]; if (!row.IsNull(dataColumn)) { mappedObject.Name = (string)row[dataColumn]; } // Column "Status" dataColumn = dataTable.Columns["Status"]; if (!row.IsNull(dataColumn)) { mappedObject.Status = (byte)row[dataColumn]; } // Column "Calling_plan_id" dataColumn = dataTable.Columns["Calling_plan_id"]; if (!row.IsNull(dataColumn)) { mappedObject.Calling_plan_id = (int)row[dataColumn]; } // Column "Country_id" dataColumn = dataTable.Columns["Country_id"]; if (!row.IsNull(dataColumn)) { mappedObject.Country_id = (int)row[dataColumn]; } // Column "Routing_number" dataColumn = dataTable.Columns["Routing_number"]; if (!row.IsNull(dataColumn)) { mappedObject.Routing_number = (int)row[dataColumn]; } // Column "Version" dataColumn = dataTable.Columns["Version"]; if (!row.IsNull(dataColumn)) { mappedObject.Version = (int)row[dataColumn]; } return(mappedObject); }
/// <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="RouteRow"/> objects.</returns> protected virtual RouteRow[] 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."); } var route_idColumnIndex = reader.GetOrdinal("route_id"); var nameColumnIndex = reader.GetOrdinal("name"); var statusColumnIndex = reader.GetOrdinal("status"); var calling_plan_idColumnIndex = reader.GetOrdinal("calling_plan_id"); var country_idColumnIndex = reader.GetOrdinal("country_id"); var routing_numberColumnIndex = reader.GetOrdinal("routing_number"); var versionColumnIndex = reader.GetOrdinal("version"); var recordList = new System.Collections.ArrayList(); var ri = -startIndex; while (reader.Read()) { ri++; if (ri > 0 && ri <= length) { var record = new RouteRow(); recordList.Add(record); record.Route_id = Convert.ToInt32(reader.GetValue(route_idColumnIndex)); record.Name = Convert.ToString(reader.GetValue(nameColumnIndex)); record.Status = Convert.ToByte(reader.GetValue(statusColumnIndex)); record.Calling_plan_id = Convert.ToInt32(reader.GetValue(calling_plan_idColumnIndex)); record.Country_id = Convert.ToInt32(reader.GetValue(country_idColumnIndex)); var _routing_number = reader.GetValue(routing_numberColumnIndex).ToString(); record.Routing_number = string.IsNullOrEmpty(_routing_number) ? 0 : Convert.ToInt32(_routing_number); record.Version = Convert.ToInt32(reader.GetValue(versionColumnIndex)); if (ri == length && 0 != totalRecordCount) { break; } } } totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1; return((RouteRow[])(recordList.ToArray(typeof(RouteRow)))); }
CustomerRoute(WholesaleRouteRow pWholesaleRouteRow, int pRoutingPlanId, RouteRow pRouteRow) : base(pRouteRow) { wholesaleRouteRow = pWholesaleRouteRow; routingPlanId = pRoutingPlanId; baseRouteId = pRouteRow.Route_id; using (var _db = new Rbr_Db()) { var _serviceRow = _db.ServiceCollection.GetByPrimaryKey(wholesaleRouteRow.Service_id); if (_serviceRow == null) { throw new Exception(string.Format("CustomerRoute.Ctor | ServiceRow NOT FOUND, Service_id:{0}", wholesaleRouteRow.Service_id)); } ratingType = _serviceRow.RatingType; } }
//static RouteRow[] mapToRouteRows(BaseRouteDto[] pBaseRoutes) { // ArrayList _list = new ArrayList(); // if (pBaseRoutes != null) { // foreach (BaseRouteDto _route in pBaseRoutes) { // RouteRow _routeRow = MapToRouteRow(_route); // _list.Add(_routeRow); // } // } // return (RouteRow[])_list.ToArray(typeof(RouteRow)); //} internal static RouteRow MapToRouteRow(BaseRouteDto pBaseRoute) { if (pBaseRoute == null) { return(null); } var _routeRow = new RouteRow(); _routeRow.Route_id = pBaseRoute.BaseRouteId; _routeRow.Name = pBaseRoute.Name; _routeRow.RouteStatus = pBaseRoute.BaseStatus; _routeRow.Calling_plan_id = pBaseRoute.CallingPlanId; _routeRow.Country_id = pBaseRoute.CountryId; _routeRow.Routing_number = pBaseRoute.RoutingNumber; _routeRow.Version = pBaseRoute.Version; return(_routeRow); }
static BaseRouteDto mapToBaseRoute(RouteRow pRouteRow, CountryDto pCountry, CallingPlanDto pCallingPlan, RouteState pRouteState) { if (pRouteRow == null) { return(null); } var _baseRoute = new BaseRouteDto(); _baseRoute.BaseRouteId = pRouteRow.Route_id; _baseRoute.Name = pRouteRow.Name; _baseRoute.BaseStatus = pRouteRow.RouteStatus; _baseRoute.CallingPlan = pCallingPlan; _baseRoute.Country = pCountry; _baseRoute.RoutingNumber = pRouteRow.Routing_number; _baseRoute.Version = pRouteRow.Version; _baseRoute.RouteState = pRouteState; return(_baseRoute); }
protected int getRouteId(Rbr_Db pDb, int pCountryId, RouteRecord pRouteRecord) { RouteRow _routeRow = RoutingManager.GetByName(pDb, args.CallingPlanId, pRouteRecord.FullName); if (_routeRow == null) { _routeRow = new RouteRow(); _routeRow.Name = pRouteRecord.FullName; _routeRow.Country_id = pCountryId; _routeRow.Calling_plan_id = args.CallingPlanId; _routeRow.RouteStatus = Status.Active; RoutingManager.AddBaseRoute(pDb, RoutingManager.MapToBaseRoute(pDb, _routeRow)); } else { // Existing RouteRow: delete all dialcodes pDb.DialCodeCollection.DeleteByRoute_id(_routeRow.Route_id); } return(_routeRow.Route_id); }
//internal static BaseRouteDto[] MapToBaseRoutes(Rbr_Db pDb, RouteRow[] pRouteRows, CountryRow[] pCountryRows, CallingPlanRow pCallingPlanRow) { // ArrayList _list = new ArrayList(); // if (pRouteRows != null) { // foreach (RouteRow _routeRow in pRouteRows) { // CountryRow _countryRow = getCountry(_routeRow.Country_id, pCountryRows); // int _dialCodeCount = pDb.DialCodeCollection.GetCount( /*_routeRow.Calling_plan_id,*/ _routeRow.Route_id); // RouteState _routeState = ( _dialCodeCount > 0 ) ? RouteState.Valid : RouteState.NoDialCodes; // BaseRouteDto _baseRoute = MapToBaseRoute(_routeRow, _countryRow, pCallingPlanRow, _routeState); // _list.Add(_baseRoute); // } // } // return (BaseRouteDto[])_list.ToArray(typeof(BaseRouteDto)); //} public static BaseRouteDto MapToBaseRoute(Rbr_Db pDb, RouteRow pRouteRow) //}, CountryRow pCountryRow, CallingPlanRow pCallingPlanRow, RouteState pRouteState) { { if (pRouteRow == null) { return(null); } var _baseRoute = new BaseRouteDto(); _baseRoute.BaseRouteId = pRouteRow.Route_id; _baseRoute.Name = pRouteRow.Name; _baseRoute.BaseStatus = pRouteRow.RouteStatus; _baseRoute.CallingPlan = CallingPlanManager.GetCallingPlan(pDb, pRouteRow.Calling_plan_id); _baseRoute.Country = CallingPlanManager.GetCountry(pDb, pRouteRow.Country_id); _baseRoute.RoutingNumber = pRouteRow.Routing_number; _baseRoute.Version = pRouteRow.Version; _baseRoute.RouteState = RouteState.Valid; return(_baseRoute); }
/// <summary> /// Updates a record in the <c>Route</c> table. /// </summary> /// <param name="value">The <see cref="RouteRow"/> /// object used to update the table record.</param> /// <returns>true if the record was updated; otherwise, false.</returns> public virtual bool Update(RouteRow value) { var _sqlStr = "UPDATE [dbo].[Route] SET " + "[name]=" + _db.CreateSqlParameterName("Name") + ", " + "[status]=" + _db.CreateSqlParameterName("Status") + ", " + "[calling_plan_id]=" + _db.CreateSqlParameterName("Calling_plan_id") + ", " + "[country_id]=" + _db.CreateSqlParameterName("Country_id") + ", " + "[routing_number]=" + _db.CreateSqlParameterName("Routing_number") + " WHERE " + "[route_id]=" + _db.CreateSqlParameterName("Route_id"); var cmd = _db.CreateCommand(_sqlStr); AddParameter(cmd, "Name", value.Name); AddParameter(cmd, "Status", value.Status); AddParameter(cmd, "Calling_plan_id", value.Calling_plan_id); AddParameter(cmd, "Country_id", value.Country_id); AddParameter(cmd, "Routing_number", value.Routing_number); AddParameter(cmd, "Route_id", value.Route_id); return(0 != cmd.ExecuteNonQuery()); }
public TableAdjustment EditRoute(LatticeData <Route, RouteRow> latticeData, RouteRow routeRow) { Route route; if (routeRow.RouteId == 0) { route = new Route(); _context.Routes.Add(route); } else { route = _context.Routes .FirstOrDefault(x => x.RouteId == routeRow.RouteId); } route.RouteName = routeRow.RouteName; _context.SaveChanges(); routeRow.RouteId = route.RouteId; return(latticeData.Adjust(x => x .Update(routeRow) .Message(LatticeMessage.User("success", "Editing", "Route saved")) )); }
/// <summary> /// Adds a new record into the <c>Route</c> table. /// </summary> /// <param name="value">The <see cref="RouteRow"/> object to be inserted.</param> public virtual void Insert(RouteRow value) { var sqlStr = "INSERT INTO [dbo].[Route] (" + "[name], " + "[status], " + "[calling_plan_id], " + "[country_id]" + "[routing_number]" + ") VALUES (" + _db.CreateSqlParameterName("Name") + ", " + _db.CreateSqlParameterName("Status") + ", " + _db.CreateSqlParameterName("Calling_plan_id") + ", " + _db.CreateSqlParameterName("Country_id") + ")" + ", " + _db.CreateSqlParameterName("Routing_number_id"); IDbCommand cmd = _db.CreateCommand(sqlStr); AddParameter(cmd, "Name", value.Name); AddParameter(cmd, "Status", value.Status); AddParameter(cmd, "Calling_plan_id", value.Calling_plan_id); AddParameter(cmd, "Country_id", value.Country_id); AddParameter(cmd, "Routing_number", value.Routing_number); cmd.ExecuteNonQuery(); }
/// <summary> /// Deletes the specified object from the <c>Route</c> table. /// </summary> /// <param name="value">The <see cref="RouteRow"/> object to delete.</param> /// <returns>true if the record was deleted; otherwise, false.</returns> public bool Delete(RouteRow value) { return(DeleteByPrimaryKey(value.Route_id)); }
public RouteRowChangeEvent(RouteRow row, DataRowAction action) { this.eventRow = row; this.eventAction = action; }
public void RemoveRouteRow(RouteRow row) { this.Rows.Remove(row); }
public void AddRouteRow(RouteRow row) { this.Rows.Add(row); }