Exemplo n.º 1
0
    private void track(string[] numbers)
    {
        //Track one or more cartons
        try {
            //Reset session state
            Session["TrackData"] = null;

            //Validate carton numbers
            for (int i = 0; i < numbers.Length; i++)
            {
                numbers[i] = numbers[i].Replace("\n", "");
                numbers[i] = numbers[i].Replace("-", "");
            }

            //Get tracking details for all cartons and retain in Session state
            TrackingDataset trackDS = new TrackingDataset();
            trackDS.Merge(new EnterpriseGateway().TrackCartons(numbers, null, null));
            Session["TrackData"] = trackDS;

            //Redirect to appropriate UI
            if (trackDS.TrackingSummaryTable.Rows.Count == 0)
            {
                reportError(new ApplicationException("Carton not found."));
            }
            else if (trackDS.TrackingSummaryTable.Rows.Count == 1)
            {
                Response.Redirect("~/Detail.aspx?ID=" + trackDS.TrackingSummaryTable[0].ItemNumber.Trim(), false);
            }
            else
            {
                Response.Redirect("~/Summary.aspx", false);
            }
        }
        catch (Exception ex) { reportError(ex); }
    }
Exemplo n.º 2
0
        public TrackingDataset TrackCartonsForStoreDetail(string clientID, string storeNumber, DateTime from, DateTime to, string tl, string by)
        {
            //Get carton details
            TrackingDataset  cartons = new TrackingDataset();
            CRMServiceClient client  = null;

            try {
                client = new CRMServiceClient();
                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);
        }
Exemplo n.º 3
0
        public TrackingStoreItems TrackCartonsForStoreSummary(string clientNumber, string storeNumber, DateTime fromDate, DateTime toDate, string vendorNumber, string by)
        {
            //
            TrackingStoreItems items = new TrackingStoreItems();

            try {
                TrackingDataset cartons = new TrackingDataset();
                DataSet         ds      = null;
                if (by.ToLower() == "pickup")
                {
                    ds = new EnterpriseRGateway().GetCartonsForStoreByPickupDate2(clientNumber, storeNumber, fromDate, toDate, vendorNumber);
                }
                else
                {
                    ds = new EnterpriseRGateway().GetCartonsForStoreByDeliveryDate2(clientNumber, storeNumber, fromDate, toDate, vendorNumber);
                }
                if (ds.Tables["CartonDetailForStoreTable"] != null && ds.Tables["CartonDetailForStoreTable"].Rows.Count > 0)
                {
                    cartons.Merge(ds, true, MissingSchemaAction.Ignore);
                }

                //Build a summary by TL; start with a dataset of unique
                TrackingDataset tls = new TrackingDataset();
                tls.Merge(cartons.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)(cartons.CartonDetailForStoreTable.Select("TL='" + tl.TL + "'", "TL ASC"))[0];

                    tl.S           = tlCarton0.S;
                    tl.CartonCount = cartons.CartonDetailForStoreTable.Select("TL='" + tl.TL + "'").Length;
                    tl.Wt          = int.Parse(cartons.CartonDetailForStoreTable.Compute("Sum(Wt)", "TL='" + tl.TL + "'").ToString());
                    tl.CBOL        = tlCarton0.IsCBOLNull() ? "" : tlCarton0.CBOL;
                    object minDate = cartons.CartonDetailForStoreTable.Compute("Min(ScD)", "TL='" + tl.TL + "' AND (IsNull(ScD,#01/01/1900#) <> #01/01/1900#)");
                    if (minDate != System.DBNull.Value)
                    {
                        tl.ScD = minDate.ToString();
                        object minTime = cartons.CartonDetailForStoreTable.Compute("Min(ScTm)", "TL='" + tl.TL + "' AND ScD='" + minDate + "'");
                        tl.ScTm = minTime.ToString();
                    }
                    tl.ActSDD = !tlCarton0.IsActSDDNull() ? tlCarton0.ActSDD : "01/01/0001";
                    tl.OFD1   = !tlCarton0.IsOFD1Null() ? tlCarton0.OFD1 : DateTime.MinValue;
                    tl.Ag     = !tlCarton0.IsAgNull() ? tlCarton0.Ag : "";
                    tl.AgNm   = tlCarton0.AgNm;
                    tl.AcceptChanges();

                    TrackingStoreItem item = new TrackingStoreItem(tl);
                    items.Add(item);
                }
            }
            catch (Exception ex) { throw new FaultException <TrackingFault>(new TrackingFault(ex.Message), "Service Error"); }
            return(items);
        }
