protected object newTime(object o)
        {
            String      s    = (String)o;
            DateHandler dh   = new DateHandler();
            DateTime    time = dh.stringToDate(s);

            o = time.ToString("d MMM HH:mm");
            return(o);
        }
Exemple #2
0
        private async Task <portCallMessage> genMessage()
        {
            //----------- Message ---------------
            var message = new portCallMessage
            {
                portCallId = portCallIdHiddenField.Value,
                vesselId   = "urn:mrn:stm:vessel:IMO:" + shipImoHiddenField.Value,
                messageId  = "urn:mrn:stm:portcdm:message:" + messageIdGenerator.generateMessageId(),
                reportedAt = dateHandler.getCurrentTimeString(),
                comment    = commentBox.Text
            };

            //--------- Service state -----------
            if (!locationStateChosen())
            {
                message.serviceState = new ServiceState();
                message.serviceState.serviceObject = (ServiceObject)Enum.Parse(typeof(ServiceObject),
                                                                               messageTypeHiddenField.Value);
                message.serviceState.timeSequence = (ServiceTimeSequence)Enum.Parse(typeof(ServiceTimeSequence),
                                                                                    serviceTimeSequenceDropDown.SelectedValue);
                message.serviceState.timeType = (TimeType)Enum.Parse(typeof(TimeType), timeTypeDropDown.SelectedValue);
                string serviceStateTime = setYearDropDown.SelectedValue + "-" + setMonthDropDown.SelectedValue + "-" +
                                          setDayDropDown.SelectedValue + "T" + setHourDropDown.SelectedValue + ":" + setMinuteDropDown.SelectedValue + ":00Z";
                message.serviceState.time = dateHandler.stringToDate(serviceStateTime);

                //--------- Service state, location At -----------
                if (atRadioButton.Checked)
                {
                    message.serviceState.at             = new Location();
                    message.serviceState.at.locationMRN = atLocationName.SelectedValue;
                }

                //--------- Service state, location between --------
                else if (betweenRadioButton.Checked)
                {
                    message.serviceState.between                  = new ServiceStateBetween();
                    message.serviceState.between.from             = new Location();
                    message.serviceState.between.from.locationMRN = fixTrafficAreaBug(fromLocationName.SelectedValue);
                    message.serviceState.between.to               = new Location();
                    message.serviceState.between.to.locationMRN   = fixTrafficAreaBug(toLocationName.SelectedValue);
                }
            }

            else
            {
                message.locationState = new LocationState();
                message.locationState.referenceObject = LocationReferenceObject.VESSEL;
                string locationStateTime = setYearDropDown.SelectedValue + "-" + setMonthDropDown.SelectedValue + "-" +
                                           setDayDropDown.SelectedValue + "T" + setHourDropDown.SelectedValue + ":" + setMinuteDropDown.SelectedValue + ":00Z";
                message.locationState.time     = dateHandler.stringToDate(locationStateTime);
                message.locationState.timeType = (TimeType)Enum.Parse(typeof(TimeType), timeTypeDropDown.SelectedValue);
                if (messageTypeHiddenField.Value == "DEPARTURE_VESSEL")
                {
                    message.locationState.departureLocation = new LocationStateDepartureLocation();
                    //------ Location State , departure location, from
                    if (fromCheckBox.Checked)
                    {
                        message.locationState.departureLocation.from             = new Location();
                        message.locationState.departureLocation.from.locationMRN = fixTrafficAreaBug(fromLocationName.SelectedValue);
                    }

                    //------ Location State , departure location, to
                    if (toCheckBox.Checked)
                    {
                        message.locationState.departureLocation.to             = new Location();
                        message.locationState.departureLocation.to.locationMRN = fixTrafficAreaBug(fromLocationName.SelectedValue);
                    }
                }
                else if (messageTypeHiddenField.Value == "ARRIVAL_VESSEL")
                {
                    message.locationState.arrivalLocation = new LocationStateArrivalLocation();
                    //------ Location State , arrival location, from
                    if (fromCheckBox.Checked)
                    {
                        message.locationState.arrivalLocation.from             = new Location();
                        message.locationState.arrivalLocation.from.locationMRN = fixTrafficAreaBug(fromLocationName.SelectedValue);
                    }

                    //------ Location State , arrival location, to
                    if (toCheckBox.Checked)
                    {
                        message.locationState.arrivalLocation.to             = new Location();
                        message.locationState.arrivalLocation.to.locationMRN = fixTrafficAreaBug(toLocationName.SelectedValue);
                    }
                }
            }
            return(message);
        }