public PartialViewResult GetDirectioryWithFilesAVX(int Id = 0) { List <GetDirctoryinformation> singdir = new List <GetDirctoryinformation>(); SitesBL sb = new SitesBL(); List <BandVM> Bands = sb.GetSiteBands("", Id); if (Bands.Count() > 0) { var band = Bands.FirstOrDefault(); var sPath = Server.MapPath("~/Content/AirViewLogs/" + band.ClientPrefix + "\\" + band.SiteCode); if (Directory.Exists(sPath)) { FileInfo[] allFiles = new DirectoryInfo(sPath).GetFiles("*.avx", SearchOption.AllDirectories); if (allFiles.Length > 0) { foreach (var file in allFiles) { GetDirctoryinformation info = new GetDirctoryinformation(); info.createDate = file.CreationTime.ToString(); info.directoryPath = file.FullName; info.fileName = file.Name; info.fileType = file.Extension; info.size = (file.Length / 1024).ToString(); singdir.Add(info); } } } } return(PartialView("~/Views/SiteDashboard/RenderFilesOfDirectoryBaseOnWorkorder.cshtml", singdir)); }
public PartialViewResult getDirectioryWithFiles(string getNetworkLayer, string Scope = "") { List <GetDirctoryinformation> singdir = new List <GetDirctoryinformation>(); // string absolutePath = Server.MapPath("/Content/AirViewLogs/TMO"); if (Scope == "TSS") { string absolutePath = Server.MapPath("~/Content/AirViewLogs/" + getNetworkLayer); string path = ""; if (Directory.Exists(absolutePath)) { path = absolutePath; DirectoryInfo objDirectoryInfo = new DirectoryInfo(path); FileInfo[] allFiles = objDirectoryInfo.GetFiles("*.*", SearchOption.AllDirectories); if (allFiles.Length > 0) { foreach (var file in allFiles) { GetDirctoryinformation info = new GetDirctoryinformation(); info.createDate = file.CreationTime.ToString(); info.directoryPath = file.FullName; info.fileName = file.Name; info.fileType = file.Extension; info.size = (file.Length / 1024).ToString(); singdir.Add(info); } } } else { string SiteCode = getNetworkLayer.Split('/')[1]; path = Server.MapPath("~/Content/AirviewLogs/TMO/WEB/" + SiteCode); if (Directory.Exists(path)) { DirectoryInfo objDirectoryInfo = new DirectoryInfo(path); FileInfo[] allFiles = objDirectoryInfo.GetFiles("*.*", SearchOption.AllDirectories); if (allFiles.Length > 0) { foreach (var file in allFiles) { GetDirctoryinformation info = new GetDirctoryinformation(); info.createDate = file.CreationTime.ToString(); info.directoryPath = file.FullName; info.fileName = file.Name; info.fileType = file.Extension; info.size = (file.Length / 1024).ToString(); singdir.Add(info); } } } } // Collecting All Files } else { string absolutePath = Server.MapPath("~/Content/AirViewLogs/" + getNetworkLayer); System.IO.DirectoryInfo files = new System.IO.DirectoryInfo(absolutePath); singdir = walkDirectoryByTree.WalkDirectoryTree(files); } return(PartialView("~/Views/SiteDashboard/RenderFilesOfDirectoryBaseOnNetWorklayer.cshtml", singdir)); }
public ActionResult Information(Int64 Id) { ViewBag.SiteId = Id; List <string> Chennels = new List <string>(); List <string> TestTypes = new List <string>(); List <GetDirctoryinformation> singdir = new List <GetDirctoryinformation>(); SitesBL sb = new SitesBL(); try { List <BandVM> Bands = sb.GetSiteBands("", Id); if (Bands.Count > 0) { AV_SectorBL secb = new AV_SectorBL(); ViewBag.Sectors = secb.ToList("GetSectors", Id.ToString(), null, null, null, null); ViewBag.Bands = Bands.Select(m => new { m.BandId, m.NetworkMode, m.BandName, m.Carrier, Text = m.NetworkMode + " " + m.BandName + " " + m.Carrier, Value = m.SiteCode + "_" + m.NetworkMode + "_" + m.BandName + "_" + m.Carrier }).ToList(); ViewBag.NetworkModeBag = Bands; var band = Bands.FirstOrDefault(); var sPath = Server.MapPath("~/Content/AirViewLogs/" + band.ClientPrefix + "\\" + band.SiteCode); ViewBag.FilePath = sPath; if (Directory.Exists(sPath)) { FileInfo[] allFiles = new DirectoryInfo(sPath).GetFiles("*.xml", SearchOption.AllDirectories); if (allFiles.Length > 0) { foreach (var file in allFiles) { GetDirctoryinformation info = new GetDirctoryinformation(); info.createDate = file.CreationTime.ToString(); info.directoryPath = file.FullName; info.fileName = file.Name; info.fileType = file.Extension; info.size = (file.Length / 1024).ToString(); singdir.Add(info); } } var fileList = new DirectoryInfo(sPath).GetFiles("*.xml", SearchOption.AllDirectories); myFile mf = new myFile(); for (int i = 0; i < fileList.Length; i++) { try { XmlDocument doc = new XmlDocument(); doc.Load(fileList[i].FullName); string jsonText = JsonConvert.SerializeXmlNode(doc); JObject json = JObject.Parse(jsonText); //string txt = mf.FileToString(fileList[i].FullName); //JObject json = JObject.Parse(txt); string rssTitle = (string)json["Drive"]["TestType"]; foreach (var x in json) { // string name = x.Key; JToken value = x.Value; if (value != null) { var sector = value["TestType"]; TestTypes.Add(sector.ToString()); } } var Chennellst = from p in json["Drive"]["message-body"] select new { channel = (string)p["channel"], Event = (string)p["event"] }; foreach (var item in Chennellst) { Chennels.Add(item.channel); } } catch (Exception ex) { } } } } } catch (Exception) { //throw; } ViewBag.AVXFiles = singdir.ToList(); ViewBag.Chennels = Chennels.Distinct().ToList(); ViewBag.TestTypes = TestTypes.Distinct().ToList(); return(View()); }