예제 #1
0
        public CodingIncidentMessage ConvertDispatchedIncidentToCoding(gCAD.Shared.IntegrationContract.DispatchedIncident CADincidentMsg)
        {
            string codingID = _CallOut_CodingService.GetCodingID();

            CodingLocation incidentLocation = new CodingLocation();
            incidentLocation.Name = "N.A. Name";
            //incidentLocation.Name = CADincidentMsg.IncidentLocation.Name;
            incidentLocation.Street = CADincidentMsg.IncidentLocation.Street;
            incidentLocation.Unit = CADincidentMsg.IncidentLocation.Unit;
            incidentLocation.State = CADincidentMsg.IncidentLocation.State;
            incidentLocation.City = CADincidentMsg.IncidentLocation.City;
            incidentLocation.Country = "N.A. Country";
            //incidentLocation.Country = CADincidentMsg.IncidentLocation.Country;
            incidentLocation.PostalCode = CADincidentMsg.IncidentLocation.PostalCode;

            List<CodingUnits> tmpcodingunitList = new List<CodingUnits>();
            foreach (gCAD.Shared.IntegrationContract.DispatchedUnit unit in CADincidentMsg.ListOfUnits)
            {
                CodingUnits newUnit = new CodingUnits();
                newUnit.ID = unit.ID;
                newUnit.Callsign = unit.CallSign;
                newUnit.UnitType = "N.A. Unit Type";
                //newUnit.UnitType = unit.UnitType;
                newUnit.FromStatus = unit.Status;
                newUnit.UnitLocation = unit.Location;
                newUnit.UnitHomeStation = unit.HomeStation;
                newUnit.UnitCurrentStation = unit.CurrentStation;

                tmpcodingunitList.Add(newUnit);
            }

            CodingUnits[] dispatchUnits = tmpcodingunitList.ToArray();

            CodingIncidentMessage codingIncidentMsg = new CodingIncidentMessage();
            codingIncidentMsg.CodingID = codingID;
            codingIncidentMsg.IncidentNo = CADincidentMsg.IncidentNumber;
            codingIncidentMsg.IncidentTitle = "N.A. Incident Title";
            //codingIncidentMsg.IncidentTitle = CADincidentMsg.IncidentTitle;
            codingIncidentMsg.IncidentLocation = incidentLocation;
            codingIncidentMsg.IncidentType = CADincidentMsg.IncidentType;
            codingIncidentMsg.IncidentAlarm = CADincidentMsg.AlarmLevel;
            codingIncidentMsg.IncidentPriority = CADincidentMsg.Priority;
            codingIncidentMsg.DispatchDateTime = CADincidentMsg.DateTime;
            codingIncidentMsg.DispatchUnits = dispatchUnits;

            return codingIncidentMsg;
        }
예제 #2
0
        //------------------------------- for trying connection purpose---------------------------------------------
        public void RcvDispatchedIncidentMsg(gCAD.Shared.IntegrationContract.DispatchedIncident CADincidentMsg)
        {
            SendOrPostCallback callback =
                delegate (object state)
                {
                    List<string> tmpstationList = new List<string>();
                    List<Tracking> trackingList = new List<Tracking>();
                    //Only take out the stations on the Current Station
                    foreach (gCAD.Shared.IntegrationContract.DispatchedUnit uniqueunit in CADincidentMsg.ListOfUnits)
                    {
                        //Avoid duplicate station name in the list
                        if (!tmpstationList.Contains(uniqueunit.CurrentStation))
                        {
                            tmpstationList.Add(uniqueunit.CurrentStation);
                            Tracking newstation = new Tracking();
                            newstation.Station = uniqueunit.CurrentStation;
                            newstation.Status = "Pending";

                            List<string> unitcallsign = new List<string>();

                            //To give relevant station units callsign
                            foreach (gCAD.Shared.IntegrationContract.DispatchedUnit unit in CADincidentMsg.ListOfUnits)
                            {
                                if (unit.CurrentStation.Equals(uniqueunit.CurrentStation))
                                {
                                    unitcallsign.Add(unit.CallSign);
                                }
                            }

                            newstation.Unit = unitcallsign.ToArray();
                            trackingList.Add(newstation); //Add into tracking list
                        }
                    }

                    string[] addressList = tmpstationList.ToArray();

                    //Convert Incident to Coding Message and send to respective console
                    CodingIncidentMessage codingincidentmsg = ConvertDispatchedIncidentToCoding(CADincidentMsg);
                    ConvertCodingtoTracker(addressList, codingincidentmsg); //Add to gateway tracker
                    Log("Forward message from Real CAD to respective console");
                    _CallOut_CodingService.TargetMsg(addressList, codingincidentmsg);

                    //Send ack back to CAD
                    foreach (Tracking station in trackingList)
                    {
                        string Comment = station.Station + " " + station.Status;
                        CallAPI(CADincidentMsg.IncidentNumber, Comment);
                    }

                    //Set Coding Entry
                    CreateCodingEntry(codingincidentmsg, tmpstationList.Count.ToString());
                    //Set Message Entry
                    CreateMessageEntry(codingincidentmsg, tmpstationList.Count.ToString());

                };

            _uiSyncContext.Post(callback, "Rcv Incident Message");
        }