private static void DownloadAndCreateFolder(Entry entry, string directoryName) { l_entryFolder = Path.Combine(m_saveFolder, directoryName, entry.EntryId.ToString() + " - " + entry.Email); if (!Directory.Exists(l_entryFolder)) { Directory.CreateDirectory(l_entryFolder); } StreamWriter l_writer = File.CreateText(Path.Combine(l_entryFolder, entry.EntryId + " - " + entry.Email + ".txt")); WriteEntryToFile(l_writer, entry); l_writer.Close(); string l_letterOfAttestationLink = GetDocumentLink(entry.LetterOfAttestationLink); string l_additionalDocument1 = GetDocumentLink(entry.AdditionalDocument1); string l_additionalDocument2 = GetDocumentLink(entry.AdditionalDocument2); string l_additionalDocument3 = GetDocumentLink(entry.AdditionalDocument3); string l_additionalDocument4 = GetDocumentLink(entry.AdditionalDocument4); WebClient l_Client = new WebClient(); DownloadDocument(l_letterOfAttestationLink, l_Client, "LetterOfAttestation"); DownloadDocument(l_additionalDocument1, l_Client, "AdditionalDocument1"); DownloadDocument(l_additionalDocument2, l_Client, "AdditionalDocument2"); DownloadDocument(l_additionalDocument3, l_Client, "AdditionalDocument3"); DownloadDocument(l_additionalDocument4, l_Client, "AdditionalDocument4"); }
private static Entry MergeEntries(Entry entry, Entry existingEntry) { if (entry.CompleteSubmission==1) { if (existingEntry.CompleteSubmission==0) { return entry; } } if (!String.IsNullOrWhiteSpace(entry.LetterOfAttestationLink)) { if (String.IsNullOrWhiteSpace(existingEntry.LetterOfAttestationLink)) { return entry; } } Entry l_mergedEntry = AutoMapper.Mapper.Map(entry, existingEntry); return l_mergedEntry; }
private static void WriteEntryToFile(StreamWriter writer, Entry entry) { writer.WriteLine("Name:" + entry.Name); writer.WriteLine("Father's Name: " + entry.FathersName); writer.WriteLine("Mother's Name: " + entry.MothersName); writer.WriteLine("Date of Birth: " + entry.DateOfBirth); writer.WriteLine("Email: " + entry.Email); writer.WriteLine("Phone: " + entry.Phone); writer.WriteLine("Address:"); writer.Write(GetMailingAddress(entry)); writer.WriteLine("Nagarathar Village: " + entry.NagaratharVillage); writer.WriteLine("Degree: " + entry.Degree); writer.WriteLine("Specialization: " + entry.Specialization); writer.WriteLine("Year of Study: " + entry.YearOfStudy); writer.WriteLine("College Name: " + entry.College); writer.WriteLine("College Address:"); writer.Write(GetCollegeAddress(entry)); writer.WriteLine("Annual Family Income: " + entry.AnnualFamilyIncome); writer.WriteLine("Extra Curricular Activities: " + entry.ExtraCurricularActivities); writer.WriteLine("Additional Comments: " + entry.AdditionalComments); writer.WriteLine("Submitted on: " + entry.DateCreated.ToShortDateString()); }
private static string GetMailingAddress(Entry entry) { StringBuilder sb = new StringBuilder(); if(!String.IsNullOrWhiteSpace(entry.AddressLine1)) sb.AppendLine(entry.AddressLine1); if (!String.IsNullOrWhiteSpace(entry.AddressLine2)) sb.AppendLine(entry.AddressLine2); sb.AppendLine(entry.City + ", " + entry.State + "-" + entry.ZipCode); if (!String.IsNullOrWhiteSpace(entry.Country)) sb.AppendLine(entry.Country); return sb.ToString(); }