private static void ZipRes()
    {
        if (_verRes <= 1)
        {
            return;
        }

        string pathPlatVerLast = VerPath(_verRes - 1);
        string zipPath         = Config.WwwRootPath + "res/" + _platform + "/";
        string zipFile         = zipPath + _verRes + ".zip";

        List <string> listResInfoDiff = GetFileInfoDiff(_pathPlatVer + "resourcesinfo", pathPlatVerLast + "resourcesinfo");

        Dictionary <string, string> dictZipFile = new Dictionary <string, string>();

        dictZipFile.Add(_pathPlatVer + "v" + _verRes, "AssetBundle");
        foreach (string diffFile in listResInfoDiff)
        {
            string diffFile2 = _pathPlatVer + diffFile;
            dictZipFile.Add(diffFile2, diffFile);
        }

        UtilIO.CreateDir(zipPath);
        UtilZip.Zip(dictZipFile, zipFile);
    }
Beispiel #2
0
        public FileResult GetStudentZipLabs(int id, int subjectId, int userId)
        {
            var zip = new ZipFile(Encoding.UTF8);

            var subGroups = SubjectManagementService.GetSubGroup(id);

            var subGroup = subGroups.SubjectStudents.FirstOrDefault(e => e.StudentId == userId);

            var model = SubjectManagementService.GetUserLabFiles(subGroup.StudentId, subjectId);

            var attachments = new List <Attachment>();

            foreach (var data in model)
            {
                attachments.AddRange(FilesManagementService.GetAttachments(data.Attachments));
            }

            UtilZip.CreateZipFile(ConfigurationManager.AppSettings["FileUploadPath"], zip, attachments, subGroup.Student.FullName.Replace(" ", "_"));

            var memoryStream = new MemoryStream();

            zip.Save(memoryStream);

            memoryStream.Seek(0, SeekOrigin.Begin);

            return(new FileStreamResult(memoryStream, "application/zip")
            {
                FileDownloadName = subGroup.Student.FullName.Replace(" ", "_") + ".zip"
            });
        }
Beispiel #3
0
    void Start()
    {
        _zipSrcPath  = Application.dataPath + "/Examples/Zip/Src/";
        _zipSrcFile  = Application.dataPath + "/Examples/Zip/Src.zip";
        _zipDestPath = Application.dataPath + "/Examples/Zip/Dest/";

        Dictionary <string, string> dictFile = new Dictionary <string, string>();

        DirectoryInfo dirInfo = new DirectoryInfo(_zipSrcPath);

        FileInfo[] filesInfo = dirInfo.GetFiles("*", SearchOption.AllDirectories);
        for (int i = 0; i < filesInfo.Length; i++)
        {
            var fileInfo = filesInfo[i];
            if (fileInfo.Name.EndsWith(".meta"))
            {
                continue;
            }
            Debug.Log("fileInfo.FullName: " + fileInfo.FullName);
            string relativeName = fileInfo.FullName.Substring(_zipSrcPath.Length);
            Debug.Log("relativeName:" + relativeName);
            dictFile.Add(fileInfo.FullName, relativeName);
        }

        UtilZip.Zip(dictFile, _zipSrcFile);

        UtilZip.UnZip(_zipSrcFile, _zipDestPath);
    }
Beispiel #4
0
    IEnumerator DoResUpdate(int verResLocal, int verResServer)
    {
        if (verResLocal >= verResServer)
        {
            _taskUpdateNum--;
        }
        else
        {
            verResLocal++;
            string resFile = Config.ApiUrl + "res/" + Config.platform + "/" + verResLocal + ".zip";

            WWW wwwRes = new WWW(resFile);
            yield return(wwwRes);

            if (!string.IsNullOrEmpty(wwwRes.error))
            {
                Debug.LogError("request " + resFile + " error: " + wwwRes.error);
                yield break;
            }

            string localResFile = Config.ResPath + "res.zip";
            File.WriteAllBytes(localResFile, wwwRes.bytes);

            UtilZip.UnZip(localResFile, Config.ResPath);

            File.Delete(localResFile);
            SetLocalResVersion(verResLocal);
            StartCoroutine(DoResUpdate(verResLocal, verResServer));
        }
    }
Beispiel #5
0
        private static List <detallePublicado> GenerarXlsHojaHtmZip(string hoja, string archivoDestino, string rango)
        {
            List <detallePublicado> resultado = new List <detallePublicado>();

            //copiarValoresHoja(hoja);

            Excel.Range     xlSourceRange = ((Excel.Worksheet)xlWorkBook.Application.ActiveWorkbook.Sheets[hoja]).get_Range("E1", "F1");
            Excel.Hyperlink enlace        = (Excel.Hyperlink)xlSourceRange.Hyperlinks.Add(xlSourceRange, Path.GetFileNameWithoutExtension(archivoDestino) + ".zip", Type.Missing, Type.Missing, "Descargar Archivo");

            ((Excel.Workbook)xlWorkBook.Application.ActiveWorkbook).PublishObjects.Add(Excel.XlSourceType.xlSourceRange,
                                                                                       Path.Combine(Path.GetDirectoryName(archivoDestino), Path.GetFileNameWithoutExtension(archivoDestino) + ".htm"), hoja, rango,
                                                                                       Excel.XlHtmlType.xlHtmlStatic, "1-10225", Type.Missing).Publish(true);
            if (File.Exists(Path.Combine(Path.GetDirectoryName(archivoDestino), Path.GetFileNameWithoutExtension(archivoDestino) + ".htm")))
            {
                resultado.Add(new detallePublicado(Path.GetFileNameWithoutExtension(archivoDestino) + ".htm", "Local", "OK"));
            }

            if (File.Exists(Path.Combine(Path.GetDirectoryName(archivoDestino), archivoDestino)))
            {
                UtilZip.CreaArchivoZip(Path.Combine(Path.GetDirectoryName(archivoDestino), archivoDestino), Path.Combine(Path.GetDirectoryName(archivoDestino), Path.GetFileNameWithoutExtension(archivoDestino) + ".zip"));
                if (File.Exists(Path.Combine(Path.GetDirectoryName(archivoDestino), Path.GetFileNameWithoutExtension(archivoDestino) + ".zip")))
                {
                    resultado.Add(new detallePublicado(Path.GetFileNameWithoutExtension(archivoDestino) + ".zip", "Local", "OK"));
                    //resultado.Add(new detallePublicado(Path.GetFileName(archivoDestino),"Local", "OK"));
                }
            }
            return(resultado);
        }