public void FixedUpdate() { if (!isStarted && _startup) { // Load scenario JSON TextAsset scenarioJsonFile = Resources.Load <TextAsset>(scenariosPath + scenarioId + "/scenario"); ScenarioJson scenarioJson = JsonUtility.FromJson <ScenarioJson>(scenarioJsonFile.text); // Set current simulated time currentSimulatedTime = Convert.ToDateTime(scenarioJson.currentSimulatedTime); // Set Point Last Seen pointLastSeen = scenarioJson.pointLastSeen; // Set Last Known Position lastKnownPosition = scenarioJson.lastKnownPosition; // Set Command Post location commandPostLocation = scenarioJson.commandPostLocation; // Setup field teams foreach (FieldTeamJson fieldTeamJson in scenarioJson.fieldTeams) { GameObject fieldTeamObj = GameObject.Instantiate(fieldTeamPrefab, this.transform); FieldTeam fieldTeam = fieldTeamObj.GetComponent <FieldTeam>(); fieldTeam.teamName = fieldTeamJson.name; ColorUtility.TryParseHtmlString(fieldTeamJson.color, out fieldTeam.teamColor); fieldTeam.recordingDirectoryPath = scenariosPath + scenarioId + "/TeamRecords/" + fieldTeamJson.path; fieldTeam.simulatedStartTime = Convert.ToDateTime(fieldTeamJson.simulatedStartTime); fieldTeam.mainController = this; AddFieldTeam(fieldTeam); } //// Instantiate PLS and LKP markers //plsMarkerObj = GameObject.Instantiate(plsMarkerPrefab, sceneUiObj.transform); //plsMarkerObj.transform.SetSiblingIndex(0); //lkpMarkerObj = GameObject.Instantiate(lkpMarkerPrefab, sceneUiObj.transform); //lkpMarkerObj.transform.SetSiblingIndex(0); // Instantiate Command Post marker cpMarkerObj = GameObject.Instantiate(cpMarkerPrefab, sceneUiObj.transform); cpMarkerObj.transform.SetSiblingIndex(0); _startTimeOfSimulation = currentSimulatedTime.dateTime; _actualStartTime = DateTime.Now; networkEvents.AddHandler("MessageToCommand", MessageToCommand); //LayoutRebuilder.MarkLayoutForRebuild(sideUiObj.GetComponent<RectTransform>()); Canvas.ForceUpdateCanvases(); layoutGroupToRefresh.enabled = false; layoutGroupToRefresh.enabled = true; isStarted = true; _startup = false; GameObject.Destroy(startScreenObj); } }
internal static void FillMembers(FieldTeam item) { //\"FieldTeamSystemId\", \"FieldTeamId\", \"PersonSystemId\", \"PersonId\", \"FieldTeamMemberRoleSystemId\", \"FieldTeamMemberRoleId\" if (item != null) { NpgsqlCommand cmd = Db.GetCmd(Db.ConnectionString); cmd.CommandText = Db.SelectFieldTeamMembers; cmd.Parameters.AddWithValue("sid", item.Identity.DataStoreIdentity); cmd.Parameters.AddWithValue("id", item.Identity.Identity); NpgsqlDataReader rdr = Db.ExecuteReader(cmd); if (rdr != null) { try { FieldTeamMembers m = item.Members; while (rdr.Read()) { m.Add(new FieldTeamMember(new CompoundIdentity(DbReaderUtils.GetGuid(rdr, 2), DbReaderUtils.GetGuid(rdr, 3)), new CompoundIdentity(DbReaderUtils.GetGuid(rdr, 4), DbReaderUtils.GetGuid(rdr, 5)))); } if (cmd.Connection.State == System.Data.ConnectionState.Open) { cmd.Connection.Close(); } } catch { } finally { cmd.Dispose(); } } } }
public override FieldTeam Get(CompoundIdentity id) { if (!id.IsNullOrEmpty() && this.CanGet()) { NpgsqlCommand cmd = Db.GetCmd(Db.ConnectionString); cmd.CommandText = Db.SelectFieldTeams + Db.SelectById; cmd.Parameters.AddWithValue("sid", id.DataStoreIdentity); cmd.Parameters.AddWithValue("id", id.Identity); NpgsqlDataReader rdr = Db.ExecuteReader(cmd); FieldTeam o = null; if (rdr != null) { try { rdr.Read(); o = FieldTeamBuilder.Instance.Build(rdr); if (cmd.Connection.State == System.Data.ConnectionState.Open) { cmd.Connection.Close(); } } catch { } finally { cmd.Dispose(); } } return(o); } return(null); }
public override bool Contains(FieldTeam team, FieldTrip item) { if (team != null && item != null && this.CanGet()) { return(ContainsImpl(team.Identity, item.Identity, FieldActivityUtils.FieldTripWktId)); } return(false); }
public override bool Remove(FieldTeam team, FieldActivity item) { if (team != null && item != null) { return(Remove(team.Identity, item.Identity, FieldActivityUtils.FieldActivityWktId)); } return(false); }
public override bool Add(FieldTeam team, FieldActivity item) { if (team != null && item != null && this.CanCreate()) { return(this.AddImpl(team.Identity, item.Identity, FieldActivityUtils.FieldActivityWktId)); } return(false); }
private bool UpdateMembers(FieldTeam item) { bool clear = this.DeleteMembers(item.Identity); if (clear && item.Members.Count > 0) { try { NpgsqlCommand cmd = Db.GetCmd(Db.ConnectionString); cmd.CommandText = Db.InsertFieldTeamMembers; if (cmd.Connection.State != ConnectionState.Open) { cmd.Connection.Open(); } foreach (FieldTeamMember cur in item.Members) { if (cur != null && !cur.FieldTeamMemberRoleId.IsNullOrEmpty() && !cur.PersonId.IsNullOrEmpty()) { try { //:sid, :id, :psid, :pid, :rsid, :rid) cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("sid", item.Identity.DataStoreIdentity); cmd.Parameters.AddWithValue("id", item.Identity.Identity); cmd.Parameters.AddWithValue("psid", cur.PersonId.DataStoreIdentity); cmd.Parameters.AddWithValue("pid", cur.PersonId.Identity); cmd.Parameters.AddWithValue("rsid", cur.FieldTeamMemberRoleId.DataStoreIdentity); cmd.Parameters.AddWithValue("rid", cur.FieldTeamMemberRoleId.Identity); cmd.ExecuteNonQuery(); } catch { } } } try { if (cmd.Connection.State == ConnectionState.Open) { cmd.Connection.Close(); } } catch { } return(true); } catch { } } return(clear); }
public void ShowAllFieldTeams(bool showExtraDetails = false) { foreach (Transform t in this.transform) { FieldTeam ft = t.gameObject.GetComponent <FieldTeam>(); if (ft != null && ft.isActiveAndEnabled) { ft.showExtraDetails = showExtraDetails; ft.fieldTeamAppearStatus = FieldTeam.FieldTeamAppearStatus.Showing; } } }
public void AddFieldTeam(FieldTeam fieldTeam) { if (_earliestSimulatedStartTime == null || fieldTeam.simulatedStartTime.dateTime < _earliestSimulatedStartTime.dateTime) { _earliestSimulatedStartTime = fieldTeam.simulatedStartTime; } if (_latestSimulatedEndTime == null || fieldTeam.simulatedEndTime.dateTime > _latestSimulatedEndTime) { _latestSimulatedEndTime = fieldTeam.simulatedEndTime; } fieldTeam.FieldTeamInstantiate(); }
public override void OnBackButtonClick(GameObject fromPage, GameObject toPage) { mainController.ShowAllFieldTeams(false); selectedFieldTeam = null; currentlyActivePage = CurrentlyActivePage.MainMenu; Image liveFootageImage = liveFootageObj.GetComponent <Image>(); liveFootageImage.sprite = null; _lastDisplayedThumbnailImagePath = null; }
public void ShowTeamDetails(FieldTeam ft) { selectedFieldTeam = ft; selectedFieldTeam.ShowThisFieldTeamOnly(true); ftdPageTeamColorIconObj.GetComponent <Image>().color = selectedFieldTeam.teamColor; ftdPageTeamNameTextObj.GetComponent <Text>().text = selectedFieldTeam.teamName; mainMenuPageObj.SetActive(false); fieldTeamDetailsPageObj.SetActive(true); DisplayFieldTeamLiveImage( selectedFieldTeam.GetPhotoPathFromSimulatedTime(selectedFieldTeam.simulatedTimeLastOnline), selectedFieldTeam.GetPhotoThumbnailPathFromSimulatedTime(selectedFieldTeam.simulatedTimeLastOnline), selectedFieldTeam.GetGrayscalePhotoThumbnailPathFromSimulatedTime(selectedFieldTeam.simulatedTimeLastOnline) ); currentlyActivePage = CurrentlyActivePage.FieldTeamDetails; }
public override bool Update(FieldTeam item) { if (item != null && this.CanUpdate(item)) { try { NpgsqlCommand cmd = Db.GetCmd(Db.ConnectionString); cmd.CommandText = Db.UpdateFieldTeam; cmd.Parameters.AddWithValue("sid", item.Identity.DataStoreIdentity); cmd.Parameters.AddWithValue("id", item.Identity.Identity); cmd.Parameters.AddWithValue("name", item.Name); cmd.Parameters.AddWithValue("desc", item.Description); Db.ExecuteNonQuery(cmd); return(this.UpdateMembers(item)); } catch { } } return(false); }
private IEnumerable <FieldTeam> Get(CompoundIdentity eid, Guid wktid) { //:esid, :eid, :wtid NpgsqlCommand cmd = Db.GetCmd(Db.ConnectionString); cmd.CommandText = Db.SelectFieldTeamByAssociation; cmd.Parameters.AddWithValue("esid", eid.DataStoreIdentity); cmd.Parameters.AddWithValue("eid", eid.Identity); cmd.Parameters.AddWithValue("wtid", wktid); NpgsqlDataReader rdr = Db.ExecuteReader(cmd); if (rdr != null) { try { List <FieldTeam> m = new List <FieldTeam>(); FieldTeam tmp = null; while (rdr.Read()) { tmp = FieldTeamBuilder.Instance.Build(rdr); if (tmp != null) { m.Add(tmp); } } if (cmd.Connection.State == System.Data.ConnectionState.Open) { cmd.Connection.Close(); } } catch { } finally { cmd.Dispose(); } } return(null); }
public override bool CanUpdate(FieldTeam item) { return(this.CanUpdate()); //TODO -- add fine grained security }