Exemple #1
0
 private void SetBFPropertiesAfterImport(BusinessFlow tsBusFlow)
 {
     if (WorkSpace.Instance.Solution.MainApplication != null)
     {
         //add the applications mapped to the Activities
         foreach (Activity activ in tsBusFlow.Activities)
             if (string.IsNullOrEmpty(activ.TargetApplication) == false)
                 if (tsBusFlow.TargetApplications.Where(x => x.Name == activ.TargetApplication).FirstOrDefault() == null)
                 {
                     ApplicationPlatform appAgent = WorkSpace.Instance.Solution.ApplicationPlatforms.Where(x => x.AppName == activ.TargetApplication).FirstOrDefault();
                     if (appAgent != null)
                         tsBusFlow.TargetApplications.Add(new TargetApplication() { AppName = appAgent.AppName });
                 }
         //handle non mapped Activities
         if (tsBusFlow.TargetApplications.Count == 0)
             tsBusFlow.TargetApplications.Add(new TargetApplication() { AppName = WorkSpace.Instance.Solution.MainApplication });
         foreach (Activity activ in tsBusFlow.Activities)
         {
             if (string.IsNullOrEmpty(activ.TargetApplication))
                 activ.TargetApplication = tsBusFlow.MainApplication;
             activ.Active = true;
         }
     }
     else
     {
         foreach (Activity activ in tsBusFlow.Activities)
             activ.TargetApplication = null; // no app configured on solution level
     }
 }
        private ObservableList <Act> GetPlatformsActions(bool ShowAll = false)
        {
            ObservableList <Act> Acts = new ObservableList <Act>();

            AppDomain.CurrentDomain.Load("GingerCore");
            AppDomain.CurrentDomain.Load("GingerCoreCommon");
            AppDomain.CurrentDomain.Load("GingerCoreNET");

            var ActTypes = new List <Type>();

            foreach (Assembly GC in AppDomain.CurrentDomain.GetAssemblies().Where(assembly => assembly.GetName().Name.Contains("GingerCore")))
            {
                var types = from type in GC.GetTypes() where type.IsSubclassOf(typeof(Act)) && type != typeof(ActWithoutDriver) select type;
                ActTypes.AddRange(types);
            }

            foreach (Type t in ActTypes)
            {
                Act a = (Act)Activator.CreateInstance(t);

                if (a.IsSelectableAction == false)
                {
                    continue;
                }

                if (mContext.BusinessFlow.CurrentActivity == null)
                {
                    return(null);
                }
                TargetApplication TA = (TargetApplication)(from x in mContext.BusinessFlow.TargetApplications where x.Name == mContext.BusinessFlow.CurrentActivity.TargetApplication select x).FirstOrDefault();
                if (TA == null)
                {
                    if (mContext.BusinessFlow.TargetApplications.Count == 1)
                    {
                        TA = (TargetApplication)mContext.BusinessFlow.TargetApplications.FirstOrDefault();
                        mContext.BusinessFlow.CurrentActivity.TargetApplication = TA.AppName;
                    }
                    else
                    {
                        Reporter.ToUser(eUserMsgKey.MissingActivityAppMapping);
                        return(null);
                    }
                }
                ApplicationPlatform AP = (from x in WorkSpace.Instance.Solution.ApplicationPlatforms where x.AppName == TA.AppName select x).FirstOrDefault();
                if (AP != null)
                {
                    if (a.Platforms.Contains(AP.Platform))
                    {
                        //DO Act.GetSampleAct in base
                        if ((Acts.Where(c => c.GetType() == a.GetType()).FirstOrDefault()) == null)
                        {
                            a.Description = a.ActionDescription;
                            a.Active      = true;
                            Acts.Add(a);
                        }
                    }
                }
            }
            return(Acts);
        }
Exemple #3
0
        private void UpdateApplicationNameChangeInSolution(ApplicationPlatform app)
        {
            int numOfAfectedBFs = 0;

            if (Reporter.ToUser(eUserMsgKey.UpdateApplicationNameChangeInSolution) == Amdocs.Ginger.Common.eUserMsgSelection.No)
            {
                return;
            }

            foreach (BusinessFlow bf in WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <BusinessFlow>())
            {
                //update the BF target applications
                foreach (TargetApplication bfApp in bf.TargetApplications)
                {
                    if (bfApp.AppName == app.NameBeforeEdit)
                    {
                        bfApp.AppName = app.AppName;

                        //update the bf activities
                        foreach (Activity activity in bf.Activities)
                        {
                            if (activity.TargetApplication == app.NameBeforeEdit)
                            {
                                activity.TargetApplication = app.AppName;
                            }
                        }

                        numOfAfectedBFs++;
                        break;
                    }
                }
            }
            Reporter.ToUser(eUserMsgKey.StaticInfoMessage, string.Format("{0} {1} were updated successfully, please remember to Save All change.", numOfAfectedBFs, GingerDicser.GetTermResValue(eTermResKey.BusinessFlows)));
        }
Exemple #4
0
        public static void LoadOnCurrentApplicationDomain(
            IntPtr gameDllNameAsPointer,
            IntPtr gameTypeNameAsPointer,
            int currentPlatformAsInteger)
        {
            Platform currentPlatform = (Platform)currentPlatformAsInteger;

            ApplicationPlatform.Initialize(currentPlatform, Controller.RuntimeLibrary);
            string stringAnsi1 = Marshal.PtrToStringAnsi(gameDllNameAsPointer);
            string stringAnsi2 = Marshal.PtrToStringAnsi(gameTypeNameAsPointer);

            Debug.Print("Appending private path to current application domain.");
            AppDomain.CurrentDomain.AppendPrivatePath(ManagedDllFolder.Name);
            Debug.Print("Creating GameApplicationDomainController on current application domain.");
            GameApplicationDomainController domainController = new GameApplicationDomainController(false);

            if (domainController == null)
            {
                Console.WriteLine("GameApplicationDomainController is NULL!");
                Console.WriteLine("Press a key to continue...");
                Console.ReadKey();
            }
            if (Controller.RuntimeLibrary == TaleWorlds.Library.Runtime.Mono)
            {
                Debug.Print("Initializing GameApplicationDomainController as Mono.");
                domainController.LoadAsMono(Controller._passManagedInitializeMethodPointer, Controller._passManagedCallbackMethodPointer, stringAnsi1, stringAnsi2, currentPlatform);
            }
            else
            {
                Debug.Print("Initializing GameApplicationDomainController as Dot Net.");
                domainController.Load(Controller._passManagedInitializeMethod, Controller._passManagedCallbackMethod, stringAnsi1, stringAnsi2, currentPlatform);
            }
        }
        private void xTargetApplicationComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            xAgentComboBox.IsEnabled = true;
            ApplicationPlatform ap = (ApplicationPlatform)xTargetApplicationComboBox.SelectedItem;
            List <Agent>        optionalAgentsList = (from x in WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <Agent>() where x.Platform == ap.Platform select x).ToList();

            xAgentComboBox.ItemsSource = optionalAgentsList;
        }
