private void btnClassSave_Click(object sender, RoutedEventArgs e)
        {
            if (FormMode == FormModes.View)
            {
                this.ActualParent.Close();
                return;
            }

            var parent = (ucClassListView)this.ParentContainer;

            ClassDetail.created_by = ClassDetail.updated_by = Utilities.UserSession.UserID;

            if (FormMode == FormModes.New)
            {
                _classid = ClassRepo.Insert(ClassDetail);
                parent.AddToClassList(ClassDetail);
            }
            else
            {
                ClassRepo.Update(ClassDetail);
                parent.Refreshlist();
            }
            ClassSubjectRepo.SaveSubjects(SelectedSubjectList, _classid, Utilities.UserSession.UserID);
            this.ActualParent.Close();
        }
예제 #2
0
 /// <summary>
 /// Delete selected repository and optionally more files (if a single repo is selected)
 /// If multiple repos are selected, simply remove them from our list.
 /// </summary>
 private void MenuDeleteRepoClick(object sender, EventArgs e)
 {
     if (listRepos.SelectedItems.Count > 1)
     {
         // Remove every selected repo from the list
         foreach (int index in listRepos.SelectedIndices)
         {
             ListViewItem li = listRepos.Items[index];
             ClassRepo    r  = li.Tag as ClassRepo;
             App.Repos.Delete(r);
         }
         MenuRefreshClick(null, null);           // Heavy refresh
     }
     else
     {
         // Single selected repo offers more deletion choices...
         ClassRepo repo = GetSelectedRepo();
         // The actual file deletion is implemented in FormDeleteRepo form class:
         FormDeleteRepo deleteRepo = new FormDeleteRepo(repo.Path);
         if (deleteRepo.ShowDialog() == DialogResult.OK)
         {
             App.Repos.Delete(repo);
             MenuRefreshClick(null, null);       // Heavy refresh
         }
     }
 }
예제 #3
0
        /// <summary>
        /// Apply changed settings
        /// </summary>
        public void ApplyChanges(ClassRepo repo)
        {
            string newCrlf = string.Empty;              // Default

            if (radio1.Checked)
            {
                newCrlf = "true";
            }
            if (radio2.Checked)
            {
                newCrlf = "input";
            }
            if (radio3.Checked)
            {
                newCrlf = "false";
            }
            if (radio4.Checked)
            {
                newCrlf = string.Empty;                 // This value will remove the setting
            }
            if (newCrlf != crlf)
            {
                ClassConfig.SetLocal(repo, "core.autocrlf", newCrlf);
            }
        }
예제 #4
0
 /// <summary>
 /// Apply changed settings
 /// </summary>
 public void ApplyChanges(ClassRepo repo)
 {
     if (userControlEditFile.Dirty)
     {
         userControlEditFile.SaveFile(configFile);
     }
 }
