示例#1
0
        /// <summary>
        /// Exports the <see cref="LogMessage"/> with its data into a comma seperated line.
        /// </summary>
        /// <returns>The <see cref="LogMessage"/> with its data as a comma seperated line.</returns>
        public override string GetCsvLine()
        {
            string messageValue = string.Format("\"{0}\",\"{1}\",\"{2}\",\"{3}\",\"{4}\",\"{5}\",\"{6}\",\""
                                                , mIndex.ToCsv()
                                                , mLevel.ToCsv()
                                                , mTimestamp.ToString(Settings.Default.TimestampFormat)
                                                , mLogger.ToCsv()
                                                , mThread.ToCsv()
                                                , mMessage.ToCsv()
                                                , mLocation.ToString().ToCsv());

            foreach (KeyValuePair <string, string> customProperty in mCustomProperties)
            {
                messageValue += string.Format("{0}: {1},"
                                              , customProperty.Key.ToCsv()
                                              , customProperty.Value.ToCsv());
            }

            if (messageValue.Length > 0)
            {
                // Remove the last comma from the custom properties string.
                messageValue = messageValue.Remove(
                    messageValue.Length - 1
                    , 1);
            }

            return(messageValue + "\"");
        }
        private IEnumerator StartLocationService(float desiredAccuracy, float minDistance, Action <LocationInfo> doneHandler = null)
        {
            Debug.Log("ULS:StartLocationService");
            if (!IsLocationServiceEnabled())
            {
                Debug.LogError("ULS:No location service!");
                yield break;
            }


            loc.Start(desiredAccuracy, desiredAccuracy);
            yield return(loc);

            Debug.Log("ULS:Started loc update request");

            var maxWaitSeconds = 30; // TODO find value

            while (loc.status == LocationServiceStatus.Initializing && maxWaitSeconds > 0)
            {
                Debug.Log("ULS: Waiting..." + maxWaitSeconds);
                yield return(new WaitForSeconds(maxWaitSeconds--));
            }
            Debug.Log("ULS: Late init checks");
            if (loc.status == LocationServiceStatus.Failed)
            {
                Debug.LogError("ULS:Failed initalize unity location service");
                yield break;
            }

            if (maxWaitSeconds <= 0)
            {
                timedOut = true;
                Debug.LogError("ULSLocation service initialization timed out.");
            }

            yield return(lastKnownLocation = loc.lastData);

            Debug.Log("ULS:LastKnownLocation: " + lastKnownLocation.ToString());
            if (doneHandler != null)
            {
                Debug.Log("ULS:SingleRequest, send data back");
                doneHandler.Invoke(lastKnownLocation);
                loc.Stop();
                Debug.Log("ULS:Stopped after SingleRequest");
            }
        }
    private IEnumerator RequestAtPos(LocationInfo location)
    {
        lastUpdate  = location;
        hasLocation = true;
        print("Making web request at " + location.ToString());
        using (UnityWebRequest www = UnityWebRequest.Get(API_ROOT + "/notes?lat=" + location.latitude + "&long="
                                                         + location.longitude + "&resolution=" + REQUEST_RESOLUTION_DEG)) {
            yield return(www.SendWebRequest());

            if (www.isNetworkError || www.isHttpError)
            {
                print("Failed to make request.");
                print(www.error);
                hasLocation = false;
            }
            else
            {
                print(www.downloadHandler.text);
                NoteResult result = JsonUtility.FromJson <NoteResult>(www.downloadHandler.text);
                print("Got " + result.notes.Length + " items.");
                onNotesUpdated.Invoke(result.notes, location);
            }
        }
    }