Exemple #6
0
        public NewSolutionTargetApplicationWizardPage(Solution solution)
        {
            InitializeComponent();
            ApplicationPlatform applicationPlatform = new ApplicationPlatform();

            MainApplicationNameTextBox.BindControl(applicationPlatform, nameof(ApplicationPlatform.AppName));
            MainApplicationPlatformComboBox.BindControl(applicationPlatform, nameof(applicationPlatform.Platform));
        }
Exemple #7
0
        public AddApplicationPage()
        {
            InitializeComponent();

            mApplicationPlatform = new ApplicationPlatform();
            NameTextBox.BindControl(mApplicationPlatform, nameof(ApplicationPlatform.AppName));
            PlatformComboBox.BindControl(mApplicationPlatform, nameof(ApplicationPlatform.Platform));
        }
Exemple #8
0
 private void ApplicationGrid_PreparingCellForEdit(object sender, DataGridPreparingCellForEditEventArgs e)
 {
     if (e.Column.DisplayIndex == 0)//App Name Column
     {
         ApplicationPlatform currentApp = (ApplicationPlatform)xTargetApplicationsGrid.CurrentItem;
         currentApp.NameBeforeEdit = currentApp.AppName;
     }
 }
Exemple #9
0
        internal Application()
        {
            var platformTypeAttribute = ReflectionHelper.GetAttribute <PlatformTypeAttribute>(GetType());

            if (!ReflectionHelper.IsTypeDerived(platformTypeAttribute.PlatformType, typeof(ApplicationPlatform)))
            {
                throw new InvalidOperationException("PlatformType must be derived from ApplicationPlatform.");
            }

            services                 = new ServiceRegistry();
            appTime                  = new ApplicationTime();
            totalTime                = new TimeSpan();
            timer                    = new TimerTick();
            IsFixedTimeStep          = false;
            maximumElapsedTime       = TimeSpan.FromMilliseconds(500.0);
            TargetElapsedTime        = TimeSpan.FromTicks(10000000 / 120); // target elapsed time is by default 60Hz
            lastUpdateCount          = new int[4];
            nextLastUpdateCountIndex = 0;

            // Calculate the updateCountAverageSlowLimit (assuming moving average is >=3 )
            // Example for a moving average of 4:
            // updateCountAverageSlowLimit = (2 * 2 + (4 - 2)) / 4 = 1.5f
            const int BadUpdateCountTime = 2; // number of bad frame (a bad frame is a frame that has at least 2 updates)
            var       maxLastCount       = 2 * Math.Min(BadUpdateCountTime, lastUpdateCount.Length);

            updateCountAverageSlowLimit = (float)(maxLastCount + (lastUpdateCount.Length - maxLastCount)) / lastUpdateCount.Length;

            services.AddService(typeof(IWindowService), this);
            services.AddService(typeof(ITimeService), appTime);

            // Setup Content Manager
            contentManager = new ContentManager(services);
            contentManager.AddMapping(AssetType.EngineReferences, typeof(EngineReferenceCollection));
            contentManager.AddMapping(AssetType.Model, typeof(Model));
            contentManager.AddMapping(AssetType.Effect, typeof(ShaderCollection));
            contentManager.AddMapping(AssetType.Texture2D, typeof(Texture2D));
            contentManager.AddMapping(AssetType.TextureCube, typeof(TextureCube));
            contentManager.AddMapping(AssetType.Cutscene, typeof(Cutscene));

            var additionalServices = ReflectionHelper.GetAttributes <RequiredServiceAttribute>(GetType());

            foreach (var requiredService in additionalServices)
            {
                var service = Activator.CreateInstance(requiredService.ClassType, services);
                services.AddService(requiredService.ServiceType, service);
            }

            // Setup Platform
            applicationPlatform                = (ApplicationPlatform)Activator.CreateInstance(platformTypeAttribute.PlatformType, this);
            applicationPlatform.Activated     += ApplicationPlatformActivated;
            applicationPlatform.Deactivated   += ApplicationPlatformDeactivated;
            applicationPlatform.Exiting       += ApplicationPlatform_Exiting;
            applicationPlatform.WindowCreated += ApplicationPlatformWindowCreated;
        }
        void AddFirstAgentForSolutionForApplicationPlatfrom(ApplicationPlatform MainApplicationPlatform)
        {
            Agent           agent           = new Agent();
            AgentOperations agentOperations = new AgentOperations(agent);

            agent.AgentOperations = agentOperations;

            agent.Name = MainApplicationPlatform.AppName + " - Agent 1";
            switch (MainApplicationPlatform.Platform)
            {
            case ePlatformType.ASCF:
                agent.DriverType = Agent.eDriverType.ASCF;
                break;

            case ePlatformType.DOS:
                agent.DriverType = Agent.eDriverType.DOSConsole;
                break;

            case ePlatformType.Mobile:
                agent.DriverType = Agent.eDriverType.Appium;
                break;

            case ePlatformType.PowerBuilder:
                agent.DriverType = Agent.eDriverType.PowerBuilder;
                break;

            case ePlatformType.Unix:
                agent.DriverType = Agent.eDriverType.UnixShell;
                break;

            case ePlatformType.Web:
                agent.DriverType = Agent.eDriverType.SeleniumChrome;
                break;

            case ePlatformType.WebServices:
                agent.DriverType = Agent.eDriverType.WebServices;
                break;

            case ePlatformType.Windows:
                agent.DriverType = Agent.eDriverType.WindowsAutomation;
                break;

            case ePlatformType.Java:
                agent.DriverType = Agent.eDriverType.JavaDriver;
                break;

            default:
                Reporter.ToUser(eUserMsgKey.StaticWarnMessage, "No default driver set for first agent");
                break;
            }

            agent.AgentOperations.InitDriverConfigs();
            WorkSpace.Instance.SolutionRepository.AddRepositoryItem(agent);
        }
