private void SetAccessibleProfilesSets(List <ProfileSession> userSession, ISpatialReference spatialReference) { var currentSessionProfiles = new List <ProfileSession>(userSession); var allAccessibleProfilesSets = MilSpaceProfileFacade.GetAvaibleProfileSessions().ToList(); var notInCurrentSessionProfilesSet = new List <ProfileSession>(allAccessibleProfilesSets.Count); foreach (var set in allAccessibleProfilesSets) { var currentSessionSet = currentSessionProfiles.FirstOrDefault(session => session.SessionId == set.SessionId); if (currentSessionSet != null) { currentSessionProfiles.Remove(currentSessionSet); } else { notInCurrentSessionProfilesSet.Add(set); } } notInCurrentSessionProfilesSet.ForEach(session => { session.ConvertLinesToEsriPolypile(spatialReference); }); _accessibleProfilesSets = notInCurrentSessionProfilesSet.ToArray(); }
private ProfileSession GetProfileSessionById(int profileId) { var profile = MilSpaceProfileFacade.GetProfileSessionById(profileId); profile.ConvertLinesToEsriPolypile(View.ActiveView.FocusMap.SpatialReference); return(profile); }
internal TreeViewModel ParseUserProfileSessions() { var result = new TreeViewModel(); var userProfileSessions = MilSpaceProfileFacade.GetUserProfileSessions(); foreach (var profileSession in userProfileSessions) { var model = new TreeViewNodeModel { Name = profileSession.SessionName, Guid = Guid.NewGuid(), NodeProfileSession = profileSession }; AddChildCollection(model, profileSession); if (profileSession.DefinitionType == ProfileSettingsTypeEnum.Points) { result.Lines.Add(model); } if (profileSession.DefinitionType == ProfileSettingsTypeEnum.Fun) { result.Funs.Add(model); } if (profileSession.DefinitionType == ProfileSettingsTypeEnum.Primitives) { result.Primitives.Add(model); } } return(result); }
internal bool CanEraseProfileSession(int profileSession) { if (profileSession < 0) { return(false); } return(MilSpaceProfileFacade.CanEraseProfileSessions(profileSession));; }
internal void InitiateUserProfiles() { MilSpaceProfileFacade.GetUserProfileSessions().ToList().ForEach(p => { p.ConvertLinesToEsriPolypile(View.ActiveView.FocusMap.SpatialReference); AddProfileToList(p); } ); OnDocumentsLoad(); }
/// <summary> /// Insert or Update the profile set in DB /// </summary> /// <param name="profileSet"></param> internal bool SaveProfileSet(ProfileSession profileSet) { //Write to DB bool res = MilSpaceProfileFacade.SaveProfileSession(profileSet); if (!res) { MessageBox.Show(LocalizationConstants.ErrorOnDataAccessTextMessage, "MilSpace", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(res); }
private ProfileSession GetProfileSessionById(int profileId) { var profile = MilSpaceProfileFacade.GetProfileSessionById(profileId); profile.ConvertLinesToEsriPolypile(View.ActiveView.FocusMap.SpatialReference); if (profile.DefinitionType == ProfileSettingsTypeEnum.Primitives) { profile.SetSegments(View.ActiveView.FocusMap.SpatialReference); } return(profile); }
internal void AddAvailableSets() { var accessibleProfilesSetsModalWindow = new AccessibleProfilesModalWindow(_workingProfiles, ArcMap.Document.FocusMap.SpatialReference); var dialogResult = accessibleProfilesSetsModalWindow.ShowDialog(); if (dialogResult == DialogResult.OK) { var profilesSets = accessibleProfilesSetsModalWindow.SelectedProfilesSets; foreach (var set in profilesSets) { AddProfileToList(set); MilSpaceProfileFacade.SaveUserSession(set.SessionId); } } }
internal bool RemoveProfilesFromUserSession(bool eraseFromDB = false) { var result = MilSpaceProfileFacade.DeleteUserSessions(View.SelectedProfileSessionIds.ProfileSessionId); if (result) { if (eraseFromDB) { result = result && MilSpaceProfileFacade.EraseProfileSessions(View.SelectedProfileSessionIds.ProfileSessionId); } _workingProfiles.Remove(_workingProfiles.First(session => session.SessionId == View.SelectedProfileSessionIds.ProfileSessionId)); MilSpaceProfileGraphsController.RemoveTab(View.SelectedProfileSessionIds.ProfileSessionId); GraphicsLayerManager.RemoveGraphic(View.SelectedProfileSessionIds.ProfileSessionId); return(View.RemoveTreeViewItem()); } return(true); }
public ProfileSession GenerateProfile( string profileSource, IEnumerable <IPolyline> profileLines, ProfileSettingsTypeEnum profileSettingsTypeEnum, int sessionId, string sessionName) { string profileSourceName = GdbAccess.Instance.AddProfileLinesToCalculation(profileLines); var action = new ActionParam <string>() { ParamName = ActionParamNamesCore.Action, Value = ActionsEnum.bsp.ToString() }; string sdtnow = MilSpace.DataAccess.Helper.GetTemporaryNameSuffix(); var resuTable = $"{MilSpaceConfiguration.ConnectionProperty.TemporaryGDBConnection}\\StackProfile{sdtnow}"; var profileLineFeatureClass = GdbAccess.Instance.GetProfileLinesFeatureClass(profileSourceName); var prm = new List <IActionParam> { action, new ActionParam <string>() { ParamName = ActionParameters.FeatureClass, Value = profileLineFeatureClass }, new ActionParam <string>() { ParamName = ActionParameters.ProfileSource, Value = profileSource }, new ActionParam <string>() { ParamName = ActionParameters.DataWorkSpace, Value = resuTable }, new ActionParam <string>() { ParamName = ActionParameters.OutGraphName, Value = "" } }; var procc = new ActionProcessor(prm); var res = procc.Process <BoolResult>(); if (!res.Result) { if (res.Exception != null) { throw res.Exception; } //TODO: Log error throw new Exception(res.ErrorMessage); } //Take the table and import the data ISpatialReference currentSpatialreference = profileLines.First().SpatialReference; try { ITable profiletable = GdbAccess.Instance.GetProfileTable($"StackProfile{sdtnow}"); IFeatureClass lines = GdbAccess.Instance.GetCalcProfileFeatureClass(profileSourceName); IQueryFilter queryFilter = new QueryFilter() { WhereClause = WhereAllRecords }; ICursor featureCursor = profiletable.Search(queryFilter, true); IRow profileRow; int distanceFld = profiletable.FindField(FIRST_DIST_Field); int zFld = profiletable.FindField(FIRST_Z_Field); int idFld = profiletable.FindField(LINE_ID_Field); List <ProfileSurface> profileSurfaces = new List <ProfileSurface>(); ProfileSession session = new ProfileSession() { ProfileSurfaces = profileSurfaces.ToArray(), ProfileLines = GetProfileLines(lines).ToArray(), SessionId = sessionId, SessionName = sessionName, DefinitionType = profileSettingsTypeEnum }; Dictionary <int, List <ProfileSurfacePoint> > surface = new Dictionary <int, List <ProfileSurfacePoint> >(); int curLine = -1; IPolyline line = null; IPoint firstPoint = null; while ((profileRow = featureCursor.NextRow()) != null) { int lineId = Convert.ToInt32(profileRow.Value[idFld]); var profileLine = session.ProfileLines.FirstOrDefault(l => l.Id == lineId); if (profileLine == null) { throw new MilSpaceProfileLineNotFound(lineId, profileLineFeatureClass); } List <ProfileSurfacePoint> points; if (!surface.ContainsKey(lineId)) { points = new List <ProfileSurfacePoint>(); surface.Add(lineId, points); } else { points = surface[lineId]; } if (curLine != lineId) { curLine = lineId; line = lines.GetFeature(profileLine.Id).Shape as IPolyline; firstPoint = line.FromPoint; } var profilePoint = EsriTools.GetPointFromAngelAndDistance(firstPoint, profileLine.Angel, (double)profileRow.Value[distanceFld]); profilePoint.Project(EsriTools.Wgs84Spatialreference); points.Add(new ProfileSurfacePoint { Distance = (double)profileRow.Value[distanceFld], Z = (double)profileRow.Value[zFld], X = profilePoint.X, Y = profilePoint.Y }); } //TODO: Clean memo using Marhsaling IRow session.ProfileSurfaces = surface.Select(r => new ProfileSurface { LineId = r.Key, ProfileSurfacePoints = r.Value.ToArray() } ).ToArray(); //Write to DB if (!MilSpaceProfileFacade.SaveProfileSession(session)) { return(null); } return(session); } catch (MilSpaceDataException ex) { //TODO: Log error throw ex; } catch (Exception ex) { //TODO: Log error throw ex; } }