예제 #5
0
        /// <summary>
        /// Builds ands returns a context menu for branches
        /// </summary>
        public ToolStripItemCollection GetContextMenu(ToolStrip owner)
        {
            ToolStripMenuItem mNew        = new ToolStripMenuItem("New...", null, MenuNewRepoClick);
            ToolStripMenuItem mScan       = new ToolStripMenuItem("Scan...", null, MenuScanRepoClick);
            ToolStripMenuItem mEdit       = new ToolStripMenuItem("Edit...", null, MenuRepoEditClick);
            ToolStripMenuItem mDelete     = new ToolStripMenuItem("Delete...", null, MenuDeleteRepoClick);
            ToolStripMenuItem mClone      = new ToolStripMenuItem("Clone...", null, MenuNewRepoClick);
            ToolStripMenuItem mSwitchTo   = new ToolStripMenuItem("Switch to...", null, ListReposDoubleClick);
            ToolStripMenuItem mSetDefault = new ToolStripMenuItem("Set Default to...", null, MenuSetDefaultRepoToClick);
            ToolStripMenuItem mCommand    = new ToolStripMenuItem("Command Prompt...", null, MenuViewCommandClick);
            ToolStripMenuItem mRefresh    = new ToolStripMenuItem("Refresh", null, MenuRefreshClick, Keys.F5);

            ToolStripItemCollection menu = new ToolStripItemCollection(owner, new ToolStripItem[] {
                mNew, mScan, mEdit, mDelete, mClone,
                new ToolStripSeparator(),
                mSwitchTo, mSetDefault, mCommand,
                new ToolStripSeparator(),
                mRefresh
            });

            // Disable some menus depending on few rules
            ClassRepo repo = GetSelectedRepo();

            if (repo == null)
            {
                mEdit.Enabled = mDelete.Enabled = mClone.Enabled = mSwitchTo.Enabled = mSetDefault.Enabled = mCommand.Enabled = false;
            }
            else
            {
                mNew.Tag = String.Empty;
                if (repo == App.Repos.Current)
                {
                    mSwitchTo.Enabled = false;
                }

                if (repo == App.Repos.Default)
                {
                    mSetDefault.Enabled = false;
                }
            }
            // We can delete a number of repos
            if (listRepos.SelectedIndices.Count > 1)
            {
                mDelete.Enabled  = true;
                mCommand.Enabled = false;
                mClone.Enabled   = false;
            }

            // Add the specific singular repo name
            if (listRepos.SelectedIndices.Count == 1)
            {
                string repoName = listRepos.SelectedItems[0].Text.Replace('\\', '/').Split('/').Last();
                mSwitchTo.Text   = "Switch to " + repoName;
                mSetDefault.Text = "Set Default to " + repoName;
                mClone.Tag       = App.Repos.Repos[listRepos.SelectedIndices[0]];
            }

            return(menu);
        }
예제 #6
0
 /// <summary>
 /// Initialize pertinent settings
 /// </summary>
 public void Init(ClassRepo repo)
 {
     // Initialize the line endings radio buttons
     crlf = ClassConfig.GetLocal(repo, "core.autocrlf");
     if (crlf == "true") radio1.Checked = true;
     if (crlf == "input") radio2.Checked = true;
     if (crlf == "false") radio3.Checked = true;
 }
예제 #7
0
 /// <summary>
 /// Initialize pertinent settings
 /// </summary>
 public void Init(ClassRepo repo)
 {
     excludesFile = repo.Root + Path.DirectorySeparatorChar +
                    ".git" + Path.DirectorySeparatorChar +
                    "info" + Path.DirectorySeparatorChar +
                    "exclude";
     userControlEditGitignore.LoadGitIgnore(excludesFile);
 }
예제 #8
0
 /// <summary>
 /// Initialize pertinent settings
 /// </summary>
 public void Init(ClassRepo repo)
 {
     excludesFile = repo.Root + Path.DirectorySeparatorChar +
                     ".git" + Path.DirectorySeparatorChar +
                     "info" + Path.DirectorySeparatorChar +
                     "exclude";
     userControlEditGitignore.LoadGitIgnore(excludesFile);
 }
예제 #9
0
        /// <summary>
        /// Initialize pertinent settings
        /// </summary>
        public void Init(ClassRepo repo)
        {
            textBoxUserName.Text  = ClassConfig.GetLocal(repo, "user.name");
            textBoxUserEmail.Text = ClassConfig.GetLocal(repo, "user.email");

            // Add the dirty (modified) value changed helper
            textBoxUserName.TextChanged  += ControlDirtyHelper.ControlDirty;
            textBoxUserEmail.TextChanged += ControlDirtyHelper.ControlDirty;
        }
예제 #10
0
        public void GetAllClassRecordsFromDbContextNotNull()
        {
            var dbContext    = new SQLConnType(@"localhost\SQLEXPRESS14", "CSG", "sa", "@1Mops4moa");
            var sysUnderTest = new ClassRepo(dbContext);

            var result = sysUnderTest.GetAllAsync();

            Assert.NotNull(result);
        }
예제 #11
0
        public void GetAllClassRecordsFromDbContextGreaterThanZeroRecords()
        {
            var dbContext    = new SQLConnType(@"localhost\SqlExpress14", "CSG", "sa", "@1Mops4moa");
            var sysUnderTest = new ClassRepo(dbContext);

            var result = sysUnderTest.GetAllAsync();

            Assert.True(result.Count > 0);
        }
