コード例 #1
0
 public void SetInformations(Incidents incident)
 {
     Date        = incident.IncidentDate;
     Description = incident.Description;
     Severity    = incident.Severity;
     AnimalID    = incident.AnimalID;
 }
コード例 #2
0
        public async Task <ActionResult <Incidents> > PostIncidents(Incidents incidents)
        {
            _context.Incidents.Add(incidents);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetIncidents", new { id = incidents.Id }, incidents));
        }
コード例 #3
0
        private void ProcessPreviousActivities(Activity activity, List <int> ids)
        {
            foreach (var id in ids)
            {
                var current = Activities.Single(a => a.ID == id);

                if (activity.Parent != null)
                {
                    current.Children = activity.Parent;
                    current.Children.Incoming.Add(current);
                }
                else if (current.Children != null)
                {
                    activity.Parent = current.Children;
                    activity.Parent.Outgoing.Add(activity);
                }
                else //(current.Children == null && activity.Parent == null)
                {
                    var incident = new Incident();
                    Incidents.Add(incident);
                    current.Children = incident;
                    incident.Incoming.Add(current);
                    activity.Parent = incident;
                    incident.Outgoing.Add(activity);
                }
            }
        }
コード例 #4
0
        public void NewActivity(Activity activity)
        {
            Activities.Add(activity);
            if (activity.IdPrevious.Length == 0)
            {
                if (Incidents.Count == 0)
                {
                    var incident = new Incident();
                    Incidents.Add(incident);
                }
                var firstIncident = Incidents.Single(i => i.ID == 0);
                activity.Parent = firstIncident;
                firstIncident.Outgoing.Add(activity);
            }

            var withChildrens    = new List <int>();
            var withoutChildrens = new List <int>();

            foreach (var id in activity.IdPrevious)
            {
                var tmp = Activities.Single(a => a.ID == id);
                if (tmp.Children != null)
                {
                    withChildrens.Add(id);
                }
                else
                {
                    withoutChildrens.Add(id);
                }
            }
            ProcessPreviousActivities(activity, withChildrens);
            ProcessPreviousActivities(activity, withoutChildrens);
        }
コード例 #5
0
ファイル: IncidentsController.cs プロジェクト: gozu42/api
        public IActionResult Post([FromBody] Incidents incident)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            using (var context = new Context())
            {
                try
                {
                    incident.CreatedAt = DateTime.UtcNow;
                    incident.UpdatedAt = DateTime.UtcNow;
                    context.Incidents.Add(incident);

                    context.SaveChanges();

                    return(Created(Url.RouteUrl(incident.Id), incident.Id));
                }
                catch (Exception ex)
                {
                    return(StatusCode(StatusCodes.Status500InternalServerError, ex));
                }
            }
        }
コード例 #6
0
ファイル: IncidentsController.cs プロジェクト: gozu42/api
        public IActionResult Put(int id, [FromBody] Incidents updatedIncident)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var existing = db.Set <Incidents>().Where(x => x.Id == id).FirstOrDefault();

            if (existing == null)
            {
                return(NotFound());
            }

            try
            {
                existing.Name       = updatedIncident.Name;
                existing.Location   = updatedIncident.Location;
                existing.Managers   = updatedIncident.Managers;
                existing.Impacted   = updatedIncident.Impacted;
                existing.Casualties = updatedIncident.Casualties;
                existing.UpdatedAt  = DateTime.UtcNow;

                db.SaveChanges();

                return(Ok());
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, ex));
            }
        }
