Exemplo n.º 1
0
        public PassengerBaggage(Flight flight, Passenger passenger, BaggageLimits baggageLimits)
        {
            if (flight == null)
            {
                throw new ArgumentNullException(nameof(flight));
            }
            if (passenger == null)
            {
                throw new ArgumentNullException(nameof(passenger));
            }

            baggage = new List <PassengerBag>();

            PassengerId = PassengerId.Of(passenger.Id);
            FlightId    = FlightId.Of(flight.Id);

            Limits = baggageLimits ?? throw new ArgumentNullException(nameof(baggageLimits));
        }
Exemplo n.º 2
0
 public PassengerBag(PassengerId passengerId, Guid guid, int weight)
 {
     PassengerId = passengerId;
     Guid        = guid;
     Weight      = weight;
 }
Exemplo n.º 3
0
 public CheckedInPassenger(PassengerId passengerId, Guid boardingPassGuid)
 {
     PassengerId      = passengerId ?? throw new ArgumentNullException(nameof(passengerId));
     BoardingPassGuid = boardingPassGuid;
 }
Exemplo n.º 4
0
 public CheckedInPassenger(Passenger passenger)
     : this(PassengerId.Of(passenger.Id), Guid.NewGuid())
 {
 }
Exemplo n.º 5
0
        protected override void Execute(CodeActivityContext executionContext)
        {
            // Create the context
            IWorkflowContext            context        = executionContext.GetExtension <IWorkflowContext>();
            IOrganizationServiceFactory serviceFactory = executionContext.GetExtension <IOrganizationServiceFactory>();
            IOrganizationService        service        = serviceFactory.CreateOrganizationService(context.UserId);
            ITracingService             tracingService = executionContext.GetExtension <ITracingService>();

            try
            {
                JSONRequestResponse request = new JSONRequestResponse();
                request.InputObj = new TitanicPlugins.Input1();
                //request.inputObj2 = new Dictionary<string, string>() { };
                Input    input   = new Input();
                string[] columns = { "PassengerId", "Age", "Cabin", "Embarked", "Fare", "Name", "Parch", "Pclass", "SibSp", "Sex", "Ticket", "Survived" };
                object[] values  = { PassengerId.Get(executionContext), Age.Get(executionContext),    Cabin.Get(executionContext), Embarked.Get(executionContext), Fare.Get(executionContext),   Name.Get(executionContext),
                                     Parch.Get(executionContext),        Pclass.Get(executionContext), SibSp.Get(executionContext), Sex.Get(executionContext),      Ticket.Get(executionContext), Survived.Get(executionContext) };
                input.Columns           = columns;
                input.Values            = new object[][] { values };
                request.InputObj.Inputs = new Input();
                request.InputObj.Inputs = input;

                System.Runtime.Serialization.Json.DataContractJsonSerializer serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(request.GetType());
                MemoryStream ms = new MemoryStream();
                serializer.WriteObject(ms, request);
                string jsonMsg = Encoding.Default.GetString(ms.ToArray());

                const string endpoint = "https://ussouthcentral.services.azureml.net/workspaces/92e7c840c83f4673ac594e767da8b538/services/e8b5c75d168345189225fcb5eab964d5/execute?api-version=2.0";
                const string apiKey   = "PjAGXQN7aI8FhJ+bVPi7wFEt6QeUzLMTkx7FTkOcjxakVv2Fq4r8VNdnirlK2tBSIqp58sF4UiJ1tXT+l2eiTQ==";

                System.Net.WebRequest req = System.Net.WebRequest.Create(endpoint);
                req.ContentType = "application/json";
                req.Method      = "POST";
                req.Headers.Add(string.Format("Authorization:Bearer {0}", apiKey));


                //create a stream
                byte[] bytes = System.Text.Encoding.ASCII.GetBytes(jsonMsg.ToString());
                req.ContentLength = bytes.Length;
                System.IO.Stream os = req.GetRequestStream();
                os.Write(bytes, 0, bytes.Length);
                os.Close();

                //get the response
                System.Net.WebResponse resp = req.GetResponse();

                Stream responseStream = CopyAndClose(resp.GetResponseStream());
                // Do something with the stream
                StreamReader reader         = new StreamReader(responseStream, Encoding.UTF8);
                String       responseString = reader.ReadToEnd();
                tracingService.Trace("json response: {0}", responseString);

                responseStream.Position = 0;
                //deserialize the response to a myjsonresponse object
                JsonResponse myResponse = new JsonResponse();
                System.Runtime.Serialization.Json.DataContractJsonSerializer deserializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(myResponse.GetType());
                myResponse = deserializer.ReadObject(responseStream) as JsonResponse;

                tracingService.Trace("Scored Label- " + myResponse.Results.Output1.Value.Values[0][9]);
                tracingService.Trace("Scored Probablility- " + myResponse.Results.Output1.Value.Values[0][10]);

                ScoredLabel.Set(executionContext, myResponse.Results.Output1.Value.Values[0][9]);
                ScoredProbability.Set(executionContext, myResponse.Results.Output1.Value.Values[0][10]);
            }
            catch (WebException exception)
            {
                string str = string.Empty;
                if (exception.Response != null)
                {
                    using (StreamReader reader =
                               new StreamReader(exception.Response.GetResponseStream()))
                    {
                        str = reader.ReadToEnd();
                    }
                    exception.Response.Close();
                }
                if (exception.Status == WebExceptionStatus.Timeout)
                {
                    throw new InvalidPluginExecutionException(
                              "The timeout elapsed while attempting to issue the request.", exception);
                }
                throw new InvalidPluginExecutionException(String.Format(CultureInfo.InvariantCulture,
                                                                        "A Web exception ocurred while attempting to issue the request. {0}: {1}",
                                                                        exception.Message, str), exception);
            }
            catch (FaultException <OrganizationServiceFault> e)
            {
                tracingService.Trace("Exception: {0}", e.ToString());

                // Handle the exception.
                throw;
            }
            catch (Exception e)
            {
                tracingService.Trace("Exception: {0}", e.ToString());
                throw;
            }
        }
Exemplo n.º 6
0
 public AircraftBaggageOverweightException(Flight flight, PassengerId passengerId)
     : base($"Passenger [{passengerId}] can't check in baggage to the flight [{flight}] due to overweight.")
 {
     Flight      = flight;
     PassengerId = passengerId;
 }
Exemplo n.º 7
0
 protected bool Equals(PassengerId other)
 {
     return(value == other.value);
 }