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 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.IO;
namespace WindowsFormsApplication3
{
class CL_CAD
{
string filename1, filename2, filename3;
public CL_CAD(string [] files)//string _filename1, string _filename2, string _filename3)
{
foreach (string file in files)
{
if(file.Contains("AffectationBug.csv"))
filename1 = file;
else if (file.Contains("ListeBug.csv"))
filename2 = file;
else if (file.Contains("WorkflowBug.csv"))
filename3 = file;
}
}
DataTable dt1 = new DataTable();
DataTable dt2 = new DataTable();
DataTable dt3 = new DataTable();
DataSet ds = new DataSet();
Form1 form = new Form1();
public DataTable GetTable1()
{
StreamReader csv_file = null;
DataColumn NumeroBugColumn = new DataColumn("NumeroBug", typeof(System.Int32));
DataColumn dateModificationColumn = new DataColumn("dateModification", typeof(System.DateTime));
DataColumn ModifieParColumn = new DataColumn("ModifiePar", typeof(System.Int32));
DataColumn DeColumn = new DataColumn("De", typeof(System.DateTime));
DataColumn VersColumn = new DataColumn("Vers", typeof(System.DateTime));
dt3.Columns.Add(NumeroBugColumn);
dt3.Columns.Add(dateModificationColumn);
dt3.Columns.Add(ModifieParColumn);
dt3.Columns.Add(DeColumn);
dt3.Columns.Add(VersColumn);
dt3.PrimaryKey = new DataColumn[] { NumeroBugColumn };
try
{
csv_file = File.OpenText(filename1);
}
catch
{
throw new Exception("Erreur lors du chargement du fichier, le fichier est peut etre ouvert");
}
int i = 0;
if (filename1.EndsWith("AffectationBug.csv"))
{
while (csv_file.Peek() > 0)
{
// read and add a line
string line = csv_file.ReadLine();
string[] vals = line.Split(';');
DataRow dr = dt1.NewRow();
dr["NumeroBug"] = vals[0];
dr["dateModification"] = vals[1];
dr["ModifiePar"] = vals[2];
//dr["De"] = vals[3];
//dr["Vers"] = vals[4];
i++;
if (i > 1)
{
dt1.Rows.Add(dr);
}
}
csv_file.Close();
}
else
{
throw new Exception("Vous avez selectionné le mauvais fichier");
}
return dt1;
}
public DataTable GetTable2()
{
StreamReader csv_file = null;
DataColumn NumeroBugColumn = new DataColumn("NumeroBug", typeof(System.Int32));
DataColumn projetColumn = new DataColumn("projet", typeof(System.String));
DataColumn PrioriteColumn = new DataColumn("Priorite", typeof(System.Int32));
DataColumn SeveriteColumn = new DataColumn("Severite", typeof(System.Int32));
DataColumn DateSoumissionColumn = new DataColumn("DateSoumission", typeof(System.DateTime));
DataColumn ResumeColumn = new DataColumn("Resume", typeof(System.String));
DataColumn RapporteurColumn = new DataColumn("Rapporteur", typeof(System.Int32));
dt3.Columns.Add(NumeroBugColumn);
dt3.Columns.Add(projetColumn);
dt3.Columns.Add(PrioriteColumn);
dt3.Columns.Add(SeveriteColumn);
dt3.Columns.Add(DateSoumissionColumn);
dt3.Columns.Add(ResumeColumn);
dt3.Columns.Add(RapporteurColumn);
dt3.PrimaryKey = new DataColumn[] { NumeroBugColumn };//le cle primaire de la table
try
{
csv_file = File.OpenText(filename2);
}
catch
{
throw new Exception("Erreur lors du chargement du fichier, le fichier est peut etre ouvert");
}
int i = 0;
if (filename2.EndsWith("ListeBug.csv"))
{
while (csv_file.Peek() > 0)
{
string line = csv_file.ReadLine();
string[] vals = line.Split(';');
DataRow dr = dt2.NewRow();
dr["Projet"] = vals[0];
dr["NumeroBug"] = vals[1];
dr["Priorite"] = vals[2];
dr["Severite"] = vals[3];
dr["DateSoumission"] = vals[4];
dr["Resume"] = vals[5];
dr["Rapporteur"] = vals[6];
//Permet d'ignorer la première ligne qui contient les en-têtes des colonnes
i++;
if (i > 1)
{
dt2.Rows.Add(dr);
}
}
csv_file.Close();
}
else
{
throw new Exception("Vous avez selectionné le mauvais fichier");
}
return dt2;
}
public DataTable GetTable3()
{
StreamReader csv_file = null;
DataColumn NumeroBugColumn = new DataColumn("NumeroBug", typeof(System.Int32));
DataColumn DateModificationColumn = new DataColumn("DateModification", typeof(System.Int32));
DataColumn ModifieParColumn = new DataColumn("ModifiePar", typeof(System.Int32));
DataColumn AncienStatutColumn = new DataColumn("AncienStatut", typeof(System.Int32));
DataColumn NouveauStatutColumn = new DataColumn("NouveauStatut", typeof(System.Int32));
dt3.Columns.Add(NumeroBugColumn);
dt3.Columns.Add(DateModificationColumn);
dt3.Columns.Add(ModifieParColumn);
dt3.Columns.Add(AncienStatutColumn);
dt3.Columns.Add(NouveauStatutColumn);
dt3.PrimaryKey =new DataColumn[]{NumeroBugColumn};
try
{
csv_file = File.OpenText(filename3);
}
catch
{
throw new Exception("Erreur lors du chargement du fichier, le fichier est peut etre ouvert");
}
int i = 0;
//Vérirfie si le bon fichier a été sélectionné
if (filename3.EndsWith("WorkflowBug.csv"))
{
while (csv_file.Peek() > 0)
{
// read and add a line
string line = csv_file.ReadLine();
string[] vals = line.Split(';');
DataRow dr = dt3.NewRow();
dr["NumeroBug"] = vals[0];
dr["DateModification"] = vals[1];
dr["ModifiePar"] = vals[2];
dr["AncienStatut"] = vals[3];
dr["NouveauStatut"] = vals[4];
i++;
if (i > 1)
{
dt3.Rows.Add(dr);
}
}
csv_file.Close();
}
else
{
throw new Exception("Vous avez selectionné le mauvais fichier");
}
return dt3;
}
public DataTable UnionTables()
{
DataTable table1 = dt1.Clone();
table1.Merge(dt2, false, MissingSchemaAction.Add);
table1.Merge(dt3, false, MissingSchemaAction.Add);
DataTable table = new DataTable();
//mettre les donnees que tu veux afficher
DataColumn NumeroBugColumn = new DataColumn("NumeroBug", typeof(System.Int32));
DataColumn dateModificationColumn = new DataColumn("dateModification", typeof(System.DateTime));
DataColumn ModifieParColumn = new DataColumn("ModifiePar", typeof(System.Int32));
DataColumn DeColumn = new DataColumn("De", typeof(System.DateTime));
DataColumn VersColumn = new DataColumn("Vers", typeof(System.DateTime));
table.Columns.Add(NumeroBugColumn);
table.Columns.Add(dateModificationColumn);
table.Columns.Add(ModifieParColumn);
table.Columns.Add(DeColumn);
table.Columns.Add(VersColumn);
table.PrimaryKey = new DataColumn[] { NumeroBugColumn };
foreach (DataRow row in table1.Rows)
{
DataRow dr = table.NewRow();
dr["NumeroBug"] = row["NumeroBug"];
//.....remplir les données
table.Rows.Add(dr);
}
return table;
}
}
} |