예제 #1
0
        public ActionResult uploadFile2(UploadModel uploadModel, int patronesId)
        {
            Patrone patron = db.Patrones.Find(patronesId);

            String path = this.Upload(uploadModel, patron.direccionArchivo);

            return View("OnlyUploadFile");
        }
예제 #2
0
        public String Upload(UploadModel uploadModel, String subFolder)
        {
            String path = "";
            ParametrosHelper parameterHelper = new ParametrosHelper();
            Parametro rutaParameter = parameterHelper.getParameterByKey("SUARUTA");
            if (Request.Files.Count > 0)
            {
                var file = Request.Files[0];

                if (file != null && file.ContentLength > 0)
                {

                    if (!subFolder.Equals(""))
                    {
                        path = Path.Combine(rutaParameter.valorString.Trim(), subFolder);
                        path = path.Trim();
                        if (!System.IO.File.Exists(path))
                        {
                            System.IO.Directory.CreateDirectory(path);
                        }
                    }
                    else
                    {
                        path = rutaParameter.valorString.Trim();
                        path = path.Trim();
                    }

                    var fileName = Path.GetFileName(file.FileName);
                    //var path = Path.Combine(Server.MapPath("~/App_LocalResources/"), fileName);
                    var pathFinal = Path.Combine(path, fileName);
                    file.SaveAs(pathFinal);
                    ZipFile zip = ZipFile.Read(pathFinal);
                    zip.ExtractAll(path, ExtractExistingFileAction.OverwriteSilently);

                    ViewBag.dbUploaded = true;
                    TempData["error"] = false;
                    TempData["viewMessage"] = "Se ha realizado la actualización con exito!";
                }
            }

            return path;
        }
예제 #3
0
        public ActionResult uploadFile(UploadModel uploadModel, int patronesId)
        {
            Patrone patron = db.Patrones.Find(patronesId);

            String path = this.Upload(uploadModel, patron.direccionArchivo).Trim();
            if (!path.Equals("")) {
                this.uploadAcreditado(path);
                this.uploadAsegurado(path);
            }
            String path2 = path + "\\BACKUP\\";
            path = path + "\\SUA.mdb";
            if (!System.IO.File.Exists(path2))
            {
               System.IO.Directory.CreateDirectory(path2);
            }
            DateTime date = DateTime.Now;
            System.IO.File.Move(path, Path.Combine(path2, "SUA" + date.ToString("ddMMyyyyHHmm") + ".mdb"));
            System.IO.File.Delete(path);

            return View("UploadAcreditados");
        }