コード例 #1
0
ファイル: PickupRequest.aspx.cs プロジェクト: jpheary/Argix10
    //Interface
    protected void Page_Load(object sender, EventArgs e)
    {
        //Page load event handler
        try {
            if (!Page.IsPostBack)
            {
                int id = int.Parse(Request.QueryString["pickupid"]);
                if (id > 0)
                {
                    //this.mPickup = new FreightGateway().ReadLTLShipper(id);
                    //ViewState.Add("Pickup",this.mPickup);

                    //Populate form fields from existing
                    //TODO

                    //Set read only fields
                    //this.txtName.ReadOnly = this.txtCity.ReadOnly = this.txtState.ReadOnly = this.txtZip.ReadOnly = id > 0;
                }
                else
                {
                    this.txtWindowOpen.Text  = "900";
                    this.txtWindowClose.Text = "1700";
                }
            }
            else
            {
                this.mPickup = ViewState["Pickup"] != null ? (PickupRequest)ViewState["Pickup"] : null;
            }
        }
        catch (Exception ex) { Master.ReportError(ex, 3); }
    }
コード例 #2
0
        public bool UpdatePickup(PickupRequest pickup)
        {
            //Update an existing pickup requesst
            bool updated = false;

            try {
                //Apply simple business rules
                //Cannot cancel if arrived or if day of pickup
                PickupRequest _pickup = ReadPickup(pickup.RequestID);
                if (_pickup.ScheduleDate.CompareTo(DateTime.Today) <= 0)
                {
                    throw new ApplicationException("Pickups must be updated at least one day before the scheduled pickup date.");
                }
                if (_pickup.ActualPickup > DateTime.MinValue)
                {
                    throw new ApplicationException("This pickup has already been arrived.");
                }

                //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()) {
                    //
                    updated = new DispatchGateway().UpdatePickupRequest(pickup);

                    //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(updated);
        }
コード例 #3
0
        public IActionResult Put(int id, [FromBody] PickupRequest request)
        {
            request.PickupRequestID = id;
            _repository.Edit(request);

            return(Ok());
        }
コード例 #4
0
        private SqlCommand GeneratePickupRequestSqlCommand(string sqlCommand, PickupRequest pickupRequest, SqlConnection con)
        {
            var command = new SqlCommand(sqlCommand, con)
            {
                CommandType = CommandType.StoredProcedure
            };

            SqlParameter[] sqlParameters =
            {
                new SqlParameter("@userID",             pickupRequest.Activity.UserId),
                new SqlParameter("@restaurant",         pickupRequest.Activity.Restaurant),
                new SqlParameter("@foodOrderNumber",    pickupRequest.FoodOrderNumber),
                new SqlParameter("@preferedPickupTime", pickupRequest.PreferedPickupTime),
                new SqlParameter("@tips",               pickupRequest.Tips),
                new SqlParameter("@notes",              pickupRequest.Activity.Notes),
                new SqlParameter("@address1",           pickupRequest.Address.Address1),
                new SqlParameter("@address2",           pickupRequest.Address.Address2),
                new SqlParameter("@city",               pickupRequest.Address.City),
                new SqlParameter("@state",              pickupRequest.Address.State),
                new SqlParameter("@zipcode",            pickupRequest.Address.Zipcode),
                new SqlParameter("@latitude",                                        0.00),
                new SqlParameter("@longitude", 0.00)
            };

            if (true)
            {
            }

            command.Parameters.AddRange(sqlParameters);

            return(command);
        }
コード例 #5
0
        public bool UpdatePickupRequest(PickupRequest pickupRequest)
        {
            var result = false;

            try
            {
                using (var con = new SqlConnection(ConnString))
                {
                    con.Open();

                    using (var cmd = GeneratePickupRequestSqlCommand("Requester_UpdatePickupRequest", pickupRequest, con))
                    {
                        cmd.Parameters.RemoveAt("@userID");
                        cmd.Parameters.RemoveAt("@latitude");
                        cmd.Parameters.RemoveAt("@longitude");
                        cmd.Parameters.Add(new SqlParameter("@requestID", pickupRequest.Activity.Id));
                        cmd.Parameters.Add(new SqlParameter("idAddress", pickupRequest.Address.Id));

                        var updatedRecords = cmd.ExecuteNonQuery();

                        if (updatedRecords == 2)
                        {
                            result = true;
                        }
                    }
                }
            }
            catch (Exception E)
            {
                Debug.WriteLine(E.Message);
                throw new Exception("UpdateDriverService", E);
            }

            return(result);
        }
コード例 #6
0
        public bool SaveNewPickupRequest(PickupRequest pickupRequest)
        {
            var isSuccess = false;

            try
            {
                using (var con = new SqlConnection(ConnString))
                {
                    con.Open();

                    using (var cmd = GeneratePickupRequestSqlCommand("AddNewPickupRequest", pickupRequest, con))
                    {
                        var returnParameter = cmd.Parameters.Add("@errorMessage", SqlDbType.VarChar, 256);
                        returnParameter.Direction = ParameterDirection.Output;

                        cmd.ExecuteNonQuery();

                        var result = returnParameter.Value;

                        if (result.ToString().Equals("success"))
                        {
                            isSuccess = true;
                        }
                    }
                }
            }
            catch (Exception E)
            {
                Debug.WriteLine(E.Message);
                throw new Exception("SaveNewPickupRequest", E);
            }

            return(isSuccess);
        }
コード例 #7
0
        public bool ChangePickupRequest(PickupRequest request)
        {
            //Change an existing pickup request
            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()) {
                    //
                    //Get the pickups current state
                    PickupRequest pickup = ReadPickup(request.RequestID);

                    //Update the pickup
                    changed = new DispatchGateway().UpdatePickupRequest(request);

                    //Arrive/unarrive LTL shipment (if applicable); see if the actual pickup date is now being changed
                    if (pickup != null && pickup.CreateUserID == "PSP" && (pickup.ActualPickup == null || pickup.ActualPickup == DateTime.MinValue) && (request.ActualPickup != null && request.ActualPickup > DateTime.MinValue))
                    {
                        //This is an LTL pickup being arrived
                        new LTLGateway2().ArriveLTLShipment(request.RequestID, request.ActualPickup);
                    }
                    else if (pickup != null && pickup.CreateUserID == "PSP" && (pickup.ActualPickup != null && pickup.ActualPickup > DateTime.MinValue) && (request.ActualPickup == null || request.ActualPickup == DateTime.MinValue))
                    {
                        //This is an LTL pickup being unarrived
                        new LTLGateway2().ArriveLTLShipment(request.RequestID, DateTime.MinValue);
                    }
                    scope.Complete();
                }
            }
            catch (Exception ex) { throw new FaultException <DispatchFault>(new DispatchFault(ex.Message), "Service Error"); }
            return(changed);
        }