예제 #12
0
        /// <summary>
        /// Initialize pertinent settings
        /// </summary>
        public void Init(ClassRepo repo)
        {
            textBoxUserName.Text = ClassConfig.GetLocal(repo, "user.name");
            textBoxUserEmail.Text = ClassConfig.GetLocal(repo, "user.email");

            // Add the dirty (modified) value changed helper
            textBoxUserName.TextChanged += ControlDirtyHelper.ControlDirty;
            textBoxUserEmail.TextChanged += ControlDirtyHelper.ControlDirty;
        }
예제 #13
0
        /// <summary>
        /// Edit a selected repository specification
        /// </summary>
        private void MenuRepoEditClick(object sender, EventArgs e)
        {
            ClassRepo    repo     = GetSelectedRepo();
            FormRepoEdit repoEdit = new FormRepoEdit(repo);

            if (repoEdit.ShowDialog() == DialogResult.OK)
            {
                App.DoRefresh();
            }
        }
예제 #14
0
 public CrossTable()
 {
     classRepo           = unit.ClassRepo();
     fileRepo            = unit.FileRepo();
     employeeAccountRepo = unit.EmployeeAccountRepo();
     employeeRepo        = unit.EmployeeRepo();
     studentAccountRepo  = unit.StudentAccountRepo();
     studentRepo         = unit.StudentRepo();
     gradeRepo           = unit.GradeRepo();
     subjectRepo         = unit.SubjectRepo();
 }
예제 #15
0
        /// <summary>
        /// Apply changed settings
        /// </summary>
        public void ApplyChanges(ClassRepo repo)
        {
            string newCrlf = string.Empty;              // Default
            if (radio1.Checked) newCrlf = "true";
            if (radio2.Checked) newCrlf = "input";
            if (radio3.Checked) newCrlf = "false";
            if (radio4.Checked) newCrlf = string.Empty; // This value will remove the setting

            if (newCrlf != crlf)
                ClassConfig.SetLocal(repo, "core.autocrlf", newCrlf);
        }
예제 #16
0
        public void DeleteAllClassRecords_Succeed()
        {
            var dbContext    = new SQLConnType(@"localhost\SqlExpress14", "CSG", "sa", "@1Mops4moa");
            var sysUnderTest = new ClassRepo(dbContext);

            sysUnderTest.DeleteAllAsync();

            var result = sysUnderTest.GetAllAsync();

            Assert.True(result.Count == 0);
        }
예제 #17
0
        /// <summary>
        /// Create or clone a new git repository.
        /// If the Tag field is non-empty, it contains the Repo to clone.
        /// </summary>
        private void MenuNewRepoClick(object sender, EventArgs e)
        {
            // If we need to clone a repo, set the cloning parameters within the Step1 form
            ClassRepo repoToClone = ((ToolStripDropDownItem)sender).Tag as ClassRepo;
            string    root        = NewRepoWizard(repoToClone, null, null);

            if (!string.IsNullOrEmpty(root))
            {
                AddNewRepo(root, true);
            }
        }
예제 #18
0
        public UnitOfWorkSessionTest()
        {
            var dbInMemory   = DbInMemory.getDbInMemoryOptions(dbName);
            var personRepo   = new PersonRepo(dbInMemory);
            var sessionRepo  = new SessionRepo(dbInMemory);
            var reasonRepo   = new ReasonRepo(dbInMemory);
            var classRepo    = new ClassRepo(dbInMemory);
            var semesterRepo = new SemesterRepo(dbInMemory);

            db          = new TCSContext(dbInMemory);
            unitSession = new UnitOfWorkSession(personRepo, reasonRepo, sessionRepo, classRepo, semesterRepo);
        }
예제 #19
0
        public void DeleteClassRecordByID_Succeed()
        {
            var dbContext    = new SQLConnType(@"localhost\SqlExpress14", "CSG", "sa", "@1Mops4moa");
            var sysUnderTest = new ClassRepo(dbContext);
            var classEnt     = new ClassEntity("50f14850-1161-4b7f-8093-af335090268f");

            sysUnderTest.DeleteByIdAsync(classEnt.Id);

            var result = sysUnderTest.GetAllAsync();

            Assert.True(result.Count > 0);
        }
