FogBugz » FogBugz for Visual Studio Read More
Clone URL:  
Case.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
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
using System; using System.Collections.Generic; using System.Text; using System.Drawing; namespace FogBugzForVisualStudio.Api { public class Case { [FlagsAttribute] public enum Op { edit = 0x0001, spam = 0x0002, assign = 0x0004, resolve = 0x0008, move = 0x0010, reactivate = 0x0020, close = 0x0040, reopen = 0x0080, remind = 0x0100, reply = 0x0200, forward = 0x0400, email = 0x0800 } public int ixBug { get; private set; } public Op ops { get; private set; } public int? ixBugParent { get; private set; } public IList<int> ixBugChildren { get; private set; } public int ixBugEventLatest { get; private set; } public int ixBugEventLastView { get; private set; } public Category category { get; private set; } public Priority priority { get; private set; } public Status status { get; private set; } public Project project { get; private set; } public Area area { get; private set; } public FixFor fixfor { get; private set; } public string sTitle { get; private set; } public Person assignedTo { get; private set; } public Person openedBy { get; private set; } public Person resolvedBy { get; private set; } public Person closedBy { get; private set; } public Person lastEditedBy { get; private set; } public Estimate hrsOrigEst { get; private set; } public Estimate hrsCurrEst { get; private set; } public Estimate hrsElapsed { get; private set; } public Estimate hrsRemaining { get { return new Estimate(Math.Max(this.hrsCurrEst.hrs - this.hrsElapsed.hrs, Decimal.Zero)); } } public Nullable<DateTime> dtOpened { get; private set; } public Nullable<DateTime> dtResolved { get; private set; } public Nullable<DateTime> dtClosed { get; private set; } public Nullable<DateTime> dtDue { get; private set; } public Nullable<DateTime> dtLastUpdated { get; private set; } public int? iBacklog { get; private set; } public static string BacklogFieldName = "plugin_projectbacklog_at_fogcreek_com_ibacklog"; public Case(int ixBug, Op ops, Dictionary<String, String> fields, FogBugzClient parentClient) { this.ixBug = ixBug; this.ops = ops; if (!String.IsNullOrEmpty(fields["ixBugParent"])) { this.ixBugParent = Convert.ToInt32(fields["ixBugParent"]); if (this.ixBugParent <= 0) this.ixBugParent = null; } else { this.ixBugParent = null; } this.ixBugChildren = new List<int>(); if (!String.IsNullOrEmpty(fields["ixBugChildren"])) { foreach (string ix in fields["ixBugChildren"].Split(',')) { this.ixBugChildren.Add(Convert.ToInt32(ix)); } } this.ixBugEventLatest = Convert.ToInt32(fields["ixBugEventLatest"]); this.ixBugEventLastView = Convert.ToInt32(fields["ixBugEventLastView"]); this.category = parentClient.GetCategory(Convert.ToInt32(fields["ixCategory"])); this.priority = new Priority(Convert.ToInt32(fields["ixPriority"]), fields["sPriority"]); this.status = parentClient.GetStatus(Convert.ToInt32(fields["ixStatus"])); this.project = new Project(Convert.ToInt32(fields["ixProject"]), fields["sProject"]); this.area = new Area(Convert.ToInt32(fields["ixArea"]), fields["sArea"]); this.fixfor = new FixFor(Convert.ToInt32(fields["ixFixFor"]), fields["sFixFor"]); this.sTitle = fields["sTitle"]; this.assignedTo = parentClient.GetPerson(Convert.ToInt32(fields["ixPersonAssignedTo"])); this.openedBy = parentClient.GetPerson(Convert.ToInt32(fields["ixPersonOpenedBy"])); this.resolvedBy = parentClient.GetPerson(Convert.ToInt32(fields["ixPersonResolvedBy"])); this.closedBy = parentClient.GetPerson(Convert.ToInt32(fields["ixPersonClosedBy"])); this.lastEditedBy = parentClient.GetPerson(Convert.ToInt32(fields["ixPersonLastEditedBy"])); this.hrsOrigEst = Estimate.Parse(fields["hrsOrigEst"]); this.hrsCurrEst = Estimate.Parse(fields["hrsCurrEst"]); this.hrsElapsed = Estimate.Parse(fields["hrsElapsed"]); this.dtOpened = Util.ParseApiDate(fields["dtOpened"]); this.dtResolved = Util.ParseApiDate(fields["dtResolved"]); this.dtClosed = Util.ParseApiDate(fields["dtClosed"]); this.dtDue = Util.ParseApiDate(fields["dtDue"]); this.dtLastUpdated = Util.ParseApiDate(fields["dtLastUpdated"]); if (fields.ContainsKey(BacklogFieldName) && !String.IsNullOrEmpty(fields[BacklogFieldName])) { this.iBacklog = Convert.ToInt32(fields[BacklogFieldName]); } } /// <summary> /// DataGridView's binding doesn't support subkeys. So cheat and add a shortcut. /// </summary> public Bitmap categoryImage { get { return category.Image; } } public bool Unread { get { return ixBugEventLastView < ixBugEventLatest; } set { // An exception to our usual immutability, since the user might view a case if (value) { ixBugEventLastView = ixBugEventLatest; } else { ixBugEventLastView = 0; } } } public void SetNewEstimate(Estimate e) { // A rare exception to Bug's immutability. Thus make a special wrapper method to set this. hrsCurrEst = e; } internal void WorkStarted() { hrsElapsed = new Estimate(0.01m); } } }