コード例 #8
0
        public int RequestPickup(PickupRequest pickup)
        {
            //Add a new pickup request
            int pickupID = 0;

            try {
                //Apply simple business rules
                //Validate schedule date > today
                if (pickup.ScheduleDate.CompareTo(DateTime.Today) <= 0)
                {
                    throw new ApplicationException("Schedule date must be next day or later.");
                }

                //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()) {
                    //Enforce identification of LTL pickups (needed for BizTalk integration)
                    pickup.CreateUserID = "PSP";
                    pickupID            = new DispatchGateway().InsertPickupRequest3(pickup);

                    //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(pickupID);
        }
コード例 #9
0
        public bool CancelLoadTenderEntry(int entryID, DateTime cancelled, string cancelledBy)
        {
            //
            bool result = false;

            try {
                //Apply simple business rules
                LoadTenderEntry entry = ReadLoadTenderEntry(entryID);
                if (entry.PickupNumber > 0)
                {
                    //Get the pickup appointment or request and check if picked up
                    if (entry.PickupNumber.ToString().Substring(0, 1) == "1")
                    {
                        ClientInboundFreight appt = null;
                        if (appt != null && appt.ActualArrival != DateTime.MinValue)
                        {
                            throw new ApplicationException("This load tender has already been picked up.");
                        }
                    }
                    else
                    {
                        PickupRequest pickup = null;
                        if (pickup != null && pickup.ActualPickup != DateTime.MinValue)
                        {
                            throw new ApplicationException("This load tender has already been picked up.");
                        }
                    }
                }

                //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()) {
                    if (entry.PickupNumber > 0)
                    {
                        //Get the pickup appointment or request and check if picked up
                        if (entry.PickupNumber.ToString().Substring(0, 1) == "1")
                        {
                            //Cancel the pickup appointment
                            new DispatchGateway().CancelClientInboundFreight(entry.PickupNumber, cancelled, cancelledBy);
                        }
                        else
                        {
                            //Cancel the pickup request
                            new DispatchGateway().CancelPickupRequest(entry.PickupNumber, cancelled, cancelledBy);
                        }
                    }

                    //Cancel the load tender entry
                    result = new DispatchGateway().CancelLoadTenderEntry(entryID, cancelled, cancelledBy);

                    //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(result);
        }
コード例 #10
0
        void IPickupRequestRepository.Cancel(PickupRequest request)
        {
            if (request.Answered != null)
            {
                _context.AnsweredPickupRequests.Remove(request.Answered);
            }

            _context.PickupRequests.Remove(request);
            _context.SaveChanges();
        }
コード例 #11
0
        public void Answer(PickupRequest request, Leg leg)
        {
            AnsweredPickupRequest ans = new AnsweredPickupRequest
            {
                AnswerLeg = leg,
                Request   = request
            };

            _context.AnsweredPickupRequests.Add(ans);
            _context.SaveChanges();
        }
コード例 #12
0
        //Dispatch services
        public int SchedulePickupRequest(PickupRequest request)
        {
            //Add a new pickup request
            int id = 0;

            try {
                id = new DispatchGateway().InsertPickupRequest3(request);
            }
            catch (Exception ex) { throw new FaultException <DispatchFault>(new DispatchFault(ex.Message), "Service Error"); }
            return(id);
        }
コード例 #13
0
        bool IPickupRequestRepository.IsAnswered(int id)
        {
            PickupRequest req = _context.PickupRequests.Include(r => r.Answered).FirstOrDefault(r => r.PickupRequestID == id);

            if (req == null)
            {
                return(false);
            }

            return(req.Answered != null);
        }
コード例 #14
0
        public IActionResult ModifyPickupRequest([FromBody] PickupRequest pickupRequest)
        {
            var result = _database.UpdatePickupRequest(pickupRequest);

            if (result)
            {
                return(NoContent());
            }
            else
            {
                return(BadRequest());
            }
        }
コード例 #15
0
        void IPickupRequestRepository.Edit(PickupRequest request)
        {
            PickupRequest existingRequest = _context.PickupRequests.FirstOrDefault(r => request.PickupRequestID == r.PickupRequestID);

            if (existingRequest == null)
            {
                return;
            }

            existingRequest.RequestedAddress = request.RequestedAddress;
            existingRequest.RequestedTime    = request.RequestedTime;

            _context.Update(existingRequest);
            _context.SaveChanges();
        }
コード例 #16
0
        public int RequestPickup(PickupRequest request)
        {
            //Create a new pickup request
            int pickupID = 0;
            DispatchClientServiceClient client = new DispatchClientServiceClient();

            try {
                pickupID = client.RequestPickup(request);
                client.Close();
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message, te); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message, fe); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message, ce); }
            return(pickupID);
        }
