public IActionResult Index2(SetupVM vm) { vm.EntryDir = AppDomain.CurrentDomain.BaseDirectory; vm.ExtraDir = vm.EntryDir + "\\" + vm.ExtraDir; vm.MainNs = vm.ExtraNS; vm.MainDir = vm.ExtraDir + "\\" + vm.MainNs; if (Directory.Exists(vm.ExtraDir) == false) { Directory.CreateDirectory(vm.ExtraDir); } if (Directory.Exists(vm.MainDir) == false) { Directory.CreateDirectory(vm.MainDir); } vm.WriteDefaultFiles(); vm.DoSetup(); var zipdir = vm.EntryDir + "\\ZipFiles"; if (Directory.Exists(zipdir) == false) { Directory.CreateDirectory(zipdir); } var zipfile = zipdir + "\\" + vm.ExtraNS + ".zip"; System.IO.Compression.ZipFile.CreateFromDirectory(vm.ExtraDir, zipfile); byte[] rv = System.IO.File.ReadAllBytes(zipfile); System.IO.File.Delete(zipfile); return(File(rv, "application/zip", vm.ExtraNS + ".zip")); }
public IActionResult Index2(SetupVM vm) { vm.EntryDir = AppDomain.CurrentDomain.BaseDirectory; vm.ExtraDir = vm.EntryDir + Path.DirectorySeparatorChar + vm.ExtraDir; vm.MainNs = vm.ExtraNS; vm.MainDir = vm.ExtraDir + Path.DirectorySeparatorChar + vm.MainNs; string propertydir = vm.MainDir + Path.DirectorySeparatorChar + "Properties"; if (Directory.Exists(vm.ExtraDir) == false) { Directory.CreateDirectory(vm.ExtraDir); } if (Directory.Exists(vm.MainDir) == false) { Directory.CreateDirectory(vm.MainDir); } if (Directory.Exists(propertydir) == false) { Directory.CreateDirectory(propertydir); } vm.WriteDefaultFiles(); vm.DoSetup(); var zipdir = vm.EntryDir + Path.DirectorySeparatorChar + "ZipFiles"; if (Directory.Exists(zipdir) == false) { Directory.CreateDirectory(zipdir); } string g = Guid.NewGuid().ToString(); var zipfile = zipdir + Path.DirectorySeparatorChar + g + ".zip"; System.IO.Compression.ZipFile.CreateFromDirectory(vm.ExtraDir, zipfile); byte[] rv = System.IO.File.ReadAllBytes(zipfile); System.IO.File.Delete(zipfile); System.IO.Directory.Delete(vm.ExtraDir, true); return(File(rv, "application/zip", vm.ExtraNS + ".zip")); }
//------------------------------------------------------------------------------------------------------------ // GET: SetUps public ActionResult Index(string message) { //This handles the messages //Add a message if the message is not empty if (!string.IsNullOrEmpty(message)) { ModelState.AddModelError("",message); } var setupList = repo.FindAll().OrderBy(x => x.Description).ToList(); List<SetupVM> setupListVM = new List<SetupVM>(); if (setupList != null) { foreach (var item in setupList) { SetupVM sVM = new SetupVM(); sVM.Id = item.Id; sVM.Description = item.Description; sVM.Value = item.Value; sVM.Name = item.Name; setupListVM.Add(sVM); } } return View(setupListVM); }
//------------------------------------------------------------------------------------------------------------ // GET: SetUps/Edit/5 public ActionResult Edit(long? id) { SetUp setUp = new SetUp(); try { setUp = repo.FindFor(id); } catch(Exception e) { return RedirectToIndexActionErrorHelper("There was a problem. No record was found. ", e); } SetupVM setupVM = new SetupVM(); setupVM.Id = setUp.Id; setupVM.Description = setUp.Description; setupVM.Value = setUp.Value; if (setUp.Type==EnumTypes.EmailingMethod) { List<SelectListVM> emailOptions = new List<SelectListVM> { new SelectListVM { Id="sendgrid",Name="sendgrid"}, new SelectListVM {Id="smtp",Name="smtp"}, new SelectListVM {Id="test",Name=@"Create dir at c:\TestEmail"} }; ViewBag.Value = new SelectList(emailOptions, "Id", "Name", setupVM.Value); return View("EditWithDropDown", setupVM); } return View(setupVM); }
public SetupView() { InitializeComponent(); BindingContext = vm = new SetupVM(); }