internal Attachment(Action parent, IssueDS.AttachmentTableRow attachment) { //Constructor try { this._parent = parent; this._actionid = parent.ID; if (attachment != null) { if (!attachment.IsIDNull()) { this._id = attachment.ID; } if (!attachment.IsFileNameNull()) { this._filename = attachment.FileName; } if (!attachment.IsFileNull()) { this._file = attachment.File; } if (!attachment.IsActionIDNull()) { this._actionid = attachment.ActionID; } } } catch (Exception ex) { throw new ApplicationException("Unexpected error while creating new Action instance", ex); } }
public static bool UpdateIssue(Issue issue) { //Update an existing issue bool b = false; try { //Update the updateable issue attributes _Mediator.ExecuteNonQuery(USP_ISSUE_UPDATE, new object[] { issue.ID, issue.ContactID, issue.OFD1FromDate, issue.OFD1ToDate, issue.PROID }); //Add any new actions and associated attachments DataSet ds = issue.Actions.GetChanges(DataRowState.Added); if (ds != null) { //NOTE: Should never be more than 1 new action (constrained by the issue.Add() // method which saves actions immediately) IssueDS actions = new IssueDS(); actions.Merge(ds); for (int i = 0; i < actions.ActionTable.Rows.Count; i++) { IssueDS.ActionTableRow a = actions.ActionTable[i]; object ao = _Mediator.ExecuteNonQueryWithReturn(USP_ACTION_NEW, new object[] { null, a.TypeID, issue.ID, a.UserID, a.Comment }); long aid = (long)ao; //Add associated attachments //NOTE: Attachments are held in the issue, but saved (associated) to the action try { DataSet _ds = issue.Attachments.GetChanges(DataRowState.Added); if (_ds != null) { IssueDS attachments = new IssueDS(); attachments.Merge(_ds); for (int j = 0; j < attachments.AttachmentTable.Rows.Count; j++) { IssueDS.AttachmentTableRow at = attachments.AttachmentTable[j]; SaveFileAttachment(aid, at.FileName, at.File); } } } catch (Exception ex) { throw new ApplicationException("Unexpected error while saving file attachment to new action.", ex); } } } b = true; } catch (Exception ex) { throw new ApplicationException("Unexpected error while updating issue.", ex); } finally { if (IssuesChanged != null) { IssuesChanged(null, EventArgs.Empty); } } return(b); }
public DataSet ToDataSet() { //Return a dataset containing values for this object IssueDS ds = null; try { ds = new IssueDS(); IssueDS.AttachmentTableRow attachment = ds.AttachmentTable.NewAttachmentTableRow(); attachment.ID = this._id; attachment.FileName = this._filename; attachment.File = this._file; attachment.ActionID = this._actionid; ds.AttachmentTable.AddAttachmentTableRow(attachment); } catch (Exception) { } return(ds); }