コード例 #17
0
        public bool UpdatePickup(PickupRequest pickup)
        {
            //Update an existing pickup request
            bool updated = false;
            DispatchClientServiceClient client = new DispatchClientServiceClient();

            try {
                updated = client.UpdatePickup(pickup);
                client.Close();
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message, te); }
            catch (FaultException <DispatchFault> dfe) { client.Abort(); throw new ApplicationException(dfe.Detail.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message, fe); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message, ce); }
            return(updated);
        }
コード例 #18
0
        public PickupRequest ReadPickup(int requestID)
        {
            //Read an existing pickup request
            PickupRequest request = null;
            DispatchClientServiceClient client = new DispatchClientServiceClient();

            try {
                request = client.ReadPickup(requestID);
                client.Close();
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message, te); }
            catch (FaultException <DispatchFault> dfe) { client.Abort(); throw new ApplicationException(dfe.Detail.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message, fe); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message, ce); }
            return(request);
        }
コード例 #19
0
 public void addPickupReq(PickupRequest req)
 {
     if (curStop == req.getStop())
     {
         if (destinations.Count == 0)
         {
             idle = true;
         }
         return;
     }
     idle         = false;
     reqGoingLeft = req.isGoingLeft();
     cabGoingLeft = (curStop > req.getStop()) ? false : true;
     destinations = !(reqGoingLeft) ? new PriorityQueue <int>(true) : new PriorityQueue <int>();
     destinations.Enqueue(req.getStop());
     destStop = destinations.Peek();
 }
