|
@@ -30,6 +30,10 @@ public class WorkerController : MonoBehaviour
|
|
|
static GameObject sStartStopButton;
|
|
|
public GameObject ErrorDialog;
|
|
|
public GameObject ButtonPlay;
|
|
|
+ public Dropdown DropdownMode;
|
|
|
+
|
|
|
+ enum Mode { RealTime = 0, History = 1 };
|
|
|
+ int mode = 0;
|
|
|
//public GameObject Time;
|
|
|
|
|
|
static Client client = new Client();
|
|
@@ -48,26 +52,27 @@ public class WorkerController : MonoBehaviour
|
|
|
{
|
|
|
DebugHelper.ActivateConsole();
|
|
|
|
|
|
- WorkerMarker(4);
|
|
|
- WorkerMarker(356);
|
|
|
+
|
|
|
+ WorkerMarker(4, Color.red);
|
|
|
+ WorkerMarker(356, Color.green);
|
|
|
|
|
|
sStartStopButton = StartStopButton;
|
|
|
|
|
|
- foreach (var s in structures.Select(s => s.acc_id).Distinct())
|
|
|
- WorkerMarker(s);
|
|
|
+ //foreach (var s in structures.Select(s => s.acc_id).Distinct())
|
|
|
+ // WorkerMarker(s, UnityEngine.Random.ColorHSV(0f, 1f, 1f, 1f, 0.5f, 1f));
|
|
|
|
|
|
- foreach (var s in structures.Select(s => s.ts.Date).Distinct())
|
|
|
- {
|
|
|
- dates.Add(s);
|
|
|
- DropdownData.options.Add(new Dropdown.OptionData(s.ToString("dd.MM.yyyy")));
|
|
|
- }
|
|
|
+ //foreach (var s in structures.Select(s => s.ts.Date).Distinct())
|
|
|
+ //{
|
|
|
+ // dates.Add(s);
|
|
|
+ // DropdownData.options.Add(new Dropdown.OptionData(s.ToString("dd.MM.yyyy")));
|
|
|
+ //}
|
|
|
|
|
|
//foreach (var s in structures.Select(s => s.location_id).Distinct())
|
|
|
//{
|
|
|
// locations.Add(s);
|
|
|
DropdownLocation.options.Add(new Dropdown.OptionData("22 Офис Ижевск"));
|
|
|
DropdownLocation.options.Add(new Dropdown.OptionData("25"));
|
|
|
- inputField_date.text = DateTime.Now.ToString("dd.MM.yyyy");
|
|
|
+ inputField_date.text = DateTime.Now.ToString("yyyy.MM.dd");
|
|
|
//}
|
|
|
}
|
|
|
|
|
@@ -75,6 +80,24 @@ public class WorkerController : MonoBehaviour
|
|
|
// Update is called once per frame
|
|
|
void Update()
|
|
|
{
|
|
|
+
|
|
|
+ if (DropdownMode.value != mode)
|
|
|
+ {
|
|
|
+ starting[starting.Count - 1] = false;
|
|
|
+ StartStopButton.transform.GetChild(0).GetComponent<Text>().text = "Отобразить";
|
|
|
+
|
|
|
+ mode = DropdownMode.value;
|
|
|
+ switch (DropdownMode.value)
|
|
|
+ {
|
|
|
+ case 0:
|
|
|
+ history_start = false;
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ real_time = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (active_location != DropdownLocation.value)
|
|
|
{
|
|
|
maps.ElementAt(active_location).SetActive(false);
|
|
@@ -106,7 +129,7 @@ public class WorkerController : MonoBehaviour
|
|
|
|
|
|
if (real_time && !inputField_location.text.Equals("") && Time.time >= nextTime)
|
|
|
{
|
|
|
- var dateNow = DateTime.UtcNow.AddHours(3);
|
|
|
+ //var dateNow = DateTime.UtcNow.AddHours(3);
|
|
|
//Time.GetComponent<Text>().text = dateNow.ToString();
|
|
|
starting.Add(true);
|
|
|
var location_id = uint.Parse(inputField_location.text);
|
|
@@ -114,9 +137,9 @@ public class WorkerController : MonoBehaviour
|
|
|
{
|
|
|
if (m.toggle.isOn)
|
|
|
{
|
|
|
- client.CoordinatesRequest(dateNow.AddSeconds(-2).Ticks, dateNow.Ticks, 1, location_id, m.acc_id);
|
|
|
-
|
|
|
- start = true;
|
|
|
+ client.CoordinatesRequest(-2, 0, 1, location_id, m.acc_id);
|
|
|
+
|
|
|
+ history_start = true;
|
|
|
//end_send[m.acc_id] = false;
|
|
|
}
|
|
|
}
|
|
@@ -124,14 +147,6 @@ public class WorkerController : MonoBehaviour
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void Play()
|
|
|
- {
|
|
|
- real_time = !real_time;
|
|
|
- if(real_time) ButtonPlay.transform.GetChild(0).GetComponent<Text>().text = "Stop";
|
|
|
- else ButtonPlay.transform.GetChild(0).GetComponent<Text>().text = "Play";
|
|
|
- //Time.SetActive(true);
|
|
|
- }
|
|
|
-
|
|
|
public static List<Marker> markers = new List<Marker>();
|
|
|
public class Marker
|
|
|
{
|
|
@@ -144,7 +159,7 @@ public class WorkerController : MonoBehaviour
|
|
|
/// Создание маркера для сотрудника
|
|
|
/// </summary>
|
|
|
/// <param name="acc_id"></param>
|
|
|
- void WorkerMarker(uint acc_id)
|
|
|
+ void WorkerMarker(uint acc_id, Color color)
|
|
|
{
|
|
|
var worker_toggle = Instantiate(Resources.Load("GameObjects/Toggle", typeof(Toggle))) as Toggle;
|
|
|
worker_toggle.name = acc_id.ToString();
|
|
@@ -155,7 +170,7 @@ public class WorkerController : MonoBehaviour
|
|
|
worker_marker.name = "marker_" + acc_id.ToString();
|
|
|
worker_marker.transform.GetChild(0).transform.GetChild(0).transform.GetChild(0).GetComponent<Text>().text = $"{acc_id}";
|
|
|
|
|
|
- worker_marker.GetComponent<Renderer>().material.color = UnityEngine.Random.ColorHSV(0f, 1f, 1f, 1f, 0.5f, 1f);
|
|
|
+ worker_marker.GetComponent<Renderer>().material.color = color; // UnityEngine.Random.ColorHSV(0f, 1f, 1f, 1f, 0.5f, 1f);
|
|
|
|
|
|
markers.Add(new Marker { acc_id = acc_id, marker = worker_marker, toggle = worker_toggle });
|
|
|
}
|
|
@@ -173,10 +188,10 @@ public class WorkerController : MonoBehaviour
|
|
|
/// <param name="progress">Номер записи из БД</param>
|
|
|
/// <param name="all">Всего записей из БД</param>
|
|
|
/// <returns></returns>
|
|
|
- static IEnumerator MarkerPostion(float pause,float step, Vector3 start_pos, Vector3 end_pos, GameObject worker_marker, Toggle toggle, Structure w, int count, int progress, int all)
|
|
|
+ static IEnumerator MarkerPostion(float pause, float step, Vector3 start_pos, Vector3 end_pos, GameObject worker_marker, Toggle toggle, Structure w, int count, int progress, int all)
|
|
|
{
|
|
|
yield return new WaitForSeconds(pause);
|
|
|
- if (worker_marker.activeSelf == true && start && starting[count])
|
|
|
+ if (worker_marker.activeSelf == true && history_start && starting[count])
|
|
|
{
|
|
|
var x_position = Mathf.Lerp(start_pos.x, end_pos.x, step);
|
|
|
var y_position = Mathf.Lerp(start_pos.z, end_pos.z, step);
|
|
@@ -184,18 +199,18 @@ public class WorkerController : MonoBehaviour
|
|
|
worker_marker.transform.position = new Vector3(x_position, 0.5f, y_position);
|
|
|
worker_marker.transform.GetChild(0).transform.GetChild(0).transform.GetChild(0).GetComponent<Text>().text = $"{w.acc_id} x={end_pos.x} y={end_pos.z}";
|
|
|
toggle.transform.GetChild(1).gameObject.GetComponent<Text>().text = $"{w.acc_id} {w.ts.ToString("hh:mm:ss")} {progress + 1} из {all}";
|
|
|
- if(progress + 1 == all)
|
|
|
+ if (progress + 1 == all)
|
|
|
{
|
|
|
sStartStopButton.transform.GetChild(0).GetComponent<Text>().text = "Отобразить";
|
|
|
starting[count] = false;
|
|
|
- start = false;
|
|
|
+ history_start = false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void Position(float step, Vector3 start_pos, Vector3 end_pos, GameObject worker_marker, Toggle toggle, Structure w, int count)
|
|
|
{
|
|
|
- if (worker_marker.activeSelf == true && start && starting[count])
|
|
|
+ if (worker_marker.activeSelf == true && history_start && starting[count])
|
|
|
{
|
|
|
var x_position = Mathf.Lerp(start_pos.x, end_pos.x, Time.time - interval);
|
|
|
var y_position = Mathf.Lerp(start_pos.z, end_pos.z, Time.time - interval);
|
|
@@ -214,81 +229,93 @@ public class WorkerController : MonoBehaviour
|
|
|
// Debug.Log(t);
|
|
|
//}
|
|
|
|
|
|
- static bool start = false;
|
|
|
+ static bool history_start = false;
|
|
|
/// <summary>
|
|
|
/// Запуск отрисовки
|
|
|
/// </summary>
|
|
|
public void ButtonStart()
|
|
|
{
|
|
|
- if (int.Parse(StartHour.GetComponent<InputField>().text) == 99) SceneManager.LoadScene("Editor");
|
|
|
- else start = !start;
|
|
|
- if (start)
|
|
|
- {
|
|
|
- starting.Add(true);
|
|
|
- var date = DateTime.Now; var error_date = false;
|
|
|
- try
|
|
|
- {
|
|
|
- date = DateTime.Parse(inputField_date.text);
|
|
|
- }
|
|
|
- catch (Exception e)
|
|
|
- {
|
|
|
- ErrorDialog.SetActive(true);
|
|
|
- error_date = true;
|
|
|
- var text = ErrorDialog.transform.GetChild(0).GetComponent<Text>().text = "Некорректный формат даты";
|
|
|
- start = false;
|
|
|
- }
|
|
|
-
|
|
|
- var time_start = date; //new DateTime(dates.ElementAt(DropdownData.value).Ticks);
|
|
|
- time_start = time_start.AddHours(int.Parse(StartHour.GetComponent<InputField>().text));
|
|
|
- time_start = time_start.AddMinutes(int.Parse(StartMin.GetComponent<InputField>().text));
|
|
|
- time_start = time_start.AddSeconds(int.Parse(StartSec.GetComponent<InputField>().text));
|
|
|
- Debug.Log(time_start);
|
|
|
- //var time_start = new DateTime(1, 1, 1, int.Parse(StartHour.GetComponent<InputField>().text), int.Parse(StartMin.GetComponent<InputField>().text), int.Parse(StartSec.GetComponent<InputField>().text));
|
|
|
-
|
|
|
- //var time_end = new DateTime(1, 1, 1, int.Parse(EndHour.GetComponent<InputField>().text), int.Parse(EndMin.GetComponent<InputField>().text), int.Parse(EndSec.GetComponent<InputField>().text));
|
|
|
- var time_end = date; //new DateTime(dates.ElementAt(DropdownData.value).Ticks);
|
|
|
- time_end = time_end.AddHours(int.Parse(EndHour.GetComponent<InputField>().text));
|
|
|
- time_end = time_end.AddMinutes(int.Parse(EndMin.GetComponent<InputField>().text));
|
|
|
- time_end = time_end.AddSeconds(int.Parse(EndSec.GetComponent<InputField>().text));
|
|
|
- // client.account_id = 356;
|
|
|
-
|
|
|
- //StartCoroutine(RequestPostion(time_start.Ticks, time_end.Ticks, 22, 356));
|
|
|
- if (!error_date)
|
|
|
- {
|
|
|
- try
|
|
|
+ var button_text = StartStopButton.transform.GetChild(0);
|
|
|
+ switch (DropdownMode.value)
|
|
|
+ {
|
|
|
+ case 0:
|
|
|
+ real_time = !real_time;
|
|
|
+ if (real_time) button_text.GetComponent<Text>().text = "Остановить";
|
|
|
+ else button_text.GetComponent<Text>().text = "Отобразить";
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ if (int.Parse(StartHour.GetComponent<InputField>().text) == 99) SceneManager.LoadScene("Editor");
|
|
|
+ else history_start = !history_start;
|
|
|
+ if (history_start)
|
|
|
{
|
|
|
- var location_id = uint.Parse(inputField_location.text);
|
|
|
- foreach (var m in markers)
|
|
|
+ starting.Add(true);
|
|
|
+ var date = DateTime.Now; var error_date = false;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ date = DateTime.Parse(inputField_date.text);
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ ErrorDialog.SetActive(true);
|
|
|
+ error_date = true;
|
|
|
+ var text = ErrorDialog.transform.GetChild(0).GetComponent<Text>().text = "Некорректный формат даты";
|
|
|
+ history_start = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ var time_start = date; //new DateTime(dates.ElementAt(DropdownData.value).Ticks);
|
|
|
+ time_start = time_start.AddHours(int.Parse(StartHour.GetComponent<InputField>().text));
|
|
|
+ time_start = time_start.AddMinutes(int.Parse(StartMin.GetComponent<InputField>().text));
|
|
|
+ time_start = time_start.AddSeconds(int.Parse(StartSec.GetComponent<InputField>().text));
|
|
|
+ Debug.Log(time_start);
|
|
|
+ //var time_start = new DateTime(1, 1, 1, int.Parse(StartHour.GetComponent<InputField>().text), int.Parse(StartMin.GetComponent<InputField>().text), int.Parse(StartSec.GetComponent<InputField>().text));
|
|
|
+
|
|
|
+ //var time_end = new DateTime(1, 1, 1, int.Parse(EndHour.GetComponent<InputField>().text), int.Parse(EndMin.GetComponent<InputField>().text), int.Parse(EndSec.GetComponent<InputField>().text));
|
|
|
+ var time_end = date; //new DateTime(dates.ElementAt(DropdownData.value).Ticks);
|
|
|
+ time_end = time_end.AddHours(int.Parse(EndHour.GetComponent<InputField>().text));
|
|
|
+ time_end = time_end.AddMinutes(int.Parse(EndMin.GetComponent<InputField>().text));
|
|
|
+ time_end = time_end.AddSeconds(int.Parse(EndSec.GetComponent<InputField>().text));
|
|
|
+ // client.account_id = 356;
|
|
|
+
|
|
|
+ //StartCoroutine(RequestPostion(time_start.Ticks, time_end.Ticks, 22, 356));
|
|
|
+ if (!error_date)
|
|
|
{
|
|
|
- if (m.toggle.isOn)
|
|
|
+ try
|
|
|
{
|
|
|
- client.CoordinatesRequest(time_start.Ticks, time_end.Ticks, 1, location_id, m.acc_id);
|
|
|
- //end_send[m.acc_id] = false;
|
|
|
+ var location_id = uint.Parse(inputField_location.text);
|
|
|
+ foreach (var m in markers)
|
|
|
+ {
|
|
|
+ if (m.toggle.isOn)
|
|
|
+ {
|
|
|
+ client.CoordinatesRequest(time_start.Ticks, time_end.Ticks, 1, location_id, m.acc_id);
|
|
|
+ //end_send[m.acc_id] = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ button_text.GetComponent<Text>().text = "Остановить";
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ ErrorDialog.SetActive(true);
|
|
|
+ ErrorDialog.transform.GetChild(0).GetComponent<Text>().text = "Введите идентификатор локации";
|
|
|
+ history_start = false;
|
|
|
}
|
|
|
}
|
|
|
- StartStopButton.transform.GetChild(0).GetComponent<Text>().text = "Остановить";
|
|
|
+
|
|
|
+ // var workers = structures.Where(w => w.ts >= time_start && w.ts <= time_end && w.location_id == int.Parse(DropdownLocation.options[DropdownLocation.value].text.ToString())).ToList();
|
|
|
+
|
|
|
+ //foreach (var m in markers)
|
|
|
+ // if (m.toggle.isOn)
|
|
|
+ // StartingAccPositiong(m);
|
|
|
}
|
|
|
- catch (Exception e)
|
|
|
+ else
|
|
|
{
|
|
|
- ErrorDialog.SetActive(true);
|
|
|
- ErrorDialog.transform.GetChild(0).GetComponent<Text>().text = "Введите идентификатор локации";
|
|
|
- start = false;
|
|
|
+ button_text.GetComponent<Text>().text = "Отобразить";
|
|
|
+ starting[starting.Count - 1] = false;
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- // var workers = structures.Where(w => w.ts >= time_start && w.ts <= time_end && w.location_id == int.Parse(DropdownLocation.options[DropdownLocation.value].text.ToString())).ToList();
|
|
|
-
|
|
|
- //foreach (var m in markers)
|
|
|
- // if (m.toggle.isOn)
|
|
|
- // StartingAccPositiong(m);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- StartStopButton.transform.GetChild(0).GetComponent<Text>().text = "Отобразить";
|
|
|
- starting[starting.Count - 1] = false;
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
public void ErrorDialogClose()
|
|
|
{
|
|
|
ErrorDialog.SetActive(false);
|