Web Services - Creating attachments
I recently started playing around with attching a file to new issue and cant seem to get it to work.
Can anyone help. Below is sample code from Countersoft's sample application modified to attach a file on issue creation.
private void btnCreateIssueClick(object sender, System.EventArgs e)
{
IssueEN data=new IssueEN();
IssueComponentEN[] iceComps = new IssueComponentEN[1];
iceComps[0] = new IssueComponentEN();
FileEN[] files = new FileEN[1];
files[0] = new FileEN();
iceComps[0].ComponentID = 1;
data.Components = iceComps;
data.FixedInVersion=0;
data.IssueLongDesc=txtDesc.Text;
data.IssuePriority=1;
data.IssueResolution=1;
data.IssueStatus=1;
data.IssueSummary=txtTitle.Text;
data.IssueType=1;
data.IssueSeverity = 1;
data.ReportedBy=1;
data.RiskLevel=1;
data.Visibility = 1;
data.VisibilityMemberType = GeminiConstant.SecurityMemberType.GlobalGroup;
data.ReportedByUsername = "test@test.com";
data.ProjectID = (int)numProjectID.Value;
System.IO.FileInfo attachment = new System.IO.FileInfo("c:\test.txt");
System.IO.FileStream fs = attachment.OpenRead();
byte[] bytes = new byte[fs.Length];
fs.Read(bytes, 0, (int)fs.Length);
fs.Close();
files[0].FileData = bytes;
files[0].FileName = "testatt";
files[0].ProjectID = (int)numProjectID.Value;
data.Attachments = files;
try
{
// Note that this might throw a security exception.
data.IssueID=msmProxyManager.IssueServices.CreateIssue(data);
BindGrid();
}
catch(Exception ex)
{
MessageBox.Show(this,ex.Message);
}
}
|
EWH
· 1 |
|
| Tuesday, September 16, 2008, 10:20:13 AM | |




