Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }