Skip to content

Commit

Permalink
Merge pull request #32 from jankcat/release/r2.6
Browse files Browse the repository at this point in the history
Release/r2.6
  • Loading branch information
jankcat committed Jun 19, 2015
2 parents 9be80c5 + dece700 commit 0d10ee4
Show file tree
Hide file tree
Showing 18 changed files with 814 additions and 10 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# rapidreporterplusplus
A fork of http://testing.gershon.info/reporter/

Please read the file titled "Readme.docx" for detailed instructions.
Please read the file titled "Readme.docx" for detailed instructions.

The secondary project is a converter tool for Issue #30, convert RR2.4/2.5 sessions into RR2.6 sessions.
2 changes: 1 addition & 1 deletion Rapid Reporter/HTML/HTMLEmbedder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal static string BuildSessionRow_Img(int imgCount, string imgFile)
var str = MakeImageSrcData(imgFile);
return
string.Format(
"<a href=\"#\" onclick=\"ShowImgEle('imgdiv{0}', 'imgbig{0}', 'imgsmall{0}');\"><img id='imgsmall{0}' src=\"{1}\"></a>{2}",
"<a href=\"#\" onclick=\"ShowImgEle('imgdiv{0}', 'imgbig{0}', 'imgsmall{0}');\"><img id='imgsmall{0}' src=\"\"></a><script>var imgSrcData{0} = \"{1}\"; document.getElementById(\"imgsmall{0}\").src = imgSrcData{0};</script>{2}",
imgCount, str, "&nbsp;");
}

Expand Down
2 changes: 1 addition & 1 deletion Rapid Reporter/HTML/Htmlstrings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static class Htmlstrings

