public bool CheckApp(PtiApp app) { try { //if (string.IsNullOrEmpty(app.ZipFile)) //{ // return false; //} if ((!string.IsNullOrWhiteSpace(app.ZipFile)) && (!File.Exists(Path.Combine(Config.Get().AppZipPath, app.ZipFile)))) { return(false); } if (string.IsNullOrWhiteSpace(app.Name)) { return(false); } if (string.IsNullOrWhiteSpace(app.Id)) { app.Id = MD5Helper.getMd5Hash(app.Name); } app.UpdateDate = DateTime.Now; if (app.CreateDate == null) { app.CreateDate = app.UpdateDate; } return(true); } catch (Exception e) { WriteError(e.ToString()); return(false); } }
public bool AddApp(PtiApp app) { if (!this.CheckApp(app)) { return(false); } //解压文件 string targetPath = Path.Combine(Config.Get().AppRunPath, app.Id); if (!string.IsNullOrWhiteSpace(app.ZipFile)) { string source = Path.Combine(Config.Get().AppZipPath, app.ZipFile); if (!ZipHelper.UnZip(source, targetPath)) { return(false); } } else { if (!Directory.Exists(targetPath)) { Directory.CreateDirectory(targetPath); } } this.Db.AddOrUpdateApp(app); return(true); }