Пример #1
0
        private bool CheckKey(string key)
        {
            bool CheckKeyRet = default;

            CheckKeyRet = true;
            var dbServiceSites = new dbServiceSites();

            dbServiceSites.GetSitebyKey(ref key);
            if (dbServiceSites.ID < 1)
            {
                // key not found
                var ServiceCallErr = new clsServiceCalls()
                {
                    ESSIncident = new clsServiceCalls.IncidentList()
                    {
                        IncidentNumber   = "",
                        ErrorDescription = "key not found"
                    }
                };
                dbServiceSites.Dispose();
                Context.Response.ContentType = "application/json; charset=utf-8";
                Context.Response.Write(JsonConvert.SerializeObject(ServiceCallErr));
                CheckKeyRet = false;
            }

            dbServiceSites.Dispose();
            return(CheckKeyRet);
        }
Пример #2
0
        public void GetIncident(string IncNum, string key)
        {
            OpenConnection();
            if (!CheckKey(key))
            {
                CloseConnection();
                return;
            }
            //
            var Vehicles = new List <clsServiceCalls.VehicleList>();
            var dbCall   = new dbcalls();

            dbCall.GetItem(IncNum);

            // log.Info(IncNum)

            var dbStats = new dbCallStats();

            dbStats.GetItem(IncNum);
            Vehicles = GetVehicles(IncNum);
            string tempPriority = GetPriority(dbCall.PriorityId);
            string tempStation  = GetStation(dbCall.StationId);

            var ServiceCall = new clsServiceCalls()
            {
                ESSIncident = new clsServiceCalls.IncidentList()
                {
                    IncidentNumber      = dbCall.CallNum.Substring(0, System.Math.Min(200, dbCall.CallNum.Length)),
                    Datetime            = dbCall.Datetime,
                    Priority            = tempPriority.Substring(0, System.Math.Min(200, tempPriority.Length)),
                    Category            = dbCall.Category.Substring(0, System.Math.Min(200, dbCall.Category.Length)),
                    SubCategory         = dbCall.Subcategory.Substring(0, System.Math.Min(200, dbCall.Subcategory.Length)),
                    Location            = dbCall.Location.Substring(0, System.Math.Min(200, dbCall.Location.Length)),
                    LocationNumber      = dbCall.LocationNumber.Substring(0, System.Math.Min(200, dbCall.LocationNumber.Length)),
                    Floor               = dbCall.Floor.Substring(0, System.Math.Min(200, dbCall.Floor.Length)),
                    LocationTelelephone = dbCall.LocationTel.Substring(0, System.Math.Min(200, dbCall.LocationTel.Length)),
                    Complex             = dbCall.Floor.Substring(0, System.Math.Min(200, dbCall.Floor.Length)),
                    Poi          = dbCall.Poi.Substring(0, System.Math.Min(200, dbCall.Poi.Length)),
                    Street       = dbCall.Street.Substring(0, System.Math.Min(200, dbCall.Street.Length)),
                    StreetNumber = dbCall.StreetNum.Substring(0, System.Math.Min(200, dbCall.StreetNum.Length)),
                    Suburb       = dbCall.Suburb.Substring(0, System.Math.Min(200, dbCall.Suburb.Length)),
                    Town         = dbCall.Town.Substring(0, System.Math.Min(200, dbCall.Town.Length)),
                    Xroad        = dbCall.Xroad.Substring(0, System.Math.Min(200, dbCall.Xroad.Length)),
                    Province     = dbCall.Province.Substring(0, System.Math.Min(200, dbCall.Province.Length)),
                    Latitude     = dbCall.Latitude,
                    Longitude    = dbCall.Longitude,
                    Station      = tempStation.Substring(0, System.Math.Min(200, tempStation.Length)),
                    Status       = dbCall.Status,
                    Vehicles     = Vehicles,
                    Statistics   = new clsServiceCalls.StatsList()
                    {
                        CallAcknowledged = dbStats.CallAcknowledged,
                        CallAnswered     = dbStats.CallAnswered,
                        CallDespatched   = dbStats.CallDespatched,
                        CallTransferred  = dbStats.CallTransferred,
                        CallClosed       = dbStats.CallClosed,
                        CallTaken        = dbStats.CallTaken,
                        VehArrived       = dbStats.VehArrived,
                        LastVehLeft      = dbStats.LastVehLeft
                    }
                }
            };

            dbCall.Dispose();
            dbStats.Dispose();
            Context.Response.ContentType = "application/json; charset=utf-8";
            Context.Response.Write(JsonConvert.SerializeObject(ServiceCall));
            CloseConnection();
        }