Beispiel #1
0
        private void CreateProfileDetails(ProfileDetails details)
        {
            var sbSQL             = new StringBuilder();
            SQLiteConnection conn = GetDatabaseConnection();

            sbSQL.Append("INSERT INTO Details ");
            sbSQL.Append("(ProfileID,Repository,DumpDirectory,FilePattern,Incremental,Revisions,RootDumpFilePath) ");
            sbSQL.Append("VALUES ");
            sbSQL.Append("(@ProfileId,@Repository,@DumpDirectory,@FilePattern,@Incremental,@Revisions,@RootDumpFilePath)");

            var cmd   = new SQLiteCommand(sbSQL.ToString());
            var param = new SQLiteParameter("Repository", details.Repository);

            cmd.Parameters.Add(param);
            param = new SQLiteParameter("DumpDirectory", details.DumpDirectory);
            cmd.Parameters.Add(param);
            param = new SQLiteParameter("FilePattern", details.FilePattern);
            cmd.Parameters.Add(param);
            param = new SQLiteParameter("Incremental", details.Incremental);
            cmd.Parameters.Add(param);
            param = new SQLiteParameter("Revisions", details.Revisions);
            cmd.Parameters.Add(param);
            param = new SQLiteParameter("ProfileId", details.ProfileID);
            cmd.Parameters.Add(param);
            param = new SQLiteParameter("RootDumpFilePath", details.RootDumpFilePath);
            cmd.Parameters.Add(param);

            conn.Open();
            cmd.Connection = conn;
            cmd.ExecuteNonQuery();

            conn.Close();
        }
