Exemplo n.º 1
0
    //根据配置项 获得配置项目对应的URL页面内容
    static public void GetURLPageContent(string cfgItemName, Action <string> onLoad)
    {
        Action <string> loadURL = delegate(string url)
        {
            HTTPTool.GetText(url, onLoad);
        };

        GetURL(cfgItemName, loadURL);
    }
Exemplo n.º 2
0
    static void ShowLog()
    {
        scrollPos = GUILayout.BeginScrollView(scrollPos);

        try
        {
            GUIUtil.SafeTextArea(showContent);
        }
        catch (Exception e)
        {
            GUILayout.TextArea(e.ToString());
        }

        GUILayout.EndScrollView();

        if (URLManager.GetURL("LogUpLoadURL") != null)
        {
            if (GUILayout.Button("上传日志"))
            {
                HTTPTool.Upload_Request_Thread(URLManager.GetURL("LogUpLoadURL"), LogPath, UploadCallBack);
            }
        }
        else
        {
            GUILayout.Label("上传日志需要在 URLConfig -> LogUpLoadURL 配置上传目录");
        }

#if UNITY_ANDROID
        if (GUILayout.Button("导出到设备"))
        {
            try
            {
                string path = phonePath + LogName + ".txt";
                FileTool.CreatFilePath(path);
                File.Copy(LogPath, path, true);
                GUIUtil.ShowTips("复制成功");
            }
            catch (Exception e)
            {
                GUIUtil.ShowTips(e.ToString());
            }
        }
#endif

        if (GUILayout.Button("复制到剪贴板"))
        {
            TextEditor tx = new TextEditor();
            tx.text = showContent;
            tx.OnFocus();
            tx.Copy();
        }

        if (GUILayout.Button("返回上层"))
        {
            isShowLog = false;
        }
    }
Exemplo n.º 3
0
    static void ReplayListGUI()
    {
        scrollPos = GUILayout.BeginScrollView(scrollPos);

        for (int i = 0; i < FileNameList.Length; i++)
        {
            if (!isUploadReplay)
            {
                if (GUILayout.Button(FileNameList[i]))
                {
                    ChoseReplayMode(true, FileNameList[i]);
                }
            }
            else
            {
                if (GUILayout.Button("上传 " + FileNameList[i]))
                {
                    string replayPath = GetReplayEventFilePath(FileNameList[i]);
                    string randomPath = GetReplayRandomFilePath(FileNameList[i]);

                    HTTPTool.Upload_Request_Thread(URLManager.GetURL("ReplayFileUpLoadURL"), replayPath, UploadCallBack);
                    HTTPTool.Upload_Request_Thread(URLManager.GetURL("ReplayFileUpLoadURL"), randomPath, UploadCallBack);
                }
            }
        }

        GUILayout.EndScrollView();

        if (GUILayout.Button("清除记录"))
        {
            OpenWarnWindow("确定要删除所有记录吗?", () =>
            {
                Debug.Log("已删除所有记录");
                FileTool.SafeDeleteDirectory(PathTool.GetAbsolutePath(ResLoadLocation.Persistent, c_directoryName));
                FileNameList = new string[0];
            });
        }

        if (URLManager.GetURL("ReplayFileUpLoadURL") != null)
        {
            if (GUILayout.Button("上传模式 : " + isUploadReplay))
            {
                isUploadReplay = !isUploadReplay;
            }
        }
        else
        {
            GUILayout.Label("上传持久数据需要在 URLConfig -> ReplayFileUpLoadURL 配置上传目录");
        }

        if (GUILayout.Button("返回上层"))
        {
            MenuStatus = DevMenuEnum.MainMenu;
        }
    }
