Пример #1
0
        /// <summary>
        /// Creates the De object
        /// </summary>
        /// <returns>Status code for the post.  Returns -1 if there was an exception</returns>
        /// <param name="lat">Lat.</param>
        /// <param name="lon">Lon.</param>
        /// <param name="name">Name.</param>
        /// <param name="agency">Agency.</param>
        /// <param name="postURL">Post URL.</param>
        /// <param name="resourceType">Resource type.</param>
        /// <param name="eventDetails">Event details.</param>
        public static async Task sendUpdate(double lat, double lon, string name, string agency, string postURL, string resourceType, List <EventDetails> eventDetails)
        {
            try
            {
                // Creating DE
                DEv1_0 de = new DEv1_0();
                de.ContentObjects = new List <EMS.EDXL.DE.ContentObject>();

                de.DistributionID          = name;
                de.DateTimeSent            = DateTime.Now;
                de.DistributionStatus      = StatusValue.Test;
                de.DistributionType        = TypeValue.Update;
                de.CombinedConfidentiality = "Unclassified";

                // Creating Event
                Event newEvent = new Event();
                newEvent.EventTypeDescriptor            = new EventTypeDescriptor();
                newEvent.EventLocation                  = new EventLocation();
                newEvent.EventLocation.LocationCylinder = new LocationCylinder();
                newEvent.EventLocation.LocationCylinder.LocationPoint       = new LocationPoint();
                newEvent.EventLocation.LocationCylinder.LocationPoint.Point = new Point();

                newEvent.EventID = de.DistributionID;
                de.SenderID      = name + "." + agency + "@watchtower";
                newEvent.EventTypeDescriptor.EventTypeCode = resourceType;
                newEvent.Details = eventDetails;

                newEvent.EventMessageDateTime = DateTime.Now;
                newEvent.EventValidityDateTimeRange.StartDate = DateTime.Now;
                newEvent.EventValidityDateTimeRange.EndDate   = DateTime.Now.AddMinutes(30);

                newEvent.EventLocation.LocationCylinder.LocationPoint.Point.Lat = lat;
                newEvent.EventLocation.LocationCylinder.LocationPoint.Point.Lon = lon;

                Debug.WriteLine(newEvent.ToString());

                // Serializing Event to XML
                XElement xml = XElement.Parse(newEvent.ToString());

                // Adding the Event to DE as a content object
                EMS.EDXL.DE.ContentObject co = new EMS.EDXL.DE.ContentObject();
                co.XMLContent = new XMLContentType();
                co.XMLContent.AddEmbeddedXML(xml);
                de.ContentObjects.Add(co);

                await sendMessage(de, postURL);
            }
            catch (Exception e)
            {
                // log
            }
        }
Пример #2
0
        /// <summary>
        /// Sends the location.
        /// </summary>
        /// <returns>The location.</returns>
        /// <param name="lat">Lat.</param>
        /// <param name="lon">Lon.</param>
        /// <param name="url">URL.</param>
        /// <param name="name">Name.</param>
        /// <param name="agency">Agency.</param>
        /// <param name="resourceType">Resource type.</param>
        /// <param name="eventDetails">Event details.</param>
        public static async Task SendLocation(double lat, double lon, string url, string name, string agency, string resourceType, List <EventDetails> eventDetails)
        {
            DEv1_0         de       = new DEv1_0();
            Event          newEvent = new Event();
            ResourceDetail resource = new ResourceDetail();

            resource.Status = new ResourceStatus();
            //resource.Status.SecondaryStatus = new List<AltStatus>();
            resource.setPrimaryStatus(ResourcePrimaryStatusCodeList.Available);
            resource.OwningOrg            = new ResourceOrganization();
            resource.OwningOrg.ResourceID = name;
            // resource.AddSecondaryStatusText("Test", "001");
            newEvent.EventTypeDescriptor = new EventTypeDescriptor();
            newEvent.EventTypeDescriptor.EventTypeCode = resourceType;
            //EventTypeCodeList.ATOM_GRDTRK_EQT_GRDVEH_CVLVEH_EM_EMS_AMBULANCE.ToString();
            de.SenderID                = name + "." + agency + "@watchtower";
            de.DistributionID          = name;
            de.DateTimeSent            = DateTime.Now;
            de.DistributionStatus      = StatusValue.Test;
            de.DistributionType        = TypeValue.Update;
            de.CombinedConfidentiality = "Unclassified";

            // add resource details at beginning
            eventDetails.Insert(0, resource);
            newEvent.Details = eventDetails;
            newEvent.EventID = de.DistributionID;
            newEvent.EventMessageDateTime = DateTime.Now;
            newEvent.EventValidityDateTimeRange.StartDate = DateTime.Now;
            newEvent.EventValidityDateTimeRange.EndDate   = DateTime.Now.AddMinutes(30);

            newEvent.EventLocation = new EventLocation();
            newEvent.EventLocation.LocationCylinder = new LocationCylinder();
            newEvent.EventLocation.LocationCylinder.LocationPoint           = new LocationPoint();
            newEvent.EventLocation.LocationCylinder.LocationPoint.Point     = new Point();
            newEvent.EventLocation.LocationCylinder.LocationPoint.Point.Lat = lat;
            newEvent.EventLocation.LocationCylinder.LocationPoint.Point.Lon = lon;


            de.ContentObjects = new List <EMS.EDXL.DE.ContentObject>();

            //Debug.WriteLine(newEvent.ToString());

            XElement xml = XElement.Parse(newEvent.ToString());

            EMS.EDXL.DE.ContentObject co = new EMS.EDXL.DE.ContentObject();
            co.XMLContent = new XMLContentType();
            co.XMLContent.AddEmbeddedXML(xml);
            de.ContentObjects.Add(co);

            await sendMessage(de, url);
        }