Exemplo n.º 4
0
        public TrackingItems TrackCartonsByCartonNumber(string[] itemNumbers, string clientNumber, string vendorNumber)
        {
            //
            TrackingItems items = new TrackingItems();

            try {
                string numbers = "";
                for (int i = 0; i < itemNumbers.Length; i++)
                {
                    if (i > 0)
                    {
                        numbers += ",";
                    }
                    numbers += itemNumbers[i];
                }
                TrackingDataset cartons = new TrackingDataset();
                cartons.Merge(new EnterpriseRGateway().GetCartonsByCartonNumber(numbers, clientNumber, vendorNumber));

                //Return records for all found items
                foreach (TrackingDataset.TrackingTableRow carton in cartons.TrackingTable.Rows)
                {
                    //Keep the response item if it matches a requested item (use CTN number)
                    for (int i = 0; i < itemNumbers.Length; i++)
                    {
                        if (carton.CTN.Trim() == itemNumbers[i])
                        {
                            //Keep it
                            TrackingItem item = new TrackingItem(itemNumbers[i], carton);
                            items.Add(item);
                            itemNumbers[i] = "";    //Mark as found by nulling it
                            break;
                        }
                    }
                }

                //Return a record for all unfound requests
                for (int i = 0; i < itemNumbers.Length; i++)
                {
                    if (itemNumbers[i].Length > 0)
                    {
                        items.Add(new TrackingItem(itemNumbers[i]));
                    }
                }
            }
            catch (Exception ex) { throw new FaultException <TrackingFault>(new TrackingFault(ex.Message), "Service Error"); }
            return(items);
        }
