コード例 #1
0
        public static void CreateAssist(UIIncidentDispatch incidentDispatch)
        {
            using (FSPDataContext dc = new FSPDataContext())
            {
                using (TowTruckServiceRef.TowTruckServiceClient service = new TowTruckServiceRef.TowTruckServiceClient())
                {
                    TowTruckServiceRef.IncidentIn thisIncident = new TowTruckServiceRef.IncidentIn();

                    Guid     IncidentID = Guid.NewGuid();
                    DateTime TimeStamp  = DateTime.Now;

                    Guid CreatedBy = MembershipExtensions.GetUserId();

                    thisIncident.IncidentID     = IncidentID;
                    thisIncident.FreewayID      = Convert.ToInt32(incidentDispatch.FreewayId);
                    thisIncident.LocationID     = dc.Locations.Where(p => p.LocationCode == incidentDispatch.LocationName).FirstOrDefault().LocationID;
                    thisIncident.TimeStamp      = TimeStamp;
                    thisIncident.CreatedBy      = CreatedBy;
                    thisIncident.Description    = incidentDispatch.Description;
                    thisIncident.IncidentNumber = String.Empty;

                    //create incident
                    service.AddIncident(thisIncident);

                    //for each truck create assit

                    foreach (var truck in incidentDispatch.SelectedTrucks)
                    {
                        TowTruckServiceRef.AssistReq thisAssist = new TowTruckServiceRef.AssistReq();
                        thisAssist.AssistID = Guid.NewGuid();

                        thisAssist.IncidentID = IncidentID;

                        FleetVehicle dbTruck = dc.FleetVehicles.Where(p => p.VehicleNumber == truck).FirstOrDefault();

                        thisAssist.FleetVehicleID = dbTruck.FleetVehicleID;
                        thisAssist.ContractorID   = dbTruck.ContractorID;

                        thisAssist.DispatchTime = DateTime.Now;
                        thisAssist.x1097        = DateTime.Now;
                        service.AddAssist(thisAssist);
                    }
                }
            }
        }
