public ActionResult Edit(AV_Site Site, Workorder wo, List <Workorder> Sectors) { //Workorder Site, List<AV_Sector> Sectors Response res = new Response(); try { DataTable Sectorsdt = new DataTable(); // Sectorsdt = Sectors.ToDataTable(); Sectorsdt.Columns.Remove("TestStatus"); Sectorsdt.Columns.Remove("Latitude"); Sectorsdt.Columns.Remove("Longitude"); Sectorsdt.Columns.Remove("isActive"); Sectorsdt.Columns.Remove("sectorColor"); WorkOrderDL dl = new WorkOrderDL(); // dl.Edit(Site, Sectorsdt); res.Status = "success"; res.Message = "save successfully"; } catch (Exception ex) { res.Status = "danger"; res.Message = ex.Message; } return(Json(res, JsonRequestBehavior.AllowGet)); }
public void SiteWithSectors(int SiteId, ref AV_Site Site, ref List <AV_Sector> Sectors) { try { DataSet ds = sd.GetDataSet("SiteWithSectors", SiteId.ToString()); if (ds.Tables.Count > 0) { DataTable Sit = ds.Tables[0]; var rec = Sit.ToList <AV_Site>(); if (rec.Count > 0) { Site = rec.FirstOrDefault(); } DataTable sec = ds.Tables[1]; Site.Sectors = sec.ToList <AV_Sector>(); Sectors = sec.ToList <AV_Sector>(); } } catch { throw; } }
public List <Workorder> GetWO(string value1 = null, string value2 = null, string value3 = null) { AV_SitesDL sd = new AV_SitesDL(); List <Workorder> wolst = new List <Workorder>(); DataSet ds = sd.GetDataSet("SiteWithSectors", value1); if (ds.Tables.Count > 0) { DataTable Sit = ds.Tables[0]; AV_Site s = new AV_Site(); var rec = Sit.ToList <AV_Site>(); if (rec.Count > 0) { s = rec.FirstOrDefault(); } DataTable sec = ds.Tables[1]; Workorder wo; for (int i = 0; i < sec.Rows.Count; i++) { wo = new Workorder(); wo.SiteId = s.SiteId; wo.siteCode = s.SiteCode; wo.siteLatitude = s.Latitude.ToString(); wo.siteLongitude = s.Longitude.ToString(); wo.Client = s.ClientId.ToString(); wo.Scope = s.ScopeId.ToString(); wo.SiteAddress = s.SiteAddress; wo.SiteName = s.SiteName; wo.SiteTypeId = s.SiteTypeId.ToString(); wo.SiteClassId = s.SiteClassId; wo.Description = s.Description; wo.clusterCode = "-"; wo.sectorCode = sec.Rows[i]["SectorCode"].ToString(); wo.networkMode = sec.Rows[i]["NetworkModeId"].ToString(); wo.Band = sec.Rows[i]["BandId"].ToString(); wo.Carrier = sec.Rows[i]["CarrierId"].ToString(); wo.BandWidth = (!string.IsNullOrEmpty(sec.Rows[i]["BandWidth"].ToString())) ? sec.Rows[i]["BandWidth"].ToString() : "0"; wo.Antenna = sec.Rows[i]["Antenna"].ToString(); wo.BeamWidth = sec.Rows[i]["BeamWidth"].ToString(); wo.Azimuth = sec.Rows[i]["Azimuth"].ToString(); wo.PCI = sec.Rows[i]["PCI"].ToString(); wo.MRBTS = sec.Rows[i]["MRBTS"].ToString(); wo.RFHeight = DataType.ToInt32(sec.Rows[i]["RFHeight"].ToString()); wo.MTilt = DataType.ToInt32(sec.Rows[i]["MTilt"].ToString()); wo.ETilt = DataType.ToInt32(sec.Rows[i]["ETilt"].ToString()); wo.CellId = sec.Rows[i]["CellId"].ToString(); wolst.Add(wo); } } return(wolst); }
public bool Edit(AV_Site sit, DataTable Sectors) { SqlCommand loCommand = DataContext.OpenConnection(); try { loCommand = DataContext.SetStoredProcedure(loCommand, "AV_EditWorkOrder"); loCommand = DataContext.StartTransaction(loCommand); bool result = DataContext.ExecuteNonQuery(DataContext.AddParameters(loCommand, "@SiteId", sit.SiteId, "@SiteCode", sit.SiteCode, "@Latitude", sit.Latitude, "@Longitude", sit.Longitude, "@Description", sit.Description, "@CityId", sit.CityId, "@SiteAddress", sit.SiteAddress, "@Sectors", Sectors)); DataContext.EndTransaction(loCommand); return(result); } catch { DataContext.CancelTransaction(loCommand); throw; } finally { DataContext.CloseConnection(loCommand); } }
//public List<AV_Site> ListIsActive(string value1 = null, string value2 = null, string value3 = null) //{ // DataTable dtbl = new DataTable(); // dtbl = wod.Get("Search", value1, value2, value3); // List<AV_Site> WorkOrders = dtbl.ToList<AV_Site>(); // return WorkOrders; //} public bool ChangeFolderName(Workorder wo, List <Workorder> wolst) { try { List <string> Newpath = new List <string>(); List <string> OldPath = new List <string>(); AD_DefinationBL db = new AD_DefinationBL(); int x = 0; string ClientPrefix = ""; string networkmode = ""; string carriors = ""; string bands = ""; var Newtworkmode = db.SelectedList("NetworkModes", null, "-NetworkMode-"); var Bands = db.ToList("Bands"); var Carriers = db.ToList("Carriers"); List <AV_Sector> Sectors = new List <AV_Sector>(); List <Changefoldername> t = new List <Changefoldername>(); List <Changefoldername> oldt = new List <Changefoldername>(); AV_SitesBL sb = new AV_SitesBL(); AV_Site Site = new AV_Site(); sb.SiteWithSectors(Convert.ToInt32(wo.SiteId), ref Site, ref Sectors); for (int i = 0; i < 1; i++) { ClientPrefix = wolst[0].ClientPrefix; } var dt = wod.GetSiteBands("Get_All", wo.SiteId); if (wolst != null) { if (wo.siteCode.ToString() == Site.SiteCode) { foreach (var row in Sectors) { foreach (var netmod in Newtworkmode) { if (netmod.Value == row.NetworkModeId.ToString()) { networkmode = netmod.Text; } } foreach (var b in Bands) { if (b.DefinationId == row.BandId) { bands = b.DefinationName; } } foreach (var c in Carriers) { if (c.DefinationId == row.CarrierId) { carriors = c.DefinationName; } } var oldp = "/Content/AirViewLogs/" + ClientPrefix + "/" + Site.SiteCode + '/' + networkmode + "_" + bands + "_" + carriors + ""; Changefoldername cf = new Changefoldername(); cf.Id = Convert.ToInt64(row.SectorId); cf.Path = oldp; oldt.Add(cf); } foreach (var item in wolst) { foreach (var netmod in Newtworkmode) { if (netmod.Value == item.networkMode) { networkmode = netmod.Text; } } foreach (var b in Bands) { if (b.DefinationId.ToString() == item.Band) { bands = b.DefinationName; } } foreach (var c in Carriers) { if (c.DefinationId.ToString() == item.Carrier) { carriors = c.DefinationName; } } var p = "/Content/AirViewLogs/" + ClientPrefix + "/" + wo.siteCode.ToString() + '/' + networkmode + "_" + bands + "_" + carriors + ""; foreach (var itm in Sectors) { if (itm.SectorId == item.SectorId) { Changefoldername cfn = new Changefoldername(); cfn.Id = Convert.ToInt64(item.SectorId); cfn.Path = p; t.Add(cfn); break; } } } List <long> RemoveLayesId = new List <long>(); foreach (var itme in t) { foreach (var tm in oldt) { if (itme.Id == tm.Id && itme.Path == tm.Path) { RemoveLayesId.Add(itme.Id); } } } foreach (var r in RemoveLayesId) { var obj = t.Where(xx => xx.Id == r).FirstOrDefault(); var obj1 = oldt.Where(xx => xx.Id == r).FirstOrDefault(); t.Remove(obj); oldt.Remove(obj1); } for (int i = 0; i < t.Count; i++) { bool exists = System.IO.Directory.Exists(HttpContext.Current.Server.MapPath(oldt[i].Path)); if (exists) { bool exists1 = System.IO.Directory.Exists(HttpContext.Current.Server.MapPath(t[i].Path)); if (!exists1) { t[i].Path = HttpContext.Current.Server.MapPath(t[i].Path); oldt[i].Path = HttpContext.Current.Server.MapPath(oldt[i].Path); Directory.CreateDirectory(t[i].Path); DirectoryInfo dirInfo = new DirectoryInfo(t[i].Path); int xx = 0; int y = 0; List <String> MyFiles = Directory .GetFiles(oldt[i].Path, "*.*", SearchOption.AllDirectories).ToList(); foreach (string file in MyFiles) { FileInfo mFile = new FileInfo(file); // to remove name collisions if (new FileInfo(dirInfo + "\\" + mFile.Name).Exists == false) { mFile.MoveTo(dirInfo + "\\" + mFile.Name); xx++; } } //Directory.CreateDirectory(HttpContext.Current.Server.MapPath(t[i].Path)); // } // System.IO.Directory.Move(HttpContext.Current.Server.MapPath(oldt[i].Path), HttpContext.Current.Server.MapPath(t[i].Path)); } else { t[i].Path = HttpContext.Current.Server.MapPath(t[i].Path); oldt[i].Path = HttpContext.Current.Server.MapPath(oldt[i].Path); List <String> Files = Directory .GetFiles(oldt[i].Path, "*.*", SearchOption.AllDirectories).ToList(); if (Files.Count > 0) { var MyFiles = Directory .GetFiles(oldt[i].Path, "*.*", SearchOption.AllDirectories).ToList(); foreach (string file in MyFiles) { FileInfo mFile = new FileInfo(file); // to remove name collisions if (new FileInfo(t[i].Path + "\\" + mFile.Name).Exists == false) { mFile.MoveTo(t[i].Path + "\\" + mFile.Name); } } } } } } } else { var oldp = "/Content/AirViewLogs/" + ClientPrefix + "/" + Site.SiteCode + '/'; var p = "/Content/AirViewLogs/" + ClientPrefix + "/" + wo.siteCode.ToString() + '/'; var newPath = HttpContext.Current.Server.MapPath(p); var oldPath = HttpContext.Current.Server.MapPath(oldp); DirectoryCopy(oldPath, newPath, true); clearFolder(oldPath); DeleteFolder(oldPath); } } return(true); } catch (Exception ex) { throw ex; } }
public bool ChangeFolderName(long networklayerid, string SiteCode) { try { AD_DefinationBL db = new AD_DefinationBL(); int x = 0; string ClientPrefix = ""; string networkmode = ""; string carriors = ""; string bands = ""; var Newtworkmode = db.SelectedList("NetworkModes", null, "-NetworkMode-"); var Bands = db.ToList("Bands"); var Carriers = db.ToList("Carriers"); string oldpath = ""; string newpath = ""; AV_NetLayerStatusBL nlsb = new AV_NetLayerStatusBL(); var rec = nlsb.ToSingle("Get_byLayerStatusId", 0, 0, 0, 0, networklayerid.ToString()); AV_SitesBL sb = new AV_SitesBL(); AV_Site oldSite = new AV_Site(); oldSite = sb.Single("SingleSitebyId", rec.SiteId.ToString(), null, null, null, null); AV_Site newSite = new AV_Site(); newSite = sb.Single("SingleSitebySiteCode", SiteCode.ToString(), null, null, null, null); var Newrec = nlsb.ToSingle("Get_byLayerStatusId", 0, 0, 0, 0, networklayerid.ToString()); var oldSiteRecord = sb.ToList("BySiteCodeWithLayer", oldSite.SiteCode, null, null, null, null, null); var newSiteRecord = sb.ToList("BySiteCodeWithLayer", newSite.SiteCode, null, null, null, null, null); foreach (var netmod in Newtworkmode) { if (netmod.Value == rec.NetworkModeId.ToString()) { networkmode = netmod.Text; } } foreach (var b in Bands) { if (b.DefinationId == rec.BandId) { bands = b.DefinationName; } } foreach (var c in Carriers) { if (c.DefinationId == rec.CarrierId) { carriors = c.DefinationName; } } oldpath = "/Content/AirViewLogs/" + oldSiteRecord[0].ClientPrefix + "/" + oldSite.SiteCode + "/" + networkmode + "_" + bands + "_" + carriors + ""; foreach (var netmod in Newtworkmode) { if (netmod.Value == Newrec.NetworkModeId.ToString()) { networkmode = netmod.Text; } } foreach (var b in Bands) { if (b.DefinationId == Newrec.BandId) { bands = b.DefinationName; } } foreach (var c in Carriers) { if (c.DefinationId == Newrec.CarrierId) { carriors = c.DefinationName; } } newpath = "/Content/AirViewLogs/" + newSiteRecord[0].ClientPrefix + "/" + newSite.SiteCode + '/' + networkmode + "_" + bands + "_" + carriors + ""; var newPath = HttpContext.Current.Server.MapPath(newpath); var oldPath = HttpContext.Current.Server.MapPath(oldpath); WorkOrderBL wo = new WorkOrderBL(); wo.DirectoryCopy(oldPath, newPath, true); return(true); } catch (Exception ex) { throw ex; } }
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 })); }
public ActionResult Edit(int Id = 0) { ViewBag.FormType = "Edit"; AV_SitesBL sb = new AV_SitesBL(); AV_Site Site = new AV_Site(); List <AV_Sector> Sectors = new List <AV_Sector>(); sb.SiteWithSectors(Id, ref Site, ref Sectors); ViewBag.Site = Site; Common.SelectedList sl = new Common.SelectedList(); AD_DefinationBL db = new AD_DefinationBL(); ViewBag.NetworkModes = db.SelectedList("NetworkModes", null, "-NetworkMode-"); ViewBag.Bands = db.ToList("Bands"); ViewBag.Carriers = db.ToList("Carriers"); ViewBag.Scopes = sl.Scopes(); ViewBag.Sectors = sl.Sectors(); List <SWI.Libraries.Common.SelectedList> Markets = new List <SelectedList>(); if (ViewBag.IsAdmin) { ViewBag.UserMarkets = db.SelectedList("AllCities"); Markets = ViewBag.UserMarkets; } else { ViewBag.UserMarkets = db.SelectedList("UserCities", Convert.ToString(ViewBag.UserId)); Markets = ViewBag.UserMarkets; } //bands network mode etc dropdowns WorkorderEdit we = new WorkorderEdit(); Sec_UserSettingsDL udl = new Sec_UserSettingsDL(); we.Site = Site; we.Site.StateId = we.Site.State; we.Site.RegionId = we.Site.Region; we.Site.MarketId = we.Site.Market; we.Site.SiteType = we.Site.SiteTypeId; we.Site.SiteClass = we.Site.SiteClassId; we.Bands = ViewBag.Bands; ViewBag.Id = Id; we.Carriers = ViewBag.Carriers; DataTable Table = udl.GetDataTable("UserProjects", Convert.ToString(ViewBag.UserId), null, null); we.Projects = Table.ToList <PM_Projects>(); we.Cities = db.ToList("UserCities", Convert.ToString(ViewBag.UserId)); we.SubCheckList = db.ToList("byDefinationType", "Sub CheckList"); we.NetworkModes = ViewBag.NetworkModes; var hjh = db.MultiSelecet("NetworkModes", null, "-NetworkMode-"); we.NetworkModesm = hjh; we.States = sl.Definations("UserStates", Convert.ToString(ViewBag.UserId), "-State-"); //sl.States(); we.Regions = db.ToList("UserRegions", Convert.ToString(ViewBag.UserId)); // we.Regions = we.Regions.Where(x => x.PDefinationId ==we.State).ToList(); we.UserMarkets = Markets; // we.UserMarkets = we.UserMarkets; //.Where(x=>x.Value==Convert.ToString(we.Region)).ToList(); TSS_SurveyDocumentBL sdb = new TSS_SurveyDocumentBL(); we.Surveys = sdb.ToList("GetAll_byIsActive", true.ToString()); we.Clients = sl.Clients("UserClients", Convert.ToString(ViewBag.UserId)); we.Scopes = sl.Definations("UserScopes", Convert.ToString(ViewBag.UserId));// sl.Scopes(); we.SiteTypes = sl.Definations("SiteTypes"); we.SiteClasses = sl.Definations("SiteClasses"); we.CheckList = sl.Definations("byDefinationType", "CheckList", "-CheckList-"); we.Sectors = Sectors; we.Sectors[0].Bands = we.Bands; we.Sectors[0].Carriers = we.Carriers; return(View("Workorder", we)); // return View(Sectors); }