public static void addLocation(portCallMessage pcm)
        {
            //APPEND WITH LOCATIONSTATE ARRIVAL(TO AND FROM)
            if (pcm.locationState != null)
            {
                string locationFrom = pcm.locationState.arrivalLocation.from.locationMRN;
                string locationTo   = pcm.locationState.arrivalLocation.to.locationMRN;
                departureMessage.Append(NiceString(locationFrom) + " -> " + NiceString(locationTo));
            }

            //APPEND WITH LOCATIONSTATE DEPARTURE(TO AND FROM)
            if (pcm.locationState != null)
            {
                string locationFrom = pcm.locationState.departureLocation.from.locationMRN;
                string locationTo   = pcm.locationState.departureLocation.to.locationMRN;
                departureMessage.Append(NiceString(locationFrom) + " -> " + NiceString(locationTo));
            }

            //APPEND WITH SERVICESTATE POSTITION AT
            if (pcm.serviceState != null)
            {
                string locationAt = pcm.serviceState.at.locationMRN;
                departureMessage.Append("at " + NiceString(locationAt) + " ");
            }
        }
Ejemplo n.º 2
0
        private string getKey(portCallMessage pcm)
        {
            string key = "";

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

            key += pcm.portCallId;
            if (isLocationState(pcm))
            {
                LocationState ls = pcm.locationState;
                key += ls.referenceObject.ToString();
                key += ls.time.ToString();
                if (ls.arrivalLocation != null)
                {
                    LocationStateArrivalLocation al = ls.arrivalLocation;
                    if (al.from != null)
                    {
                        key += al.from.locationMRN ?? "";
                    }
                    if (al.to != null)
                    {
                        key += al.to.locationMRN ?? "";
                    }
                }
                if (ls.departureLocation != null)
                {
                    LocationStateDepartureLocation dl = ls.departureLocation;
                    if (dl.from != null)
                    {
                        key += dl.from.locationMRN ?? "";
                    }
                    if (dl.to != null)
                    {
                        key += dl.to.locationMRN ?? "";
                    }
                }
            }
            else
            {
                ServiceState ss = pcm.serviceState;
                key += ss.serviceObject;
                key += ss.time;
                if (ss.at != null)
                {
                    key += ss.at.locationMRN ?? "";
                }
                else if (ss.between != null)
                {
                    ServiceStateBetween b = ss.between;
                    key += b.from.locationMRN ?? "";
                    key += b.to.locationMRN ?? "";
                }
            }

            return(key);
        }
 public static DateTime LocationOrService(portCallMessage pcm)
 {
     if (pcm.locationState != null)
     {
         return(pcm.locationState.time);
     }
     else
     {
         return(pcm.serviceState.time);
     }
 }
Ejemplo n.º 4
0
        public static async Task <string> createPCM(portCallMessage pcm)
        {
            PrepareRestCall.postXML();

            string xml = toXML(pcm);

            var response = await PrepareRestCall.HttpClientInstance.PostAsync("mb/mss", new StringContent(xml, Encoding.UTF8, "application/xml"));

            string result = response.ReasonPhrase + " - " + response.Content.ReadAsStringAsync().Result;

            return(result);
        }
 public static void addObject(portCallMessage pcm)
 {
     //APPEND WITH LOCATIONSTATE REFERENCEOBJECT
     if (pcm.locationState != null)
     {
         departureMessage.Append(pcm.locationState.referenceObject + " ");
     }
     //APPEND WITH SERVICESTATE SERVICEOBJECT
     if (pcm.serviceState != null)
     {
         departureMessage.Append(pcm.serviceState.serviceObject + " ");
     }
 }
 public static void addTime(portCallMessage pcm)
 {
     //APPEND WITH LOCATIONSTATE TIME
     if (pcm.locationState != null)
     {
         object niceDate = NiceDate(pcm.locationState.time);
         departureMessage.Append(niceDate + " ");
     }
     //APPEND WITH SERVICESTATE TIME
     if (pcm.serviceState != null)
     {
         object niceDate = NiceDate(pcm.serviceState.time);
         departureMessage.Append(niceDate + " ");
     }
 }
