Ejemplo n.º 1
0
 public static void MapObjToDto(Session obj, SessionDto dto)
 {
     dto.Name = obj.Name;
       foreach (var doc in obj.GetDocuments())
       {
     var dtoDoc = new SessionDocumentDto();
     DtoMapper.MapObjToDto(doc, dtoDoc);
     dto.Documents.Add(dtoDoc);
       }
 }
Ejemplo n.º 2
0
        public void ConfigureForSaveAs(IEnumerable <SessionDto> currentSessions)
        {
            dataGridView1.DataSource = currentSessions;
            _currentSessions         = currentSessions;

            dataGridView1.MultiSelect = false;
            dataGridView1.RowEnter   += rowEnter;

            labelExtra.Text = "Save the current session as:";

            textNewSessionName.TextChanged += textChanged;
            labelHeader.Text = "Double-click an existing session to replace it";

            buttonOk.Text = STR_SaveAs_OkButton;

            textNewSessionName.Visible = true;
            labelExtra.Visible         = true;
            labelName.Visible          = true;

            _saveAsMode = true;

            buttonOk.Click += (sender, e) =>
            {
                try
                {
                    var session = _currentSessions.FirstOrDefault(s => s.Name.Equals(textNewSessionName.Text.Trim(), StringComparison.OrdinalIgnoreCase));
                    if (session != null)
                    {
                        if (!_settings.DsmSettings.AskConfirmationOnSaveAs || AskForConfirmation("Session '{0}' will be replaced, do you want to continue?", session.Name))
                        {
                            _result.Add(session);
                            Close();
                        }
                    }
                    else
                    {
                        var newSession = new SessionDto {
                            Name = textNewSessionName.Text.Trim()
                        };
                        if (!_settings.DsmSettings.AskConfirmationOnSaveAs || AskForConfirmation("Session '{0}' will be saved, do you want to continue?", newSession.Name))
                        {
                            _result.Add(newSession);
                            Close();
                        }
                    }
                }
                catch (Exception ex)
                {
                    _exceptionManager.HandleException(ex);
                }
            };
        }
Ejemplo n.º 3
0
        private static List <SessionDto> getSessionDtoList(IEnumerable <Session> sessionList)
        {
            var dtoList = new List <SessionDto>();

            foreach (var obj in sessionList)
            {
                var dto = new SessionDto();
                DtoMapper.MapObjToDto(obj, dto);
                dtoList.Add(dto);
            }

            return(dtoList);
        }
Ejemplo n.º 4
0
        public void LoadSession()
        {
            IList <SessionDto> dtoList    = getSessionDtoList(_sessionManager.GetSessions());
            SessionDto         sessionDto = _viewAdapter.GetSessionForLoading(dtoList);

            if (sessionDto != null)
            {
                Session session = _sessionManager.GetSession(sessionDto.Name);
                _sessionManager.CurrentSession = session;
                _selectedSessionName           = session.Name;
                LoadDocumentsFromSession(session);
            }
        }
Ejemplo n.º 5
0
        public void TestSessionMapObjToDto()
        {
            var session = new Session("session");
              var sessionDocument = new SessionDocument("path", DocumentType.Designer);
              session.AddDocument(sessionDocument);

              var sessionDto = new SessionDto();

              DtoMapper.MapObjToDto(session, sessionDto);

              Assert.AreEqual(session.Name, sessionDto.Name);

              Assert.AreEqual(session.GetDocuments().Count(), sessionDto.DocumentsCount);

              Assert.AreEqual(sessionDocument.Path, sessionDto.Documents[0].Path);
              Assert.AreEqual(sessionDocument.Type, sessionDto.Documents[0].Type);
        }
Ejemplo n.º 6
0
        public void ConfigureForSaveAs(IEnumerable<SessionDto> currentSessions)
        {
            dataGridView1.DataSource = currentSessions;
              _currentSessions = currentSessions;

              dataGridView1.MultiSelect = false;
              dataGridView1.RowEnter += rowEnter;

              labelExtra.Text = "Save the current session as:";

              textNewSessionName.TextChanged += textChanged;
              labelHeader.Text = "Double-click an existing session to replace it";

              buttonOk.Text = STR_SaveAs_OkButton;

              textNewSessionName.Visible = true;
              labelExtra.Visible = true;
              labelName.Visible = true;

              _saveAsMode = true;

              buttonOk.Click += (sender, e) =>
              {
            try
            {
              var session = _currentSessions.FirstOrDefault(s => s.Name.Equals(textNewSessionName.Text.Trim(), StringComparison.OrdinalIgnoreCase));
              if (session != null)
              {
            if (!_settings.DsmSettings.AskConfirmationOnSaveAs || AskForConfirmation("Session '{0}' will be replaced, do you want to continue?", session.Name))
            {
              _result.Add(session);
              Close();
            }
              }
              else
              {
            var newSession = new SessionDto { Name = textNewSessionName.Text.Trim() };
            if (!_settings.DsmSettings.AskConfirmationOnSaveAs || AskForConfirmation("Session '{0}' will be saved, do you want to continue?", newSession.Name))
            {
              _result.Add(newSession);
              Close();
            }
              }
            }
            catch (Exception ex)
            {
              _exceptionManager.HandleException(ex);
            }
              };
        }
Ejemplo n.º 7
0
        private static List<SessionDto> getSessionDtoList(IEnumerable<Session> sessionList)
        {
            var dtoList = new List<SessionDto>();

              foreach (var obj in sessionList)
              {
            var dto = new SessionDto();
            DtoMapper.MapObjToDto(obj, dto);
            dtoList.Add(dto);
              }

              return dtoList;
        }