Exemple #11
0
        private void SetPossibleAgentsGridData()
        {
            ObservableList <Agent> optionalAgents = new ObservableList <Agent>();

            if (mApplicationAgent != null)
            {
                //find out the target application platform
                ApplicationPlatform ap = (from x in App.UserProfile.Solution.ApplicationPlatforms where x.AppName == mApplicationAgent.AppName select x).FirstOrDefault();
                if (ap != null)
                {
                    ePlatformType appPlatform = ap.Platform;

                    //get the solution Agents which match to this platform
                    //List<Agent> optionalAgentsList = (from p in App.UserProfile.Solution.Agents where p.Platform == appPlatform select p).ToList();
                    List <Agent> optionalAgentsList = (from p in WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <Agent>() where p.Platform == appPlatform select p).ToList();
                    if (optionalAgentsList != null && mGingerRunner != null)
                    {
                        //remove already mapped agents
                        List <ApplicationAgent> mappedApps = mGingerRunner.ApplicationAgents.Where(x => x.Agent != null).ToList();
                        foreach (ApplicationAgent mappedApp in mappedApps)
                        {
                            if (mappedApp.Agent.Platform == appPlatform && mappedApp != mApplicationAgent)
                            {
                                optionalAgentsList.Remove(mappedApp.Agent);
                            }
                        }

                        foreach (Agent agent in optionalAgentsList)
                        {
                            optionalAgents.Add(agent);
                        }
                    }
                }
            }

            if (optionalAgents.Count == 0)
            {
                Reporter.ToUser(eUserMsgKeys.NoOptionalAgent);
            }

            grdPossibleAgents.DataSourceList = optionalAgents;

            //select the current mapped agent in the list
            foreach (Agent agent in optionalAgents)
            {
                if (agent == mApplicationAgent.Agent)
                {
                    grdPossibleAgents.Grid.SelectedItem = agent;
                }
            }
        }
Exemple #12
0
        private void ApplicationGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
        {
            //Validate the name of the App is unique
            if (e.Column.DisplayIndex == 0)//App Name Column
            {
                ApplicationPlatform currentApp = (ApplicationPlatform)xTargetApplicationsGrid.CurrentItem;
                mSolution.SetUniqueApplicationName(currentApp);

                if (currentApp.AppName != currentApp.NameBeforeEdit)
                {
                    UpdateApplicationNameChangeInSolution(currentApp);
                }
            }
        }
        private void XAgentNameComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            //save last used agent on the Solution Target Applications
            ApplicationAgent ag = ApplicationAgents.Where(x => x.Agent == (Agent)((ComboBox)sender).SelectedValue).FirstOrDefault();

            if (ag != null)
            {
                ApplicationPlatform ap = WorkSpace.Instance.Solution.ApplicationPlatforms.Where(x => x.AppName == ag.AppName).FirstOrDefault();
                if (ap != null)
                {
                    ap.LastMappedAgentName = ag.AgentName;
                }
            }
        }
        private void SetGridView()
        {
            GridViewDef view = new GridViewDef(GridViewDef.DefaultViewName);

            view.GridColsView = new ObservableList <GridColView>();

            view.GridColsView.Add(new GridColView()
            {
                Field = "Selected", WidthWeight = 20, StyleType = GridColView.eGridColStyleType.CheckBox
            });
            view.GridColsView.Add(new GridColView()
            {
                Field = "AppName", Header = "Application Name", WidthWeight = 50, ReadOnly = true, BindingMode = BindingMode.OneWay
            });
            view.GridColsView.Add(new GridColView()
            {
                Field = "Platform", Header = "Platform", WidthWeight = 30, ReadOnly = true, BindingMode = BindingMode.OneWay
            });

            AppsGrid.SetAllColumnsDefaultView(view);
            AppsGrid.InitViewItems();

            foreach (ApplicationPlatform AP in  WorkSpace.Instance.Solution.ApplicationPlatforms)
            {
                ApplicationPlatform AP1 = new ApplicationPlatform();
                AP1.AppName  = AP.AppName;
                AP1.Platform = AP.Platform;

                // If this App was selected before then mark it
                TargetApplication APS = (TargetApplication)(from x in mBusinessFlow.TargetApplications where x.Name == AP.AppName select x).FirstOrDefault();

                if (APS != null)
                {
                    AP1.Selected = true;
                }

                mApplicationsPlatforms.Add(AP1);
            }

            AppsGrid.DataSourceList = mApplicationsPlatforms;
        }
Exemple #15
0
        public void SetUniqueApplicationName(ApplicationPlatform app)
        {
            if (this.ApplicationPlatforms.Where(obj => obj.AppName == app.AppName).FirstOrDefault() == null)
            {
                return;                                                                                              //no name like it in the group
            }
            List <ApplicationPlatform> sameNameObjList =
                this.ApplicationPlatforms.Where(obj => obj.AppName == app.AppName).ToList <ApplicationPlatform>();

            if (sameNameObjList.Count == 1 && sameNameObjList[0] == app)
            {
                return;                                                          //Same internal object
            }
            //Set unique name
            int counter = 2;

            while ((this.ApplicationPlatforms.Where(obj => obj.AppName == app.AppName + counter).FirstOrDefault()) != null)
            {
                counter++;
            }
            app.AppName += counter.ToString();
        }
Exemple #16
0
        private void MapSelectedAgent()
        {
            if (grdPossibleAgents.Grid.SelectedItem == null)
            {
                Reporter.ToUser(eUserMsgKey.NoItemWasSelected);
                return;
            }
            else
            {
                Agent selectedAgent = (Agent)grdPossibleAgents.Grid.SelectedItem;
                mApplicationAgent.Agent = selectedAgent;

                //save last used agent on the Solution Target Applications
                ApplicationPlatform ap = WorkSpace.Instance.Solution.ApplicationPlatforms.Where(x => x.AppName == mApplicationAgent.AppName).FirstOrDefault();
                if (ap != null)
                {
                    ap.LastMappedAgentName = selectedAgent.Name;
                }
            }

            _pageGenericWin.Close();
        }
Exemple #17
0
        public void POMWithTargetApplicationKey()
        {
            //Arrange
            ApplicationPlatform AP = new ApplicationPlatform();

            AP.AppName = "App1";
            RepositoryItemKey key = AP.Key;

            ApplicationPOMModel POM = new ApplicationPOMModel();

            POM.Name = "POM1";
            POM.TargetApplicationKey = AP.Key;


            //Act
            string xml = RS.SerializeToString(POM);
            ApplicationPOMModel POM2 = (ApplicationPOMModel)NewRepositorySerializer.DeserializeFromText(xml);

            //Assert
            Assert.AreEqual(POM.Name, POM2.Name);
            Assert.AreEqual(POM2.TargetApplicationKey.Guid, key.Guid);
            Assert.AreEqual(POM2.TargetApplicationKey.ItemName, key.ItemName);
        }
Exemple #18
0
        private void UpdateApplicationNameChangeInSolution(ApplicationPlatform app)
        {
            int numOfAfectedBFs = 0;

            if (Reporter.ToUser(eUserMsgKeys.UpdateApplicationNameChangeInSolution) == MessageBoxResult.No)
            {
                return;
            }


            foreach (BusinessFlow bf in App.LocalRepository.GetSolutionBusinessFlows())
            {
                //update the BF target applications
                foreach (TargetApplication bfApp in bf.TargetApplications)
                {
                    if (bfApp.AppName == app.NameBeforeEdit)
                    {
                        App.AddItemToSaveAll(bf);
                        bfApp.AppName = app.AppName;

                        //update the bf activities
                        foreach (Activity activity in bf.Activities)
                        {
                            if (activity.TargetApplication == app.NameBeforeEdit)
                            {
                                activity.TargetApplication = app.AppName;
                            }
                        }

                        numOfAfectedBFs++;
                        break;
                    }
                }
            }
            Reporter.ToUser(eUserMsgKeys.StaticInfoMessage, string.Format("{0} {1} were updated successfully, please remember to Save All change.", numOfAfectedBFs, GingerDicser.GetTermResValue(eTermResKey.BusinessFlows)));
        }