static Htmlstrings()
{
AHtmlHead = "<html>\r\n <head>\r\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n <title>";
AHtmlHead = "<html>\r\n <head>\r\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n <!--RR++V2.6-->\r\n <title>";
BTitleOut = " </title>";
CStyle = "\r\n <style>\r\n html *\r\n {\r\n font-family: Verdana !important;\r\n font-size: 11px;\r\n }\r\n .aroundtable {font-family: Verdana; font-size: 11px; }\r\n H1 {text-align: center; font-family: Verdana;}\r\n H5 {text-align: center; font-family: Verdana; font-weight: normal;} \r\n table {margin-left: auto; margin-right: auto; min-width:700px; width:80%; border-collapse: collapse; border: 1px solid black;}\r\n table tr img {max-width: 350px; max-height: 250px; resize-scale: showall;}\r\n table tr td {padding: 2px;}\r\n\r\n table tr.Session {font-weight: bold; background: #FAFAFA;}\r\n table tr.Scenario {font-weight: bold; background: #FAFAFA;}\r\n table tr.Environment {font-weight: bold; background: #FAFAFA;}\r\n table tr.Versions {font-weight: bold; background: #FAFAFA;}\r\n\r\n table tr.Bug\\/Issue {background: #FF4D4D;}\r\n table tr.Follow {background: #5CADFF;}\r\n table tr.Note {background: #FAFAFA;}\r\n table tr.Test {background: #FAFAFA;}\r\n table tr.Success {background: #80FF80;}\r\n table tr.Prerequisite {background: #FAFAFA;}\r\n table tr.Summary {background: #FAFAFA;}\r\n\r\n table tr.Screenshot {background: #FAFAFA;}\r\n table tr.PlainText {background: #FAFAFA;}\r\n\r\n table td.notetype {font-weight: bold; width:190px;}\r\n table td.timestamp {font-weight: bold; width:175px;}\r\n </style>";
DJavascript = "\r\n <script>\r\n function ShowImgEle(eleId, bigImgId, littleImgId)\r\n {\r\n var sessionTable = document.getElementById('aroundtable');\r\n\t sessionTable.style.display = \"none\";\r\n\t var bigImgDiv = document.getElementById(eleId);\r\n\t bigImgDiv.style.display = \"inline\";\r\n\t //bigImgDiv.style.background = \"url('\"+img64+\"') no-repeat\";\r\n\t //bigImgDiv.style.backgroundPosition = \"0px 15px\";\r\n\t bigImgDiv.style.textDecoration = \"underline\";\r\n var bigImg = document.getElementById(bigImgId);\r\n var littleImg = document.getElementById(littleImgId);\r\n bigImg.src = littleImg.src;\r\n }\r\n function HideImgEle(eleId)\r\n {\r\n\t var bigImgDiv = document.getElementById(eleId);\r\n var sessionTable = document.getElementById('aroundtable');\r\n\t sessionTable.style.display = \"inline\";\r\n\t bigImgDiv.style.display = \"none\";\r\n }\r\n function ShowPlaintextNote(eleId)\r\n {\r\n\t var ele = document.getElementById(eleId);\r\n var eletable = document.getElementById('aroundtable');\r\n\t eletable.style.display = \"none\";\r\n\t ele.style.display = \"inline\";\r\n }\r\n function HidePlaintextNote(eleId)\r\n {\r\n\t var ele = document.getElementById(eleId);\r\n var eletable = document.getElementById('aroundtable');\r\n\t eletable.style.display = \"inline\";\r\n\t ele.style.display = \"none\";\r\n }\r\n </script>\r\n </head>";
Expand Down
6 changes: 3 additions & 3 deletions Rapid Reporter/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
[assembly: AssemblyConfiguration("Requires .NET framework 4.5")]
[assembly: AssemblyCompany("Timothy Watkins")]
[assembly: AssemblyProduct("Rapid Reporter++")]
[assembly: AssemblyCopyright("Copyright © 2014 Timothy Watkins.")]
[assembly: AssemblyCopyright("Copyright © 2014-2015 Timothy Watkins.")]
[assembly: AssemblyTrademark("Rapid Reporter++")]
[assembly: AssemblyCulture("")]

Expand Down Expand Up @@ -50,7 +50,7 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.5.0.0")]
[assembly: AssemblyFileVersion("2.5.0.0")]
[assembly: AssemblyVersion("2.6.0.0")]
[assembly: AssemblyFileVersion("2.6.0.0")]
[assembly: GuidAttribute("7AEB6D97-FCA8-4197-8DBD-0017E3B00468")]
[assembly: NeutralResourcesLanguageAttribute("en-US")]
2 changes: 1 addition & 1 deletion Rapid Reporter/Rapid Reporter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<PublisherName>Shmuel Gershon</PublisherName>
<SuiteName>Session Master</SuiteName>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>2.4.0.%2a</ApplicationVersion>
<ApplicationVersion>2.6.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>false</BootstrapperEnabled>
Expand Down
12 changes: 10 additions & 2 deletions RapidReporter.sln
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rapid Reporter", "Rapid Reporter\Rapid Reporter.csproj", "{196CF724-3EB5-4E53-B9D5-DA733A7D6CC7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RapidReporterSharePointFix30", "RapidReporterSharePointFix30\RapidReporterSharePointFix30.csproj", "{3960F435-F941-4CC9-8A3B-D852484F4ECD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -14,6 +18,10 @@ Global
{196CF724-3EB5-4E53-B9D5-DA733A7D6CC7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{196CF724-3EB5-4E53-B9D5-DA733A7D6CC7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{196CF724-3EB5-4E53-B9D5-DA733A7D6CC7}.Release|Any CPU.Build.0 = Release|Any CPU
{3960F435-F941-4CC9-8A3B-D852484F4ECD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3960F435-F941-4CC9-8A3B-D852484F4ECD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3960F435-F941-4CC9-8A3B-D852484F4ECD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3960F435-F941-4CC9-8A3B-D852484F4ECD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
6 changes: 6 additions & 0 deletions RapidReporterSharePointFix30/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
87 changes: 87 additions & 0 deletions RapidReporterSharePointFix30/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

201 changes: 201 additions & 0 deletions RapidReporterSharePointFix30/Form1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
using System;
using System.IO;
using System.Linq;
using System.Windows.Forms;

namespace RapidReporterSharePointFix30
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void btnChoosefile_Click(object sender, EventArgs e)
{
string text;
var result = openFileDialog1.ShowDialog();
if (result != DialogResult.OK) return;
var fn = openFileDialog1.FileName;
try
{
text = File.ReadAllText(fn);
}
catch (IOException exception)
{
MessageBox.Show(exception.Message, exception.ToString());
return;
}
if (string.IsNullOrWhiteSpace(text))
{
MessageBox.Show(@"File was empty or could not be read;");
return;
}
if (text.Contains("<!--RR++V"))
{
MessageBox.Show(@"File created with new version of Rapid Reporter++ and cannot be converted at this time");
return;
}
if (text.Contains("function ShowImgEle(eleId, img64)"))
{
MessageBox.Show(@"File created with really old version of Rapid Reporter++ and cannot be converted at this time");
return;
}
if (!text.Contains("function ShowImgEle(eleId, bigImgId, littleImgId)"))
{
MessageBox.Show(@"File created with unknown version of Rapid Reporter++ and cannot be converted at this time");
return;
}
int count;
var outputHtml = ConvertOldStringToNew(text, out count);
MessageBox.Show(string.Format("Successfully converted {0} images.", count));
saveFileDialog1.FileName = openFileDialog1.FileName;
var saveResult = saveFileDialog1.ShowDialog();
if (saveResult != DialogResult.OK) return;
var sfn = saveFileDialog1.FileName;
try
{
File.WriteAllText(sfn, outputHtml);
}
catch (IOException exception)
{
MessageBox.Show(exception.Message, exception.ToString());
}
}

private void FolderBtn_Click(object sender, EventArgs e)
{
var result = folderBrowserDialog1.ShowDialog();
if (result != DialogResult.OK) return;
var files = Directory.GetFiles(folderBrowserDialog1.SelectedPath).ToList();
files = files.Where(f => f.EndsWith("html") || f.EndsWith("htm")).ToList();
if (!files.Any())
{
MessageBox.Show(@"No HTML or HTM files found in directory");
return;
}
var root = folderBrowserDialog1.SelectedPath;
if (!root.EndsWith("\\")) root += "\\";
var errorDir = root + "error\\";
var oldDir = root + "old\\";
var newDir = root + "new\\";

int errorCnt = 0, goodCnt = 0, imgCnt = 0;

try
{
Directory.CreateDirectory(newDir);
Directory.CreateDirectory(oldDir);
Directory.CreateDirectory(errorDir);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, ex.ToString());
return;
}

foreach (var f in files)
{
string text;
try
{
text = File.ReadAllText(f);
}
catch (IOException exception)
{
File.Move(f, errorDir + Path.GetFileName(f));
errorCnt++;
continue;
}
if (string.IsNullOrWhiteSpace(text))
{
File.Move(f, errorDir + Path.GetFileName(f));
errorCnt++;
continue;
}
if (text.Contains("<!--RR++V"))
{
File.Move(f, errorDir + Path.GetFileName(f));
errorCnt++;
continue;
}
if (text.Contains("function ShowImgEle(eleId, img64)"))
{
File.Move(f, errorDir + Path.GetFileName(f));
errorCnt++;
continue;
}
if (!text.Contains("function ShowImgEle(eleId, bigImgId, littleImgId)"))
{
File.Move(f, errorDir + Path.GetFileName(f));
errorCnt++;
continue;
}
int count;
var outputHtml = ConvertOldStringToNew(text, out count);
imgCnt += count;
goodCnt++;
File.WriteAllText(newDir + Path.GetFileName(f), outputHtml);
File.Move(f, oldDir + Path.GetFileName(f));
}
MessageBox.Show(string.Format("Successfully converted {0} images in {1} files. {2} files failed.", imgCnt, goodCnt, errorCnt));
}


private static string ConvertOldStringToNew(string old, out int count)
{
var trimmedHtml = old;
var outputHtml = old;
count = 0;
while (true)
{
var id = GetImageId(trimmedHtml);
if (string.IsNullOrWhiteSpace(id)) break;
var src = GetImageSrc(trimmedHtml, id);
if (string.IsNullOrWhiteSpace(src)) break;
outputHtml = GetNewOutput(outputHtml, id, src);
trimmedHtml = TrimBuffer(trimmedHtml, id, src);
count++;
}
return outputHtml;
}

private static string GetImageId(string msg)
{
var startOf1 = msg.IndexOf("');\"><img id='imgsmall", StringComparison.Ordinal);
if (startOf1 < 0) return null;
startOf1 += "');\"><img id='imgsmall".Length;
var chopped = msg.Substring(startOf1);
var startOf2 = chopped.IndexOf("' src=\"data:image/png;base64", StringComparison.Ordinal);
if (startOf2 < 0) return null;
return chopped.Substring(0, startOf2);
}

private static string GetImageSrc(string msg, string id)
{
var start1Str = string.Format("');\"><img id='imgsmall{0}' src=\"", id);
var startOf1 = msg.IndexOf(start1Str, StringComparison.Ordinal);
if (startOf1 < 0) return null;
startOf1 += start1Str.Length;
var chopped = msg.Substring(startOf1);
var startOf2 = chopped.IndexOf("\"></a>&nbsp;", StringComparison.Ordinal);
if (startOf2 < 0) return null;
return chopped.Substring(0, startOf2);
}

private static string GetNewOutput(string msg, string id, string src)
{
var oldStr = string.Format("');\"><img id='imgsmall{0}' src=\"{1}\"></a>&nbsp;", id, src);
var newStr = string.Format("');\"><img id='imgsmall{0}' src=\"\"></a><script>var imgSrcData{0} = \"{1}\"; document.getElementById(\"imgsmall{0}\").src = imgSrcData{0};</script>&nbsp;", id, src);
return msg.Replace(oldStr, newStr);
}

private static string TrimBuffer(string msg, string id, string src)
{
var oldStr = string.Format("');\"><img id='imgsmall{0}' src=\"{1}\"></a>&nbsp;", id, src);
var start = msg.IndexOf(oldStr, StringComparison.Ordinal) + oldStr.Length;
return msg.Substring(start);
}
}
}
Loading

0 comments on commit 0d10ee4

Please sign in to comment.