Exemplo n.º 4
0
    //------------------------------------------------------------------------//

    static private void Init(Action <bool> initFinish)
    {
        //Debug.Log("ServerConfig-->Init()-->ServerConfig.Instance.CfgMapURL:" + ServerConfig.Instance.CfgMapURL);
        Action <string> getMapCfgAction = delegate(string cfgMapContent)
        {
            if (string.IsNullOrEmpty(cfgMapContent) || cfgMapContent == "")
            {
                UIWindowUpdate.Instance.ShowTips(LanguageConfig.GetText(15));
                Init(initFinish);
                return;
            }

            CfgURLConfig.LoadFromText(cfgMapContent, "CfgURLConfig");

            string cfgURL = CfgURLConfig.GetCfgURL(ServerConfig.Instance.Version);
            //Debug.Log("ServerConfig-->Init()-->getMapCfgAction-->cfgURL:" + cfgURL);

            Action <string> getCfgAction = delegate(string cfgContent)
            {
                ServerURLConfig.LoadFromText(cfgContent, "ServerURLConfig");
                foreach (var item in ServerURLConfig.dataMap)
                {
                    //Debug.Log("ServerConfig-->Init()-->getMapCfgAction-->getCfgAction-->cfg name:"+item.Value.name + " url:" + item.Value.url);
                    switch (item.Value.name.ToLower())
                    {
                    case "noticedata": NoticeURL = item.Value.url; break;

                    case "paomadeng": PaoMaDengURL = item.Value.url; break;

                    case "contact": ContactURL = item.Value.url; break;

                    case "help": HelpURL = item.Value.url; break;

                    case "serverlist": ServerListURL = item.Value.url; break;

                    case "androidversion": AndroidVersionURL = item.Value.url; break;

                    case "iosversion": IOSVersionURL = item.Value.url; break;

                    case "windowsversion": WindowsVersionURL = item.Value.url; break;

                    case "game": GameConfigURL = item.Value.url; break;

                    case "agreement": AgreementURL = item.Value.url; break;
                    }
                }
                IsInit = true;
                initFinish(true);
            };

            HTTPTool.GetText(cfgURL, getCfgAction);
        };

        HTTPTool.GetText(ServerConfig.Instance.CfgMapURL, getMapCfgAction);
    }
Exemplo n.º 5
0
    public async void Click()
    {
        // text.text = await GetText("ssssssssssssssssss");
        // text.text = "3";
        // text.text = await GetText("sss2");
        // text.text = "4";
        // HTTPTool.DownLoadFile("http://www.ban-ming.com/serverfile.txt", (isDown) => { }, Application.dataPath+"/test.txt");
        var bytes = File.ReadAllBytes(Application.dataPath + "/test.txt");
        UploadHandlerRaw uploadHandler = new UploadHandlerRaw(bytes);

        HTTPTool.UploadFile("http://www.ban-ming.com/serverfile.txt", uploadHandler, (isOk) => { UnityEngine.Debug.Log("isOk:" + isOk); });
    }
Exemplo n.º 6
0
    //分享图文
    public void ShareWebpage(bool isFriend, string title, string url, string contentStr, string iconUrl)
    {
#if UNITY_ANDROID || UNITY_IOS
        HTTPTool.GetBytes(iconUrl, (bytes) => {
            if (File.Exists(WeChatConstants.WebpageIconPath))
            {
                File.Delete(WeChatConstants.WebpageIconPath);
            }
            File.Create(WeChatConstants.WebpageIconPath);
            ShareContent(isFriend, title, url, contentStr, WeChatConstants.WebpageIconPath);
        });
#endif
    }