Exemple #19
0
        public override bool ImportSelectedTests(string importDestinationPath, IEnumerable <Object> testPlanList)
        {
            if (testPlanList != null)
            {
                foreach (RQMTestPlan testPlan in testPlanList)
                {
                    //Refresh Ginger repository and allow GingerRQM to use it

                    ALMIntegration.Instance.AlmCore.GingerActivitiesGroupsRepo = App.LocalRepository.GetSolutionRepoActivitiesGroups(false);
                    ALMIntegration.Instance.AlmCore.GingerActivitiesGroupsRepo = App.LocalRepository.GetSolutionRepoActivitiesGroups(false);
                    ALMIntegration.Instance.AlmCore.GingerActivitiesRepo       = App.LocalRepository.GetSolutionRepoActivities(false);

                    try
                    {
                        BusinessFlow existedBF = App.LocalRepository.GetSolutionBusinessFlows().Where(x => x.ExternalID == RQMID + "=" + testPlan.RQMID).FirstOrDefault();
                        if (existedBF != null)
                        {
                            MessageBoxResult userSelection = Reporter.ToUser(eUserMsgKeys.TestSetExists, testPlan.Name);
                            if (userSelection == MessageBoxResult.Yes)
                            {
                                File.Delete(existedBF.FileName);
                            }
                        }

                        Reporter.ToGingerHelper(eGingerHelperMsgKey.ALMTestSetImport, null, testPlan.Name);

                        // convert test set into BF
                        BusinessFlow tsBusFlow = ALMIntegration.Instance.AlmCore.ConvertRQMTestPlanToBF(testPlan);

                        if (App.UserProfile.Solution.MainApplication != null)
                        {
                            //add the applications mapped to the Activities
                            foreach (Activity activ in tsBusFlow.Activities)
                            {
                                if (string.IsNullOrEmpty(activ.TargetApplication) == false)
                                {
                                    if (tsBusFlow.TargetApplications.Where(x => x.AppName == activ.TargetApplication).FirstOrDefault() == null)
                                    {
                                        ApplicationPlatform appAgent = App.UserProfile.Solution.ApplicationPlatforms.Where(x => x.AppName == activ.TargetApplication).FirstOrDefault();
                                        if (appAgent != null)
                                        {
                                            tsBusFlow.TargetApplications.Add(new TargetApplication()
                                            {
                                                AppName = appAgent.AppName
                                            });
                                        }
                                    }
                                }
                            }
                            //handle non mapped Activities
                            if (tsBusFlow.TargetApplications.Count == 0)
                            {
                                tsBusFlow.TargetApplications.Add(new TargetApplication()
                                {
                                    AppName = App.UserProfile.Solution.MainApplication
                                });
                            }
                            foreach (Activity activ in tsBusFlow.Activities)
                            {
                                if (string.IsNullOrEmpty(activ.TargetApplication))
                                {
                                    activ.TargetApplication = tsBusFlow.MainApplication;
                                }
                            }
                        }
                        else
                        {
                            foreach (Activity activ in tsBusFlow.Activities)
                            {
                                activ.TargetApplication = null; // no app configured on solution level
                            }
                        }

                        //save bf
                        tsBusFlow.FileName = LocalRepository.GetRepoItemFileName(tsBusFlow, importDestinationPath);
                        tsBusFlow.SaveToFile(tsBusFlow.FileName);
                        //add to cach
                        App.LocalRepository.AddItemToCache(tsBusFlow);
                        Reporter.CloseGingerHelper();
                    }
                    catch (Exception ex)
                    {
                        Reporter.ToUser(eUserMsgKeys.ErrorInTestsetImport, testPlan.Name, ex.Message);
                    }

                    //Refresh the solution tree
                    App.MainWindow.RefreshSolutionPage();

                    Reporter.ToUser(eUserMsgKeys.TestSetsImportedSuccessfully);
                }
                return(true);
            }
            return(false);
        }
Exemple #20
0
        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //TODO: replace with robot message
                Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
                //check name and folder inputs exists
                if (SolutionNameTextBox.Text.Trim() == string.Empty || SolutionFolderTextBox.Text.Trim() == string.Empty ||
                    ApplicationTextBox.Text.Trim() == string.Empty ||
                    MainPlatformComboBox.SelectedItem == null || MainPlatformComboBox.SelectedItem.ToString() == "Null")
                {
                    Mouse.OverrideCursor = null;
                    Reporter.ToUser(eUserMsgKey.MissingAddSolutionInputs);
                    return;
                }

                mSolution.ApplicationPlatforms = new ObservableList <ApplicationPlatform>();
                ApplicationPlatform MainApplicationPlatform = new ApplicationPlatform();
                MainApplicationPlatform.AppName  = ApplicationTextBox.Text;
                MainApplicationPlatform.Platform = (ePlatformType)MainPlatformComboBox.SelectedValue;
                mSolution.ApplicationPlatforms.Add(MainApplicationPlatform);

                //TODO: check AppName and platform validity - not empty + app exist in list of apps

                //validate solution
                if (!mSolution.Folder.EndsWith(@"\"))
                {
                    mSolution.Folder += @"\";
                }

                //make sure main folder exist
                if (!System.IO.Directory.Exists(mSolution.Folder))
                {
                    System.IO.Directory.CreateDirectory(mSolution.Folder);
                }

                //create new folder with solution name
                mSolution.Folder += mSolution.Name + @"\";
                if (!System.IO.Directory.Exists(mSolution.Folder))
                {
                    System.IO.Directory.CreateDirectory(mSolution.Folder);
                }

                //check solution not already exist
                if (System.IO.File.Exists(System.IO.Path.Combine(mSolution.Folder, @"Ginger.Solution.xml")) == false)
                {
                    mSolution.FilePath = System.IO.Path.Combine(mSolution.Folder, @"Ginger.Solution.xml");
                    mSolution.SaveSolution(false);
                }
                else
                {
                    //solution already exist
                    Mouse.OverrideCursor = null;
                    Reporter.ToUser(eUserMsgKey.SolutionAlreadyExist);
                    return;
                }

                App.SetSolution(mSolution.Folder);

                //Create default items
                AddFirstAgentForSolutionForApplicationPlatfrom(MainApplicationPlatform);
                App.UpdateApplicationsAgentsMapping();
                AddDefaultDataSource();
                AddDeafultReportTemplate();
                AutomatePage.CreateDefaultEnvironment();
                WorkSpace.Instance.SolutionRepository.AddRepositoryItem(App.GetNewBusinessFlow("Flow 1", true));

                //show success message to user
                Mouse.OverrideCursor = null;
                Reporter.ToUser(eUserMsgKey.AddSolutionSucceed);
                _pageGenericWin.Close();
            }
            catch (Exception ex)
            {
                Mouse.OverrideCursor = null;
                Reporter.ToUser(eUserMsgKey.AddSolutionFailed, ex.Message);
            }
        }
