Skip to content
Browse files

Initial check in

svn path=/trunk/momareports/; revision=136608
  • Loading branch information...
0 parents commit d7fc2aad64724ad45e2a37806bb3b88353e1edc0 @gonzalop gonzalop committed Jun 22, 2009
Showing with 49,686 additions and 0 deletions.
  1. +1 −0 AUTHORS
  2. +22 −0 COPYING
  3. +17 −0 README
  4. +5 −0 createmomadb/App.config
  5. +26 −0 createmomadb/AssemblyInfo.cs
  6. +69 −0 createmomadb/createmomadb.cs
  7. +50 −0 createmomadb/createmomadb.csproj
  8. +231 −0 createmomadb/statements.txt
  9. +5 −0 loadmoma/App.config
  10. +26 −0 loadmoma/AssemblyInfo.cs
  11. +100 −0 loadmoma/DataAccess.cs
  12. +130 −0 loadmoma/MySqlDataAccess.cs
  13. +133 −0 loadmoma/loadmoma.cs
  14. +50 −0 loadmoma/loadmoma.csproj
  15. +5 −0 loadmomareport/App.config
  16. +26 −0 loadmomareport/AssemblyInfo.cs
  17. +106 −0 loadmomareport/DataAccess.cs
  18. +185 −0 loadmomareport/MySqlDataAccess.cs
  19. +504 −0 loadmomareport/loadmomareport.cs
  20. +53 −0 loadmomareport/loadmomareport.csproj
  21. +10,179 −0 loadmomareport/wpf-exclusions.txt
  22. +33 −0 moma.sln
  23. +1 −0 web/build/build.sh
  24. +14 −0 web/moma/moma.Tests/App.config
  25. +136 −0 web/moma/moma.Tests/AuthoringTests.txt
  26. +655 −0 web/moma/moma.Tests/Controllers/AccountControllerTest.cs
  27. +41 −0 web/moma/moma.Tests/Controllers/HomeControllerTest.cs
  28. +69 −0 web/moma/moma.Tests/Moma.Web.Tests.csproj
  29. +35 −0 web/moma/moma.Tests/Properties/AssemblyInfo.cs
  30. +26 −0 web/moma/moma.sln
  31. +344 −0 web/moma/moma/Content/Site.css
  32. BIN web/moma/moma/Content/images/Thumbs.db
  33. BIN web/moma/moma/Content/images/back_disabled.jpg
  34. BIN web/moma/moma/Content/images/back_enabled.jpg
  35. BIN web/moma/moma/Content/images/file.gif
  36. BIN web/moma/moma/Content/images/folder-closed.gif
  37. BIN web/moma/moma/Content/images/folder.gif
  38. BIN web/moma/moma/Content/images/forward_disabled.jpg
  39. BIN web/moma/moma/Content/images/forward_enabled.jpg
  40. BIN web/moma/moma/Content/images/header-logo.png
  41. BIN web/moma/moma/Content/images/minus.gif
  42. BIN web/moma/moma/Content/images/plus.gif
  43. BIN web/moma/moma/Content/images/se.gif
  44. BIN web/moma/moma/Content/images/sm.gif
  45. BIN web/moma/moma/Content/images/sort_asc.jpg
  46. BIN web/moma/moma/Content/images/sort_both.jpg
  47. BIN web/moma/moma/Content/images/sort_desc.jpg
  48. BIN web/moma/moma/Content/images/st.gif
  49. BIN web/moma/moma/Content/images/treeview-black-line.gif
  50. BIN web/moma/moma/Content/images/treeview-black.gif
  51. BIN web/moma/moma/Content/images/treeview-default-line.gif
  52. BIN web/moma/moma/Content/images/treeview-default.gif
  53. BIN web/moma/moma/Content/images/treeview-famfamfam-line.gif
  54. BIN web/moma/moma/Content/images/treeview-famfamfam.gif
  55. BIN web/moma/moma/Content/images/treeview-gray-line.gif
  56. BIN web/moma/moma/Content/images/treeview-gray.gif
  57. BIN web/moma/moma/Content/images/treeview-red-line.gif
  58. BIN web/moma/moma/Content/images/treeview-red.gif
  59. +68 −0 web/moma/moma/Content/jquery.treeview.css
  60. BIN web/moma/moma/Content/redmond/images/Thumbs.db
  61. BIN web/moma/moma/Content/redmond/images/ui-bg_flat_0_aaaaaa_40x100.png
  62. BIN web/moma/moma/Content/redmond/images/ui-bg_flat_55_fbec88_40x100.png
  63. BIN web/moma/moma/Content/redmond/images/ui-bg_glass_75_d0e5f5_1x400.png
  64. BIN web/moma/moma/Content/redmond/images/ui-bg_glass_85_dfeffc_1x400.png
  65. BIN web/moma/moma/Content/redmond/images/ui-bg_glass_95_fef1ec_1x400.png
  66. BIN web/moma/moma/Content/redmond/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png
  67. BIN web/moma/moma/Content/redmond/images/ui-bg_inset-hard_100_f5f8f9_1x100.png
  68. BIN web/moma/moma/Content/redmond/images/ui-bg_inset-hard_100_fcfdfd_1x100.png
  69. BIN web/moma/moma/Content/redmond/images/ui-icons_217bc0_256x240.png
  70. BIN web/moma/moma/Content/redmond/images/ui-icons_2e83ff_256x240.png
  71. BIN web/moma/moma/Content/redmond/images/ui-icons_469bdd_256x240.png
  72. BIN web/moma/moma/Content/redmond/images/ui-icons_6da8d5_256x240.png
  73. BIN web/moma/moma/Content/redmond/images/ui-icons_cd0a0a_256x240.png
  74. BIN web/moma/moma/Content/redmond/images/ui-icons_d8e7f3_256x240.png
  75. BIN web/moma/moma/Content/redmond/images/ui-icons_f9bd01_256x240.png
  76. +404 −0 web/moma/moma/Content/redmond/jquery-ui-1.7.1.custom.css
  77. +350 −0 web/moma/moma/Controllers/AccountController.cs
  78. +43 −0 web/moma/moma/Controllers/ApisController.cs
  79. +29 −0 web/moma/moma/Controllers/HomeController.cs
  80. +120 −0 web/moma/moma/Controllers/ReportsController.cs
  81. +140 −0 web/moma/moma/Controllers/SummaryController.cs
  82. +149 −0 web/moma/moma/Controllers/TreeController.cs
  83. +95 −0 web/moma/moma/DB/ApiData.cs
  84. +38 −0 web/moma/moma/DB/BaseData.cs
  85. +114 −0 web/moma/moma/DB/HomeData.cs
  86. +102 −0 web/moma/moma/DB/ReportsData.cs
  87. +203 −0 web/moma/moma/DB/SummaryData.cs
  88. +37 −0 web/moma/moma/DB/TreeData.cs
  89. +3 −0 web/moma/moma/Default.aspx
  90. +22 −0 web/moma/moma/Default.aspx.cs
  91. +1 −0 web/moma/moma/Global.asax
  92. +60 −0 web/moma/moma/Global.asax.cs
  93. +43 −0 web/moma/moma/Helpers/GChart.cs
  94. +99 −0 web/moma/moma/Helpers/MomaNode.cs
  95. +31 −0 web/moma/moma/Helpers/Pager.cs
  96. +83 −0 web/moma/moma/Helpers/Util.cs
  97. +13 −0 web/moma/moma/Models/ApiViewData.cs
  98. +15 −0 web/moma/moma/Models/ChartViewData.cs
  99. +4,345 −0 web/moma/moma/Models/MomaDataSet.Designer.cs
  100. +10 −0 web/moma/moma/Models/MomaDataSet.cs
  101. +9 −0 web/moma/moma/Models/MomaDataSet.xsc
  102. +116 −0 web/moma/moma/Models/MomaDataSet.xsd
  103. +20 −0 web/moma/moma/Models/MomaDataSet.xss
  104. +11 −0 web/moma/moma/Models/ReportsViewData.cs
  105. +16 −0 web/moma/moma/Models/SingleReportViewData.cs
  106. +13 −0 web/moma/moma/Models/SummaryViewData.cs
  107. +232 −0 web/moma/moma/Moma.Web.csproj
  108. +35 −0 web/moma/moma/Properties/AssemblyInfo.cs
  109. +6,850 −0 web/moma/moma/Scripts/MicrosoftAjax.debug.js
  110. +7 −0 web/moma/moma/Scripts/MicrosoftAjax.js
  111. +337 −0 web/moma/moma/Scripts/MicrosoftMvcAjax.debug.js
  112. +23 −0 web/moma/moma/Scripts/MicrosoftMvcAjax.js
  113. +6,255 −0 web/moma/moma/Scripts/jquery-1.3.2-vsdoc.js
  114. +4,410 −0 web/moma/moma/Scripts/jquery-1.3.2.js
  115. +6,255 −0 web/moma/moma/Scripts/jquery-1.3.2.min-vsdoc.js
  116. +53 −0 web/moma/moma/Scripts/jquery-1.3.2.min.js
  117. +20 −0 web/moma/moma/Scripts/jquery-ui-1.7.1.custom.min.js
  118. +3,464 −0 web/moma/moma/Scripts/jquery.dataTables.js
  119. +388 −0 web/moma/moma/Scripts/jquery.dataTables.min.js
  120. +72 −0 web/moma/moma/Scripts/jquery.treeview.async.js
  121. +251 −0 web/moma/moma/Scripts/jquery.treeview.js
  122. +15 −0 web/moma/moma/Scripts/jquery.treeview.min.js
  123. +16 −0 web/moma/moma/Scripts/jquery.treeview.pack.js
  124. +42 −0 web/moma/moma/Views/Account/ChangePassword.aspx
  125. +12 −0 web/moma/moma/Views/Account/ChangePasswordSuccess.aspx
  126. +37 −0 web/moma/moma/Views/Account/LogOn.aspx
  127. +47 −0 web/moma/moma/Views/Account/Register.aspx
  128. +61 −0 web/moma/moma/Views/Apis/Api.aspx
  129. +50 −0 web/moma/moma/Views/Apis/AppTable.ascx
  130. +11 −0 web/moma/moma/Views/Apis/Index.aspx
  131. +67 −0 web/moma/moma/Views/Home/Index.aspx
  132. +51 −0 web/moma/moma/Views/Reports/Index.aspx
  133. +116 −0 web/moma/moma/Views/Reports/SingleReport.aspx
  134. +9 −0 web/moma/moma/Views/Shared/Chart.ascx
  135. +12 −0 web/moma/moma/Views/Shared/Error.aspx
  136. +14 −0 web/moma/moma/Views/Shared/LogOnUserControl.ascx
  137. +12 −0 web/moma/moma/Views/Shared/NoData.aspx
  138. +54 −0 web/moma/moma/Views/Shared/Site.Master
  139. +17 −0 web/moma/moma/Views/Shared/TreeNode.ascx
  140. +17 −0 web/moma/moma/Views/Shared/ViewPager.ascx
  141. +51 −0 web/moma/moma/Views/Summary/Browse.aspx
  142. +23 −0 web/moma/moma/Views/Summary/Index.aspx
  143. +42 −0 web/moma/moma/Views/Tree/Index.aspx
  144. +34 −0 web/moma/moma/Views/Web.config
  145. +1 −0 web/moma/moma/Views/account
  146. +1 −0 web/moma/moma/Views/apis
  147. +1 −0 web/moma/moma/Views/home
  148. +1 −0 web/moma/moma/Views/reports
  149. +1 −0 web/moma/moma/Views/summary
  150. +1 −0 web/moma/moma/Views/tree
  151. +139 −0 web/moma/moma/Web.config
