コード例 #1
0
        public JsonResult SaveWorkIntegrity()
        {
            var DataString = System.Web.HttpContext.Current.Request.Params.Get("JsonMaster").ToString();

            SaveWorkIntegrity saveWorkIntegrity = JsonConvert.DeserializeObject <SaveWorkIntegrity>(DataString);

            List <HttpPostedFile> adjuntoList = null;

            if (System.Web.HttpContext.Current.Request.Files.Count > 0)
            {
                adjuntoList = new List <HttpPostedFile>(System.Web.HttpContext.Current.Request.Files.GetMultiple("dataFile"));
            }


            string IdEmpresa = SessionHelper.GetValueSession(Settings.Session.IdEmpresa).ToString();
            int    IdPais    = Int32.Parse(SessionHelper.GetValueSession(Settings.Session.IdPais).ToString());

            saveWorkIntegrity.IdEmpresa = IdEmpresa;
            saveWorkIntegrity.IdUsuario = SessionHelper.GetUser().ToString();
            saveWorkIntegrity.IdPais    = IdPais;



            var Data = _IworkService.SaveWorkIntegrity(saveWorkIntegrity, adjuntoList);



            if (adjuntoList != null && adjuntoList.Count > 0)
            {
                string FolderGenerate = _IworkService.CreateFolder(TypeFolder.generated, (long)Data.IdIntegridad, 0);
                foreach (HttpPostedFile file in adjuntoList)
                {
                    string routeFile = string.Format("{0}\\{1}", FolderGenerate, $"{rExtension(file.FileName)}_{Data.IdIntegridad}{getExtesion(file.FileName)}");
                    //adjuntoList[0].SaveAs(routeFile);
                    file.SaveAs(routeFile);
                }
            }
            return(Json(new
            {
                Data
            }, JsonRequestBehavior.AllowGet));
        }