Exemple #21
0
        public override bool ImportSelectedTests(string importDestinationPath, IEnumerable <Object> selectedTestSets)
        {
            if (selectedTestSets != null && selectedTestSets.Count() > 0)
            {
                ObservableList <QCTestSetTreeItem> testSetsItemsToImport = new ObservableList <QCTestSetTreeItem>();
                bool bfsWereDeleted = false;
                foreach (QCTestSetTreeItem testSetItem in selectedTestSets)
                {
                    //check if some of the Test Set was already imported
                    if (testSetItem.AlreadyImported == true)
                    {
                        MessageBoxResult userSelection = Reporter.ToUser(eUserMsgKeys.TestSetExists, testSetItem.TestSetName);
                        if (userSelection == MessageBoxResult.Yes)
                        {
                            //Delete the mapped BF
                            File.Delete(testSetItem.MappedBusinessFlow.FileName);
                            bfsWereDeleted = true;
                            testSetsItemsToImport.Add(testSetItem);
                        }
                    }
                    else
                    {
                        testSetsItemsToImport.Add(testSetItem);
                    }
                }

                if (testSetsItemsToImport.Count == 0)
                {
                    return(false);                                  //noting to import
                }
                //Refresh Ginger repository and allow GingerQC to use it
                ALMIntegration.Instance.AlmCore.GingerActivitiesGroupsRepo = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <ActivitiesGroup>();
                ALMIntegration.Instance.AlmCore.GingerActivitiesRepo       = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <Activity>();

                foreach (QCTestSetTreeItem testSetItemtoImport in testSetsItemsToImport)
                {
                    try
                    {
                        //import test set data
                        Reporter.ToGingerHelper(eGingerHelperMsgKey.ALMTestSetImport, null, testSetItemtoImport.TestSetName);
                        QCTestSet TS = new QCTestSet();
                        TS.TestSetID   = testSetItemtoImport.TestSetID;
                        TS.TestSetName = testSetItemtoImport.TestSetName;
                        TS.TestSetPath = testSetItemtoImport.Path;
                        TS             = ((QCCore)ALMIntegration.Instance.AlmCore).ImportTestSetData(TS);

                        //convert test set into BF
                        BusinessFlow tsBusFlow = ((QCCore)ALMIntegration.Instance.AlmCore).ConvertQCTestSetToBF(TS);

                        //Set BF/Activities target application
                        //if (App.UserProfile.Solution.MainApplication != null)
                        //{
                        //    if (tsBusFlow.TargetApplications.Count == 0)
                        //    {
                        //        tsBusFlow.TargetApplications.Add(new TargetApplication() { AppName = App.UserProfile.Solution.MainApplication });
                        //        if (tsBusFlow.TargetApplications.Count > 0)
                        //            foreach (Activity activ in tsBusFlow.Activities)
                        //                activ.TargetApplication = tsBusFlow.TargetApplications[0].AppName;
                        //    }
                        //}
                        if (App.UserProfile.Solution.MainApplication != null)
                        {
                            //add the applications mapped to the Activities
                            foreach (Activity activ in tsBusFlow.Activities)
                            {
                                if (string.IsNullOrEmpty(activ.TargetApplication) == false)
                                {
                                    if (tsBusFlow.TargetApplications.Where(x => x.Name == activ.TargetApplication).FirstOrDefault() == null)
                                    {
                                        ApplicationPlatform appAgent = App.UserProfile.Solution.ApplicationPlatforms.Where(x => x.AppName == activ.TargetApplication).FirstOrDefault();
                                        if (appAgent != null)
                                        {
                                            tsBusFlow.TargetApplications.Add(new TargetApplication()
                                            {
                                                AppName = appAgent.AppName
                                            });
                                        }
                                    }
                                }
                            }
                            //handle non mapped Activities
                            if (tsBusFlow.TargetApplications.Count == 0)
                            {
                                tsBusFlow.TargetApplications.Add(new TargetApplication()
                                {
                                    AppName = App.UserProfile.Solution.MainApplication
                                });
                            }
                            foreach (Activity activ in tsBusFlow.Activities)
                            {
                                if (string.IsNullOrEmpty(activ.TargetApplication))
                                {
                                    activ.TargetApplication = tsBusFlow.MainApplication;
                                }
                            }
                        }
                        else
                        {
                            foreach (Activity activ in tsBusFlow.Activities)
                            {
                                activ.TargetApplication = null; // no app configured on solution level
                            }
                        }

                        //save bf
                        WorkSpace.Instance.SolutionRepository.AddRepositoryItem(tsBusFlow);
                        Reporter.CloseGingerHelper();
                    }
                    catch (Exception ex)
                    {
                        Reporter.ToUser(eUserMsgKeys.ErrorInTestsetImport, testSetItemtoImport.TestSetName, ex.Message);
                        Reporter.ToLog(eAppReporterLogLevel.ERROR, "Error importing from QC", ex);
                    }
                }

                Reporter.ToUser(eUserMsgKeys.TestSetsImportedSuccessfully);

                Reporter.ToLog(eAppReporterLogLevel.INFO, "Imported from QC successfully");
                return(true);
            }
            Reporter.ToLog(eAppReporterLogLevel.ERROR, "Error importing from QC");
            return(false);
        }
        public override bool ImportSelectedTests(string importDestinationPath, IEnumerable <Object> selectedTestSuites)
        {
            if (selectedTestSuites != null && selectedTestSuites.Count() > 0)
            {
                ObservableList <QtestSuiteTreeItem> testSuitesItemsToImport = new ObservableList <QtestSuiteTreeItem>();
                foreach (QtestSuiteTreeItem testSuiteItem in selectedTestSuites)
                {
                    //check if some of the Test Set was already imported
                    if (testSuiteItem.AlreadyImported)
                    {
                        Amdocs.Ginger.Common.eUserMsgSelection userSelection = Reporter.ToUser(eUserMsgKey.TestSetExists, testSuiteItem.Name);
                        if (userSelection == Amdocs.Ginger.Common.eUserMsgSelection.Yes)
                        {
                            //Delete the mapped BF
                            File.Delete(testSuiteItem.MappedBusinessFlow.FileName);
                            testSuitesItemsToImport.Add(testSuiteItem);
                        }
                    }
                    else
                    {
                        testSuitesItemsToImport.Add(testSuiteItem);
                    }
                }

                if (testSuitesItemsToImport.Count == 0)
                {
                    return(false); //noting to import
                }

                //Refresh Ginger repository and allow GingerQC to use it
                ALMIntegration.Instance.AlmCore.InitCoreObjs();

                foreach (QtestSuiteTreeItem testSetItemtoImport in testSuitesItemsToImport)
                {
                    try
                    {
                        Reporter.ToStatus(eStatusMsgKey.ALMTestSetImport, null, testSetItemtoImport.Name);
                        QtestTestSuite TS = new QtestTestSuite();
                        TS.ID   = testSetItemtoImport.ID;
                        TS.Name = testSetItemtoImport.Name;
                        TS      = ((QtestCore)ALMIntegration.Instance.AlmCore).ImportTestSetData(TS);

                        //convert test set into BF
                        BusinessFlow tsBusFlow = ((QtestCore)ALMIntegration.Instance.AlmCore).ConvertQCTestSetToBF(TS);

                        if (WorkSpace.Instance.Solution.MainApplication != null)
                        {
                            //add the applications mapped to the Activities
                            foreach (Activity activ in tsBusFlow.Activities)
                            {
                                if (!string.IsNullOrEmpty(activ.TargetApplication))
                                {
                                    if (tsBusFlow.TargetApplications.Where(x => x.Name == activ.TargetApplication).FirstOrDefault() == null)
                                    {
                                        ApplicationPlatform appAgent = WorkSpace.Instance.Solution.ApplicationPlatforms.Where(x => x.AppName == activ.TargetApplication).FirstOrDefault();
                                        if (appAgent != null)
                                        {
                                            tsBusFlow.TargetApplications.Add(new TargetApplication()
                                            {
                                                AppName = appAgent.AppName
                                            });
                                        }
                                    }
                                }
                            }
                            //handle non mapped Activities
                            if (tsBusFlow.TargetApplications.Count == 0)
                            {
                                tsBusFlow.TargetApplications.Add(new TargetApplication()
                                {
                                    AppName = WorkSpace.Instance.Solution.MainApplication
                                });
                            }
                            foreach (Activity activ in tsBusFlow.Activities)
                            {
                                if (string.IsNullOrEmpty(activ.TargetApplication))
                                {
                                    activ.TargetApplication = tsBusFlow.MainApplication;
                                }
                                activ.Active = true;
                            }
                        }
                        else
                        {
                            foreach (Activity activ in tsBusFlow.Activities)
                            {
                                activ.TargetApplication = null; // no app configured on solution level
                            }
                        }

                        //save bf
                        AddTestSetFlowToFolder(tsBusFlow, importDestinationPath);
                        Reporter.HideStatusMessage();
                    }
                    catch (Exception ex)
                    {
                        Reporter.ToUser(eUserMsgKey.ErrorInTestsetImport, testSetItemtoImport.Name, ex.Message);
                        Reporter.ToLog(eLogLevel.ERROR, "Error importing from QC", ex);
                    }
                }

                Reporter.ToUser(eUserMsgKey.TestSetsImportedSuccessfully);

                Reporter.ToLog(eLogLevel.DEBUG, "Imported from QC successfully");
                return(true);
            }
            Reporter.ToLog(eLogLevel.ERROR, "Error importing from QC");
            return(false);
        }