Exemplo n.º 7
0
    static void ShowPersistentFileList()
    {
        scrollPos = GUILayout.BeginScrollView(scrollPos);

        for (int i = 0; i < FileNameList.Length; i++)
        {
            if (GUILayout.Button(FileNameList[i]))
            {
                //isShowPersistentFile = true;
                //scrollPos = Vector2.zero;
                //showContent = PersistentFileManager.GetData(FileNameList[i]);
                //LogPath = PersistentFileManager.GetPath(FileNameList[i]);

                string path = PersistentFileManager.GetPath(FileNameList[i]);
                HTTPTool.Upload_Request_Thread(URLManager.GetURL("PersistentFileUpLoadURL"), path, UploadCallBack);
            }
        }

        GUILayout.EndScrollView();

        if (URLManager.GetURL("PersistentFileUpLoadURL") != null)
        {
            if (GUILayout.Button("上传所有持久数据文件"))
            {
                for (int i = 0; i < FileNameList.Length; i++)
                {
                    string path = PersistentFileManager.GetPath(FileNameList[i]);
                    HTTPTool.Upload_Request_Thread(URLManager.GetURL("PersistentFileUpLoadURL"), path, UploadCallBack);
                }
            }
        }
        else
        {
            GUILayout.Label("上传持久数据文件需要在 URLConfig -> PersistentFileUpLoadURL 配置上传目录");
        }

        if (GUILayout.Button("清除持久数据文件"))
        {
            OpenWarnWindow("确定要删除所有持久数据文件吗?", () =>
            {
                Debug.Log("已删除所有持久数据文件");
                FileTool.SafeDeleteDirectory(PathTool.GetAbsolutePath(ResLoadLocation.Persistent, PersistentFileManager.c_directoryName));
                FileNameList = new string[0];
            });
        }

        if (GUILayout.Button("返回上层"))
        {
            MenuStatus = DevMenuEnum.MainMenu;
        }
    }
Exemplo n.º 8
0
 static public void GetAgreementData(Action <string> onLoad)
 {
     if (IsInit)
     {
         HTTPTool.GetText(AgreementURL, onLoad);
     }
     else
     {
         Action <bool> initAction = delegate(bool result)
         {
             HTTPTool.GetText(AgreementURL, onLoad);
         };
         Init(initAction);
     }
 }
Exemplo n.º 9
0
 static public void GetVersionData(Action <string> onLoad)
 {
     if (IsInit)
     {
         HTTPTool.GetText(GetCurrentVersionURL(), onLoad);
     }
     else
     {
         Action <bool> initAction = delegate(bool result)
         {
             HTTPTool.GetText(GetCurrentVersionURL(), onLoad);
         };
         Init(initAction);
     }
 }
Exemplo n.º 10
0
 static public void GetPaoMaDengData(Action <string> onLoad)
 {
     if (IsInit)
     {
         HTTPTool.GetText(PaoMaDengURL, onLoad);
     }
     else
     {
         Action <bool> initAction = delegate(bool result)
         {
             HTTPTool.GetText(PaoMaDengURL, onLoad);
         };
         Init(initAction);
     }
 }
Exemplo n.º 11
0
 static public void GetGameConfigData(Action <string> onLoad)
 {
     //Debug.Log("ServerURLManager.cs-->GetGameConfigData-->GameConfigURL:" + GameConfigURL + " Init:" + IsInit);
     if (IsInit)
     {
         HTTPTool.GetText(GameConfigURL, onLoad);
     }
     else
     {
         Action <bool> initAction = delegate(bool result)
         {
             HTTPTool.GetText(GameConfigURL, onLoad);
         };
         Init(initAction);
     }
 }
Exemplo n.º 12
0
    IEnumerator DownLoadResItemImp(ResInfo item, int totalCount, int current, System.Action <bool, string, ResInfo> updateFinish)
    {
        //WWW www = new WWW(item.resURL);
        WWW www = HTTPTool.GetWWW(item.resURL);

        //ui提示
        UIWindowUpdate.Instance.ShowDownloadTips(totalCount, current + 1, item.resName, www, item.resSize);
        UIWindowFirstLoading.Hide();

        yield return(www);

        if (string.IsNullOrEmpty(www.error) == false)
        {
            //下载出错
            Debug.LogError(www.error + item.resURL);
            // updateFinish(false, "资源下载失败,请点击重试", item);
            updateFinish(false, LanguageConfig.GetText(5), item);
            yield break;
        }
        else
        {
            UIWindowUpdate.Instance.ShowVerifyTips();
            UIWindowFirstLoading.Hide();
            if (MD5Tool.Verify(www.bytes, item.resMD5))
            {
                //解压文件--下载成功
                UIWindowUpdate.Instance.ShowUnZipTips();
                UIWindowFirstLoading.Hide();
                ZIPTool.DecompressToDirectory(www.bytes, MyFileUtil.CacheDir);
                updateFinish(true, "", item);
            }
            else
            {
                //md5 匹配不上
                string str = string.Format("VersionManager.DownLoadResImp:资源{0} md5出错", item.resURL);
                Debug.LogError(str);

                // updateFinish(false, "资源校验失败,md5值不匹配,请点击重新下载", item);
                updateFinish(false, LanguageConfig.GetText(6), item);
                yield break;
            }
        }
    }
