/// <summary> /// Start doing whatever is needed for the supported type of action. /// </summary> public void StartWorking(Dictionary <string, string> commandLineArgs) { _fwProjectFolder = Path.GetDirectoryName(commandLineArgs["-p"]); MainForm = new MainBridgeForm { ClientSize = new Size(904, 510) }; _chorusUser = new ChorusUser(commandLineArgs["-u"]); _chorusSystem = Utilities.InitializeChorusSystem(Utilities.LiftOffset(_fwProjectFolder), _chorusUser.Name, LiftFolder.AddLiftFileInfoToFolderConfiguration); _chorusSystem.EnsureAllNotesRepositoriesLoaded(); _notesBrowser = _chorusSystem.WinForms.CreateNotesBrowser(); var conflictHandler = _notesBrowser.MessageContentHandlerRepository.KnownHandlers.OfType <MergeConflictEmbeddedMessageContentHandler>().First(); _chorusSystem.NavigateToRecordEvent.Subscribe(JumpToLiftObject); conflictHandler.HtmlAdjuster = AdjustConflictHtml; if (_connectionHelper != null) { JumpUrlChanged += _connectionHelper.SendJumpUrlToFlex; } var viewer = new BridgeConflictView(); MainForm.Controls.Add(viewer); MainForm.Text = viewer.Text; viewer.Dock = DockStyle.Fill; viewer.SetBrowseView(_notesBrowser); // Only used by FLEx, so how can it not be in use? //if (_currentLanguageProject.FieldWorkProjectInUse) // viewer.EnableWarning(); viewer.SetProjectName(LiftUtilties.GetLiftProjectName(_fwProjectFolder)); }
private void JumpToLiftObject(string url) { // TODO REVIEW JohnT(RandyR): This one needs to be modified for use by lift data, but for use by FLEx. //// Flex expects the query to be UrlEncoded (I think so it can be used as a command line argument). var hostLength = url.IndexOf("?", StringComparison.InvariantCulture); if (hostLength < 0) { return; // can't do it, not a valid FLEx url. } var host = url.Substring(0, hostLength); // This should be fairly safe for a lift URL, since it won't have the "database=current" string in the query. // A lift URL will be something like: // lift://foo.lift?type=entry&id=someguid&label=formforentry var originalQuery = url.Substring(hostLength + 1).Replace("database=current", "database=" + LiftUtilties.GetLiftProjectName(_fwProjectFolder)); var query = HttpUtilityFromMono.UrlEncode(originalQuery); // Instead of closing the conflict viewer we now need to fire this event to notify // the FLExConnectionHelper that we have a URL to jump to. if (JumpUrlChanged != null) { JumpUrlChanged(this, new JumpEventArgs(host + "?" + query)); } }
public void StartWorking(Dictionary <string, string> commandLineArgs) { // As per the API, -p will be the main FW data file. // REVIEW (RandyR): What if it is the DB4o file? // REVIEW (RandyR): What is sent if the user is a client of the DB4o server? // -p <$fwroot>\foo\foo.fwdata var pathToLiftProject = Utilities.LiftOffset(Path.GetDirectoryName(commandLineArgs["-p"])); using (var chorusSystem = Utilities.InitializeChorusSystem(pathToLiftProject, commandLineArgs["-u"], LiftFolder.AddLiftFileInfoToFolderConfiguration)) { var newlyCreated = false; if (chorusSystem.Repository.Identifier == null) { // First do a commit, since the repo is brand new. var projectConfig = chorusSystem.ProjectFolderConfiguration; ProjectFolderConfiguration.EnsureCommonPatternsArePresent(projectConfig); projectConfig.IncludePatterns.Add("**.ChorusRescuedFile"); chorusSystem.Repository.AddAndCheckinFiles(projectConfig.IncludePatterns, projectConfig.ExcludePatterns, "Initial commit"); newlyCreated = true; } chorusSystem.EnsureAllNotesRepositoriesLoaded(); // Do the Chorus business. using (var syncDlg = (SyncDialog)chorusSystem.WinForms.CreateSynchronizationDialog(SyncUIDialogBehaviors.Lazy, SyncUIFeatures.NormalRecommended | SyncUIFeatures.PlaySoundIfSuccessful)) { var syncAdjunt = new LiftSynchronizerAdjunct(LiftUtilties.PathToFirstLiftFile(pathToLiftProject)); syncDlg.SetSynchronizerAdjunct(syncAdjunt); // Chorus does it in this order: // Local Commit // Pull // Merge (Only if anything came in with the pull from other sources, and commit of merged results) // Push syncDlg.SyncOptions.DoPullFromOthers = true; syncDlg.SyncOptions.DoMergeWithOthers = true; syncDlg.SyncOptions.DoSendToOthers = true; syncDlg.Text = Resources.SendReceiveView_DialogTitleLift; syncDlg.StartPosition = FormStartPosition.CenterScreen; syncDlg.BringToFront(); var dlgResult = syncDlg.ShowDialog(); if (dlgResult == DialogResult.OK) { if (newlyCreated && (!syncDlg.SyncResult.Succeeded || syncDlg.SyncResult.ErrorEncountered != null)) { _gotChanges = false; // Wipe out new repo, since something bad happened in S/R, // and we don't want to leave the user in a sad state (cf. LT-14751). Directory.Delete(pathToLiftProject, true); } else if (syncDlg.SyncResult.DidGetChangesFromOthers || syncAdjunt.WasUpdated) { _gotChanges = true; } } else { // User probably bailed out of S/R using the "X" to close the dlg. if (newlyCreated) { _gotChanges = false; // Wipe out new repo, since the user cancelled without even trying the S/R, // and we don't want to leave the user in a sad state (cf. LT-14751). Directory.Delete(pathToLiftProject, true); } } } } }