/// <summary> /// Sisteme uygulama yanıtı gönderir /// </summary> /// <returns>Sisteme gönderilen uygulama yanıtının bilgileri</returns> public SendUBLResponseType[] UygulamaYanitiGonder(TextModel m, string gelenFaturaID, ArrayList sslList) { ApplicationResponseUBL applicationResponse = new ApplicationResponseUBL(); var createdUBL = applicationResponse.CreateApplicationResponse(m.VknTckn, gelenFaturaID, m.IssueDate); // Uygulama yanıtı UBL i oluşturulur UBLBaseSerializer serializer = new InvoiceSerializer(); // UBL XML e dönüştürülür var strUygulamaYaniti = serializer.GetXmlAsString(createdUBL); // XML byte tipinden string tipine dönüştürülür byte[] zipliFile = ZipUtility.CompressFile(Encoding.UTF8.GetBytes(strUygulamaYaniti), createdUBL.UUID.Value); // XML ziplenir ServicePointManager.SecurityProtocol = TlsSetting.TlsSet(sslList); // TLS/SSL ayarları WebServisAdresDegistir(); using (new OperationContextScope(WsClient.InnerChannel)) { if (WebOperationContext.Current != null) { WebOperationContext.Current.OutgoingRequest.Headers.Add(HttpRequestHeader.Authorization, Authorization.GetAuthorization(m.Kullanici, m.Sifre)); } var req = new sendUBLRequest { SenderIdentifier = m.PkEtiketi, //uygulama yanıtı gönderici birim etiketi ReceiverIdentifier = m.GbEtiketi, //uygulama yanıtı alıcı posta kutusu VKN_TCKN = m.VknTckn, // tckn veya vkn DocType = "APP_RESP", //gönderilen döküman tipi DocData = zipliFile //gönderilen uygulama yanıtının ziplenmiş byte datası }; return(WsClient.sendUBL(req)); } }
/// <summary> /// Sisteme e-fatura gönderir /// </summary> /// <returns>Sisteme gönderilen faturanın bilgileri </returns> public SendUBLResponseType[] FaturaGonder(TextModel m, ArrayList sslList, BaseInvoiceUBL fatura) { var createdUBL = fatura.BaseUBL; // Fatura UBL i oluşturulur UBLBaseSerializer serializer = new InvoiceSerializer(); // UBL XML e dönüştürülür var strFatura = serializer.GetXmlAsString(createdUBL); // XML byte tipinden string tipine dönüştürülür byte[] zipliFile = ZipUtility.CompressFile(Encoding.UTF8.GetBytes(strFatura), createdUBL.UUID.Value); // XML ziplenir ServicePointManager.SecurityProtocol = TlsSetting.TlsSet(sslList); // TLS/SSL ayarları WebServisAdresDegistir(); using (new OperationContextScope(WsClient.InnerChannel)) { if (WebOperationContext.Current != null) { WebOperationContext.Current.OutgoingRequest.Headers.Add(HttpRequestHeader.Authorization, Authorization.GetAuthorization(m.Kullanici, m.Sifre)); } var req = new sendUBLRequest { VKN_TCKN = m.VknTckn, //tckn veya vkn SenderIdentifier = m.GbEtiketi, //gönderici birim etiketi ReceiverIdentifier = m.PkEtiketi, //alıcı posta kutusu DocType = "INVOICE", //gönderilen döküman tipi. zarf, fatura vs. DocData = zipliFile //içinde xml dosyası olan zip lenen dosya. }; return(WsClient.sendUBL(req)); } }
public static void zip_lua() { string base_path = UnityEngine.Application.dataPath + "/../../lua_zip/"; Dictionary <string, string> d = new Dictionary <string, string>(); d.Add("config", Path.Combine(UnityEngine.Application.dataPath, "../../src/client/config/")); d.Add("game", Path.Combine(UnityEngine.Application.dataPath, "../../src/client/game/")); d.Add("fwk", Path.Combine(UnityEngine.Application.dataPath, "../../fwk_src/lua/fwk")); foreach (var k in d.Keys) { string ver = File.ReadAllText(base_path + "lua_ver/" + k + "_ver.txt"); string path = base_path + "lua_zip_src/" + k; if (Directory.Exists(path)) { Directory.Delete(path, true); } Directory.CreateDirectory(path); SYFwk.Core.Extension.CopyDirectory(d[k], path); string[] dir = { path }; if (!Directory.Exists(base_path + "zip/")) { Directory.CreateDirectory(base_path + "zip/"); } string fullName = base_path + "zip/" + k + "_" + ver + ".zip"; ZipUtility.Zip(dir, fullName); //string md5 = SYFwk.Core.Extension.EncodeMd5File(fullName, true); } Debug.Log("zip_lua finish"); }
/// <summary> /// 获取插件包的信息 /// </summary> /// <param name="fileName"></param> /// <returns></returns> public static IEnumerable <PluginPackAttribute> GetPluginPackInfo(string fileName) { var tempDir = String.Concat(EnvUtil.GetBaseDirectory() + "/", PluginConfig.PLUGIN_TMP_DIRECTORY, "tmp/"); if (Directory.Exists(tempDir)) { Directory.Delete(tempDir, true); } Directory.CreateDirectory(tempDir).Create(); var dir = new DirectoryInfo(tempDir); ZipUtility.DecompressFile(tempDir, fileName, false); Assembly ass; string[] multExt = PluginConfig.GetFilePartterns(); foreach (String ext in multExt) { var files = dir.GetFiles(ext); foreach (FileInfo f in files) { ass = Assembly.Load(File.ReadAllBytes(f.FullName)); var attbs = ass.GetCustomAttributes(typeof(PluginPackAttribute), false); foreach (object attb in attbs) { if (attb is PluginPackAttribute) { yield return((PluginPackAttribute)attb); } } } } }
public Task <string> CompressLogFiles(string filePath, bool deleteAfterCompressed) { var tcs = new TaskCompletionSource <string>(); var pathRoot = Application.persistentDataPath; try { Task.Run(() => { LogOutputListStop(); float progress = 0; ZipUtility.ZipFileDirectory(pathRoot + $"{FileLogOutput.LogPath}", filePath, false, ref progress); if (deleteAfterCompressed) { System.IO.Directory.Delete(pathRoot + $"{FileLogOutput.LogPath}", true); } LogOutputListStart(); tcs.TrySetResult(filePath); }); } catch (Exception e) { Debug.LogError("compress log files error:" + e.Message); } return(tcs.Task); }
public static IEnumerator LoadTestDescriptor(string fileName, EventHandler <EventArgs> OnFinished, EventHandler <MainMenuController.ExceptionEventArgs> OnError) { byte[] zipBytes = null; string filePath = Application.streamingAssetsPath + "/" + fileName; WWW www = new WWW(filePath); yield return(www); zipBytes = www.bytes; try { Dictionary <string, MemoryStream> descFiles = ZipUtility.ExtractZipFile(zipBytes); List <string> xmlNames = GetXmlNames(descFiles); Dictionary <string, MemoryStream> imgResources = GetImgs(descFiles); List <GameDescriptor> gDescriptors = ReadXmls(xmlNames, descFiles); new DescriptorProcessor().ProcessMultipleGameDescriptor(gDescriptors, imgResources); OnFinished(null, EventArgs.Empty); yield break; } catch (System.Exception e) { OnError(null, new MainMenuController.ExceptionEventArgs("Error occoured during descriptor loading!", e)); yield break; } }
public void SaveToZip(FileInfo saveFile) { //var initialDirectory = FileUtils.AppFolder.GetSubFolder("Data"); //initialDirectory.EnsureExists(); using (var tempDir = new TemporaryDirectory("Jeremy")) { var temp = tempDir.GetFile("data.xml"); using (Stream saveStream = new FileStream(temp.FullName, FileMode.Create)) { XmlSerializer serializer = new XmlSerializer(typeof(ObservableCollection <Philosopher>)); serializer.Serialize(saveStream, MainWin.Pvm.m_philosophers); var path = FileUtils.AppFolder.GetSubFolder("Images"); var res = path.CopyMeTo(tempDir.Directory.GetSubFolder("Images").FullName); ZipUtility.ZipUpFolder(tempDir.Directory, saveFile); //DirectoryInfo dir2 = new DirectoryInfo(initialDirectory.FullName + @"\" + "data.zip"); //Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile(); //zip.AddFile(temp.FullName, @"\"); //zip.AddDirectory(path.FullName); //zip.Save(dir2.FullName); } } }
private void btnZipFiles_Click(object sender, EventArgs e) { string zippedFile = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "Package.zip"); List <string> fileList = Directory.GetFiles(System.AppDomain.CurrentDomain.BaseDirectory).ToList(); ZipUtility.ZipFiles(fileList, zippedFile, ""); }
/// <summary> /// Sisteme e-irsaliye yanıtı gönderir /// </summary> /// <returns>Gönderilen irsaliye yanıtı bilgileri</returns> public sendDesUBLResponse IrsaliyeYanitiGonder(TextModel m, string UUID, ArrayList sslList) { IrsaliyeYanitiUBL receiptAdvice = new IrsaliyeYanitiUBL(); var createdUBL = receiptAdvice.CreateReceiptAdvice(m.VknTckn, m.IssueDate, UUID); // İrsaliye yanıtı UBL i oluşturulur UBLBaseSerializer serializer = new ReceiptAdviceSerializer(); // UBL XML e dönüştürülür var strIrsaliyeYaniti = serializer.GetXmlAsString(createdUBL); // XML byte tipinden string tipine dönüştürülür byte[] zipliFile = ZipUtility.CompressFile(Encoding.UTF8.GetBytes(strIrsaliyeYaniti), createdUBL.UUID.Value); // XML ziplenir ServicePointManager.SecurityProtocol = TlsSetting.TlsSet(sslList); // TLS/SSL ayarları ClientEDespatchServicesPortClient wsClient = new ClientEDespatchServicesPortClient(); using (new OperationContextScope(wsClient.InnerChannel)) { if (WebOperationContext.Current != null) { WebOperationContext.Current.OutgoingRequest.Headers.Add(HttpRequestHeader.Authorization, Authorization.GetAuthorization(m.Kullanici, m.Sifre)); } var req = new sendDesUBLRequest { VKN_TCKN = m.VknTckn, // gönderici vkn veya tckn SenderIdentifier = m.PkEtiketi, //gönderici birim etiketi ReceiverIdentifier = m.GbEtiketi, //alıcı birim etiketi DocType = "RECEIPT", // gönderilecek doküman tipi DocData = zipliFile //gönderilecek irsaliye yanıtının ziplenmiş byte datası }; return(wsClient.sendDesUBL(req)); } }
private void CreateVersionPackage() { Resources.UnloadUnusedAssets(); string lasetManifestPath = Path.Combine(versionUpdatePath, lastManifestFolder); string assetBundlesPath = Path.Combine(versionUpdatePath, assetBundlesFolder); string publishPath = Path.Combine(versionUpdatePath, publishFolder); AssetBundleManifest newManifest; if (!LoadAssetBundleAsset(assetBundlesPath, out newManifest)) { Debug.LogWarning("Load Asset Bundle Manifest Failed! " + assetBundlesPath); return; } if (!LoadAssetBundleAsset(assetBundlesPath, out versionData)) { Debug.LogWarning("Load Version Update Data Failed!" + assetBundlesPath); return; } string zipName = versionData.versionNumber + ".zip"; string[] newBundles = newManifest.GetAllAssetBundles(); WriteVersionUpdateTable(publishPath, versionData.versionNumber, zipName); ZipUtility.CompressesFileList(assetBundlesPath, newBundles, string.Empty, Path.Combine(publishPath, zipName)); if (copyToLastManifest) { CopyAssetBundleManifestToOldPath(assetBundlesPath, lasetManifestPath); } hasPackageVersion = true; Debug.Log("Create Version Package Successful!"); EditorUtility.RevealInFinder(publishPath); }
private string SaveFileToTempDirectory(FileUpload fileToRestore) { // Save file to temp directory, ensuring that we are not overwriting an existing file. If the uploaded file is a ZIP archive, // extract the embedded XML file and save that. var filePath = String.Empty; var fileExt = Path.GetExtension(fileToRestore.FileName); if (fileExt == null || String.IsNullOrWhiteSpace(fileExt)) { return(filePath); } if (fileExt.Equals(".zip", StringComparison.OrdinalIgnoreCase)) { using (var zip = new ZipUtility(Utils.UserName, GetGalleryServerRolesForUser())) { filePath = zip.ExtractNextFileFromZip(fileToRestore.FileContent, AppSetting.Instance.TempUploadDirectory); } } else if (fileExt.Equals(".xml", StringComparison.OrdinalIgnoreCase)) { string fileName = HelperFunctions.ValidateFileName(AppSetting.Instance.TempUploadDirectory, fileToRestore.FileName); filePath = Path.Combine(AppSetting.Instance.TempUploadDirectory, fileName); fileToRestore.SaveAs(filePath); } return(filePath); }
public byte[] ToUnzipBytes() { var oriData = ToBytes(); var unzipData = ZipUtility.DecompressDeflate(oriData); return(unzipData); }
public Job(Guid id, Guid handlerId, string jobInputString, string hash) { Id = id; HandlerId = handlerId; Hash = hash; JobInputCompressed = ZipUtility.GZipCompress(Encoding.UTF8.GetBytes(jobInputString)); }
public async Task <IList <ImportResult> > PerformImport() { IList <ImportResult> results = new List <ImportResult>(); //clean the files await CleanEnvironment(); //Download the zipfile FileDownloadResult downloadResult = await FileDownloadUtilities.DownloadFile(new Uri(Path.Combine(CsvImportSettings.FtpSource, CsvImportSettings.FacZipFilename)), CsvImportSettings.LocalImportDirectory); if (downloadResult.Success) { ZipUtility.UnZipFile(downloadResult.LocalFilePath, downloadResult.TargetDirectory); results.Add(await PassthroughImporter.Import()); results.Add(await FormattedFindingsTextImporter.Import()); results.Add(await FormattedCapTextImporter.Import()); results.Add(await FindingTextImporter.Import()); results.Add(await FindingImporter.Import()); results.Add(await EinImporter.Import()); results.Add(await DunImporter.Import()); results.Add(await CpaImporter.Import()); results.Add(await CapTextImporter.Import()); results.Add(await AgencyImporter.Import()); results.Add(await GeneralImporter.Import()); results.Add(await CfdaImporter.Import()); } return(results); }
/// <summary> /// 获取插件包的信息 /// </summary> /// <param name="fileName"></param> /// <returns></returns> public static IEnumerable <PluginPackAttribute> GetPluginPackInfo(string fileName) { var tempDir = String.Concat(AppDomain.CurrentDomain, PluginConfig.PLUGIN_TMP_DIRECTORY, "tmp/"); if (Directory.Exists(tempDir)) { Directory.Delete(tempDir, true); } Directory.CreateDirectory(tempDir).Create(); var dir = new DirectoryInfo(tempDir); ZipUtility.UncompressFile(tempDir, fileName, false); Assembly ass; var files = dir.GetFiles("*.dll"); foreach (FileInfo f in files) { ass = Assembly.Load(File.ReadAllBytes(f.FullName)); var attbs = ass.GetCustomAttributes(typeof(PluginPackAttribute), false); foreach (object attb in attbs) { if (attb is PluginPackAttribute) { yield return((PluginPackAttribute)attb); } } } }
// 解压脚本 IEnumerator UnZip_lua() { launcherUI.setTip(tipTextUnzipLua); if (Directory.Exists(dst_lua_zip)) { if (!Directory.Exists(dst_lua)) { Directory.CreateDirectory(dst_lua); yield return(new WaitForSeconds(1.01f)); } DirectoryInfo dir = new DirectoryInfo(dst_lua_zip); FileSystemInfo[] fileinfo = dir.GetFileSystemInfos(); foreach (FileSystemInfo i in fileinfo) { string aFirstName = i.Name.Substring(0, i.Name.LastIndexOf(".")); //文件名 ZipUtility.UnzipFile(i.FullName, dst_lua); yield return(new WaitForSeconds(0.01f)); } // 解压完毕,删除目录,避免累积 Directory.Delete(dst_lua_zip, true); } // 全部热更完成 加载主场景 TryEnterGeme(); // TODO:request_server_list }
public void DownLoadFileCompleted(object sender, AsyncCompletedEventArgs e) { if (e.Error != null) { OnFailed(); Debug.LogError(e.Error); return; } if (e.Cancelled) { return; } downLoadComplete = true; if (Target != null) { //解压zip然后把skc和贴图保存,然后保存插件的存档.下次进来 if (OnUnZipFinish == null) { OnUnZipFinish = new UnzipCallbackEx(this); } ZipUtility.UnzipFile(Target.LocalPath, Target.LocalPath.Substring(0, Target.LocalPath.Length - 4), null, OnUnZipFinish); } if (Chapter != null) { if (OnUnZipFinish == null) { OnUnZipFinish = new UnzipCallbackEx(this); } ZipUtility.UnzipFile(Chapter.LocalPath, Chapter.LocalPath.Substring(0, Chapter.LocalPath.Length - 4), null, OnUnZipFinish); } }
/// <summary> /// 打包下载指定GUID的所有附件文件 /// </summary> /// <param name="guid"></param> /// <returns></returns> public ActionResult DownloadAttach(string guid) { List <FileUploadInfo> list = BLLFactory <FileUpload> .Instance.GetByAttachGUID(guid); List <string> fileList = new List <string>(); foreach (FileUploadInfo info in list) { string realFolderPath = ""; string filePath = BLLFactory <FileUpload> .Instance.GetFilePath(info); if (!Path.IsPathRooted(filePath)) { realFolderPath = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, filePath); } fileList.Add(realFolderPath); } ZipUtility.ZipFiles(fileList, Response.OutputStream, ""); string saveFileName = "AttachPackage.zip"; Response.Charset = "GB2312"; Response.ContentEncoding = Encoding.GetEncoding("GB2312"); Response.ContentType = "application/octet-stream"; Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(saveFileName)); Response.Flush(); Response.End(); return(new FileStreamResult(Response.OutputStream, "application/octet-stream")); }
public void Close(string ssss) { Test.Instance.Log("Close " + ssss); isStop = true; if (mRequest != null) { mRequest.Abort(); mRequest = null; } if (mResponse != null) { mResponse.Close(); mResponse = null; } if (mHttpStream != null) { mHttpStream.Close(); mHttpStream.Dispose(); mHttpStream = null; } if (mDownloadThread != null) { mDownloadThread.Abort(); } ZipUtility.Stop(); }
IEnumerator LoadImage() { UnityWebRequest request = UnityWebRequest.Get(Singleton <LoginModel> .GetInstance().GetStringWithFileUrl() + "file/downByzip.do?"); // yield return(request.Send()); // if (request.isNetworkError) { Debug.Log(request.error); } else { if (request.responseCode == 200) { byte[] results = request.downloadHandler.data; //Debug.Log("Application.persistentDataPath=" + AssetConst.ImageSavePath); ZipUtility.UnzipFile(results, AssetConst.ImageSavePath); Singleton <ModuleEventDispatcher> .GetInstance().dispatchEvent(ModuleEventDispatcher.IMAGE_LOAD_COMPLETE); //CreatAllImageTarget(); } } }
/// <summary> /// Saves the data model for the specified <see cref="ViewModel<TController, TModel>"/>. /// </summary> /// <param name="viewModel">The view model.</param> /// <param name="owner">The owner window.</param> /// <returns> /// <c>true</c> if the data model is saved; otherwise, <c>false</c>. /// </returns> public static bool SaveAs(ViewModel <TController, TModel> viewModel, Window owner) { string currentDirectory = Environment.CurrentDirectory; // this is line X. line X and line Y are necessary for back-compat with windows XP. // Get the save path from the user // NOTE: For now, use the WinForms SaveFileDialog since it supports the Vista style common save file dialog. SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "Configuration file (*.zip)|*.zip"; saveFileDialog.FileName = viewModel.Title; bool succeeded = false; //if (saveFileDialog.ShowDialog (owner) == true) if (saveFileDialog.ShowDialog() == DialogResult.OK) { Environment.CurrentDirectory = System.IO.Path.GetTempPath(); string tempFileName = "_Configuration.xml"; succeeded = viewModel.Save(tempFileName); ZipUtility.Zip(saveFileDialog.FileName, new string[] { tempFileName }); File.Delete(tempFileName); } else { succeeded = false; } Environment.CurrentDirectory = currentDirectory; // this is line Y. line X and line Y are necessary for back-compat with windows XP. return(succeeded); }
private void UnzipFiles(CommandLineLogger logger, string holderFolder, string defaultDirectory, string parentZipFile, string toExtract, ref ParserVersionEnum version) { ZipUtility zp = new ZipUtility(logger) { CaseName = holderFolder, ParentZipFilePath = parentZipFile }; IEnumerable <ExtractFileInfo> htmlFiles = zp.ExtractZip(defaultDirectory, toExtract, ".html"); if (htmlFiles.Any()) { foreach (ExtractFileInfo file in htmlFiles) { File.Copy(file.File_Path, Path.GetDirectoryName(file.File_Path) + "\\save-" + file.File_Name); _filesToPreserve.Add(file); } _htmlToParse.AddRange(htmlFiles.Where(x => !x.File_Name.ToUpper().Trim().StartsWith("INDEX.") && !x.File_Name.ToUpper().Trim().StartsWith("PRESERVATION"))); IEnumerable <ExtractFileInfo> generatedHtmlFiles = zp.GenerateParsedHtml(htmlFiles); if (generatedHtmlFiles.Any()) { version = ParserVersionEnum.Two; foreach (ExtractFileInfo generatedHtmlFile in generatedHtmlFiles) { if (!_htmlToParse.Any(x => x.File_Path.Equals(generatedHtmlFile.File_Path)) && !_htmlToParse.Any(x => x.File_Path.Equals(generatedHtmlFile.File_Path + @"\" + Path.GetFileNameWithoutExtension(generatedHtmlFile.File_Path)))) { _htmlToParse.Add(generatedHtmlFile); } } _tempFilesToRemove.AddRange(generatedHtmlFiles); } else { _htmlToParse.AddRange(htmlFiles.Where(x => x.File_Name.ToUpper().Trim().StartsWith("INDEX."))); } SaveFiles(htmlFiles); } IEnumerable <ExtractFileInfo> zipFiles = zp.ExtractZip(defaultDirectory, toExtract, ".zip"); if (zipFiles.Count() > 0) { SaveFiles(zipFiles); _tempFilesToRemove.AddRange(zipFiles); } IEnumerable <ExtractFileInfo> otherFiles = zp.ExtractZip(defaultDirectory, toExtract, ""); if (otherFiles.Count() > 0) { SaveFiles(otherFiles); } foreach (ExtractFileInfo z in zipFiles) { UnzipFiles(logger, holderFolder, defaultDirectory, toExtract, z.File_Path, ref version); } }
/// <summary> /// 在文件夹里查找模型文件(只支持.zip/.fbx/.gltf/.glb/.unity3d) /// </summary> /// <param name="folder">文件夹Path</param> /// <returns></returns> public static string FindModelFileFullName(string folder, out string format) { folder = ZipUtility.PathRespace(folder); Debug.Log("文件夹路径 " + folder); DirectoryInfo theFolder = new DirectoryInfo(folder); //当前层检测是否找到 FileInfo[] fileInfos = theFolder.GetFiles(); for (int i = 0; i < fileInfos.Length; i++) { string fileName = fileInfos[i].Name.ToLower(); if (fileName.EndsWith(".fbx")) { format = ".fbx"; return(PathRespace(fileInfos[i].FullName)); } if (fileName.EndsWith(".gltf")) { format = ".gltf"; return(PathRespace(fileInfos[i].FullName)); } if (fileName.EndsWith(".glb")) { format = ".glb"; return(PathRespace(fileInfos[i].FullName)); } if (fileName.EndsWith(".unity3d")) { format = ".unity3d"; return(PathRespace(fileInfos[i].FullName)); } if (fileName.EndsWith(".zip")) { format = ".zip"; return(PathRespace(fileInfos[i].FullName)); } } //递归子文件夹查找 DirectoryInfo[] childFolders = theFolder.GetDirectories(); for (int i = 0; i < childFolders.Length; i++) { string found = FindModelFileFullName(childFolders[i].FullName, out string outEndFile); if (!string.IsNullOrEmpty(found)) { format = outEndFile; return(found); } } Debug.Log("资源没找到 " + folder); format = ""; return(""); }
/// <summary> /// Register a package (handlers, dependencies, ...) /// </summary> public bool RegisterPackage(PackageInfo packageInfo, byte[] zipcontent) { // Save package information _packageManager.Save(packageInfo); // Unpack the zip file ZipUtility.ZipExtractToDirectory(zipcontent, PackagesFolder, true); Logger.Info("Registered package '{0}' with {1} handler file(s) and {2} dependent file(s)", packageInfo.PackageName, packageInfo.HandlerAssemblies.Count, packageInfo.Dependencies.Count); return(true); }
void UnzipFromBytes(byte[] bytes) { System.IO.MemoryStream zipStream = new System.IO.MemoryStream(bytes); ZipUtility.UnzipFromStream(zipStream, materialPath); string jsonPath = Path.Combine(materialPath, "materials/" + jsonFileName); string jsonText = System.IO.File.ReadAllText(jsonPath); material = JsonUtility.FromJson <Material>(jsonText); }
protected IEnumerator UncompressPatches() { m_VersionCheckState = VersionCheckState.UncompressPatch; for (int i = m_HasDownloadDoneCount; i < m_PatchKeyList.Count; ++i) { var result = 0; var downloadProgress = 0f; var localPath = Path.Combine(UGCoreConfig.GetExternalDownloadFolder() + "/Patches", m_PatchKeyList[i]); LoadingUI.Instance.ShowLoadingTip(string.Format(LoadingLanguageData.Instance.GetString(16), (i + 1), m_PatchKeyList.Count, 0)); LoadingUI.Instance.PushLoadTaskProgressDelta(1); LoadingUI.Instance.SetLoadingBarProgress(0); ZipUtility.UnzipDirectoryAsync(localPath, UGCoreConfig.GetExternalResourceFolder(), (progress) => { downloadProgress = progress; }, () => { ++m_HasDownloadDoneCount; result = 1; }, () => { result = 2; }); while (result == 0) { LoadingUI.Instance.ShowLoadingTip(string.Format(LoadingLanguageData.Instance.GetString(16), (i + 1), m_PatchKeyList.Count, (int)downloadProgress)); LoadingUI.Instance.SetLoadingBarProgress(downloadProgress * 0.01f); yield return(null); } if (result == 1) { LoadingUI.Instance.ShowLoadingTip(string.Format(LoadingLanguageData.Instance.GetString(16), (i + 1), m_PatchKeyList.Count, 100)); LoadingUI.Instance.SetLoadingBarProgress(1); LoadingUI.Instance.PopLoadTaskProgressDelta(); } else if (result == 2) { m_CoroutineWorkflow.AddFirst("ShowUncompressPatchesError", ShowUncompressPatchesError); yield break; } yield return(null); } //保存资源版本号 GameRuntimeInfo.ResourceVersion = GameRuntimeInfo.RemoteControlConfig.ResourceVersion; SaveVersionInfo(GameRuntimeInfo.ProgramVersion, GameRuntimeInfo.ResourceVersion, false); }
/// <summary> /// Handles the Click event of the btnExportData control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void btnExportData_Click(object sender, EventArgs e) { string backupFilename = "GalleryServerBackup_" + DateTime.Now.ToString("yyyy-MM-dd_HHmmss", CultureInfo.InvariantCulture); IBackupFile bak = new BackupFile(); bak.IncludeMembershipData = chkExportMembership.Checked; bak.IncludeGalleryData = chkExportGalleryData.Checked; var galleryData = bak.Create(); IMimeType mimeType = Factory.LoadMimeType("dummy.zip"); int bufferSize = AppSetting.Instance.MediaObjectDownloadBufferSize; byte[] buffer = new byte[bufferSize]; Stream stream = null; try { // Create an in-memory ZIP file. stream = ZipUtility.CreateZipStream(galleryData, backupFilename + ".xml"); // Send to user. Response.AddHeader("Content-Disposition", "attachment; filename=" + backupFilename + ".zip"); Response.Clear(); Response.ContentType = (mimeType != null ? mimeType.FullType : "application/octet-stream"); Response.Buffer = false; stream.Position = 0; int byteCount; while ((byteCount = stream.Read(buffer, 0, buffer.Length)) > 0) { if (Response.IsClientConnected) { Response.OutputStream.Write(buffer, 0, byteCount); Response.Flush(); } else { return; } } } finally { if (stream != null) { stream.Close(); } Response.End(); } }
/// <summary> /// 安装/升级插件 /// </summary> /// <param name="url"></param> /// <param name="handler"></param> /// <returns></returns> public static bool InstallPlugin(string url, PluginHandler <PluginPackAttribute> handler) { var installResult = false; string appDirectory = AppDomain.CurrentDomain.BaseDirectory; var pluginPath = String.Concat( appDirectory, PluginConfig.PLUGIN_DIRECTORY); var tempDir = String.Concat(appDirectory, PluginConfig.PLUGIN_TMP_DIRECTORY, "plugin/"); var fileName = tempDir + "dl_pack_" + String.Empty.RandomLetters(16) + ".zip"; if (Directory.Exists(tempDir)) { Directory.Delete(tempDir, true); } Directory.CreateDirectory(tempDir).Create(); var dir = new DirectoryInfo(tempDir); var data = WebClient.DownloadFile(url, null); using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write)) { fs.Write(data, 0, data.Length); fs.Flush(); fs.Dispose(); } IList <PluginPackAttribute> pluginAttrs = new List <PluginPackAttribute>(GetPluginPackInfo(fileName)); if (pluginAttrs.Count != 0) { ZipUtility.UncompressFile(pluginPath, fileName, false); foreach (FileInfo file in dir.GetFiles("*.dll")) { File.Delete(pluginPath + file.Name); file.MoveTo(pluginPath + file.Name); } if (handler != null) { var result = false; foreach (PluginPackAttribute attr in pluginAttrs) { handler(attr, ref result); } } installResult = true; } Directory.Delete(tempDir, true); return(installResult); }
void ModelLoad() { //string modelPath = ZipUtility.FindModelFileFullName(resPath, out string format); //Debug.Log("---测试模型:" + modelPath); string[] foundFilePathlist = ZipUtility.FindModelFileFullNameList(resPath, out string fomat); for (int i = 0; i < ZipUtility.GetListFullName.Count; i++) { string modelPath = ZipUtility.GetListFullName[i]; Debug.Log("---测试模型:" + modelPath); MiniLoadModel(modelPath); } }
protected void btnExportData_Click(object sender, EventArgs e) { string backupFilename = "GalleryServerBackup_" + DateTime.Now.ToString("yyyy-MM-dd_HHmmss"); string galleryData = HelperFunctions.ExportGalleryData(chkExportMembership.Checked, chkExportGalleryData.Checked); IMimeType mimeType = MimeType.LoadInstanceByFilePath("dummy.zip"); ZipUtility zip = new ZipUtility(Util.UserName, RoleController.GetGalleryServerRolesForUser()); int bufferSize = Core.MediaObjectDownloadBufferSize; byte[] buffer = new byte[bufferSize]; Stream stream = null; try { // Create an in-memory ZIP file. stream = zip.CreateZipStream(galleryData, backupFilename + ".xml"); // Send to user. Response.AddHeader("Content-Disposition", "attachment; filename=" + backupFilename + ".zip"); Response.Clear(); Response.ContentType = (mimeType != null ? mimeType.FullType : "application/octet-stream"); Response.Buffer = false; stream.Position = 0; int byteCount; while ((byteCount = stream.Read(buffer, 0, buffer.Length)) > 0) { if (Response.IsClientConnected) { Response.OutputStream.Write(buffer, 0, byteCount); Response.Flush(); } else { return; } } } finally { if (stream != null) { stream.Close(); } Response.End(); } }