Exemple #23
0
        public override bool ImportSelectedTests(string importDestinationPath, IEnumerable <Object> testPlanList)
        {
            if (testPlanList != null)
            {
                foreach (RallyTestPlan testPlan in testPlanList)
                {
                    //Refresh Ginger repository and allow GingerRally to use it
                    ALMIntegration.Instance.AlmCore.GingerActivitiesGroupsRepo = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <ActivitiesGroup>();
                    ALMIntegration.Instance.AlmCore.GingerActivitiesRepo       = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <Activity>();

                    try
                    {
                        BusinessFlow existedBF = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <BusinessFlow>().Where(x => x.ExternalID == RallyID + "=" + testPlan.RallyID).FirstOrDefault();
                        if (existedBF != null)
                        {
                            Amdocs.Ginger.Common.eUserMsgSelection userSelection = Reporter.ToUser(eUserMsgKey.TestSetExists, testPlan.Name);
                            if (userSelection == Amdocs.Ginger.Common.eUserMsgSelection.Yes)
                            {
                                File.Delete(existedBF.FileName);
                            }
                        }

                        Reporter.ToStatus(eStatusMsgKey.ALMTestSetImport, null, testPlan.Name);

                        // convert test set into BF
                        BusinessFlow tsBusFlow = ALMIntegration.Instance.AlmCore.ConvertRallyTestPlanToBF(testPlan);

                        if (WorkSpace.UserProfile.Solution.MainApplication != null)
                        {
                            //add the applications mapped to the Activities
                            foreach (Activity activ in tsBusFlow.Activities)
                            {
                                if (string.IsNullOrEmpty(activ.TargetApplication) == false)
                                {
                                    if (tsBusFlow.TargetApplications.Where(x => x.Name == activ.TargetApplication).FirstOrDefault() == null)
                                    {
                                        ApplicationPlatform appAgent = WorkSpace.UserProfile.Solution.ApplicationPlatforms.Where(x => x.AppName == activ.TargetApplication).FirstOrDefault();
                                        if (appAgent != null)
                                        {
                                            tsBusFlow.TargetApplications.Add(new TargetApplication()
                                            {
                                                AppName = appAgent.AppName
                                            });
                                        }
                                    }
                                }
                            }
                            //handle non mapped Activities
                            if (tsBusFlow.TargetApplications.Count == 0)
                            {
                                tsBusFlow.TargetApplications.Add(new TargetApplication()
                                {
                                    AppName = WorkSpace.UserProfile.Solution.MainApplication
                                });
                            }
                            foreach (Activity activ in tsBusFlow.Activities)
                            {
                                if (string.IsNullOrEmpty(activ.TargetApplication))
                                {
                                    activ.TargetApplication = tsBusFlow.MainApplication;
                                }
                            }
                        }
                        else
                        {
                            foreach (Activity activ in tsBusFlow.Activities)
                            {
                                activ.TargetApplication = null; // no app configured on solution level
                            }
                        }

                        //save bf
                        WorkSpace.Instance.SolutionRepository.AddRepositoryItem(tsBusFlow);
                        Reporter.HideStatusMessage();
                    }
                    catch (Exception ex)
                    {
                        Reporter.ToUser(eUserMsgKey.ErrorInTestsetImport, testPlan.Name, ex.Message);
                    }

                    Reporter.ToUser(eUserMsgKey.TestSetsImportedSuccessfully);
                }
                return(true);
            }

            return(false);
        }
 public ApplicationEditPage(ApplicationPlatform applicationPlatform)
 {
     InitializeComponent();
     NameTextBox.BindControl(applicationPlatform, nameof(ApplicationPlatform.AppName));
     PlatformComboBox.BindControl(applicationPlatform, nameof(ApplicationPlatform.Platform));
 }
        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //TODO: replace with robot message
                Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
                //check name and folder inputs exists
                if (SolutionNameTextBox.Text.Trim() == string.Empty || SolutionFolderTextBox.Text.Trim() == string.Empty ||
                    ApplicationTextBox.Text.Trim() == string.Empty ||
                    MainPlatformComboBox.SelectedItem == null || MainPlatformComboBox.SelectedItem.ToString() == "Null" ||
                    UCEncryptionKey.EncryptionKeyPasswordBox.Password.Trim() == string.Empty)
                {
                    Mouse.OverrideCursor = null;
                    Reporter.ToUser(eUserMsgKey.MissingAddSolutionInputs);
                    return;
                }

                Regex regex = new Regex(@"^.*(?=.{8,16})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!*@#$%^&+=]).*$");
                if (!UCEncryptionKey.CheckKeyCombination())
                {
                    Mouse.OverrideCursor = null;
                    UCEncryptionKey.EncryptionKeyPasswordBox.Password = "";
                    return;
                }

                mSolution.ApplicationPlatforms = new ObservableList <ApplicationPlatform>();
                ApplicationPlatform MainApplicationPlatform = new ApplicationPlatform();
                MainApplicationPlatform.AppName  = ApplicationTextBox.Text;
                MainApplicationPlatform.Platform = (ePlatformType)MainPlatformComboBox.SelectedValue;
                mSolution.ApplicationPlatforms.Add(MainApplicationPlatform);
                mSolution.EncryptionKey = UCEncryptionKey.EncryptionKeyPasswordBox.Password;
                //TODO: check AppName and platform validity - not empty + app exist in list of apps


                //make sure main folder exist
                if (!System.IO.Directory.Exists(mSolution.Folder))
                {
                    System.IO.Directory.CreateDirectory(mSolution.Folder);
                }

                //create new folder with solution name
                mSolution.Folder = Path.Combine(mSolution.Folder, mSolution.Name);
                if (!System.IO.Directory.Exists(mSolution.Folder))
                {
                    System.IO.Directory.CreateDirectory(mSolution.Folder);
                }

                //check solution not already exist
                if (System.IO.File.Exists(System.IO.Path.Combine(mSolution.Folder, @"Ginger.Solution.xml")) == false)
                {
                    mSolution.FilePath = System.IO.Path.Combine(mSolution.Folder, @"Ginger.Solution.xml");
                    mSolution.SolutionOperations.SaveEncryptionKey();
                    mSolution.SolutionOperations.SaveSolution(false);
                }
                else
                {
                    //solution already exist
                    Mouse.OverrideCursor = null;
                    Reporter.ToUser(eUserMsgKey.SolutionAlreadyExist);
                    return;
                }

                WorkSpace.Instance.OpenSolution(mSolution.Folder);

                //Create default items
                AddFirstAgentForSolutionForApplicationPlatfrom(MainApplicationPlatform);
                App.OnAutomateBusinessFlowEvent(BusinessFlowWindows.AutomateEventArgs.eEventType.UpdateAppAgentsMapping, null);
                AddDefaultDataSource();
                AddDeafultReportTemplate();
                GingerCoreNET.GeneralLib.General.CreateDefaultEnvironment();
                WorkSpace.Instance.SolutionRepository.AddRepositoryItem(WorkSpace.Instance.GetNewBusinessFlow("Flow 1", true));
                mSolution.SolutionOperations.SetReportsConfigurations();

                //Save again to keep all defualt configurations setup
                mSolution.SolutionOperations.SaveSolution(false);
                //show success message to user
                Mouse.OverrideCursor = null;
                Reporter.ToUser(eUserMsgKey.AddSolutionSucceed);
                _pageGenericWin.Close();
            }
            catch (Exception ex)
            {
                Mouse.OverrideCursor = null;
                Reporter.ToUser(eUserMsgKey.AddSolutionFailed, ex.Message);
            }
        }
