public static IEnumerable <T> LoadObjectList <T>(Dictionary <string, object> filter = null) where T : TObject { DBTableAttribute dbTableAttribute = (DBTableAttribute)Attribute.GetCustomAttribute(typeof(T), typeof(DBTableAttribute)); TStorage tStorage = new TStorage { Fields = filter, Table = dbTableAttribute.Table }; TrackingServiceClient tsc = new TrackingServiceClient(); IEnumerable <TStorage> tStorageList = tsc.LoadList(tStorage); List <T> result = new List <T>(); foreach (TStorage s in tStorageList) { var ctor = typeof(T).GetConstructor(new Type[] { }); var item = ctor.Invoke(new object[] { }) as T; item.SetKeyValuePairs(s.Fields); item.SetKeyValue(s.Fields[item.GetKeyField()]); result.Add(item); } return(result); }
/// <summary> /// Returns a reference to the <see cref="Tracker"/> class object. /// </summary> /// <param name="solver">The solver to be used by the returned tracker.</param> /// <param name="geocoder">The geocoder to be used by the returned tracker.</param> /// <param name="messageReporter">The messageReporter to be used by the returned /// tracker.</param> /// <returns>A new <see cref="Tracker"/> class instance.</returns> /// <exception cref="ArgumentNullException"><paramref name="solver"/>, /// <paramref name="geocoder"/> or <paramref name="messageReporter"/> is a null /// reference.</exception> public Tracker GetTracker( IVrpSolver solver, IGeocoder geocoder, IMessageReporter messageReporter) { CodeContract.RequiresNotNull("solver", solver); CodeContract.RequiresNotNull("geocoder", geocoder); CodeContract.RequiresNotNull("messageReporter", messageReporter); _CheckSettings(_settings); var settings = new TrackingSettings { BreakTolerance = _settings.TrackingSettings.BreakTolerance ?? 0, }; var uri = new Uri(_settings.TrackingServiceInfo.RestUrl); var service = FeatureService.Create(uri, Server); var trackingServiceClient = new TrackingServiceClient(service); var trackingService = new TrackingServiceClient(service); var synchronizationService = new SynchronizationService(trackingServiceClient); return(new Tracker( settings, trackingService, synchronizationService, solver, geocoder, messageReporter)); }
public TrackingDataSet TrackCartonsForStoreDetail(string clientID, string storeNumber, DateTime from, DateTime to, string by, string tl) { //Get carton details TrackingDataSet cartons = new TrackingDataSet(); TrackingServiceClient client = null; try { client = new TrackingServiceClient(); DataSet ds = null; if (by.ToLower() == "delivery") { ds = client.TrackCartonsForStoreByDeliveryDate(clientID, storeNumber, from, to, null); } else { ds = client.TrackCartonsForStoreByPickupDate(clientID, storeNumber, from, to, null); } client.Close(); //Snag the carton detail TrackingDataSet detail = new TrackingDataSet(); if (ds.Tables["CartonDetailForStoreTable"] != null && ds.Tables["CartonDetailForStoreTable"].Rows.Count > 0) { detail.Merge(ds, true, MissingSchemaAction.Ignore); } //Get all cartons for the specified tl cartons.Merge(detail.CartonDetailForStoreTable.Select("TL='" + tl + "'")); } catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); } catch (FaultException <TrackingFault> tfe) { client.Abort(); throw new ApplicationException(tfe.Detail.Message); } catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); } catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); } return(cartons); }
public static object InsertObject <T>(T obj) where T : TObject { DBTableAttribute dbTableAttribute = (DBTableAttribute)Attribute.GetCustomAttribute(typeof(T), typeof(DBTableAttribute)); TStorage tStorage = new TStorage { Fields = obj.GetKeyValuePairs(), Table = dbTableAttribute.Table, PKField = obj.GetKeyField() }; TrackingServiceClient tsc = new TrackingServiceClient(); return(tsc.Insert(tStorage)); }
public TrackingItems TrackCartons(string[] itemNumbers, string companyID) { //Get invoices for the specified client TrackingItems items = null; TrackingServiceClient _Client = null; try { _Client = new TrackingServiceClient(); items = _Client.TrackCartons(itemNumbers, companyID); _Client.Close(); } catch (FaultException fe) { throw new ApplicationException("TrackCartons() service error.", fe); } catch (TimeoutException te) { _Client.Abort(); throw new ApplicationException("TrackCartons() timeout error.", te); } catch (CommunicationException ce) { _Client.Abort(); throw new ApplicationException("TrackCartons() communication error.", ce); } return(items); }
public TrackingItems TrackItemsByLabelNumber(string[] itemNumbers, string clientNumber, string vendorNumber) { //Track items by Argix label number TrackingItems items = new TrackingItems(); TrackingServiceClient client = null; try { client = new TrackingServiceClient(); items = client.TrackCartonsByLabelNumber(itemNumbers, clientNumber, vendorNumber); } catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); } catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); } catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); } finally { client.Close(); } return(items); }
public TrackingStoreItems TrackCartonsForStoreDetail(string clientID, string storeNumber, DateTime from, DateTime to, string vendorID, string by, string tl) { //Get carton details TrackingStoreItems items = new TrackingStoreItems(); TrackingServiceClient client = null; try { client = new TrackingServiceClient(); items = client.TrackCartonsForStoreDetail(clientID, storeNumber, from, to, vendorID, by, tl); client.Close(); } catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); } catch (FaultException <TrackingFault> tfe) { client.Abort(); throw new ApplicationException(tfe.Detail.Message); } catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); } catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); } return(items); }
public TrackingDataSet GetClients() { //Get a list of clients TrackingDataSet clients = new TrackingDataSet(); TrackingServiceClient client = null; try { client = new TrackingServiceClient(); //If user is: // Vendor: get list of all it's clients // Client: no need to get client's list - fill the drop-down with client's name // Argix: get list of all clients string username = Membership.GetUser().UserName; ProfileBase profile = HttpContext.Current.Profile; if (profile["ClientVendorID"].ToString() == "000" || Roles.IsUserInRole(username, "administrators")) { DataSet ds = client.GetClients(null); if (ds.Tables["ClientTable"] != null && ds.Tables["ClientTable"].Rows.Count > 0) { clients.Merge(ds); } } else { if (profile["Type"].ToString().ToLower() == "vendor") { DataSet ds = client.GetClients(profile["ClientVendorID"].ToString()); if (ds.Tables["ClientTable"] != null && ds.Tables["ClientTable"].Rows.Count > 0) { clients.Merge(ds); } } else { clients.ClientTable.AddClientTableRow(profile["ClientVendorID"].ToString(), "", profile["Company"].ToString(), ""); } } } catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); } catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); } catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); } finally { client.Close(); } return(clients); }
public static T LoadObject <T>(int id) where T : TObject { DBTableAttribute dbTableAttribute = (DBTableAttribute)Attribute.GetCustomAttribute(typeof(T), typeof(DBTableAttribute)); TStorage tStorage = new TStorage { ID = id, Table = dbTableAttribute.Table }; TrackingServiceClient tsc = new TrackingServiceClient(); TStorage tObjStorage = tsc.LoadDetails(tStorage); var ctor = typeof(T).GetConstructor(new Type[] { }); var result = ctor.Invoke(new object[] { }) as T; result.SetKeyValuePairs(tObjStorage.Fields); return(result); }
public static void DeleteObject <T>(T obj) where T : TObject { try { DBTableAttribute dbTableAttribute = (DBTableAttribute)Attribute.GetCustomAttribute(typeof(T), typeof(DBTableAttribute)); TStorage tStorage = new TStorage { ID = Convert.ToInt32(obj.GetKeyValue()), Table = dbTableAttribute.Table, PKField = obj.GetKeyField() }; TrackingServiceClient tsc = new TrackingServiceClient(); tsc.Delete(tStorage); } catch (Exception ex) { } }
public TrackingDataSet TrackCartonsForStoreSummary(string clientID, string storeNumber, DateTime from, DateTime to, string by) { //Get TL summary TrackingDataSet tlSummary = new TrackingDataSet(); TrackingServiceClient client = null; try { client = new TrackingServiceClient(); DataSet ds = null; if (by.ToLower() == "delivery") { ds = client.TrackCartonsForStoreByDeliveryDate(clientID, storeNumber, from, to, null); } else { ds = client.TrackCartonsForStoreByPickupDate(clientID, storeNumber, from, to, null); } client.Close(); //Snag the carton detail TrackingDataSet detail = new TrackingDataSet(); if (ds.Tables["CartonDetailForStoreTable"] != null && ds.Tables["CartonDetailForStoreTable"].Rows.Count > 0) { detail.Merge(ds, true, MissingSchemaAction.Ignore); } //Build a summary by TL; start with a dataset of unique TrackingDataSet tls = new TrackingDataSet(); tls.Merge(detail.CartonDetailForStoreTable.DefaultView.ToTable(true, new string[] { "TL" })); foreach (TrackingDataSet.CartonDetailForStoreTableRow tl in tls.CartonDetailForStoreTable.Rows) { //Get one of the cartons from this TL group TrackingDataSet.CartonDetailForStoreTableRow tlCarton0 = (TrackingDataSet.CartonDetailForStoreTableRow)(detail.CartonDetailForStoreTable.Select("TL='" + tl.TL + "'", "TL ASC"))[0]; tl.Store = tlCarton0.Store; tl.CartonCount = detail.CartonDetailForStoreTable.Select("TL='" + tl.TL + "'").Length; tl.Weight = int.Parse(detail.CartonDetailForStoreTable.Compute("Sum(weight)", "TL='" + tl.TL + "'").ToString()); tl.CBOL = tlCarton0.IsCBOLNull() ? "" : tlCarton0.CBOL; object minDate = detail.CartonDetailForStoreTable.Compute("Min(PodDate)", "TL='" + tl.TL + "' AND (IsNull(PodDate,#01/01/1900#) <> #01/01/1900#)"); if (minDate != System.DBNull.Value) { tl.PodDate = DateTime.Parse(minDate.ToString()); } else { if (!tlCarton0.IsOFD1Null()) { tl.OFD1 = tlCarton0.OFD1; } } tl.AG = !tlCarton0.IsAGNull() ? tlCarton0.AG : ""; tl.AgName = tlCarton0.Trf == "N" ? tlCarton0.AgName : tlCarton0.AgName + " (Transfer)"; tl.AcceptChanges(); } tlSummary.Merge(tls); } catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); } catch (FaultException <TrackingFault> tfe) { client.Abort(); throw new ApplicationException(tfe.Detail.Message); } catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); } catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); } return(tlSummary); }
/// <summary> /// Returns a reference to the <see cref="Tracker"/> class object. /// </summary> /// <param name="solver">The solver to be used by the returned tracker.</param> /// <param name="geocoder">The geocoder to be used by the returned tracker.</param> /// <param name="messageReporter">The messageReporter to be used by the returned /// tracker.</param> /// <returns>A new <see cref="Tracker"/> class instance.</returns> /// <exception cref="ArgumentNullException"><paramref name="solver"/>, /// <paramref name="geocoder"/> or <paramref name="messageReporter"/> is a null /// reference.</exception> public Tracker GetTracker( IVrpSolver solver, IGeocoder geocoder, IMessageReporter messageReporter) { CodeContract.RequiresNotNull("solver", solver); CodeContract.RequiresNotNull("geocoder", geocoder); CodeContract.RequiresNotNull("messageReporter", messageReporter); _CheckSettings(_settings); var settings = new TrackingSettings { BreakTolerance = _settings.TrackingSettings.BreakTolerance ?? 0, }; var uri = new Uri(_settings.TrackingServiceInfo.RestUrl); var service = FeatureService.Create(uri, Server); var trackingServiceClient = new TrackingServiceClient(service); var trackingService = new TrackingServiceClient(service); var synchronizationService = new SynchronizationService(trackingServiceClient); return new Tracker( settings, trackingService, synchronizationService, solver, geocoder, messageReporter); }