00001 /* Bugzilla C# Proxy Library 00002 Copyright (C) 2006, Dansk BiblioteksCenter A/S 00003 Mads Bondo Dydensborg, <mbd@dbc.dk> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 2.1 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public 00016 License along with this library; if not, write to the Free Software 00017 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00018 */ 00019 /*! \file 00020 \brief Encapsulation of a bug in Bugzilla. 00021 00022 Bugs are, of course, what Bugzilla tracks. In order to do anything with bugs, 00023 you need bug objects. 00024 00025 Instances of this class can be used to manipulate a Bug in a 00026 Bugzilla server. 00027 00028 You cannot directly create a \b Bug object. You should get a \b Bug 00029 object from Server.GetBug or Server.GetBugs. 00030 00031 In order to actually instantiate a Bug, a Server instance must be 00032 supplied. 00033 */ 00034 00035 using CookComputing.XmlRpc; 00036 using System; 00037 using Bugzproxy.ProxyStructs; 00038 00039 namespace Bugzproxy { 00040 /// <summary>This class Encapsulates a bug in Bugzilla</summary> 00041 /// <remarks> 00042 /// <para>One should assume that all operations on a <b>Bug</b> will create network 00043 /// traffic, unless specifically indicated they will not.</para> 00044 /// <para>Properties reflect settings that will not cause network traffic, except 00045 /// for <see cref="Resolution"/>, while methods typically involves the server 00046 /// on the other end.</para> 00047 /// <para>Currently there are no public constructors. You should get a <b>Bug</b> 00048 /// object from <see cref="Server.GetBug"/> or <see cref="Server.GetBugs"/>. 00049 /// </para> 00050 /// </remarks> 00051 public class Bug { 00052 private Server server; 00053 private BugInfo bi; // Must always be valid 00054 00055 /*! \name Constructors */ 00056 00057 //@{ 00058 00059 // This assumes the bug already exists on the server side. 00060 /// <summary> 00061 /// Initialize a new instance of the <see cref="Bug"/> class. 00062 /// </summary> 00063 /// <param name="server">A <see cref="Server"/> instance that is associated with this bug</param> 00064 /// <param name="bi">Information about the bug, as retreived from the server</param> 00065 internal Bug(Server server, BugInfo bi) { 00066 this.server = server; 00067 this.bi = bi; 00068 } 00069 //@} 00070 00071 /*! \name General methods */ 00072 //@{ 00073 00074 /// <summary>Update bug from server</summary> 00075 /// <remarks>Get any changes to the bug from the server. This updates information 00076 /// such as the time/date of the last change to the bug, etc.</remarks> 00077 public void Update() { 00078 int[] ids = new int[] { bi.id }; 00079 BugIds param; 00080 param.ids = ids; 00081 this.bi = server.Proxy.GetBugs(param).bugs[0]; 00082 } 00083 00084 //@} 00085 00086 /*! \name Experimental 00087 Experimental methods require patches. */ 00088 00089 //@{ 00090 /*! \example AppendComment.cs 00091 * This is an example on how to use the Bugzproxy.Bug.AppendComment method */ 00092 00093 /// <summary>Append a comment to the bug.</summary> 00094 /// <param name="comment">The comment to append</param> 00095 /// <param name="isPrivate"><b>true</b> to make this comment visible to members 00096 /// of Bugzilla's <c>insidergroup</c> only, <b>false</b> (or <b>null</b>) to 00097 /// make it visible to all members.</param> 00098 /// <param name="worktime">The work time of this comment. Can be <b>null</b> 00099 /// or 0 for no work time. Ignored if You are not in the <c>timetrackinggroup</c>. 00100 /// </param> 00101 /// <remarks> 00102 /// <para>This requires a patch from 00103 /// <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=355847">Bug 355847</a>. 00104 /// </para> 00105 /// <para>If <paramref name="isPrivate"/> is <b>null</b>, the comment is assumed 00106 /// public.</para> 00107 /// </remarks> 00108 public void AppendComment(string comment, bool? isPrivate, double? worktime) { 00109 AppendCommentParam param = new AppendCommentParam(); 00110 param.id = bi.id; 00111 param.comment = comment; 00112 param.isPrivate = isPrivate; 00113 param.workTime = worktime; 00114 server.Proxy.AppendComment(param); 00115 /*! \todo, call update? */ 00116 } 00117 00118 /// <summary> 00119 /// Append a comment to the bug. 00120 /// </summary> 00121 /// <param name="comment">The comment to append</param> 00122 /// <remarks>Works with Bugzilla trunk (3.1.2+) only</remarks> 00123 public void AppendComment(string comment) { 00124 AppendComment(comment, null, null); 00125 } 00126 00127 /// <summary> 00128 /// Append a comment to the bug. 00129 /// </summary> 00130 /// <param name="comment">The comment to append</param> 00131 /// <param name="isPrivate"><b>true</b> to make this comment visible to members 00132 /// of Bugzilla's <c>insidergroup</c> only, <b>false</b> (or <b>null</b>) to 00133 /// make it visible to all members.</param> 00134 /// <remarks>Works with Bugzilla trunk (3.1.2+) only</remarks> 00135 public void AppendComment(string comment, bool? isPrivate) { 00136 AppendComment(comment, isPrivate, null); 00137 } 00138 00139 /// <summary> 00140 /// Append a comment to the bug. 00141 /// </summary> 00142 /// <param name="comment">The comment to append</param> 00143 /// <param name="worktime">The work time of this comment. Can be <b>null</b> 00144 /// or 0 for no work time. Ignored if You are not in the <c>timetrackinggroup</c>. 00145 /// </param> 00146 /// <remarks>Works with Bugzilla trunk (3.1.2+) only</remarks> 00147 public void AppendComment(string comment, double? worktime) { 00148 AppendComment(comment, null, worktime); 00149 } 00150 00151 /// <summary> 00152 /// Set the bug resolution 00153 /// </summary> 00154 /// <value>A <b>string</b> with a legal resolution value to set for this bug.</value> 00155 /// <remarks>This property is not implemented in Bugzilla, and requires an 00156 /// unpublished patch. It calls a web service named <c>Bug.set_resolution</c> 00157 /// (and therefore creates network traffic).</remarks> 00158 public string Resolution { 00159 set { 00160 SetBugResolutionParam parameters; 00161 parameters.bugId = bi.id; 00162 parameters.resolution = value; 00163 server.Proxy.SetBugResolution(parameters); 00164 Update(); 00165 } 00166 } 00167 00168 //@} 00169 00170 /// <summary> 00171 /// Get the bug id number 00172 /// </summary> 00173 /// <value>The bug id.</value> 00174 public int Id { 00175 get { 00176 return bi.id; 00177 } 00178 } 00179 00180 /// <summary> 00181 /// Get the time the bug was created 00182 /// </summary> 00183 /// <value>The bug creation time.</value> 00184 public DateTime Created { 00185 get { 00186 return bi.created; 00187 } 00188 } 00189 00190 /// <summary> 00191 /// Get the time the bug was last changed. 00192 /// </summary> 00193 /// <value>The bug last change time.</value> 00194 /// <remarks>A change may be a change in any of the bug fields, or a change 00195 /// in the status of an attachment of the bug.</remarks> 00196 public DateTime Changed { 00197 get { 00198 return bi.changed; 00199 } 00200 } 00201 00202 /// <summary> 00203 /// Get the bug alias 00204 /// </summary> 00205 /// <value>The bug alias</value> 00206 public string Alias { 00207 get { 00208 return bi.alias; 00209 } 00210 } 00211 00212 /// <summary> 00213 /// Get the bug summary 00214 /// </summary> 00215 /// <value>The bug summary</value> 00216 public string Summary { 00217 get { 00218 return bi.summary; 00219 } 00220 } 00221 00222 } // class Bug 00223 00224 } // namespace Bugzproxy