private async Task <bool> ShowXMLTemplatesOperations()
        {
            bool parseSuccess = true;

            AddAPIModelWizard.ProcessStarted();

            XMLTemplateParser WSDLP = new XMLTemplateParser();
            ObservableList <ApplicationAPIModel> AAMTempList      = new ObservableList <ApplicationAPIModel>();
            ObservableList <ApplicationAPIModel> AAMCompletedList = new ObservableList <ApplicationAPIModel>();

            foreach (TemplateFile XTF in AddAPIModelWizard.XTFList)
            {
                try
                {
                    AAMTempList = await Task.Run(() => WSDLP.ParseDocument(XTF.FilePath, AddAPIModelWizard.AvoidDuplicatesNodes));

                    if (!string.IsNullOrEmpty(XTF.MatchingResponseFilePath))
                    {
                        AAMTempList[0].ReturnValues = await Task.Run(() => APIConfigurationsDocumentParserBase.ParseResponseSampleIntoReturnValuesPerFileType(XTF.MatchingResponseFilePath));
                    }
                    AAMCompletedList.Add(AAMTempList[0]);
                }
                catch (Exception ex)
                {
                    Reporter.ToUser(eUserMsgKeys.ParsingError, "Failed to Parse the XML" + XTF.FilePath);
                    GingerCoreNET.ReporterLib.Reporter.ToLog(GingerCoreNET.ReporterLib.eLogLevel.ERROR, "Error Details: " + ex.Message + "Failed to Parse the XML" + XTF.FilePath);
                    parseSuccess = false;
                }
            }

            AddAPIModelWizard.AAMList         = AAMCompletedList;
            xApisSelectionGrid.DataSourceList = AddAPIModelWizard.AAMList;
            // AddAPIModelWizard.FinishEnabled = false;
            AddAPIModelWizard.ProcessEnded();

            return(parseSuccess);
        }
        private async Task <bool> ShowXMLTemplatesOperations()
        {
            bool parseSuccess = true;

            AddAPIModelWizard.ProcessStarted();

            XMLTemplateParser WSDLP = new XMLTemplateParser();
            ObservableList <ApplicationAPIModel> AAMTempList      = new ObservableList <ApplicationAPIModel>();
            ObservableList <ApplicationAPIModel> AAMCompletedList = new ObservableList <ApplicationAPIModel>();

            foreach (TemplateFile XTF in AddAPIModelWizard.XTFList)
            {
                try
                {
                    AAMTempList = await Task.Run(() => WSDLP.ParseDocument(XTF.FilePath));

                    if (!string.IsNullOrEmpty(XTF.MatchingResponseFilePath))
                    {
                        AAMTempList[0].ReturnValues = await Task.Run(() => APIConfigurationsDocumentParserBase.ParseResponseSampleIntoReturnValuesPerFileType(XTF.MatchingResponseFilePath));
                    }
                    AAMCompletedList.Add(AAMTempList[0]);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error Details:" + Environment.NewLine + ex.Message, "Failed to Parse the XML" + XTF.FilePath, System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error, System.Windows.MessageBoxResult.None);
                    GingerCoreNET.ReporterLib.Reporter.ToLog(GingerCoreNET.ReporterLib.eLogLevel.ERROR, "Error Details: " + ex.Message + "Failed to Parse the XML" + XTF.FilePath);
                    parseSuccess = false;
                }
            }

            AddAPIModelWizard.AAMList         = AAMCompletedList;
            OperationsDataGrid.DataSourceList = AddAPIModelWizard.AAMList;
            // AddAPIModelWizard.FinishEnabled = false;
            AddAPIModelWizard.ProcessEnded();

            return(parseSuccess);
        }
Example #3
0
        private void TestToOutput(SoapUIUtils soapUIUtils, Act act)
        {
            Dictionary <string, List <string> > dict = new Dictionary <string, List <string> >();

            dict = soapUIUtils.RequestsAndResponds();
            foreach (KeyValuePair <string, List <string> > kpr in dict)
            {
                if (!string.IsNullOrEmpty(kpr.Value[1]))
                {
                    string requestQouteFixed = kpr.Value[1].Replace("\"", "");
                    requestQouteFixed = requestQouteFixed.Replace("\0", "");
                    act.AddOrUpdateReturnParamActual(kpr.Value[0] + "-Request", requestQouteFixed);
                }
                if (!string.IsNullOrEmpty(kpr.Value[2]))
                {
                    string responseQouteFixed = string.Empty;

                    //if response is JSON format then not replace double quotes
                    if (kpr.Value[2].IndexOf("{") > -1)
                    {
                        responseQouteFixed = kpr.Value[2];
                    }
                    else
                    {
                        responseQouteFixed = kpr.Value[2].Replace("\"", "");
                    }


                    responseQouteFixed = responseQouteFixed.Replace("\0", "");

                    act.AddOrUpdateReturnParamActual(kpr.Value[0] + "-Response", responseQouteFixed);
                    if (((ActSoapUI)act).AddXMLResponse_Value)
                    {
                        string fileContent = kpr.Value[2];
                        ObservableList <ActReturnValue> ReturnValues = null;
                        if (APIConfigurationsDocumentParserBase.IsValidJson(fileContent))
                        {
                            ReturnValues = JSONTemplateParser.ParseJSONResponseSampleIntoReturnValues(fileContent);
                            foreach (ActReturnValue ReturnValue in ReturnValues)
                            {
                                act.ReturnValues.Add(ReturnValue);
                            }
                        }
                        else if (APIConfigurationsDocumentParserBase.IsValidXML(fileContent))
                        {
                            XmlDocument xmlDoc1 = new XmlDocument();
                            xmlDoc1.LoadXml(kpr.Value[2]);

                            List <GingerCore.General.XmlNodeItem> outputTagsList1 = new List <GingerCore.General.XmlNodeItem>();
                            outputTagsList1 = General.GetXMLNodesItems(xmlDoc1);
                            foreach (GingerCore.General.XmlNodeItem outputItem in outputTagsList1)
                            {
                                act.AddOrUpdateReturnParamActualWithPath(outputItem.param, outputItem.value, outputItem.path);
                            }
                        }
                    }
                }
                if (!string.IsNullOrEmpty(kpr.Value[4]))
                {
                    string messageQouteFixed = kpr.Value[4].Replace("\"", "");
                    messageQouteFixed = messageQouteFixed.Replace("\0", "");
                    act.AddOrUpdateReturnParamActual(kpr.Value[0] + "-Message", kpr.Value[4]);
                }
                if (!string.IsNullOrEmpty(kpr.Value[5]))
                {
                    string propertiesQouteFixed = kpr.Value[4].Replace("\"", "");
                    propertiesQouteFixed = propertiesQouteFixed.Replace("\0", "");
                    act.AddOrUpdateReturnParamActual(kpr.Value[0] + "-Properties", kpr.Value[5]);
                }
            }

            Dictionary <List <string>, List <string> > dictValues = new Dictionary <List <string>, List <string> >();

            dictValues = soapUIUtils.OutputParamAndValues();
            foreach (KeyValuePair <List <string>, List <string> > Kpr in dictValues)
            {
                int index = 0;
                if (Kpr.Key.Count() != 0 && Kpr.Value.Count() != 0)
                {
                    foreach (string property in Kpr.Key)
                    {
                        act.AddOrUpdateReturnParamActual(Kpr.Key[index], Kpr.Value[index]);
                        index++;
                    }
                }
            }
        }