Skip to content
This repository was archived by the owner on Feb 12, 2025. It is now read-only.

Commit ef2dfcc

Browse files
committed
Conflicts: project/core/CruiseServerClient.cs
2 parents 3d74ebf + 6a5c625 commit ef2dfcc

File tree

107 files changed

+3217
-1774
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+3217
-1774
lines changed

createDocs.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ rmdir %outputfolder% /s /q
77
mkdir %outputfolder%
88

99
Tools\docGenerator\Console\bin\Debug\Console.exe -c=generate -s=Build\Server\ThoughtWorks.CruiseControl.Remote.dll -o=%outputfolder%
10-
Tools\docGenerator\Console\bin\Debug\Console.exe -c=generate -s=Build\Server\\ThoughtWorks.CruiseControl.Core.dll -o=%outputfolder%
10+
Tools\docGenerator\Console\bin\Debug\Console.exe -c=generate -s=Build\Server\ThoughtWorks.CruiseControl.Core.dll -o=%outputfolder%
1111
Tools\docGenerator\Console\bin\Debug\Console.exe -c=generate -s=Build\WebDashboard\ThoughtWorks.CruiseControl.WebDashboard.dll -o=%outputfolder%
1212

1313
IF "%2"=="" GOTO Continue

project/CCTrayLib/Presentation/MainForm.cs

Lines changed: 91 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using ThoughtWorks.CruiseControl.CCTrayLib.Monitoring;
99
using Message = System.Windows.Forms.Message;
1010
using System.Text;
11+
using System.Text.RegularExpressions;
1112
using System.Collections.Generic;
1213

1314
namespace ThoughtWorks.CruiseControl.CCTrayLib.Presentation
@@ -779,15 +780,15 @@ private string GetBuildStage()
779780
{ return string.Empty; }
780781

781782

782-
783+
783784

784785
if (controller.SelectedProject.ProjectState != ProjectState.Building &&
785786
controller.SelectedProject.ProjectState != ProjectState.BrokenAndBuilding)
786787
{ return controller.SelectedProject.Detail.ProjectDescription; }
787788

788789
String currentBuildStage = controller.SelectedProject.Detail.CurrentBuildStage;
789790
if (currentBuildStage == null || currentBuildStage.Length == 0)
790-
{ return string.Empty ; }
791+
{ return string.Empty; }
791792

