public override void AddTreeItem() { string BizFlowName = string.Empty; if (GingerCore.General.GetInputWithValidation("Add " + GingerDicser.GetTermResValue(eTermResKey.BusinessFlow), GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + " Name:", ref BizFlowName, System.IO.Path.GetInvalidFileNameChars())) { BusinessFlow BizFlow = LocalRepository.CreateNewBizFlow(BizFlowName); if (App.UserProfile.Solution.ApplicationPlatforms.Count != 1) { EditBusinessFlowAppsPage EBFP = new EditBusinessFlowAppsPage(BizFlow); EBFP.ResetPlatformSelection(); EBFP.Title = "Configure " + GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + " Target Application(s)"; EBFP.ShowAsWindow(eWindowShowStyle.Dialog, false); } BizFlow.FileName = LocalRepository.GetRepoItemFileName(BizFlow, Path); BusinessFlowTreeItem BFTI = new BusinessFlowTreeItem(); BFTI.BusinessFlow = BizFlow; ITreeViewItem addTreeViewItem = mTreeView.Tree.AddChildItemAndSelect(this, BFTI); //Must do the action after the node was added to tree! BizFlow.Save(); //add BF to cach App.LocalRepository.AddItemToCache(BizFlow); //refresh header- to reflect source control state mTreeView.Tree.RefreshHeader(addTreeViewItem); } }
private void ImportExternalBuinessFlow(object sender, System.Windows.RoutedEventArgs e) { BusinessFlow importedBF = null; //open dialog for selecting the BF file System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog(); dlg.DefaultExt = ".Ginger.BusinessFlow.xml"; dlg.Filter = "Ginger Business Flow File|*.Ginger.BusinessFlow.xml"; if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { try { //copy to Solution Business Flow folder string importedBFpath = System.IO.Path.Combine(Path, System.IO.Path.GetFileName(dlg.FileName)); File.Copy(dlg.FileName, importedBFpath, false); //load it to object importedBF = (BusinessFlow)RepositoryItem.LoadFromFile(typeof(BusinessFlow), importedBFpath); //customize the imported BF importedBF.Guid = Guid.NewGuid(); for (int i = 0; i < importedBF.TargetApplications.Count; i++) { if (App.UserProfile.Solution.ApplicationPlatforms.Where(x => x.AppName == importedBF.TargetApplications[i].AppName).FirstOrDefault() == null) { importedBF.TargetApplications.RemoveAt(i);//No such Application so Delete it i--; } } if (importedBF.TargetApplications.Count == 0) { TargetApplication ta = new TargetApplication(); ta.AppName = App.UserProfile.Solution.ApplicationPlatforms[0].AppName; importedBF.TargetApplications.Add(ta); } importedBF.Save(); //add it to cache & tree App.LocalRepository.AddItemToCache(importedBF); BusinessFlowTreeItem importedBFTI = new BusinessFlowTreeItem(); importedBFTI.BusinessFlow = importedBF; mTreeView.Tree.AddChildItemAndSelect(this, importedBFTI); } catch (Exception ex) { Reporter.ToUser(eUserMsgKeys.StaticErrorMessage, "Failed to copy and load the selected " + GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + " file." + System.Environment.NewLine + "Error: " + System.Environment.NewLine + ex.Message); return; } } }
List <ITreeViewItem> ITreeViewItem.Childrens() { List <ITreeViewItem> Childrens = new List <ITreeViewItem>(); ObservableList <BusinessFlow> BFs; if (Folder == "Recently Used") { // Since Recently used is per user we keep temp file in the solution folder using MRU class BFs = new ObservableList <BusinessFlow>(); string[] BizFlowsFile = App.UserProfile.Solution.RecentlyUsedBusinessFlows.getList(); foreach (string BFfilename in BizFlowsFile) { // DO NOT load from file - need to search or get from db repo... so it will all be in sync wherever ths BF is used //BusinessFlow BF = App.LocalRepository.GetBusinessFlow(BFfilename); BusinessFlow BF = App.LocalRepository.GetItemByFileName <BusinessFlow>(typeof(BusinessFlow), BFfilename); if (BF != null && BFs.Contains(BF) == false) { BFs.Add(BF); } } } else { if (WorkSpace.Instance.BetaFeatures.BFUseSolutionRepositry) { BFs = mRepositoryFolder.GetFolderItems(); AddsubFolders(mRepositoryFolder, Childrens); } else { BFs = App.LocalRepository.GetSolutionBusinessFlows(specificFolderPath: Path); AddsubFolders(Path, Childrens); } } //Add Business Flows to tree children foreach (BusinessFlow BF in BFs) { BusinessFlowTreeItem BFTI = new BusinessFlowTreeItem(mViewMode); BFTI.BusinessFlow = BF; Childrens.Add(BFTI); } return(Childrens); }
private void ImportSeleniumScript(object sender, System.Windows.RoutedEventArgs e) { System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog(); dlg.DefaultExt = ".html"; dlg.Filter = "Recorded Selenium Scripts (*.html)|*.html"; if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { BusinessFlow BF = SeleniumToGinger.ConvertSeleniumScript(dlg.FileName); string BFFileName = LocalRepository.GetRepoItemFileName(BF, Path); BusinessFlowTreeItem BFTI = new BusinessFlowTreeItem(); BFTI.BusinessFlow = BF; mTreeView.Tree.AddChildItemAndSelect(this, BFTI); BF.SaveToFile(BFFileName); } }
private void ImportGherkinFeature(object sender, RoutedEventArgs e) { BusinessFlow BF = null; if (WorkSpace.Instance.BetaFeatures.ImportGherkinFeatureWizrd) { WizardWindow.ShowWizard(new ImportGherkinFeatureWizard(mBusFlowsFolder.FolderFullPath)); } else { // TODO: check test me string FeatureFolder = mBusFlowsFolder.FolderFullPath; if (!mBusFlowsFolder.FolderFullPath.EndsWith("BusinessFlows")) { FeatureFolder = mBusFlowsFolder.FolderFullPath.Substring(mBusFlowsFolder.FolderFullPath.IndexOf("BusinessFlows\\") + 14); } ImportGherkinFeatureFilePage IFP = new ImportGherkinFeatureFilePage(FeatureFolder, ImportGherkinFeatureFilePage.eImportGherkinFileContext.BusinessFlowFolder); IFP.ShowAsWindow(); BF = IFP.BizFlow; if (BF != null) { //Refresh and select Faetures Folder DocumentsFolderTreeItem DFTI = (DocumentsFolderTreeItem)mTreeView.Tree.GetChildItembyNameandSelect("Documents"); DFTI = (DocumentsFolderTreeItem)mTreeView.Tree.GetChildItembyNameandSelect("Features", DFTI); if (mBusFlowsFolder.FolderFullPath != "Business Flows") { mTreeView.Tree.GetChildItembyNameandSelect(mBusFlowsFolder.FolderFullPath, DFTI); } mTreeView.Tree.RefreshSelectedTreeNodeChildrens(); //Select Business Folder mTreeView.Tree.SelectItem(this); mTreeView.Tree.RefreshSelectedTreeNodeChildrens(); BusinessFlowTreeItem BFTI = new BusinessFlowTreeItem(BF); mTreeView.Tree.GetChildItembyNameandSelect(BF.Name, this); } } }