示例#1
0
        public static SortProfile CreateSortProfile(InboundFreight shipment, int sortTypeID, string sortType, int labelID, int excLocation)
        {
            //Create a sort profile for the specified freight based upon its' type (i.e. Tsort, Returns),
            //the client/shipper relationship, and how it was scheduled by Freight Assign to be sorted (i.e. San, Regular, SKU, etc)
            SortProfile sortProfile = null;

            try {
                //The freight type of the shipment determines whether a regular or returns profile is needed
                //Create a sort profile that specifies freight type, sort type, and inbound label
                SortProfileDS sortProfileDS = new SortProfileDS();
                SortProfileDS.SortProfileTableRow profile = sortProfileDS.SortProfileTable.NewSortProfileTableRow();
                sortProfileDS.EnforceConstraints = false;
                profile.FreightType              = shipment.FreightType;
                profile.SortTypeID               = sortTypeID;
                profile.SortType                 = sortType;
                profile.ClientNumber             = shipment.Client.Number;
                profile.ClientDivision           = shipment.Client.Division;
                profile.VendorNumber             = shipment.Shipper.NUMBER;
                profile.Status                   = "";
                profile.LabelID                  = labelID;
                profile.ExceptionLocation        = excLocation;
                sortProfileDS.EnforceConstraints = true;
                sortProfile = new SortProfile(profile);
            }
            catch (ApplicationException ex) { throw ex; }
            catch (Exception ex) { throw new ApplicationException("Unexpected exception creating sort profile.", ex); }
            return(sortProfile);
        }
示例#2
0
        public InboundFreight GetInboundFreight(int terminalID, string freightType)
        {
            //Get the operating enterprise terminal
            InboundFreight       shipments = null;
            FreightServiceClient _Client   = null;

            try {
                _Client = new FreightServiceClient();
                InboundFreight _shipments = _Client.GetInboundFreight(terminalID, 0);
                if (freightType != null && freightType.Length > 0)
                {
                    shipments = new InboundFreight();
                    for (int i = 0; i < _shipments.Count; i++)
                    {
                        if (_shipments[i].FreightType.Trim().ToLower() == freightType.ToLower())
                        {
                            shipments.Add(_shipments[i]);
                        }
                    }
                }
                else
                {
                    shipments = _shipments;
                }
                _Client.Close();
            }
            catch (FaultException fe) { throw new ApplicationException("GetInboundFreight() service error.", fe); }
            catch (TimeoutException te) { _Client.Abort(); throw new ApplicationException("GetInboundFreight() timeout error.", te); }
            catch (CommunicationException ce) { _Client.Abort(); throw new ApplicationException("GetInboundFreight() communication error.", ce); }
            return(shipments);
        }
示例#3
0
        public static StationAssignments GetStationAssignments(Workstation workstation)
        {
            //Return a collection of current freight assignments for the specified workstation
            StationAssignments assignments = null;

            try {
                if (workstation == null)
                {
                    throw new ApplicationException("Workstation is null.");
                }

                assignments = new StationAssignments();
                StationAssignmentDS dsAssignments = new StationAssignmentDS();
                dsAssignments.Merge(Mediator.FillDataset(USP_FREIGHTCLIENTSHIPPER, TBL_FREIGHTCLIENTSHIPPER, new object[] { workstation.WorkStationID }));
                foreach (StationAssignmentDS.FreightClientShipperTableRow row in dsAssignments.FreightClientShipperTable)
                {
                    Client         client   = EnterpriseFactory.CreateClient(row.ClientNumber, row.ClientDivision, row.Client, row.ClientAddressLine1, row.ClientAddressLine2, row.ClientAddressCity, row.ClientAddressState, row.ClientAddressZip);
                    Shipper        shipper  = EnterpriseFactory.CreateShipper(row.FreightType, row.ShipperNumber, row.Shipper, row.ShipperAddressLine1, row.ShipperAddressLine2, row.ShipperAddressCity, row.ShipperAddressState, row.ShipperAddressZip, row.ShipperUserData);
                    InboundFreight shipment = FreightFactory.CreateInboundFreight(row.TerminalID, row.FreightID, row.FreightType, row.TDSNumber, row.VendorKey, row.TrailerNumber, row.PickupDate, row.PickupNumber, row.CubeRatio, client, shipper);
                    SortProfile    profile  = CreateSortProfile(shipment, row.SortTypeID, row.SortType, row.LabelID, row.ExcLocation);
                    assignments.Add(new StationAssignment("", workstation, shipment, profile));
                }
            }
            catch (ApplicationException ex) { throw ex; }
            catch (Exception ex) { throw new ApplicationException("Unexpected error while getting station assignments (freight-client-shipper).", ex); }
            return(assignments);
        }
 public StationFreightAssignment(SortStation station, InboundFreight freight, string sortType)
 {
     //Constructor
     try {
         //Configure this assignment from the assignment configuration information
         this.mStation  = station;
         this.mFreight  = freight;
         this.mSortType = sortType;
     }
     catch (Exception ex) { throw new ApplicationException("Unexpected error while creating new Station Assignment instance.", ex); }
 }
示例#5
0
 public StationAssignment(string assignmentID, Workstation sortStation, InboundFreight inboundFreight, SortProfile sortProfile)
 {
     //Constructor
     try {
         //Configure this assignment from the assignment configuration information
         this.mAssignmentID = assignmentID;
         this.mStation      = sortStation;
         this.mFreight      = inboundFreight;
         this.mProfile      = sortProfile;
     }
     catch (Exception ex) { throw new ApplicationException("Unexpected error while creating new Station Assignment instance.", ex); }
 }