예제 #20
0
        /// <summary>
        /// Returns a list of repos which are selected (not necessarily the "current" or "default")
        /// </summary>
        public List <ClassRepo> GetSelectedRepos()
        {
            var repos = new List <ClassRepo>();

            foreach (int index in listRepos.SelectedIndices)
            {
                ListViewItem li = listRepos.Items[index];
                ClassRepo    r  = li.Tag as ClassRepo;
                repos.Add(r);
            }
            return(repos);
        }
 private void UserControl_Loaded(object sender, RoutedEventArgs e)
 {
     if (FormMode == FormModes.Edit || FormMode == FormModes.View)
     {
         ClassDetail           = ClassRepo.FindByID(_classid);
         SelectedSubjectList   = ClassSubjectRepo.GetSelectedSubjects(_classid);
         UnSelectedSubjectList = ClassSubjectRepo.GetUnSelectedSubjects(_classid);
     }
     if (FormMode == FormModes.New)
     {
         UnSelectedSubjectList = SubjectRepo.GetAll();
     }
 }
예제 #22
0
        public UnitOfWorkPersonTest()
        {
            var dbInMemory     = DbInMemory.getDbInMemoryOptions(dbName);
            var personRepo     = new PersonRepo(dbInMemory);
            var classRepo      = new ClassRepo(dbInMemory);
            var scheduleRepo   = new ScheduleRepo(dbInMemory);
            var semesterRepo   = new SemesterRepo(dbInMemory);
            var departmentRepo = new DepartmentRepo(dbInMemory);

            db = new TCSContext(dbInMemory);
            mockBannerService = new Mock <IBannerService>();

            unitPerson = new UnitOfWorkPerson(personRepo, scheduleRepo, classRepo, semesterRepo, departmentRepo, mockBannerService.Object);
        }
예제 #23
0
        /// <summary>
        /// Initialize pertinent settings
        /// </summary>
        public void Init(ClassRepo repo)
        {
            currentRepo = repo;

            currentRepo.Remotes.Refresh(currentRepo);

            listRemotes.BeginUpdate();
            listRemotes.Items.Clear();

            // Get the list of names from remotes class and iteratively add them to the listbox
            foreach (var r in currentRepo.Remotes.GetListNames())
                listRemotes.Items.Add(r);

            listRemotes.EndUpdate();
        }
예제 #24
0
        public void InsertClassRecord_Succeed()
        {
            var dbContext    = new SQLConnType(@"localhost\SqlExpress14", "CSG", "sa", "@1Mops4moa");
            var sysUnderTest = new ClassRepo(dbContext);
            var classEnt     = new ClassEntity(Guid.NewGuid().ToString());

            classEnt.ClassName   = "English";
            classEnt.Description = "English Poetry";

            sysUnderTest.InsertEntityAsync(classEnt);

            var result = sysUnderTest.GetAllAsync();

            Assert.True(result.Count > 0);
        }
예제 #25
0
        /// <summary>
        /// Initialize pertinent settings
        /// </summary>
        public void Init(ClassRepo repo)
        {
            currentRepo = repo;

            currentRepo.Remotes.Refresh(currentRepo);

            listRemotes.BeginUpdate();
            listRemotes.Items.Clear();

            // Get the list of names from remotes class and iteratively add them to the listbox
            foreach (var r in currentRepo.Remotes.GetListNames())
            {
                listRemotes.Items.Add(r);
            }

            listRemotes.EndUpdate();
        }
예제 #26
0
 /// <summary>
 /// Initialize pertinent settings
 /// </summary>
 public void Init(ClassRepo repo)
 {
     // Initialize the line endings radio buttons
     crlf = ClassConfig.GetLocal(repo, "core.autocrlf");
     if (crlf == "true")
     {
         radio1.Checked = true;
     }
     if (crlf == "input")
     {
         radio2.Checked = true;
     }
     if (crlf == "false")
     {
         radio3.Checked = true;
     }
 }