Exemplo n.º 13
0
    static void ShowPersistentFile()
    {
        scrollPos = GUILayout.BeginScrollView(scrollPos);

        try
        {
            GUIUtil.SafeTextArea(showContent);
        }
        catch (Exception e)
        {
            GUILayout.TextArea(e.ToString());
        }

        GUILayout.EndScrollView();

        if (URLManager.GetURL("PersistentFileUpLoadURL") != null)
        {
            if (GUILayout.Button("上传持久数据"))
            {
                HTTPTool.Upload_Request_Thread(URLManager.GetURL("PersistentFileUpLoadURL"), LogPath, UploadCallBack);
            }
        }
        else
        {
            GUILayout.Label("上传持久数据需要在 URLConfig -> PersistentFileUpLoadURL 配置上传目录");
        }

        if (GUILayout.Button("复制到剪贴板"))
        {
            TextEditor tx = new TextEditor();
            tx.text = showContent;
            tx.OnFocus();
            tx.Copy();
        }

        if (GUILayout.Button("返回上层"))
        {
            isShowPersistentFile = false;
        }
    }
Exemplo n.º 14
0
 static IEnumerator UpLoad(string upLoadLogUrl, Action <string> CallBack)
 {
     byte[] screenshotBytes;
     MyUnityTool.ScreenShotByReadPixels((data) => { screenshotBytes = data; });
     HTTPTool.UpLoadFiles(upLoadLogUrl, new List <string>()
     {
         "log", "logs"
     }, new List <byte[]>()
     {
     },
                          new List <string>()
     {
         "image.jpg", "log.txt"
     }, new List <string>()
     {
         "uid"
     }, new List <string>()
     {
         "0"
     }, CallBack);
     yield return(null);
 }
