public ActionResult Create(PackageModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {

                    CaculateModel(model);
                    string msg = "";
                    string generatedfileName = SaveFile(inputFileFieldName, out msg);
                    model.File = generatedfileName;
                    if (string.IsNullOrWhiteSpace(generatedfileName))
                    {
                        ModelState.AddModelError(inputFileFieldName, msg);
                        return View(model);
                    }

                    PackageBusiness b = new PackageBusiness();
                    b.AddPackage(ObjectCopier.Copy<Package>(model));

                }

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
Exemplo n.º 2
0
        public ActionResult Create()
        {
            PackageBusiness b = new PackageBusiness();
            var list = b.GetPackageList();
            var count = b.GetPackageCount();

            List<PackageModel> results = new List<PackageModel>();
            list.ForEach(p => results.Add(ObjectCopier.Copy<PackageModel>(p)));

            return View(results);
        }
 public FileResult GetPackageFile(string uuid)
 {
     var b = new PackageBusiness();
     string fileName = b.GetFileName(uuid);
     return File(Path.Combine(GetUploadDir(), fileName),
         System.Net.Mime.MediaTypeNames.Application.Zip, fileName);
 }
        public ActionResult Delete(int id, FormCollection c)
        {
            PackageBusiness b = new PackageBusiness();
            b.DeletePackage(id);

            return RedirectToAction("Index");
        }
        public ActionResult SetVerified(int packageId)
        {
            PackageBusiness b = new PackageBusiness();
            b.SetPackageVerified(packageId);

            return RedirectToAction("Index");
        }
        public ActionResult SetPackageVerified(int packageId)
        {
            PackageBusiness b = new PackageBusiness();
            bool ok = b.SetPackageVerified(packageId);

            return Json(new { ok });
        }
        //
        // GET: /Package/
        public ActionResult Index(int pageIndex = 1, int pageSize = 10)
        {
            PackageBusiness b = new PackageBusiness();
            var list = b.GetPackageList();
            var count = b.GetPackageCount();

            DeployRecordBusiness drb = new DeployRecordBusiness();
            var packageIdAndDeployedCountPairs = drb.GetDeployCountForPackage(list.Select(p => p.PackageId));

            List<PackageModel> results = new List<PackageModel>();
            list.ForEach(p =>
            {
                var q = ObjectCopier.Copy<PackageModel>(p);
                q.ExtraInfo = "暂未发布";
                if (packageIdAndDeployedCountPairs.ContainsKey(p.PackageId))
                    q.ExtraInfo = string.Format("已发布{0}次", packageIdAndDeployedCountPairs[p.PackageId]);
                results.Add(q);
            });

            return View(results);
        }