123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.SceneManagement;
- using UnityEngine.UI;
- using UnityEngine.Networking;
- using System.Text.RegularExpressions;
- using System.Data.SqlClient;
- using TMPro;
- using System;
- using System.IO;
- using ZXing;
- using ZXing.QrCode;
- using System.Net;
- using SimpleJSON;
- using System.ComponentModel;
-
- public class Main : MonoBehaviour
- {
-
- [SerializeField] GameObject 讀取面板;
- [SerializeField] TextMeshProUGUI 讀取;
-
- [SerializeField] GameObject 選單;
- [SerializeField] TextMeshProUGUI 伺服器;
-
- [SerializeField] Button 電子簽章_cb;
- [SerializeField] Button 個人照號管理_cb;
- [SerializeField] Button 點名_cb;
- [SerializeField] Button 庫存表_cb;
- [SerializeField] Button 生產排程表_cb;
- [SerializeField] Button 生產日報表_cb;
- [SerializeField] Button 出貨排程表_cb;
- [SerializeField] Button 出貨日報表_cb;
- [SerializeField] Button 庫存盤點_cb;
- [SerializeField] Button 庫存審查_cb;
- [SerializeField] Button 加班紀錄_cb;
-
- private List<Button> bts = new List<Button>();
-
- private string str;
- public CanvasScaler canvasScaler;
- public float idleTime = 300f; // 5分鐘的閒置時間
- private float timeSinceLastInteraction = 0f;
-
-
- private int buttonPressCount = 0;
- private float lastButtonPressTime = 0.0f;
- public float maxButtonPressInterval = 0.2f;
- public int requiredButtonPressCount = 5;
-
-
- private float timer = 0f;
- private float interval = 60f;
-
- private ScreenOrientation currentOrientation;
-
- float scale = 0;
- float xbar = 0;
- float ybar = 0;
- RectTransform panelRectTransform;
- float screenWidth;
- float screenHeight;
-
- private string loadingText = "";
- private int dotCount = 0;
- // Start is called before the first frame update
- void Start()
- {
- Screen.autorotateToPortrait = true;
- Screen.orientation = ScreenOrientation.AutoRotation;
- if (Screen.orientation == ScreenOrientation.LandscapeLeft)
- {
-
- float rate = 900.0f / 1900.0f;
- if (Main.Global.rate<rate)
- {
- canvasScaler.matchWidthOrHeight = 1f;
- }
- else
- {
- canvasScaler.matchWidthOrHeight = 0f;
- }
- }
- if (Screen.orientation == ScreenOrientation.Portrait)
- {
- float rate = 900.0f / 1900.0f;
- if (Main.Global.rate>rate)
- {
- canvasScaler.matchWidthOrHeight = 1f;
- }
- else
- {
- canvasScaler.matchWidthOrHeight = 0f;
- }
- }
-
- if (Main.Global.預設伺服器路徑=="official")
- {
- 伺服器.text="official";
- }
- else
- {
- 伺服器.text="test";
- }
-
- if (Main.Global.阿帕契路徑==Main.Global.PHP[0, 1] || Main.Global.阿帕契路徑==Main.Global.PHP[2, 1])
- {
- Main.Global.阿帕契路徑=Main.Global.PHP[2, 1];
- }
- else
- {
- Main.Global.阿帕契路徑=Main.Global.PHP[3, 1];
- }
- currentOrientation = Screen.orientation;
- //Main.Global.阿帕契路徑="http://106.1.48.106:8080/wp-content/themes/event-star/ow_main.php?";
- StartCoroutine(AnimateText());
- 讀取面板.SetActive(true);
- //Main.Global.預設伺服器路徑="official";
- //Main.Global.系統語言="繁體中文";
- //Main.Global.PA="b70340";
- //Main.Global.PB="0911274990";
- StartCoroutine(讀取CC());
- }
- void Update()
- {
-
- if (Screen.orientation != currentOrientation)
- {
- if (Screen.orientation == ScreenOrientation.LandscapeLeft)
- {
- change_Secen(12);
-
- }
- if (Screen.orientation == ScreenOrientation.Portrait)
- {
- change_Secen(1);
- }
- }
-
- }
- IEnumerator AnimateText()
- {
- string qqq = 讀取.text.ToString();
- while (true)
- {
- yield return new WaitForSeconds(0.5f);
-
- if (dotCount < 3)
- {
- loadingText += ".";
- dotCount++;
- }
- else
- {
- loadingText = "";
- dotCount = 0;
- }
-
- 讀取.text = qqq+loadingText;
- }
- }
- public void OnButtonPress()
- {
-
- if (Time.time - lastButtonPressTime > maxButtonPressInterval)
- {
-
- buttonPressCount = 0;
- }
- else
- {
-
- buttonPressCount++;
- }
- lastButtonPressTime = Time.time;
- if (buttonPressCount >= requiredButtonPressCount)
- {
- // 觸發你想要的事件
- buttonPressCount = 0;
- 選單.SetActive(true);
- }
- }
- IEnumerator 讀取CC()
- {
- string strcon = "讀取";
- string name = Main.Global.PA;
- string ps = Main.Global.PB;
- string se = Main.Global.預設伺服器路徑;
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&帳號={1}&密碼={2}&se={3}", strcon, name, ps, se);
- Debug.Log(strUrl);
-
- UnityWebRequest request = UnityWebRequest.Get(strUrl);
- yield return request.SendWebRequest();
- if (request.result == UnityWebRequest.Result.ConnectionError)
- {
- //Debug.Log(request.error);
- }
- JSONNode json1 = JSON.Parse(request.downloadHandler.text);
- Debug.Log(json1);
- 讀取面板.SetActive(false);
- Main.Global.人員 = json1[0].ToString().Trim('"');
- Main.Global.級別 = json1[129].ToString().Trim('"');
- Main.Global.部門 = json1[130].ToString().Trim('"');
- Main.Global.職稱 = json1[131].ToString().Trim('"');
- Debug.Log(Main.Global.人員);
- 電子簽章_cb.gameObject.SetActive(false);
- //bts.Add(電子簽章_cb);
- bts.Add(個人照號管理_cb);
- bts.Add(庫存表_cb);
- if (json1[52].ToString()=="0")
- {
- 點名_cb.gameObject.SetActive(false);
- }
- else
- {
- bts.Add(點名_cb);
- }
- if (json1[53].ToString()=="0")
- {
- 生產排程表_cb.gameObject.SetActive(false);
- }
- else
- {
- bts.Add(生產排程表_cb);
- }
- if (json1[106].ToString()=="0")
- {
- 生產日報表_cb.gameObject.SetActive(false);
- }
- else
- {
- bts.Add(生產日報表_cb);
- }
- if (json1[109].ToString()=="0")
- {
- 出貨排程表_cb.gameObject.SetActive(false);
- }
- else
- {
- bts.Add(出貨排程表_cb);
- }
- if (json1[114].ToString()=="0")
- {
- 出貨日報表_cb.gameObject.SetActive(false);
- }
- else
- {
- bts.Add(出貨日報表_cb);
- }
- if (json1[85].ToString()=="0")
- {
- 庫存盤點_cb.gameObject.SetActive(false);
- }
- else
- {
- bts.Add(庫存盤點_cb);
- }
- if (json1[86].ToString()=="0")
- {
- 庫存審查_cb.gameObject.SetActive(false);
- }
- else
- {
- bts.Add(庫存審查_cb);
- }
-
- bts.Add(加班紀錄_cb);
- if (Screen.orientation == ScreenOrientation.LandscapeLeft)
- {
-
- for (int i = 0; i < bts.Count; i++)
- {
- float x, y;
- if (i % 2 == 0) // 偶數索引
- {
- x = 50f + (i / 2) * 250f;
- y = -50f;
- }
- else // 奇數索引
- {
- x = 50f + ((i - 1) / 2) * 250f;
- y = -400f;
- }
-
- RectTransform rt = bts[i].GetComponent<RectTransform>();
- rt.anchoredPosition = new Vector2(x, y);
- }
- }
- if (Screen.orientation == ScreenOrientation.Portrait)
- {
- for (int i = 0; i < bts.Count; i++)
- {
- // 設定按鈕的位置
- float x = 60 + (i % 4) * 210; // 在每一行的水平位置
- float y = -100 - (i / 4) * 300; // 在每一行的垂直位置
- RectTransform rt = bts[i].GetComponent<RectTransform>();
- rt.anchoredPosition = new Vector2(x, y);
- }
- }
- 讀取面板.SetActive(false);
- }
-
-
- public static class Global
- {
- public static string 登入人IP, 部門,年,日期, 職稱, 系統語言 ,使用者名稱, 密碼, 進入, 離開, 資料庫版本號, 執行檔版本號,版本號比對,預設伺服器路徑,版本號,選擇組別,阿帕契路徑,阿帕契,CC判別,合約內容,合約編號,級別,ID,查詢日期,人員,連動客戶;
- public static bool 判斷是否連線, 螢幕方向,啟動完畢,系統分區控制,登入位置,鏡頭啟動,有無清單 ,讀取完畢, 首次登入, 讀取年份, 快速登入, show1, show2, show3, show4, show5, show6, show7,展示帳號登入,qwe,印尼內網;
- public static int 部門編號,camfps;
- public static float rate, rate_;
- //public static TimeSpan 運行天數;
- public static string PA, PB, PC, PD, PE, PF, PG, PH, PI, PJ, PK, PA1, PA2, PA3, PA4, PA5, PA6, PA9, PA20;
- //public static bool[] 電表異常BL = new bool[999];
- // public static Sprite[] Wnum;
- // public static Sprite[] Bnum;
- public static string[] 系統語言資料;
- // public static string[] CC判斷=new string[999];
- public static Dictionary<string, string> 系統語言字典 = new Dictionary<string, string>() { };
- public static string[,] PHP = new string[5,2];
- }
-
-
- public void 回登入()
- {
- change_Secen(0);
- }
- public void 電簽()
- {
- change_Secen(2);
- }
- public void 個人帳號管理()
- {
- change_Secen(3);
- }
- public void 點名()
- {
- change_Secen(4);
- }
- public void 庫存()
- {
- change_Secen(5);
- }
- public void 生產排程()
- {
- change_Secen(6);
- }
- public void 出貨排程()
- {
- change_Secen(7);
- }
- public void 生產日報()
- {
- change_Secen(8);
- }
- public void 出貨日報()
- {
- change_Secen(9);
- }
- public void 盤點()
- {
- change_Secen(10);
- }
- public void 審查()
- {
- change_Secen(11);
- }
- public void 選單關閉()
- {
- 選單.SetActive(false);
- }
- public void 加班打卡()
- {
- change_Secen(13);
- }
-
- public void 正式()
- {
- Main.Global.預設伺服器路徑="official";
- 伺服器.text="official";
- //StartCoroutine(測驗());
- }
- public void 測試()
- {
- Main.Global.預設伺服器路徑="test";
- 伺服器.text="test";
- //StartCoroutine(測驗());
- }
-
- public void change_Secen(int _screenNum)
- {
-
- SceneManager.LoadScene(_screenNum);
- }
- public void 截圖()
- {
- string fileName = string.Format("{0}/screenshot_{1}.png", Application.persistentDataPath, System.DateTime.Now.ToString("yyyyMMdd_HHmmss"));
- ScreenCapture.CaptureScreenshot(fileName);
- }
-
-
- }
|