コード例 #7
0
        public List <Incidents> SelectIncidents(int currentUserType, int deploymentId)
        {
            MySqlParameter[] parameters = new MySqlParameter[] {
                new MySqlParameter("currentUserType", currentUserType),
                new MySqlParameter("p_deploymentId", deploymentId)
            };
            List <Incidents> IncidentsCol = new List <Incidents>();
            DataTable        dt           = MySQLDB.MySQLDBHelper.ExecuteSelectCommand("GetIncidents", CommandType.StoredProcedure, parameters);
            Incidents        objIncident  = null;

            foreach (DataRow dr in dt.Rows)
            {
                objIncident                        = new Incidents();
                objIncident.incidentid             = Convert.ToInt32(dr["incidentid"].ToString());
                objIncident.reportdate             = Convert.ToDateTime(dr["reportdate"].ToString());
                objIncident.natureofincident       = dr["natureofincident"].ToString();
                objIncident.dateofincident         = Convert.ToDateTime(dr["dateofincident"].ToString());
                objIncident.locationid             = Convert.ToInt32(dr["locationid"].ToString());
                objIncident.particularsofpersons   = dr["particularsofpersons"].ToString();
                objIncident.briefdescription       = dr["briefdescription"].ToString();
                objIncident.remarksandactionstaken = dr["remarksandactionstaken"].ToString();
                objIncident.snapshotpath           = dr["snapshotpath"].ToString();
                objIncident.deploymentid           = dr["deploymentid"] != null && dr["deploymentid"].ToString() != "" ? Convert.ToInt32(dr["deploymentid"]) : 0;;
                IncidentsCol.Add(objIncident);
            }
            dt.Clear();
            dt.Dispose();
            return(IncidentsCol);
        }
