string GetLatestZip() { string[] fileNames = Directory.GetFiles(PathHelper.ZipDirectory); string result = null; DateTime latestZipTime = DateTime.MinValue; foreach (string fileName in fileNames) { if (fileName.Contains(".zip")) { DateTime thisZipTime = File.GetLastWriteTime(fileName); if (thisZipTime > latestZipTime) { result = fileName; latestZipTime = thisZipTime; } } } if (!string.IsNullOrEmpty(result)) { PathHelper.ProjectZipFullPath = result; Debug.Log(PathHelper.ProjectZipFullPath); return(File.GetLastWriteTime(result).ToLongTimeString()); } return(null); }
// // Project Config // void SaveProjectConfig() { JSONNode configJson = Utils.GetProjectSettingsJsonNode(); if (configJson == null) { configJson = JSONNode.Parse("{}"); } configJson["PackingDirectories"] = JsonHelper.ToJsonArray(PackingDirectories.Directories); foreach (TransferMode t in Enum.GetValues(typeof(TransferMode))) { int modeInt = (int)t; string modeString = Enum.GetName(typeof(TransferMode), t); configJson["taskId"][modeString] = ContextForMode[(int)t].taskId; configJson["repoInfo"][modeString]["repoUsername"] = ContextForMode[modeInt].repoUsername; configJson["repoInfo"][modeString]["repoPassword"] = ContextForMode[modeInt].repoPassword; configJson["repoInfo"][modeString]["repoUrl"] = ContextForMode[modeInt].repoUrl; configJson["repoInfo"][modeString]["repoBranch"] = ContextForMode[modeInt].repoBranch; configJson["repoInfo"][modeString]["repoToken"] = ContextForMode[modeInt].repoToken; } Debug.Log("Save Project Config: " + configJson); Utils.SaveProjectSettings(configJson); }
void StartCloudBuildAction() { //check if IL2CPP if (ContextForMode[transferModeFlag].BadScriptingBackend()) { EditorUtility.DisplayDialog("Error", "Can't start Cloud Build.\nScripting Backend: IL2CPP detected. To some build targets [Standalone, OSX, Android], IL2CPP is not supported. Please check you player settings.", "OK"); return; } ContextForMode[transferModeFlag].HideProgress(); ContextForMode[transferModeFlag].ResetJobsWithActionsOpened(); JSONNode data = BuildStartCloudBuildOptions(); try { JSONNode response = ucbFacade.PostTask(data); ContextForMode[transferModeFlag].taskId = response["taskUuid"]; ContextForMode[transferModeFlag].taskInfo = response; ContextForMode[transferModeFlag].UpdateSyncTaskInterval(); SaveProjectConfig(); Debug.Log(string.Format(@"Build Task [{0}] started with Jobs [{1}].", ContextForMode[transferModeFlag].taskId, response["jobs"].ToString())); } catch (Exception ex) { Debug.LogError(ex); ShowNotification(new GUIContent(ex.Message)); } }
public static void showWindow() { Debug.Log("Unity Version: " + unityVersion); if (UcbFacade.GetInstance().CheckUnityVersion(unityVersion)) { EditorWindow.GetWindow(typeof(UcbEditorWindow)); } else { EditorUtility.DisplayDialog("Unsupported Unity Version", "You are using a version of Unity Editor that is not supported by Cloud Build Plugin.", "OK"); } }
// public async Task AsyncUploadProject(string fileName, string projectId, IProgress<double> progress) // { // AsyncFunction(fileName, projectId, progress); // } // private Task AsyncFunction(string fileName, string projectId, IProgress<double> progress) // { // return Task.Run(() => // { // UploadProject(fileName, projectId, progress); // return; // }); // } public void AsyncUploadProject(string fileName, string projectId, IProgress <double> progress, OnCompleteCallback onComplete) { Func <string, string, IProgress <double>, Exception> fun = t_UploadProject; fun.BeginInvoke(fileName, projectId, progress, (ar => { Debug.Log("Async FTP Upload Ended."); if (ar == null) { throw new ArgumentNullException("ar"); } Func <string, string, IProgress <double>, Exception> dl = (Func <string, string, IProgress <double>, Exception>)ar.AsyncState; Exception result = dl.EndInvoke(ar); onComplete(result); }), fun); Debug.Log("Async FTP Upload Start."); }
// // Pack // void StartPackingProject() { OnZipProgressChange(0f); try { ZipHandler.CleanPreviousZip(PathHelper.ZipDirectory); PathHelper.ProjectZipFullPath = ZipHandler.CompressProject(PathHelper.ProjectDirectory, PathHelper.ZipDirectory + "project-pack.zip", new BasicProgress <double>(OnZipProgressChange)); Debug.Log(PathHelper.ProjectZipFullPath); } catch (IOException ex) { //file hash exists Debug.LogError(ex); ShowNotification(new GUIContent(ex.Message)); } finally { EditorUtility.ClearProgressBar(); } }
public void UploadProject(string fileName, string projectId, IProgress <double> progress) { long offset = GetFileOffset(fileName, projectId); Console.WriteLine("file offset {0}", offset); long fileLength = new FileInfo(fileName).Length; if (offset == fileLength) { throw new CosFileExistsException("File Exists"); } Debug.Log(string.Format(@"Start to upload zip file to ftp server - {0}", DateTime.Now)); Uri uri = new Uri(string.Format(@"ftp://{0}:{1}/{2}/{3}", remoteHost, remotePort, projectId, Path.GetFileName(fileName))); Debug.Log(string.Format(@"ftp url is {0} - {1}", uri, DateTime.Now)); FtpWebRequest request = (FtpWebRequest)WebRequest.Create(uri); request.Credentials = new NetworkCredential(username, password); request.UsePassive = false; request.KeepAlive = true; request.UseBinary = true; request.ContentOffset = offset; if (offset > 0L) { request.Method = WebRequestMethods.Ftp.AppendFile; } else { request.Method = WebRequestMethods.Ftp.UploadFile; } Debug.Log(string.Format(@"*** {0} ***", DateTime.Now)); Stream dest = request.GetRequestStream(); Debug.Log(string.Format(@"*** {0} ***", DateTime.Now)); FileStream src = File.OpenRead(fileName); src.Position = offset; int bufSize = (int)Math.Min(src.Length, 2048); byte[] buffer = new byte[bufSize]; int bytesRead = 0; long currentBytes = 0; do { bytesRead = src.Read(buffer, 0, bufSize); dest.Write(buffer, 0, bufSize); currentBytes += bytesRead; progress.Report(currentBytes / (double)src.Length); }while (bytesRead != 0); dest.Close(); src.Close(); Debug.Log(string.Format(@"Finish to upload zip file to ftp server - {0}", DateTime.Now)); using (FtpWebResponse response = (FtpWebResponse)request.GetResponse()) { Debug.Log("Upload File Complete, status " + response.StatusDescription); } }