Beispiel #2
0
        public void CreateProfile(string profileName, ProfileDetails details)
        {
            int ID = CreateProfile(profileName);

            details.ProfileID = ID;

            CreateProfileDetails(details);
        }
        private void cboProfiles_SelectedIndexChanged(object sender, EventArgs e)
        {
            int currItemId = cboProfiles.SelectedIndex;

            if (currItemId == 0)
            {
                txtDumpDir.Text        = string.Empty;
                txtDumpDir.Enabled     = false;
                txtFilePattern.Text    = string.Empty;
                txtFilePattern.Enabled = false;
                chkIncremental.Checked = false;
                btnRun.Enabled         = false;
                btnNew.Enabled         = true;
                btnDelete.Enabled      = false;
                btnSave.Enabled        = false;

                if (cboRepos.Items.Count > 0)
                {
                    cboRepos.SelectedIndex = 0;
                }

                _isNew    = false;
                _isUpdate = false;
            }
            else
            {
                var            dal       = new DAL();
                var            repoIndex = (int)_profileIndex[currItemId];
                ProfileDetails d         = dal.LoadProfileDetails(repoIndex);

                if (d != null)
                {
                    txtDumpDir.Text        = d.DumpDirectory;
                    txtDumpDir.Enabled     = true;
                    txtFilePattern.Text    = d.FilePattern;
                    txtFilePattern.Enabled = true;
                    chkIncremental.Checked = d.Incremental;
                    txtRevisions.Text      = d.Revisions;

                    int idx = cboRepos.FindStringExact(d.Repository);
                    cboRepos.SelectedIndex = idx;
                    btnRun.Enabled         = true;
                    btnNew.Enabled         = true;
                    btnDelete.Enabled      = true;
                    btnSave.Enabled        = true;

                    _isNew    = false;
                    _isUpdate = true;
                }
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            var    det = new ProfileDetails();
            string repoName;
            int    idx;

            det.DumpDirectory    = txtDumpDir.Text;
            det.FilePattern      = txtFilePattern.Text;
            det.Incremental      = chkIncremental.Checked;
            det.Revisions        = txtRevisions.Text;
            det.RootDumpFilePath = txtBaseFile.Text;

            var dal = new DAL();

            if (_isUpdate)
            {
                repoName = cboRepos.Text;

                idx = Convert.ToInt32(_profileIndex[cboProfiles.SelectedIndex]);

                det.ProfileID  = idx;
                det.Repository = repoName;

                dal.UpdateProfile(det);
            }

            if (_isNew)
            {
                string profileName = cboProfiles.Text;
                repoName = cboRepos.Text;

                det.Repository = repoName;

                dal.CreateProfile(profileName, det);

                _profileIndex = new Hashtable();
                cboProfiles.Items.Clear();
                cboRepos.Items.Clear();

                InitializeForm();

                idx = cboProfiles.FindStringExact(profileName);
                cboProfiles.SelectedIndex = idx;

                _isNew    = false;
                _isUpdate = false;
            }
        }
Beispiel #5
0
        public ProfileDetails LoadProfileDetails(int profileId)
        {
            ProfileDetails   det  = null;
            string           sql  = "SELECT * FROM Details WHERE ProfileID = @ProfileId";
            SQLiteConnection conn = GetDatabaseConnection();
            var cmd   = new SQLiteCommand(sql);
            var param = new SQLiteParameter("ProfileId", profileId);

            cmd.Parameters.Add(param);
            SQLiteDataReader dr;

            conn.Open();
            cmd.Connection = conn;
            dr             = cmd.ExecuteReader();

            while (dr.Read())
            {
                det = new ProfileDetails
                {
                    DumpDirectory = dr["DumpDirectory"].ToString(),
                    Repository    = dr["Repository"].ToString(),
                    FilePattern   = dr["FilePattern"].ToString(),
                    Incremental   = Convert.ToBoolean(dr["Incremental"])
                };

                try
                {
                    det.Revisions = dr["Revisions"].ToString();
                }
                catch (IndexOutOfRangeException)
                {}

                det.RootDumpFilePath = dr["RootDumpFilePath"].ToString();
            }

            dr.Close();
            conn.Close();

            return(det);
        }
        private static DumpArgs GetDumpArgsFromProfileName(string profileName)
        {
            var args = new DumpArgs();
            var dal  = new DAL();

            int profileID = dal.GetProfileId(profileName);

            if (profileID > 0)
            {
                ProfileDetails det = dal.LoadProfileDetails(profileID);

                string filePattern = Utilities.ParseFilePattern(det.FilePattern, det.Repository);

                args.DumpFileName   = Path.Combine(det.DumpDirectory, filePattern);
                args.RevisionArg    = det.Revisions;
                args.UseIncremental = det.Incremental;
                args.UseQuiet       = true;
                args.RepositoryName = det.Repository;
            }

            return(args);
        }
Beispiel #7
0
        public void UpdateProfile(ProfileDetails details)
        {
            var sbSQL             = new StringBuilder();
            SQLiteConnection conn = GetDatabaseConnection();

            sbSQL.Append("UPDATE Details ");
            sbSQL.Append("SET Repository = @Repository, ");
            sbSQL.Append("DumpDirectory = @DumpDirectory, ");
            sbSQL.Append("FilePattern = @FilePattern, ");
            sbSQL.Append("Incremental = @Incremental, ");
            sbSQL.Append("Revisions = @Revisions, ");
            sbSQL.Append("RootDumpFilePath = @RootDumpFilePath ");
            sbSQL.Append("WHERE ProfileID = @ProfileId");

            var cmd   = new SQLiteCommand(sbSQL.ToString());
            var param = new SQLiteParameter("Repository", details.Repository);

            cmd.Parameters.Add(param);
            param = new SQLiteParameter("DumpDirectory", details.DumpDirectory);
            cmd.Parameters.Add(param);
            param = new SQLiteParameter("FilePattern", details.FilePattern);
            cmd.Parameters.Add(param);
            param = new SQLiteParameter("Incremental", details.Incremental);
            cmd.Parameters.Add(param);
            param = new SQLiteParameter("Revisions", details.Revisions);
            cmd.Parameters.Add(param);
            param = new SQLiteParameter("ProfileId", details.ProfileID);
            cmd.Parameters.Add(param);
            param = new SQLiteParameter("RootDumpFilePath", details.RootDumpFilePath);
            cmd.Parameters.Add(param);

            conn.Open();
            cmd.Connection = conn;
            cmd.ExecuteNonQuery();

            conn.Close();
        }