internal void AddProfileToList(ProfileSession profile)
        {
            bool isAddToGraphics = false;

            isAddToGraphics = View.AddNodeToTreeView(profile);

            //Add Profile to the working list
            _workingProfiles.Add(profile);

            //Add graphics
            if (isAddToGraphics)
            {
                var spatialReference = ArcMap.Document.FocusMap.SpatialReference;

                if (profile.DefinitionType == ProfileSettingsTypeEnum.Primitives)
                {
                    profile.Segments = ProfileLinesConverter.GetSegmentsFromProfileLine(profile.ProfileSurfaces, spatialReference);
                    GraphicsLayerManager.AddLinesToWorkingGraphics(ProfileLinesConverter.ConvertLineToPrimitivePolylines(profile.ProfileSurfaces[0],
                                                                                                                         spatialReference),
                                                                   profile.SessionId,
                                                                   profile.Segments.First());
                }
                else
                {
                    profile.SetSegments(spatialReference);
                    GraphicsLayerManager.AddLinesToWorkingGraphics(ProfileLinesConverter.ConvertSolidGroupedLinesToEsriPolylines(profile.Segments, spatialReference),
                                                                   profile.SessionId);
                }
            }

            GraphicsLayerManager.EmptyProfileGraphics(MilSpaceGraphicsTypeEnum.Calculating);
        }
        /// <summary>
        /// Do Actions to generate profile(s), save them and set properties to default values
        /// </summary>
        /// <returns>Profile Session data</returns>
        internal ProfileSession GenerateProfile()
        {
            string errorMessage;

            try
            {
                ProfileManager manager        = new ProfileManager();
                var            profileSetting = profileSettings[View.SelectedProfileSettingsType];
                var            newProfileId   = GenerateProfileId();
                logger.InfoEx($"Profile {newProfileId}. Generation started");
                var newProfileName = GenerateProfileName(newProfileId);

                var session = manager.GenerateProfile(profileSetting.DemLayerName, profileSetting.ProfileLines, View.SelectedProfileSettingsType, newProfileId, newProfileName, View.ObserveHeight, profileSetting.AzimuthToStore);
                logger.InfoEx($"Profile {newProfileId}. Generated");

                if (session.DefinitionType == ProfileSettingsTypeEnum.Primitives)
                {
                    session.Segments = ProfileLinesConverter.GetSegmentsFromProfileLine(session.ProfileSurfaces, ArcMap.Document.FocusMap.SpatialReference);
                }
                else
                {
                    session.SetSegments(ArcMap.Document.FocusMap.SpatialReference);
                }

                SetPeofileId();
                SetProfileName();
                return(session);
            }
            catch (MilSpaceCanotDeletePrifileCalcTable ex)
            {
                //TODO Localize error message
                errorMessage = ex.Message;
            }
            catch (MilSpaceDataException ex)
            {
                //TODO Localize error message
                errorMessage = ex.Message;
            }
            catch (Exception ex)
            {
                //TODO log error
                //TODO Localize error message
                errorMessage = ex.Message;
            }

            MessageBox.Show(errorMessage);
            return(null);
        }
        internal void CallGraphsHandle(int profileSessionId)
        {
            var profileSession = GetProfileSessionById(profileSessionId);

            if (profileSession != null)
            {
                if (_workingProfiles.FirstOrDefault(profile => profile.SessionId == profileSession.SessionId) != null)
                {
                    _workingProfiles.Remove(_workingProfiles.FirstOrDefault(profile => profile.SessionId == profileSession.SessionId));
                }
                _workingProfiles.Add(profileSession);

                if (profileSession.DefinitionType == ProfileSettingsTypeEnum.Primitives)
                {
                    profileSession.Segments = ProfileLinesConverter.GetSegmentsFromProfileLine(profileSession.ProfileSurfaces, ArcMap.Document.FocusMap.SpatialReference);
                }
                else
                {
                    profileSession.SetSegments(ArcMap.Document.FocusMap.SpatialReference);
                }
                CallGraphsHandle(profileSession);
            }
        }