public static DriverCompDataset GetRateTypes() { // DriverCompDataset types = null; DriverCompServiceClient client = null; try { ObjectCache cache = MemoryCache.Default; types = cache["rateTypes"] as DriverCompDataset; if (types == null) { types = new DriverCompDataset(); client = new DriverCompServiceClient(); DataSet ds = client.GetRateTypes(); client.Close(); if (ds.Tables["RateTypeTable"] != null && ds.Tables["RateTypeTable"].Rows.Count > 0) { types.Merge(ds); } DateTimeOffset policy = new DateTimeOffset(DateTime.Now.AddMinutes(_cacheTimeout)); cache.Set("rateTypes", types, policy); } } catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); } catch (FaultException <DriverCompensationFault> cfe) { client.Abort(); throw new ApplicationException(cfe.Detail.Message); } catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); } catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); } return(types); }
public static DriverCompDataset ReadDriverRoutes(string agentNumber, DateTime startDate, DateTime endDate) { // DriverCompDataset routes = new DriverCompDataset(); DriverCompServiceClient client = null; try { client = new DriverCompServiceClient(); DataSet ds = client.ReadDriverRoutes(agentNumber, startDate, endDate); if (ds.Tables["DriverRouteTable"] != null && ds.Tables["DriverRouteTable"].Rows.Count > 0) { routes.Merge(ds); for (int i = 0; i < routes.DriverRouteTable.Rows.Count; i++) { //Set local fields (i.e. not persisted) DriverCompDataset.DriverRouteTableRow route = (DriverCompDataset.DriverRouteTableRow)routes.DriverRouteTable.Rows[i]; route.IsNew = false; route.IsCombo = (routes.DriverRouteTable.Select("Operator='" + route.Operator + "' AND RouteDate='" + route.RouteDate + "'").Length > 1); route.IsAdjust = route.RouteName.Contains("ADJUST"); } routes.AcceptChanges(); } client.Close(); } catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); } catch (FaultException <DriverCompensationFault> cfe) { client.Abort(); throw new ApplicationException(cfe.Detail.Message); } catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); } catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); } return(routes); }
public static DriverCompDataset GetUnitRouteRates(DateTime date, string terminalAgent, string route) { //Return applicable route-based unit rates (i.e. multi-trip, carton, pallet) for the specified date DriverCompDataset rates = new DriverCompDataset(); try { DataSet ds = Mediator.FillDataset(USP_RATEUNITROUTE, TBL_RATEUNITROUTE, new object[] { date, terminalAgent, route }); if (ds.Tables[TBL_RATEUNITROUTE].Rows.Count > 0) { rates.Merge(ds); } } catch (ApplicationException ex) { throw ex; } catch (Exception ex) { throw new DriverRateException("Unexpected error while reading rates.", ex); } return(rates); }
public static DriverCompDataset GetMileageRates(DateTime date, string terminalAgent, int equipmentTypeID) { //Return applicable mileage rates for the specified date DriverCompDataset rates = new DriverCompDataset(); try { object id = null; if (equipmentTypeID > -1) { id = equipmentTypeID; } DataSet ds = Mediator.FillDataset(USP_RATEMILEAGE, TBL_RATEMILEAGE, new object[] { date, terminalAgent, id }); if (ds.Tables[TBL_RATEMILEAGE].Rows.Count > 0) { rates.Merge(ds); } } catch (ApplicationException ex) { throw ex; } catch (Exception ex) { throw new DriverRateException("Unexpected error while reading rates.", ex); } return(rates); }
public static DriverCompDataset ImportRoutes(string agentNumber, DateTime startDate, DateTime endDate) { // DriverCompDataset routes = new DriverCompDataset(); DriverCompServiceClient client = null; try { client = new DriverCompServiceClient(); DataSet ds = client.ReadRoadshowRoutes(agentNumber, startDate, endDate); if (ds.Tables["RoadshowRouteTable"] != null && ds.Tables["RoadshowRouteTable"].Rows.Count > 0) { routes.Merge(ds); } client.Close(); } catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); } catch (FaultException <DriverCompensationFault> cfe) { client.Abort(); throw new ApplicationException(cfe.Detail.Message); } catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); } catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); } return(routes); }
public static DataSet ReadRouteUnitRates(DateTime effectiveDate, string terminalAgent, string route) { // DriverCompDataset rates = new DriverCompDataset(); DriverCompServiceClient client = null; try { client = new DriverCompServiceClient(); DataSet ds = client.ReadRouteUnitRates(effectiveDate, terminalAgent, route); client.Close(); if (ds.Tables["RateUnitRouteTable"] != null && ds.Tables["RateUnitRouteTable"].Rows.Count > 0) { rates.Merge(ds); } } catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); } catch (FaultException <DriverCompensationFault> cfe) { client.Abort(); throw new ApplicationException(cfe.Detail.Message); } catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); } catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); } return(rates); }
public static DriverCompDataset ReadDriverEquipment() { // DriverCompDataset equipment = new DriverCompDataset(); DriverCompServiceClient client = null; try { client = new DriverCompServiceClient(); DataSet ds = client.ReadDriverEquipment(null, null); client.Close(); if (ds.Tables["DriverEquipmentTable"] != null && ds.Tables["DriverEquipmentTable"].Rows.Count > 0) { equipment.Merge(ds); } } catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); } catch (FaultException <DriverCompensationFault> cfe) { client.Abort(); throw new ApplicationException(cfe.Detail.Message); } catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); } catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); } return(equipment); }