© 2018 Capita Business Services Ltd. All rights reserved.

Capita Education Software Solutions is a trading name of Capita Business Services Ltd. Our Registered office is 30 Berners Street, London, W1T 3LR and our registered number is 02299747. Further information about Capita plc can be found in our legal statement.

Local API - Document Server Interface

The Document Server

The document server physically holds the documents linked into SIMS and acts as a repository for those documents for all machines connected to SIMS. Links to the documents are stored and maintained in the SIMS SQL database.

Documents can be retrieved (browsed) in their own right or linked via another entity such as a student.

Accessing Documents via other Entities

If you want to obtain the documents linked to an entity (such as all documents linked to a particular student) then load the main entity first and then step through the document entities linked to that main entity.

This code sample will step through each document loaded for the student with a person_id of 4030.

 

//instantiate objects
SIMS.Processes.DocManagementCache docCache = new SIMS.Processes.DocManagementCache();
SIMS.Processes.DocumentServers docserv = new DocumentServers();
SIMS.Processes.DocManagementCache.Populate();
SIMS.Processes.EditStudentInformationReadOnly editStudent = new SIMS.Processes.EditStudentInformationReadOnly();
//load editstudent entity for person_id 4030
editStudent.Load(new Person(4030),DateTime.Now);

//step though each document that the student is linked to
foreach (SIMS.Entities.Document gendoc in editStudent.Student.Documents) 
	{
//sample document properties
gendoc.LocalFilename;
gendoc.AttachmentName;
gendoc.DocumentType.DescriptionAttribute.ToString();	
}

Accessing the Document Server directly

This method allows you to create and read documents directly. You will still need to supply a person_id for the particular documents you want to interact with but you will be able to add documents rather than just view or amend them.

 

In this sample code a new SIMS Entity of type Document is created, amended and then linked to the ManageEntityDocuments process. The ManageEntityDocuments Save process (loaded for the IDocumentLinkedEntity for  student with a person_id pf 6345) is then called linking this new document to the student.

//Creates a ManageEntityDocuments process for the person_id you pass in.

SIMS.Entities.IIDEntity identity  = new SIMS.Entities.Person(6345);                 
EditStudentInformation edStudInfo = new EditStudentInformation();
edStudInfo.Load(identity,System.DateTime.Now);
                  
 //create a linkedEntity of type PERSON for the passed in student id.
IDocumentLinkedEntity entity = new DocumentLinkedEntity(edStudInfo.Student.ID, "PERSON");
// create a collection of linkedEntity’s
DocumentLinkedEntitys entitys = new DocumentLinkedEntitys();                  

//set the Entities as of type PERSON.
entitys.MainEntity = new DocumentLinkedEntity(entity.ID, entity.EntityType.CodeAttribute.Value);
entitys.SubEntity = new DocumentLinkedEntity(entity.ID, "PERSON");

//create a new document and set the properties. Example is for a student medical document
Document document = new Document(entitys, InformationDomainEnum.StudentBasic);
document.State = DocumentState.New;             
document.AttachmentNameAttribute.Value = "test.doc";
document.LocalFilename = "d:\temp\test.doc";                
document.DocumentType = SIMS.Entities.DocManagementCache.DocumentTypes.ItemByCode("STUDMED") as DocumentType;
document.SummaryAttribute.Value = "test";       
                  
//create a manageEntityDocuments process, then add in the document from above and save. 
SIMS.Processes.ManageEntityDocuments manEntDoc = new  ManageEntityDocuments(entity);
manEntDoc.Entity.Documents.Add(document);
manEntDoc.Save();       

Attaching a document to Agent

editAgent.Load(5867,System.DateTime.Now); 
Document doc = ((IDocumentLinkedEntity)editAgent.Agent).CreateNewDocument();
doc.DocumentType = (DocumentType)SIMS.Entities.DocManagementCache.DocumentTypes.ItemByCode("SENFDESC");	//You should have all the documenttypes in the DocumentCache
doc.State = DocumentState.New;
doc.AttachmentNameAttribute.Value = "test";
doc.LocalFilename = @"D:\priya\CSSMobileTestBed\CSS Mobile Test Bed.doc"; //This doc is on my local machine
doc.SummaryAttribute.Value = "test";

SIMS.Processes.ManageEntityDocuments manEntDoc = new  ManageEntityDocuments(editAgent.Agent);
manEntDoc.Entity.Documents.Add(doc);
manEntDoc.Save();       

similar code works for employee and agency.

SIMS 7 RESOURCES

Related resources for SIMS 7