Ejemplo n.º 1
0
    private static void CompressAssetBundles(string strPath)
    {
        string strMD5Path = strPath.Replace(Application.dataPath, "");

        strMD5Path = strMD5Path.Substring(1);

        string strOldMD5 = GetBundleMD5(strMD5Path);
        string strNewMD5 = CUility.GetFileMD5(strPath);

        if (null == strOldMD5 || strOldMD5 != strNewMD5)
        {
            string strCompress  = GetCompressPath(strPath);
            string strDirectory = strCompress.Substring(0, strCompress.LastIndexOf('/'));
            if (!Directory.Exists(strDirectory))
            {
                Directory.CreateDirectory(strDirectory);
            }
            GzipHelper.GZipFile(strPath, strCompress);
        }

        MD5Info cMD5 = new MD5Info();

        cMD5.strMD5  = strNewMD5;
        cMD5.strPath = strMD5Path.Replace("AssetBundles", "StreamingAssets");

        m_lstNewFileMD5.Add(cMD5);
    }
Ejemplo n.º 2
0
        /// <summary>
        ///     Creates a local score object from a score processor.
        /// </summary>
        /// <param name="processor"></param>
        /// <param name="md5"></param>
        /// <param name="name"></param>
        /// <param name="scrollSpeed"></param>
        /// <returns></returns>
        public static Score FromScoreProcessor(ScoreProcessor processor, string md5, string name, int scrollSpeed, int pauseCount)
        {
            var score = new Score()
            {
                MapMd5             = md5,
                Name               = name,
                DateTime           = $"{System.DateTime.Now.ToShortDateString()} {System.DateTime.Now.ToShortTimeString()}",
                Mode               = processor.Map.Mode,
                TotalScore         = processor.Score,
                Grade              = processor.Failed ? Grade.F : GradeHelper.GetGradeFromAccuracy(processor.Accuracy),
                Accuracy           = processor.Accuracy,
                MaxCombo           = processor.MaxCombo,
                CountMarv          = processor.CurrentJudgements[Judgement.Marv],
                CountPerf          = processor.CurrentJudgements[Judgement.Perf],
                CountGreat         = processor.CurrentJudgements[Judgement.Great],
                CountGood          = processor.CurrentJudgements[Judgement.Good],
                CountOkay          = processor.CurrentJudgements[Judgement.Okay],
                CountMiss          = processor.CurrentJudgements[Judgement.Miss],
                Mods               = processor.Mods,
                ScrollSpeed        = scrollSpeed,
                PauseCount         = pauseCount,
                JudgementBreakdown = GzipHelper.Compress(processor.GetJudgementBreakdown()),
            };

            return(score);
        }
