123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458 |
- 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] Button 班表明細c;
- [SerializeField] Button 個人班表c;
- [SerializeField] Button 請假申請c;
- [SerializeField] Button 請假審核c;
- [SerializeField] Button 加班申請c;
- [SerializeField] Button 加班審核c;
- [SerializeField] Button 考勤c;
- [SerializeField] Button 會議提案c;
- [SerializeField] Button 文件查看c;
- private List<Button> bts = new List<Button>();
- [SerializeField] GameObject 讀取面板;
- [SerializeField] TextMeshProUGUI 讀取;
-
- [SerializeField] GameObject 選單;
- [SerializeField] TextMeshProUGUI 伺服器;
-
-
- public CanvasScaler canvasScaler;
-
- 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 screenWidth;
- float screenHeight;
-
- private string loadingText = "";
- private int dotCount = 0;
- private ADS adsScript;
- // Start is called before the first frame update
- void Start()
- {
- Screen.autorotateToPortrait = true;
- Screen.orientation = ScreenOrientation.AutoRotation;
- if (Main.Global.螢幕方向=="直")
- {
- canvasScaler.referenceResolution = new Vector2(Main.Global.固寬, Main.Global.固高);
- canvasScaler.matchWidthOrHeight=Main.Global.固比;
- }
- else
- {
- canvasScaler.referenceResolution = new Vector2(Main.Global.固高, Main.Global.固寬);
- canvasScaler.matchWidthOrHeight=Main.Global.固比1;
- }
- if (Main.Global.預設伺服器路徑=="official")
- {
- 伺服器.text="official";
- }
- else
- {
- 伺服器.text="test";
- }
-
- adsScript = FindObjectOfType<ADS>();
- if (adsScript != null)
- {
- adsScript.ShowBanner();
- }
- 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)
- {
- Main.Global.螢幕方向="橫";
- change_Secen(3);
- }
- if (Screen.orientation == ScreenOrientation.Portrait)
- {
- Main.Global.螢幕方向="直";
- change_Secen(2);
- }
- }
- }
- 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 se = Main.Global.預設伺服器路徑;
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&帳號={1}&se={2}", strcon, name, 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);
- Main.Global.編號=json1[0].ToString().Trim('"');
- if (json1[17].ToString()=="0")
- {
- Main.Global.排班主管權限=false;
- }
- else
- {
- Main.Global.排班主管權限=true;
- }
- if (json1[16].ToString()=="0")
- {
- Main.Global.考勤主管權限=false;
- }
- else
- {
- Main.Global.考勤主管權限=true;
- }
-
- bts.Add(班表明細c);
- bts.Add(個人班表c);
- if (json1[12].ToString()=="0")
- {
- 請假申請c.gameObject.SetActive(false);
- }
- else
- {
- bts.Add(請假申請c);
- }
- if (json1[13].ToString()=="0")
- {
- 請假審核c.gameObject.SetActive(false);
- }
- else
- {
- bts.Add(請假審核c);
- }
- if (json1[8].ToString()=="0")
- {
- 加班申請c.gameObject.SetActive(false);
- }
- else
- {
- bts.Add(加班申請c);
- }
- if (json1[9].ToString()=="0")
- {
- 加班審核c.gameObject.SetActive(false);
- }
- else
- {
- bts.Add(加班審核c);
- }
- if (json1[26].ToString()=="0")
- {
- 考勤c.gameObject.SetActive(false);
- }
- else
- {
- bts.Add(考勤c);
- }
- bts.Add(會議提案c);
- bts.Add(文件查看c);
- if (Screen.orientation == ScreenOrientation.LandscapeLeft)
- {
-
- for (int i = 0; i < bts.Count; i++)
- {
- float x, y;
- if (i % 2 == 0) // 偶數索引
- {
- x = 50f + (i / 2) * 300f;
- y = -25f;
- }
- else // 奇數索引
- {
- x = 50f + ((i - 1) / 2) * 300f;
- y = -375f;
- }
- 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 = 125 + (i % 2) * 450; // 在每一行的水平位置
- float y = -50 - (i / 2) * 275; // 在每一行的垂直位置
- RectTransform rt = bts[i].GetComponent<RectTransform>();
- rt.anchoredPosition = new Vector2(x, y);
- }
- }
-
- 讀取面板.SetActive(false);
- }
- public void 個人班表()
- {
- if (adsScript != null)
- {
- adsScript.HideBanner();
- }
- if (Main.Global.螢幕格式=="胖")
- {
- change_Secen(5);
- }
- else
- {
- change_Secen(4);
- }
-
- }
- public void 班表明細()
- {
- if (adsScript != null)
- {
- adsScript.HideBanner();
- }
- if (Main.Global.螢幕格式=="胖")
- {
- change_Secen(7);
- }
- else
- {
- change_Secen(6);
- }
-
- }
- public void 請假申請()
- {
- if (adsScript != null)
- {
- adsScript.HideBanner();
- }
- if (Main.Global.螢幕格式=="胖")
- {
- change_Secen(9);
- }
- else
- {
- change_Secen(8);
- }
-
- }
- public void 請假審核()
- {
- if (adsScript != null)
- {
- adsScript.HideBanner();
- }
- if (Main.Global.螢幕格式=="胖")
- {
- change_Secen(11);
- }
- else
- {
- change_Secen(10);
- }
- }
- public void 加班申請()
- {
- if (adsScript != null)
- {
- adsScript.HideBanner();
- }
- if (Main.Global.螢幕格式=="胖")
- {
- change_Secen(13);
- }
- else
- {
- change_Secen(12);
- }
- }
- public void 加班審核()
- {
- if (adsScript != null)
- {
- adsScript.HideBanner();
- }
- if (Main.Global.螢幕格式=="胖")
- {
- change_Secen(15);
- }
- else
- {
- change_Secen(14);
- }
- }
- public void 考勤表()
- {
- if (adsScript != null)
- {
- adsScript.HideBanner();
- }
- if (Main.Global.螢幕格式=="胖")
- {
- change_Secen(17);
- }
- else
- {
- change_Secen(16);
- }
- }
- public void 會議提案()
- {
- if (adsScript != null)
- {
- adsScript.HideBanner();
- }
- if (Main.Global.螢幕格式 == "胖")
- {
- change_Secen(19);
- }
- else
- {
- change_Secen(18);
- }
- }
- public void 文件查看()
- {
- if (adsScript != null)
- {
- adsScript.HideBanner();
- }
- if (Main.Global.螢幕格式 == "胖")
- {
- change_Secen(21);
- }
- else
- {
- change_Secen(20);
- }
- }
- 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_, 固高, 固寬, 固比, 固比1;
- //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[6,2];
- }
-
-
- public void 回登入()
- {
- if (adsScript != null)
- {
- adsScript.HideBanner();
- }
- change_Secen(1);
- }
- public void 選單關閉()
- {
- 選單.SetActive(false);
- }
- 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);
- }
-
-
- }
|