예제 #1
0
        public void GetConnections()
        {
            mockServer.ExpectNewRequest()
            .AndExpectUri("https://api.linkedin.com/v1/people/~/connections:(id,first-name,last-name,headline,industry,site-standard-profile-request,public-profile-url,picture-url,summary)?format=json")
            .AndExpectMethod(HttpMethod.GET)
            .AndRespondWith(JsonResource("Connections"), responseHeaders);

#if NET_4_0 || SILVERLIGHT_5
            LinkedInProfiles connections = linkedIn.ConnectionOperations.GetConnectionsAsync().Result;
#else
            LinkedInProfiles connections = linkedIn.ConnectionOperations.GetConnections();
#endif

            Assert.AreEqual(4, connections.Profiles.Count);
            AssertProfile(connections.Profiles[0], "kR0lnX1ll8", "SpringSource Cofounder", "Keith", "Donald", "Computer Software",
                          null, "", null, "http://www.linkedin.com/profile?viewProfile=&key=2526541&authToken=61Sm&authType=name&trk=api*a121026*s129482*", "name:61Sm");
            AssertProfile(connections.Profiles[1], "VRcwcqPCtP", "GM, SpringSource and SVP, Middleware at VMware", "Rod", "Johnson", "Computer Software",
                          null, "", null, "http://www.linkedin.com/profile?viewProfile=&key=210059&authToken=3hU1&authType=name&trk=api*a121026*s129482*", "name:3hU1");
            AssertProfile(connections.Profiles[2], "Ia7uR1OmDB", "Spring and AOP expert; author AspectJ in Action", "Ramnivas", "Laddad", "Computer Software",
                          "http://media.linkedin.com/mpr/mprx/0__gnH4Z-585hJSJSu_M6B4RrHCikUf0pu30CB4Rhqg6KwrUI2fUQXnUNVuSXku4j8CYN9cyYH-JuX", "", null,
                          "http://www.linkedin.com/profile?viewProfile=&key=208994&authToken=P5K9&authType=name&trk=api*a121026*s129482*", "name:P5K9");
            AssertProfile(connections.Profiles[3], "gKEMq4CMdl", "Head of Groovy Development at SpringSource", "Guillaume", "Laforge", "Information Technology and Services",
                          "http://media.linkedin.com/mpr/mprx/0_CV5yQ4-Er7cqa-ZZhJziQU1WpS3v2qZZhRliQU1Miez51K74apvKHRbB-iTE71MN_JbCWpT7SdWe", "", null,
                          "http://www.linkedin.com/profile?viewProfile=&key=822306&authToken=YmIW&authType=name&trk=api*a121026*s129482*", "name:YmIW");
        }
        public void Search()
        {
            mockServer.ExpectNewRequest()
            .AndExpectUri("https://api.linkedin.com/v1/people-search:(people:(id,first-name,last-name,headline,industry,public-profile-url,picture-url,summary,site-standard-profile-request,api-standard-profile-request))?format=json&keywords=SpringSource")
            .AndExpectMethod(HttpMethod.GET)
            .AndRespondWith(JsonResource("Search"), responseHeaders);

            SearchParameters parameters = new SearchParameters();

            parameters.Keywords = "SpringSource";

#if NET_4_0 || SILVERLIGHT_5
            LinkedInProfiles result = linkedIn.ProfileOperations.SearchAsync(parameters).Result;
#else
            LinkedInProfiles result = linkedIn.ProfileOperations.Search(parameters);
#endif

            AssertProfile(result.Profiles[0],
                          "lNJuCn-ejG", "Principal Software Engineer at SpringSource", "Mark", "Pollack", "Computer Software",
                          null, "", "http://www.linkedin.com/pub/mark-pollack/7/17a/b77",
                          "http://www.linkedin.com/profile?viewProfile=&key=21314827&authToken=Vl4x&authType=OUT_OF_NETWORK&trk=api*a159628*s167852*", "OUT_OF_NETWORK:Vl4x");

            Assert.AreEqual(0, result.Start);
            Assert.AreEqual(10, result.Count);
            Assert.AreEqual(110, result.Total);
            Assert.AreEqual(10, result.Profiles.Count);
        }
        public override object Deserialize(JsonValue json, JsonMapper mapper)
        {
            JsonValue        peopleJson = json.ContainsName("people") ? json.GetValue("people") : json;
            LinkedInProfiles profiles   = (LinkedInProfiles)base.Deserialize(peopleJson, mapper);

            profiles.Profiles = mapper.Deserialize <IList <LinkedInProfile> >(peopleJson);
            return(profiles);
        }