Exemple #26
0
        public bool ImportSelectedZephyrCyclesAndFolders(string importDestinationPath, IEnumerable<object> selectedObjects)
        {
            if (selectedObjects != null && selectedObjects.Count() > 0)
            {
                foreach (JiraZephyrTreeItem obj in selectedObjects)
                {
                    BusinessFlow existedBF;
                    if (obj is JiraZephyrFolderTreeItem)
                    {
                        existedBF = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems<BusinessFlow>().Where(x => x.ExternalID == ((JiraZephyrFolderTreeItem)obj).CycleId  && x.ExternalID2 == obj.Id).FirstOrDefault();
                    }
                    else
                    {
                        existedBF = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems<BusinessFlow>().Where(x => x.ExternalID == obj.Id && x.ExternalID2 == null).FirstOrDefault();
                    }

                    if (existedBF != null)
                    {
                        Amdocs.Ginger.Common.eUserMsgSelection userSelection = Reporter.ToUser(eUserMsgKey.TestSetExists, obj.Name);
                        if (userSelection == Amdocs.Ginger.Common.eUserMsgSelection.Yes)
                        {
                            File.Delete(existedBF.FileName);
                        }
                    }
                    Reporter.ToStatus(eStatusMsgKey.ALMTestSetImport, null, obj.Name);
                }

                //Refresh Ginger repository and allow GingerQC to use it
                ALMIntegration.Instance.AlmCore.GingerActivitiesGroupsRepo = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems<ActivitiesGroup>();
                ALMIntegration.Instance.AlmCore.GingerActivitiesRepo = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems<Activity>();

                foreach (JiraZephyrTreeItem obj in selectedObjects)
                {
                    try
                    {
                        Reporter.ToStatus(eStatusMsgKey.ALMTestSetImport, null, obj.Name);
                        JiraZephyrCycle currentCycle;
                        BusinessFlow tsBusFlow;
                        if (obj is JiraZephyrFolderTreeItem)
                        {
                            currentCycle = ((JiraCore)ALMIntegration.Instance.AlmCore).GetZephyrCycleOrFolderWithIssuesAndStepsAsCycle(obj.VersionId, ((JiraZephyrFolderTreeItem)obj).CycleId, ((JiraZephyrFolderTreeItem)obj).Id);
                            currentCycle.name = obj.Name;
                            currentCycle.description = ((JiraZephyrFolderTreeItem)obj).Description;
                            tsBusFlow = ((JiraCore)ALMIntegration.Instance.AlmCore).ConvertJiraZypherCycleToBF(currentCycle);
                            tsBusFlow.ExternalID = ((JiraZephyrFolderTreeItem)obj).CycleId;
                            tsBusFlow.ExternalID2 = obj.Id;
                        }
                        else
                        {
                            currentCycle = ((JiraCore)ALMIntegration.Instance.AlmCore).GetZephyrCycleOrFolderWithIssuesAndStepsAsCycle(obj.VersionId, obj.Id);
                            tsBusFlow = ((JiraCore)ALMIntegration.Instance.AlmCore).ConvertJiraZypherCycleToBF(currentCycle);
                        }

                        if (WorkSpace.Instance.Solution.MainApplication != null)
                        {
                            //add the applications mapped to the Activities
                            foreach (Activity activ in tsBusFlow.Activities)
                            {
                                if (!string.IsNullOrEmpty(activ.TargetApplication))
                                {
                                    if (tsBusFlow.TargetApplications.Where(x => x.Name == activ.TargetApplication).FirstOrDefault() == null)
                                    {
                                        ApplicationPlatform appAgent = WorkSpace.Instance.Solution.ApplicationPlatforms.Where(x => x.AppName == activ.TargetApplication).FirstOrDefault();
                                        if (appAgent != null)
                                        {
                                            tsBusFlow.TargetApplications.Add(new TargetApplication() { AppName = appAgent.AppName });
                                        }
                                    }
                                }
                            }
                            //handle non mapped Activities
                            if (tsBusFlow.TargetApplications.Count == 0)
                            {
                                tsBusFlow.TargetApplications.Add(new TargetApplication() { AppName = WorkSpace.Instance.Solution.MainApplication });
                            }
                            foreach (Activity activ in tsBusFlow.Activities)
                            {
                                if (string.IsNullOrEmpty(activ.TargetApplication))
                                {
                                    activ.TargetApplication = tsBusFlow.MainApplication;
                                }
                                activ.Active = true;
                            }
                        }
                        else
                        {
                            foreach (Activity activ in tsBusFlow.Activities)
                            {
                                activ.TargetApplication = null; // no app configured on solution level
                            }
                        }

                        //save bf
                        AddTestSetFlowToFolder(tsBusFlow, importDestinationPath);
                        Reporter.HideStatusMessage();
                    }
                    catch (Exception ex)
                    {
                        Reporter.ToUser(eUserMsgKey.ErrorInTestsetImport, obj.Name, ex.Message);
                        Reporter.ToLog(eLogLevel.ERROR, "Error importing from Jira-Zephyr", ex);
                    }
                }

                Reporter.ToUser(eUserMsgKey.TestSetsImportedSuccessfully);

                Reporter.ToLog(eLogLevel.DEBUG, "Imported from Jira-Zephyr successfully");
                return true;
            }
            Reporter.ToLog(eLogLevel.ERROR, "Error importing from Jira-Zephyr");
            return false;
        }