Exemplo n.º 5
0
    public TrackingDataset TrackCartons(string[] itemNumbers, string clientNumber, string vendorNumber)
    {
        //Track items by customer carton number
        TrackingDataset items = new TrackingDataset();
        ConsumerTrackingServiceClient client = null;

        try {
            client = new ConsumerTrackingServiceClient();
            items.Merge(client.TrackCartons(itemNumbers, clientNumber, vendorNumber));
        }
        catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
        catch (FaultException <TrackingFault> tf) { client.Abort(); throw new ApplicationException(tf.Detail.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);
    }
Exemplo n.º 6
0
    //Interface
    protected void Page_Load(object sender, EventArgs e)
    {
        //Event handler for page load event

        //Validate
        TrackingDataset ds = (TrackingDataset)Session["TrackData"];

        //if(ds == null)

        //Set UI; hide links as required
        this.btnImgTrackNew.Visible = this.btnTrackNew.Visible = true;

        //Display summary
        this.grdTrack.DataMember = "TrackingSummaryTable";
        this.grdTrack.DataSource = ds;
        this.grdTrack.DataBind();
        this.lblSumFootnote.Text += "  " + System.DateTime.Now;
    }
Exemplo n.º 7
0
    //Interface
    protected void Page_Load(object sender, EventArgs e)
    {
        //Event handler for page load event
        //Validate
        string          itemNumber = Request.QueryString["ID"];
        TrackingDataset ds         = (TrackingDataset)Session["TrackData"];

        //Set UI; hide links as required
        bool fromDefault = (bool)Session["FromDefault"];

        this.btnGoSummary.Visible = this.btnImgGoSummary.Visible = (ds.TrackingSummaryTable.Rows.Count > 1);
        this.btnTrackNew.Visible  = this.btnImgTrackNew.Visible = (fromDefault || ds.TrackingSummaryTable.Rows.Count > 1);

        //Display detail
        this.grdDetail.DataMember = "TrackingDetailTable";
        this.grdDetail.DataSource = ds.TrackingDetailTable.Select("ItemNumber='" + itemNumber + "'", "Date DESC, Time DESC");
        this.grdDetail.DataBind();

        //Display summary
        TrackingDataset.TrackingSummaryTableRow[] summaryInfo = (TrackingDataset.TrackingSummaryTableRow[])ds.TrackingSummaryTable.Select("ItemNumber='" + itemNumber + "'");
        if (summaryInfo[0].IsShipperNameNull() || summaryInfo[0].ShipperName == "N/A")
        {
            this.detailPanel.Visible = false;
        }
        this.lblDetail_ID.Text    += itemNumber;
        this.lblDetail_Status.Text = summaryInfo[0].Status.ToString();
        this.lblDetailSum.Text     = "in " + summaryInfo[0].ConsigneeCity.ToString() + ", " + summaryInfo[0].ConsigneeState.ToString() + " on " + summaryInfo[0].Date.ToString("MM-dd-yyyy") + " at " + summaryInfo[0].Time.ToString("hh:mm tt");
        this.lblFromInfo.Text      = summaryInfo[0].ShipperName.ToString();
        this.lblFromInfo.Text     += "\n" + summaryInfo[0].ShipperCity.ToString();
        this.lblFromInfo.Text     += ", " + summaryInfo[0].ShipperState.ToString();
        this.lblFromInfo.Text     += " " + summaryInfo[0].ShipperZip.ToString();
        this.lblFromInfo.Text     += "\n" + summaryInfo[0].ShipperCountry.ToString();
        this.lblToInfo.Text        = summaryInfo[0].ConsigneeName.ToString();
        this.lblToInfo.Text       += "\n" + summaryInfo[0].ConsigneeCity.ToString();
        this.lblToInfo.Text       += ", " + summaryInfo[0].ConsigneeState.ToString();
        this.lblToInfo.Text       += " " + summaryInfo[0].ConsigneeZip.ToString();
        this.lblToInfo.Text       += "\n" + summaryInfo[0].ConsigneeCountry.ToString();
        this.lbShipInfo.Text       = "Ship date: " + (summaryInfo[0].IsShipDateNull() ? "" : summaryInfo[0].ShipDate.ToShortDateString());
        this.lbShipInfo.Text      += "\nPieces: " + summaryInfo[0].Pieces.ToString();
        this.lbShipInfo.Text      += "\nTotal weight: " + summaryInfo[0].Weight.ToString() + " lbs";
        //this.lbShipInfo.Text += "\nReference: " + summaryInfo[0].LabelSequenceNumber.ToString();
        //this.lbShipInfo.Text += "\nDescription:: " + "?????????????";
        this.lblDetailFootnote.Text += "   " + System.DateTime.Now + ".";
    }
Exemplo n.º 8
0
        public TrackingItems TrackCartonsForBOL(string clientNumber, string BOLNumber)
        {
            //
            TrackingItems items = new TrackingItems();

            try {
                TrackingDataset cartons = new TrackingDataset();
                cartons.Merge(new EnterpriseRGateway().GetCartonsForBOL(clientNumber, BOLNumber));

                //Return records for all items
                foreach (TrackingDataset.TrackingTableRow carton in cartons.TrackingTable.Rows)
                {
                    TrackingItem item = new TrackingItem(carton.CTN, carton);
                    items.Add(item);
                }
            }
            catch (Exception ex) { throw new FaultException <TrackingFault>(new TrackingFault(ex.Message), "Service Error"); }
            return(items);
        }
Exemplo n.º 9
0
        public TrackingItems TrackPalletShipment(string shipmentNumber)
        {
            //
            TrackingItems items = new TrackingItems();

            try {
                TrackingDataset pallets = new TrackingDataset();
                pallets.Merge(new EnterpriseRGateway().TrackLTLPallets(shipmentNumber));

                //Return records for all found items
                foreach (TrackingDataset.TrackingTableRow pallet in pallets.TrackingTable.Rows)
                {
                    TrackingItem item = new TrackingItem(pallet.CTN, pallet);
                    items.Add(item);
                }
            }
            catch (Exception ex) { throw new FaultException <TrackingFault>(new TrackingFault(ex.Message), "Service Error"); }
            return(items);
        }
Exemplo n.º 10
0
        public TrackingStoreItems TrackCartonsForStoreDetail(string clientNumber, string storeNumber, DateTime fromDate, DateTime toDate, string vendorNumber, string by, string tlNumber)
        {
            //
            TrackingStoreItems items = new TrackingStoreItems();

            try {
                TrackingDataset cartons = new TrackingDataset();
                DataSet         ds      = null;
                if (by.ToLower() == "pickup")
                {
                    ds = new EnterpriseRGateway().GetCartonsForStoreByPickupDate2(clientNumber, storeNumber, fromDate, toDate, vendorNumber);
                }
                else
                {
                    ds = new EnterpriseRGateway().GetCartonsForStoreByDeliveryDate2(clientNumber, storeNumber, fromDate, toDate, vendorNumber);
                }
                if (ds.Tables["CartonDetailForStoreTable"] != null && ds.Tables["CartonDetailForStoreTable"].Rows.Count > 0)
                {
                    if (tlNumber != null)
                    {
                        cartons.Merge(ds.Tables["CartonDetailForStoreTable"].Select("TL='" + tlNumber + "'"), true, MissingSchemaAction.Ignore);
                    }
                    else
                    {
                        cartons.Merge(ds, true, MissingSchemaAction.Ignore);
                    }
                }

                foreach (TrackingDataset.CartonDetailForStoreTableRow carton in cartons.CartonDetailForStoreTable.Rows)
                {
                    TrackingStoreItem item = new TrackingStoreItem(carton);
                    items.Add(item);
                }
            }
            catch (Exception ex) { throw new FaultException <TrackingFault>(new TrackingFault(ex.Message), "Service Error"); }
            return(items);
        }
Exemplo n.º 11
0
        public TrackingDataset TrackCartonsForStoreSummary(string clientID, string storeNumber, DateTime from, DateTime to, string by)
        {
            //Get TL summary
            TrackingDataset  cartons = new TrackingDataset();
            CRMServiceClient client  = null;

            try {
                client = new CRMServiceClient();
                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
                TrackingDataset summary = new TrackingDataset();
                summary.Merge(detail.CartonDetailForStoreTable.DefaultView.ToTable(true, new string[] { "TL" }));
                foreach (TrackingDataset.CartonDetailForStoreTableRow row in summary.CartonDetailForStoreTable.Rows)
                {
                    row.CartonCount = detail.CartonDetailForStoreTable.Select("TL='" + row.TL + "'").Length;
                    row.Weight      = int.Parse(detail.CartonDetailForStoreTable.Compute("Sum(weight)", "TL='" + row.TL + "'").ToString());
                    object minDate = detail.CartonDetailForStoreTable.Compute("Min(PodDate)", "TL='" + row.TL + "' AND (IsNull(PodDate,#01/01/1900#) <> #01/01/1900#)");

                    TrackingDataset.CartonDetailForStoreTableRow row0 = (TrackingDataset.CartonDetailForStoreTableRow)(detail.CartonDetailForStoreTable.Select("TL='" + row.TL + "'"))[0];
                    if (minDate != System.DBNull.Value)
                    {
                        row.PodDate = DateTime.Parse(minDate.ToString());
                    }
                    else
                    {
                        if (!row0.IsOFD1Null())
                        {
                            row.OFD1 = row0.OFD1;
                        }
                    }
                    row.Store  = row0.Store;
                    row.CBOL   = row0.IsCBOLNull() ? "" : row0.CBOL;
                    row.AG     = !row0.IsAGNull() ? row0.AG : "";
                    row.AgName = row0.Trf == "N" ? row0.AgName : row0.AgName + " (Transfer)";
                    row.AcceptChanges();
                }
                cartons.Merge(summary);
            }
            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);
        }
