public bool ShowCheckInDialog() { CheckInWindow checkInWindow = new CheckInWindow(); List <EventDto> events = (List <EventDto>)mainWindow.EventData; checkInWindow.EventID = events[mainWindow.SelectIndexEvent].Id; return((bool)checkInWindow.ShowDialog()); }
/// <summary> /// Check in the file(s). /// </summary> public override void Execute() { Project project = App.Instance.SalesForceApp.CurrentProject; if (project != null && project.Client.Checkout.IsEnabled()) { // get all checkouts IDictionary <string, SourceFile> checkoutTable = null; using (App.Wait("Getting check outs.")) checkoutTable = project.Client.Checkout.GetCheckouts(); // filter checkouts to current user List <SourceFile> userCheckouts = new List <SourceFile>(); foreach (KeyValuePair <string, SourceFile> kvp in checkoutTable) { if (project.Client.User.Equals(kvp.Value.CheckedOutBy)) { userCheckouts.Add(kvp.Value); } } // show dialog to collect user input CheckInWindow dlg = new CheckInWindow(); dlg.Title = "Undo checkout"; dlg.CommitTitle = "Undo"; dlg.ShowComment = false; dlg.Files = userCheckouts.ToArray(); dlg.SelectedFiles = IsRootNodeSelected() ? userCheckouts.ToArray() : GetSelectedFiles(); if (App.ShowDialog(dlg)) { using (App.Wait("Undoing file(s) checkout.")) { // commit to salesforce project.Client.Checkout.CheckinFiles(dlg.SelectedFiles); // update UI HashSet <string> ids = new HashSet <string>(); foreach (SourceFile f in dlg.SelectedFiles) { ids.Add(f.Id); } IEnumerable <SourceFileNode> fileNodes = App.Instance.Navigation.GetNodes <SourceFileNode>(); foreach (SourceFileNode fileNode in fileNodes) { if (ids.Contains(fileNode.SourceFile.Id)) { fileNode.SourceFile.CheckedOutBy = null; fileNode.UpdateHeader(); } } } App.Instance.UpdateWorkspaces(); } } }
/// <summary> /// Check in the file(s). /// </summary> public override void Execute() { Project project = App.Instance.SalesForceApp.CurrentProject; if (project != null && project.Client.Checkout.IsEnabled()) { // get all checkouts IDictionary <string, SourceFile> checkoutTable = null; using (App.Wait("Getting check outs.")) checkoutTable = project.Client.Checkout.GetCheckouts(); // filter checkouts to current user List <SourceFile> userCheckouts = new List <SourceFile>(); foreach (KeyValuePair <string, SourceFile> kvp in checkoutTable) { if (project.Client.User.Equals(kvp.Value.CheckedOutBy)) { userCheckouts.Add(kvp.Value); } } // show dialog to collect user input CheckInWindow dlg = new CheckInWindow(); dlg.Title = "Check in files"; dlg.CommitTitle = "Commit"; dlg.Files = userCheckouts.ToArray(); dlg.SelectedFiles = IsRootNodeSelected() ? userCheckouts.ToArray() : GetSelectedFiles(); if (App.ShowDialog(dlg)) { using (App.Wait("Checking in files.")) { // commit to repository if (project.Repository.IsValid) { // check for unsaved changes foreach (SourceFile file in dlg.SelectedFiles) { IDocument[] documents = App.Instance.Content.GetDocumentsByEntity(file); foreach (IDocument document in documents) { if (document is ISourceFileEditorDocument && (document as ISourceFileEditorDocument).IsDirty) { throw new Exception(String.Format("The file '{0}' has unsaved changes. You must save your changes before you can check it in.", file.FullName)); } } } // download the files in a package byte[] packageBits = project.Client.Meta.GetSourceFileContentAsPackage(dlg.SelectedFiles); // commit and push the package project.Repository.PushPackage(packageBits, dlg.Comment); } // commit to salesforce project.Client.Checkout.CheckinFiles(dlg.SelectedFiles); // update UI HashSet <string> ids = new HashSet <string>(); foreach (SourceFile f in dlg.SelectedFiles) { ids.Add(f.Id); } IEnumerable <SourceFileNode> fileNodes = App.Instance.Navigation.GetNodes <SourceFileNode>(); foreach (SourceFileNode fileNode in fileNodes) { if (ids.Contains(fileNode.SourceFile.Id)) { fileNode.SourceFile.CheckedOutBy = null; fileNode.UpdateHeader(); } } App.Instance.UpdateWorkspaces(); } } } }