示例#6
0
        public bool ChangeScheduledInboundFreight(InboundFreight freight)
        {
            //Change an existing inbound freight
            bool changed = false;

            try {
                //Create the TransactionScope to execute the commands, guaranteeing that both commands can commit or roll back as a single unit of work
                using (TransactionScope scope = new TransactionScope()) {
                    //
                    changed = new DispatchGateway().UpdateInboundFreight(freight);

                    //Commits the transaction; if an exception is thrown, Complete is not called and the transaction is rolled back
                    scope.Complete();
                }
            }
            catch (Exception ex) { throw new FaultException <DispatchFault>(new DispatchFault(ex.Message), "Service Error"); }
            return(changed);
        }
示例#7
0
        public InboundFreight GetInboundFreight(int terminalID, int sortedRange)
        {
            //Get a list of inbound shipments for the specified terminal
            InboundFreight shipments = new InboundFreight();

            try {
                DataSet ds = new DataService().FillDataset(SQL_CONNID, USP_FREIGHT, TBL_FREIGHT, new object[] { terminalID, DateTime.Today.AddDays(-sortedRange) });
                if (ds != null)
                {
                    FreightDS freight = new FreightDS();
                    freight.Merge(ds, true);
                    for (int i = 0; i < freight.InboundFreightTable.Rows.Count; i++)
                    {
                        shipments.Add(new InboundShipment(freight.InboundFreightTable[i]));
                    }
                }
            }
            catch (Exception ex) { throw new FaultException <FreightFault>(new FreightFault(new ApplicationException("Unexpected error while reading inbound freight.", ex))); }
            return(shipments);
        }
示例#8
0
        public bool InsertInboundFreight(InboundFreight freight)
        {
            //
            bool inserted = false;

            try {
                inserted = new DataService().ExecuteNonQuery(SQL_CONNID, USP_SCHEDULEDINBOUND_INSERT,
                                                             new object[] {
                    freight.Created, freight.CreateUserID, freight.ScheduleDate,
                    freight.Origin, freight.OriginLocation, freight.Destination, freight.DestinationLocation,
                    freight.CarrierName, freight.DriverName, freight.TrailerNumber, freight.DropEmptyTrailerNumber,
                    (freight.ScheduledDeparture != DateTime.MinValue ? freight.ScheduledDeparture : null as object),
                    (freight.ScheduledArrival != DateTime.MinValue ? freight.ScheduledArrival : null as object),
                    freight.Confirmed,
                    freight.Amount, freight.AmountType, freight.FreightType,
                    freight.Comments, freight.IsTemplate, freight.LastUpdated, freight.UserID
                });
            }
            catch (Exception ex) { throw new ApplicationException(ex.Message, ex); }
            return(inserted);
        }
示例#9
0
 public void RefreshIndirectAssignments()
 {
     //Load trip assignments
     try {
         this.mIndirectAssignments.Clear();
         StationAssignmentDS assignments = new StationAssignmentDS();
         assignments.Merge(this.mMediator.FillDataset(App.USP_INDIRECTASSIGNMENTS, App.TBL_INDIRECTASSIGNMENTS, null));
         foreach (StationAssignmentDS.IndirectAssignmentTableRow row in assignments.IndirectAssignmentTable)
         {
             SortStation    station = EnterpriseFactory.GetStation(row.StationNumber);
             InboundFreight freight = FreightFactory.CreateInboundFreight(0, row.TripNumber, "", "", 0);
             this.mIndirectAssignments.Add(station.Number + freight.FreightID, new StationFreightAssignment(station, freight, ""));
         }
     }
     catch (Exception ex) { throw ex; }
     finally { if (IndirectAssignmentsChanged != null)
               {
                   IndirectAssignmentsChanged(this, EventArgs.Empty);
               }
     }
 }
示例#10
0
 public void RefreshDirectAssignments()
 {
     //Load direct freight assignments
     try {
         this.mDirectAssignments.Clear();
         StationAssignmentDS assignments = new StationAssignmentDS();
         assignments.Merge(this.mMediator.FillDataset(App.USP_DIRECTASSIGNMENTS, App.TBL_DIRECTASSIGNMENTS, null));
         foreach (StationAssignmentDS.DirectAssignmentTableRow row in assignments.DirectAssignmentTable)
         {
             SortStation    station = EnterpriseFactory.GetStation(row.StationNumber);
             Client         client  = EnterpriseFactory.CreateClient(row.ClientNumber, row.ClientDivision, row.Client, "", "", "", "", "");
             Shipper        shipper = EnterpriseFactory.CreateShipper(row.FreightType, row.ShipperNumber, row.Shipper, "", "", "", "", "", "");
             InboundFreight freight = FreightFactory.CreateInboundFreight(row.TerminalID, row.FreightID, row.FreightType, row.TDSNumber, "", row.TrailerNumber, row.Pickup, row.Pickup, 0, client, shipper);
             this.mDirectAssignments.Add(station.Number + freight.FreightID, new StationFreightAssignment(station, freight, row.SortType));
         }
     }
     catch (Exception ex) { throw ex; }
     finally { if (DirectAssignmentsChanged != null)
               {
                   DirectAssignmentsChanged(this, EventArgs.Empty);
               }
     }
 }