Exemplo n.º 12
0
        public TrackingItems TrackCartons(string[] itemNumbers, string companyID)
        {
            //Get tracking information for the specified items and company
            TrackingItems items = null;

            try {
                //Get tracking response for the specified requests
                items = new TrackingItems();
                string numbers = "";
                for (int i = 0; i < itemNumbers.Length; i++)
                {
                    if (i > 0)
                    {
                        numbers += ",";
                    }
                    numbers += itemNumbers[i];
                }

                //Get tracking data response
                TrackingDataset _cartons = new TrackingDataset();
                _cartons.Merge(new EnterpriseRGateway().GetCartonsByCartonNumber(numbers, companyID, null));
                if (_cartons.TrackingTable.Rows.Count > 0)
                {
                    TrackingDataset cartons = new TrackingDataset();
                    DataView        view    = _cartons.TrackingTable.DefaultView;
                    view.Sort = "CTN,BL DESC,SCNTP DESC,SCD DESC,SCT DESC";
                    DataTable dt = view.Table.Clone();
                    Hashtable ht = new Hashtable();
                    for (int i = 0; i < view.Count; i++)
                    {
                        string key = view[i]["CTN"].ToString().Trim() + view[i]["BL"].ToString().Trim();
                        if (!ht.ContainsKey(key))
                        {
                            ht.Add(key, null);
                            dt.ImportRow(view[i].Row);
                        }
                    }
                    cartons.TrackingTable.Merge(dt);

                    //Return records for all found items
                    foreach (TrackingDataset.TrackingTableRow carton in cartons.TrackingTable.Rows)
                    {
                        //Keep the response item if it matches a requested item
                        for (int i = 0; i < itemNumbers.Length; i++)
                        {
                            if (carton.CTN.Trim() == itemNumbers[i])
                            {
                                //Keep it
                                TrackingItem item = new TrackingItem(itemNumbers[i], carton);
                                items.Add(item);
                                itemNumbers[i] = "";    //Mark as found by nulling it
                                break;
                            }
                        }
                    }

                    //Return a record for all unfound requests
                    for (int i = 0; i < itemNumbers.Length; i++)
                    {
                        if (itemNumbers[i].Length > 0)
                        {
                            items.Add(new TrackingItem(itemNumbers[i]));
                        }
                    }
                }
            }
            catch (Exception ex) { throw new FaultException <TrackingFault>(new TrackingFault(ex.Message), "Service Error"); }
            return(items);
        }
