Ejemplo n.º 1
0
        /// <summary>
        /// Parses a batch of resumes
        /// </summary>
        /// <param name="apiClient">The API client to use to parse the files</param>
        /// <param name="parseOptions">Any parsing/indexing options</param>
        /// <param name="rules">
        /// The rules that should be applied to whatever files are found prior to parsing.
        /// This is important to reduce the number of invalid parse API calls and reduce parsing costs.
        /// </param>
        /// <param name="directory">The directory containing the files to be parsed</param>
        /// <param name="searchOption"></param>
        /// <param name="successCallback">A callback for when a file is parsed successfully</param>
        /// <param name="partialSuccessCallback">A callback for when some error happened during/after parsing, but there is still usable data in the response</param>
        /// <param name="errorCallback">A callback for when an error occurred when parsing the file, and there is no usable data</param>
        /// <param name="generateDocumentIdFn">A callback so you can specify a DocumentId for each file that is parsed</param>
        /// <exception cref="SovrenInvalidBatchException">Thrown when the directory provided does not meet the <see cref="BatchParsingRules"/></exception>
        public static async Task ParseResumes(
            SovrenClient apiClient,
            ParseOptions parseOptions,
            BatchParsingRules rules,
            string directory,
            SearchOption searchOption,
            Func <ResumeBatchSuccessResult, Task> successCallback,
            Func <ResumeBatchPartialSuccessResult, Task> partialSuccessCallback,
            Func <BatchErrorResult, Task> errorCallback,
            Func <string, string> generateDocumentIdFn = null)
        {
            if (apiClient == null)
            {
                throw new ArgumentNullException(nameof(apiClient));
            }

            IEnumerable <string> files = GetFiles(rules, directory, searchOption);

            //process the batch serially, since multi-threading could cause the customer to violate the AUP accidentally
            foreach (string file in files)
            {
                Document doc   = new Document(file);
                string   docId = generateDocumentIdFn == null?Guid.NewGuid().ToString() : generateDocumentIdFn(file);

                try
                {
                    //set document id if we plan to index these documents
                    if (parseOptions?.IndexingOptions != null)
                    {
                        parseOptions.IndexingOptions.DocumentId = docId;
                    }

                    ParseRequest        request  = new ParseRequest(doc, parseOptions);
                    ParseResumeResponse response = await apiClient.ParseResume(request);

                    if (successCallback != null)
                    {
                        await successCallback(new ResumeBatchSuccessResult(file, docId, response));
                    }
                }
                catch (SovrenUsableResumeException e)
                {
                    //this happens when something wasn't 100% successful, but there still might be usable data
                    if (partialSuccessCallback != null)
                    {
                        await partialSuccessCallback(new ResumeBatchPartialSuccessResult(file, docId, e));
                    }
                }
                catch (SovrenException e)
                {
                    //this happens where there is no usable data
                    if (errorCallback != null)
                    {
                        await errorCallback(new BatchErrorResult(file, docId, e));
                    }
                }
            }
        }
 /// <summary>Snippet for ParseResume</summary>
 public void ParseResume()
 {
     // Snippet: ParseResume(ProjectName,ByteString,CallSettings)
     // Create client
     ResumeServiceClient resumeServiceClient = ResumeServiceClient.Create();
     // Initialize request argument(s)
     ProjectName parent = new ProjectName("[PROJECT]");
     ByteString  resume = ByteString.Empty;
     // Make the request
     ParseResumeResponse response = resumeServiceClient.ParseResume(parent, resume);
     // End snippet
 }
 /// <summary>Snippet for ParseResume</summary>
 public void ParseResume_RequestObject()
 {
     // Snippet: ParseResume(ParseResumeRequest,CallSettings)
     // Create client
     ResumeServiceClient resumeServiceClient = ResumeServiceClient.Create();
     // Initialize request argument(s)
     ParseResumeRequest request = new ParseResumeRequest
     {
         ParentAsProjectName = new ProjectName("[PROJECT]"),
         Resume = ByteString.Empty,
     };
     // Make the request
     ParseResumeResponse response = resumeServiceClient.ParseResume(request);
     // End snippet
 }
        /// <summary>Snippet for ParseResumeAsync</summary>
        public async Task ParseResumeAsync()
        {
            // Snippet: ParseResumeAsync(ProjectName,ByteString,CallSettings)
            // Additional: ParseResumeAsync(ProjectName,ByteString,CancellationToken)
            // Create client
            ResumeServiceClient resumeServiceClient = await ResumeServiceClient.CreateAsync();

            // Initialize request argument(s)
            ProjectName parent = new ProjectName("[PROJECT]");
            ByteString  resume = ByteString.Empty;
            // Make the request
            ParseResumeResponse response = await resumeServiceClient.ParseResumeAsync(parent, resume);

            // End snippet
        }
        /// <summary>Snippet for ParseResumeAsync</summary>
        public async Task ParseResumeAsync_RequestObject()
        {
            // Snippet: ParseResumeAsync(ParseResumeRequest,CallSettings)
            // Additional: ParseResumeAsync(ParseResumeRequest,CancellationToken)
            // Create client
            ResumeServiceClient resumeServiceClient = await ResumeServiceClient.CreateAsync();

            // Initialize request argument(s)
            ParseResumeRequest request = new ParseResumeRequest
            {
                ParentAsProjectName = new ProjectName("[PROJECT]"),
                Resume = ByteString.Empty,
            };
            // Make the request
            ParseResumeResponse response = await resumeServiceClient.ParseResumeAsync(request);

            // End snippet
        }