792793
System.Text.StringBuilder SB = new System.Text.StringBuilder();
793794
System.IO.StringWriter BuildStage = new System.IO.StringWriter(SB);
@@ -1028,7 +1029,7 @@ private void lvProjects_ColumnClick(object sender, ColumnClickEventArgs e)
10281029
}
10291030
else
10301031
{
1031-
compare.SortAscending = false;
1032+
compare.SortAscending = true;
10321033
compare.SortColumn = e.Column;
10331034
}
10341035
}
@@ -1131,10 +1132,13 @@ private void UpdateStartStopProjectButtonLabel()
11311132
// Implements the manual sorting of items by columns.
11321133
private class ListViewItemComparer : IComparer
11331134
{
1134-
private static string[] _columnSortTypes = new string[] { "string", "string", "string", "string", "string", "string", "datetime", "string", "string", "int" };
1135+
private static int _columnToSortAsDateTime = 6;
11351136
private int col;
11361137
private bool ascendingOrder;
11371138

1139+
private Dictionary<string, string[]> naturalSortTable;
1140+
private static Regex partRegex;
1141+
11381142
public int SortColumn
11391143
{
11401144
get { return col; }
@@ -1166,52 +1170,99 @@ public ListViewItemComparer(int column, bool ascending)
11661170
public int Compare(object x, object y)
11671171
{
11681172
int compare = 0;
1169-
switch (_columnSortTypes[col])
1173+
if (col == _columnToSortAsDateTime)
1174+
{
1175+
DateTime xDateTime = DateTime.MinValue;
1176+
DateTime yDateTime = DateTime.MinValue;
1177+
1178+
if (DateTime.TryParse(((ListViewItem)x).SubItems[SortColumn].Text, out xDateTime) && DateTime.TryParse(((ListViewItem)y).SubItems[SortColumn].Text, out yDateTime))
1179+
{
1180+
compare = DateTime.Compare(xDateTime, yDateTime);
1181+
}
1182+
}
1183+
else
11701184
{
1171-
case "int":
1172-
int xValue = 0;
1173-
int yValue = 0;
1174-
1175-
if (int.TryParse(((ListViewItem)x).SubItems[SortColumn].Text, out xValue) && int.TryParse(((ListViewItem)y).SubItems[SortColumn].Text, out yValue))
1176-
{
1177-
if (xValue < yValue)
1178-
{
1179-
compare = -1;
1180-
}
1181-
else
1182-
{
1183-
if (xValue > yValue)
1184-
{
1185-
compare = 1;
1186-
}
1187-
else
1188-
{
1189-
compare = 0;
1190-
}
1191-
}
1192-
}
1193-
break;
1194-
case "datetime":
1195-
DateTime xDateTime = DateTime.MinValue;
1196-
DateTime yDateTime = DateTime.MinValue;
1197-
1198-
if (DateTime.TryParse(((ListViewItem)x).SubItems[SortColumn].Text, out xDateTime) && DateTime.TryParse(((ListViewItem)y).SubItems[SortColumn].Text, out yDateTime))
1199-
{
1200-
compare = DateTime.Compare(xDateTime, yDateTime);
1201-
}
1202-
break;
1203-
default: // assume string
1204-
compare = string.Compare(((ListViewItem)x).SubItems[SortColumn].Text, ((ListViewItem)y).SubItems[SortColumn].Text);
1205-
break;
1185+
compare = NaturalCompare(((ListViewItem)x).SubItems[SortColumn].Text, ((ListViewItem)y).SubItems[SortColumn].Text);
12061186
}
12071187

12081188
if (!ascendingOrder)
12091189
{
12101190
compare = -compare;
12111191
}
12121192

1193+
// always sort column 0 in ascending order if value of other (higher) column is equal
1194+
if (compare == 0 && SortColumn != 0)
1195+
{
1196+
compare = NaturalCompare(((ListViewItem)x).SubItems[0].Text, ((ListViewItem)y).SubItems[0].Text);
1197+
}
1198+
12131199
return compare;
12141200
}
1201+
1202+
// NaturalCompare() is taken from Code Project Article "Natural Sort Comparer"
1203+
// see http://www.codeproject.com/Articles/22517/Natural-Sort-Comparer
1204+
private int NaturalCompare(string x, string y)
1205+
{
1206+
if (x == y)
1207+
{
1208+
return 0;
1209+
}
1210+
1211+
if (naturalSortTable == null)
1212+
{
1213+
naturalSortTable = new Dictionary<string, string[]>();
1214+
}
1215+
if (partRegex == null)
1216+
{
1217+
partRegex = new Regex("([0-9]+)");
1218+
}
1219+
1220+
string[] x1, y1;
1221+
if (!naturalSortTable.TryGetValue(x, out x1))
1222+
{
1223+
x1 = partRegex.Split(x.Replace(" ", ""));
1224+
naturalSortTable.Add(x, x1);
1225+
}
1226+
if (!naturalSortTable.TryGetValue(y, out y1))
1227+
{
1228+
y1 = partRegex.Split(y.Replace(" ", ""));
1229+
naturalSortTable.Add(y, y1);
1230+
}
1231+
1232+
for (int i = 0; i < x1.Length && i < y1.Length; i++)
1233+
{
1234+
if (x1[i] != y1[i])
1235+
{
1236+
return NaturalComparePart(x1[i], y1[i]);
1237+
}
1238+
}
1239+
if (y1.Length > x1.Length)
1240+
{
1241+
return 1;
1242+
}
1243+
if (x1.Length > y1.Length)
1244+
{
1245+
return -1;
1246+
}
1247+
return 0;
1248+
}
1249+
1250+
private static int NaturalComparePart(string left, string right)
1251+
{
1252+
int x, y;
1253+
if (!int.TryParse(left, out x))
1254+
{
1255+
return left.CompareTo(right);
1256+
}
1257+
1258+
if (!int.TryParse(right, out y))
1259+
{
1260+
return left.CompareTo(right);
1261+
}
1262+
1263+
return x.CompareTo(y);
1264+
}
1265+
12151266
}
12161267

12171268
private void currentStatusMenu_Click(object sender, EventArgs e)

project/CCTrayLib/Presentation/MainFormController.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public MainFormController(ICCTrayMultiConfiguration configuration, ISynchronizeI
4646
for (int i = 0; i < serverMonitors.Length; i++)
4747
{
4848
serverMonitors[i] = new SynchronizedServerMonitor(serverMonitors[i], owner);
49+
serverMonitors[i].Start();
4950
}
5051
aggregatedServerMonitor = new AggregatingServerMonitor(serverMonitors);
5152
queueIconProvider = new ResourceIntegrationQueueIconProvider();

project/CommonAssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//------------------------------------------------------------------------------
44
// <auto-generated>
55
// This code was generated by a tool.
6-
// Runtime Version:4.0.30319.225
6+
// Runtime Version:4.0.30319.237
77
//
88
// Changes to this file may cause incorrect behavior and will be lost if
99
// the code is regenerated.

project/Remote/CruiseServerClient.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,7 @@ public override bool Login(List<NameValuePair> credentials)
542542
if (!string.IsNullOrEmpty(resp.SessionToken))
543543
{
544544
SessionToken = resp.SessionToken;
545+
DisplayName = resp.DisplayName;
545546
return true;
546547
}
547548
else

project/Remote/Message.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,10 @@ public MessageKind Kind
104104
/// <returns>The text of the message.</returns>
105105
public override string ToString()
106106
{
107-
return message;
107+
if (message == null)
108+
return string.Empty;
109+
else
110+
return message;
108111
}
109112

110113
/// <summary>

project/Remote/Messages/LoginResponse.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public class LoginResponse
1515
{
1616
#region Private fields
1717
private string sessionToken;
18+
private string displayName;
1819
#endregion
1920

2021
#region Constructors
@@ -57,6 +58,18 @@ public string SessionToken
5758
set { sessionToken = value; }
5859
}
5960
#endregion
61+
62+
#region DisplayName
63+
/// <summary>
64+
/// The display name of the user.
65+
/// </summary>
66+
[XmlAttribute("displayName")]
67+
public string DisplayName
68+
{
69+
get { return displayName; }
70+
set { displayName = value; }
71+
}
72+
#endregion
6073
#endregion
6174
}
6275
}