Ejemplo n.º 3
0
        private void CreateDatabaseArchive()
        {
            var archiveName = this.GetDatabaseFileName(this.databaseName);

            GzipHelper.CompressFiles(this.databaseName, archiveName);
            Directory.Delete(this.databaseName, true);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 发送短信
        /// </summary>
        /// <param name="mobile"></param>
        /// <returns></returns>
        public static bool SendMesssage(string mobile, string Content)
        {
            string url = string.Format("{0}:{1}/inter/sendSingleSMS", EMayConfig.Host, EMayConfig.Port);

            SingMessage entity = new SingMessage()
            {
                content            = Content,
                mobile             = mobile,
                customsmsid        = DateTime.Now.ToString("yyyyMMddHHmmsss"),
                extendedcode       = "",
                requesttime        = DateTime.Now.Ticks,
                timertime          = "",
                requestvalidperiod = EMayConfig.ValidPeriod
            };
            HttpWebResponse response = null;
            string          json     = SerializerJson.SerializeObject(entity);

            byte[] byteArray = EMayConfig.IsCompress ? AESHelper.AESEncrypt(GzipHelper.GZipCompressString(json), EMayConfig.SecretKey) : AESHelper.AESEncrypt(json, EMayConfig.SecretKey);
            byte[] result    = HttpHelper.SendRequestData(url, byteArray, ref response);

            string code = response.GetResponseHeader("result").ToString();

            if (code == "SUCCESS")
            {
                string res = AESHelper.AESDecryptString(result, EMayConfig.SecretKey);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            GzipHelper.CompressPage();
            //string type = Request.QueryString["type"];
            string agenda      = Request.QueryString["agenda"];
            string policy      = Request.QueryString["policy"];
            string rule        = Request.QueryString["rule"];
            string process     = Request.QueryString["process"];
            string subprocess  = Request.QueryString["subprocess"];
            string application = Request.QueryString["application"];
            string module      = Request.QueryString["module"];


            //var typename = Request.QueryString["typetext"];
            var agendaname      = Request.QueryString["agendatext"];
            var policyname      = Request.QueryString["policytext"];
            var rulename        = Request.QueryString["ruletext"];
            var processname     = Request.QueryString["processtext"];
            var subprocessname  = Request.QueryString["subprocesstext"];
            var applicationname = Request.QueryString["applicationtext"];
            var modulename      = Request.QueryString["moduletext"];

            presenter.GenerateReport(agenda, agendaname,
                                     policy, policyname, rule, rulename, process, processname,
                                     subprocess, subprocessname, application, applicationname,
                                     module, modulename);
        }
Ejemplo n.º 6
0
        private async ETVoid PlaySound()
        {
            this.isPlaying = true;
            while (soundQueue.Count > 0)
            {
                Sound sound = soundQueue.Dequeue();
                sound.bytes = GzipHelper.Decompress(sound.bytes);
                SetData(soundSource.clip, sound.bytes);
                float volume = musicSource.volume;
                musicSource.volume = volume > 0.1f ? 0.1f : volume;
                soundSource.mute   = false;
                soundSource.Play();
                playingSound?.Invoke(sound.seatId);
                await ETModel.Game.Scene.GetComponent <TimerComponent>().WaitAsync((long)(sound.time * 1000));

                musicSource.volume = volume;
            }
            while (clipQueue.Count > 0)
            {
                soundSource.clip = clipQueue.Dequeue();
                soundSource.Play();
                await ETModel.Game.Scene.GetComponent <TimerComponent>().WaitAsync(1000);
            }
            this.isPlaying = false;
        }
Ejemplo n.º 7
0
 public Helpers()
 {
     Hash       = new HashHelper();
     Encryption = new EncryptionHelper();
     Rando      = new RandoLib();
     GZip       = new GzipHelper();
 }
Ejemplo n.º 8
0
 protected void Page_Load(object sender, EventArgs e)
 {
     GzipHelper.CompressPage();
     if (Request["reportid"] != null && Request["reportid"] != "undefined")
     {
         int reportId = int.Parse(Request["reportid"]);
         _presenter.GenerateReport(reportId);
     }
 }
Ejemplo n.º 9
0
 public Helpers()
 {
     Hash          = new HashHelper();
     Encryption    = new EncryptionHelper();
     Rando         = new RandoLib();
     GZip          = new GzipHelper();
     TextUtilities = new TextUtils();
     DateLib       = new DateLib();
 }
Ejemplo n.º 10
0
 private void btnDe_Click(object sender, EventArgs e)
 {
     try
     {
         txtEn.Text = GzipHelper.GZipDecompressString(txtDe.Text);
     }
     catch (Exception)
     {
         MessageHelper.ShowError("解密失败,错误的字符串!");
     }
 }
Ejemplo n.º 11
0
        public void Gzip()
        {
            var          utf8          = new UTF8Encoding(false, true);
            const string rawString     = "HelloWorld你好世界";
            var          rawBytes      = utf8.GetBytes(rawString);
            var          zippedBytes   = GzipHelper.Compress(rawBytes);
            var          unzippedBytes = GzipHelper.UnCompressToBytes(zippedBytes);
            var          result        = utf8.GetString(unzippedBytes);

            Assert.AreEqual(rawString, result);
        }
Ejemplo n.º 12
0
        public void Gzip压缩字符串()
        {
            string str1 = "aaaaaaaaaaaaaaaaaa";

            // 压缩字符串
            string base64 = GzipHelper.Compress(str1);

            // 解压缩
            string str2 = GzipHelper.Decompress(base64);

            Assert.AreEqual(str1, str2);
        }
Ejemplo n.º 13
0
 public void OnButtonUp()
 {
     if (this.tokenSource != null)
     {
         this.tokenSource.Cancel();
         this.tokenSource = null;
     }
     Microphone.End(device);
     soundSource.mute = false;
     byte[] bytes = GetData(soundSource.clip);
     bytes = GzipHelper.CompressBytes(bytes);
     //发送数据给服务器
 }
Ejemplo n.º 14
0
        public bool DownloadCityFile()
        {
            if (!File.Exists(_fileUrlsAndPaths.CompressedCityListFilePath))
            {
                using var client = new WebClient();
                client.DownloadFile(_fileUrlsAndPaths.CityListFileUrl, _fileUrlsAndPaths.CompressedCityListFilePath);
            }

            if (!File.Exists(_fileUrlsAndPaths.DecompressedCityListFilePath))
            {
                var fileInfo = new FileInfo(_fileUrlsAndPaths.DecompressedCityListFilePath);

                GzipHelper.Decompress(fileInfo);
            }

            return(File.Exists(_fileUrlsAndPaths.DecompressedCityListFilePath));
        }
Ejemplo n.º 15
0
        public LocalDatabase(string databaseName)
        {
            this.databaseName = databaseName.SantizeForDatabaseName();

            string archiveName = GetDatabaseFileName(databaseName);

            if (File.Exists(archiveName))
            {
                GzipHelper.DecompressFiles(archiveName);
                File.Delete(archiveName);
            }

            indexStore  = new IndexStore(databaseName);
            fileStore   = new FileDataStore(databaseName, indexStore);
            journal     = new FileJournal(databaseName, fileStore);
            memoryStore = new InMemoryDataStore(fileStore, journal.DirectoryPath);
        }
Ejemplo n.º 16
0
        public void Test_Gzip压缩字符串()
        {
            string s = @"
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
";

            string b = GzipHelper.Compress(s);

            string s2 = GzipHelper.Decompress(b);

            Assert.AreEqual(s, s2);
        }
Ejemplo n.º 17
0
        public void TestCompressGzip()
        {
            Console.WriteLine("Gzip--------------------------------------------------------------");
            string content = "我是中国人,我来自苏州,我是一个件一般是从其扩展名判断其类型(但扩展名也是可以随便改的,扩展名主要告诉系统该用什么软件打开这个文件才正确),至于显示的图标就更没关系了,你现在是用winrar关联打开,如果用其他软件则会显示其他图标。我是中国人,我来自苏州,我是一个件一般是从其扩展名判断其类型(但扩展名也是可以随便改的,扩展名主要告诉系统该用什么软件打开这个文件才正确),至于显示的图标就更没关系了,你现在是用winrar关联打开,如果用其他软件则会显示其他图标。我是中国人,我来自苏州,我是一个件一般是从其扩展名判断其类型(但扩展名也是可以随便改的,扩展名主要告诉系统该用什么软件打开这个文件才正确),至于显示的图标就更没关系了,你现在是用winrar关联打开,如果用其他软件则会显示其他图标。我是中国人,我来自苏州,我是一个件一般是从其扩展名判断其类型(但扩展名也是可以随便改的,扩展名主要告诉系统该用什么软件打开这个文件才正确),至于显示的图标就更没关系了,你现在是用winrar关联打开,如果用其他软件则会显示其他图标。我是中国人,我来自苏州,我是一个件一般是从其扩展名判断其类型(但扩展名也是可以随便改的,扩展名主要告诉系统该用什么软件打开这个文件才正确),至于显示的图标就更没关系了,你现在是用winrar关联打开,如果用其他软件则会显示其他图标。我是中国人,我来自苏州,我是一个件一般是从其扩展名判断其类型(但扩展名也是可以随便改的,扩展名主要告诉系统该用什么软件打开这个文件才正确),至于显示的图标就更没关系了,你现在是用winrar关联打开,如果用其他软件则会显示其他图标。我是中国人,我来自苏州,我是一个件一般是从其扩展名判断其类型(但扩展名也是可以随便改的,扩展名主要告诉系统该用什么软件打开这个文件才正确),至于显示的图标就更没关了,你现在是用winrar关联打开,如果用其他软件则会显示其他图标。";

            Console.WriteLine("【文档内容】" + content);
            Console.WriteLine("【文字数量】" + content.Length);

            string inter = "H4sIAAAAAAAAAO2QTVLCQBCFz+rSjQs2bgMlJBEhUsYUJPyWhELKCDEWhkwSDmN3z7jKFWyMxQ0sN7Obev36vZ6PrAENt5BGGBSQZVV+R6xMQmVuVNfBj+mvcvIYkG5A7PmhrJeTIvrY3pP9jPEj3vfQWpIXsSJjgdNulVtQdM5TOMx4BR3eCr98B8ojuQfp35zyz55UqFUTB7dqa8tESDFT21C6axAGHCxV8C7XPWBuqOOIjyHP/FF6FD3JxWuV25ymzASyPg1Lucw4H4OS5ibuYgre6W2B7YSTIeuwE4q57O9wvObDuOX68qpx0WCDarp1C3tw1aLpmKf8LxBefQNaI8j9uqLW65ZPo0Wap+apeWqemqfmqXn+B8+/g/kNYNyJuC0JAAA=";//GzipHelper.CompressData(content);

            Console.WriteLine("【压缩后内容】" + inter);
            Console.WriteLine("【内容数量】" + inter.Length);

            GzipHelper h = new GzipHelper();

            content = h.DeCompressData(inter);
            Console.WriteLine("【解压后文档内容】" + content);
            Console.WriteLine("【解压后文字数量】" + content.Length);

            h.CompressData("D:/test.docx", "D:/test1.zip");
            h.DeCompressData("D:/test1.zip", "D:/test2.docx");
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            GzipHelper.CompressPage();

            string qstring = ExpandQueryString(Request.QueryString);

            Page.ClientScript.RegisterStartupScript(GetType(), "hwa", string.Format("ajaxcallmaincontent('{0}');", qstring), true);

            //if (Request[Resources.IdKey] != null)
            //{
            //    int id = Convert.ToInt32(Request[Resources.IdKey]);
            //    if( Request["isDetail"] != null )
            //    {
            //        presenter.RenderDetail(id);
            //        return;
            //    }
            //    presenter.RenderEntity(id);
            //}
            //else
            //{
            //    int defaultHomeId = Convert.ToInt32(AppSettingsReader.GetValue("HOMEPAGE_ID"));
            //    if (defaultHomeId > 0)
            //    {
            //        int type =presenter.GetHomePageType(defaultHomeId);
            //        switch (type)
            //        {
            //            case 105:
            //                presenter.RenderEntity(defaultHomeId);
            //                break;
            //            default:
            //                var asIsPresenter = new AsIsPagePresenter(this);
            //                asIsPresenter.RenderDetail(defaultHomeId);
            //                break;
            //        }

            //    }
            //}
        }
Ejemplo n.º 19
0
        public void Test_Gzip压缩二进制字节()
        {
            string s = @"
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
";

            byte[] bb = Encoding.UTF8.GetBytes(s);

            byte[] b1 = GzipHelper.Compress(bb);
            byte[] b2 = GzipHelper.Decompress(b1);

            Assert.AreEqual(bb.Length, b2.Length);

            for (int i = 0; i < bb.Length; i++)
            {
                Assert.AreEqual((int)bb[i], (int)b2[i]);
            }
        }
Ejemplo n.º 20
0
        /// <summary>
        ///     Checks if there are new scoreboard users.
        /// </summary>
        private void CheckIfNewScoreboardUsers()
        {
            var mapScores = MapManager.Selected.Value.Scores.Value;

            if (mapScores == null || mapScores.Count <= 0 || Scoreboard.Users.Count != 1)
            {
                return;
            }

            for (var i = 0; i < 4 && i < mapScores.Count; i++)
            {
                ScoreboardUser user;

                // For online scores we want to just give them their score in the processor,
                // since we don't have access to their judgement breakdown.
                if (mapScores[i].IsOnline)
                {
                    user = new ScoreboardUser(Screen, ScoreboardUserType.Other, $"{mapScores[i].Name}",
                                              new List <Judgement>(), UserInterface.UnknownAvatar, mapScores[i].Mods, mapScores[i])
                    {
                        Parent    = Container,
                        Alignment = Alignment.MidLeft
                    };

                    user.Scoreboard = Scoreboard;

                    var processor = user.Processor as ScoreProcessorKeys;
                    processor.Accuracy = (float)mapScores[i].Accuracy;
                    processor.MaxCombo = mapScores[i].MaxCombo;
                    processor.Score    = mapScores[i].TotalScore;

                    user.Score.Text = $"{user.RatingProcessor.CalculateRating(processor.Accuracy):0.00} / {StringHelper.AccuracyToString(processor.Accuracy)}";
                    user.Combo.Text = $"{processor.MaxCombo}x";
                }
                // Allow the user to play against their own local scores.
                else
                {
                    // Decompress score
                    var breakdownHits = GzipHelper.Decompress(mapScores[i].JudgementBreakdown);

                    var judgements = new List <Judgement>();

                    // Get all of the hit stats for the score.
                    foreach (var hit in breakdownHits)
                    {
                        judgements.Add((Judgement)int.Parse(hit.ToString()));
                    }

                    user = new ScoreboardUser(Screen, ScoreboardUserType.Other, $"{mapScores[i].Name}",
                                              judgements, UserInterface.UnknownAvatar, mapScores[i].Mods, mapScores[i])
                    {
                        Parent    = Container,
                        Alignment = Alignment.MidLeft
                    };

                    user.Scoreboard = Scoreboard;

                    // Make sure the user's score is updated with the current user.
                    for (var j = 0; j < Screen.Ruleset.ScoreProcessor.TotalJudgementCount && i < judgements.Count; j++)
                    {
                        var processor = user.Processor as ScoreProcessorKeys;
                        processor?.CalculateScore(judgements[i]);
                    }
                }

                Scoreboard.Users.Add(user);
            }

            Scoreboard.SetTargetYPositions();

            // Re-change the transitioner and pause screen's parent so that they appear on top of the scoreboard
            // again.
            Transitioner.Parent = Container;
            PauseScreen.Parent  = Container;
        }
Ejemplo n.º 21
0
        public ContentResult SubmitVideo(HttpPostedFileBase FileData, string folder, string videoName)
        {
            string filename   = "";
            string resultName = "";

            if (null != FileData)
            {
                try
                {
                    filename = Path.GetFileName(FileData.FileName); //获得文件名
                    string fullPathname = Path.Combine(folder, filename);
                    //文件后缀名
                    string suffix = FileData.FileName.Substring(FileData.FileName.LastIndexOf(".") + 1).ToLower();
                    resultName = Guid.NewGuid() + "." + suffix;
                    if (saveFile(FileData, folder, resultName))
                    {
                        //解压操作  然后获得解压后的文件名 保存在数据库中
                        int i = resultName.LastIndexOf(".");

                        GzipHelper.UnZip(UFCOVideoADDR, UFCOVideoZIP,
                                         UFCOVideoUSR, UFCOVideoPwd,
                                         HttpContext.Server.MapPath(folder + resultName),
                                         UFCOVideoZIP + @"\" + resultName.Substring(0, i), "", true);
                        Cl_VideoManage model = new Cl_VideoManage()
                        {
                            LastUpdateTime = DateTime.Now,
                            Name           = videoName.Replace("%2B", "+"),                 //.Replace("%3C","<").Replace("%3E",">").Replace("%2F","/"),
                            Path           =
                                resultName.Substring(0, i) +
                                @"/Untitled/Untitled_media/Untitled.wmv",
                            Size     = FileData.ContentLength / 1024,
                            IsDelete = 0
                        };
                        int status = NetworkConnection.Connect(UFCOVideoADDR, UFCOVideoZIP,
                                                               string.Format(@"{0}", UFCOVideoUSR), UFCOVideoPwd);
                        if (status == (int)ERROR_ID.ERROR_SUCCESS || status == 1202)
                        {
                            string aa =
                                ProcessRequest(UFCOVideoZIP + resultName.Substring(0, i) + @"/Untitled/Untitled.html");

                            var lefttop = getmodelList(aa, "<div id=\"indexlinks\" (.+?)></div>", 1);
                            var leftbot = getmodelList(aa,
                                                       "<table width=\"202\" height=\"200\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-bottom:1px solid #669966\">(.+?)</table>",
                                                       1);
                            model.BottomContent = "";
                            model.TopContent    = "";

                            if (lefttop.Count != 0)
                            {
                                model.LeftContent = lefttop[0].ToString();
                            }
                            else
                            {
                                model.LeftContent = "";
                            }
                            if (leftbot.Count != 0)
                            {
                                model.RightContent = leftbot[0].ToString();
                            }
                            else
                            {
                                model.RightContent = "";
                            }
                            _videoManageBL.Add(model);
                        }
                        NetworkConnection.Disconnect(UFCOVideoZIP);
                        return(Content(model.Id.ToString() + status.ToString()));
                    }
                    else
                    {
                        return(Content("-1"));
                    }
                }
                catch (Exception ex)
                {
                    return(Content(ex.Message + "--------" + ex.Source + "-----------" + ex.StackTrace));
                }
            }
            return(Content("-1"));
        }
Ejemplo n.º 22
0
        public static void exportExcelFile(TableExcelData data, string filePath)
        {
            const int version = 1;

            var ms = new MemoryStream();
            var bw = new BinaryWriter(ms, Encoding.UTF8);

            bw.Write(version);

            foreach (var hdr in data.Headers)
            {
                bw.WriteUtf8String(hdr.FieldName);
                byte ftype = 0;
                switch (hdr.FieldType)
                {
                case "int":
                    ftype = 1;
                    break;

                case "double":
                    ftype = 2;
                    break;

                case "string":
                    ftype = 3;
                    break;

                default:
                    throw new Exception(string.Format("无法识别的字段类型 {0} 名称 {1}", hdr.FieldType, hdr.FieldName));
                }
                bw.Write(ftype);
            }
            bw.Write((byte)0);

            foreach (var row in data.Rows)
            {
                for (int i = 0; i < data.Headers.Count; i++)
                {
                    var hdr = data.Headers[i];
                    var val = row.StrList[i];
                    switch (hdr.FieldType)
                    {
                    case "int":
                    {
                        int n = 0;
                        int.TryParse(val, out n);
                        bw.Write(n);
                    }
                    break;

                    case "double":
                    {
                        double n = 0;
                        double.TryParse(val, out n);
                        bw.Write(n);
                    }
                    break;

                    case "string":
                        bw.WriteUtf8String(val);
                        break;
                    }
                }
            }

            if (File.Exists(filePath))
            {
                File.Delete(filePath);
            }

            File.WriteAllBytes(filePath, GzipHelper.processGZipEncode(ms.GetBuffer(), (int)ms.Length));

            bw.Close();
            ms.Close();
        }
Ejemplo n.º 23
0
        /// <summary>
        ///     Checks if there are new scoreboard users.
        /// </summary>
        private void CheckIfNewScoreboardUsers()
        {
            if (Screen.IsPlayTesting || StopCheckingForScoreboardUsers)
            {
                return;
            }

            var mapScores = MapManager.Selected.Value.Scores.Value;

            if (mapScores == null || mapScores.Count <= 0 || (ScoreboardLeft.Users?.Count < 1 && ScoreboardRight != null && ScoreboardRight.Users.Count < 1))
            {
                return;
            }

            for (var i = 0; i < (OnlineManager.CurrentGame == null ? 4 : mapScores.Count) && i < mapScores.Count; i++)
            {
                ScoreboardUser user;

                // For online scores we want to just give them their score in the processor,
                // since we don't have access to their judgement breakdown.
                if (mapScores[i].IsOnline)
                {
                    user = new ScoreboardUser(Screen, ScoreboardUserType.Other, $"{mapScores[i].Name}",
                                              new List <Judgement>(), UserInterface.UnknownAvatar, (ModIdentifier)mapScores[i].Mods, mapScores[i])
                    {
                        Parent    = Container,
                        Alignment = Alignment.MidLeft
                    };

                    if (OnlineManager.CurrentGame != null &&
                        OnlineManager.CurrentGame.Ruleset == MultiplayerGameRuleset.Team && OnlineManager.GetTeam(user.LocalScore.PlayerId) == MultiplayerTeam.Blue)
                    {
                        user.Scoreboard = ScoreboardRight;
                        user.X          = WindowManager.Width;
                    }
                    else
                    {
                        user.Scoreboard = ScoreboardLeft;
                    }

                    user.SetImage();

                    var processor = user.Processor as ScoreProcessorKeys;
                    processor.Accuracy = (float)mapScores[i].Accuracy;
                    processor.MaxCombo = mapScores[i].MaxCombo;
                    processor.Score    = mapScores[i].TotalScore;

                    user.Score.Text = $"{user.RatingProcessor.CalculateRating(processor.Accuracy):0.00} / {StringHelper.AccuracyToString(processor.Accuracy)}";
                    user.Combo.Text = $"{processor.MaxCombo}x";
                }
                // Allow the user to play against their own local scores.
                else
                {
                    // Decompress score
                    var breakdownHits = GzipHelper.Decompress(mapScores[i].JudgementBreakdown);

                    var judgements = new List <Judgement>();

                    // Get all of the hit stats for the score.
                    foreach (var hit in breakdownHits)
                    {
                        judgements.Add((Judgement)int.Parse(hit.ToString()));
                    }

                    user = new ScoreboardUser(Screen, ScoreboardUserType.Other, $"{mapScores[i].Name}",
                                              judgements, UserInterface.UnknownAvatar, (ModIdentifier)mapScores[i].Mods, mapScores[i])
                    {
                        Parent    = Container,
                        Alignment = Alignment.MidLeft
                    };

                    if (OnlineManager.CurrentGame != null &&
                        OnlineManager.CurrentGame.Ruleset == MultiplayerGameRuleset.Team && OnlineManager.GetTeam(user.LocalScore.PlayerId) == MultiplayerTeam.Blue)
                    {
                        user.Scoreboard = ScoreboardRight;
                    }
                    else
                    {
                        user.Scoreboard = ScoreboardLeft;
                    }

                    user.SetImage();

                    // Make sure the user's score is updated with the current user.
                    for (var j = 0; j < Screen.Ruleset.ScoreProcessor.TotalJudgementCount && i < judgements.Count; j++)
                    {
                        var processor = user.Processor as ScoreProcessorKeys;
                        processor?.CalculateScore(judgements[i]);
                    }
                }

                if (OnlineManager.CurrentGame != null && OnlineManager.CurrentGame.Ruleset == MultiplayerGameRuleset.Team &&
                    OnlineManager.GetTeam(user.LocalScore.PlayerId) == MultiplayerTeam.Blue)
                {
                    ScoreboardRight.Users.Add(user);
                }
                else
                {
                    ScoreboardLeft.Users.Add(user);
                }
            }

            ScoreboardLeft.SetTargetYPositions();
            ScoreboardRight?.SetTargetYPositions();

            // Re-change the transitioner and pause screen's parent so that they appear on top of the scoreboard
            // again.
            if (ProgressBar != null)
            {
                ProgressBar.Parent = Container;
            }

            Transitioner.Parent = Container;
            PauseScreen.Parent  = Container;

            StopCheckingForScoreboardUsers = true;
            Screen.SetRichPresence();
        }
Ejemplo n.º 24
0
        public static TableExcelData ImportFile(string filePath)
        {
            byte[] content = GzipHelper.processGZipDecode(File.ReadAllBytes(filePath));
            var    ms      = new MemoryStream(content);
            var    br      = new BinaryReader(ms);

            if (br.ReadInt32() != 1)
            {
                throw new Exception("无法识别的文件版本号");
            }

            var r = new TableExcelData();

            while (true)
            {
                var fieldName = br.ReadUtf8String();
                if (string.IsNullOrEmpty(fieldName))
                {
                    break;
                }

                string fieldType;
                byte   ftype = br.ReadByte();
                switch (ftype)
                {
                case 1:
                    fieldType = "int";
                    break;

                case 2:
                    fieldType = "double";
                    break;

                case 3:
                    fieldType = "string";
                    break;

                case 4:
                    fieldType = "group";
                    break;

                case 5:
                    fieldType = "bool";
                    break;

                case 6:
                    fieldType = "color";
                    break;

                case 7:
                    fieldType = "table";
                    break;

                case 8:
                    fieldType = "string(nil)";
                    break;

                case 9:
                    fieldType = "group(int)";
                    break;

                case 10:
                    fieldType = "group(double)";
                    break;

                case 11:
                    fieldType = "group(bool)";
                    break;

                case 12:
                    fieldType = "group(string)";
                    break;

                case 13:
                    fieldType = "double(64)";
                    break;

                default:
                    throw new Exception(string.Format("无法识别的字段类型 fieldName:{0} fieldType:{1}", fieldName, ftype));
                }
                r.Headers.Add(new TableExcelHeader()
                {
                    FieldName = fieldName, FieldType = fieldType
                });
            }

            while (br.BaseStream.Position < br.BaseStream.Length)
            {
                var lst = new List <string>();
                for (int i = 0; i < r.Headers.Count; i++)
                {
                    var hdr = r.Headers[i];
                    switch (hdr.FieldType)
                    {
                    case "string":
                        lst.Add(br.ReadUtf8String());
                        break;

                    case "int":
                        lst.Add(br.ReadInt32().ToString());
                        break;

                    case "double":
                        lst.Add(br.ReadDouble().ToString());
                        break;

                    case var a when a.Contains("group"):
                        lst.Add(br.ReadUtf8String());

                        break;

                    case "bool":
                        lst.Add(br.ReadBoolean().ToString());
                        break;

                    case "color":
                        lst.Add(br.ReadInt32().ToString());
                        break;

                    case "table":
                        lst.Add(br.ReadUtf8String());
                        break;

                    case "string(nil)":
                        lst.Add(br.ReadUtf8String());
                        break;
                    }
                }
                r.Rows.Add(new TableExcelRow()
                {
                    StrList = lst
                });
            }

            return(r);
        }
        public static TableExcelData importFile(string filePath)
        {
            var content = GzipHelper.processGZipDecode(File.ReadAllBytes(filePath));
            var ms      = new MemoryStream(content);
            var br      = new BinaryReader(ms);

            if (br.ReadInt32() != 1)
            {
                throw new Exception("无法识别的文件版本号");
            }

            var r = new TableExcelData();

            while (true)
            {
                var fieldName = br.ReadUtf8String();
                if (string.IsNullOrEmpty(fieldName))
                {
                    break;
                }

                var fieldType = string.Empty;
                var ftype     = br.ReadByte();
                switch (ftype)
                {
                case 1:
                    fieldType = "int";
                    break;

                case 2:
                    fieldType = "double";
                    break;

                case 3:
                    fieldType = "string";
                    break;

                default:
                    throw new Exception(string.Format("无法识别的字段类型 fieldName:{0} fieldType:{1}", fieldName, ftype));
                }
                r.Headers.Add(new TableExcelHeader()
                {
                    FieldName = fieldName, FieldType = fieldType
                });
            }

            while (br.BaseStream.Position < br.BaseStream.Length)
            {
                var lst = new List <string>();
                for (int i = 0; i < r.Headers.Count; i++)
                {
                    var hdr = r.Headers[i];
                    switch (hdr.FieldType)
                    {
                    case "string":
                        lst.Add(br.ReadUtf8String());
                        break;

                    case "int":
                        lst.Add(br.ReadInt32().ToString());
                        break;

                    case "double":
                        lst.Add(br.ReadDouble().ToString());
                        break;
                    }
                }
                r.Rows.Add(new TableExcelRow()
                {
                    StrList = lst
                });
            }

            return(r);
        }
Ejemplo n.º 26
0
 protected void Page_Load(object sender, EventArgs e)
 {
     GzipHelper.CompressPage();
 }
Ejemplo n.º 27
0
 protected void Page_Load(object sender, EventArgs e)
 {
     GzipHelper.CompressPage();
     presenter.BuildNavigation();
 }
Ejemplo n.º 28
0
 private void btnEn_Click(object sender, EventArgs e)
 {
     txtDe.Text = GzipHelper.GZipCompressString(txtEn.Text);
 }
Ejemplo n.º 29
0
    public override IEnumerator SysEnterCo()
    {
        SetProgress(0);

#if !UNITY_EDITOR || BUNDLE_MODE
#if UNITY_IPHONE
        string strMd5ConfigURL = GetURLRoot() + "/IOSAssetsMD5Config.xml";
#elif UNITY_EDITOR
        string strMd5ConfigURL = GetURLRoot() + "/StreamingAssets/AndroidAssetsMD5Config.xml";
#else
        string strMd5ConfigURL = GetURLRoot() + "/AndroidAssetsMD5Config.xml";
#endif

        WWW www = new WWW(strMd5ConfigURL);
        yield return(www);

        if (!string.IsNullOrEmpty(www.error))
        {
            Debug.LogError("下载资源配置出错!");
            yield break;
        }

        List <MD5Info> lstFileMD5 = (List <MD5Info>)CUility.DeSerializerObjectFromBuff(www.bytes, typeof(List <MD5Info>));

        www.Dispose();

        for (int i = 0; i != lstFileMD5.Count; ++i)
        {
            MD5Info md5Info      = lstFileMD5[i];
            string  strLocalPath = Application.persistentDataPath + md5Info.strPath.Substring(md5Info.strPath.IndexOf('/'));
            bool    bNeedUpdate  = true;
            if (File.Exists(strLocalPath))
            {
                string strFileMd5 = CUility.GetFileMD5(strLocalPath);
                if (strFileMd5 == md5Info.strMD5)
                {
                    bNeedUpdate = false;
                }
            }
            if (bNeedUpdate)
            {
                string strURL = GetURL(md5Info.strPath);
                www = new WWW(strURL);
                yield return(www);

                if (!string.IsNullOrEmpty(www.error))
                {
                    Debug.LogError("下载资源出错!");
                    yield break;
                }

                byte[] arrData      = GzipHelper.GzipDecompress(www.bytes);
                string strDirectory = strLocalPath.Substring(0, strLocalPath.LastIndexOf('/'));
                if (!Directory.Exists(strDirectory))
                {
                    Directory.CreateDirectory(strDirectory);
                }
                using (FileStream destFile = File.Open(strLocalPath, FileMode.Create, FileAccess.Write))
                {
                    destFile.Write(arrData, 0, arrData.Length);
                    destFile.Close();
                }
                www.Dispose();
            }
        }
        CResourceSys.Instance.GenManifestBundle();
#endif

        SetProgress(1.0f);

#if !UNITY_EDITOR
#if UNITY_IPHONE
        string strCompressDir = Application.dataPath + "/StreamingAssets/IOSAssetsCompress";
#else
        string strCompressDir = Application.dataPath + "/StreamingAssets/AndroidAssetsCompress";
#endif
        if (Directory.Exists(strCompressDir))
        {
            Directory.Delete(strCompressDir, true);
        }
#endif

        CGameRoot.SwitchToState(EStateType.GamePreLoading);

        yield return(null);
    }