Ejemplo n.º 6
0
        public void TestNullTelephones()
        {
            ParseResumeResponse fakeResponse = new ParseResumeResponse();

            fakeResponse.Value = new ParseResumeResponseValue
            {
#pragma warning disable CS0618 // Type or member is obsolete
                ResumeData = new ParsedResume
                {
                    ContactInformation = new ContactInformation
                    {
                        Telephones = null
                    }
                }
#pragma warning restore CS0618 // Type or member is obsolete
            };

            Assert.DoesNotThrow(() => { fakeResponse.EasyAccess().GetPhoneNumbers(); });
            IEnumerable <string> phones = fakeResponse.EasyAccess().GetPhoneNumbers();
            Assert.IsNull(phones);
        }
        public void ParseResume2()
        {
            Mock <ResumeService.ResumeServiceClient> mockGrpcClient = new Mock <ResumeService.ResumeServiceClient>(MockBehavior.Strict);
            ParseResumeRequest request = new ParseResumeRequest
            {
                ParentAsProjectName = new ProjectName("[PROJECT]"),
                Resume = ByteString.CopyFromUtf8("45"),
            };
            ParseResumeResponse expectedResponse = new ParseResumeResponse
            {
                RawText = "rawText503586532",
            };

            mockGrpcClient.Setup(x => x.ParseResume(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            ResumeServiceClient client   = new ResumeServiceClientImpl(mockGrpcClient.Object, null);
            ParseResumeResponse response = client.ParseResume(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public async Task ParseResumeAsync2()
        {
            Mock <ResumeService.ResumeServiceClient> mockGrpcClient = new Mock <ResumeService.ResumeServiceClient>(MockBehavior.Strict);
            ParseResumeRequest request = new ParseResumeRequest
            {
                ParentAsProjectName = new ProjectName("[PROJECT]"),
                Resume = ByteString.CopyFromUtf8("45"),
            };
            ParseResumeResponse expectedResponse = new ParseResumeResponse
            {
                RawText = "rawText503586532",
            };

            mockGrpcClient.Setup(x => x.ParseResumeAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <ParseResumeResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            ResumeServiceClient client   = new ResumeServiceClientImpl(mockGrpcClient.Object, null);
            ParseResumeResponse response = await client.ParseResumeAsync(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Ejemplo n.º 9
0
        public static void Main(string[] args)
        {
            byte[] fileBytes = File.ReadAllBytes(@"C:\Users\welly\AppData\Roaming\Skype\My Skype Received Files\CV.pdf");

            // Optionally, compress the bytes to reduce network delays
            //fileBytes = Gzip(fileBytes);
            //var endpointConfiguration = new ParsingServiceSoapClient.EndpointConfiguration();

            var client = new ParsingServiceSoapClient();

            ParseResumeRequest request = new ParseResumeRequest
            {
                // Required parameters
                AccountId  = AccountId,
                ServiceKey = ServiceKey,
                FileBytes  = fileBytes,

                // Optional parameters
                //Configuration = "", // Paste string from Parser Config String Builder.xls spreadsheet
                //OutputHtml = true, // Convert to HTML
                //OutputRtf = true, // Convert to RTF
                //OutputWordXml = true, // Convert to WordXml
                //RevisionDate = "2011-05-15", // Parse assuming a historical date for "current"
            };

            // Perform the parse. The first request will be slow due to WCF initializing
            // the connection and SOAP/XML serialization, but subsequent calls will be fast.
            ParseResumeResponse response = client.ParseResumeAsync(request).Result;

            // Display the results
            Console.OutputEncoding = Encoding.UTF8;
            Console.WriteLine("Code=" + response.Code);
            Console.WriteLine("SubCode=" + response.SubCode);
            Console.WriteLine("Message=" + response.Message);
            Console.WriteLine("TextCode=" + response.TextCode);
            Console.WriteLine("CreditsRemaining=" + response.CreditsRemaining);
            Console.WriteLine("-----");
            Console.WriteLine(response.Xml);
        }
 internal SovrenIndexResumeException(RestResponse response, ApiResponseInfoLite errorInfo, string transactionId, ParseResumeResponse parseResponse)
     : base(response, errorInfo, transactionId, parseResponse)
 {
 }
 internal SovrenUsableResumeException(RestResponse response, ApiResponseInfoLite errorInfo, string transactionId, ParseResumeResponse parseResponse)
     : base(null, response, errorInfo, transactionId)
 {
     Response = parseResponse;
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Use this method to get easy access to most of the commonly-used data inside a parse response.
 /// <br/>For example <code>response.EasyAccess().GetCandidateName()</code>.
 /// <br/>This is just an alternative to writing your own logic to process the information provided in the response.
 /// </summary>
 public static ParseResumeResponseExtensions EasyAccess(this ParseResumeResponse response)
 {
     return(new ParseResumeResponseExtensions(response));
 }
Ejemplo n.º 13
0
 internal ParseResumeResponseExtensions(ParseResumeResponse response)
 {
     Response = response;
 }
Ejemplo n.º 14
0
 internal ResumeBatchSuccessResult(string file, string docId, ParseResumeResponse response)
     : base(file, docId)
 {
     Response = response;
 }
 internal SovrenProfessionNormalizationResumeException(RestResponse response, ApiResponseInfoLite errorInfo, string transactionId, ParseResumeResponse parseResponse)
     : base(response, errorInfo, transactionId, parseResponse)
 {
 }