Exemplo n.º 15
0
        public MainForm()
        {
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();
            fileHash = new Dictionary <long, string>();
            this.buComboBox.SelectedIndexChanged += delegate {
                string bu = this.buComboBox.Text;

                if (bu.Length > 0)
                {
                    List <Employee> newList = new List <MainForm.Employee>();

                    foreach (Employee item in employeeList)
                    {
                        if (item.org.StartsWith(bu))
                        {
                            newList.Add(item);
                        }
                    }

                    analyzeYear(newList);
                }
                else
                {
                    analyzeYear(employeeList);
                }
            };

            this.updateButton.Click += delegate {
                String h1 = "https://dl.dropboxusercontent.com";
                String h2 = "/u/";
                String h3 = "135" + 8 + "874";
                String h4 = "4";
                String h5 = "/quanta/";
                if (GUtils.StaticTool.checkHostConnectable("www.yahoo.com", 80, 2))
                {
                    String content = GUtils.HTTPTool.fetchHttpContentInQ(
                        h1 + h2 + h3 + h4 + h5 + "quanta_list.txt");
                    if (content != null)
                    {
                        List <List <string> > data = Converter.csv2ListArray(content);
                        foreach (List <string> item in data)
                        {
                            if (item[0].ToLower().EndsWith(".csv"))
                            {
                                if (!fileList.Contains(FILES_PATH + item[0]))
                                {
                                    String csv = HTTPTool.fetchHttpContentInQ(h1 + h2 + h3 + h4 + h5 + item[0]);
                                    File.WriteAllText(FILES_PATH + item[0], csv);
                                    addCSVFile(item[0]);
                                    this.updateButton.Text = "已下載";
                                }
                                else
                                {
                                    this.updateButton.Text = "已最新";
                                }
                                break;
                            }
                        }
                    }
                    else
                    {
                        this.updateButton.Text = "無資料";
                    }
                }
                else
                {
                    this.updateButton.Text = "沒網路";
                }

                /*using (var client = new WebClient())
                 * {
                 *      client.DownloadFile("http://qciewcdb/files/2007/sa/g.xls", "test.xls");
                 * }
                 *
                 * if(File.Exists("test.xls")) {
                 *      //CovertExcelToCsv("test.xls", "test.csv", 0);
                 * }*/

                /*Stream stream = GUtils.HTTPTool.fetchHttpStream("http://qciewcdb/files/2007/sa/g.xls");
                 * FileStream fileStream = File.Create("test.xls", 1024);
                 * byte[] bytesInStream = new byte[stream.Length];
                 * stream.Read(bytesInStream, 0, bytesInStream.Length);
                 * fileStream.Write(bytesInStream, 0, bytesInStream.Length);*/
                this.updateButton.Enabled = false;
            };
            this.parseButton.Click += delegate {
                if (fileListView.SelectedItems.Count == 0)
                {
                    chagneTextBox.Text = "先選一個檔案";
                }
                else
                {
                    if (parseTextBox.Text.Length > 0)
                    {
                        List <Employee> list = parseContent(parseTextBox.Text);
                        list.Sort(
                            delegate(Employee x, Employee y) {
                            return(x.org.CompareTo(y.org));
                        });
                        chagneTextBox.Clear();
                        StringBuilder sb = new StringBuilder();
                        sb.AppendLine("總數: " + list.Count);
                        foreach (Employee item in list)
                        {
                            sb.AppendLine(item.ToString());
                        }

                        chagneTextBox.Text = sb.ToString();
                    }
                }
            };

            this.emailButton.Click += delegate {
                if (fileListView.SelectedItems.Count == 0)
                {
                    chagneTextBox.Text = "先選一個檔案";
                }
                else
                {
                    if (parseTextBox.Text.Length > 0)
                    {
                        List <Employee> list = parseContent(parseTextBox.Text);
                        list.Sort(
                            delegate(Employee x, Employee y) {
                            return(x.org.CompareTo(y.org));
                        });
                        chagneTextBox.Clear();
                        StringBuilder sb = new StringBuilder();
                        sb.AppendLine("總數: " + list.Count);
                        foreach (Employee item in list)
                        {
                            sb.AppendLine(item.email + "(" + item.chtName + ")");
                        }

                        chagneTextBox.Text = sb.ToString();
                    }
                }
            };

            this.filterButton.Click += delegate {
                if (fileListView.SelectedItems.Count == 0)
                {
                    chagneTextBox.Text = "先選一個檔案";
                }
                else
                {
                    string          selectedTitle = titleFilterComboBox.SelectedItem as string;
                    List <Employee> list          = filterEmployee(selectedTitle, yearFilterTextBox.Text);
                    list.Sort(
                        delegate(Employee x, Employee y) {
                        return(x.org.CompareTo(y.org));
                    });
                    chagneTextBox.Clear();
                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine("總數: " + list.Count);
                    foreach (Employee item in list)
                    {
                        sb.AppendLine(item.ToString());
                    }

                    chagneTextBox.Text = sb.ToString();
                }
            };

            this.clearButton.Click += delegate {
                parseTextBox.Clear();
            };

            fileList = new List <string>();
            this.fileListView.ItemSelectionChanged += selectedIndexChanged;

            if (!Directory.Exists(FILES_PATH))
            {
                Directory.CreateDirectory(FILES_PATH);
            }

            string[] files = Directory.GetFiles(FILES_PATH);
            fileList.AddRange(files);
            if (files.Length > 0)
            {
                foreach (string item in files)
                {
                    if (item.EndsWith(".csv"))
                    {
                        addCSVFile(item.Replace(FILES_PATH, ""));
                    }
                }
            }
        }