static void Main(string[] args) { Console.WriteLine("**********************************************************"); Console.WriteLine("* Captura el número de una de las siguientes opciones: *"); Console.WriteLine("* 1 = Subir código *"); Console.WriteLine("* 2 = Agregar Notificador *"); Console.WriteLine("* 3 = Agregar Compilador *"); Console.WriteLine("* 4 = Agregar Ejecutor de Pruebas Unitarias *"); Console.WriteLine("* 5 = Agregar Instalador *"); Console.WriteLine("**********************************************************"); string text; UploadCode uploadCode = new UploadCode(); Notifier notifier = new Notifier(); Compiler compiler = new Compiler(); UnitTestExecutor executor = new UnitTestExecutor(); Installer installer = new Installer(); do { text = Console.ReadLine(); switch (text) { case "1": uploadCode.PrintMessage(); break; case "2": uploadCode.Subscribe(notifier); break; case "3": uploadCode.Subscribe(compiler); break; case "4": uploadCode.Subscribe(executor); break; case "5": uploadCode.Subscribe(installer); break; default: Console.WriteLine("No existe esa opción en el menú"); break; } } while (text != null); }
/// <summary> /// 保存文件 /// </summary> /// <param name="autoName">是否自动命名</param> /// <returns></returns> private string SaveToFile(bool autoName) { this._length = postFile.ContentLength; string mFile = postFile.FileName; string mType = postFile.ContentType; if (mFile == "") { errorCode = UploadCode.NoFile; return(""); } if (this._length == 0) { errorCode = UploadCode.BadFile; return(""); } if (!CheckFileExe(mFile)) { errorCode = UploadCode.CencelType; return(""); } if (this._length > this.FormatSize) { errorCode = UploadCode.Exceed; return(""); } if (autoName) { this.fileName = this.HexNewFileName + "." + this.GetFileExe(mFile); } else if (string.IsNullOrEmpty(this.fileName)) { this.fileName = mFile; } else { var index = this.fileName.LastIndexOf("."); if (index < 0) { this.fileName += "." + this.GetFileExe(mFile); } else { this.fileName = this.fileName.Substring(0, index + 1) + this.GetFileExe(mFile); } } DateTime d = DateTime.Now; string tmp = ""; if (autoName) { tmp = string.Format(@"{0}-{1}\{2}", new object[] { d.Year, d.Month, d.Day }); } this.savePath = this.savePath + tmp + "\\"; this.savePath = this.MapPath(this.savePath, out webUrl); if (!Directory.Exists(this.savePath)) { Directory.CreateDirectory(this.savePath); } try { webUrl += this.fileName; this.fileName = this.savePath + this.fileName; postFile.SaveAs(this.fileName); errorCode = UploadCode.Success; return(webUrl); } catch { errorCode = UploadCode.Unknown; } return(""); }