-
Notifications
You must be signed in to change notification settings - Fork 1
/
ctrlReleaseNotes.cs
123 lines (100 loc) · 3.98 KB
/
ctrlReleaseNotes.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Globalization;
namespace VAGSuite
{
public partial class ctrlReleaseNotes : DevExpress.XtraEditors.XtraUserControl
{
private DateTime m_LatestReleaseDate = DateTime.MinValue;
public ctrlReleaseNotes()
{
InitializeComponent();
}
public static string GetExceptionType(Exception ex)
{
string exceptionType = ex.GetType().ToString();
return exceptionType.Substring(
exceptionType.LastIndexOf('.') + 1);
}
public DateTime StringToDateTime(string cultureName, string dateTimeString)
{
CultureInfo culture = new CultureInfo(cultureName);
//Console.WriteLine();
// Convert each string in the dateStrings array.
DateTime dateTimeValue = DateTime.MinValue;
// Display the first part of the output line.
//Console.Write(lineFmt, dateStr, cultureName, null);
try
{
// Convert the string to a DateTime object.
dateTimeValue = Convert.ToDateTime(dateTimeString, culture);
// Display the DateTime object in a fixed format
// if Convert succeeded.
Console.WriteLine("{0:yyyy-MMM-dd}", dateTimeValue);
}
catch (Exception ex)
{
// Display the exception type if Parse failed.
Console.WriteLine("{0}", GetExceptionType(ex));
}
return dateTimeValue;
}
public void LoadXML(string filename)
{
DataSet ds = new DataSet();
//DataTable dt = new DataTable();
try
{
/*dt.TableName = "channel";
dt.Columns.Add("description");
dt.Columns.Add("link");
dt.Columns.Add("pubDate");
dt.Columns.Add("docs");
dt.Columns.Add("rating");
dt.Columns.Add("generator");
dt.ReadXml(filename);*/
ds.ReadXml(filename);
if (ds.Tables.Count > 2)
{
if (ds.Tables[1].Rows.Count > 0)
{
// get the info from the channel table
//System.Globalization.Calendar cal = System.Globalization.CultureInfo.CreateSpecificCulture("nl-NL").Calendar;
//System.Globalization.CultureInfo.CreateSpecificCulture("nl-NL").DateTimeFormat
m_LatestReleaseDate = StringToDateTime("en-US", ds.Tables[1].Rows[0]["pubDate"].ToString());
Console.WriteLine("Release date: " + m_LatestReleaseDate.ToString());
}
ds.Tables[2].Columns.Add("Date", System.Type.GetType("System.DateTime"));
foreach (DataRow dr in ds.Tables[2].Rows)
{
try
{
dr["Date"] = StringToDateTime("en-US", dr["pubDate"].ToString()).Date;
}
catch (Exception convE)
{
Console.WriteLine("Failed to convert datetime: " + convE.Message);
}
}
gridControl1.DataSource = ds.Tables[2];
//gridView1.SetMasterRowExpanded(0, true);
gridView1.ExpandAllGroups();
}
}
catch (Exception E)
{
Console.WriteLine(E.Message);
}
}
private void printPreviewToolStripMenuItem_Click(object sender, EventArgs e)
{
gridControl1.ShowPrintPreview();
}
}
}