Esempio n. 1
0
        public ContentResult Generate([System.Web.Http.FromBody] string nameTemplate, string json)
        {
            FillDocxController fillDocx = new FillDocxController();

            InfoVuln.GetInstance().ProcessDocx(nameTemplate, json);

            var timeStamp = InfoVuln.GetInstance().TimeStamp;

            if (fillDocx.IsExistFile(timeStamp + ".Report.docx").IsSuccessStatusCode)
            {
                return(base.Content($"<a href='/api/filldocx/download?filename={timeStamp}.Report.docx'>{timeStamp}.Report.docx</a>", "text/html"));
            }
            //$"/api/filldocx/download?filename={helper.TimeStamp}.Report.docx";
            else
            {
                return(base.Content("Not Found File"));
            }

            //string fullName = Server.MapPath("~/Render/" + helper.TimeStamp + ".Report.docx");

            //byte[] fileBytes = GetFile(fullName);
            //return File(
            //    fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, Server.MapPath("~/Render/" + helper.TimeStamp + ".Report.docx"));



            //if (fillDocx.IsExistFile(helper.TimeStamp + ".Report.docx").StatusCode == System.Net.HttpStatusCode.OK)
            //    return fillDocx.Download(helper.TimeStamp + ".Report.docx");
            //else return new HttpResponseMessage(System.Net.HttpStatusCode.NotFound);
        }
        public HttpResponseMessage Post([FromBody] InfoVuln infoVuln)
        {
            //var res = new HttpResponseMessage(System.Net.HttpStatusCode.OK);
            try
            {
                helper.MainProcess(infoVuln);

                //string path = $"{CurrentDirectory}Renders/{helper.timeStamp}.Report.docx";
                //ITemplateDocument docc = Configuration.Factory.Open(path);
                //docc.Process(infoVuln);

                //string filename = $"{helper.CurrentDirectory}/Renders/{helper.timeStamp}.Report.docx";
                //var filebytes = System.IO.File.ReadAllBytes(filename);

                //var filememoryStream = new MemoryStream(filebytes);
                //res.Content = new StreamContent(filememoryStream);

                //var header = res.Content.Headers;
                //header.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment");
                //header.ContentDisposition.FileName = filename;
                //header.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/docx");
                //header.ContentLength = filememoryStream.Length;
                //return res;
                //DeleteDir();
                return(IsExistFile($"{helper.timeStamp}.Report.docx"));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(new HttpResponseMessage()
                {
                    StatusCode = System.Net.HttpStatusCode.NotFound
                });
            }
        }
Esempio n. 3
0
        public ActionResult UploadFile(HttpPostedFileBase files)
        {
            string ext = Path.GetExtension(files.FileName);

            if (ext == ".json")
            {
                FileUpload        model   = new FileUpload();
                List <FileUpload> list    = new List <FileUpload>();
                DataTable         dtFiles = GetFileDetails();
                foreach (DataRow dr in dtFiles.Rows)
                {
                    list.Add(new FileUpload
                    {
                        FileId   = @dr["Id"].ToString(),
                        FileName = @dr["FILENAME"].ToString(),
                        FileUrl  = @dr["FILEURL"].ToString(),
                        JsonName = @dr["JSONNAME"].ToString(),
                        JsonUrl  = @dr["JSONURL"].ToString()
                    });
                }
                model.FileList = list;

                if (files != null)
                {
                    //var Extension = Path.GetExtension(files.FileName);
                    var timeStamp = InfoVuln.GetInstance().TimeStamp;
                    if (!Directory.Exists(Server.MapPath($"~/UploadedFiles/{timeStamp}")))
                    {
                        Directory.CreateDirectory(Server.MapPath($"~/UploadedFiles/{timeStamp}"));
                    }

                    string path = Path.Combine(Server.MapPath($"~/UploadedFiles/{timeStamp}"), files.FileName);
                    model.FileUrl = Url.Content(Path.Combine($"~/UploadedFiles/{timeStamp}/", files.FileName));

                    model.FileName = files.FileName;

                    if (SaveFile(model))
                    {
                        files.SaveAs(path);
                        TempData["AlertMessage"] = "Uploaded Successfully !!";
                        return(RedirectToAction("Index", "Template"));
                    }
                    else
                    {
                        ModelState.AddModelError("", "Error In Add File. Please Try Again !!!");
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Please Choose Correct File Type !!");
                    return(View(model));
                }
            }

            return(RedirectToAction("Index", "Template"));
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            InfoVuln info = new InfoVuln();

            info.TimeStamp = info.GetTimestamp(DateTime.Now);

            string rootPath = AppDomain.CurrentDomain.BaseDirectory;

            if (!Directory.Exists($"{rootPath}Static/{info.TimeStamp}"))
            {
                Directory.CreateDirectory($"{rootPath}Static/{info.TimeStamp}");
            }

            info.LoadJson();
        }
Esempio n. 5
0
 public HttpResponseMessage Generate([FromBody] string nameTemplate, string json)
 {
     try
     {
         InfoVuln.GetInstance().ProcessDocx(nameTemplate, json);
         return(IsExistFile($"{InfoVuln.GetInstance().TimeStamp}.Report.docx"));
     }
     catch (Exception)
     {
         //Console.WriteLine(ex.Message);
         return(new HttpResponseMessage()
         {
             StatusCode = HttpStatusCode.NotFound
         });
     }
 }
 public FillDocxController(IWebHostEnvironment environment)
 {
     _rootPath = environment;
     info      = new InfoVuln();
 }