Exemple #1
0
        public void SearchIncidents(string StartDate, string EndDate, string Category, string Status, string key)
        {
            OpenConnection();
            if (!CheckKey(key))
            {
                CloseConnection();
                return;
            }

            var  SqlQuery   = new StringBuilder();
            bool isDate     = false;
            bool isCategory = false;

            SqlQuery.Append("SELECT TOP 100 call_num FROM CALLS");
            if (!string.IsNullOrEmpty(StartDate) & !string.IsNullOrEmpty(EndDate))
            {
                isDate = true;
                SqlQuery.Append(" WHERE dateTime between '" + StartDate + "' AND '" + EndDate + "'");
            }

            if (!string.IsNullOrEmpty(Category))
            {
                isCategory = true;
                if (isDate)
                {
                    SqlQuery.Append(" AND Category = '" + Category + "'");
                }
                else
                {
                    SqlQuery.Append(" WHERE Category = '" + Category + "'");
                }
            }

            if (!string.IsNullOrEmpty(Status))
            {
                if (isDate | isCategory)
                {
                    SqlQuery.Append(" AND Status = '" + Status + "'");
                }
                else
                {
                    SqlQuery.Append(" WHERE Status = '" + Status + "'");
                }
            }

            SqlQuery.Append(" ORDER BY ID DESC");
            var IncidentList = new List <clsServiceCallsList.IncidentList>();
            var dbCall       = new dbcalls();
            var dbStats      = new dbCallStats();

            System.Data.SqlClient.SqlDataReader myReader;
            SqlCommand.CommandText = SqlQuery.ToString();
            // log.Info(SqlQuery.ToString)
            myReader = SqlCommand.ExecuteReader();
            while (myReader.Read())
            {
                dbCall.GetItem(myReader["call_num"].ToString());
                dbStats.GetItem(myReader["call_num"].ToString());
                var Vehicles = new List <clsServiceCallsList.VehicleList>();
                Vehicles = dbCall.GetVehiclesList(myReader["call_num"].ToString());
                var incident = new clsServiceCallsList.IncidentList()
                {
                    IncidentNumber      = dbCall.CallNum,
                    Datetime            = dbCall.Datetime,
                    Priority            = GetPriority(dbCall.PriorityId),
                    Category            = dbCall.Category,
                    SubCategory         = dbCall.Subcategory,
                    Location            = dbCall.Location,
                    LocationNumber      = dbCall.LocationNumber,
                    Floor               = dbCall.Floor,
                    LocationTelelephone = dbCall.LocationTel,
                    Complex             = dbCall.Complex,
                    Poi          = dbCall.Poi,
                    Street       = dbCall.Street,
                    StreetNumber = dbCall.StreetNum,
                    Suburb       = dbCall.Suburb,
                    Town         = dbCall.Town,
                    Xroad        = dbCall.Xroad,
                    Province     = dbCall.Province,
                    Latitude     = dbCall.Latitude,
                    Longitude    = dbCall.Longitude,
                    Station      = GetStation(dbCall.StationId),
                    Status       = dbCall.Status,
                    Vehicles     = Vehicles,
                    Statistics   = new clsServiceCallsList.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
                    }
                };
                IncidentList.Add(incident);
                log.Info(myReader["call_num"].ToString());
            }

            myReader.Close();
            dbCall.Dispose();
            dbStats.Dispose();
            CloseConnection();
            var ServiceCall = new clsServiceCallsList();

            ServiceCall.ESSIncident      = IncidentList;
            Context.Response.ContentType = "application/json; charset=utf-8";
            Context.Response.Write(JsonConvert.SerializeObject(ServiceCall));
        }
Exemple #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();
        }