当前文件路径:BugNet/BugNET_WAP/Bugs/Rss.aspx.cs 
1
using System;
2
using System.Collections;
3
using System.ComponentModel;
4
using System.Data;
5
using System.Drawing;
6
using System.Web;
7
using System.Web.SessionState;
8
using System.Web.UI;
9
using System.Web.UI.WebControls;
10
using System.Web.UI.HtmlControls;
11
using Rss;
12
using BugNET.BusinessLogicLayer;
13
14
namespace BugNET.Bugs
15
...{
16
/**//// <summary>
17
/// Summary description for RSS.
18
/// </summary>
19
public partial class RSS : System.Web.UI.Page
20
...{
21
int ProjectId;
22
int FeedId;
23
string ProjectName;
24
RssChannel channel = new RssChannel();
25
RssFeed feed = new RssFeed();
26
27
/**//// <summary>
28
/// Handles the Load event of the Page control.
29
/// </summary>
30
/// <param name="sender">The source of the event.</param>
31
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
32
protected void Page_Load(object sender, System.EventArgs e)
33
...{
34
//get project id
35
if (Request.QueryString["pid"] != null)
36
ProjectId = Convert.ToInt32(Request.Params["pid"]);
37
//get feed id
38
if (Request.QueryString["feed"] != null)
39
FeedId = Convert.ToInt32(Request.Params["feed"]);
40
41
ProjectName = Project.GetProjectById(ProjectId).Name;
42
43
switch(FeedId)
44
...{
45
46
case 1:
47
VersionFeed();
48
break;
49
case 2:
50
ComponentFeed();
51
break;
52
case 3:
53
StatusFeed();
54
break;
55
case 4:
56
PriorityFeed();
57
break;
58
case 5:
59
TypeFeed();
60
break;
61
case 6:
62
AssigneeFeed();
63
break;
64
case 7:
65
FilteredIssuesFeed();
66
break;
67
}
68
69
channel.LastBuildDate = channel.Items.LatestPubDate();
70
channel.Link = new System.Uri( HostSettings.GetHostSetting("DefaultUrl") + "/Bugs/BugList.aspx?"+ Request.QueryString.ToString());
71
72
try
73
...{
74
feed.Channels.Add(channel);
75
feed.Encoding = System.Text.Encoding.UTF8;
76
Response.ContentType = "text/xml";
77
feed.Write(Response.OutputStream);
78
Response.End();
79
}
80
catch...{
81
//TODO:Catch exceptions here.
82
}
83
84
85
}
86
87
/**//// <summary>
88
/// Filtereds the issues feed.
89
/// </summary>
90
private void FilteredIssuesFeed()
91
...{
92
BugCollection bugs= new BugCollection();
93
94
if(BugId != 0)
95
...{
96
Bug searchBug = Bug.GetBugById(BugId);
97
98
if(searchBug !=null)
99
...{
100
bugs.Add(searchBug);
101
}
102
}
103
else
104
...{
105
bugs = Bug.GetBugsByCriteria(ProjectId,ComponentId,VersionId,TypeId,PriorityId,
106
StatusId,AssignedToUserName,ResolutionId,Key,false);
107
}
108
109
110
foreach(Bug b in bugs)
111
...{
112
RssItem item = new RssItem();
113
item.Title = string.Format("{0} - {1}",b.FullId,b.Summary);
114
item.Description = b.Description;
115
item.Author = b.ReporterDisplayName;
116
//item. = b.ComponentName;
117
item.PubDate = b.DateCreated;
118
item.Link = new System.Uri(Page.ResolveUrl(string.Format("{0}/Bugs/BugDetail.aspx?bid={1}",HostSettings.GetHostSetting("DefaultUrl"),b.Id.ToString())));
119
channel.Items.Add(item);
120
}
121
122
channel.Title = ProjectName + " Filtered Issues";
123
channel.Description = "A filtered list of " + ProjectName + " issues";
124
}
125
126
Querystring Properties#region Querystring Properties
127
/**//// <summary>
128
/// Returns the component Id from the querystring
129
/// </summary>
130
public int ComponentId
131
...{
132
get
133
...{
134
if(Request.Params["c"] == null)
135
...{
136
return -1;
137
}
138
return Convert.ToInt32(Request.Params["c"]);
139
}
140
}
141
/**//// <summary>
142
/// Returns the keywords from the querystring
143
/// </summary>
144
public string Key
145
...{
146
get
147
...{
148
if(Request.Params["key"] == null)
149
...{
150
return string.Empty;
151
}
152
return Request.Params["key"].Replace("|"," ");
153
}
154
}
155
/**//// <summary>
156
/// Returns the version Id from the querystring
157
/// </summary>
158
public int VersionId
159
...{
160
get
161
...{
162
if(Request.Params["v"] == null)
163
...{
164
return -1;
165
}
166
return Convert.ToInt32(Request.Params["v"]);
167
}
168
}
169
/**//// <summary>
170
/// Returns the priority Id from the querystring
171
/// </summary>
172
public int PriorityId
173
...{
174
get...{return Convert.ToInt32(Request.Params["p"]);}
175
}
176
/**//// <summary>
177
/// Returns the Type Id from the querystring
178
/// </summary>
179
public int TypeId
180
...{
181
get...{return Convert.ToInt32(Request.Params["t"]);}
182
}
183
/**//// <summary>
184
/// Returns the status Id from the querystring
185
/// </summary>
186
public int StatusId
187
...{
188
get...{return Convert.ToInt32(Request.Params["s"]);}
189
}
190
/**//// <summary>
191
/// Returns the assigned to user Id from the querystring
192
/// </summary>
193
public string AssignedToUserName
194
...{
195
get
196
...{
197
if(Request.Params["u"] == null)
198
...{
199
return string.Empty;
200
}
201
return Request.Params["u"].ToString();
202
}
203
}
204
/**//// <summary>
205
/// Returns the hardware Id from the querystring
206
/// </summary>
207
/// <value>The resolution id.</value>
208
public int ResolutionId
209
...{
210
get...{return Convert.ToInt32(Request.Params["r"]);}
211
}
212
213
/**//// <summary>
214
/// Gets the bug id.
215
/// </summary>
216
/// <value>The bug id.</value>
217
public int BugId
218
...{
219
get...{return Convert.ToInt32(Request.Params["bid"]);}
220
}
221
#endregion
222
223
Feed Methods#region Feed Methods
224
225
/**//// <summary>
226
/// Creates an RSS news feed for Issues By Version
227
/// </summary>
228
private void VersionFeed()
229
...{
230
ArrayList lsVersion = (ArrayList)Bug.GetBugVersionCountByProject(ProjectId);
231
232
foreach(BugCount bc in lsVersion)
233
...{
234
RssItem item = new RssItem();
235
item.Title = bc.Name;
236
item.Description = string.Concat(bc.Count.ToString()," Open Issues");
237
item.PubDate = DateTime.Now;
238
item.Link = new System.Uri(Page.ResolveUrl(string.Format("{2}/Bugs/BugList.aspx?pid={0}&s=0&v={1}",ProjectId,bc.Id, HostSettings.GetHostSetting("DefaultUrl"))));
239
channel.Items.Add(item);
240
}
241
242
channel.Title = ProjectName + " Issues By Version";
243
channel.Description = "A listing of all " + ProjectName + " issues grouped by version";
244
}
245
246
/**//// <summary>
247
/// Creates an RSS news feed for Issues By Component
248
/// </summary>
249
private void ComponentFeed()
250
...{
251
ComponentTree objComps = new ComponentTree();
252
ArrayList al = (ArrayList)objComps.GetComponentTreeByProjectId(ProjectId);
253
254
foreach(BugNET.BusinessLogicLayer.Component c in al)
255
...{
256
RssItem item = new RssItem();
257
item.Title = c.Name;
258
item.Description = string.Concat(Bug.GetBugCountByProjectAndComponent(ProjectId,c.Id).ToString()," Open Issues");
259
item.PubDate = DateTime.Now;
260
item.Link = new System.Uri(Page.ResolveUrl(string.Format("{2}/Bugs/BugList.aspx?pid={0}&s=0&c={1}",ProjectId,c.Id, HostSettings.GetHostSetting("DefaultUrl"))));
261
channel.Items.Add(item);
262
}
263
264
channel.Title = ProjectName + " Issues By Component";
265
channel.Description = "A listing of all " + ProjectName + " issues grouped by component";
266
}
267
268
