/// <summary> /// Parses the company details file. /// </summary> /// <returns></returns> /// <exception cref="Exception"> /// File path is not set /// or /// Columns to read not set /// </exception> public bool ParseCompanyDetailsFile() { var counter = 0; if (FileName == null) { throw new Exception("File path is not set"); } if (Columns.Length == 0) { throw new Exception("Columns to read not set"); } SetIdentifierFields(out string symbol, out string ipoYear, out string sector, out string industry, out string name); using (var reader = File.OpenText(FileName)) { var csv = new CsvReader(reader); ConfigureReader(csv); while (csv.Read()) { ExtractDataFromRecord(symbol, ipoYear, sector, industry, name, csv, out string securitySymbol, out string securitySector, out string securityIndustry, out int securityIPOYear, out string securityName); if (string.IsNullOrWhiteSpace(securitySector) || string.IsNullOrWhiteSpace(securityIndustry) || securitySector.Equals("n/a") || securityIndustry.Equals("n/a")) { continue; } var cd = CompanyDetails.FirstOrDefault(r => r.Symbol.Equals(securitySymbol)); if (cd == null) { cd = new CompanyDetail { Symbol = securitySymbol, IPOyear = securityIPOYear, Sector = securitySector, Industry = securityIndustry, SecurityName = securityName }; CompanyDetails.Add(cd); counter++; } else { cd.IPOyear = securityIPOYear; cd.Sector = securitySector; cd.Industry = securityIndustry; } } } Console.WriteLine($"New records count {counter}"); return(true); }
/// <summary> /// Parses the security listing file. /// </summary> /// <returns></returns> /// <exception cref="Exception"> /// File path is not set /// or /// Columns to read not set /// </exception> public bool ParseSecurityListingFile() { if (FileName == null) { throw new Exception("File path is not set"); } if (Columns.Length == 0) { throw new Exception("Columns to read not set"); } var symbol = ""; var securityName = ""; SetIdentifierFields(ref symbol, ref securityName); using (var reader = File.OpenText(FileName)) { var csv = new CsvReader(reader); ConfigureReader(csv); while (csv.Read()) { CompanyDetail newRecord = BuildCompanyDetails(csv, symbol, securityName); newRecord.IsExTrdFund = IsETF == true ? IsETF : newRecord.IsExTrdFund; var oldRecord = CompanyDetails.Find(cd => cd.Symbol.Equals(newRecord)); if (oldRecord != null) { oldRecord.Industry = string.IsNullOrWhiteSpace(newRecord.Industry) ? oldRecord.Industry : newRecord.Industry; oldRecord.IPOyear = newRecord.IPOyear == 0 ? oldRecord.IPOyear : newRecord.IPOyear; oldRecord.IsExTrdFund = newRecord.IsExTrdFund == false ? oldRecord.IsExTrdFund : newRecord.IsExTrdFund; oldRecord.IsMutualFund = newRecord.IsMutualFund == false ? oldRecord.IsMutualFund : newRecord.IsMutualFund; oldRecord.Sector = string.IsNullOrWhiteSpace(newRecord.Sector) ? oldRecord.Sector : newRecord.Sector; } else { CompanyDetails.Add(newRecord); } } } return(true); }
public async override void Init(object initData) { base.Init(initData); if (initData is Tuple <bool, bool, object> ) { if (((Tuple <bool, bool, object>)initData).Item1) { IsSegmentVisible = ((Tuple <bool, bool, object>)initData).Item1; } if (((Tuple <bool, bool, object>)initData).Item2) { IsContactTab = ((Tuple <bool, bool, object>)initData).Item2; } if (((Tuple <bool, bool, object>)initData).Item3 == null) { Title = $"{AppResources.New} {AppResources.Contact}"; IsNewCreation = true; } else { Title = $"{AppResources.Contact}"; IsNewCreation = false; } IsProfessional = IsSegmentVisible; //mockdata CompanyDetails.Add(new CompanyDynamicEntry() { Placeholder = "Adresse postale" }); CompanyDetails.Add(new CompanyDynamicEntry() { Placeholder = "Email", Keyboard = Keyboard.Email }); CompanyDetails.Add(new CompanyDynamicEntry() { Placeholder = "Tel. Bureau", Keyboard = Keyboard.Telephone }); CompanyDetails.Add(new CompanyDynamicEntry() { Placeholder = "Tel. Mobile", Keyboard = Keyboard.Telephone }); CompanyDetails.Add(new CompanyDynamicEntry() { Placeholder = "Web", Keyboard = Keyboard.Url }); CompanyDetails.Add(new CompanyDynamicEntry() { Placeholder = "Siret" }); CompanyDetails.Add(new CompanyDynamicEntry() { Placeholder = "Statut juridique" }); CompanyDetails.Add(new CompanyDynamicEntry() { Placeholder = "APE" }); CompanyDetails.Add(new CompanyDynamicEntry() { Placeholder = "APE libéllé" }); CompanyDetails.Add(new CompanyDynamicEntry() { Placeholder = "APE sous classe" }); CompanyDetails.Add(new CompanyDynamicEntry() { Placeholder = "Effectifs" }); // if (!IsNewCreation) { if (((Tuple <bool, bool, object>)initData).Item3 is ContactModel) { ExistingContact = (((Tuple <bool, bool, object>)initData).Item3 as ContactModel).Contact; FirstName = ExistingContact.Firstname; LastName = ExistingContact.Lastname; Email = ExistingContact.Email; Company = ExistingContact.CompanyName; Function = ExistingContact.JobTitle; Mobile = ExistingContact.Mobile?.Split('-')?.Last(); Rating = Convert.ToInt32(ExistingContact.Weight); Qualification = ExistingContact.Qualification; Source = ExistingContact.CollectSourceName; ActiveCheckIn = ExistingContact.AllowCheckin; if (!string.IsNullOrEmpty(ExistingContact.CompanyId)) { CompanyObject = await StoreManager.CompanyStore.GetItemAsync(ExistingContact.CompanyId); } } else { CompanyObject = (((Tuple <bool, bool, object>)initData).Item3 as Company); } if (CompanyObject != null) { var obj = CompanyObject as Company; CompanyDetails[0].Text = obj.Address; // Address CompanyDetails[1].Text = obj.Email; CompanyDetails[2].Text = obj.Phone; CompanyDetails[3].Text = obj.Mobile; CompanyDetails[4].Text = obj.Web; CompanyDetails[5].Text = obj.Siret; CompanyDetails[6].Text = obj.StatutJuridique; CompanyDetails[7].Text = obj.Ape; CompanyDetails[8].Text = obj.ApeLibelle; CompanyDetails[9].Text = obj.ApeSousClasse; CompanyDetails[10].Text = obj.Effectif; } } GetAdditionalData(); } }