Ejemplo n.º 7
0
        public void add(portCallMessage pcm)
        {
            string key = getKey(pcm);

            if (pcmGroups.ContainsKey(key))
            {
                pcmGroups[key].Add(pcm);
            }
            else
            {
                List <portCallMessage> pcms = new List <portCallMessage>();
                pcms.Add(pcm);
                pcmGroups.Add(key, pcms);
            }
        }
        public static void appendMessageInfo(portCallMessage pcm)
        {
            //APPEND WITH SERVICESTATE TIMESEQUENCE(COMMENCED / COMPLETED)
            if (pcm.serviceState != null)
            {
                switch (pcm.serviceState.timeSequence)
                {
                case (ServiceTimeSequence.COMMENCED):
                case (ServiceTimeSequence.COMPLETED):
                    addTime(pcm);
                    addObject(pcm);
                    addLocation(pcm);
                    departureMessage.Append(pcm.serviceState.timeSequence + "<br />");
                    break;

                default:
                    break;
                }
            }
        }
Ejemplo n.º 9
0
        static string toXML(portCallMessage pcm)
        {
            pcm.namespaces = new XmlSerializerNamespaces(new XmlQualifiedName[]
            {
                new XmlQualifiedName(string.Empty, "urn:mrn:stm:schema:port-call-message:0.6")
            });
            XmlSerializer xs = new XmlSerializer(typeof(portCallMessage), new XmlRootAttribute("portCallMessage")
            {
                Namespace = "urn:mrn:stm:schema:port-call-message:0.6"
            });
            StringWriter sw = new StringWriter();

            XmlWriterSettings xws = new XmlWriterSettings();

            xws.OmitXmlDeclaration = true;
            xws.Encoding           = Encoding.UTF8;
            xws.Indent             = true;

            XmlWriter xtw = XmlWriter.Create(sw, xws);

            xs.Serialize(xtw, pcm, pcm.namespaces);

            return(sw.ToString());
        }
Ejemplo n.º 10
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);
        }
        protected void rptr_ItemDataBound(Object Sender, RepeaterItemEventArgs e)
        {
            Literal boxHeader = (Literal)e.Item.FindControl("boxHeader");

            List <portCallMessage> list = (List <portCallMessage>)e.Item.DataItem;

            portCallMessage pcm = list[0];

            if (PortCallMessageGrouper.isLocationState(pcm))
            {
                if (pcm.locationState.arrivalLocation != null)
                {
                    if (pcm.locationState.arrivalLocation.to != null)
                    {
                        boxHeader.Text += "To: " + getLocationName(fixTrafficAreaBug(pcm.locationState.arrivalLocation.to.locationMRN));
                        if (pcm.locationState.arrivalLocation.from != null)
                        {
                            boxHeader.Text += "<br />";
                        }
                    }
                    if (pcm.locationState.arrivalLocation.from != null)
                    {
                        boxHeader.Text += "From: " + getLocationName(fixTrafficAreaBug(pcm.locationState.arrivalLocation.from.locationMRN)).ToString();
                    }
                }
                else if (pcm.locationState.departureLocation != null)
                {
                    if (pcm.locationState.departureLocation.to != null)
                    {
                        boxHeader.Text += "To: " + getLocationName(fixTrafficAreaBug(pcm.locationState.departureLocation.to.locationMRN));
                        if (pcm.locationState.departureLocation.from != null)
                        {
                            boxHeader.Text += "<br />";
                        }
                    }
                    if (pcm.locationState.departureLocation.from != null)
                    {
                        boxHeader.Text += "From: " + getLocationName(fixTrafficAreaBug(pcm.locationState.departureLocation.from.locationMRN));
                    }
                }
            }
            else
            {
                boxHeader.Text += FirstCharToUpper(pcm.serviceState.serviceObject.ToString()) + "<br />";
                if (pcm.serviceState.at != null)
                {
                    boxHeader.Text += "At: " + getLocationName(fixTrafficAreaBug(pcm.serviceState.at.locationMRN));
                }
                else
                {
                    boxHeader.Text += "To: " + getLocationName(fixTrafficAreaBug(pcm.serviceState.between.to.locationMRN));
                    boxHeader.Text += "<br />From: " + getLocationName(fixTrafficAreaBug(pcm.serviceState.between.from.locationMRN));
                }
            }


            Repeater timeRepeater = (Repeater)e.Item.FindControl("timeRepeater");
            Repeater boxRepeater  = (Repeater)e.Item.FindControl("boxRepeater");

            timeRepeater.DataSource = e.Item.DataItem;
            timeRepeater.DataBind();
            boxRepeater.DataSource = e.Item.DataItem;
            boxRepeater.DataBind();
        }
Ejemplo n.º 12
0
 public static bool isLocationState(portCallMessage pcm)
 {
     return(pcm.locationState != null);
 }
Ejemplo n.º 13
0
 public PortCallMessageGrouper(portCallMessage pcm) : this()
 {
     add(pcm);
 }