Exemplo n.º 13
0
        public TrackingDataset TrackCartons(string[] cartonNumbers, string clientNumber, string vendorNumber)
        {
            //Get a list of carton tracking details
            TrackingDataset trackDS = null;     //Composite dataset (i.e. summary and detail info)

            try {
                //Init
                trackDS = new TrackingDataset();
                TrackResponse trackResponse = new TrackResponse();
                Exception     Exa = null, Exu = null;

                #region 1. Get Argix tracking data
                try {
                    string numbers = "";
                    for (int i = 0; i < cartonNumbers.Length; i++)
                    {
                        if (i > 0)
                        {
                            numbers += ",";
                        }
                        numbers += cartonNumbers[i];
                    }
                    TrackResponse _respone = new TrackResponse();
                    _respone.Merge(new EnterpriseRGateway().TrackUSPSCartons(numbers, clientNumber, vendorNumber));
                    if (_respone.TrackingTable.Rows.Count > 0)
                    {
                        trackResponse.Merge(_respone.TrackingTable.Select("", "Date DESC"));
                    }
                }
                catch (Exception ex) { Exa = ex; }
                #endregion
                #region 2. Get USPS carton tracking details if no Argix data or TenderedDate is null
                try {
                    //Build string[] of applicable #s for USPS web service data call
                    //1. Get data for cartonNumbers[i] if no Argix data or TenderedDate=null
                    //2. Get data for OsTrackingNumber if OsTrackingNumber != cartonNumbers[i]
                    ArrayList ctnList = new ArrayList();
                    for (int i = 0; i < cartonNumbers.Length; i++)
                    {
                        //Select Argix data for this carton number
                        TrackResponse.TrackingTableRow[] items = (TrackResponse.TrackingTableRow[])trackResponse.TrackingTable.Select("ItemNumber='" + cartonNumbers[i] + "'");
                        if (items.Length == 0 || (items.Length > 0 && items[0].IsTenderedDateNull()))
                        {
                            ctnList.Add(cartonNumbers[i]);
                        }
                        if (items.Length > 0 && (items[0].OsTrackingNumber.Trim() != cartonNumbers[i]))
                        {
                            ctnList.Add(items[0].OsTrackingNumber.Trim());
                        }
                    }

                    //Make a batch call to the USPS web service for cartonNumbers
                    string[] request = new string[ctnList.Count];
                    for (int j = 0; j < ctnList.Count; j++)
                    {
                        request[j] = (string)ctnList[j];
                    }
                    trackResponse.Merge(new USPSGateway().TrackFieldRequests(request));
                }
                catch (Exception ex) { Exu = ex; }
                #endregion
                #region 3. Populate tracking view dataset; use two tables in TrackingDataset:
                //1. TrackingDataset.TrackingSummaryTable- holds a single summary record per carton item
                //2. TrackingDataset.TrackingDetailTable- holds all detail records for all carton items
                for (int i = 0; i < cartonNumbers.Length; i++)
                {
                    //Create summary/detail for each carton
                    string itemNumber       = cartonNumbers[i].Trim();
                    string osTrackingNumber = "";
                    TrackResponse.TrackingTableRow[] items = (TrackResponse.TrackingTableRow[])trackResponse.TrackingTable.Select("ItemNumber='" + cartonNumbers[i] + "'");
                    if (items.Length > 0 && !items[0].IsOsTrackingNumberNull() && items[0].OsTrackingNumber.Trim().Length > 0)
                    {
                        osTrackingNumber = items[0].OsTrackingNumber.Trim();
                    }

                    //Get all data for this carton#
                    //NOTE: rgxRows      Argix records
                    //      uspsRows     TrackResponse.TrackInfoRow parent record (single record per item)
                    //      uspsSumRow   TrackResponse.TrackSummary child record (single record per item)
                    //      uspsDetRows  TrackResponse.TrackDetail child records (multiple records per item)
                    //      uspsErrRow   TrackResponse.Error child records (single record per item)
                    TrackResponse.TrackingTableRow[] rgxRows     = (TrackResponse.TrackingTableRow[])trackResponse.TrackingTable.Select("ItemNumber='" + itemNumber + "'", "Date DESC, Time DESC");
                    TrackResponse.TrackInfoRow[]     uspsRows    = null;
                    TrackResponse.TrackInfoRow[]     uspsRows1   = (TrackResponse.TrackInfoRow[])trackResponse.TrackInfo.Select("ID='" + itemNumber + "'");
                    TrackResponse.TrackInfoRow[]     uspsRows2   = (TrackResponse.TrackInfoRow[])trackResponse.TrackInfo.Select("ID='" + osTrackingNumber + "'");
                    TrackResponse.TrackSummaryRow[]  uspsSumRow  = new TrackResponse.TrackSummaryRow[] { };
                    TrackResponse.TrackDetailRow[]   uspsDetRows = new TrackResponse.TrackDetailRow[] { };
                    TrackResponse.ErrorRow[]         uspsErrRow  = new TrackResponse.ErrorRow[] { };

                    //Order of use: cartonNumber detail, osTrackingNumber detail, cartonNumber error, osTrackingNumber error
                    if (uspsRows1.Length > 0 && trackResponse.TrackSummary.Select("TrackInfo_Id=" + uspsRows1[0].TrackInfo_Id).Length > 0)
                    {
                        uspsRows = uspsRows1;
                    }
                    else if (uspsRows2.Length > 0 && trackResponse.TrackSummary.Select("TrackInfo_Id=" + uspsRows2[0].TrackInfo_Id).Length > 0)
                    {
                        uspsRows = uspsRows2;
                    }
                    else if (uspsRows1.Length > 0 && trackResponse.Error.Select("TrackInfo_Id=" + uspsRows1[0].TrackInfo_Id).Length > 0)
                    {
                        uspsRows = uspsRows1;
                    }
                    else if (uspsRows2.Length > 0 && trackResponse.Error.Select("TrackInfo_Id=" + uspsRows2[0].TrackInfo_Id).Length > 0)
                    {
                        uspsRows = uspsRows2;
                    }

                    if (uspsRows != null && uspsRows.Length > 0)
                    {
                        //Determine USPS summary, detail, and error records
                        int id = uspsRows[0].TrackInfo_Id;
                        uspsSumRow  = (TrackResponse.TrackSummaryRow[])trackResponse.TrackSummary.Select("TrackInfo_Id=" + id);
                        uspsDetRows = (TrackResponse.TrackDetailRow[])trackResponse.TrackDetail.Select("TrackInfo_Id=" + id);
                        uspsErrRow  = (TrackResponse.ErrorRow[])trackResponse.Error.Select("TrackInfo_Id=" + id);

                        //Remove 'Electronic Billing Info Received' record (if applicable)
                        //Rebuild uspsSumRow, uspsDetRows since dataset maybe modified by a delete
                        for (int j = 0; j < uspsSumRow.Length; j++)
                        {
                            if (uspsSumRow[j].Event.Contains("Electronic"))
                            {
                                uspsSumRow[j].Delete();
                            }
                        }
                        uspsSumRow = (TrackResponse.TrackSummaryRow[])trackResponse.TrackSummary.Select("TrackInfo_Id=" + id);
                        for (int j = 0; j < uspsDetRows.Length; j++)
                        {
                            if (uspsDetRows[j].Event.Contains("Electronic"))
                            {
                                uspsDetRows[j].Delete();
                            }
                        }
                        uspsDetRows = (TrackResponse.TrackDetailRow[])trackResponse.TrackDetail.Select("TrackInfo_Id=" + id);
                    }
    #if DEBUG
                    DataSet ds = new DataSet();
                    if (rgxRows != null)
                    {
                        ds.Merge(rgxRows);
                    }
                    if (uspsRows != null)
                    {
                        ds.Merge(uspsRows);
                    }
                    if (uspsSumRow != null)
                    {
                        ds.Merge(uspsSumRow);
                    }
                    if (uspsDetRows != null)
                    {
                        ds.Merge(uspsDetRows);
                    }
                    if (uspsErrRow != null)
                    {
                        ds.Merge(uspsErrRow);
                    }
                    Debug.WriteLine(ds.GetXml() + "\n");
#endif
                    //Create a summary record for this carton# (this is a key for detail records)
                    TrackingDataset.TrackingSummaryTableRow sumRow = trackDS.TrackingSummaryTable.NewTrackingSummaryTableRow();
                    sumRow.ItemNumber = itemNumber;
                    trackDS.TrackingSummaryTable.AddTrackingSummaryTableRow(sumRow);

                    //Build detail for this carton#
                    if (rgxRows.Length > 0)
                    {
                        //Update summary; populate with details from first (or any) Argix record for this carton#
                        #region Copy fields from TrackResponse.TrackingTable to TrackingDataset.TrackingSummaryTable
                        sumRow.LabelSequenceNumber = rgxRows[0].LabelSequenceNumber;
                        if (!rgxRows[0].IsDateNull())
                        {
                            sumRow.Date = rgxRows[0].Date;
                        }
                        if (!rgxRows[0].IsTimeNull())
                        {
                            sumRow.Time = rgxRows[0].Time;
                        }
                        sumRow.Status           = rgxRows[0].Status.Trim();
                        sumRow.LocationName     = rgxRows[0].LocationName.Trim();
                        sumRow.ShipperName      = rgxRows[0].ShipperName.Trim();
                        sumRow.ShipperCity      = rgxRows[0].ShipperCity.Trim();
                        sumRow.ShipperState     = rgxRows[0].ShipperState.Trim();
                        sumRow.ShipperZip       = rgxRows[0].ShipperZip.Trim();
                        sumRow.ShipperCountry   = rgxRows[0].ShipperCountry.Trim();
                        sumRow.ConsigneeName    = rgxRows[0].ConsigneeName.Trim();
                        sumRow.ConsigneeCity    = rgxRows[0].ConsigneeCity.Trim();
                        sumRow.ConsigneeState   = rgxRows[0].ConsigneeState.Trim();
                        sumRow.ConsigneeZip     = rgxRows[0].ConsigneeZip.Trim();
                        sumRow.ConsigneeCountry = rgxRows[0].ConsigneeCountry.Trim();
                        sumRow.Pieces           = rgxRows[0].Pieces;
                        sumRow.Weight           = rgxRows[0].Weight;
                        if (!rgxRows[0].IsShipDateNull())
                        {
                            sumRow.ShipDate = rgxRows[0].ShipDate;
                        }
                        if (!rgxRows[0].IsShipTimeNull())
                        {
                            sumRow.ShipTime = rgxRows[0].ShipTime;
                        }
                        if (!rgxRows[0].IsTenderedDateNull())
                        {
                            sumRow.TenderedDate = rgxRows[0].TenderedDate;
                        }
                        if (!rgxRows[0].IsTenderedTimeNull())
                        {
                            sumRow.TenderedTime = rgxRows[0].TenderedTime;
                        }
                        #endregion

                        //Add Argix tracking detail records
                        for (int j = 0; j < rgxRows.Length; j++)
                        {
                            trackDS.TrackingDetailTable.AddTrackingDetailTableRow(sumRow, rgxRows[j].Date, rgxRows[j].Time, rgxRows[j].Status.Trim(), rgxRows[j].LocationName.Trim());
                        }

                        //Copy USPS data for this item
                        if (uspsSumRow.Length > 0 || uspsDetRows.Length > 0)
                        {
                            //Add USPS tracking data
                            if (uspsSumRow.Length > 0)
                            {
                                DateTime time = Convert.ToDateTime("1900-01-01 " + uspsSumRow[0].EventTime);
                                trackDS.TrackingDetailTable.AddTrackingDetailTableRow(sumRow, Convert.ToDateTime(uspsSumRow[0].EventDate), time, uspsSumRow[0].Event, uspsSumRow[0].EventCity + ", " + uspsSumRow[0].EventState + " " + uspsSumRow[0].EventZIPCode);
                            }
                            for (int n = 0; n < uspsDetRows.Length; n++)
                            {
                                DateTime time2 = Convert.ToDateTime("1900-01-01 " + uspsDetRows[n].EventTime);
                                trackDS.TrackingDetailTable.AddTrackingDetailTableRow(sumRow, Convert.ToDateTime(uspsDetRows[n].EventDate), time2, uspsDetRows[n].Event, uspsDetRows[n].EventCity + ", " + uspsDetRows[n].EventState + " " + uspsDetRows[n].EventZIPCode);
                            }
                        }
                    }
                    else
                    {
                        //No Argix data
                        //Update summary; populate with 'N/A'
                        #region TrackingDataset.TrackingSummaryTable
                        sumRow.LabelSequenceNumber = 0;
                        sumRow.Date = sumRow.Time = DateTime.Now;
                        if (uspsSumRow.Length > 0)
                        {
                            sumRow.Status = uspsSumRow[0].Event;
                        }
                        else if (uspsDetRows.Length > 0)
                        {
                            sumRow.Status = uspsDetRows[0].Event;
                        }
                        else if (uspsErrRow.Length > 0)
                        {
                            uspsErrRow[0].Description.Trim();
                        }
                        sumRow.LocationName  = "N/A";
                        sumRow.ShipperName   = sumRow.ShipperCity = sumRow.ShipperState = sumRow.ShipperZip = sumRow.ShipperCountry = "N/A";
                        sumRow.ConsigneeName = sumRow.ConsigneeCity = sumRow.ConsigneeState = sumRow.ConsigneeZip = sumRow.ConsigneeCountry = "N/A";
                        sumRow.Pieces        = sumRow.Weight = 0;
                        //sumRow.ShipDate = sumRow.ShipTime = ;
                        //sumRow.TenderedDate = sumRow.TenderedTime = ;
                        #endregion

                        //Copy USPS data for this item
                        if (uspsSumRow.Length > 0 || uspsDetRows.Length > 0 || uspsErrRow.Length > 0)
                        {
                            //Add USPS tracking data
                            if (uspsSumRow.Length > 0)
                            {
                                DateTime time = Convert.ToDateTime("1900-01-01 " + uspsSumRow[0].EventTime);
                                trackDS.TrackingDetailTable.AddTrackingDetailTableRow(sumRow, Convert.ToDateTime(uspsSumRow[0].EventDate), time, uspsSumRow[0].Event, uspsSumRow[0].EventCity + ", " + uspsSumRow[0].EventState + " " + uspsSumRow[0].EventZIPCode);
                            }
                            for (int n = 0; n < uspsDetRows.Length; n++)
                            {
                                DateTime time2 = Convert.ToDateTime("1900-01-01 " + uspsDetRows[n].EventTime);
                                trackDS.TrackingDetailTable.AddTrackingDetailTableRow(sumRow, Convert.ToDateTime(uspsDetRows[n].EventDate), time2, uspsDetRows[n].Event, uspsDetRows[n].EventCity + ", " + uspsDetRows[n].EventState + " " + uspsDetRows[n].EventZIPCode);
                            }
                            //02/06/13- Don't return "No Record Of That Item" in case of error
                            //for(int e = 0; e < uspsErrRow.Length; e++)
                            //trackDS.TrackingDetailTable.AddTrackingDetailTableRow(sumRow,DateTime.Now,DateTime.Now,uspsErrRow[e].Description,"N/A");
                            if (uspsErrRow.Length > 0)
                            {
                                trackDS.TrackingDetailTable.AddTrackingDetailTableRow(sumRow, DateTime.Now, DateTime.Now, "Order Being Processed", "N/A");
                            }
                        }
                        else
                        {
                            //No USPS data for this carton- check for USPS error
                            if (Exa != null || Exu != null)
                            {
                                //Argix or USPS exception- add "Order Being Processed" record
                                trackDS.TrackingDetailTable.AddTrackingDetailTableRow(sumRow, DateTime.Now, DateTime.Now, "Order Being Processed", "N/A");
                            }
                            else if (Exa == null && Exu == null)
                            {
                                //No data, no exceptions (should not happen)- add "Item Not Found" record
                                trackDS.TrackingDetailTable.AddTrackingDetailTableRow(sumRow, DateTime.Now, DateTime.Now, "Item Not Found", "N/A");
                            }
                        }
                    }

                    //Update summary record with most recent tracking detail record
                    TrackingDataset.TrackingDetailTableRow[] _rows = (TrackingDataset.TrackingDetailTableRow[])trackDS.TrackingDetailTable.Select("ItemNumber='" + itemNumber + "'", "Date DESC, Time DESC");
                    sumRow.Date         = _rows[0].Date;
                    sumRow.Time         = _rows[0].Time;
                    sumRow.Status       = _rows[0].Status.Trim();
                    sumRow.LocationName = _rows[0].LocationName.Trim();
                }
                #endregion
            }
            catch (Exception ex) { throw new FaultException <TrackingFault>(new TrackingFault(ex.Message), "Service Error"); }
            return(trackDS);
        }