public List <AV_Sector> GetSector(string Filter, Int64 SiteId, string SiteCode, Int64 NetworkModeId, Int64 BandId, Int64 CarrierId, Int64 ScopeId) { List <AV_Sector> secList = new List <AV_Sector>(); AV_SectorDL sectorDL = new AV_SectorDL(); var data = sectorDL.Get("GetSectors", SiteId.ToString(), NetworkModeId.ToString(), BandId.ToString(), CarrierId.ToString(), ScopeId.ToString()); foreach (DataRow item in data.Rows) { AV_Sector s = new AV_Sector(); //s.Id = Convert.ToInt64(item["SectorId"].ToString()); s.SectorCode = item["SectorCode"].ToString(); s.sectorColor = item["sectorColor"].ToString(); s.BeamWidth = Convert.ToInt32(item["BeamWidth"].ToString()); s.Azimuth = Convert.ToInt32(item["Azimuth"].ToString()); s.Latitude = Convert.ToDouble(item["SectorLatitude"].ToString()); s.Longitude = Convert.ToDouble(item["SectorLongitude"].ToString()); s.PCI = Convert.ToInt32(item["PCI"].ToString()); secList.Add(s); } return(secList); }
public HttpResponseMessage Fileupload() { var random = new Random(); //var color = String.Format("#{0:X6}", random.Next(0x1000000)); //RepositoryContext rep = new RepositoryContext(); HttpResponseMessage response = new HttpResponseMessage(); List <string> sitecode = new List <string>(); List <AV_Site> listLatLong = new List <AV_Site>(); List <AV_Sector> secList = new List <AV_Sector>(); var httpRequest = HttpContext.Current.Request; DataTable FileRecord = new DataTable(); //string filePath = null; //string docPath = null; if (httpRequest.Files.Count > 0) { foreach (string file in httpRequest.Files) { var postedFile = httpRequest.Files[file]; Stream stream = httpRequest.Files[file].InputStream; using (CsvReader csvReader = new CsvReader(new StreamReader(stream), true)) { FileRecord.Load(csvReader); } //filePath = HttpContext.Current.Server.MapPath("~/files/" + postedFile.FileName); //postedFile.SaveAs(filePath); } //docPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, filePath); //var result = rep.GetDataTableFromCsv(docPath, true); foreach (DataRow item in FileRecord.Rows) { AV_Site lat = new AV_Site(); lat.Latitude = Convert.ToDouble(item["siteLatitude"].ToString()); lat.Longitude = Convert.ToDouble(item["siteLongitude"].ToString()); lat.SiteCode = item["siteCode"].ToString(); listLatLong.Add(lat); sitecode.Add(item["siteCode"].ToString()); AV_Sector s = new AV_Sector(); //s.Id = Convert.ToInt64(item["SectorId"].ToString()); s.SectorCode = item["siteCode"].ToString(); //s.sectorColor = "red"; s.BeamWidth = Convert.ToInt32(item["BeamWidth"].ToString()); s.Azimuth = Convert.ToInt32(item["Azimuth"].ToString()); s.Latitude = Convert.ToDouble(item["siteLatitude"].ToString()); s.Longitude = Convert.ToDouble(item["siteLongitude"].ToString()); s.PCI = Convert.ToInt32(item["PCI"].ToString()); secList.Add(s); } } //var uniquePci = secList.Select(x=>x.Pci).Distinct().ToList(); var list = listLatLong.Distinct().Take(10).ToList(); var list1 = (from x in list join y in secList on x.SiteCode equals y.SectorCode into data from d in data.DefaultIfEmpty() select d).ToList(); var uniq = list1.GroupBy(x => x.PCI).ToList(); foreach (var item in uniq) { var color = String.Format("#{0:X6}", random.Next(0x1000000)); var q = list1.Where(x => x.PCI == item.Key).FirstOrDefault(); q.sectorColor = color.ToString(); foreach (var item1 in list1.Where(x => x.PCI == item.Key).ToList()) { item1.sectorColor = q.sectorColor; } } //var a = list1.Where(x => x.sectorColor != null); return(Request.CreateResponse(HttpStatusCode.OK, new { list, list1 })); }