コード例 #20
0
        static async System.Threading.Tasks.Task Main(string[] args)
        {
            Console.WriteLine("Calling a GRPC Service");
            Console.WriteLine("Hit enter to call the service....");
            Console.ReadLine();

            using var channel = GrpcChannel.ForAddress("https://localhost:5001");

            var client = new Greeter.GreeterClient(channel);

            var reply = await client.SayHelloAsync(new HelloRequest { Name = "Putintane" });

            Console.WriteLine($"Got the response - {reply.Message}");

            //Console.WriteLine("Hit enter to get directions...");
            //Console.ReadLine();

            //var clientRouting = new TurnByTurn.TurnByTurnClient(channel);

            //var destination = new Destination { DestinationName = "Taco Bell" };

            //var replyRoute = clientRouting.StartGuidance(destination);

            //await foreach (var step in replyRoute.ResponseStream.ReadAllAsync())
            //{
            //    Console.WriteLine($"Turn {step.Direction} at {step.Road}");
            //}

            //Console.WriteLine("You have arrived. Enjoy your tacos.");

            Console.WriteLine("Hit enter to estimate your order pickup date");
            Console.ReadLine();

            var estimatorClient = new PickupEstimator.PickupEstimatorClient(channel);

            var pickupRequest = new PickupRequest
            {
                For = "Jeff"
            };

            pickupRequest.Items.AddRange(new int[] { 1, 2, 3, 4, 5, 6, 7 });

            var estimatorResponse = await estimatorClient.GetPickupTimeAsync(pickupRequest);

            Console.WriteLine($"That'll be ready on {estimatorResponse.PickupTime.ToDateTime().ToShortDateString()}");
        }
コード例 #21
0
ファイル: DispatchGateway.cs プロジェクト: jpheary/Argix10
        public bool InsertPickupRequest(PickupRequest request)
        {
            //
            bool inserted = false;

            try {
                inserted = new DataService().ExecuteNonQuery(SQL_CONNID, USP_PICKUPREQUEST_INSERT,
                                                             new object[] {
                    request.Created, request.CreateUserID, request.ScheduleDate, request.CallerName, request.ClientNumber, request.Client,
                    request.ShipperNumber, request.Shipper, request.ShipperAddress, request.ShipperPhone, request.WindowOpen, request.WindowClose,
                    request.TerminalNumber, request.Terminal, request.DriverName, request.OrderType,
                    request.Amount, request.AmountType, request.FreightType, request.Weight,
                    request.Comments, request.IsTemplate, request.LastUpdated, request.UserID
                });
            }
            catch (Exception ex) { throw new ApplicationException(ex.Message, ex); }
            return(inserted);
        }