예제 #27
0
        /// <summary>
        /// Apply changed settings
        /// </summary>
        public void ApplyChanges(ClassRepo repo)
        {
            if (textBoxUserName.Tag != null)
            {
                // Change the repo config and our internal variable so we dont need to reload
                ClassConfig.SetLocal(repo, "user.name", textBoxUserName.Text.Trim());
                repo.UserName = textBoxUserName.Text;
                textBoxUserName.Tag = null;
            }

            if (textBoxUserEmail.Tag != null)
            {
                // Change the repo config and our internal variable so we dont need to reload
                ClassConfig.SetLocal(repo, "user.email", textBoxUserEmail.Text.Trim());
                repo.UserEmail = textBoxUserEmail.Text;
                textBoxUserEmail.Tag = null;
            }
        }
예제 #28
0
        /// <summary>
        /// Apply changed settings
        /// </summary>
        public void ApplyChanges(ClassRepo repo)
        {
            if (textBoxUserName.Tag != null)
            {
                // Change the repo config and our internal variable so we dont need to reload
                ClassConfig.SetLocal(repo, "user.name", textBoxUserName.Text.Trim());
                repo.UserName       = textBoxUserName.Text;
                textBoxUserName.Tag = null;
            }

            if (textBoxUserEmail.Tag != null)
            {
                // Change the repo config and our internal variable so we dont need to reload
                ClassConfig.SetLocal(repo, "user.email", textBoxUserEmail.Text.Trim());
                repo.UserEmail       = textBoxUserEmail.Text;
                textBoxUserEmail.Tag = null;
            }
        }
예제 #29
0
        public SessionsControllerTest()
        {
            var dbOptions = DbInMemory.getDbInMemoryOptions(dbName);

            db          = new TCSContext(dbOptions);
            sessionRepo = new SessionRepo(dbOptions);
            var personRepo        = new PersonRepo(dbOptions);
            var semesterRepo      = new SemesterRepo(dbOptions);
            var sessionClassRepo  = new SessionClassRepo(dbOptions);
            var sessionReasonRepo = new SessionReasonRepo(dbOptions);
            var reasonRepo        = new ReasonRepo(dbOptions);
            var classRepo         = new ClassRepo(dbOptions);

            csvParser = new CSVSessionUploadParser();
            var mapper      = Utils.GetProjectMapper();
            var unitSession = new UnitOfWorkSession(personRepo, reasonRepo, sessionRepo, classRepo, semesterRepo);

            sessionController = new SessionsController(sessionRepo, semesterRepo, personRepo, sessionReasonRepo, sessionClassRepo, mapper, csvParser, unitSession);
        }
예제 #30
0
        /// <summary>
        /// This internal function adds a new repo
        /// After the repo has been added to the list, the repo edit dialog will open to let the user
        /// have a chance to modify its settings. This behavior can be disabled by setting openEdit to false.
        /// </summary>
        private void AddNewRepo(string path, bool openEdit)
        {
            try
            {
                // Simply add the new repo. This method will throw exceptions if something's not right.
                ClassRepo repo = App.Repos.Add(path);

                // Switch to the new repo and do a global refresh
                App.Repos.SetCurrent(repo);
                App.DoRefresh();

                // Open the Edit Repo dialog since the user may want to fill in user name and email, at least
                if (openEdit)
                {
                    MenuRepoEditClick(null, null);
                }
            }
            catch (Exception ex)
            {
                App.PrintLogMessage("Unable to add repo: " + ex.Message, MessageType.Error);
                App.PrintStatusMessage(ex.Message, MessageType.Error);
            }
        }
예제 #31
0
 /// <summary>
 /// Apply changed settings
 /// </summary>
 public void ApplyChanges(ClassRepo repo)
 {
 }
예제 #32
0
 /// <summary>
 /// Apply changed settings
 /// </summary>
 public void ApplyChanges(ClassRepo repo)
 {
     if (userControlEditFile.Dirty)
         userControlEditFile.SaveFile(_configFile);
 }
