コード例 #1
0
        public ActionResult Invoke(FileExtractionViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    string protocol = "\"http://";
                    if (Request.IsSecureConnection)
                    {
                        protocol = "\"https://";
                    }
                    string         url        = protocol + Request.Headers["Host"] + "/forensics/file-extraction/receiver\"";
                    PSRemoting     ps         = new PSRemoting(viewModel.ComputerName, config.FALCON_FORENSICS_USERNAME, config.FALCON_FORENSICS_PASSWORD, config.FALCON_FORENSICS_DOMAIN);
                    FileExtraction extraction = new FileExtraction(ps);

                    Dictionary <string, string> mapper = new Dictionary <string, string>();
                    mapper.Add("{{FilePath}}", "\"" + viewModel.FilePath + "\"");
                    mapper.Add("{{URL}}", url);

                    var model = GetFileMetadata(mapper, extraction);
                    this.UploadFile(mapper, extraction);
                    ViewBag.FileName = viewModel.FilePath.Split('\\').Last();
                    return(PartialView("~/Areas/Forensics/Views/FileExtraction/_DownloadLink.cshtml", model));
                }
                catch (Exception e)
                {
                    ModelState.AddModelError(String.Empty, e.Message);
                }
            }
            List <string> errors = ModelState.Where(x => x.Value.Errors.Count > 0).SelectMany(x => x.Value.Errors).Select(x => x.ErrorMessage).ToList();

            return(PartialView("_ValidationError", errors));
        }
コード例 #2
0
        protected override void OnInitialized(EventArgs e)
        {
            ViewModel = (FileExtractionViewModel)DataContext;

            this.Loaded += FileExtractionWindow_Loaded;

            base.OnInitialized(e);
        }