public async Task UpdateProject(ge_project from, ge_project to) { to.name = from.name; to.managerId = from.managerId; await _unitOfWork.CommitAsync(); }
public static void AddFile(ge_project project, string filename, ge_user user) { if (File.Exists(filename)) { System.IO.FileInfo fi = new FileInfo(filename); project.data.Add(new ge_data { createdId = user.Id, createdDT = DateTime.Now, filename = fi.Name, fileext = fi.Extension, filetype = "text/plain", filesize = fi.Length, filedate = fi.LastWriteTime, encoding = "ascii", datumProjection = datumProjection.NONE, pstatus = PublishStatus.Uncontrolled, cstatus = ConfidentialityStatus.RequiresClientApproval, version = "P01.1", vstatus = VersionStatus.Intermediate, qstatus = QualitativeStatus.AECOMFactual, description = fi.Name, operations = "Read;Update;Delete", file = new ge_data_file { data_string = File.ReadAllText(filename) } } ); } }
public async Task <ge_project> CreateProject(ge_project newProject) { await _unitOfWork.Project.AddAsync(newProject); await _unitOfWork.CommitAsync(); return(newProject); }
public static bool IsUserApprover(this ge_DbContext context, ge_project project, string userId) { if (context == null || project == null || userId == String.Empty) { return(false); } return(DoesUserHaveOperation(context, Constants.ApproveOperationName, project, userId)); }
public async Task <operation_request> GetOperationRequest(string userId, ge_project project) { ge_user_ops group_user = await _unitOfWork.UserOps.GetByUserIdGroupId(userId, project.groupId); ge_user_ops project_user = await _unitOfWork.UserOps.GetByUserIdProjectId(userId, project.Id); operation_request req = new operation_request(project, group_user, project_user); return(req); }
public async Task <Boolean> AreProjectOperationsAllowed(string userId, ge_project project, string request_ops) { ge_user_ops group_user = await _unitOfWork.UserOps.GetByUserIdGroupId(userId, project.groupId); ge_user_ops project_user = await _unitOfWork.UserOps.GetByUserIdProjectId(userId, project.Id); operation_request req = new operation_request(project, group_user, project_user); return(req.AreProjectOperationsAllowed(request_ops)); }
public async Task <string> GetAllowedOperations(string userId, ge_project project) { ge_user_ops group_user = await _unitOfWork.UserOps.GetByUserIdGroupId(userId, project.groupId); ge_user_ops project_user = await _unitOfWork.UserOps.GetByUserIdProjectId(userId, project.Id); operation_request req = new operation_request(project, group_user, project_user); return(req._effectiveProject_ops); }
public async Task <Boolean> DoesUserHaveOperation(string operation, ge_project project, ge_user user) { var user_ops = await GetByUserIdProjectIdIncludeProject(user.Id, project.Id); if (user_ops == null) { return(false); } return(user_ops.operations.Contains(operation)); }
public async Task <EsriConnectionSettings> GetEsriConnectionSettingsByProjectId(Guid Id) { ge_project project = await _unitOfWork.Project.FindByIdAsync(Id); if (project.esriConnectId == null) { return(null); } EsriConnectionSettings ecs = await GetFileAsClass <EsriConnectionSettings>(project.esriConnectId.Value); return(ecs); }
public static bool IsUserLastAdmin(this ge_DbContext context, ge_project project, string userId) { string LastAdminUserId = context.lastAdminUserId(project); if (!String.IsNullOrEmpty(LastAdminUserId)) { if (LastAdminUserId == userId) { return(true); } } return(false); }
public static bool DoesUserHaveAnyOperations(this ge_DbContext context, ge_project project, string userEmail) { if (context == null || project == null || userEmail == String.Empty) { return(false); } var user_project = context.ge_user_ops .AsNoTracking() .Include(u => u.user) .Where(u => u.user.Email == userEmail && u.projectId == project.Id); return(user_project.Any()); }
private string createKML(ge_project project) { ge_KML g = new ge_KML(); g._href = getHostHref() + constHref; g.createContainer(ge_KML.kmlContainer.DOCUMENT, project.name, project.description, project.Id.ToString()); foreach (var d in project.data) { g.process_loc(d, d.filename, d.Id.ToString()); } return(g.ToString()); }
public async Task <Boolean> IsUserProjectAdmin(string userId, ge_project project) { ge_user_ops group_user = await _unitOfWork.UserOps.GetByUserIdGroupId(userId, project.groupId); if (group_user.user_operations.Contains("Admin")) { return(true); } ; ge_user_ops project_user = await _unitOfWork.UserOps.GetByUserIdProjectId(userId, project.Id); return(project_user.user_operations.Contains("Admin")); }
public bool write(ge_project project, XmlNode parent) { write_base(project, parent); write_location(project, parent); try { AddNode("Id", project.Id.ToString(), parent); AddNode("keywords", project.keywords, parent); return(true); } catch { return(false); } }
public async Task <IActionResult> OnGetAsync(Guid groupId) { var userId = GetUserIdAsync().Result; var group = await _context.ge_group.FindAsync(groupId); if (group == null) { return(NotFound()); } project = new ge_project(); project.name = "My Project " + (_context.GetUserProjectCount(userId) + 1).ToString(); project.managerId = userId; project.createdId = userId; project.group = group; project.groupId = groupId; project.start_date = DateTime.UtcNow; project.operations = "Read;Update;Delete"; project.data_operations = "Create;Read;Download;Update;Delete"; if (IsCreateAllowed() != geOPSResp.Allowed) { return(RedirectToPageMessage(msgCODE.PROJECT_CREATE_PROHIBITED)); } var UserAuthorize = await IsUserCreateAuthorised(); if (!UserAuthorize.Succeeded) { return(RedirectToPageMessage(msgCODE.PROJECT_CREATE_USER_PROHIBITED)); } var groups = await _context.GroupSearchByOperation(userId, "Create", "").ToListAsync(); var groupList = new SelectList(groups, "Id", "name", groupId.ToString()); ViewData["groupId"] = groupList; ViewData["managerId"] = _context.getGroupUsers(groups.FirstOrDefault().Id); ViewData["selectRUDOperations"] = Constants.RUD_OperationsArray.Select(x => new SelectListItem() { Text = x, Value = x }); ViewData["selectCRUDDOperations"] = Constants.CRUDD_OperationsArray.Select(x => new SelectListItem() { Text = x, Value = x }); return(Page()); }
private string createXML(ge_project project) { ge_XML g = new ge_XML(); // g._href = getHostHref() + constHref; XmlNode xmlproject = g.createChild("project", project.Id.ToString(), null); g.write(project, xmlproject); foreach (var d in project.data) { XmlNode xmldata = g.createChild("data", d.Id.ToString(), xmlproject); g.write(d, xmldata); } return(g.ToString()); }
public async Task <IActionResult> xmlGet(Guid?projectId) { if (projectId == null) { return(BadRequest()); } project = await _context.ge_project .Include(p => p.data) .FirstAsync(p => p.Id == projectId); if (project == null) { return(UnprocessableEntity("project is null")); } string data_string = ""; data_string = createXML(project); return(Ok(data_string)); }
public static string lastAdminUserId(this ge_DbContext context, ge_project project) { if (context == null || project == null) { return(String.Empty); } string userId = ""; var admin_user_proj = context.ge_user_ops .AsNoTracking() .Where(p => p.user_operations.Contains(Constants.AdminOperationName) && p.projectId == project.Id); if (admin_user_proj.Count() > 1) { userId = String.Empty; } else { userId = admin_user_proj.FirstOrDefault().userId; } admin_user_proj = null; return(userId); }
private async Task <int> AddSurveyData(ge_project project) { // string[] AllPoints = new string[] {""}; // MOND = new List<MOND>(); // MONV = new List<MONV>(); // var resp = await new ge_gINTController (_context, // _authorizationService, // _userManager, // _env , // _ge_config // ).getMONG(project.Id,AllPoints); // var okResult = resp as OkObjectResult; // if (okResult == null) { // return -1; // } // MONG = okResult.Value as List<MONG>; // if (MONG==null) { // return -1; // } // resp = await new ge_gINTController (_context, // _authorizationService, // _userManager, // _env , // _ge_config // ).getPOINT(project.Id,AllPoints); // okResult = resp as OkObjectResult; // if (okResult.StatusCode!=200) { // return -1; // } // POINT = okResult.Value as List<POINT>; // if (POINT==null) { // return -1; // } // int projectId = POINT.FirstOrDefault().gINTProjectID; // foreach (LTM_Survey_Data2 survey in Survey_Data) { // if (survey==null) { // continue; // } // string point_id = survey.hole_id; // if (map_hole_id.ContainsKey(survey.hole_id)) { // point_id = map_hole_id[survey.hole_id]; // } // POINT pt = POINT.Find(p=>p.PointID==point_id); // if (pt==null) { // if ((survey.pack.Contains("A") && projectId==1) || // (survey.pack.Contains("B") && projectId==2) || // (survey.pack.Contains("C") && projectId==3) || // (survey.pack.Contains("D") && projectId==4)) { // Console.WriteLine ("Package {0} survey.hole_id [{1}] not found", survey.pack, survey.hole_id); // } // continue; // } // List<MONG> pt_mg = MONG.Where(m=>m.PointID==pt.PointID).ToList(); // if (pt_mg.Count == 0) { // Console.WriteLine ("Package {0} monitoring point for survey.hole_id {1} not found", survey.pack, survey.hole_id); // continue; // } // string mong_id = survey.mong_ID; // MONG mg = null; // MONG mg_topo = null; // if (map_mong_id.ContainsKey(survey.hole_id + survey.mong_ID)) { // mong_id = map_mong_id[survey.hole_id + survey.mong_ID]; // } // mg = pt_mg.Find(m=>m.ItemKey == mong_id); // if (map_mong_id_gintrecid.ContainsKey(survey.hole_id + survey.mong_ID)) { // int mong_gintrecid = map_mong_id_gintrecid[survey.hole_id + survey.mong_ID]; // mg = pt_mg.Find(m=>m.GintRecID == mong_gintrecid); // } // if (mg == null) { // mg = pt_mg.FirstOrDefault(); // } // DateTime? survey_start = gINTDateTime(survey.date1_getDT()); // if (survey_start==null) continue; // AddVisit (pt, survey); // if (survey.QA_status.Contains("Dip_Approved")) { // AddDip(mg, survey); // } // if (survey.QA_status.Contains("Purge_Approved")) { // AddPurge(mg, survey); // } // if (survey.QA_status.Contains("Gas_Approved")) { // AddGas(mg, survey); // } // if (survey.QA_status.Contains("Topo_Approved") && // (survey.surv_g_level != null || // survey.meas_ToC != null)) { // mg_topo = pt_mg.Find(m=>m.MONG_DIS == 0); // if (mg_topo == null) { // mg_topo = new MONG(); // mg_topo.PointID = pt.PointID; // mg_topo.PIPE_REF = "Pipe 1"; // mg_topo.ItemKey = "SM1"; // mg_topo.MONG_DIS = 0; // mg_topo.MONG_DETL = "Ground Survey Monitoring Point"; // mg_topo.MONG_TYPE = "GNSS"; // pt_mg.Add (mg_topo); // var resp_mong = await UpdateMONG (pt_mg); // //if update fails set mg_topo=null; // } // if (mg_topo != null) { // AddTopo(mg_topo, survey); // } // } // } // return MOND.Count(); return(0); }
public async Task DeleteProject(ge_project project) { _unitOfWork.Project.Remove(project); await _unitOfWork.CommitAsync(); }
private async Task <int> AddMOND(ge_project project) { string[] AllPoints = new string[] { "" }; var resp = await new ge_gINTController(_context, _authorizationService, _userManager, _env, _ge_config ).getMONG(project.Id, AllPoints); var okResult = resp as OkObjectResult; if (okResult.StatusCode != 200) { return(-1); } MONG = okResult.Value as List <MONG>; if (MONG == null) { return(-1); } resp = await new ge_gINTController(_context, _authorizationService, _userManager, _env, _ge_config ).getPOINT(project.Id, AllPoints); okResult = resp as OkObjectResult; if (okResult.StatusCode != 200) { return(-1); } POINT = okResult.Value as List <POINT>; if (POINT == null) { return(-1); } MOND = new List <MOND>(); MONV = new List <MONV>(); int projectId = POINT.FirstOrDefault().gINTProjectID; foreach (LTM_Survey_Data_Add survey in Survey_Data_Add) { if (survey == null) { continue; } POINT pt = POINT.Find(p => p.PointID == survey.hole_id); if (pt == null) { if ((survey.package.Contains("A") && projectId == 1) || (survey.package.Contains("B") && projectId == 2) || (survey.package.Contains("C") && projectId == 3) || (survey.package.Contains("D") && projectId == 4)) { Console.WriteLine("Package {0} survey.hole_id [{1}] not found", survey.package, survey.hole_id); } continue; } List <MONG> pt_mg = MONG.Where(m => m.PointID == survey.hole_id).ToList(); if (pt_mg.Count == 0) { Console.WriteLine("Package {0} monitoring point for survey.hole_id {1} not found", survey.package, survey.hole_id); continue; } MONG mg = pt_mg.Find(m => m.ItemKey == survey.mong_ID); if (mg == null) { mg = pt_mg.FirstOrDefault(); } DateTime?survey_start = gINTDateTime(survey.date1_getDT()); if (survey_start == null) { continue; } DateTime survey_startDT = gINTDateTime(survey.time1_getDT()).Value; DateTime survey_endDT = gINTDateTime(survey.time2_getDT()).Value; // if (survey.globalid == new Guid("bf8e8e5f-7394-4363-bfc2-9bfe876b048a")) { // Console.WriteLine ("{0} {1}", survey_startDT, survey.time1_getDT()); // } MONV mv = NewMONV(pt, survey); mv.MONV_STAR = survey_startDT; mv.MONV_ENDD = survey_endDT; mv.MONV_DIPR = survey.dip_req; mv.MONV_GASR = survey.gas_mon; mv.MONV_LOGR = survey.logger_downld_req; mv.MONV_REMG = survey.gas_fail + " " + survey.gas_com; mv.MONV_REMD = survey.dip_fail + " " + survey.dip_com; mv.MONV_REML = survey.logger_fail + " " + survey.logger_com; mv.MONV_REMS = survey.samp_fail + " " + survey.samp_com; mv.PUMP_TYPE = survey.purg_pump + " " + survey.purg_pump_oth; mv.MONV_WEAT = survey.weath; mv.MONV_TEMP = survey.temp; mv.MONV_WIND = survey.wind; if (survey.dip_instr != null) { mv.DIP_SRLN = survey.dip_instr; mv.DIP_CLBD = gINTDateTime(survey.dip_cali_d_getDT()); } if (survey.interface_instr != null) { mv.DIP_SRLN = survey.interface_instr; mv.DIP_CLBD = gINTDateTime(survey.interface_cali_d_getDT()); } mv.FLO_SRLN = survey.purg_meter; mv.FLO_CLBD = gINTDateTime(survey.purg_meter_cali_d_getDT()); mv.GAS_SRLN = survey.gas_instr; mv.GAS_CLBD = gINTDateTime(survey.gas_cali_d_getDT()); mv.PID_SRLN = survey.PID_instr; mv.PID_CLBD = gINTDateTime(survey.PID_cali_d_getDT()); mv.RND_REF = survey.mon_rd_nb; mv.MONV_DATM = survey.dip_datum; mv.AIR_PRESS = survey.atmo_pressure; mv.AIR_TEMP = survey.atmo_temp; mv.PIPE_DIA = survey.pipe_diam; if (survey.dip_datum_offset != null) { mv.MONV_DIS = ((float)survey.dip_datum_offset.Value) / 100f; } mv.MONV_MENG = survey.Creator; MONV.Add(mv); // if (IgnoreDataRepeat_GlobalId.Contains(survey.globalid)) { // continue; // } if (survey.QA_status.Contains("Dip_Approved")) { AddDip(mg, survey); } if (survey.QA_status.Contains("Purge_Approved")) { AddPurge(mg, survey); } if (survey.QA_status.Contains("Gas_Approved")) { AddGas(mg, survey); } } return(MOND.Count()); }
public static void SeedLowerThamesCrossing(ge_DbContext context) { var manager1 = context.Users.Where(a => a.UserName == "*****@*****.**").Single(); var user1 = context.Users.Where(a => a.UserName == "*****@*****.**").Single(); var g1 = new ge_group { Id = Guid.NewGuid(), locName = "Lower Thames Crossing Ground Investigation", createdDT = DateTime.Now, locAddress = "", locPostcode = "", datumProjection = datumProjection.NONE, managerId = manager1.Id, operations = "Read;Update;Delete", project_operations = "Create;Read;Update;Delete", projects = new List <ge_project>(), users = new List <ge_user_ops>() }; g1.users.Add(new ge_user_ops { groupId = g1.Id, userId = manager1.Id, user_operations = "Read;Download;Create;Update;Delete;Approve;Admin" }); g1.users.Add(new ge_user_ops { groupId = g1.Id, userId = user1.Id, user_operations = "Read;Download;Create;Update;Delete" }); dbConnectDetails cd1 = new dbConnectDetails() { Type = gINTTables.DB_DATA_TYPE, Server = "EUDTC1PSQLW001", Database = "ltc_ags4", DataSource = "172.17.136.103", UserId = "ltc_ags4", Password = "******" }; #region CreateProjects var p1 = new ge_project { Id = Guid.NewGuid(), locName = "Lower Thames Crossing Package A", locAddress = "", locPostcode = "", description = "Monitoring Data for Lower Thames Crossing Package A", keywords = "", createdId = user1.Id, createdDT = DateTime.Now, editedId = user1.Id, editedDT = DateTime.Now, start_date = new DateTime(2017, 11, 15), pstatus = PublishStatus.Uncontrolled, cstatus = ConfidentialityStatus.RequiresClientApproval, datumProjection = datumProjection.NONE, managerId = manager1.Id, operations = "Read;Update;Delete", data_operations = "Read;Create;Update;Delete", data = new List <ge_data>(), users = new List <ge_user_ops>() }; p1.users.Add(new ge_user_ops { projectId = p1.Id, userId = manager1.Id, user_operations = "Create;Read;Update;Delete;Approve;Admin" }); p1.users.Add(new ge_user_ops { projectId = p1.Id, userId = user1.Id, user_operations = "Create;Read;Update;Delete" }); var p2 = new ge_project { Id = Guid.NewGuid(), locName = "Lower Thames Crossing Package B", locAddress = "", locPostcode = "", description = "Monitoring Data for Lower Thames Crossing Package B", createdId = user1.Id, createdDT = DateTime.Now, editedId = user1.Id, editedDT = DateTime.Now, keywords = "", start_date = new DateTime(2017, 11, 15), pstatus = PublishStatus.Uncontrolled, cstatus = ConfidentialityStatus.Owned, datumProjection = datumProjection.NONE, managerId = manager1.Id, operations = "Read;Update;Delete", data_operations = "Read;Update;Delete", data = new List <ge_data>(), users = new List <ge_user_ops>() }; p2.users.Add(new ge_user_ops { projectId = p1.Id, userId = manager1.Id, user_operations = "Create;Read;Update;Delete;Approve;Admin" }); p2.users.Add(new ge_user_ops { projectId = p1.Id, userId = user1.Id, user_operations = "Create;Read;Update;Delete" }); var p3 = new ge_project { Id = Guid.NewGuid(), locName = "Lower Thames Crossing Package C", locAddress = "", locPostcode = "", description = "Monitoring Data for Lower Thames Crossing Package C", createdId = user1.Id, createdDT = DateTime.Now, editedId = user1.Id, editedDT = DateTime.Now, keywords = "", start_date = new DateTime(2017, 11, 15), pstatus = PublishStatus.Uncontrolled, cstatus = ConfidentialityStatus.Owned, datumProjection = datumProjection.NONE, managerId = manager1.Id, operations = "Read;Update;Delete", data_operations = "Read;Update;Delete", data = new List <ge_data>(), users = new List <ge_user_ops>() }; p3.users.Add(new ge_user_ops { projectId = p3.Id, userId = manager1.Id, user_operations = "Create;Read;Update;Delete;Approve;Admin" }); p3.users.Add(new ge_user_ops { projectId = p3.Id, userId = user1.Id, user_operations = "Create;Read;Update;Delete" }); string folder = @"\\eu.aecomnet.com\euprojectvol\UKCRD1-TI\Projects\14\geotech1\Projects\Lower Thames Crossing\Package C\02 WIP\LTM Data Round0"; AddFile(p3, folder + "\\" + "Logger_Data 2019-11-14 to 2019-12-16.csv", user1); AddFile(p3, folder + "\\" + "Package B Round0 Long Term Monitoring data 2020-01-31.csv", user1); var p4 = new ge_project { Id = Guid.NewGuid(), locName = "Lower Thames Crossing Package D", locAddress = "", locPostcode = "", description = "Monitoring Data for Lower Thames Crossing Package D", createdId = user1.Id, createdDT = DateTime.Now, editedId = user1.Id, editedDT = DateTime.Now, keywords = "", start_date = new DateTime(2017, 11, 15), pstatus = PublishStatus.Uncontrolled, cstatus = ConfidentialityStatus.Owned, datumProjection = datumProjection.NONE, managerId = manager1.Id, operations = "Read;Update;Delete", data_operations = "Read;Update;Delete", data = new List <ge_data>(), users = new List <ge_user_ops>() }; p4.users.Add(new ge_user_ops { projectId = p4.Id, userId = manager1.Id, user_operations = "Create;Read;Update;Delete;Approve;Admin" }); p4.users.Add(new ge_user_ops { projectId = p4.Id, userId = user1.Id, user_operations = "Create;Read;Update;Delete" }); #endregion g1.projects.Add(p1); g1.projects.Add(p2); g1.projects.Add(p3); g1.projects.Add(p4); context.ge_group.Add(g1); context.SaveChanges(); }
public void insertProject(ge_project project) { }
public static bool DoesUserHaveOperation(this ge_DbContext context, string operation, ge_project project, string userId) { if (context == null || project == null || operation == null || userId == null) { return(false); } if (userId == String.Empty) { return(false); } bool retvar = false; ge_user_ops user_proj = null; ge_user_ops user_group = null; if (project.Id == Guid.Empty && operation == geOPS.Create.Name) { if (project.group == null) { return(false); } return(DoesUserHaveOperation(context, geOPS.Create.Name, project.group, userId)); } user_proj = context.ge_user_ops .AsNoTracking() .Where(p => p.userId == userId && p.projectId == project.Id).FirstOrDefault(); if (user_proj != null) { if (user_proj.user_operations.Contains(operation)) { retvar = true; } else { retvar = false; } } else { user_group = context.ge_user_ops .AsNoTracking() .Where(u => u.userId == userId && u.groupId == project.groupId).FirstOrDefault(); if (user_group.user_operations.Contains(operation)) { retvar = true; } else { retvar = false; } } return(retvar); }
public static int IsOperationAllowed(this ge_DbContext context, string operation, ge_project project, ge_transform transform) { if (context == null || transform == null || project == null || operation == String.Empty) { return(geOPSResp.InvalidInput); } // check project record status if (project.data_operations == null) { return(geOPSResp.ProjectData); } if (!project.data_operations.Contains(operation)) { return(geOPSResp.ProjectData); } if (operation == Constants.UpdateOperationName || operation == Constants.DeleteOperationName) { if (project.pstatus == Constants.PublishStatus.Approved) { return(geOPSResp.ProjectApproved); } } //Check data record status if (transform.Id == Guid.Empty) { return(geOPSResp.Allowed); } // if (operation == geOPS.Update || operation==geOPS.Delete) { // if (transform.pstatus == Constants.PublishStatus.Approved) { // return geOPSResp.DataApproved; // } // } if (transform.operations == null) { return(geOPSResp.Data); } if (!transform.operations.Contains(operation)) { return(geOPSResp.Data); } return(geOPSResp.Allowed); }
public static int IsOperationAllowed(this ge_DbContext context, string operation, ge_group group, ge_project project, ge_data data) { if (context == null || data == null || project == null || group == null || operation == String.Empty) { return(geOPSResp.InvalidInput); } // Check at group level; if (group.project_operations == null) { return(geOPSResp.GroupProject);; } if (!group.project_operations.Contains(operation)) { return(geOPSResp.GroupProject); } // check project record status if (project.data_operations == null) { return(geOPSResp.ProjectData); } if (!project.data_operations.Contains(operation)) { return(geOPSResp.ProjectData); } if (operation == Constants.UpdateOperationName || operation == Constants.DeleteOperationName) { if (project.pstatus == Constants.PublishStatus.Approved) { return(geOPSResp.ProjectApproved); } } //Check data record status if (data.Id == Guid.Empty) { return(geOPSResp.Allowed); } if (operation == Constants.UpdateOperationName || operation == Constants.DeleteOperationName) { if (data.pstatus == Constants.PublishStatus.Approved) { return(geOPSResp.DataApproved); } } if (data.operations == null) { return(geOPSResp.Data); } if (!data.operations.Contains(operation)) { return(geOPSResp.Data); } return(geOPSResp.Allowed); }
public static int IsOperationAllowed(this ge_DbContext context, string operation, ge_group group, ge_project project) { if (context == null || group == null || project == null || operation == String.Empty) { return(geOPSResp.InvalidInput); } // Check at group level; if (group.project_operations == null) { return(geOPSResp.GroupProject);; } if (!group.project_operations.Contains(operation)) { return(geOPSResp.GroupProject); } // Check for new project if (project.Id == Guid.Empty) { return(geOPSResp.Allowed); } // Check at project level if it is approved and cannot be edited or deleted if (operation == Constants.UpdateOperationName || operation == Constants.DeleteOperationName) { if (project.pstatus == Constants.PublishStatus.Approved) { return(geOPSResp.ProjectApproved); } } if (project.operations == null) { return(geOPSResp.Project); } if (!project.operations.Contains(operation)) { return(geOPSResp.Project); } return(geOPSResp.Allowed); }
public static void SeedDB(ge_DbContext context, string source) { if (context.ge_project.Any() && context.ge_data.Any()) { return; // DB has been seeded } try { #region snippit_CreateOffices var manager1 = context.Users.Where(user => user.UserName == "*****@*****.**").Single(); var user1 = context.Users.Where(user => user.UserName == "*****@*****.**").Single(); var g1 = new ge_group { Id = Guid.NewGuid(), locName = "Croydon", createdDT = DateTime.Now, locAddress = "Sunley House, 4 Bedford Park, Surrey, Croydon", locPostcode = "CR0 2AP", datumProjection = datumProjection.OSGB36NG, managerId = manager1.Id, operations = "Read;Update;Delete", project_operations = "Create;Read;Update;Delete", projects = new List <ge_project>(), users = new List <ge_user_ops>() }; g1.users.Add(new ge_user_ops { groupId = g1.Id, userId = manager1.Id, user_operations = "Read;Download;Create;Update;Delete;Approve;Admin" }); g1.users.Add(new ge_user_ops { groupId = g1.Id, userId = user1.Id, user_operations = "Read;Download;Create;Update;Delete" }); var manager2 = context.Users.Where(a => a.UserName == "*****@*****.**").Single(); var manager22 = context.Users.Where(a => a.UserName == "*****@*****.**").Single(); var user2 = context.Users.Where(a => a.UserName == "*****@*****.**").Single(); var g2 = new ge_group { Id = Guid.NewGuid(), locName = "Aldgate", createdDT = DateTime.Now, locAddress = "2 Leman Street, London", locPostcode = "E1 8FA", manager = manager2, datumProjection = datumProjection.OSGB36NG, operations = "Read;Update;Delete", project_operations = "Create;Read;Update;Delete", projects = new List <ge_project>(), users = new List <ge_user_ops>() }; g2.users.Add(new ge_user_ops { userId = manager2.Id, user_operations = "Create;Read;Update;Delete;Reject;Approve;Admin" }); g2.users.Add(new ge_user_ops { userId = user2.Id, user_operations = "Create;Read;Update;Delete" }); g2.users.Add(new ge_user_ops { userId = manager22.Id, user_operations = "Create;Read;Update;Delete;Admin" }); var manager3 = context.Users.Where(a => a.UserName == "*****@*****.**").Single(); var user3 = context.Users.Where(a => a.UserName == "*****@*****.**").Single(); var g3 = new ge_group { Id = Guid.NewGuid(), locName = "Chelmsford", createdDT = DateTime.Now, locAddress = "Saxon House, 27 Duke Street, Chelmsford", locPostcode = "CM1 1HT", managerId = manager3.Id, datumProjection = datumProjection.OSGB36NG, operations = "Read;Update;Delete", project_operations = "Create;Read;Update;Delete", projects = new List <ge_project>(), users = new List <ge_user_ops>() }; g3.users.Add(new ge_user_ops { userId = manager3.Id, operations = "Create;Read;Update;Delete;Reject;Approve;Admin" }); g3.users.Add(new ge_user_ops { userId = user3.Id, operations = "Create;Read;Update;Delete" }); var manager4 = context.Users.Where(a => a.UserName == "*****@*****.**").Single();; var user4 = context.Users.Where(a => a.UserName == "*****@*****.**").Single();; var g4 = new ge_group { Id = Guid.NewGuid(), locName = "Basingstoke", createdDT = DateTime.Now, locAddress = "Midpoint, Alencon Link, Hampshire, Basingstoke, ", locPostcode = "RG21 7PP", datumProjection = datumProjection.OSGB36NG, managerId = manager4.Id, operations = "Read;Update;Delete", project_operations = "Read;Update;Delete", projects = new List <ge_project>(), users = new List <ge_user_ops>() }; g4.users.Add(new ge_user_ops { userId = manager4.Id, operations = "Create;Read;Update;Delete;Reject;Approve;Admin" }); g4.users.Add(new ge_user_ops { userId = user4.Id, operations = "Create;Read;Update;Delete" }); #endregion #region CreateProjects var p1 = new ge_project { Id = Guid.NewGuid(), locName = "Burton Upon Trent SWWM Appraisal", locAddress = "Meadowside Drive, Burton, East Staffordshire, Staffordshire, West", locPostcode = "DE14 1LD", description = "Ground Investigation Data for Burton SWWM", createdId = user1.Id, keywords = " ", start_date = new DateTime(2017, 11, 15), createdDT = DateTime.Now, pstatus = PublishStatus.Uncontrolled, cstatus = ConfidentialityStatus.ClientApproved, locEast = 425388, locNorth = 323033, datumProjection = datumProjection.OSGB36NG, managerId = manager1.Id, operations = "Read;Update;Delete", data_operations = "Read;Create;Update;Delete", data = new List <ge_data>(), users = new List <ge_user_ops>() }; p1.users.Add(new ge_user_ops { projectId = p1.Id, userId = manager1.Id, user_operations = "Create;Read;Update;Delete;Approve;Admin" }); p1.users.Add(new ge_user_ops { projectId = p1.Id, userId = user1.Id, user_operations = "Create;Read;Update;Delete" }); p1.data.Add(new ge_data { createdId = user1.Id, createdDT = DateTime.Now, filename = "E7037A_Burton SWWM_Final Factual Report AGS4.ags", fileext = ".ags", filetype = "text/plain", filesize = 948423, filedate = new DateTime(2018, 06, 28), locEast = 425388.43, locNorth = 323032.67, pstatus = PublishStatus.Uncontrolled, cstatus = ConfidentialityStatus.ClientApproved, version = "P01.1", vstatus = VersionStatus.Intermediate, qstatus = QualitativeStatus.AECOMFactual, description = "AGS data downloaded from BGS website", operations = "Read;Update;Delete", file = new ge_data_file { data_string = File.ReadAllText(source + @"\E7037A_Burton SWWM\E7037A_Burton SWWM_Final Factual Report AGS4.ags") } } ); var p11 = new ge_project { Id = Guid.NewGuid(), name = "AGS Dictionary", description = "Developement of AGS Reference Dictionary for converting from AGS to XML and SQL data formats", createdId = user1.Id, keywords = "ags, xml ", start_date = new DateTime(2017, 11, 15), createdDT = DateTime.Now, pstatus = PublishStatus.Approved, cstatus = ConfidentialityStatus.Owned, locEast = 529565, locNorth = 177615, datumProjection = datumProjection.OSGB36NG, managerId = manager1.Id, operations = "Read;Update;Delete", data_operations = "Read;Update;Delete", data = new List <ge_data>(), users = new List <ge_user_ops>() }; p11.users.Add(new ge_user_ops { projectId = p1.Id, userId = manager1.Id, user_operations = "Create;Read;Update;Delete;Approve;Admin" }); p11.users.Add(new ge_user_ops { projectId = p1.Id, userId = user1.Id, user_operations = "Create;Read;Update;Delete" }); p11.data.Add(new ge_data { createdId = user1.Id, createdDT = DateTime.Now, filename = "DictionaryAgsml_0.0.14.xml", fileext = ".xml", filetype = "text/plain", filesize = 948423, filedate = new DateTime(2018, 06, 28), locEast = 425388.43, locNorth = 323032.67, pstatus = PublishStatus.Approved, cstatus = ConfidentialityStatus.Owned, version = "P01.1", vstatus = VersionStatus.Final, qstatus = QualitativeStatus.AECOMFactual, description = "AGS data dictionary", operations = "Read;Update;Delete", file = new ge_data_file { data_string = File.ReadAllText(source + @"\AGS Dictionary\DictionaryAgsml_0.0.14.xml") } } ); p11.data.Add(new ge_data { createdId = user1.Id, createdDT = DateTime.Now, filename = "DictionaryAgsml.xsl", fileext = ".xsl", filetype = "text/plain", filesize = 2582, filedate = new DateTime(2018, 06, 28), locEast = 425388.43, locNorth = 323032.67, pstatus = PublishStatus.Approved, cstatus = ConfidentialityStatus.Owned, version = "P01.1", vstatus = VersionStatus.Final, qstatus = QualitativeStatus.AECOMFactual, description = "AGS xml data template", operations = "Read;Update;Delete", file = new ge_data_file { data_string = File.ReadAllText(source + @"\AGS Dictionary\DictionaryAgsml.xsl") } } ); var p2 = new ge_project { name = "Tideway C410 HEAPS", description = "Ground Invetsigation Data close to the CSO shaft HEAPS", createdId = user2.Id, keywords = "London Clay;London Basin;Lambeth Group;Pressuremeter;Small Strain", start_date = new DateTime(2017, 11, 15), createdDT = DateTime.Now, pstatus = PublishStatus.Uncontrolled, cstatus = ConfidentialityStatus.ClientApproved, locEast = 529565, locNorth = 177615, managerId = manager2.Id, operations = "Read;Update;Delete", data_operations = "Read;Update;Delete", data = new List <ge_data>(), users = new List <ge_user_ops>() }; p2.users.Add(new ge_user_ops { projectId = p2.Id, userId = manager2.Id, user_operations = "Create;Read;Update;Delete;Reject;Approve;Admin" }); p2.users.Add(new ge_user_ops { projectId = p2.Id, userId = user2.Id, user_operations = "Create;Read;Update;Delete" }); p2.users.Add(new ge_user_ops { projectId = p2.Id, userId = manager22.Id, user_operations = "Create;Read;Update;Delete;Approve;Admin" }); p2.data.Add(new ge_data { createdId = user2.Id, createdDT = DateTime.Now, filename = "heaps_boreholes_3d_03-Geological Plan2.pdf", fileext = ".pdf", filetype = "application/pdf", filesize = 2177973, filedate = new DateTime(2018, 06, 28), locEast = 425388.43, locNorth = 323032.67, pstatus = PublishStatus.Uncontrolled, cstatus = ConfidentialityStatus.ClientApproved, version = "P01.1", vstatus = VersionStatus.Intermediate, qstatus = QualitativeStatus.AECOMFactual, description = "Surfaces created from gINT Civil Tools for HEAPS", operations = "Read;Update;Delete", file = new ge_data_file { data_binary = File.ReadAllBytes(source + @"\Tideway HEAPS\heaps_boreholes_3d_03-Geological Plan.pdf") } } ); p2.data.Add(new ge_data { createdId = user2.Id, createdDT = DateTime.Now, filename = "4602-FLOJV-HEAPS-180-GG-MD-900001.gpj", fileext = ".gpj", filetype = "application/gINT", filesize = 19427328, filedate = new DateTime(2018, 06, 28), locEast = 425388.43, locNorth = 323032.67, pstatus = PublishStatus.Uncontrolled, cstatus = ConfidentialityStatus.ClientApproved, version = "P01.1", vstatus = VersionStatus.Intermediate, qstatus = QualitativeStatus.AECOMFactual, description = "Tideway database exports of gINT database for HEAPS local GI data", operations = "Read;Update;Delete", file = new ge_data_file { data_binary = File.ReadAllBytes(source + @"\Tideway HEAPS\4602-FLOJV-HEAPS-180-GG-MD-900001.gpj") } } ); var p3 = new ge_project { locName = "Ryhad Metro", name = "Ryad Metro", description = "Bridge 1-5 1A1P30", createdId = user3.Id, keywords = "Rock sockets", start_date = new DateTime(2018, 06, 15), createdDT = DateTime.Now, pstatus = PublishStatus.Uncontrolled, cstatus = ConfidentialityStatus.ClientApproved, datumProjection = datumProjection.OSGB36NG, operations = "Read;Update;Delete", data_operations = "Read;Update;Delete", data = new List <ge_data>(), users = new List <ge_user_ops>() }; p3.users.Add(new ge_user_ops { projectId = p3.Id, userId = manager3.Id, user_operations = "Create;Read;Update;Delete;Reject;Approve;Admin" }); p3.users.Add(new ge_user_ops { projectId = p3.Id, userId = user3.Id, user_operations = "Create;Read;Update;Delete" }); p3.data.Add(new ge_data { createdId = user3.Id, createdDT = DateTime.Now, filename = "M-BD4-1A1VDA-CSVD-EDR-100532_Updated with Orientation.dwg", fileext = ".dwg", filetype = "application/autocad", filesize = 19427328, filedate = new DateTime(2018, 06, 28), locEast = 425388.43, locNorth = 323032.67, pstatus = PublishStatus.Uncontrolled, cstatus = ConfidentialityStatus.ClientApproved, version = "P01.1", vstatus = VersionStatus.Intermediate, qstatus = QualitativeStatus.AECOMFactual, description = "Tideway database exports of gINT database for HEAPS local GI data", operations = "Read;Update;Delete", file = new ge_data_file { data_binary = File.ReadAllBytes(source + @"\Ryhad Metro\M-BD4-1A1VDA-CSVD-EDR-100532_Updated with Orientation.dwg") } }); p3.data.Add(new ge_data { createdId = user3.Id, createdDT = DateTime.Now, filename = "1A1P30 and 1A1P31 Plaxis Embedded Pile Results 2017-03-09.xlsx", fileext = ".xls", filetype = "application/excel", filesize = 19427328, filedate = new DateTime(2018, 06, 28), locEast = 425388.43, locNorth = 323032.67, pstatus = PublishStatus.Uncontrolled, cstatus = ConfidentialityStatus.ClientApproved, version = "P01.1", vstatus = VersionStatus.Intermediate, qstatus = QualitativeStatus.AECOMFactual, description = "Results from Plaxis Analysis", operations = "Read;Update;Delete", file = new ge_data_file { data_binary = File.ReadAllBytes(source + @"\Ryhad Metro\1A1P30 and 1A1P31 Plaxis Embedded Pile Results 2017-03-09.xlsx") } } ); var p31 = new ge_project { locName = "Silvertown Tunnel", name = "Silvertown Tunnel Development Tender Phase", description = "Tender design for Silvertown Tunnel", createdId = user3.Id, keywords = "Road Tunnel;Lambeth Group;London;Infrastructure;", start_date = new DateTime(2018, 06, 15), createdDT = DateTime.Now, pstatus = PublishStatus.Uncontrolled, cstatus = ConfidentialityStatus.ClientApproved, operations = "Read;Update;Delete", data_operations = "Read;Update;Delete", data = new List <ge_data>(), users = new List <ge_user_ops>() }; p31.users.Add(new ge_user_ops { projectId = p3.Id, userId = manager3.Id, user_operations = "Create;Read;Update;Delete;Reject;Approve;Admin" }); p31.users.Add(new ge_user_ops { projectId = p3.Id, userId = user3.Id, user_operations = "Create;Read;Update;Delete" }); p31.data.Add(new ge_data { createdId = user3.Id, createdDT = DateTime.Now, filename = "20110770 - 2016-03-03 1540 - Final - 2.ags", fileext = ".ags", filetype = "text/plain", filesize = 19787, filedate = new DateTime(2018, 06, 28), locEast = 425388.43, locNorth = 323032.67, pstatus = PublishStatus.Approved, cstatus = ConfidentialityStatus.RequiresClientApproval, version = "P01.1", folder = "tender-data", vstatus = VersionStatus.Final, qstatus = QualitativeStatus.ThirdPartyFactual, description = "Silvertown AGS data recieved at tender", operations = "Read;Update;Delete", file = new ge_data_file { data_binary = File.ReadAllBytes(source + @"\Silvertown Tunnel\20110770 - 2016-03-03 1540 - Final - 2.ags") } } ); p31.data.Add(new ge_data { createdId = user3.Id, createdDT = DateTime.Now, filename = "TA7510F17.ags", fileext = ".ags", filetype = "text/plain", filesize = 8479000, filedate = new DateTime(2018, 06, 28), locEast = 425388.43, locNorth = 323032.67, pstatus = PublishStatus.Approved, cstatus = ConfidentialityStatus.RequiresClientApproval, version = "P01.1", folder = "tender_data", vstatus = VersionStatus.Final, qstatus = QualitativeStatus.ThirdPartyFactual, description = "Silvertown additional AGS data recieved at tender", operations = "Read;Update;Delete", file = new ge_data_file { data_binary = File.ReadAllBytes(source + @"\Silvertown Tunnel\TA7510F17.ags") } } ); p31.data.Add(new ge_data { createdId = user3.Id, createdDT = DateTime.Now, filename = "SilvertownGI.xml", fileext = ".xml", filetype = "text/plain", filesize = 5653000, filedate = new DateTime(2018, 06, 28), locEast = 425388.43, locNorth = 323032.67, pstatus = PublishStatus.Approved, cstatus = ConfidentialityStatus.RequiresClientApproval, version = "P01.1", folder = "tender_data", vstatus = VersionStatus.Final, qstatus = QualitativeStatus.ThirdPartyFactual, description = "Silvertown additional AGS data recieved at tender", operations = "Read;Update;Delete", file = new ge_data_file { data_binary = File.ReadAllBytes(source + @"\Silvertown Tunnel\SilvertownGI.xml") } } ); var p4 = new ge_project { locName = "West Midlands to Crewe", name = "High Speed 2 Package 2A", description = "Historic Ground Investigation Data fro HS2 Package 2A", createdId = user4.Id, keywords = "Mercia Mudstone;Earthworks;Monitoring", start_date = new DateTime(2018, 06, 15), createdDT = DateTime.Now, pstatus = PublishStatus.Uncontrolled, cstatus = ConfidentialityStatus.ClientApproved, data = new List <ge_data>(), users = new List <ge_user_ops>(), operations = "Read;Update;Delete", data_operations = "Read;Update;Delete" }; p4.users.Add(new ge_user_ops { projectId = p4.Id, userId = manager4.Id, user_operations = "Create;Read;Update;Delete;Reject;Approve;Admin" }); p4.users.Add(new ge_user_ops { projectId = p4.Id, userId = user4.Id, user_operations = "Create;Read;Update;Delete" }); p4.data.Add(new ge_data { filename = "HS2 PH2B AGS EXPORT 2018-12-18.ags", fileext = ".ags", filetype = "text/plain", createdId = user4.Id, createdDT = DateTime.Now, filesize = 2183000, filedate = new DateTime(2018, 06, 28), locEast = 425388.43, locNorth = 323032.67, pstatus = PublishStatus.Approved, cstatus = ConfidentialityStatus.RequiresClientApproval, version = "P01.1", vstatus = VersionStatus.Intermediate, qstatus = QualitativeStatus.ThirdPartyFactual, description = "Routewide historical borehole data compiled from BGS", operations = "Read;Update;Delete", file = new ge_data_file { data_binary = File.ReadAllBytes(source + @"\HS2\HS2 PH2B AGS EXPORT 2018-12-18.ags") } } ); #endregion #region AddProjectsToOffices g1.projects.Add(p1); g1.projects.Add(p11); g2.projects.Add(p2); g3.projects.Add(p3); g3.projects.Add(p31); g4.projects.Add(p4); context.ge_group.Add(g1); context.ge_group.Add(g2); context.ge_group.Add(g3); context.ge_group.Add(g4); // var user5 = context.Users.Where(a => a.UserName=="*****@*****.**").Single(); // var admin = context.Users.Where(a => a.UserName=="*****@*****.**").Single(); context.SaveChanges(); #endregion } catch (Exception e) { Console.WriteLine(e.Message); } }
public void updateProject(ge_project project) { }
public async Task <IActionResult> CreateGIS(Guid projectId, string format) { if (projectId == null) { return(NotFound()); } if (format == null) { return(NotFound()); } project = await _context.ge_project .Include(p => p.data) .FirstAsync(p => p.Id == projectId); if (project == null) { return(NotFound()); } var user = await GetUserAsync(); if (user != null) { return(RedirectToPageMessage(msgCODE.USER_NOTFOUND)); } var new_data = new ge_data(); int IsCreateAllowed = _context.IsOperationAllowed(Constants.CreateOperationName, project, new_data); Boolean CanUserCreate = _context.DoesUserHaveOperation(Constants.CreateOperationName, project, user.Id); if (IsCreateAllowed != geOPSResp.Allowed) { return(RedirectToPageMessage(msgCODE.DATA_CREATE_PROHIBITED)); } if (!CanUserCreate) { return(RedirectToPageMessage(msgCODE.DATA_CREATE_USER_PROHIBITED)); } string data_string = ""; switch (format.ToLower()) { case "kml": data_string = createKML(project); break; case "shp": data_string = createSHP(); break; case "xml": data_string = createXML(project); break; default: return(RedirectToPageMessage(msgCODE.GIS_UNEXPECTEDFORMAT)); } if (String.IsNullOrEmpty(data_string)) { return(RedirectToPageMessage(msgCODE.GIS_CREATE_UNSUCCESSFULL)); } string filename = project.name; saveGISFile(projectId, filename, user.Id, data_string, "." + format.ToLower()); return(RedirectToPage("/Data/Index", new { projectId = projectId })); }