public bool AddAttachment(Attachment attachment) { //Add a new attachment to an existing action bool added = false; CRMServiceClient client = new CRMServiceClient(); try { added = client.AddAttachment(attachment); client.Close(); } catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); } catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); } catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); } return(added); }
public static bool AddAttachment(string filename, byte[] bytes, long actionID) { // bool res = false; CRMServiceClient client = null; try { //Create DTO and call service Attachment attachment = new Attachment(); attachment.Filename = filename; attachment.File = bytes; attachment.ActionID = actionID; client = new CRMServiceClient(); res = client.AddAttachment(attachment); client.Close(); } catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); } catch (FaultException <CustomersFault> cfe) { client.Abort(); throw new ApplicationException(cfe.Detail.Message); } catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); } catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); } return(res); }