1 AUTHORS
@@ -0,0 +1 @@
+Gonzalo Paniagua Javier <gonzalo novell com>
22 COPYING
@@ -0,0 +1,22 @@
+Copyright (c) 2009 Novell, Inc. and the individuals listed
+on the ChangeLog entries.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
17 README
@@ -0,0 +1,17 @@
+* Directory Layout
+------------------
+
+ createmomadb/
+ creates the DB tables, views and stored procedures
+
+ loadmoma/
+ loads the definition files
+
+ loadmomareport/
+ loads MoMA reports
+
+ web/
+ web application that displays information from the DB
+
+Maintainer: gonzalo@novell.com
+
5 createmomadb/App.config
@@ -0,0 +1,5 @@
+<configuration>
+ <appSettings>
+ <add key="MomaDB" value="Server=localhost;Database=moma;User ID=gonzalo;Password=gonzalo;Pooling=true;Min Pool Size=4;" />
+ </appSettings>
+</configuration>
26 createmomadb/AssemblyInfo.cs
@@ -0,0 +1,26 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+// Information about this assembly is defined by the following attributes.
+// Change them to the values specific to your project.
+
+[assembly: AssemblyTitle("createmomadb")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright("")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
+// The form "{Major}.{Minor}.*" will automatically update the build and revision,
+// and "{Major}.{Minor}.{Build}.*" will update just the revision.
+
+[assembly: AssemblyVersion("1.0.*")]
+
+// The following attributes are used to specify the signing key for the assembly,
+// if desired. See the Mono documentation for more information about signing.
+
+[assembly: AssemblyDelaySign(false)]
+[assembly: AssemblyKeyFile("")]
69 createmomadb/createmomadb.cs
@@ -0,0 +1,69 @@
+using System;
+using System.Configuration;
+using System.Collections.Specialized;
+using System.Data;
+using System.Data.Common;
+using System.IO;
+using System.Text;
+
+using MySql.Data.MySqlClient;
+
+namespace Moma {
+ class MainClass {
+ static string cnc_string;
+
+ public static void Main (string[] args)
+ {
+ NameValueCollection col = ConfigurationManager.AppSettings;
+ cnc_string = col ["MomaDB"];
+ if (String.IsNullOrEmpty (cnc_string))
+ throw new ApplicationException ("Missing connection string from configuration file.");
+
+ foreach (string arg in args) {
+ ProcessFile (arg);
+ }
+ Console.WriteLine ("Tables/Views/Sprocs created");
+ }
+
+ static DbConnection GetConnection ()
+ {
+ MySqlConnection conn = new MySqlConnection();
+ conn.ConnectionString = cnc_string;
+ conn.Open ();
+ return conn;
+ }
+
+ static void ProcessFile (string filename)
+ {
+ Console.WriteLine ("Processing file {0}", filename);
+ using (StreamReader reader = new StreamReader (filename)) {
+ using (DbConnection conn = GetConnection ()) {
+ StringBuilder sb = new StringBuilder();
+ string line = null;
+ while ((line = reader.ReadLine ()) != null) {
+ if (line.StartsWith ("@STATEMENT")) {
+ ExecuteStatement (conn, sb.ToString ());
+ sb.Length = 0;
+ continue;
+ }
+ sb.AppendFormat ("{0}\n", line);
+ }
+ }
+ }
+ }
+
+ static void ExecuteStatement (DbConnection cnc, string command)
+ {
+ if (String.IsNullOrEmpty (command))
+ return;
+ Console.WriteLine ("***************************");
+ Console.WriteLine (command);
+
+ DbCommand cmd = cnc.CreateCommand ();
+ cmd.CommandText = command;
+ int res = cmd.ExecuteNonQuery ();
+ Console.WriteLine ("Result: {0}", res);
+ Console.WriteLine ("##########################");
+ }
+ }
+}
50 createmomadb/createmomadb.csproj
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{170D55FA-1539-4901-8F0D-B842A2321A44}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AssemblyName>createmomadb</AssemblyName>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug</OutputPath>
+ <DefineConstants>DEBUG</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>none</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Release</OutputPath>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="MySql.Data, Version=6.0.1.0, Culture=neutral, PublicKeyToken=null">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\MySql.Data.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Data" />
+ <Reference Include="System.Configuration" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="createmomadb.cs" />
+ <Compile Include="AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="statements.txt">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Include="App.config">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+</Project>
231 createmomadb/statements.txt
@@ -0,0 +1,231 @@
+@STATEMENT
+DROP TABLE IF EXISTS `moma`.`members`;
+@STATEMENT
+DROP TABLE IF EXISTS `moma`.`reports_members`;
+@STATEMENT
+DROP TABLE IF EXISTS `moma`.`reports_pinvoke`;
+@STATEMENT
+DROP TABLE IF EXISTS `moma`.`reports_counts`;
+@STATEMENT
+DROP TABLE IF EXISTS `moma`.`reports_master`;
+@STATEMENT
+CREATE TABLE `moma`.`members` (
+ `member_id` int(11) NOT NULL AUTO_INCREMENT,
+ `version_id` int(11) NOT NULL,
+ `name` varchar(512) COLLATE utf8_bin NOT NULL,
+ `is_todo` bit(1) NOT NULL,
+ `is_missing` bit(1) NOT NULL,
+ `is_niex` bit(1) NOT NULL,
+ `is_fixed` bit(1) NOT NULL,
+ `fixed_in_version` varchar(25) COLLATE utf8_bin DEFAULT NULL,
+ `todo_comment` varchar(256) COLLATE utf8_bin DEFAULT NULL,
+ PRIMARY KEY (`member_id`),
+ KEY `idx_name` (`name`(255)),
+ KEY `idx_fixed` (`is_fixed`),
+ KEY `idx_missing` (`is_missing`),
+ KEY `idx_niex` (`is_niex`),
+ KEY `idx_todo` (`is_todo`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
+@STATEMENT
+CREATE TABLE `moma`.`reports_master` (
+ `report_id` int(11) NOT NULL AUTO_INCREMENT,
+ `submit_date` datetime NOT NULL,
+ `IP` varchar(16) COLLATE utf8_bin NOT NULL,
+ `definitions` varchar(25) COLLATE utf8_bin DEFAULT NULL,
+ `reported_by` TEXT COLLATE utf8_bin DEFAULT NULL,
+ `email` TEXT COLLATE utf8_bin DEFAULT NULL,
+ `organization` TEXT COLLATE utf8_bin DEFAULT NULL,
+ `homepage` TEXT COLLATE utf8_bin DEFAULT NULL,
+ `comment` TEXT COLLATE utf8_bin DEFAULT NULL,
+ `guid` varchar(50) COLLATE utf8_bin NOT NULL,
+ `totalpinvokes` INT(11) NOT NULL,
+ `haswpf` INT(1) NOT NULL,
+ PRIMARY KEY (`report_id`),
+ UNIQUE KEY `idx_master_guid` (`guid`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
+@STATEMENT
+CREATE TABLE `moma`.`reports_members` (
+ `report_id` int(11) NOT NULL,
+ `member_id` int(11) NOT NULL,
+ `count` int(11) NOT NULL,
+ `is_missing` bit(1) NOT NULL,
+ `is_todo` bit(1) NOT NULL,
+ `is_niex` bit(1) NOT NULL,
+ PRIMARY KEY (`report_id`,`member_id`) USING BTREE,
+ KEY `idx_rm_member_id` (`member_id`),
+ CONSTRAINT `fk_report_id` FOREIGN KEY (`report_id`) REFERENCES `reports_master` (`report_id`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+@STATEMENT
+CREATE TABLE `moma`.`reports_pinvoke` (
+ `pinvoke_id` int(11) NOT NULL AUTO_INCREMENT,
+ `report_id` int(11) NOT NULL,
+ `library_name` varchar(40) COLLATE utf8_bin NOT NULL,
+ `function_name` varchar(80) COLLATE utf8_bin NOT NULL,
+ `count` int(11) NOT NULL,
+ PRIMARY KEY (`pinvoke_id`),
+ UNIQUE KEY (`report_id`,`library_name`,`function_name`),
+ KEY `idx_pinvoke_lname` (`library_name`),
+ KEY `idx_pinvoke_fname` (`function_name`),
+ CONSTRAINT `fk_report_id_pinvoke` FOREIGN KEY (`report_id`) REFERENCES `reports_master` (`report_id`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
+
+@STATEMENT
+DROP TABLE IF EXISTS `moma`.`versions`;
+CREATE TABLE `moma`.`versions` (
+ `version_id` int(11) NOT NULL AUTO_INCREMENT,
+ `version_name` varchar(25) COLLATE utf8_bin NOT NULL,
+ `info_date` datetime NOT NULL,
+ PRIMARY KEY (`version_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
+
+@STATEMENT
+;
+CREATE TABLE `moma`.`reports_counts` (
+ `report_id` INT(11) NOT NULL,
+ `TotalMissing` INT(11) NOT NULL,
+ `TotalTodo` INT(11) NOT NULL,
+ `TotalNiex` INT(11) NOT NULL,
+ `TotalPInvoke` INT(11) NOT NULL,
+ `TotalProblems` int(11) NOT NULL,
+ PRIMARY KEY (`report_id`),
+ CONSTRAINT `fk_report_id_count` FOREIGN KEY `fk_report_id_count` (`report_id`)
+ REFERENCES `reports_master` (`report_id`)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE
+)
+ENGINE = InnoDB;
+
+@STATEMENT
+DROP PROCEDURE IF EXISTS `insert_member`;
+CREATE PROCEDURE `insert_member`(version_id int, name
+varchar(512), is_todo bit, is_missing bit, is_niex bit, is_fixed bit,
+fixed_in_version varchar(25), todo_comment varchar(256), out id int)
+BEGIN
+DECLARE memberid int;
+
+SELECT m.member_id FROM members m WHERE m.name = name INTO memberid;
+
+IF memberid IS NULL
+THEN
+ INSERT INTO members VALUES (NULL, version_id, name, is_todo, is_missing,
+is_niex, is_fixed, fixed_in_version, todo_comment);
+ SET id = LAST_INSERT_ID();
+ELSE
+ UPDATE members m
+ SET m.is_todo = m.is_todo + is_todo, m.is_missing = m.is_missing +
+m.is_missing, m.is_niex = m.is_niex + is_niex
+ WHERE member_id = memberid;
+ SET id = memberid;
+END IF;
+END;
+
+@STATEMENT
+DROP PROCEDURE IF EXISTS `moma`.`insert_or_update_member`;
+CREATE PROCEDURE `moma`.`insert_or_update_member`(report_id int, name varchar(512),
+ is_missing bit, is_todo bit, is_niex bit, todo_comment text)
+BEGIN
+DECLARE member_id INT;
+
+SET member_id = -1;
+SELECT m.member_id FROM members m
+WHERE m.name = name
+ORDER BY version_id DESC
+LIMIT 1 INTO member_id;
+
+IF member_id = -1 THEN
+ INSERT INTO members VALUES (NULL, '0', name, is_todo, is_missing, is_niex, TRUE, '0', NULL);
+ SET member_id = LAST_INSERT_ID();
+END IF;
+INSERT INTO reports_members VALUES (report_id, member_id, 1, is_missing, is_todo, is_niex)
+ON DUPLICATE KEY UPDATE count = count + 1;
+
+END;
+
+@STATEMENT
+DROP PROCEDURE IF EXISTS `moma`.`insert_or_update_pinvoke`;
+CREATE PROCEDURE `moma`.`insert_or_update_pinvoke` (report_id int, library_name varchar(80),
+ function_name varchar(80))
+BEGIN
+
+INSERT INTO reports_pinvoke VALUES (NULL, report_id, library_name, function_name, 1)
+ON DUPLICATE KEY UPDATE count = count + 1;
+END;
+
+@STATEMENT
+DROP PROCEDURE IF EXISTS `moma`.`insert_report_master`;
+CREATE PROCEDURE `moma`.`insert_report_master`(submit_date datetime, ip varchar(16),
+ definitions TEXT,
+ reported_by TEXT,
+ email TEXT,
+ organization TEXT,
+ homepage TEXT,
+ comment text,
+ guid varchar(50),
+ out id int)
+BEGIN
+INSERT INTO reports_master VALUES
+ (NULL, submit_date, ip, definitions, reported_by, email, organization, homepage, comment, guid, 0, 0);
+SET id = LAST_INSERT_ID();
+END;
+
+@STATEMENT
+DROP PROCEDURE IF EXISTS `moma`.`insert_version`;
+CREATE PROCEDURE `moma`.`insert_version`(name varchar(25), file_date datetime, out id int)
+BEGIN
+INSERT INTO versions VALUES (NULL, name, file_date);
+SET id = LAST_INSERT_ID();
+END;
+
+@STATEMENT
+DROP PROCEDURE IF EXISTS `moma`.`init_report_counts`;
+CREATE PROCEDURE `moma`.`init_report_counts` (reportid INT)
+BEGIN
+DECLARE t_todo INT;
+DECLARE t_missing INT;
+DECLARE t_niex INT;
+DECLARE t_pinvoke INT;
+
+SELECT SUM(v.is_todo) AS 'TotalTodo', SUM(v.is_missing) AS 'TotalMissing', SUM(v.is_niex) AS 'TotalNiex'
+FROM reports_view v
+INNER JOIN reports_master m ON m.report_id = reportid
+WHERE v.report_id = reportid AND is_fixed = FALSE AND (is_todo = TRUE OR is_missing = TRUE OR is_niex = TRUE)
+INTO t_todo, t_missing, t_niex;
+
+SELECT COUNT(*)
+FROM reports_pinvoke
+WHERE report_id = reportid
+INTO t_pinvoke;
+
+IF t_todo IS NULL THEN
+ SET t_todo = 0;
+END IF;
+IF t_missing IS NULL THEN
+ SET t_missing = 0;
+END IF;
+IF t_niex IS NULL THEN
+ SET t_niex = 0;
+END IF;
+IF t_pinvoke IS NULL THEN
+ SET t_pinvoke = 0;
+END IF;
+
+INSERT INTO reports_counts VALUES (reportid, t_missing, t_todo, t_niex, t_pinvoke, t_missing + t_todo + t_niex + t_pinvoke);
+END;
+
+@STATEMENT
+DROP VIEW IF EXISTS `moma`.`reports_view`;
+CREATE SQL SECURITY INVOKER VIEW `moma`.`reports_view` AS
+SELECT r.report_id, mem.member_id, mem.name, mem.is_todo, mem.is_missing, mem.is_niex, mem.is_fixed, r.count
+FROM members mem
+INNER JOIN reports_members r ON mem.member_id = r.member_id
+
+@STATEMENT
+
+DROP VIEW IF EXISTS `moma`.`reports_count_view`;
+CREATE SQL SECURITY INVOKER VIEW `moma`.`reports_count_view` AS
+select v.report_id as 'ReportId', m.guid, m.submit_date AS 'SubmitDate', SUM(v.is_todo) as 'TotalTodo', SUM(v.is_missing) as 'TotalMissing', SUM(v.is_niex) AS 'TotalNiex'
+from reports_view v
+INNER JOIN reports_master m ON m.report_id = v.report_id
+where is_fixed = FALSE AND (is_todo = TRUE OR is_missing = TRUE OR is_niex = TRUE)
+GROUP BY v.report_id;
+
5 loadmoma/App.config
@@ -0,0 +1,5 @@
+<configuration>
+ <appSettings>
+ <add key="MomaDB" value="Server=localhost;Database=moma;User ID=gonzalo;Password=gonzalo;Pooling=true;Min Pool Size=4;" />
+ </appSettings>
+</configuration>
26 loadmoma/AssemblyInfo.cs
@@ -0,0 +1,26 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+// Information about this assembly is defined by the following attributes.
+// Change them to the values specific to your project.
+
+[assembly: AssemblyTitle("moma")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright("")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
+// The form "{Major}.{Minor}.*" will automatically update the build and revision,
+// and "{Major}.{Minor}.{Build}.*" will update just the revision.
+
+[assembly: AssemblyVersion("1.0.*")]
+
+// The following attributes are used to specify the signing key for the assembly,
+// if desired. See the Mono documentation for more information about signing.
+
+[assembly: AssemblyDelaySign(false)]
+[assembly: AssemblyKeyFile("")]
100 loadmoma/DataAccess.cs
@@ -0,0 +1,100 @@
+//
+// DataAccess.cs (MoMa)
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@novell.com)
+//
+// Copyright (c) Copyright 2009 Novell, Inc
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Collections.Specialized;
+using System.Configuration;
+using System.Data;
+using System.IO;
+using System.Text;
+
+namespace Mono.Moma {
+ abstract class DataAccess {
+ static string cnc_string;
+
+ static DataAccess ()
+ {
+ NameValueCollection col = ConfigurationManager.AppSettings;
+ cnc_string = col ["MomaDB"];
+ if (String.IsNullOrEmpty (cnc_string))
+ throw new ApplicationException ("Missing connection string from configuration file.");
+ }
+
+ protected IDbTransaction transaction;
+ protected IDbConnection connection;
+
+ public DataAccess ()
+ {
+ }
+
+ protected string ConnectionString {
+ get { return cnc_string; }
+ }
+
+
+ public bool InTransaction {
+ get { return transaction != null; }
+ }
+
+ public virtual void BeginTransaction ()
+ {
+
+ }
+
+ public virtual void Rollback ()
+ {
+ }
+
+ public virtual void Commit ()
+ {
+ }
+
+ public abstract int InsertVersion (string name, DateTime date);
+ public abstract int InsertMember (int version_id, string name, bool is_todo, bool is_missing, bool is_niex, bool is_fixed, string fixed_in, string comment);
+
+ protected static IDataParameter AddParameter (IDbCommand cmd, string name, object val)
+ {
+ IDataParameter p = cmd.CreateParameter ();
+ p.ParameterName = name;
+ p.Value = val;
+ cmd.Parameters.Add (p);
+ return p;
+ }
+
+ protected static IDataParameter AddOutputParameter (IDbCommand cmd, string name)
+ {
+ IDataParameter p = cmd.CreateParameter ();
+ p.ParameterName = name;
+ p.Direction = ParameterDirection.Output;
+ cmd.Parameters.Add (p);
+ return p;
+ }
+ }
+}
+
130 loadmoma/MySqlDataAccess.cs
@@ -0,0 +1,130 @@
+//
+// MySqlDataAccess.cs (Moma);
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@novell.com)
+//
+// Copyright (c) Copyright 2009 Novell, Inc
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Data;
+using MySql.Data.MySqlClient;
+
+namespace Mono.Moma {
+ class MySqlDataAccess : DataAccess {
+ public override void BeginTransaction ()
+ {
+ if (transaction != null)
+ throw new InvalidOperationException ("Already in a transaction");
+
+ connection = GetConnection ();
+ transaction = connection.BeginTransaction ();
+ }
+
+ public override void Rollback ()
+ {
+ if (transaction == null)
+ throw new InvalidOperationException ("Call BeginTransaction first");
+
+ try {
+ transaction.Rollback ();
+ connection.Close ();
+ } finally {
+ transaction = null;
+ connection = null;
+ }
+ }
+
+ public override void Commit ()
+ {
+ if (transaction == null)
+ throw new InvalidOperationException ("Call BeginTransaction first");
+
+ try {
+ transaction.Commit ();
+ connection.Close ();
+ } finally {
+ transaction = null;
+ connection = null;
+ }
+ }
+
+ protected virtual IDbConnection GetConnection ()
+ {
+ if (connection != null)
+ return connection;
+
+ IDbConnection cnc = new MySqlConnection ();
+ cnc.ConnectionString = ConnectionString;
+ cnc.Open ();
+ return cnc;
+ }
+
+ public override int InsertVersion (string name, DateTime date)
+ {
+ IDbConnection cnc = GetConnection ();
+ try {
+ IDbCommand cmd = cnc.CreateCommand ();
+ cmd.Transaction = transaction;
+ cmd.CommandText = "insert_version";
+ cmd.CommandType = CommandType.StoredProcedure;
+ AddParameter (cmd, "name", name);
+ AddParameter (cmd, "file_date", date);
+ IDataParameter p = AddOutputParameter (cmd, "id");
+ if (cmd.ExecuteNonQuery () != 1)
+ throw new ApplicationException ("Error inserting new version");
+ return Convert.ToInt32 (p.Value);
+ } finally {
+ if (transaction == null)
+ cnc.Close ();
+ }
+ }
+
+ public override int InsertMember (int version_id, string name, bool is_todo, bool is_missing, bool is_niex, bool is_fixed, string fixed_in, string comment)
+ {
+ IDbConnection cnc = GetConnection ();
+ try {
+ IDbCommand cmd = cnc.CreateCommand ();
+ cmd.Transaction = transaction;
+ cmd.CommandText = "insert_member";
+ cmd.CommandType = CommandType.StoredProcedure;
+ AddParameter (cmd, "version_id", version_id);
+ AddParameter (cmd, "name", name);
+ AddParameter (cmd, "is_todo", is_todo);
+ AddParameter (cmd, "is_missing", is_missing);
+ AddParameter (cmd, "is_niex", is_niex);
+ AddParameter (cmd, "is_fixed", is_fixed);
+ AddParameter (cmd, "fixed_in_version", fixed_in);
+ AddParameter (cmd, "todo_comment", comment);
+ IDataParameter p = AddOutputParameter (cmd, "id");
+ if (cmd.ExecuteNonQuery () != 1)
+ throw new ApplicationException ("Error inserting new member");
+ return Convert.ToInt32 (p.Value);
+ } finally {
+ if (transaction == null)
+ cnc.Close ();
+ }
+ }
+ }
+}
+
133 loadmoma/loadmoma.cs
@@ -0,0 +1,133 @@
+//
+// loadmoma.cs
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@novell.com)
+//
+// Copyright (c) Copyright 2009 Novell, Inc
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Collections.Specialized;
+using System.Configuration;
+using System.Data;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Threading;
+
+namespace Mono.Moma {
+ class Populate {
+ static DataAccess GetDataAccess ()
+ {
+ return new MySqlDataAccess ();
+ //return new PostgresDataAccess ();
+ }
+
+ static int Main (string [] args)
+ {
+ if (args.Length != 1)
+ return 1;
+
+ string base_path = args [0];
+ if (!Directory.Exists (base_path)) {
+ Console.Error.WriteLine ("Directory {0} not found.", base_path);
+ return 2;
+ }
+
+ DataAccess da = GetDataAccess ();
+ da.BeginTransaction ();
+ try {
+ int version_id = LoadVersion (da, base_path);
+ LoadTodo (da, version_id, base_path);
+ LoadMissing (da, version_id, base_path);
+ LoadException (da, version_id, base_path);
+ if (da.InTransaction) // Should always be true
+ da.Commit ();
+ Console.WriteLine ("Done. Version ID: {0}", version_id);
+ } catch (Exception exc) {
+ if (da.InTransaction)
+ da.Rollback ();
+ Console.WriteLine (exc);
+ }
+ return 0;
+ }
+
+ static int LoadVersion (DataAccess da, string base_path)
+ {
+ string filename = Path.Combine (base_path, "version.txt");
+ string name = null;
+ DateTime date;
+ using (StreamReader reader = new StreamReader (filename)) {
+ name = reader.ReadLine ().Trim ();
+ date = DateTime.Parse (reader.ReadLine ());
+ }
+ if (String.IsNullOrEmpty (name))
+ throw new ApplicationException ("Invalid name");
+ Console.WriteLine ("Version: {0} Date: {1}", name, date);
+ return da.InsertVersion (name, date);
+ }
+
+ static void LoadTodo (DataAccess da, int version_id, string base_path)
+ {
+ LoadFile (da, version_id, Path.Combine (base_path, "monotodo.txt"), true, false, false);
+ }
+
+ static void LoadMissing (DataAccess da, int version_id, string base_path)
+ {
+ LoadFile (da, version_id, Path.Combine (base_path, "missing.txt"), false, true, false);
+ }
+
+ static void LoadException (DataAccess da, int version_id, string base_path)
+ {
+ LoadFile (da, version_id, Path.Combine (base_path, "exception.txt"), false, false, true);
+ }
+
+ static void LoadFile (DataAccess da, int version_id, string filename, bool is_todo, bool is_missing, bool is_niex)
+ {
+ Console.WriteLine ("Loading {0}...", filename);
+ using (StreamReader reader = new StreamReader (filename)) {
+ string comment;
+ string line;
+ int n = 0;
+ while ((line = reader.ReadLine ()) != null) {
+ string name = line.Trim ();
+ comment = null;
+ if (is_todo) {
+ string [] parts = name.Split ('-');
+ name = parts [0].Trim ();
+ comment = parts [1].Trim ();
+ if (comment == "")
+ comment = null;
+ }
+ da.InsertMember (version_id, name, is_todo, is_missing, is_niex, false, null, comment);
+ n++;
+ if ((n % 1000) == 0)
+ Console.WriteLine (n);
+ }
+ }
+ }
+ }
+}
+
50 loadmoma/loadmoma.csproj
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{C3F9FF31-650D-4ABD-ACBF-215847CEAA63}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug</OutputPath>
+ <DefineConstants>DEBUG</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>3</WarningLevel>
+ <AssemblyName>loadmoma</AssemblyName>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>none</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Release</OutputPath>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <AssemblyName>moma</AssemblyName>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Configuration" />
+ <Reference Include="MySql.Data, Version=6.0.1.0, Culture=neutral, PublicKeyToken=null">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\MySql.Data.dll</HintPath>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="AssemblyInfo.cs" />
+ <Compile Include="DataAccess.cs" />
+ <Compile Include="loadmoma.cs" />
+ <Compile Include="MySqlDataAccess.cs" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <ItemGroup>
+ <None Include="App.config">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ </ItemGroup>
+</Project>
5 loadmomareport/App.config
@@ -0,0 +1,5 @@
+<configuration>
+ <appSettings>
+ <add key="MomaDB" value="Server=localhost;Database=moma;User ID=gonzalo;Password=gonzalo;Pooling=true;Min Pool Size=4;" />
+ </appSettings>
+</configuration>
26 loadmomareport/AssemblyInfo.cs
@@ -0,0 +1,26 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+// Information about this assembly is defined by the following attributes.
+// Change them to the values specific to your project.
+
+[assembly: AssemblyTitle("loadmomareport")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright("")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
+// The form "{Major}.{Minor}.*" will automatically update the build and revision,
+// and "{Major}.{Minor}.{Build}.*" will update just the revision.
+
+[assembly: AssemblyVersion("1.0.*")]
+
+// The following attributes are used to specify the signing key for the assembly,
+// if desired. See the Mono documentation for more information about signing.
+
+[assembly: AssemblyDelaySign(false)]
+[assembly: AssemblyKeyFile("")]
106 loadmomareport/DataAccess.cs
@@ -0,0 +1,106 @@
+//
+// DataAccess.cs (MoMa)
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@novell.com)
+//
+// Copyright (c) Copyright 2009 Novell, Inc
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Collections.Specialized;
+using System.Configuration;
+using System.Data;
+using System.IO;
+using System.Text;
+
+namespace Mono.Moma {
+ abstract class DataAccess {
+ static string cnc_string;
+
+ static DataAccess ()
+ {
+ NameValueCollection col = ConfigurationManager.AppSettings;
+ cnc_string = col ["MomaDB"];
+ if (String.IsNullOrEmpty (cnc_string))
+ throw new ApplicationException ("Missing connection string from configuration file.");
+ }
+
+ protected IDbTransaction transaction;
+ protected IDbConnection connection;
+
+ public DataAccess ()
+ {
+ }
+
+ protected string ConnectionString {
+ get { return cnc_string; }
+ }
+
+ public bool InTransaction {
+ get { return transaction != null; }
+ }
+
+ public virtual void BeginTransaction ()
+ {
+
+ }
+
+ public virtual void Rollback ()
+ {
+ }
+
+ public virtual void Commit ()
+ {
+ }
+
+ public abstract int InsertReportMaster (DateTime submit_date, string ip, string definitions,
+ string reported_by, string email, string organization,
+ string homepage, string comment, string guid);
+ public abstract bool InsertOrUpdatePInvoke (int report_id, string library_name, string function_name);
+ public abstract bool InsertOrUpdateMember (int report_id, string name, bool is_missing, bool is_todo, bool is_niex, string todo_comment);
+ public abstract void InitReportCounts (int report_id);
+ public abstract void SetWpf (int report_id);
+
+ protected abstract IDbConnection GetConnection ();
+
+ protected static IDataParameter AddParameter (IDbCommand cmd, string name, object val)
+ {
+ IDataParameter p = cmd.CreateParameter ();
+ p.ParameterName = name;
+ p.Value = val;
+ cmd.Parameters.Add (p);
+ return p;
+ }
+
+ protected static IDataParameter AddOutputParameter (IDbCommand cmd, string name)
+ {
+ IDataParameter p = cmd.CreateParameter ();
+ p.ParameterName = name;
+ p.Direction = ParameterDirection.Output;
+ cmd.Parameters.Add (p);
+ return p;
+ }
+ }
+}
+
185 loadmomareport/MySqlDataAccess.cs
@@ -0,0 +1,185 @@
+//
+// MySqlDataAccess.cs (Moma);
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@novell.com)
+//
+// Copyright (c) Copyright 2009 Novell, Inc
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Data;
+using MySql.Data.MySqlClient;
+
+namespace Mono.Moma {
+ class MySqlDataAccess : DataAccess {
+ public override void BeginTransaction ()
+ {
+ if (transaction != null)
+ throw new InvalidOperationException ("Already in a transaction");
+
+ connection = GetConnection ();
+ transaction = connection.BeginTransaction ();
+ }
+
+ public override void Rollback ()
+ {
+ if (transaction == null)
+ throw new InvalidOperationException ("Call BeginTransaction first");
+
+ try {
+ transaction.Rollback ();
+ connection.Close ();
+ } finally {
+ transaction = null;
+ connection = null;
+ }
+ }
+
+ public override void Commit ()
+ {
+ if (transaction == null)
+ throw new InvalidOperationException ("Call BeginTransaction first");
+
+ try {
+ transaction.Commit ();
+ connection.Close ();
+ } finally {
+ transaction = null;
+ connection = null;
+ }
+ }
+
+ protected override IDbConnection GetConnection ()
+ {
+ if (connection != null)
+ return connection;
+
+ IDbConnection cnc = new MySqlConnection ();
+ cnc.ConnectionString = ConnectionString;
+ cnc.Open ();
+ return cnc;
+ }
+
+ public override int InsertReportMaster (DateTime submit_date, string ip, string definitions,
+ string reported_by, string email, string organization,
+ string homepage, string comment, string guid)
+ {
+ IDbConnection cnc = GetConnection ();
+ try {
+ IDbCommand cmd = cnc.CreateCommand ();
+ cmd.Transaction = transaction;
+ cmd.CommandText = "insert_report_master";
+ cmd.CommandType = CommandType.StoredProcedure;
+ AddParameter (cmd, "submit_date", submit_date);
+ AddParameter (cmd, "ip", ip);
+ AddParameter (cmd, "definitions", definitions);
+ AddParameter (cmd, "reported_by", reported_by);
+ AddParameter (cmd, "email", email);
+ AddParameter (cmd, "organization", organization);
+ AddParameter (cmd, "homepage", homepage);
+ AddParameter (cmd, "comment", comment);
+ AddParameter (cmd, "guid", guid);
+ IDataParameter p = AddOutputParameter (cmd, "id");
+ if (cmd.ExecuteNonQuery () != 1)
+ throw new ApplicationException ("Error inserting new report (master)");
+ return Convert.ToInt32 (p.Value);
+ } finally {
+ if (transaction == null)
+ cnc.Close ();
+ }
+ }
+
+ public override bool InsertOrUpdatePInvoke (int report_id, string library_name, string function_name)
+ {
+ IDbConnection cnc = GetConnection ();
+ try {
+ IDbCommand cmd = cnc.CreateCommand ();
+ cmd.Transaction = transaction;
+ cmd.CommandText = "insert_or_update_pinvoke";
+ cmd.CommandType = CommandType.StoredProcedure;
+ AddParameter (cmd, "report_id", report_id);
+ AddParameter (cmd, "library_name", library_name);
+ AddParameter (cmd, "function_name", function_name);
+ int r = cmd.ExecuteNonQuery ();
+ return (r == 2) ? false : true;
+ } finally {
+ if (transaction == null)
+ cnc.Close ();
+ }
+ }
+
+ public override bool InsertOrUpdateMember (int report_id, string name, bool is_missing, bool is_todo, bool is_niex, string todo_comment)
+ {
+ IDbConnection cnc = GetConnection ();
+ try {
+ IDbCommand cmd = cnc.CreateCommand ();
+ cmd.Transaction = transaction;
+ cmd.CommandText = "insert_or_update_member";
+ cmd.CommandType = CommandType.StoredProcedure;
+ AddParameter (cmd, "report_id", report_id);
+ AddParameter (cmd, "name", name);
+ AddParameter (cmd, "is_missing", is_missing);
+ AddParameter (cmd, "is_todo", is_todo);
+ AddParameter (cmd, "is_niex", is_niex);
+ AddParameter (cmd, "todo_comment", todo_comment);
+ int r = cmd.ExecuteNonQuery ();
+ return (r == 2) ? false : true;
+ } finally {
+ if (transaction == null)
+ cnc.Close ();
+ }
+ }
+
+ public override void InitReportCounts (int report_id)
+ {
+ IDbConnection cnc = GetConnection ();
+ try {
+ IDbCommand cmd = cnc.CreateCommand ();
+ cmd.Transaction = transaction;
+ cmd.CommandText = "init_report_counts";
+ cmd.CommandType = CommandType.StoredProcedure;
+ AddParameter (cmd, "reportid", report_id);
+ cmd.ExecuteNonQuery ();
+ } finally {
+ if (transaction == null)
+ cnc.Close ();
+ }
+ }
+
+ public override void SetWpf (int report_id)
+ {
+ IDbConnection cnc = GetConnection ();
+ try {
+ IDbCommand cmd = cnc.CreateCommand ();
+ cmd.Transaction = transaction;
+ cmd.CommandText = "UPDATE reports_master SET haswpf = 1 WHERE report_id = @reportid";
+ AddParameter (cmd, "reportid", report_id);
+ cmd.ExecuteNonQuery ();
+ } finally {
+ if (transaction == null)
+ cnc.Close ();
+ }
+ }
+ }
+}
+
504 loadmomareport/loadmomareport.cs
@@ -0,0 +1,504 @@
+//
+// loadmomareport.cs
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@novell.com)
+//
+// Copyright (c) Copyright 2009 Novell, Inc
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Collections.Specialized;
+using System.Configuration;
+using System.Data;
+using System.IO;
+using System.Net;
+using System.Xml;
+
+namespace Mono.Moma {
+ class Populate {
+ static Dictionary<string, string> wpftypes = new Dictionary<string, string> ();
+
+ static DataAccess GetDataAccess ()
+ {
+ return new MySqlDataAccess ();
+ //return new PostgresDataAccess ();
+ }
+
+ static bool LoadWpfExclusions ()
+ {
+ bool loaded = false;
+ try {
+ using (StreamReader reader = new StreamReader ("wpf-exclusions.txt")) {
+ string line;
+ while ((line = reader.ReadLine ()) != null)
+ wpftypes.Add (line, line);
+ }
+ loaded = true;
+ } catch (Exception exc) {
+ Console.Error.WriteLine ("Error loading WPF exclusions file: {0}", exc.Message);
+ }
+ return loaded;
+ }
+
+ static int Main (string [] args)
+ {
+ if (args.Length == 0)
+ return 1;
+
+ if (!LoadWpfExclusions ())
+ return 1;
+
+ bool xml = true;
+ foreach (string arg in args) {
+ if (arg == "--text") {
+ xml = false;
+ continue;
+ }
+ Console.WriteLine ("Loading {0}", arg);
+ try {
+ LoadReport (xml, arg);
+ } catch (Exception e) {
+ Console.Error.WriteLine ("{0} failed: {1}", arg, e.ToString ());
+ }
+ }
+ return 0;
+ }
+
+ static void LoadReport (bool xml, string filename)
+ {
+ DateTime webparts_date = new DateTime (2008, 1, 1);
+ Loader loader;
+ if (xml)
+ loader = new XmlFileLoader (filename);
+ else
+ loader = new TextFileLoader (filename);
+
+ DataAccess da = GetDataAccess ();
+ da.BeginTransaction ();
+ try {
+ bool have_wpf;
+ using (loader) {
+ have_wpf = false;
+ int report_id = da.InsertReportMaster ( loader.ReportDate, loader.IPAddress.ToString (),
+ loader.Definitions, loader.UserName,
+ loader.Email, loader.Organization,
+ loader.HomePage, loader.Comments, loader.Guid);
+ foreach (Issue issue in loader.GetIssues ()) {
+ if (issue.IssueType == IssueType.PInvoke) {
+ PInvokeIssue p = (PInvokeIssue) issue;
+ da.InsertOrUpdatePInvoke (report_id, p.Library, p.Function);
+ } else {
+ MemberIssue m = (MemberIssue) issue;
+ bool is_missing, is_todo, is_niex;
+ GetAsBooleans (m.IssueType, out is_missing, out is_todo, out is_niex);
+ // Ignore most of the WPF types
+ if (!IsWpf (m.Name)) {
+ // Ignore reports submitted prior to 2008-01-01 that are using WebParts.
+ if (loader.ReportDate < webparts_date && m.Name.IndexOf (" System.Web.UI.WebControls.WebParts") != -1) {
+ Console.WriteLine ("Ignoring report {0} (uses WebParts and older than 2008-01-01)", loader.Guid);
+ da.Rollback ();
+ return;
+ }
+
+ da.InsertOrUpdateMember (report_id, m.Name, is_missing,is_todo, is_niex, m.Comment);
+ } else {
+ have_wpf = true;
+ }
+ }
+ }
+ da.InitReportCounts (report_id);
+ if (have_wpf)
+ da.SetWpf (report_id);
+ }
+
+ if (da.InTransaction) // Should be true...
+ da.Commit ();
+ } catch (Exception) {
+ if (da.InTransaction)
+ da.Rollback ();
+ throw;
+ //Console.WriteLine (exc);
+ //Environment.Exit (1);
+ }
+ }
+
+ static bool IsWpf (string member)
+ {
+ int colon = member.IndexOf ("::");
+ if (colon == -1)
+ return false;
+
+ int space = member.IndexOf (' ');
+ if (space == -1)
+ return false;
+ string fullname = member.Substring (space + 1, colon - space - 1);
+ return wpftypes.ContainsKey (fullname);
+ }
+
+ static void GetAsBooleans (IssueType it, out bool is_missing, out bool is_todo, out bool is_niex)
+ {
+ is_missing = (it == IssueType.Missing);
+ is_todo = (it == IssueType.Todo);
+ is_niex = (it == IssueType.Niex);
+ }
+ }
+
+ enum IssueType {
+ Todo,
+ Missing,
+ Niex,
+ PInvoke
+ }
+
+ class Issue {
+ IssueType type;
+
+ protected Issue (IssueType type)
+ {
+ this.type = type;
+ }
+
+ public IssueType IssueType {
+ get { return type; }
+ }
+ }
+
+ class MemberIssue : Issue {
+ string name;
+ string comment;
+
+ public MemberIssue (IssueType type, string method_name) : this (type, method_name, null)
+ {
+ }
+
+ public MemberIssue (IssueType type, string method_name, string todo_comment) : base (type)
+ {
+ this.name = method_name;
+ this.comment = todo_comment;
+ }
+
+ public string Name {
+ get { return name; }
+ }
+
+ public string Comment {
+ get { return comment; }
+ }
+ }
+
+ class PInvokeIssue : Issue {
+ string library;
+ string function;
+
+ public PInvokeIssue (string library, string function) : base (IssueType.PInvoke)
+ {
+ this.library = library;
+ this.function = function;
+ }
+
+ public string Library {
+ get { return library; }
+ }
+
+ public string Function {
+ get { return function; }
+ }
+ }
+
+ class Loader : IDisposable {
+ protected string filename;
+ protected DateTime date;
+ protected IPAddress address;
+ protected string definitions;
+ protected string moma_version;
+ protected string user_name;
+ protected string email;
+ protected string organization;
+ protected string homepage;
+ protected string comments;
+ protected string app_type;
+ protected string guid;
+
+ protected Loader (string filename)
+ {
+ this.filename = filename;
+ this.guid = Path.GetFileNameWithoutExtension (filename);
+ LoadMetadata ();
+ }
+
+ public DateTime ReportDate {
+ get { return date; }
+ }
+
+ public IPAddress IPAddress {
+ get { return address; }
+ }
+
+ public string Definitions {
+ get { return definitions; }
+ }
+
+ public string MomaVersion {
+ get { return moma_version; }
+ }
+
+ public string UserName {
+ get { return user_name; }
+ }
+
+ public string Organization {
+ get { return organization; }
+ }
+
+ public string HomePage {
+ get { return homepage; }
+ }
+
+ public string Comments {
+ get { return comments; }
+ }
+
+ public string ApplicationType {
+ get { return app_type; }
+ }
+
+ public string Email {
+ get { return email; }
+ }
+
+ public string Guid {
+ get { return guid; }
+ }
+
+ public void Dispose ()
+ {
+ Dispose (true);
+ GC.SuppressFinalize (this);
+ }
+
+ protected virtual void LoadMetadata ()
+ {
+ }
+
+ public virtual IEnumerable<Issue> GetIssues ()
+ {
+ yield break;
+ }
+
+ protected virtual void Dispose (bool disposing)
+ {
+ }
+ }
+
+ class TextFileLoader : Loader {
+ static char [] spl = new char [] { '-' };
+ StreamReader reader;
+ int lineno;
+
+ public TextFileLoader (string filename) : base (filename)
+ {
+ }
+
+ public override IEnumerable<Issue> GetIssues ()
+ {
+ string line;
+ while ((line = reader.ReadLine ()) != null) {
+ lineno++;
+ if (line == "" || line.Length <= 7)
+ continue;
+
+ IssueType issue_type;
+ string type = line.Substring (0, 6);
+ switch (type) {
+ case "[MISS]":
+ issue_type = IssueType.Missing;
+ break;
+ case "[NIEX]":
+ issue_type = IssueType.Niex;
+ break;
+ case "[PINV]":
+ issue_type = IssueType.PInvoke;
+ break;
+ case "[TODO]":
+ issue_type = IssueType.Todo;
+ break;
+ default:
+ Console.Error.WriteLine ("Ignoring line {0} in {1}: {2}", lineno, filename, line);
+ continue;
+ }
+ line = line.Substring (7).Trim ();
+ string str1 = line;
+ string str2 = null;
+ if (issue_type == IssueType.Todo || issue_type == IssueType.PInvoke) {
+ string [] parts = line.Split (spl, 2);
+ str1 = parts [0].Trim ();
+ str2 = null;
+ if (parts.Length == 2)
+ str2 = parts [1].Trim ();
+ }
+
+ if (issue_type == IssueType.PInvoke) {
+ if (str1 != null)
+ str1 = str1.ToLowerInvariant ();
+ else
+ str1 = "";
+ if (str2 != null)
+ str2 = str2.ToLowerInvariant ();
+ else
+ str2 = "";
+ yield return new PInvokeIssue (str2, str1);
+ } else {
+ yield return new MemberIssue (issue_type, str1, str2);
+ }
+ }
+ }
+
+ protected override void Dispose (bool disposing)
+ {
+ if (disposing) {
+ if (reader != null)
+ reader.Close ();
+ }
+ reader = null;
+ base.Dispose (disposing);
+ }
+
+ protected override void LoadMetadata ()
+ {
+ reader = new StreamReader (filename);
+ lineno = 1;
+ date = DateTime.Parse (reader.ReadLine ());
+ lineno++;
+ address = IPAddress.Parse (reader.ReadLine ());
+ lineno++;
+ definitions = GetValue (reader.ReadLine ());
+ lineno++;
+ user_name = GetValue (reader.ReadLine ());
+ lineno++;
+ email = GetValue (reader.ReadLine ());
+ lineno++;
+ organization = GetValue (reader.ReadLine ());
+ lineno++;
+ homepage = GetValue (reader.ReadLine ());
+ lineno++;
+ comments = GetValue (reader.ReadLine ());
+ lineno++;
+ app_type = null;
+ moma_version = null;
+ }
+
+ static string GetValue (string line)
+ {
+ if (String.IsNullOrEmpty (line))
+ return null;
+
+ if (line [0] != '@')
+ return null;
+
+ int idx = line.IndexOf (':');
+ if (idx == -1 || line.Length - 2 > idx)
+ return null;
+
+ return line.Substring (idx + 2);
+ }
+ }
+
+ class XmlFileLoader : Loader {
+ XmlDocument doc;
+
+ public XmlFileLoader (string filename) : base (filename)
+ {
+ }
+
+ public override IEnumerable<Issue> GetIssues ()
+ {
+ XmlNodeList issues = doc.SelectNodes ("/report/assemblies/assembly/issue");
+ foreach (XmlNode node in issues) {
+ string type_str = node.Attributes ["type"].Value;
+ IssueType issue_type = GetIssueTypeFromString (type_str);
+ Issue issue;
+ if (issue_type == IssueType.PInvoke) {
+ XmlNode function = node.SelectSingleNode ("method");
+ XmlNode library = node.SelectSingleNode ("data");
+ string lib = library.InnerText;
+ if (!String.IsNullOrEmpty (lib))
+ lib = lib.ToLowerInvariant ();
+ string func = function.InnerText;
+ if (!String.IsNullOrEmpty (func))
+ func = func.ToLowerInvariant ();
+
+ issue = new PInvokeIssue (lib, func);
+ } else {
+ XmlNode name = node.SelectSingleNode ("raw");
+ issue = new MemberIssue (issue_type, name.InnerText, null);
+ }
+
+ yield return issue;
+ }
+ }
+
+ static IssueType GetIssueTypeFromString (string str)
+ {
+ switch (str) {
+ case "pinv": return IssueType.PInvoke;
+ case "todo": return IssueType.Todo;
+ case "niex": return IssueType.Niex;
+ case "miss": return IssueType.Missing;
+ default:
+ Console.WriteLine ("Unknown type: {0}", str);
+ return IssueType.Missing;
+ }
+ }
+
+ protected override void LoadMetadata ()
+ {
+ doc = new XmlDocument ();
+ using (StreamReader reader = new StreamReader (filename)) {
+ date = DateTime.Parse (reader.ReadLine ());
+ address = IPAddress.Parse (reader.ReadLine ());
+ doc.Load (reader);
+ }
+ definitions = GetNodeValue (doc, "/report/metadata/definitions");
+ moma_version = GetNodeValue (doc, "/report/metadata/momaversion");
+ user_name = GetNodeValue (doc, "/report/metadata/name");
+ email = GetNodeValue (doc, "/report/metadata/email");
+ organization = GetNodeValue (doc, "/report/metadata/organization");
+ homepage = GetNodeValue (doc, "/report/metadata/homepage");
+ comments = GetNodeValue (doc, "/report/metadata/comments");
+ app_type = GetNodeValue (doc, "/report/metadata/apptype");
+ }
+
+ string GetNodeValue (XmlNode n, string path)
+ {
+ XmlNode node = n.SelectSingleNode (path);
+ if (node == null) {
+ Console.WriteLine ("{0} not found", path);
+ return null;
+ }
+
+ return node.InnerText;
+ }
+ }
+}
+
53 loadmomareport/loadmomareport.csproj
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{C73DA11E-D89D-4F1B-8837-D79FBA2D6077}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AssemblyName>loadmomareport</AssemblyName>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug</OutputPath>
+ <DefineConstants>DEBUG</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>none</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Release</OutputPath>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Configuration" />
+ <Reference Include="System.Xml" />
+ <Reference Include="MySql.Data, Version=6.0.1.0, Culture=neutral, PublicKeyToken=null">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\MySql.Data.dll</HintPath>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="AssemblyInfo.cs" />
+ <Compile Include="DataAccess.cs" />
+ <Compile Include="loadmomareport.cs" />
+ <Compile Include="MySqlDataAccess.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="App.config">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Include="wpf-exclusions.txt">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+</Project>
10,179 loadmomareport/wpf-exclusions.txt
10,179 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
33 moma.sln
@@ -0,0 +1,33 @@
+
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "loadmoma", "loadmoma\loadmoma.csproj", "{C3F9FF31-650D-4ABD-ACBF-215847CEAA63}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "loadmomareport", "loadmomareport\loadmomareport.csproj", "{C73DA11E-D89D-4F1B-8837-D79FBA2D6077}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "createmomadb", "createmomadb\createmomadb.csproj", "{170D55FA-1539-4901-8F0D-B842A2321A44}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {170D55FA-1539-4901-8F0D-B842A2321A44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {170D55FA-1539-4901-8F0D-B842A2321A44}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {170D55FA-1539-4901-8F0D-B842A2321A44}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {170D55FA-1539-4901-8F0D-B842A2321A44}.Release|Any CPU.Build.0 = Release|Any CPU
+ {C3F9FF31-650D-4ABD-ACBF-215847CEAA63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {C3F9FF31-650D-4ABD-ACBF-215847CEAA63}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C3F9FF31-650D-4ABD-ACBF-215847CEAA63}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {C3F9FF31-650D-4ABD-ACBF-215847CEAA63}.Release|Any CPU.Build.0 = Release|Any CPU
+ {C73DA11E-D89D-4F1B-8837-D79FBA2D6077}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {C73DA11E-D89D-4F1B-8837-D79FBA2D6077}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C73DA11E-D89D-4F1B-8837-D79FBA2D6077}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {C73DA11E-D89D-4F1B-8837-D79FBA2D6077}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(MonoDevelopProperties) = preSolution
+ version = 0.1
+ StartupItem = loadmoma\loadmoma.csproj
+ EndGlobalSection
+EndGlobal
1 web/build/build.sh
@@ -0,0 +1 @@
+gmcs -r:bin/MySql.Data.dll -r:System.Data.dll -r:System.Configuration.dll -r:System.Web.dll -r:System.Web.Mvc.dll -r:System.Web.Routing.dll -r:System.Data.DataSetExtensions.dll -r:System.Drawing.dll -target:library -out:bin/Moma.Web.dll $(find -name \*.cs)
14 web/moma/moma.Tests/App.config
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+ Note: Add entries to the App.config file for configuration settings
+ that apply only to the Test project.
+-->
+<configuration>
+ <appSettings>
+
+ </appSettings>
+
+ <connectionStrings>
+
+ </connectionStrings>
+</configuration>
136 web/moma/moma.Tests/AuthoringTests.txt
@@ -0,0 +1,136 @@
+==========================================================================
+ Visual Studio Team System: Overview of Authoring and Running Tests
+==========================================================================
+
+This overview describes the features for authoring and running tests in
+Visual Studio Team System and Visual Studio Team Edition for Software Testers.
+
+Opening Tests
+-------------
+To open a test, open a test project or a test metadata file (a file with
+extension .vsmdi) that contains the definition of the test. You can find
+test projects and metadata files in Solution Explorer.
+
+Viewing Tests
+-------------
+To see which tests are available to you, open the Test View window. Or,
+if you have installed Team Edition for Software Testers, you can also open
+the Test List Editor window to view tests.
+
+To open the Test View window, click the Test menu, point to Windows, and
+then click Test View. To open the Test List Editor window (if you have
+installed Team Edition for Software Testers), click Test, point to Windows,
+and then click Test List Editor.
+
+Running Tests
+-------------
+You can run tests from the Test View window and the Test List Editor window.
+See Viewing Tests to learn how to open these windows. To run one or more
+tests displayed in the Test View window, first select the tests in that
+window; to select multiple tests, hold either the Shift or CTRL key while
+clicking tests. Then click the Run Tests button in the Test View window
+toolbar.
+
+If you have installed Visual Studio Team Edition for Software Testers, you can
+also use the Test List Editor window to run tests. To run tests in Test List Editor,
+select the check box next to each test that you want to run. Then click the
+Run Tests button in the Test List Editor window toolbar.
+
+Viewing Test Results
+--------------------
+When you run a test or a series of tests, the results of the test run will be
+shown in the Test Results window. Each individual test in the run is shown on
+a separate line so that you can see its status. The window contains an
+embedded status bar in the top half of the window that provides you with
+summary details of the complete test run.
+
+To see more detailed results for a particular test result, double-click it in
+the Test Results window. This opens a window that provides more information
+about the particular test result, such as any specific error messages returned
+by the test.
+
+Changing the way that tests are run
+-----------------------------------
+Each time you run one or more tests, a collection of settings is used to
+determine how those tests are run. These settings are contained in a “test
+run configuration” file.
+
+Here is a partial list of the changes you can make with a test run
+configuration file:
+
+ - Change the naming scheme for each test run.
+ - Change the test controller that the tests are run on so that you can run
+ tests remotely.
+ - Gather code coverage data for the code being tested so that you can see
+ which lines of code are covered by your tests.
+ - Enable and disable test deployment.
+ - Specify additional files to deploy before tests are run.
+ - Select a different host, ASP.NET, for running ASP.NET unit tests.
+ - Select a different host, the smart device test host, for running smart device unit tests.
+ - Set various properties for the test agents that run your tests.
+ - Run custom scripts at the start and end of each test run so that you can
+ set up the test environment exactly as required each time tests are run.
+ - Set time limits for tests and test runs.
+ - Set the browser mix and the number of times to repeat Web tests in the
+ test run.
+
+By default, a test run configuration file is created whenever you create a
+new test project. You make changes to this file by double-clicking it in
+Solution Explorer and then changing its settings. (Test run configuration
+files have the extension .testrunconfig.)
+
+A solution can contain multiple test run configuration files. Only one of
+those files, known as the “Active” test run configuration file, is used to
+determine the settings that are currently used for test runs. You select
+the active test run configuration by clicking Select Active Test Run
+Configuration on the Test menu.
+
+-------------------------------------------------------------------------------
+
+Test Types
+----------
+Using Visual Studio Team Edition for Software Testers, you can create a number
+of different test types:
+
+Unit test: Use a unit test to create a programmatic test in C++, Visual C# or
+Visual Basic that exercises source code. A unit test calls the methods of a
+class, passing suitable parameters, and verifies that the returned value is
+what you expect.
+There are three specialized variants of unit tests:
+ - Data-driven unit tests are created when you configure a unit test to be
+ called repeatedly for each row of a data source. The data from each row
+ is used by the unit test as input data.
+ - ASP.NET unit tests are unit tests that exercise code in an ASP.NET Web
+ application.
+ - Smart device unit tests are unit tests that are deployed to a smart device
+ or emulator and then executed by the smart device test host.
+
+Web Test: Web tests consist of an ordered series of HTTP requests that you
+record in a browser session using Microsoft Internet Explorer. You can have
+the test report specific details about the pages or sites it requests, such
+as whether a particular page contains a specified string.
+
+Load Test: You use a load test to encapsulate non-manual tests, such as
+unit, Web, and generic tests, and then run them simultaneously by using
+virtual users. Running these tests under load generates test results,
+including performance and other counters, in tables and in graphs.
+
+Generic test: A generic test is an existing program wrapped to function as a
+test in Visual Studio. The following are examples of tests or programs that
+you can turn into generic tests:
+ - An existing test that uses process exit codes to communicate whether the
+ test passed or failed. 0 indicates passing and any other value indicates
+ a failure.
+ - A general program to obtain specific functionality during a test scenario.
+ - A test or program that uses a special XML file (called a “summary results
+ file”), to communicate detailed results.
+
+Manual test: The manual test type is used when the test tasks are to be
+completed by a test engineer as opposed to an automated script.
+
+Ordered test: Use an ordered test to execute a set of tests in an order you
+specify.
+
+-------------------------------------------------------------------------------
+
+
655 web/moma/moma.Tests/Controllers/AccountControllerTest.cs
@@ -0,0 +1,655 @@
+using System;
+using System.Security.Principal;
+using System.Web;
+using System.Web.Mvc;
+using System.Web.Routing;
+using System.Web.Security;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using moma;
+using moma.Controllers;
+
+namespace moma.Tests.Controllers
+{
+
+ [TestClass]
+ public class AccountControllerTest
+ {
+
+ [TestMethod]
+ public void ChangePasswordGetReturnsView()
+ {
+ // Arrange
+ AccountController controller = GetAccountController();
+
+ // Act
+ ViewResult result = (ViewResult)controller.ChangePassword();
+
+ // Assert
+ Assert.AreEqual(6, result.ViewData["PasswordLength"]);
+ }
+
+ [TestMethod]
+ public void ChangePasswordPostRedirectsOnSuccess()
+ {
+ // Arrange
+ AccountController controller = GetAccountController();
+
+ // Act
+ RedirectToRouteResult result = (RedirectToRouteResult)controller.ChangePassword("oldPass", "newPass", "newPass");
+
+ // Assert
+ Assert.AreEqual("ChangePasswordSuccess", result.RouteValues["action"]);
+ }
+
+ [TestMethod]
+ public void ChangePasswordPostReturnsViewIfCurrentPasswordNotSpecified()
+ {
+ // Arrange
+ AccountController controller = GetAccountController();
+
+ // Act
+ ViewResult result = (ViewResult)controller.ChangePassword("", "newPassword", "newPassword");
+
+ // Assert
+ Assert.AreEqual(6, result.ViewData["PasswordLength"]);
+ Assert.AreEqual("You must specify a current password.", result.ViewData.ModelState["currentPassword"].Errors[0].ErrorMessage);
+ }
+
+ [TestMethod]
+ public void ChangePasswordPostReturnsViewIfNewPasswordDoesNotMatchConfirmPassword()
+ {
+ // Arrange
+ AccountController controller = GetAccountController();
+
+ // Act
+ ViewResult result = (ViewResult)controller.ChangePassword("currentPassword", "newPassword", "otherPassword");
+
+ // Assert
+ Assert.AreEqual(6, result.ViewData["PasswordLength"]);
+ Assert.AreEqual("The new password and confirmation password do not match.", result.ViewData.ModelState["_FORM"].Errors[0].ErrorMessage);
+ }
+
+ [TestMethod]
+ public void ChangePasswordPostReturnsViewIfNewPasswordIsNull()
+ {
+ // Arrange
+ AccountController controller = GetAccountController();
+
+ // Act
+ ViewResult result = (ViewResult)controller.ChangePassword("currentPassword", null, null);
+
+ // Assert
+ Assert.AreEqual(6, result.ViewData["PasswordLength"]);
+ Assert.AreEqual("You must specify a new password of 6 or more characters.", result.ViewData.ModelState["newPassword"].Errors[0].ErrorMessage);
+ }
+
+ [TestMethod]
+ public void ChangePasswordPostReturnsViewIfNewPasswordIsTooShort()
+ {
+ // Arrange
+ AccountController controller = GetAccountController();
+
+ // Act
+ ViewResult result = (ViewResult)controller.ChangePassword("currentPassword", "12345", "12345");
+
+ // Assert
+ Assert.AreEqual(6, result.ViewData["PasswordLength"]);
+ Assert.AreEqual("You must specify a new password of 6 or more characters.", result.ViewData.ModelState["newPassword"].Errors[0].ErrorMessage);
+ }
+
+ [TestMethod]
+ public void ChangePasswordPostReturnsViewIfProviderRejectsPassword()
+ {
+ // Arrange
+ AccountController controller = GetAccountController();
+
+ // Act
+ ViewResult result = (ViewResult)controller.ChangePassword("oldPass", "badPass", "badPass");
+
+ // Assert
+ Assert.AreEqual(6, result.ViewData["PasswordLength"]);
+ Assert.AreEqual("The current password is incorrect or the new password is invalid.", result.ViewData.ModelState["_FORM"].Errors[0].ErrorMessage);
+ }
+
+ [TestMethod]
+ public void ChangePasswordSuccess()
+ {
+ // Arrange
+ AccountController controller = GetAccountController();
+
+ // Act
+ ViewResult result = (ViewResult)controller.ChangePasswordSuccess();
+
+ // Assert
+ Assert.IsNotNull(result);
+ }
+
+ [TestMethod]
+ public void ConstructorSetsProperties()
+ {
+ // Arrange
+ IFormsAuthentication formsAuth = new MockFormsAuthenticationService();
+ IMembershipService membershipService = new AccountMembershipService();
+
+ // Act
+ AccountController controller = new AccountController(formsAuth, membershipService);
+
+ // Assert
+ Assert.AreEqual(formsAuth, controller.FormsAuth, "FormsAuth property did not match.");
+ Assert.AreEqual(membershipService, controller.MembershipService, "MembershipService property did not match.");
+ }
+
+ [TestMethod]
+ public void ConstructorSetsPropertiesToDefaultValues()
+ {
+ // Act
+ AccountController controller = new AccountController();
+
+ // Assert
+ Assert.IsNotNull(controller.FormsAuth, "FormsAuth property is null.");
+ Assert.IsNotNull(controller.MembershipService, "MembershipService property is null.");
+ }
+
+ [TestMethod]
+ public void LoginGet()
+ {
+ // Arrange
+ AccountController controller = GetAccountController();
+
+ // Act
+ ViewResult result = (ViewResult)controller.LogOn();
+
+ // Assert
+ Assert.IsNotNull(result);
+ }
+
+ [TestMethod]
+ public void LoginPostRedirectsHomeIfLoginSuccessfulButNoReturnUrlGiven()
+ {
+ // Arrange
+ AccountController controller = GetAccountController();
+
+ // Act
+ RedirectToRouteResult result = (RedirectToRouteResult)controller.LogOn("someUser", "goodPass", true, null);
+
+ // Assert
+ Assert.AreEqual("Home", result.RouteValues["controller"]);
+ Assert.AreEqual("Index", result.RouteValues["action"]);
+ }
+
+ [TestMethod]
+ public void LoginPostRedirectsToReturnUrlIfLoginSuccessfulAndReturnUrlGiven()
+ {
+ // Arrange
+ AccountController controller = GetAccountController();
+
+ // Act
+ RedirectResult result = (RedirectResult)controller.LogOn("someUser", "goodPass", false, "someUrl");
+
+ // Assert
+ Assert.AreEqual("someUrl", result.Url);
+ }
+
+ [TestMethod]
+ public void LoginPostReturnsViewIfPasswordNotSpecified()
+ {
+ // Arrange
+ AccountController controller = GetAccountController();
+
+ // Act
+ ViewResult result = (ViewResult)controller.LogOn("username", "", true, null);
+
+ // Assert
+ Assert.AreEqual("You must specify a password.", result.ViewData.ModelState["password"].Errors[0].ErrorMessage);
+ }
+
+ [TestMethod]
+ public void LoginPostReturnsViewIfUsernameNotSpecified()
+ {
+ // Arrange
+ AccountController controller = GetAccountController();
+
+ // Act
+ ViewResult result = (ViewResult)controller.LogOn("", "somePass", false, null);
+
+ // Assert