public ActionResult New(string title, string Id = "") { if (Id == "") { return(RedirectToAction("All")); } SWI.AirView.Common.SelectedList sl = new SWI.AirView.Common.SelectedList(); Sec_UserBL ud = new Sec_UserBL(); ViewBag.tit = title; ViewBag.Id = 0; ViewBag.Reports = sl.User("All"); ViewBag.ReportTo = ud.ToList("All"); if (Id != "") { ViewBag.Id = Convert.ToInt64(Id); } ClientsBL ub = new ClientsBL(); ViewBag.Clients2 = sl.Clients("AllRecords"); NewData(); return(View()); }
public ActionResult New() { SWI.AirView.Common.SelectedList sl = new SWI.AirView.Common.SelectedList(); ViewBag.PDefinationName = sl.DefinationTypes(); AD_DefinationTypes model = new AD_DefinationTypes(); return(PartialView("~/Views/DefinationType/_DefinationTypes.cshtml", model)); }
public ActionResult Edit(int Id = 0, int ProjectSiteId = 0) { if (Id > 0) { var oob = Permission.AllowProject(Convert.ToInt64(Id)); if (oob == null) { TempData["msg_error"] = "This Project is not assigned to you. Please contact administrator for project assignment."; return(RedirectToAction("index", "error", new { Area = "Project" })); } else { TempData["ProjectEntity"] = oob; TempData.Keep("ProjectEntity"); } } AD_DefinationBL db = new AD_DefinationBL(); Sec_UserSettingsDL udl = new Sec_UserSettingsDL(); ViewBag.FormType = (TempData["FormType"] != null) ? "Edit" : "New"; ViewBag.Id = Id; ViewBag.Bands = db.ToList("Bands"); ViewBag.ProjectSiteId = ProjectSiteId; ViewBag.ProjectSite = ub.ToList("Get_By_Id", ProjectSiteId.ToString()).FirstOrDefault(); if (ViewBag.ProjectSite == null) { TempData["msg_error"] = "Record Not Exist or You Are Not Authorize to access !"; return(RedirectToAction("All")); } ViewBag.Carriers = db.ToList("Carriers"); ViewBag.Regions = db.ToList("UserRegions", Convert.ToString(ViewBag.UserId)); DataTable Table = udl.GetDataTable("UserProjects", Convert.ToString(ViewBag.UserId), null, null); ViewBag.Projects = Table.ToList <PM_Projects>().Where(x => x.ProjectId == Id).ToList(); ViewBag.Cities = db.ToList("UserCities", Convert.ToString(ViewBag.UserId)); ViewBag.SubCheckList = db.ToList("byDefinationType", "Sub CheckList"); SWI.AirView.Common.SelectedList sl = new SWI.AirView.Common.SelectedList(); ViewBag.NetworkModes = db.SelectedList("NetworkModes", null, "-NetworkMode-"); var hjh = db.MultiSelecet("NetworkModes", null, "-NetworkMode-"); ViewBag.NetworkModesm = hjh; ViewBag.States = sl.Definations("UserStates", Convert.ToString(ViewBag.UserId), "-State-"); //sl.States(); TSS_SurveyDocumentBL sdb = new TSS_SurveyDocumentBL(); ViewBag.Surveys = sdb.ToList("GetAll_byIsActive", true.ToString());; ViewBag.Scopes = sl.Definations("UserScopes", Convert.ToString(ViewBag.UserId));// sl.Scopes(); ViewBag.Clients = sl.Clients("UserClients", Convert.ToString(ViewBag.UserId)); ViewBag.SiteTypes = sl.Definations("SiteTypes"); ViewBag.SiteClasses = sl.Definations("SiteClasses"); ViewBag.CheckList = sl.Definations("byDefinationType", "CheckList", "-CheckList-"); ViewBag.Sectors = sl.Sectors(); return(View()); }
public ActionResult EditDefinationType(int Id) { AD_DefinationTypesBL db = new AD_DefinationTypesBL(); //List<AD_DefinationTypes> list = db.ToList("ALL"); SWI.AirView.Common.SelectedList sl = new SWI.AirView.Common.SelectedList(); ViewBag.PDefinationName = sl.DefinationTypes(); AD_DefinationTypes model = new AD_DefinationTypes(); if (Id > 0) { AD_DefinationTypes dt = db.SingleDefinationType("Single", Id.ToString()); model.DefinationType = dt.DefinationType; model.PDefinationTypeId = dt.PDefinationTypeId; model.DefinationTypeId = dt.DefinationTypeId; model.IsActive = dt.IsActive; } return(PartialView("~/Views/DefinationType/_DefinationTypes.cshtml", model)); }
public ActionResult Edit(string Id = "") { ClientsBL cb = new ClientsBL(); UserClientsBL uchb = new UserClientsBL(); UserCityBL ucb = new UserCityBL(); AD_DefinationBL db = new AD_DefinationBL(); Sec_User user = new Sec_User(); Sec_UserBL ubl = new Sec_UserBL(); Sec_UserSettingsDL udl = new Sec_UserSettingsDL(); Sec_PermissionBL pl = new Sec_PermissionBL(); Sec_UserDefinationTypeBL udt = new Sec_UserDefinationTypeBL(); ViewBag.Titles = new List <SelectListItem> { new SelectListItem { Text = "Mr.", Value = "1" }, new SelectListItem { Text = "Mrs.", Value = "2" }, new SelectListItem { Text = "Miss.", Value = "3" }, new SelectListItem { Text = "Ms.", Value = "4" }, new SelectListItem { Text = "Sir.", Value = "5" }, new SelectListItem { Text = "DR", Value = "6" } }; ViewBag.Hide = false; ViewBag.Team = false; if (Id == Convert.ToString(ViewBag.UserId)) { ViewBag.Hide = true; List <OrgChart> rec = ubl.hierarchy("ByCompanyId", Convert.ToString(ViewBag.CompId)); List <Chart> Data2 = FlatToHierarchy(rec, ViewBag.UserId); if (Data2.Count > 0) { ViewBag.Team = true; } else { ViewBag.Team = false; } } SWI.AirView.Common.SelectedList sl = new SWI.AirView.Common.SelectedList(); Sec_UserBL ud = new Sec_UserBL(); Sec_User User = ud.Single("ById", Id.ToString()); ViewBag.UserTitle = User.Title; ViewBag.Hide2 = true; if (User.ReportToId.ToString() == Convert.ToString(ViewBag.UserId)) { ViewBag.Hide2 = false; } if (Id == Convert.ToString(ViewBag.UserId)) { ViewBag.Hide2 = false; } ViewBag.User = User; if (User == null) { } if (User.IsAdmin == true) { ViewBag.Hide = false; ViewBag.Hide2 = false; ViewBag.Team = true; } NewData(); ViewBag.Id = User.CompanyId; ViewBag.RoleId = User.RoleId; ViewBag.Reports = sl.User("All"); ViewBag.ReportTo = ud.ToList("All"); ViewBag.Clients2 = sl.Clients("AllRecords"); /////permissions user = ubl.Single("ById", Id.ToString()); ///Project DataTable Table = udl.GetDataTable("All_Projects", User.ReportToId.ToString(), null, null); ViewBag.Projects = Table.ToList <PM_Projects>(); DataTable Table1 = udl.GetDataTable("UserProjects", Id.ToString(), null, null); ViewBag.UserProjects = Table1.ToList <PM_Projects>(); var r = pl.ToList("byUserId", Id.ToString()); var d = udt.ToList("GetByUserId", Id.ToString()); string UDSelected = null; foreach (var item in d) { UDSelected += item.DefinationTypeId + ","; } ViewBag.DIds = UDSelected; string Selected = null; foreach (var item in r) { Selected += item.Id + ","; } ViewBag.PIds = Selected; ViewBag.UId = Id; #region user Permissions on tab //Clients //ViewBag.Clients = cb.ToList("byStatus", User.ReportToId.ToString()); ViewBag.Clients = cb.ToList("byStatus", "True", User.ReportToId.ToString()); ViewBag.UserClients = uchb.ToList("byUserId", Id.ToString()); //Cities ViewBag.Cities = db.ToList("AllCities"); //db.ToList("UserCities",User.ReportToId.ToString()); ViewBag.UserCities = ucb.ToList("byUserId", Id.ToString()); ViewBag.Region = db.RegionsToList(User.ReportToId.ToString()); //scope ViewBag.Scopes = db.ToList("Scopes", User.ReportToId.ToString()); //ViewBag.Scopes = db.ToList("Scopes"); ViewBag.UserScopes = db.ToList("UserScopes", Id.ToString()); ViewBag.Permissions = pl.ToList("byRoleId", user.RoleId.ToString(), User.ReportToId.ToString()); #endregion AD_DefinationTypesBL dtd = new AD_DefinationTypesBL(); ViewBag.DefinationTypes = dtd.ToList("All", User.ReportToId.ToString()); //User.RoleName = ViewBag.RoleName; return(View("edit", User)); }
public ActionResult UploadSites(string id) { var oob = Permission.AllowProject(Convert.ToInt64(id)); if (oob == null) { TempData["msg_error"] = "This Project is not assigned to you. Please contact administrator for project assignment."; return(RedirectToAction("index", "error", new { Area = "Project" })); } else { TempData["ProjectEntity"] = oob; TempData.Keep("ProjectEntity"); } Response response = new Response(); response.Status = "Unsuccessfull"; response.Message = "Site(s) not Imported. Please try again!"; try { AD_DefinationBL defination = new AD_DefinationBL(); Sec_UserSettingsDL usrSetting = new Sec_UserSettingsDL(); DataTable Table = usrSetting.GetDataTable("UserProjects", Convert.ToString(ViewBag.UserId), null, null); var ProjectsList = Table.ToList <PM_Projects>().Where(x => x.ProjectId == long.Parse(id)).ToList(); bool isProjectNotEExist = false; List <string> ErrorFile = new List <string>(); PM_ProjectBL projectBL = new PM_ProjectBL(); var ProjectFACodeList = projectBL.ProjectFACode("ProjectFACodeList", Convert.ToInt64(id)); SWI.AirView.Common.SelectedList sl = new SWI.AirView.Common.SelectedList(); string FileNamePrefix = DateTime.Now.ToString("Error_File_ddMMhhmmss_"); string FileName = null; bool IsFileExist = false; string[] DataInTable = null; string path = null; Int64 ProjectIdOut = 0; if (isProjectNotEExist) { Table = usrSetting.GetDataTable("UserProjects", Convert.ToString(ViewBag.UserId), null, null); ProjectsList = Table.ToList <PM_Projects>().Where(x => x.ProjectId == long.Parse(id)).ToList(); } if (string.IsNullOrEmpty(id) || string.IsNullOrWhiteSpace(id)) { response.Status = "InvalidProjectID"; response.Message = "Project ID is Empty. Please close the tab and reopen it."; return(Json(response)); } else { if (!Int64.TryParse(id, out ProjectIdOut)) { response.Status = "InvalidProjectID"; response.Message = "Project ID is Invalid. Please close the tab and reopen it."; return(Json(response)); } } if (ProjectsList?.Count <= 0) { response.Status = "ProjectPermissionIssue"; response.Message = "Sorry, You don't have permission for this Project."; return(Json(response)); } for (int i = 0; i < Request.Files.Count; i++) { var file = Request.Files[i]; var fileName = Path.GetFileName(file.FileName); FileName = FileNamePrefix + fileName; path = Path.Combine(Server.MapPath("~/files/Raw"), FileName); if (Path.GetExtension(path) != ".csv") { response.Status = "Unsuccessfull"; response.Message = "Invalid file format, Only CSV file supported."; return(Json(response)); } file.SaveAs(path); IsFileExist = true; } if (IsFileExist) { List <SelectListItem> Scopes = sl.Definations("UserScopes", Convert.ToString(ViewBag.UserId)); var SiteTypes = sl.Definations("SiteTypes"); List <SWI.Libraries.AD.Entities.AD_Defination> Cities = defination.ToList("UserCities", Convert.ToString(ViewBag.UserId)); DataInTable = System.IO.File.ReadAllLines(path); List <ProjectSites> Sites = new List <ProjectSites>(); string FileHeader = string.Empty; if (DataInTable?.Count() == 1) { response.Status = "EmptyFile"; response.Message = "File is empty!"; return(Json(response)); } if (DataInTable?.Count() > 0) { FileHeader = string.Join(",", DataInTable[0].Split(',').Take(20).ToArray()) + ",Error(s)"; } ErrorFile.Add(FileHeader); string InValidInput = string.Empty; string RequiredFileds = string.Empty; string InvalidLength = string.Empty; string InvalidDataType = string.Empty; string FACodeAlreadyExist = string.Empty; List <string> FACodeInFile = new List <string>(); foreach (var item in DataInTable.Skip(1)) { var cols = item.Split(','); if (cols?.Count() > 0) { FACodeInFile.Add(cols[3]); } } foreach (var row in DataInTable.Skip(1)) { InValidInput = string.Empty; RequiredFileds = string.Empty; InvalidLength = string.Empty; InvalidDataType = string.Empty; FACodeAlreadyExist = string.Empty; ProjectSites site = new ProjectSites(); site.ProjectId = Convert.ToInt64(id); var Cols = row.Split(','); if (!string.IsNullOrEmpty(Utilities.ElementAtOrDefault(Cols, 0)) && !string.IsNullOrWhiteSpace(Utilities.ElementAtOrDefault(Cols, 0))) { var Market = Cities?.FirstOrDefault(x => x.DefinationName.ToLower() == Cols[0].ToLower()); if (Market != null) { site.Market = Convert.ToString(Market.DefinationId); } else { InValidInput += "[Market]"; } } else { RequiredFileds += "[Market]"; } if (!string.IsNullOrEmpty(Utilities.ElementAtOrDefault(Cols, 1)) && !string.IsNullOrWhiteSpace(Utilities.ElementAtOrDefault(Cols, 1))) { var Scope = Scopes?.FirstOrDefault(x => x.Text.ToLower() == Cols[1].ToLower()); if (Scope != null) { site.Scope = Convert.ToString(Scope.Value); } else { InValidInput += "[Scope]"; } } if (!string.IsNullOrEmpty(Utilities.ElementAtOrDefault(Cols, 2)) && !string.IsNullOrWhiteSpace(Utilities.ElementAtOrDefault(Cols, 2))) { if (Cols[2].Length > 50) { InvalidLength += "[Cluster Code > 50]"; } else { site.ClusterCode = Cols[2]; site.clusterId = Cols[2]; } } else { RequiredFileds += "[Cluster Code]"; } if (!string.IsNullOrEmpty(Utilities.ElementAtOrDefault(Cols, 3)) && !string.IsNullOrWhiteSpace(Utilities.ElementAtOrDefault(Cols, 3))) { if (Cols[3].Length > 25) { InvalidLength += "[Site Code > 25]"; } else { var IsFACodeExist = ProjectFACodeList?.Where(x => x.FACode.Trim().ToLower() == Cols[3].Trim().ToLower())?.Count() > 0 ? true : false; bool IsFACodeExistInFile = FACodeInFile?.Where(x => x.Trim().ToLower() == Cols[3].Trim().ToLower())?.Count() > 1 ? true : false; if (IsFACodeExist == false && IsFACodeExistInFile == false) { site.SiteCode = Cols[3]; site.FACode = Cols[3]; } else { FACodeAlreadyExist += "[Site Code]"; } } } else { RequiredFileds += "[Site Code]"; } if (!string.IsNullOrEmpty(Utilities.ElementAtOrDefault(Cols, 4)) && !string.IsNullOrWhiteSpace(Utilities.ElementAtOrDefault(Cols, 4))) { if (Cols[4].Length > 500) { InvalidLength += "[Site Name > 500]"; } else { site.SiteName = Cols[4]; } } else { RequiredFileds += "[Site Name]"; } if (!string.IsNullOrEmpty(Utilities.ElementAtOrDefault(Cols, 5)) && !string.IsNullOrWhiteSpace(Utilities.ElementAtOrDefault(Cols, 5))) { double Out = 0; if (!double.TryParse(Cols[5], out Out)) { InvalidDataType += "[Latitude]"; } if (Cols[5].Length > 500) { InvalidLength += "[Latitude > 500]"; } else { site.siteLatitude = Cols[5]; } } else { RequiredFileds += "[Latitude]"; } if (!string.IsNullOrEmpty(Utilities.ElementAtOrDefault(Cols, 6)) && !string.IsNullOrWhiteSpace(Utilities.ElementAtOrDefault(Cols, 6))) { double Out = 0; if (!double.TryParse(Cols[6], out Out)) { InvalidDataType += "[Longitude]"; } if (Cols[6].Length > 500) { InvalidLength += "[Longitude > 500]"; } else { site.siteLongitude = Cols[6]; } } else { RequiredFileds += "[Longitude]"; } if (!string.IsNullOrEmpty(Utilities.ElementAtOrDefault(Cols, 7)) && !string.IsNullOrWhiteSpace(Utilities.ElementAtOrDefault(Cols, 7))) { var siteTypes = SiteTypes?.FirstOrDefault(x => x.Text.ToLower() == Cols[7].ToLower()); if (siteTypes != null) { site.SiteTypeId = Convert.ToString(siteTypes.Value); } else { InValidInput += "[Site Type]"; } } else { RequiredFileds += "[Site Type]"; } if (!string.IsNullOrEmpty(Utilities.ElementAtOrDefault(Cols, 8)) && !string.IsNullOrWhiteSpace(Utilities.ElementAtOrDefault(Cols, 8))) { if (Cols[8].Length > 7) { InvalidLength += "[Color > 7]"; } else { site.Color = Cols[8]; } } if (!string.IsNullOrEmpty(Utilities.ElementAtOrDefault(Cols, 9)) && !string.IsNullOrWhiteSpace(Utilities.ElementAtOrDefault(Cols, 9))) { if (Cols[9].Length > 500) { InvalidLength += "[Description > 500]"; } else { site.Description = Cols[9]; } } if (!string.IsNullOrEmpty(Utilities.ElementAtOrDefault(Cols, 10)) && !string.IsNullOrWhiteSpace(Utilities.ElementAtOrDefault(Cols, 10))) { if (Cols[10].Length > 25) { InvalidLength += "[USID > 25]"; } else { site.USID = Cols[10]; } } if (!string.IsNullOrEmpty(Utilities.ElementAtOrDefault(Cols, 11)) && !string.IsNullOrWhiteSpace(Utilities.ElementAtOrDefault(Cols, 11))) { if (Cols[11].Length > 150) { InvalidLength += "[Sub Market > 150]"; } else { site.SubMarket = Cols[11]; } } if (!string.IsNullOrEmpty(Utilities.ElementAtOrDefault(Cols, 12)) && !string.IsNullOrWhiteSpace(Utilities.ElementAtOrDefault(Cols, 12))) { bool Out = false; if (!bool.TryParse(Cols[12], out Out)) { InvalidDataType += "[vMME]"; } else { site.vMME = Convert.ToBoolean(Cols[12]); } } if (!string.IsNullOrEmpty(Utilities.ElementAtOrDefault(Cols, 13)) && !string.IsNullOrWhiteSpace(Utilities.ElementAtOrDefault(Cols, 13))) { bool Out = false; if (!bool.TryParse(Cols[13], out Out)) { InvalidDataType += "[Controlled Intro]"; } else { site.ControlledIntro = Convert.ToBoolean(Cols[13]); } } if (!string.IsNullOrEmpty(Utilities.ElementAtOrDefault(Cols, 14)) && !string.IsNullOrWhiteSpace(Utilities.ElementAtOrDefault(Cols, 14))) { bool Out = false; if (!bool.TryParse(Cols[14], out Out)) { InvalidDataType += "[Super Bowl]"; } else { site.SuperBowl = Convert.ToBoolean(Cols[14]); } } if (!string.IsNullOrEmpty(Utilities.ElementAtOrDefault(Cols, 15)) && !string.IsNullOrWhiteSpace(Utilities.ElementAtOrDefault(Cols, 15))) { if (Cols[15].Length > 50) { InvalidLength += "[isDASInBuild > 50]"; } else { site.isDASInBuild = Convert.ToString(Cols[15]); } } if (!string.IsNullOrEmpty(Utilities.ElementAtOrDefault(Cols, 16)) && !string.IsNullOrWhiteSpace(Utilities.ElementAtOrDefault(Cols, 16))) { if (Cols[16].Length > 50) { InvalidLength += "[FirstNetRAN > 50]"; } else { site.FirstNetRAN = Convert.ToString(Cols[16]); } } if (!string.IsNullOrEmpty(Utilities.ElementAtOrDefault(Cols, 17)) && !string.IsNullOrWhiteSpace(Utilities.ElementAtOrDefault(Cols, 17))) { if (Cols[17].Length > 50) { InvalidLength += "[IPlan Job > 50]"; } else { site.IPlanJob = Convert.ToString(Cols[17]); } } if (!string.IsNullOrEmpty(Utilities.ElementAtOrDefault(Cols, 18)) && !string.IsNullOrWhiteSpace(Utilities.ElementAtOrDefault(Cols, 18))) { if (Cols[18].Length > 50) { InvalidLength += "[PaceNo > 50]"; } else { site.PaceNo = Convert.ToString(Cols[18]); } } if (!string.IsNullOrEmpty(Utilities.ElementAtOrDefault(Cols, 19)) && !string.IsNullOrWhiteSpace(Utilities.ElementAtOrDefault(Cols, 19))) { DateTime Out = DateTime.Now; if (!DateTime.TryParse(Cols[19], out Out)) { InvalidDataType += "[Invalid IPlanIssueDate]"; } if (Cols[19].Length > 10) { InvalidLength += "[IPlanIssueDate > 10]"; } else { site.IPlanIssueDate = Convert.ToString(Cols[19]); } } if (string.IsNullOrEmpty(RequiredFileds) && string.IsNullOrEmpty(InValidInput) && string.IsNullOrEmpty(InvalidDataType) && string.IsNullOrEmpty(InvalidLength) && string.IsNullOrEmpty(FACodeAlreadyExist)) { Sites.Add(site); } else { if (!string.IsNullOrEmpty(RequiredFileds)) { RequiredFileds += (RequiredFileds?.TrimEnd(',')?.Split(',')?.Count() >= 2) ? " are required." : " is required."; } if (!string.IsNullOrEmpty(InvalidLength)) { InvalidLength += " has Invalid Length."; } if (!string.IsNullOrEmpty(InvalidDataType)) { InvalidDataType += " have invalid data type."; } if (!string.IsNullOrEmpty(InValidInput)) { InValidInput += " have invalid input."; } if (!string.IsNullOrEmpty(FACodeAlreadyExist)) { FACodeAlreadyExist += " already exist."; } string NewRowWithErrors = $"{string.Join(",", Cols.Take(20).ToArray()).TrimEnd(',')},{RequiredFileds} {FACodeAlreadyExist} {InValidInput} {InvalidDataType} {InvalidLength} "; ErrorFile.Add(NewRowWithErrors); } } if (Sites?.Count > 0 && ErrorFile.Count <= 1) { var IsInserted = ub.Insert("Insert", Sites, Convert.ToInt64(ViewBag.UserId), 0, Sites[0].SiteName); if (IsInserted) { response.Status = "Ok"; response.Message = "Site(s) imported successfully!"; } else { response.Status = "Unsuccessfull"; response.Message = "There is an unexpected error. Please try again!"; } } else if (ErrorFile.Count > 1) { System.IO.File.WriteAllLines(Path.Combine(Server.MapPath("~/files/Raw"), FileName), ErrorFile); response.Status = "OkWithErrorFile"; response.Value = $"/files/Raw/{FileName}"; response.Message = "File could not be uploaded due to errors in file."; } else { response.Status = "Unsuccessfull"; response.Message = "There is an unexpected error. Please try again!"; } } } catch (Exception e) { return(Json(response)); } return(Json(response)); }
public ActionResult Index() { SWI.AirView.Common.SelectedList sl = new SWI.AirView.Common.SelectedList(); ViewBag.PDefinationName = sl.DefinationTypes(); return(View()); }