/// <summary> /// To add the attachment of the notes based on ZCRMAttachment class instance. /// </summary> /// <param name="attachment">ZCRMAttachment class instance</param> public void AddAttachment(ZCRMAttachment attachment) { Attachments.Add(attachment); }
private ZCRMAttachment GetZCRMAttachment(JObject attachmentDetails) { ZCRMAttachment attachment = ZCRMAttachment.GetInstance(parentRecord, Convert.ToInt64(attachmentDetails["id"])); string fileName = (string)attachmentDetails["File_Name"]; if (fileName != null) { attachment.FileName = fileName; attachment.FileType = fileName.Substring(fileName.LastIndexOf('.') + 1); } if (attachmentDetails.ContainsKey("Size")) { attachment.Size = Convert.ToInt64(attachmentDetails["Size"]); } if (attachmentDetails.ContainsKey("Created_By") && attachmentDetails["Created_By"].Type != JTokenType.Null) { JObject createdByObject = (JObject)attachmentDetails["Created_By"]; ZCRMUser createdBy = ZCRMUser.GetInstance(Convert.ToInt64(createdByObject["id"]), (string)createdByObject["name"]); attachment.CreatedBy = createdBy; attachment.CreatedTime = CommonUtil.removeEscaping((string)JsonConvert.SerializeObject(attachmentDetails["Created_Time"])); if (attachmentDetails["Owner"] != null && attachmentDetails["Owner"].Type != JTokenType.Null) { JObject ownerObject = (JObject)attachmentDetails["Owner"]; ZCRMUser owner = ZCRMUser.GetInstance(Convert.ToInt64(ownerObject["id"]), (string)ownerObject["name"]); attachment.Owner = owner; } else { attachment.Owner = createdBy; } } if (attachmentDetails.ContainsKey("Modified_By") && attachmentDetails["Modified_By"].Type != JTokenType.Null) { JObject modifiedByObject = (JObject)attachmentDetails["Modified_By"]; ZCRMUser modifiedBy = ZCRMUser.GetInstance(Convert.ToInt64(modifiedByObject["id"]), (string)modifiedByObject["name"]); attachment.ModifiedBy = modifiedBy; attachment.ModifiedTime = CommonUtil.removeEscaping((string)JsonConvert.SerializeObject(attachmentDetails["Modified_Time"])); } if (attachmentDetails.ContainsKey("$editable")) { if (attachmentDetails["$editable"] != null) { attachment.Editable = Convert.ToBoolean(attachmentDetails["$editable"]); } } if (attachmentDetails.ContainsKey("$file_id")) { if (attachmentDetails["$file_id"] != null) { attachment.FieldId = Convert.ToString(attachmentDetails["$file_id"]); } } if (attachmentDetails.ContainsKey("$type")) { if (attachmentDetails["$type"] != null) { attachment.Type = Convert.ToString(attachmentDetails["$type"]); } } if (attachmentDetails.ContainsKey("$se_module")) { if (attachmentDetails["$se_module"] != null) { attachment.Se_module = Convert.ToString(attachmentDetails["$se_module"]); } } if (attachmentDetails.ContainsKey("$link_url")) { if (attachmentDetails["$link_url"] != null) { attachment.Link_url = Convert.ToString(attachmentDetails["$link_url"]); } } return(attachment); }