using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Networking; using UnityEngine.UI; using UnityEngine.EventSystems; using System.Net; using System.Net.NetworkInformation; using System.Net.Sockets; using System.IO; using System.Text; using System.Globalization; public class ReadURL : MonoBehaviour { private static Dictionary parameters = new Dictionary(); private static string testParameters; public static bool HasKey(string key) { return parameters.ContainsKey(key); } public static string GetValue(string key) { return parameters[key]; } public static void path() { #if UNITY_EDITOR //Link to test in editor only //testParameters = "https://software.ciemetric.com/9987/?key=template&save=https%3A%2F%2Flab.cieblink.com%2Fciemetric%2Fsave%3Ftype%3Dquotation%26id%3D20187%26line%3D2584455&file=https%3A%2F%2Fs3.ca-central-1.amazonaws.com%2Fcieblink-dev%2Fdocument%2Fe6e134f2a5213093811cb56a882da1084ffb7b13.UDT%3FX-Amz-Content-Sha256%3DUNSIGNED-PAYLOAD%26X-Amz-Algorithm%3DAWS4-HMAC-SHA256%26X-Amz-Credential%3DAKIAJCUKSZNZHX6SKU2Q%252F20220928%252Fca-central-1%252Fs3%252Faws4_request%26X-Amz-Date%3D20220928T071630Z%26X-Amz-SignedHeaders%3Dhost%26X-Amz-Expires%3D604800%26X-Amz-Signature%3D03a9de131884492c2f5e9db2ea911e3c8e0cf495bc14ee778f4174967899f38f"; //testParameters = "https://software.ciemetric.com/9987/?key=template&save=https%3A%2F%2Flab.cieblink.com%2Fciemetric%2Fsave%3Ftype%3Dquotation%26id%3D20187%26line%3D2584455"; //testParameters = "https://software.ciemetric.com/9990?key=template"; //testParameters = "https://software.ciemetric.com/9990?template"; //testParameters ="https://software.ciemetric.com/9991/?key=armoirestrudeau&save=https%3A%2F%2Flab.cieblink.com%2Fciemetric%2Fsave%3Ftype%3Dorder%26id%3D591265%26line%3D2585127"; //testParameters = "https://software.ciemetric.com/soft/version/alpha_kevin/?key=cuisines_action&env=https%3A%2F%2Flab.cieblink.com%2F&room_id=3476225&ref_type=quotation&ref_id=29833&save=https%3A%2F%2Flab.cieblink.com%2Fciemetric%2Fsave%3Ftype%3Dquotation%26id%3D29833%26line%3D3476225&file=https%3A%2F%2Fs3.ca-central-1.amazonaws.com%2Fcieblink-dev%2Fdocument%2Fe4542477eaa73c372559f4a3647fdce9ba8daf09.UDT%3FX-Amz-Content-Sha256%3DUNSIGNED-PAYLOAD%26X-Amz-Algorithm%3DAWS4-HMAC-SHA256%26X-Amz-Credential%3DAKIAJCUKSZNZHX6SKU2Q%252F20230425%252Fca-central-1%252Fs3%252Faws4_request%26X-Amz-Date%3D20230425T144546Z%26X-Amz-SignedHeaders%3Dhost%26X-Amz-Expires%3D604800%26X-Amz-Signature%3D1eab0a82438487c37696e032dc889f2a66edf8a9d2bfba81ec357370ac4430b4"; //testParameters = "https://software.ciemetric.com/soft/version/alpha_onnig/?key=cuisines_action&env=https%3A%2F%2Flab.cieblink.com%2F&room_id=3477443&ref_type=order&ref_id=746059&save=https%3A%2F%2Flab.cieblink.com%2Fciemetric%2Fsave%3Ftype%3Dorder%26id%3D746059%26line%3D3477443"; testParameters = ""; #else testParameters = Application.absoluteURL; #endif if (testParameters != "") { SetRequestParameters(testParameters); } foreach (string param in parameters.Keys) { //Debug.Log(param); if (param == "key") { _G._key = GetValue("key"); Debug.Log("The key = " + _G._key); } else if (param == "save") { _G._saveLink = GetValue("save"); Debug.Log("The Link For Saving= " + _G._saveLink); } else if (param == "file") { _G._file = GetValue("file"); Debug.Log("The Cieblink File URL= " + _G._file); // UDT } else if (param == "mtfile") { _G._mtfile = GetValue("mtfile"); } else if (param == "mt") { _G._mt = GetValue("mt"); } else if (param == "room_id") { _G._ROOM_ID = GetValue(param); } else if (param == "source") { _G._SOURCE = GetValue(param); } else if(param == "ref_type") { _G.ref_type = GetValue(param); } else if (param == "ref_id") { _G.ref_id = GetValue(param); } } if (_G._key != "") { _G.PATH = _G._key; } if (_G._mt != "") { _G.PATH = _G._mt; } if (testParameters.IndexOf("?") != -1 && testParameters.IndexOf("&") == -1 && testParameters.IndexOf("key") == -1) { //print("testParameters==="+testParameters);//https://software.ciemetric.com/9987/?template int index1 = testParameters.IndexOf("?"); _G.PATH = testParameters.Substring(index1 + 1, testParameters.Length - index1 - 1); } if (testParameters.IndexOf("?") != -1 && testParameters.IndexOf("&") == -1 && testParameters.IndexOf("key") != -1) { //print("testParameters==="+testParameters);//"https://software.ciemetric.com/9990?key=template"; int index1 = testParameters.IndexOf("?"); _G.PATH = testParameters.Substring(index1 + 5, testParameters.Length - index1 - 5); } if (_G._file != "") { Get.o3("Canvas", "Panel_main", "START").SetActive(false); Get.o3("Canvas", "Panel_main", "OPEN").SetActive(false); } Get.o2("Canvas", "PATH").GetComponent().text = _G.PATH; //print("_G.PATH ==="+_G.PATH ); } public static void SetRequestParameters(string parametersString) { print("pass-------------------------------------SetRequestParameters"); char[] parameterDelimiters = new char[] { '?', '&' }; string[] parameters = parametersString.Split(parameterDelimiters, System.StringSplitOptions.RemoveEmptyEntries); char[] keyValueDelimiters = new char[] { '=' }; for (int i = 0; i < parameters.Length; ++i) { string[] keyValue = parameters[i].Split(keyValueDelimiters, System.StringSplitOptions.None); if (keyValue.Length >= 2) { ReadURL.parameters.Add(UnityWebRequest.UnEscapeURL(keyValue[0]), UnityWebRequest.UnEscapeURL(keyValue[1])); } else if (keyValue.Length == 1) { ReadURL.parameters.Add(UnityWebRequest.UnEscapeURL(keyValue[0]), ""); } } } }