예제 #4
0
        public void GetPaginatedConnections()
        {
            mockServer.ExpectNewRequest()
            .AndExpectUri("https://api.linkedin.com/v1/people/~/connections:(id,first-name,last-name,headline,industry,site-standard-profile-request,public-profile-url,picture-url,summary)?format=json&start=0&count=4")
            .AndExpectMethod(HttpMethod.GET)
            .AndRespondWith(JsonResource("Connections"), responseHeaders);

#if NET_4_0 || SILVERLIGHT_5
            LinkedInProfiles connections = linkedIn.ConnectionOperations.GetConnectionsAsync(0, 4).Result;
#else
            LinkedInProfiles connections = linkedIn.ConnectionOperations.GetConnections(0, 4);
#endif

            Assert.AreEqual(0, connections.Start);
            Assert.AreEqual(4, connections.Count);
            Assert.AreEqual(243, connections.Total);
            Assert.AreEqual(4, connections.Profiles.Count);
        }
        public async Task <IActionResult> Upload(/*CandidateDetails request*/ CandidateViewModel request)
        {
            #region MyRegion
            //        // do other validations on your model as needed
            //        if (request.Resume.FilePath != null)
            //        {
            //            var uniqueFileName = GetUniqueFileName(request.Resume.FilePath);
            //            var uploads = Path.Combine(hostingEnvironment.WebRootPath, "uploads");
            //            var filePath = Path.Combine(uploads, uniqueFileName);
            //            request.resu.CopyTo(new FileStream(filePath, FileMode.Create));

            //            //to do : Save uniqueFileName  to your db table
            //        }
            //        // to do  : Return something
            //        return RedirectToAction("Index", "Home");
            //    }
            //    private string GetUniqueFileName(string fileName)
            //    {
            //        fileName = Path.GetFileName(fileName);
            //        return Path.GetFileNameWithoutExtension(fileName)
            //                  + "_"
            //                  + Guid.NewGuid().ToString().Substring(0, 4)
            //                  + Path.GetExtension(fileName);
            //    }
            //}
            #endregion

            if (ModelState.IsValid)
            {
                //_context.Add(request);
                //await _context.SaveChangesAsync();
                ViewData["success"] = true;
                TempData["success"] = true;

                var Upload = request.Document;

                var uniqueFileName = GetUniqueFileName(Upload.FileName);
                var uploads        = Path.Combine(hostingEnvironment.WebRootPath, "uploads");
                var filePath       = Path.Combine(uploads, uniqueFileName);

                //var file = Path.Combine(_environment.ContentRootPath, "uploads", Upload.FileName);
                using (var fileStream = new FileStream(filePath, FileMode.Create))
                {
                    await Upload.CopyToAsync(fileStream);
                }

                try
                {
                    using (var transaction = _context.Database.BeginTransaction())
                    {
                        var resume = new Resume()
                        {
                            FilePath = filePath
                        };
                        _context.Resume.Add(resume);

                        _context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT Resume ON;");
                        _context.SaveChanges();
                        _context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT Resume OFF;");
                        transaction.Commit();

                        if (!string.IsNullOrWhiteSpace(request.URL))
                        {
                            var link = new LinkedInProfiles()
                            {
                                ProfilrUrl = request.URL
                            };
                            _context.LinkedInProfiles.Add(link);
                        }
                        _context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT LinkedInProfiles ON;");
                        _context.SaveChanges();
                        _context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT LinkedInProfiles OFF;");
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

                var companyName = _context.CompanyDetails
                                  .Where(s => s.CompanyId == request.jobDetails.Compnay.CompanyId)
                                  .Select(s => s.CompanyName).FirstOrDefault();

                #region Old code
                //MailMessage msg = new MailMessage("*****@*****.**", "*****@*****.**"); // enter from email and to email

                //msg.Body = "<html><head><head><body>you got an email</body></html>"; //enter body here
                //msg.Subject = "strSubject"; // enter subject line here

                //msg.IsBodyHtml = true;
                //Attachment att = new Attachment(filePath);
                //msg.Attachments.Add(att);

                //SmtpClient cli = new SmtpClient("111.111.111.111", 25);
                //cli.Credentials = new NetworkCredential("nnnnnnn", "yyyyyy");
                //cli.Send(msg);
                //msg.Dispose();
                #endregion

                #region new code email

                //send email
                using (MailMessage mm = new MailMessage("*****@*****.**", "*****@*****.**")) // fromId, ToId
                {
                    mm.Subject = "IOT Waterloo Candidate Detail (Job Request)";
                    mm.Body    = request.FirstName + " " + request.LastName + " requesting for a job from " +
                                 companyName + "and here are the detials.";

                    Attachment attachment = new Attachment(Upload.OpenReadStream(), uniqueFileName);

                    mm.Attachments.Add(attachment);
                    mm.IsBodyHtml = true;

                    SmtpClient smtp = new SmtpClient();
                    smtp.Host      = "smtp.gmail.com";
                    smtp.EnableSsl = true;

                    NetworkCredential netwoekCred = new NetworkCredential("*****@*****.**", "iot123456$");
                    smtp.UseDefaultCredentials = true;
                    smtp.Credentials           = netwoekCred;
                    smtp.Port = 587;
                    smtp.Send(mm);
                }

                #endregion
            }

            //return Ok(new { Status = "Success" }); JobDetail/Details/8
            return(RedirectToAction("Details", "Talent", new { id = request.jobDetails.JobId }));
        }