コード例 #8
0
        public async Task <IActionResult> PutIncidents(int id, Incidents incidents)
        {
            if (id != incidents.Id)
            {
                return(BadRequest());
            }

            _context.Entry(incidents).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!IncidentsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #9
0
 public ActionResult AddIncident(Models.IncidentsModel item)
 {
     if (ModelState.IsValid)
     {
         var itemIncident = new Incidents();
         itemIncident           = item;
         itemIncident.timestamp = Convert.ToDateTime(DateTime.Now.ToString());
         if (item.idIncident == 0)
         {
             /*var result = new IncidentsManager().Create(itemIncident);
              * ViewBag.Message = result.msg;*/
             repository.Add(item);
             repository.Save();
         }
         else
         {
             //var result = new IncidentsManager().Update(itemIncident);
             //ViewBag.Message = result.msg;
             repository.Edit(itemIncident);
             repository.Save();
         }
         return(RedirectToAction("Index", "Home"));
     }
     else
     {
         return(View(item));
     }
 }
コード例 #10
0
        async Task ExecuteLoadIncidentsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Incidents.Clear();
                var incidents = await DataStore.GetIncidentsAsync(true);

                foreach (var incident in incidents)
                {
                    Incidents.Add(incident);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
コード例 #11
0
        async Task ExecutedLoadIncidentsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Incidents.Clear();


                var incidents = await App.IncidentRepo.GetAllIncidents();

                foreach (var incident in incidents)
                {
                    Incidents.Add(incident);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
コード例 #12
0
        public async Task <List <Incident> > UpdateIncidentStatusAsync(string incidentId, PagerDutyPerson person, IncidentStatus newStatus)
        {
            if (person == null)
            {
                throw new ArgumentNullException(nameof(person));
            }

            var data = new PagerDutyIncidentPut
            {
                Incidents = new List <Incident>
                {
                    new Incident {
                        Id = incidentId, Status = newStatus
                    }
                },
                RequesterId = person.Id
            };

            var result = await Instance.GetFromPagerDutyAsync("incidents",
                                                              response => JSON.Deserialize <IncidentResponse>(response.ToString(), JilOptions),
                                                              httpMethod : "PUT",
                                                              data : data);

            Incidents.Poll(true);

            return(result?.Incidents ?? new List <Incident>());
        }
コード例 #13
0
 public ActionResult AddIncident(int?id)
 {
     if (id == null)
     {
         /*Models.IncidentsModel incidents = new Models.IncidentsModel();
          * incidents.idObjectList = new ICCManager().Read().Select(x => new SelectListItem
          * {
          *  Text = x.postOffice + " (" + x.idObject.ToString() + ")",
          *  Value = x.idObject.ToString()
          * });*/
         Incidents incidents = new Incidents();
         return(View(incidents));
     }
     else
     {
         /*var itemIncident = new IncidentsManager().GetById(Convert.ToInt32(id));
          * Models.IncidentsModel incidents = new Models.IncidentsModel(itemIncident);
          * incidents.idObjectList = new ICCManager().Read().Select(x => new SelectListItem
          * {
          *  Text = x.postOffice + " (" + x.idObject.ToString() + ")",
          *  Value = x.idObject.ToString()
          * });*/
         //Incidents incidents = new IncidentsManager().GetById(Convert.ToInt32(id));
         return(View(repository.FindBy(x => x.idIncident == id).FirstOrDefault()));
     }
 }
コード例 #14
0
        public Incidents SelectIncidentByID(int currentUserType, int deploymentId, int p_IncidentsID)
        {
            MySqlParameter[] parameters = new MySqlParameter[] {
                new MySqlParameter("p_incidentid", p_IncidentsID)
            };
            DataTable dt          = MySQLDB.MySQLDBHelper.ExecuteSelectCommand("GetIncidentByID", CommandType.StoredProcedure, parameters);
            Incidents objIncident = null;

            if (dt.Rows.Count > 0)
            {
                DataRow dr = dt.Rows[0];
                objIncident                        = new Incidents();
                objIncident.incidentid             = Convert.ToInt32(dr["incidentid"].ToString());
                objIncident.reportdate             = Convert.ToDateTime(dr["reportdate"].ToString());
                objIncident.natureofincident       = dr["natureofincident"].ToString();
                objIncident.dateofincident         = Convert.ToDateTime(dr["dateofincident"].ToString());
                objIncident.locationid             = Convert.ToInt32(dr["locationid"].ToString());
                objIncident.particularsofpersons   = dr["particularsofpersons"].ToString();
                objIncident.briefdescription       = dr["briefdescription"].ToString();
                objIncident.remarksandactionstaken = dr["remarksandactionstaken"].ToString();
                objIncident.snapshotpath           = dr["snapshotpath"].ToString();
                objIncident.deploymentid           = dr["deploymentid"] != null && dr["deploymentid"].ToString() != "" ? Convert.ToInt32(dr["deploymentid"]) : 0;;
            }
            dt.Clear();
            dt.Dispose();
            return(objIncident);
        }
コード例 #15
0
        public ActionResult PostAddIncidents([FromBody] JObject RqHdr)
        {
            var incidentsourceid = (Newtonsoft.Json.JsonConvert.DeserializeObject <Int16>(RqHdr["incidentsourceid"].ToString(), new Newtonsoft.Json.JsonSerializerSettings {
                NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore
            }));
            var incidenttypeid   = (Newtonsoft.Json.JsonConvert.DeserializeObject <Int16>(RqHdr["incidenttypeid"].ToString(), new Newtonsoft.Json.JsonSerializerSettings {
                NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore
            }));
            var incidentplace    = (Newtonsoft.Json.JsonConvert.DeserializeObject <string>(RqHdr["incidentplace"].ToString(), new Newtonsoft.Json.JsonSerializerSettings {
                NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore
            }));
            var extrainfo1       = (Newtonsoft.Json.JsonConvert.DeserializeObject <string>(RqHdr["extrainfo1"].ToString(), new Newtonsoft.Json.JsonSerializerSettings {
                NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore
            }));
            var extrainfo2       = (Newtonsoft.Json.JsonConvert.DeserializeObject <string>(RqHdr["extrainfo1"].ToString(), new Newtonsoft.Json.JsonSerializerSettings {
                NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore
            }));
            var extrainfo3       = (Newtonsoft.Json.JsonConvert.DeserializeObject <string>(RqHdr["extrainfo1"].ToString(), new Newtonsoft.Json.JsonSerializerSettings {
                NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore
            }));
            var userid           = (Newtonsoft.Json.JsonConvert.DeserializeObject <Int16>(RqHdr["userid"].ToString(), new Newtonsoft.Json.JsonSerializerSettings {
                NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore
            }));

            var source = _context.Incidentsources.FirstOrDefault <Incidentsources>(a => a.Incidentsourceid == incidentsourceid);

            if (source == null)
            {
                return(Ok(null));
            }
            Users user = new Users();

            if (user == null)
            {
                return(Ok(null));
            }

            var newIncident = new Incidents();

            newIncident.Incidenttypeid   = incidenttypeid;
            newIncident.Incidentstateid  = Core.Handler_Incidents.Incident_State_New;
            newIncident.Incidentsourceid = source.Incidentsourceid;
            newIncident.Place            = incidentplace;
            if (source.Requiresextrainfo1 == 1)
            {
                newIncident.Incidentsourceextrainfo1 = extrainfo1;
            }
            if (source.Requiresextrainfo2 == 1)
            {
                newIncident.Incidentsourceextrainfo2 = extrainfo2;
            }
            if (source.Requiresextrainfo3 == 1)
            {
                newIncident.Incidentsourceextrainfo3 = extrainfo3;
            }
            var result = _inc.Add_Incident(user, newIncident);

            return(Ok(result.Text));
        }
コード例 #16
0
 public Character(string name, int distance, int range, bool heroine, Incidents forbidden)
 {
     Name              = name;
     Heroine           = heroine;
     DistanceBonus     = distance;
     RangeBonus        = range;
     ForbiddenIncident = forbidden;
 }
コード例 #17
0
 public void Init()
 {
     _mapValuables      = new List <IValuable>();
     _eventNotification = new Events();
     _thiefTeamFactory  = new ThiefTeamFactoryStub(new SingleMemberThiefTeam(new FacilityMap(new InMemoryWorld())));
     _incidents         = new Incidents(_mapValuables, _eventNotification, _thiefTeamFactory);
     _eventNotification.Subscribe <GameEndEvent>(OnGameEnd);
 }
コード例 #18
0
        public Incidents GetActiveIncidents(string environmentAbbreviation)
        {
            Incidents incidents = new Incidents();

            incidents.Add(new IncidentData(
                              "IR12345", "Title", "dev engaged", "description", DateTime.UtcNow, 1, 10, "status", DateTime.UtcNow + new TimeSpan(1, 0, 0, 0)));
            return(incidents);
        }
コード例 #19
0
 public Character(string name, int distance, int range, bool heroine = false)
 {
     Name              = name;
     DistanceBonus     = distance;
     RangeBonus        = range;
     ForbiddenIncident = Incidents.None;
     Heroine           = heroine;
 }
コード例 #20
0
ファイル: IncidentsController.cs プロジェクト: prof1k/UIJCCA
        public ActionResult DeleteConfirmed(int id)
        {
            Incidents incidents = GM.FindBy(x => x.idIncident == id).FirstOrDefault();

            db.Incidents.Remove(incidents);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #21
0
            public void setup()
            {
                incident = new Incidents();

                var session = CreateDrivers("dino");

                incident.Process(CreateIncidentSample(0, 4.0d, session));
                incident.Process(CreateIncidentSample(0, (4d + 8d + 17d), session));
            }
コード例 #22
0
        public void CreateIncidents()
        {
            //---------------------------------------------
            Incident           item;
            HashSet <Incident> uniqueIncidents = new HashSet <Incident>();

            foreach (var act in Activities)
            {
                item = new Incident(act.IdParent);
                uniqueIncidents.Add(item);
                item = new Incident(act.IdChildren);
                uniqueIncidents.Add(item);
            }
            foreach (var inc in uniqueIncidents)
            {
                Incidents.Add(inc);
            }
            Incidents = Incidents.OrderBy(o => o.ID).ToList();
            //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            int             id = 0;
            List <Incident> removeIncidents = new List <Incident>();

            foreach (var inc in Incidents)
            {
                if (id == inc.ID)
                {
                    removeIncidents.Add(inc);
                }
                else
                {
                    id = inc.ID;
                }
            }
            foreach (var remove in removeIncidents)
            {
                Incidents.Remove(remove);
            }
            //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            //---------------------------------------------
            foreach (var act in Activities)
            {
                foreach (var inc in Incidents)
                {
                    if (act.IdParent == inc.ID)
                    {
                        act.Parent = inc;
                        inc.Outgoing.Add(act);
                    }
                    if (act.IdChildren == inc.ID)
                    {
                        act.Children = inc;
                        inc.Incoming.Add(act);
                    }
                }
            }
            //---------------------------------------------
        }
コード例 #23
0
            public void setup()
            {
                incident = new Incidents();

                var session = CreateDrivers("dino");

                incident.Process(CreateIncidentSample(0, 4.0d, session));
                incident.Process(CreateIncidentSample(0, (4d + 8d + 17d), session));
            }
コード例 #24
0
        //all functions here require Ahwal Permssion
        public Operationlogs Add_Incident(Users u, Incidents i) //this transaction requires User_Role_Ahwal Permisson on this AhwalID
        {
            try
            {
                //first we have to check if this user is authorized to perform this transaction
                Usersrolesmap permisson_esists = _context.Usersrolesmap.FirstOrDefault(r => r.Userid == u.Userid && r.Userroleid == Core.Handler_User.User_Role_Ops);

                if (permisson_esists == null)
                {
                    Operationlogs ol_failed = new Operationlogs();
                    ol_failed.Userid      = u.Userid;
                    ol_failed.Operationid = Handler_Operations.Opeartion_Incidents_AddNew;
                    ol_failed.Statusid    = Handler_Operations.Opeartion_Status_UnAuthorized;
                    ol_failed.Text        = "المستخدم لايملك صلاحية هذه العمليه";
                    _oper.Add_New_Operation_Log(ol_failed);
                    return(ol_failed);
                }
                i.Userid     = u.Userid;
                i.Timestamp  = DateTime.Now;
                i.Lastupdate = DateTime.Now;
                _context.Incidents.Add(i);
                //by default,we will add new comment for a new incidet,this will help later in the incidents dedicated page, that each incident at least has one comment

                _context.SaveChanges();
                //still, the incident status will be new, but with this we make sure that each incident at least has one comment
                var newIncidentComment = new Incidentscomments();
                newIncidentComment.Incidentid = i.Incidentid;
                newIncidentComment.Userid     = u.Userid;
                newIncidentComment.Text       = "قام باضافة البلاغ";
                newIncidentComment.Timestamp  = DateTime.Now;
                _context.Incidentscomments.Add(newIncidentComment);
                _context.SaveChanges();
                //add it incidentview
                AddNewIncidentViewForAllExceptOriginalPoster(u, i);

                //create the opeartion log for it
            }
            catch (Exception ex)
            {
                Operationlogs ol_failed = new Operationlogs();
                ol_failed.Userid      = u.Userid;
                ol_failed.Operationid = Handler_Operations.Opeartion_Incidents_AddNew;
                ol_failed.Statusid    = Handler_Operations.Opeartion_Status_UnKnownError;
                ol_failed.Text        = ex.Message;
                _oper.Add_New_Operation_Log(ol_failed);
                return(ol_failed);
            }
            Operationlogs ol = new Operationlogs();

            ol.Userid      = u.Userid;
            ol.Operationid = Handler_Operations.Opeartion_Incidents_AddNew;
            ol.Statusid    = Handler_Operations.Opeartion_Status_Success;
            ol.Text        = "تم اضافة البلاغ رقم: " + i.Incidentid.ToString();
            _oper.Add_New_Operation_Log(ol);
            return(ol);
        }
コード例 #25
0
            public void setup()
            {
                incident = new Incidents();

                var session = CreateDrivers("dino", "georg");

                incident.Process(CreateIncidentSample(0, 4.3d, session));
                incident.Process(CreateIncidentSample(1, 5.4d, session));
                incident.Process(CreateIncidentSample(0, 6.2d, session));
            }
コード例 #26
0
        public ActionResult ViewIncident(string first, string last)
        {
            List <incitingIncident> list = TableUtils.queryToTable <incitingIncident>("SELECT * FROM shooters.incitingIncident where first= '" + first + "' AND last = '" + last + "' order by iDate");
            var model = new Incidents()
            {
            };

            model._incidents = list;
            return(View(model));
        }
コード例 #27
0
        public void CreateIncidentsModeActivities()
        {
            var incident = new Incident();

            Incidents.Add(incident);
            foreach (var activity in Activities.Where(a => a.Children == null))
            {
                activity.Children = incident;
                incident.Incoming.Add(activity);
            }
        }
コード例 #28
0
        public RuleIncident(CameraControl cameraControl, RemovalEdits removalEdits, Incidents incidents, int limitDownTo)
        {
            this.editMarker = removalEdits.For(InterestState.Incident);
            this.cameraControl = cameraControl;
            this.limitDownTo = limitDownTo;

            nextIncident = incidents.GetEnumerator();
            nextIncident.MoveNext();
            if (nextIncident.Current != null)
                TraceInfo.WriteLine("First incident at {0}", nextIncident.Current.StartSessionTime);
        }
コード例 #29
0
ファイル: IncidentsController.cs プロジェクト: prof1k/UIJCCA
 public ActionResult Edit([Bind(Include = "idIncident,idObject,incidentOpening,IncidentClose,incidentNumberIteko,incidentNumberRT,description")] Incidents incidents)
 {
     if (ModelState.IsValid)
     {
         //db.Entry(incidents).State = EntityState.Modified;
         GM.Edit(incidents);
         GM.Save();
         return(RedirectToAction("Home", "Index"));
     }
     ViewBag.idObject = new SelectList(db.ICC, "idObject", "idpostOffice", incidents.idObject);
     return(View(incidents));
 }
コード例 #30
0
ファイル: IncidentsController.cs プロジェクト: prof1k/UIJCCA
        public ActionResult Create([Bind(Include = "idIncident,idObject,incidentOpening,IncidentClose,incidentNumberIteko,incidentNumberRT,description")] Incidents incidents)
        {
            if (ModelState.IsValid)
            {
                incidents.timestamp = DateTime.Now;
                GM.Add(incidents);
                GM.Save();
                return(RedirectToAction("Index", "Home"));
            }

            ViewBag.idObject = new SelectList(db.ICC, "idObject", "idpostOffice", incidents.idObject);
            return(View(incidents));
        }
        public IActionResult Incidents()
        {
            var optionsBuilder = new DbContextOptionsBuilder();

            optionsBuilder.UseSqlServer(ApplicatonDbContext.GetConnectionString());
            using (var dbContext = new ApplicatonDbContext(optionsBuilder.Options))
            {
                var Incidents = dbContext.Incidents.ToList();
                var incidents = new Incidents();
                incidents.incidents = Incidents;
                return(View(incidents));
            }
        }
コード例 #32
0
        public RuleIncident(CameraControl cameraControl, RemovalEdits removalEdits, Incidents incidents, int limitDownTo)
        {
            this.editMarker    = removalEdits.For(InterestState.Incident);
            this.cameraControl = cameraControl;
            this.limitDownTo   = limitDownTo;

            nextIncident = incidents.GetEnumerator();
            nextIncident.MoveNext();
            if (nextIncident.Current != null)
            {
                TraceInfo.WriteLine("First incident at {0}", nextIncident.Current.StartSessionTime);
            }
        }
コード例 #33
0
        void AnalyseIncidents()
        {
            iRacing.Replay.MoveToFrame(raceStartFrameNumber);

            incidents = new Incidents();

            if (!Settings.Default.DisableIncidentsSearch)
            {
                var incidentSamples = iRacing.GetDataFeed().RaceIncidents2(Settings.Default.IncidentScanWait, shortTestOnly ? 12 : int.MaxValue);

                foreach (var data in incidentSamples)
                    incidents.Process(data);
            }
        }
コード例 #34
0
        public void it_should_merge_two_incidents_for_same_driver()
        {
            var i = new Incidents();

            var session = CreateDrivers("dino");

            i.Process(CreateIncidentSample(0, 4.3d, session));
            i.Process(CreateIncidentSample(0, 5.2d, session));
             
            Assert.That(i.Count(), Is.EqualTo(1));

            var actual = i.First();

            Assert.That(actual.StartSessionTime, Is.EqualTo(3.3.Seconds()));
            Assert.That(actual.EndSessionTime, Is.EqualTo(13.2.Seconds()));
        }
コード例 #35
0
        public void it_should_identify_an_incident()
        {
            var i = new Incidents();

            var session = CreateDrivers("dino");

            var data = CreateIncidentSample(0, 4.3d, session);

            i.Process(data);

            Assert.That(i.Count(), Is.EqualTo(1));

            var actual = i.First();

            Assert.That(actual.LapNumber, Is.EqualTo(3));
            Assert.That(actual.StartSessionTime, Is.EqualTo(3.3.Seconds()));
            Assert.That(actual.EndSessionTime, Is.EqualTo(12.3.Seconds()));
            Assert.That(actual.Car.UserName, Is.EqualTo("dino"));
        }
コード例 #36
0
        public ReplayControl(SessionData sessionData, Incidents incidents, RemovalEdits removalEdits, TrackCameras trackCameras)
        {
            var cameras = trackCameras.Where(tc => tc.TrackName == sessionData.WeekendInfo.TrackDisplayName).ToArray();

            TraceInfo.WriteLineIf(cameras.Count() <= 0, "Track Cameras not defined for {0}", sessionData.WeekendInfo.TrackDisplayName);
            Debug.Assert(cameras.Count() > 0, "Track Cameras not defined for {0}".F(sessionData.WeekendInfo.TrackDisplayName));

            foreach (var tc in cameras)
                tc.CameraNumber = (short)sessionData.CameraInfo.Groups.First(g => g.GroupName.ToLower() == tc.CameraName.ToLower()).GroupNum;

            var camera = cameras.First(tc => tc.IsRaceStart);

            var cameraControl = new CameraControl(cameras);
            cameraControl.CameraOnPositon(1, camera.CameraNumber);

            var battleMarker = removalEdits.For(InterestState.Battle);
            var restartMarker = removalEdits.For(InterestState.Restart);

            var ruleLastSectors = new RuleLastLapPeriod(cameraControl, removalEdits);
            var ruleUnlimitedIncident = new RuleIncident(cameraControl, removalEdits, incidents, 999);
            var ruleLimitedIncident = new RuleIncident(cameraControl, removalEdits, incidents, Settings.Default.IgnoreIncidentsBelowPosition);
            var ruleFirstSectors = new RuleFirstLapPeriod(cameraControl, removalEdits);
            var rulePaceLaps = new RulePaceLaps(cameraControl, restartMarker, battleMarker);
            var ruleBattle = new RuleBattle(cameraControl, battleMarker, Settings.Default.CameraStickyPeriod, Settings.Default.BattleStickyPeriod, Settings.Default.BattleGap, Settings.Default.BattleFactor2);
            ruleRandom = new RuleRandomDriver(cameraControl, sessionData, Settings.Default.CameraStickyPeriod);

            var ruleForFirstSectors = Settings.Default.IgnoreIncidentsDuringRaceStart ? ruleFirstSectors : ruleFirstSectors.WithVeto(ruleUnlimitedIncident);

            directionRules = new IDirectionRule[] { 
                ruleLastSectors,
                ruleForFirstSectors,
                rulePaceLaps.WithVeto(ruleUnlimitedIncident.WithVeto(ruleLastSectors)),
                ruleBattle.WithVeto(ruleLimitedIncident.WithVeto(ruleLastSectors)),
                ruleUnlimitedIncident.WithVeto(ruleLastSectors),
                ruleRandom.WithVeto(ruleLastSectors)
            };

            currentRule = directionRules[0];
        }
コード例 #37
0
            public void setup()
            {
                incident = new Incidents();

                var session = CreateDrivers("dino", "georg");

                incident.Process(CreateIncidentSample(0, 4.3d, session));
                incident.Process(CreateIncidentSample(1, 5.4d, session));
                incident.Process(CreateIncidentSample(0, 6.2d, session));
            }