예제 #33
0
 /// <summary>
 /// Apply changed settings
 /// </summary>
 public void ApplyChanges(ClassRepo repo)
 {
     userControlEditGitignore.SaveGitIgnore(excludesFile);
 }
예제 #34
0
 /// <summary>
 /// Initialize pertinent settings
 /// </summary>
 public void Init(ClassRepo repo)
 {
     _configFile = repo.Root + Path.DirectorySeparatorChar +
                     ".git" + Path.DirectorySeparatorChar +
                     "config";
 }
예제 #35
0
        /// <summary>
        /// Global static function that executes a new repo wizard
        /// If successful, returns the path to the new local repo
        /// If failed, returns null
        /// </summary>
        public static string NewRepoWizard(ClassRepo repoToClone, ClassRepo repoRemote)
        {
            FormNewRepoStep1 newRepoStep1 = new FormNewRepoStep1();
            FormNewRepoStep2 newRepoStep2 = new FormNewRepoStep2();

            // If the repo to clone parameter was given, build the close repo information
            if (repoToClone != null)
            {
                newRepoStep1.Type = "local";
                newRepoStep1.Local = repoToClone.ToString();
            }
            // If the remote repo parameter was given, build the remote repo information
            if (repoRemote != null)
            {
                // If the list of remotes contains at least one entry, use it
                List<string> remotes = repoRemote.Remotes.GetRemoteNames();
                if (remotes.Count > 0)
                {
                    newRepoStep1.Type = "remote";
                    ClassRemotes.Remote remote = repoRemote.Remotes.Get(remotes[0]);
                    newRepoStep1.SetRemote(remote);
                }
                else
                    newRepoStep2.Destination = repoRemote.Root;
            }

            BackToStep1:
            if (newRepoStep1.ShowDialog() == DialogResult.OK)
            {
                // Depending on the type of the source, establish that:
                //  For clone operations:
                //  - The final directory has to exist and be empty
                //  - New repo name will be suggested based on the source project names
                switch (newRepoStep1.Type)
                {
                    case "empty":
                        newRepoStep2.ProjectName = "";
                        newRepoStep2.CheckTargetDirEmpty = false;
                        break;
                    case "local":
                        // Find the project name from the cloned path (the last part of the path)
                        string[] parts = newRepoStep1.Local.Split(new char[] { '\\', '/' });
                        if (parts.Length > 1)
                            newRepoStep2.ProjectName = parts[parts.Length - 1];
                        newRepoStep2.Destination = "";
                        newRepoStep2.CheckTargetDirEmpty = true;
                        break;
                    case "remote":
                        ClassRemotes.Remote r = newRepoStep1.Remote;
                        string remoteProjectName = r.UrlFetch;
                        // Extract the project name from the remote Url specification
                        parts = remoteProjectName.Split(new char[] { '.', '\\', '/', ':' });
                        if (parts.Length > 1 && parts[parts.Length - 1] == "git")
                            newRepoStep2.ProjectName = parts[parts.Length - 2];

                        // If the project name is equal to the last part of the path, use it for the project name instead
                        // and trim the path. This is done to (1) propagate possible upper-cased letters in the
                        // path and (2) to fix the cases where we have given repoRemote with a full path which included
                        // a redundant project name.
                        // Example: root:         c:\Projects\Arduino    =>   c:\Projects
                        //          project name: arduino                =>   Arduino
                        parts = newRepoStep2.Destination.Split(new char[] { '\\', '/' });
                        if (parts.Length > 1 && String.Compare(parts[parts.Length - 1], newRepoStep2.ProjectName, StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            newRepoStep2.ProjectName = parts[parts.Length - 1];
                            newRepoStep2.Destination = Directory.GetParent(newRepoStep2.Destination).FullName;
                        }
                        newRepoStep2.CheckTargetDirEmpty = true;
                        break;
                }

            BackToStep2:
                DialogResult result = newRepoStep2.ShowDialog();

                // Clicking on the <<Prev button will return "Retry" result, so we loop back to the first form...
                if (result == DialogResult.Retry)
                    goto BackToStep1;

                if (result == DialogResult.OK)
                {
                    string type = newRepoStep1.Type;
                    string root = newRepoStep2.Destination;
                    string extra = newRepoStep2.Extra;
                    bool isBare = newRepoStep2.IsBare;

                    try
                    {
                        string init = "";
                        switch (type)
                        {
                            case "empty":
                                init = "init \"" + root + "\"" + (isBare ? " --bare --shared=all " : " ") + extra;
                                break;

                            case "local":
                                init = "clone " + newRepoStep1.Local + " \"" + root + "\"" + (isBare ? " --bare --shared " : " ") + extra;
                                break;

                            case "remote":
                                ClassRemotes.Remote r = newRepoStep1.Remote;
                                init = "clone --progress -v --origin " + r.Name + " " + r.UrlFetch + " \"" + root + "\"" + (isBare ? " --bare --shared " : " ") + extra;

                                // Add HTTPS password for the next execute of a clone operation
                                ClassUtils.AddEnvar("PASSWORD", r.Password);
                                break;
                        }

                        // Get out of the way (so the git can remove directory if the clone operation fails)
                        Directory.SetCurrentDirectory(App.AppHome);
                        if (ClassGit.Run(init).Success() == false)
                            goto BackToStep2;

                        return root;
                    }
                    catch (ClassException ex)
                    {
                        if (MessageBox.Show(ex.Message, "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error) == DialogResult.Cancel)
                            return string.Empty;
                    }
                    goto BackToStep2;
                }
            }
            return string.Empty;
        }
예제 #36
0
        /// <summary>
        /// Open a command prompt at the root directory of a selected repo,
        /// not necessarily the current repo
        /// </summary>
        private void MenuViewCommandClick(object sender, EventArgs e)
        {
            ClassRepo repo = GetSelectedRepo();

            ClassUtils.CommandPromptHere(repo.Path);
        }
예제 #37
0
 /// <summary>
 /// Apply changed settings
 /// </summary>
 public void ApplyChanges(ClassRepo repo)
 {
 }
예제 #38
0
        /// <summary>
        /// Global static function that executes a new repo wizard
        /// If successful, returns the path to the new local repo
        /// If failed, returns null
        /// </summary>
        public static string NewRepoWizard(ClassRepo repoToClone, ClassRepo repoRemote, string folder)
        {
            FormNewRepoStep1 newRepoStep1 = new FormNewRepoStep1();
            FormNewRepoStep2 newRepoStep2 = new FormNewRepoStep2();

            // If the repo to clone parameter was given, build the close repo information
            if (repoToClone != null)
            {
                newRepoStep1.Type  = "local";
                newRepoStep1.Local = repoToClone.ToString();
            }
            // If the remote repo parameter was given, build the remote repo information
            if (repoRemote != null)
            {
                // If the list of remotes contains at least one entry, use it
                List <string> remotes = repoRemote.Remotes.GetRemoteNames();
                if (remotes.Count > 0)
                {
                    newRepoStep1.Type = "remote";
                    ClassRemotes.Remote remote = repoRemote.Remotes.Get(remotes[0]);
                    newRepoStep1.SetRemote(remote);
                }
                else
                {
                    newRepoStep2.Destination = repoRemote.Path;
                }
            }
            // If the folder parameter was given, create a new local repo at that path
            bool skipStep1 = !string.IsNullOrEmpty(folder); // In this case, we will skip step 1

            newRepoStep2.Destination = folder ?? "";        // and assign the folder path to the step 2 dialog

BackToStep1:
            if (skipStep1 || newRepoStep1.ShowDialog() == DialogResult.OK)
            {
                // Depending on the type of the source, establish that:
                //  For clone operations:
                //  - The final directory has to exist and be empty
                //  - New repo name will be suggested based on the source project names
                switch (newRepoStep1.Type)
                {
                case "empty":
                    newRepoStep2.ProjectName         = "";
                    newRepoStep2.CheckTargetDirEmpty = false;
                    break;

                case "local":
                    // Find the project name from the cloned path (the last part of the path)
                    string[] parts = newRepoStep1.Local.Split(new char[] { '\\', '/' });
                    if (parts.Length > 1)
                    {
                        newRepoStep2.ProjectName = parts[parts.Length - 1];
                    }
                    newRepoStep2.Destination         = "";
                    newRepoStep2.CheckTargetDirEmpty = true;
                    break;

                case "remote":
                    ClassRemotes.Remote r    = newRepoStep1.Remote;
                    string remoteProjectName = r.UrlFetch;
                    // Extract the project name from the remote Url specification
                    parts = remoteProjectName.Split(new char[] { '.', '\\', '/', ':' });
                    if (parts.Length > 1 && parts[parts.Length - 1] == "git")
                    {
                        newRepoStep2.ProjectName = parts[parts.Length - 2];
                    }

                    // If the project name is equal to the last part of the path, use it for the project name instead
                    // and trim the path. This is done to (1) propagate possible upper-cased letters in the
                    // path and (2) to fix the cases where we have given repoRemote with a full path which included
                    // a redundant project name.
                    // Example: root:         c:\Projects\Arduino    =>   c:\Projects
                    //          project name: arduino                =>   Arduino
                    parts = newRepoStep2.Destination.Split(new char[] { '\\', '/' });
                    if (parts.Length > 1 && String.Compare(parts[parts.Length - 1], newRepoStep2.ProjectName, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        newRepoStep2.ProjectName = parts[parts.Length - 1];
                        newRepoStep2.Destination = Directory.GetParent(newRepoStep2.Destination).FullName;
                    }
                    newRepoStep2.CheckTargetDirEmpty = true;
                    break;
                }

BackToStep2:
                DialogResult result = newRepoStep2.ShowDialog();

                // Clicking on the <<Prev button will return "Retry" result, so we loop back to the first form...
                skipStep1 = false;
                if (result == DialogResult.Retry)
                {
                    goto BackToStep1;
                }

                if (result == DialogResult.OK)
                {
                    string type   = newRepoStep1.Type;
                    string root   = newRepoStep2.Destination;
                    string extra  = newRepoStep2.Extra;
                    bool   isBare = newRepoStep2.IsBare;

                    try
                    {
                        string init = "";
                        ClassUtils.AddEnvar("PASSWORD", ""); // Clear the HTTPS password
                        switch (type)
                        {
                        case "empty":
                            init = "init \"" + root + "\"" + (isBare ? " --bare --shared=all " : " ") + extra;
                            break;

                        case "local":
                            init = "clone " + newRepoStep1.Local + " \"" + root + "\"" + (isBare ? " --bare --shared " : " ") + extra;
                            break;

                        case "remote":
                            ClassRemotes.Remote r = newRepoStep1.Remote;
                            init = "clone --progress -v --origin " + r.Name + " " + r.UrlFetch + " \"" + root + "\"" + (isBare ? " --bare --shared " : " ") + extra;

                            // Add HTTPS password for the next execute of a clone operation
                            ClassUtils.AddEnvar("PASSWORD", r.Password);
                            break;
                        }

                        // Get out of the way (so the git can remove directory if the clone operation fails)
                        Directory.SetCurrentDirectory(App.AppHome);
                        if (ClassGit.Run(init).Success() == false)
                        {
                            goto BackToStep2;
                        }

                        return(root);
                    }
                    catch (ClassException ex)
                    {
                        if (MessageBox.Show(ex.Message, "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error) == DialogResult.Cancel)
                        {
                            return(string.Empty);
                        }
                    }
                    goto BackToStep2;
                }
            }
            return(string.Empty);
        }
예제 #39
0
 /// <summary>
 /// Apply changed settings
 /// </summary>
 public void ApplyChanges(ClassRepo repo)
 {
     userControlEditGitignore.SaveGitIgnore(excludesFile);
 }
예제 #40
0
 // GET: Class
 public ActionResult Index()
 {
     return(View(ClassRepo.All()));
 }
예제 #41
0
 public ActionResult List(ClassViewModel entity)
 {
     return(PartialView("_List", ClassRepo.All()));
 }