project/Remote/XmlConversionUtil.cs

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,74 @@ public static object ConvertXmlToObject(Type messageType, string message)
121121

122122
return messageObj;
123123
}
124+
125+
/// <summary>
126+
/// Indicates whether or not a message string can be converted into an object.
127+
/// </summary>
128+
/// <param name="messageType">The type of message.</param>
129+
/// <param name="message">The XML of the message.</param>
130+
/// <returns>true if the message can be deserialized to the given message type.</returns>
131+
public static bool CanConvertXmlToObject(Type messageType, string message)
132+
{
133+
if (string.IsNullOrEmpty(message))
134+
{
135+
return false;
136+
}
137+
138+
// Make sure the serialiser has been loaded
139+
if (!messageSerialisers.ContainsKey(messageType))
140+
{
141+
messageSerialisers[messageType] = new XmlSerializer(messageType);
142+
}
143+
144+
// Perform the test
145+
try
146+
{
147+
using (StringReader reader = new StringReader(message))
148+
using (XmlReader xmlReader = XmlReader.Create(reader))
149+
return messageSerialisers[messageType].CanDeserialize(xmlReader);
150+
}
151+
catch (XmlException)
152+
{
153+
return false;
154+
}
155+
}
156+
#endregion
157+
158+
#region ConvertObjectToXml()
159+
/// <summary>
160+
/// Converts an object into a message string
161+
/// </summary>
162+
/// <param name="anObject">The object of the message.</param>
163+
/// <returns>The XML of the message.</returns>
164+
public static string ConvertObjectToXml(object anObject)
165+
{
166+
string result = null;
167+
168+
Type messageType = anObject.GetType();
169+
170+
// Make sure the serialiser has been loaded
171+
if (!messageSerialisers.ContainsKey(messageType))
172+
{
173+
messageSerialisers[messageType] = new XmlSerializer(messageType);
174+
}
175+
176+
// Perform the actual conversion
177+
XmlWriterSettings settings = new XmlWriterSettings();
178+
settings.OmitXmlDeclaration = true;
179+
180+
using (StringWriter stringWriter = new StringWriter())
181+
using (XmlWriter xmlWriter = XmlWriter.Create(stringWriter, settings))
182+
{
183+
XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces();
184+
namespaces.Add("", "");
185+
186+
messageSerialisers[messageType].Serialize(xmlWriter, anObject, namespaces);
187+
result = stringWriter.ToString();
188+
}
189+
190+
return result;
191+
}
124192
#endregion
125193

126194
#region ConvertXmlToRequest()

0 commit comments

Comments
 (0)