コード例 #2
0
        public ActionResult GetBeatNumbers(String name_startsWith)
        {
            using (FSPDataContext dc = new FSPDataContext())
            {
                var beatsQuery = from q in dc.vBeats
                                 where q.Active == true && q.BeatNumber.Contains(name_startsWith)
                                 orderby q.BeatNumber
                                 select new
                {
                    //Number = q.BeatNumber,
                    Number      = q.BeatNumber.Substring(q.BeatNumber.Length - 3, 3),
                    Description = q.BeatDescription
                };

                Debug.WriteLine("Beat numbers loaded: " + DateTime.Now);
                return(Json(beatsQuery, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #3
0
        public override bool RoleExists(string rolename)
        {
            bool exists = false;

            using (FSPDataContext db = new FSPDataContext())
            {
                var roles = from q in db.Roles
                            where q.RoleName.Equals(rolename)
                            select q;

                if (roles.Count() > 0)
                {
                    exists = true;
                }
            }

            return(exists);
        }
コード例 #4
0
        public override bool IsUserInRole(string email, string rolename)
        {
            bool userIsInRole = false;

            using (FSPDataContext db = new FSPDataContext())
            {
                var roles = from q in db.Users
                            join r in db.Roles on q.RoleID equals r.RoleID
                            where q.Email.Equals(email) && r.RoleName.Equals(rolename)
                            select q;

                if (roles.Count() > 0)
                {
                    userIsInRole = true;
                }
            }

            return(userIsInRole);
        }
コード例 #5
0
        public override string[] GetRolesForUser(string email)
        {
            string tmpRoleNames = "";

            using (FSPDataContext db = new FSPDataContext())
            {
                var users = from q in db.Users
                            where q.Email.Equals(email)
                            select q;

                if (users.Count() > 0)
                {
                    tmpRoleNames = users.FirstOrDefault().Role.RoleName;
                }
            }

            if (tmpRoleNames.Length > 0)
            {
                return(tmpRoleNames.Split(','));
            }

            return(new string[0]);
        }
コード例 #6
0
        public List <Contractor> GetContractors()
        {
            List <Contractor> returnList = new List <Contractor>();

            if (HttpContext.Current.Cache["contractors"] == null)
            {
                using (FSPDataContext dc = new FSPDataContext())
                {
                    returnList = dc.Contractors.ToList();
                }

                HttpContext.Current.Cache.Insert("contractors",
                                                 returnList,
                                                 null,
                                                 Cache.NoAbsoluteExpiration,
                                                 TimeSpan.FromMinutes(60));
            }
            else
            {
                returnList = (List <Contractor>)HttpContext.Current.Cache["contractors"];
            }
            return(returnList);
        }
コード例 #7
0
        public ActionResult GetCallBoxes()
        {
            List <UICallBox> returnList = new List <UICallBox>();

            try
            {
                using (FSPDataContext dc = new FSPDataContext())
                {
                    var callBoxes = dc.vCallBoxes;

                    foreach (var callBox in callBoxes)
                    {
                        SqlGeography geo = new SqlGeography();
                        geo = SqlGeography.Parse(callBox.Position);

                        Double lat = Convert.ToDouble(geo.STPointN(1).Lat.ToString());
                        Double lon = Convert.ToDouble(geo.STPointN(1).Long.ToString());

                        returnList.Add(new UICallBox
                        {
                            CallBoxId           = callBox.CallBoxID,
                            FreewayId           = callBox.FreewayID,
                            Lat                 = lat,
                            Lon                 = lon,
                            LocationDescription = callBox.Location,
                            TelephoneNumber     = callBox.TelephoneNumber,
                            SignNumber          = callBox.SignNumber,
                            SiteType            = callBox.SiteType,
                            Comments            = callBox.Comments
                        });
                    }
                }
            }
            catch { }
            Debug.WriteLine("Call boxes loaded: " + DateTime.Now);
            return(Json(returnList, JsonRequestBehavior.AllowGet));
        }
コード例 #8
0
        public List <TruckState> GetTruckStates()
        {
            List <TruckState> returnList = new List <TruckState>();

            if (HttpContext.Cache["truckStates"] == null)
            {
                using (FSPDataContext dc = new FSPDataContext())
                {
                    returnList = dc.TruckStates.ToList();
                }

                HttpContext.Cache.Insert("truckStates",
                                         returnList,
                                         null,
                                         Cache.NoAbsoluteExpiration,
                                         TimeSpan.FromMinutes(60));
            }
            else
            {
                returnList = (List <TruckState>)HttpContext.Cache["truckStates"];
            }

            return(returnList);
        }
コード例 #9
0
        public ActionResult GetIncidents()
        {
            List <UIIncident> returnList     = new List <UIIncident>();
            String            contractorName = String.Empty;
            Boolean           addTruck       = true;

            using (FSPDataContext dc = new FSPDataContext())
            {
                var user = dc.Users.Where(p => p.Email == User.Identity.Name).FirstOrDefault();

                if (user.Role.RoleName == "Contractor")
                {
                    contractorName = dc.Contractors.Where(p => p.ContractorID == user.ContractorID).FirstOrDefault().ContractCompanyName;
                }
                else
                {
                    contractorName = String.Empty;
                }
            }

            using (TowTruckServiceClient service = new TowTruckServiceClient())
            {
                try
                {
                    var allIncidents = from q in service.getIncidentData()
                                       select new UIIncident
                    {
                        IncidentID         = q.IncidentID,
                        IncidentNumber     = q.IncidentNumber,
                        BeatNumber         = q.BeatNumber,
                        TruckNumber        = q.TruckNumber,
                        DriverName         = q.DriverName,
                        DispatchComments   = q.DispatchComments,
                        Timestamp          = q.Timestamp.ToString(),
                        State              = q.State,
                        DispatchNumber     = q.IncidentNumber,
                        ContractorName     = q.ContractorName,
                        IsIncidentComplete = q.IsIncidentComplete,
                        IsAcked            = q.IsAcked
                    };


                    foreach (var incident in allIncidents)
                    {
                        if (!String.IsNullOrEmpty(contractorName))
                        {
                            if (contractorName == incident.ContractorName)
                            {
                                addTruck = true;
                            }
                            else
                            {
                                addTruck = false;
                            }
                        }
                        else
                        {
                            addTruck = true;
                        }

                        if (addTruck)
                        {
                            returnList.Add(incident);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                }
            }

            return(Json(returnList.OrderBy(p => p.BeatNumber), JsonRequestBehavior.AllowGet));
        }
コード例 #10
0
        public ActionResult GetAssists()
        {
            List <UIAssist> returnList = new List <UIAssist>();

            String  contractorName = String.Empty;
            Boolean addTruck       = true;

            using (FSPDataContext dc = new FSPDataContext())
            {
                var user = dc.Users.Where(p => p.Email == User.Identity.Name).FirstOrDefault();

                if (user.Role.RoleName == "Contractor")
                {
                    contractorName = dc.Contractors.Where(p => p.ContractorID == user.ContractorID).FirstOrDefault().ContractCompanyName;
                }
                else
                {
                    contractorName = String.Empty;
                }
            }

            using (TowTruckServiceRef.TowTruckServiceClient service = new TowTruckServiceRef.TowTruckServiceClient())
            {
                var allAssists = from q in service.GetAllAssists()
                                 select new UIAssist
                {
                    AssistNumber   = q.AssistNumber,
                    BeatNumber     = q.BeatNumber,
                    Color          = q.Color,
                    DispatchNumber = q.DispatchNumber,
                    Driver         = q.DriverName,
                    DriverComments = q.Comments,
                    DropZone       = q.DropZone,
                    Make           = q.Make,
                    PlateNumber    = q.LicensePlate,
                    ContractorName = q.ContractorName
                };

                foreach (var assist in allAssists)
                {
                    if (!String.IsNullOrEmpty(contractorName))
                    {
                        if (contractorName == assist.ContractorName)
                        {
                            addTruck = true;
                        }
                        else
                        {
                            addTruck = false;
                        }
                    }
                    else
                    {
                        addTruck = true;
                    }

                    if (addTruck)
                    {
                        returnList.Add(assist);
                    }
                }
            }

            return(Json(returnList.OrderBy(p => p.BeatNumber), JsonRequestBehavior.AllowGet));
        }