public return_note_attachment() { note_attachment = new note_attachment(); error = new error_value(); }
public set_entry_result set_note_attachment(string session, note_attachment note) { object[] results = this.Invoke("set_note_attachment", new object[] { session, note}); return ((set_entry_result)(results[0])); }
public set_entry_result set_note_attachment(string session, note_attachment note) { Guid gUSER_ID = GetSessionUserID(session); Guid gNOTE_ID = Sql.ToGuid(note.id); string sFILENAME = Path.GetFileName (note.filename); string sFILE_EXT = Path.GetExtension(sFILENAME); string sFILE_MIME_TYPE = "application/octet-stream"; int nACLACCESS = Security.GetUserAccess("Notes", "edit"); if ( nACLACCESS < 0 ) { L10N L10n = new L10N("en-US"); throw(new Exception(L10n.Term("ACL.LBL_INSUFFICIENT_ACCESS"))); } set_entry_result result = new set_entry_result(); byte[] byData = Convert.FromBase64String(note.file); // 02/20/2006 Paul. Try and reduce the memory requirements by releasing the original data as soon as possible. note.file = null; using ( MemoryStream stm = new System.IO.MemoryStream(byData) ) { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using ( IDbConnection con = dbf.CreateConnection() ) { con.Open(); Guid gASSIGNED_USER_ID = Guid.Empty; /* // 09/01/2006 Paul. Notes do not have an ASSIGNED_USER_ID. string sSQL = String.Empty; sSQL = "select * " + ControlChars.CrLf + " from vwNOTES_Edit" + ControlChars.CrLf + " where ID = @ID " + ControlChars.CrLf; using ( IDbCommand cmd = con.CreateCommand() ) { cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@ID", gNOTE_ID); using ( IDataReader rdr = cmd.ExecuteReader() ) { if ( rdr.Read() ) { gASSIGNED_USER_ID = Sql.ToGuid(rdr["ASSIGNED_USER_ID"]); } } } */ if ( nACLACCESS != ACL_ACCESS.OWNER || (nACLACCESS == ACL_ACCESS.OWNER && gASSIGNED_USER_ID == gUSER_ID) ) { using ( IDbTransaction trn = con.BeginTransaction() ) { try { Guid gAttachmentID = Guid.Empty; SqlProcs.spNOTE_ATTACHMENTS_Insert(ref gAttachmentID, gNOTE_ID, note.filename, sFILENAME, sFILE_EXT, sFILE_MIME_TYPE, trn); SplendidCRM.Notes.EditView.LoadFile(gAttachmentID, stm, trn); trn.Commit(); } catch(Exception ex) { trn.Rollback(); SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); throw ( new Exception(ex.Message) ); } } } } } byData = null; return result; }
public string[] GetNoteAttachment(string id) { note_attachment attachment2 = _sugarsoap.get_note_attachment(_session, id).note_attachment; return(new[] { attachment2.file, attachment2.filename }); }