Exemple #27
0
        //ApplicationEditPage mApplicationEditPage = null;

        public ApplicationTreeItem(ApplicationPlatform ApplicationModel)
        {
            this.mApplicationPlatform = ApplicationModel;
        }
        void AddItemToSolution(string sourceFile, string targetFile, bool saveAsRepo, GlobalSolutionItem itemToImport)
        {
            if (itemToImport.ItemType == GlobalSolution.eImportItemType.Variables)
            {
                //Add Global Variables from the list
                if (VariableListToImport.Count > 0)
                {
                    foreach (VariableBase vb in VariableListToImport)
                    {
                        if (WorkSpace.Instance.Solution.Variables.Where(x => x.Name == vb.Name).FirstOrDefault() == null)
                        {
                            WorkSpace.Instance.Solution.AddVariable(vb);
                        }
                    }
                }
                return;
            }
            if (itemToImport.ItemType == GlobalSolution.eImportItemType.TargetApplication)
            {
                string[]            filePaths           = Directory.GetFiles(Path.Combine(SolutionFolder), "Ginger.Solution.xml", SearchOption.AllDirectories);
                Solution            solution            = (Solution)newRepositorySerializer.DeserializeFromFile(filePaths[0]);
                ApplicationPlatform applicationPlatform = solution.ApplicationPlatforms.Where(x => x.AppName == itemToImport.ItemName).FirstOrDefault();

                ApplicationPlatform appPlatform = WorkSpace.Instance.Solution.ApplicationPlatforms.Where(x => x.AppName == applicationPlatform.AppName && x.Platform == applicationPlatform.Platform).FirstOrDefault();
                if (appPlatform == null)
                {
                    WorkSpace.Instance.Solution.ApplicationPlatforms.Add(applicationPlatform);
                }
                return;
            }
            RepositoryItemBase repoItemToImport = null;

            if (itemToImport.ItemImportSetting == GlobalSolution.eImportSetting.Replace)
            {
                if (GlobalSolutionUtils.Instance.IsGingerRepositoryItem(sourceFile))
                {
                    RepositoryItemBase repositoryItem = newRepositorySerializer.DeserializeFromFile(sourceFile);
                    RepositoryItemBase repoItem       = GlobalSolutionUtils.Instance.GetRepositoryItemByGUID(itemToImport, repositoryItem);
                    if (repoItem != null)
                    {
                        WorkSpace.Instance.SolutionRepository.MoveSharedRepositoryItemToPrevVersion(repoItem);
                        if (itemToImport.ItemType == GlobalSolution.eImportItemType.DataSources)
                        {
                            DataSourceBase dataSource = (DataSourceBase)repoItem;
                            string         dsFile     = WorkSpace.Instance.Solution.SolutionOperations.ConvertSolutionRelativePath(dataSource.FilePath);
                            GlobalSolutionUtils.Instance.KeepBackupAndDeleteFile(dsFile);
                        }
                    }
                }
                else
                {
                    GlobalSolutionUtils.Instance.KeepBackupAndDeleteFile(targetFile);
                }
            }

            if (saveAsRepo)
            {
                repoItemToImport = newRepositorySerializer.DeserializeFromFile(sourceFile);
                repoItemToImport.ContainingFolder = Path.GetDirectoryName(targetFile);
                repoItemToImport.FilePath         = targetFile;
                if (!string.IsNullOrEmpty(itemToImport.ItemNewName))
                {
                    repoItemToImport.ItemName = itemToImport.ItemNewName;
                }
                if (itemToImport.ItemType == GlobalSolution.eImportItemType.DataSources)
                {
                    DataSourceBase dataSource = (DataSourceBase)repoItemToImport;
                    sourceFile = dataSource.FilePath.Replace("~", SolutionFolder);
                    string dsFile    = WorkSpace.Instance.Solution.SolutionOperations.ConvertSolutionRelativePath(dataSource.FilePath);
                    string directory = Path.GetDirectoryName(dsFile);
                    string ext       = Path.GetExtension(dsFile);
                    string fileName  = Path.GetFileName(dsFile);

                    string newFile = string.Empty;
                    if (!string.IsNullOrEmpty(itemToImport.ItemNewName))
                    {
                        newFile = Path.Combine(directory, itemToImport.ItemNewName + ext);
                    }
                    else
                    {
                        newFile = Path.Combine(directory, fileName);
                    }
                    dataSource.FilePath = WorkSpace.Instance.SolutionRepository.ConvertFullPathToBeRelative(newFile);
                    //
                    File.Copy(sourceFile, newFile);
                }
                //Create repository (sub) folder before adding
                AddRepositoryItem(itemToImport, repoItemToImport, targetFile);
            }
            else
            {
                if (!Directory.Exists(Path.GetDirectoryName(targetFile)))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(targetFile));
                }
                File.Copy(sourceFile, targetFile);
            }
        }