コード例 #22
0
ファイル: PickupRequest.aspx.cs プロジェクト: jpheary/Argix10
    //Interface
    protected void Page_Load(object sender, EventArgs e)
    {
        //Page load event handler
        try {
            if (!Page.IsPostBack)
            {
                int id = int.Parse(Request.QueryString["pickupid"]);
                if (id > 0)
                {
                    this.mPickup = new FreightClientGateway().ReadPickup(id);
                    ViewState.Add("Pickup", this.mPickup);

                    //Populate form fields from existing
                    this.txtPickupDate.Text    = this.mPickup.ScheduleDate.ToString("MM/dd/yyyy");
                    this.txtShipperName.Text   = this.mPickup.Shipper;
                    this.txtShipperStreet.Text = this.mPickup.ShipperAddress.Split(new string[] { "\r\n" }, StringSplitOptions.None)[0];
                    this.txtShipperCity.Text   = this.mPickup.ShipperAddress.Split(new string[] { "\r\n" }, StringSplitOptions.None)[1].Split(new string[] { ", " }, StringSplitOptions.None)[0];
                    this.txtShipperState.Text  = this.mPickup.ShipperAddress.Split(new string[] { "\r\n" }, StringSplitOptions.None)[1].Split(new string[] { ", " }, StringSplitOptions.None)[1].Split(new string[] { " " }, StringSplitOptions.None)[0];
                    this.txtShipperZip.Text    = this.mPickup.ShipperAddress.Split(new string[] { "\r\n" }, StringSplitOptions.None)[1].Split(new string[] { ", " }, StringSplitOptions.None)[1].Split(new string[] { " " }, StringSplitOptions.None)[1];
                    this.txtShipperPhone.Text  = this.mPickup.ShipperPhone;
                    this.txtWindowOpen.Text    = this.mPickup.WindowOpen.ToString().PadLeft(4, '0');
                    this.txtWindowClose.Text   = this.mPickup.WindowClose.ToString().PadLeft(4, '0');
                    this.txtQuantity.Text      = this.mPickup.Amount.ToString();
                    this.txtWeight.Text        = this.mPickup.Weight.ToString();
                    this.txtComments.Text      = this.mPickup.Comments;

                    //Set read only fields
                    this.txtShipperZip.ReadOnly = this.txtConsigneeZip.ReadOnly = this.txtShipperStreet.ReadOnly = this.txtShipperCity.ReadOnly = this.txtShipperState.ReadOnly = id > 0;
                }
                else
                {
                    this.txtWindowOpen.Text  = "09:00";
                    this.txtWindowClose.Text = "17:00";
                }
                this.lblClientName.Text = Master.CurrentClient.Name;
            }
            else
            {
                this.mPickup = ViewState["Pickup"] != null ? (PickupRequest)ViewState["Pickup"] : null;
            }
        }
        catch (Exception ex) { Master.ReportError(ex, 3); }
    }
コード例 #23
0
ファイル: DispatchGateway.cs プロジェクト: jpheary/Argix10
        public int InsertPickupRequest3(PickupRequest request)
        {
            //
            int id = 0;

            try {
                object o = new DataService().ExecuteNonQueryWithReturn(SQL_CONNID, USP_PICKUPREQUEST_INSERT3,
                                                                       new object[] {
                    null, request.Created, request.CreateUserID, request.ScheduleDate, request.CallerName, request.ClientNumber, request.Client,
                    request.ShipperNumber, request.Shipper, request.ShipperAddress, request.ShipperPhone, request.WindowOpen, request.WindowClose,
                    request.TerminalNumber, request.Terminal, request.DriverName, request.OrderType,
                    request.Amount, request.AmountType, request.FreightType, request.Weight,
                    request.Comments, request.IsTemplate, request.LastUpdated, request.UserID
                });
                id = Convert.ToInt32(o);
            }
            catch (Exception ex) { throw new ApplicationException(ex.Message, ex); }
            return(id);
        }
コード例 #24
0
        Leg IPickupRequestRepository.GetAnswerLeg(int id)
        {
            PickupRequest req = _context.PickupRequests.Include(r => r.Answered)
                                .Include(r => r.Answered.AnswerLeg).FirstOrDefault(r => r.PickupRequestID == id);

            if (req == null)
            {
                return(null);
            }

            AnsweredPickupRequest ans = req.Answered;

            if (ans == null)
            {
                return(null);
            }

            return(ans.AnswerLeg);
        }
