...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
/* IMPORTANT! ** For using this example you need to uncheck the "Allow generation of asynchronous operation" option in advanced Service Reference settings*/ using System; using System.Data; using System.IO; using YourServiceReferenceHere; namespace ConsoleApp2 { class Program { public static SecurityToken GetAuth() { SecurityToken securityToken = new SecurityToken() { Username = "Student Portal", UserId = -2, DashboardAdmin = true }; return securityToken; } static void Main(string[] args) { string filePath = /*File path here*/"C:\\Users\\katie.macpherson\\Downloads\\test.txt"; int documentRequirementId = /*ID here*/123456; stringint mimeTypestudentId = "text/plain";//Example4996; CreateDocumentFileAttachment(documentRequirementId, filePath, mimeType, studentId); } static void CreateDocumentFileAttachment(int documentRequirementId, string filePath, string mimeType, int studentId) { using (var client = new RegentEnterpriseServiceClient()) { var file = new FileInfo(filePath); var record = new DocumentRequirementFileAttachment() { DocumentRequirementId = documentRequirementId, DocumentRequirementIdSpecified = true, FileName = file.Name, FileSize = file.Length, FileSizeSpecified = true, MimeType = mimeType, StoredFileName = $"{Guid.NewGuid()}.{Path.GetExtension(filePath)}", StoredFile = File.ReadAllBytes(file.FullName), CreatedBy = -168, CreatedBySpecified = true, isFileExists = false, isFileExistsSpecified = true, CreatedOn = DateTime.Now, CreatedOnSpecified = true, ModifiedOn = DateTime.Now, ModifiedOnSpecified = true, ModifiedBy = -168, }; var ModifiedBySpecifiedcreateDocumentAttachmentRequest = new UpdateDocumentRequirementFileAttachmentRequest true, { }; var createDocumentAttachmentRequestRecord = record, new UpdateDocumentRequirementFileAttachmentRequest StudentId = {studentId, RecordStudentIdSpecified = recordtrue, SecurityToken = GetAuth(), }; var response = client.createDocumentRequirementFileAttachment(createDocumentAttachmentRequest); if (response.ErrorYN) { throw new Exception(response.Message); } } } } } |
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
/* IMPORTANT! ** For using this example you need to uncheck the "Allow generation of asynchronous operation" option in advanced Service Reference settings*/ using System; using System.Data; using System.IO; using YourServiceReferenceHere; namespace ConsoleApp2 { class Program { public static SecurityToken GetAuth() { SecurityToken securityToken = new SecurityToken() { Username = "Student Portal", UserId = -2, DashboardAdmin = true }; return securityToken; } static void Main(string[] args) { CreateStudentDocumentRequirement(/*documentId*/, /*studentId*/); } static void CreateStudentDocumentRequirement(Int64 documentId, Int64 studentId) { using (var client = new RegentEnterpriseServiceClient()) { var record = new DocumentRequirement() { // All fields below are required documentId = documentId, documentIdSpecified = true, studentId = studentId, studentIdSpecified = true, ActivitySourceTypeCode = "SYSTEMACTION", ActivityLogEntryTypeCode = "QARelated", createdDate = DateTime.Now, createdDateSpecified = true, CreatedBy = 1, CreatedBySpecified = true, reviewedDate = DateTime.UtcNow, reviewedDateSpecified = true, receivedDate = DateTime.UtcNow, receivedDateSpecified = true, EditLockTimestamp = DateTime.UtcNow, EditLockTimestampSpecified = true, Files = new DocumentRequirementFileAttachment[] { } }; var createDRReques = new UpdateDocumentRequirementRequest { Record = record, SecurityToken = GetAuth() }; var response = client.createDocumentRequirement(createDRReques); if (response.ErrorYN) { throw new Exception(response.Message); } } } } } |
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
/* IMPORTANT! ** For using this example you need to uncheck the "Allow generation of asynchronous operation" option in advanced Service Reference settings*/ using System; using System.Data; using System.IO; using YourServiceReferenceHere; namespace ConsoleApp2 { class Program { public static SecurityToken GetAuth() { SecurityToken securityToken = new SecurityToken() { Username = "Student Portal", UserId = -2, DashboardAdmin = true }; return securityToken; } static void Main(string[] args) { GetFileFromDocumentRequirementFileAttachmentById(/*documentRequirementIdFileAttachmentId*/, /*Target folder path*/); } static void GetFileFromDocumentRequirementFileAttachmentById(int documentRequirementIdFileAttachmentId, string targetFolder) { using (var client = new RegentEnterpriseServiceClient()) { var request = new GetDocumentRequirementFileAttachmentRequest { SecurityToken = GetAuth(), Id = documentRequirementIdFileAttachmentId, IdSpecified = true, }; var record = client.getDocumentRequirementFileAttachment(request).Record; if (record.StoredFile.Length > 0) { File.WriteAllBytes(Path.Combine(targetFolder, record.FileName), record.StoredFile); } } } } } |
...