Esempio n. 1
0
 public Control New()
 {
     return(Wrap(new MasterDto
     {
         Name = SessionDao.NewName()
     }));
 }
Esempio n. 2
0
        private void ExportSelectedToolStripButton_Click(object sender, EventArgs e)
        {
            var selectedPage = tabControl.SelectedTab;

            if (selectedPage == null)
            {
                return;
            }

            var fd = new SaveFileDialog
            {
                Title            = "Export to SharpMaster File",
                Filter           = "LiteDB Files (*.SharpMaster)|*.SharpMaster",
                OverwritePrompt  = true,
                RestoreDirectory = true
            };

            if (fd.ShowDialog() == DialogResult.OK)
            {
                var session = new SessionSettings();
                var list    = new List <SessionSettings>();
                list.Add(session);
                GetSettings(selectedPage, session);
                var dao = new SessionDao(fd.FileName);
                dao.Save(list);
            }
        }
Esempio n. 3
0
        public MainForm(string dbPath = null)
        {
            sessionDao = new SessionDao(dbPath);

            InitializeComponent();

            toolStripStatusLabel.Text = sessionDao.DbPath;
        }
Esempio n. 4
0
 public ISessionDto[] Load(string path)
 {
     SessionDao.Exec(path, (db) =>
     {
         if (TabsTools.IsDebug())
         {
             //force migration
             db.Engine.UserVersion = 0;
         }
         //migration
         if (db.Engine.UserVersion < 1)
         {
             var assy = typeof(MasterDto).Assembly.FullName;
             var type = typeof(MasterDto).FullName;
             db.Engine.Run($"db.sessions.update _type='{type}, {assy}'");
             db.Engine.UserVersion = 1;
         }
     });
     return(SessionDao.Load <MasterDto>(path));
 }
Esempio n. 5
0
        private void ImportToolStripButton_Click(object sender, EventArgs e)
        {
            var fd = new OpenFileDialog
            {
                Title            = "Import from SharpMaster File",
                Filter           = "LiteDB Files (*.SharpMaster)|*.SharpMaster",
                CheckFileExists  = true,
                CheckPathExists  = true,
                RestoreDirectory = true
            };

            if (fd.ShowDialog() == DialogResult.OK)
            {
                var dao = new SessionDao(fd.FileName);
                foreach (var session in dao.Load())
                {
                    AddSession(session);
                }
            }
        }
Esempio n. 6
0
        private void ExportAllToolStripButton_Click(object sender, EventArgs e)
        {
            if (tabControl.TabPages.Count == 0)
            {
                return;
            }

            var fd = new SaveFileDialog
            {
                Title            = "Export to SharpMaster File",
                Filter           = "LiteDB Files (*.SharpMaster)|*.SharpMaster",
                OverwritePrompt  = true,
                RestoreDirectory = true
            };

            if (fd.ShowDialog() == DialogResult.OK)
            {
                var dao = new SessionDao(fd.FileName);
                dao.Save(GetSessionList());
            }
        }
Esempio n. 7
0
 public void Save(string path, ISessionDto[] dtos)
 {
     SessionDao.Save(path, dtos);
 }
Esempio n. 8
0
 public MasterFactory(string path)
 {
     this.path = path ?? SessionDao.DefaultPath(Name);
 }