Exemple #1
0
        public virtual ActionResult UploadFile()
        {
            HttpPostedFileBase myFile = Request.Files["MyFile"];

            string message = "File upload failed";

            if (myFile != null && myFile.ContentLength != 0)
            {
                string pathForSaving = Server.MapPath("~/Uploads");
                if (this.CreateFolderIfNeeded(pathForSaving))
                {
                    try
                    {
                        myFile.SaveAs(Path.Combine(pathForSaving, myFile.FileName));

                        ResumeParser rp = new ResumeParser();
                        message = rp.Converter(Path.Combine(pathForSaving, myFile.FileName), Path.GetExtension(myFile.FileName));
                    }
                    catch (Exception ex)
                    {
                        message = string.Format("File upload failed: {0}", ex.Message);
                    }
                }
            }
            return(Content(message));
        }
Exemple #2
0
        private static string ParseDataFromS3(Stream stream, string key)
        {
            string[]     lines        = FileParser.ExtractAllLinesFromS3(stream, key);
            ResumeParser resumeParser = new ResumeParser(lines);
            Applicant    applicant    = resumeParser.Parse();

            applicant.GenerateID();
            return(applicant.ToString());
        }
Exemple #3
0
        private static void Main(string[] args)
        {
            log4net.Config.XmlConfigurator.Configure(new FileInfo(AppDomain.CurrentDomain.BaseDirectory + "log4net.config"));

            ResumeParser parser = new ResumeParser();

            parser.Start();
            Console.ReadKey();
        }
Exemple #4
0
        // Action Listener for the "Parse" button on the main page
        // Takes in the input uploaded file and the text from the
        // position and location text boxes and outputs a display
        // of the service through the resume parser and job finder
        protected void runButton_Click(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder();

            blob = new BlobClient(
                "",
                "stringparser",
                "input.pdf");

            mainLabel.Text    = "This might take a while";
            mainLabel.Visible = true;

            if (Uploader.HasFile)
            {
                try
                {
                    string fileName    = Uploader.FileName;
                    byte[] fileContent = Uploader.FileBytes;

                    //use file content to make a hash value
                    string hash = makeHash(fileContent);

                    //check the db to see if the hash value exists
                    bool fileExists = checkHashValue(hash);

                    //if the file doesnt exist on the db, upload to the blob container and do a full resume parse
                    if (fileExists == false)
                    {
                        using (var stream = new MemoryStream(fileContent, writable: false))
                        {
                            blob.Upload(stream, true);
                        }

                        resumeparser = new ResumeParser(fileName);
                        addHashToDb(hash, resumeparser.fileID);
                    }

                    //else if the file does exist, dont upload to the blob and call on secondary resumeParser constructor
                    else if (fileExists == true)
                    {
                        string affID = getAffindaID(hash);
                        resumeparser = new ResumeParser(fileName, affID);
                    }

                    mainLabel.Text = $"Successfully parsed file: {fileName}";

                    ParserSectionLabel.Font.Size = 30;
                    ParserSectionLabel.Visible   = true;
                    ParserSectionLabel.Font.Bold = true;

                    // Build tables displaying the output
                    // of the Affinda Resume Parser JSON
                    // in distinct sections
                    BuildParserDisplay();

                    // Execute extra resume parser and
                    // job finder functionality if the
                    // position for the resume is specified
                    if (positionText.Text != "")
                    {
                        CompareHeaders();

                        if (!fileExists)
                        {
                            StoreResumeHeaders();
                        }

                        FindJobs();
                    }
                }

                catch (Exception ex)
                {
                    sb.Append("<br/> Error <br/>");
                    sb.AppendFormat("Unable to save file <br/> {0}", ex.Message);
                    mainLabel.Text    = sb.ToString();
                    mainLabel.Visible = true;
                }
            }

            else
            {
                mainLabel.Text    = "No file uploaded";
                mainLabel.Visible = true;
            }
        }
Exemple #5
0
        public XParserService()
        {
            InitializeComponent();

            _parser = new ResumeParser();
        }