コード例 #25
0
        public bool AddPickupRequest(PickupRequest request)
        {
            //Add a new pickup request
            bool added = false;

            try {
                //Apply simple business rules

                //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()) {
                    //
                    added = new DispatchGateway().InsertPickupRequest(request);

                    //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(added);
        }
コード例 #26
0
ファイル: DispatchGateway.cs プロジェクト: jpheary/Argix10
        public bool UpdatePickupRequest(PickupRequest request)
        {
            //
            bool updated = false;

            try {
                updated = new DataService().ExecuteNonQuery(SQL_CONNID, USP_PICKUPREQUEST_UPDATE,
                                                            new object[] {
                    request.RequestID, request.ScheduleDate, request.CallerName, request.ClientNumber, request.Client,
                    request.ShipperNumber, request.Shipper, request.ShipperAddress, request.ShipperPhone, request.WindowOpen, request.WindowClose,
                    request.TerminalNumber, request.Terminal, request.DriverName,
                    (request.ActualPickup != DateTime.MinValue ? request.ActualPickup : null as object),
                    request.OrderType,
                    request.Amount, request.AmountType, request.FreightType, request.Weight,
                    request.Comments, request.LastUpdated, request.UserID
                });
            }
            catch (Exception ex) { throw new ApplicationException(ex.Message, ex); }
            return(updated);
        }
コード例 #27
0
        public override Task <PickupResponse> GetPickupTime(PickupRequest request, ServerCallContext context)
        {
            //for orders under 5 items, tomorrow, over five items, two days.
            int days = 0;

            if (request.Items.Count <= 5)
            {
                days = 1;
            }
            else
            {
                days = 2;
            }
            var response = new PickupResponse
            {
                PickupTime = Timestamp.FromDateTime(DateTime.Now.AddDays(days).ToUniversalTime())
            };

            return(Task.FromResult(response));
        }
コード例 #28
0
        static async Task Main(string[] args)
        {
            Console.WriteLine("Calling a gRPC Service");
            Console.WriteLine("Hit Enter to call the service!");
            Console.ReadLine();

            using var channel = GrpcChannel.ForAddress("https://localhost:5001");

            var client = new Greeter.GreeterClient(channel);
            var reply  = await client.SayHelloAsync(new HelloRequest { Name = "Chris" });

            Console.WriteLine($"Got a response - {reply.Message}");
            Console.ReadLine();

            //Console.WriteLine("Hit enter to get directions...");
            //Console.ReadLine();

            //var clientRouting = new TurnByTurn.TurnByTurnClient(channel);
            //var destination = new Destination { DestinationName = "Taco Bell" };
            //var replyRoute = clientRouting.StartGuidance(destination);

            //await foreach(var step in replyRoute.ResponseStream.ReadAllAsync())
            //{
            //	Console.WriteLine(step);
            //}

            Console.ReadLine();

            var estimatorClient = new PickupEstimator.PickupEstimatorClient(channel);

            var pickupRequest = new PickupRequest
            {
                For = "Chris",
            };

            pickupRequest.Items.AddRange(new int[] { 1, 2, 3, 4 });

            var estimatorResponse = await estimatorClient.GetPickupTimeAsync(pickupRequest);

            Console.WriteLine($"Order will be ready on {estimatorResponse.PickupTime.ToDateTime().ToShortDateString()}");
        }
コード例 #29
0
        public PickupRequest ReadPickup(int requestID)
        {
            //Read an existing pickup request
            PickupRequest request = null;

            try {
                //
                DataSet ds = new DispatchGateway().GetPickupRequest(requestID);
                if (ds != null)
                {
                    DispatchDataset _request = new DispatchDataset();
                    _request.Merge(ds);
                    if (_request.PickupLogTable.Rows.Count > 0)
                    {
                        request = new PickupRequest(_request.PickupLogTable[0]);
                    }
                }
            }
            catch (Exception ex) { throw new FaultException <DispatchFault>(new DispatchFault(ex.Message), "Service Error"); }
            return(request);
        }
コード例 #30
0
        public void Assign(PickupRequest request, Driver driver)
        {
            // search for the PickupDriverAssignment corresponding to this driver
            PickupDriverAssignment assignment = _context.PickupDriverAssignments.FirstOrDefault(a => a.Request == request);

            if (assignment == null)
            {
                assignment = new PickupDriverAssignment
                {
                    AssignedDriver = driver,
                    Request        = request
                };
                _context.PickupDriverAssignments.Add(assignment);
            }
            else
            {
                assignment.AssignedDriver = driver;
            }

            _context.SaveChanges();
        }