-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram - LastWorking.cs
182 lines (150 loc) · 5.35 KB
/
Program - LastWorking.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/*
* Created by SharpDevelop.
* User: ankit.pal
* Date: 6/22/2015
* Time: 11:23 AM
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
namespace RobotXMLParser
{
class Program
{
//static string xmlFilePath = @"C:\Users\Ankit\AppData\Local\Temp\RIDErqsay1.d";
static string MyXmlFile;
static string XMLconfigPath;
public Program()
{
//Console.WriteLine(ConfigurationManager.AppSettings.Get("inputFilePath"));
//Console.WriteLine(ConfigurationManager.AppSettings.Get("OutputFilePath"));
//XMLconfigPath = AppDomain.CurrentDomain.BaseDirectory;
XMLconfigPath = @"C:\Users\ankit.pal\Desktop\1";
MyXmlFile = XMLconfigPath+"\\output.xml";
}
static void Main(string[] args)
{
//xmlFilePath = (AppDomain.CurrentDomain.BaseDirectory);
Console.WriteLine(AppDomain.CurrentDomain.BaseDirectory);
Program oProg = new Program();
var orobot = oProg.Deserialized();
oProg.ProcessRoboXml(orobot);
oProg.Serialized(orobot);
string strCmdText;
string timeStamp = DateTime.Now.ToString("yyyyMMdd-HHmmss");
strCmdText = "/C rebot --log " + XMLconfigPath + "\\" + timeStamp + "_LOG.html --report " + XMLconfigPath + "\\" + timeStamp + "_REPORT.html " + XMLconfigPath + "\\ParsedRobotXML.xml";
//strCmdText = "/C rebot --log " + XMLconfigPath + "\\Log.html --report " + XMLconfigPath + "\\Report.html " + XMLconfigPath + "\\ParsedRobotXML.xml";
System.Diagnostics.Process.Start("CMD.exe", strCmdText);
}
public Robot Deserialized()
{
var serializer = new XmlSerializer(typeof(Robot));
var fileStream = new FileStream(MyXmlFile, FileMode.Open);
//var fileStream = new FileStream(xmlFilePath+@"\output.xml", FileMode.Open);
var result = (Robot)serializer.Deserialize(fileStream);
return result;
}
public void Serialized(Robot oRobot)
{
var serializer = new XmlSerializer(typeof(Robot));
var obj = File.Create(XMLconfigPath + "\\ParsedRobotXML.xml");
//var obj = File.Create(xmlFilePath + @"\RobotXMLParser.xml");
serializer.Serialize(obj, oRobot);
obj.Flush();
}
public void ProcessRoboXml(Robot oRobot)
{
for (int i = 0; i < oRobot.Suite.Count; i++)
{
ProcessTestSuite(oRobot.Suite[i]);
}
}
public void ProcessTestSuite(TestSuite oTestSuite)
{
for (int i = 0; i < oTestSuite.TestSuites.Count; i++)
{
ProcessTestSuite(oTestSuite.TestSuites[i]);
}
for (int j = 0; j < oTestSuite.TestCases.Count;j++)
{
ProcessTestCase(oTestSuite.TestCases[j]);
}
}
List<Keyword> logKeywords;
public void ProcessTestCase(TestCase oTestCase)
{
bool LogFlagFalse = false;
for (int i = 0; i < oTestCase.KeywordName.Count; i++)
{
//LogFlagFalse = ProcessKeyWord(oTestCase.KeywordName[i]);
LogFlagFalse = PreProcessKeyWord(oTestCase.KeywordName[i]);
if (LogFlagFalse)
{
oTestCase.KeywordName.RemoveAt(i);
i--;
}
}
}
bool isLogItem = false;
public bool ProcessKeyWord(Keyword oKeyword)
{
bool flag = false;
for (int i = 0; i < oKeyword.Keywords.Count; i++)
{
if(oKeyword.Keywords[i].Keywords.Count>0)
{
isLogItem=false;
flag = ProcessKeyWord(oKeyword.Keywords[i]);
if(!flag)
{
i--;
// isLogItem = false;
}
// else
// {
// isLogItem=false;
// }
}
else if((oKeyword.Keywords[i].Keywords.Count==0)&&!(oKeyword.Keywords[i].Name.ToLower().Equals("builtin.log")))
{
if(oKeyword.Keywords[i].Status[0].Status.Equals("PASS"))
{
oKeyword.Keywords.RemoveAt(i);
i--;
}
}
else if(oKeyword.Keywords[i].Name.ToLower().Equals("builtin.log"))
{
isLogItem=true;
}
}
return isLogItem;
}
public bool PreProcessKeyWord(Keyword oKeyword)
{
bool isLog=false;
if (oKeyword.Keywords.Count == 0)
{
if (oKeyword.Name.ToLower().Equals("builtin.log"))
{
return false;
}
if(oKeyword.Status[0].Status.Equals("PASS"))
{
return true;
}
}
else
{
isLog = ProcessKeyWord(oKeyword);
}
return isLog;
}
}
}