protected virtual void CreateDocument(IDocument controller, string filename, XmlTemplate template, string transformationFile, object data, View view) { try { controller.CreateDocument(filename, template, data, DocumentType.Xml, view); } catch (DuradosException exception) { throw new WorkflowEngineException(exception.Message); } }
public override string Create(IDocument controller, Dictionary <string, Parameter> parameters, View view, Dictionary <string, object> values, DataRow prevRow, string pk, string connectionString, IDbCommand command) { //Dictionary<string, object> blocksValues = controller.GetBlocksValues(pk, view); object data = GetData(controller, pk, view); string fieldName = GetDocumentFieldName(controller, parameters, view, values, prevRow, pk, connectionString, command); if (string.IsNullOrEmpty(fieldName)) { throw new WorkflowEngineException("The document field name was not supplied. Please make sure that the rule has the DocumentFieldName paremeter points to the correct document field."); } if (!view.Fields.ContainsKey(fieldName)) { throw new WorkflowEngineException("The document field " + fieldName + " does not exist in the " + view.DisplayName + " view. Please make sure that the rule parameters are correct."); } Field field = view.Fields[fieldName]; if (field.FieldType != FieldType.Column) { throw new WorkflowEngineException("Please configure the " + field.DisplayName + " to be an upload field."); } string template = GetTemplate(fieldName, controller, parameters, view, values, prevRow, pk, connectionString, command); if (!System.IO.File.Exists(template)) { throw new WorkflowEngineException("The template file " + template + " was not found. Please check the Upload configuration, the document template table and the rule parameters."); } string filename = GetFileName(template, controller, parameters, view, fieldName, values, prevRow, pk, connectionString, command, data); string transformationFile = GetTransformationFile(fieldName, controller, parameters, view, values, prevRow, pk, connectionString, command); if (!System.IO.File.Exists(transformationFile)) { throw new WorkflowEngineException("The xsl file " + transformationFile + " was not found. Please check the Upload configuration, the document template table and the rule parameters."); } //controller.CreateDocument(filename, template, blocksValues); XmlTemplate xmlTemplate = new XmlTemplate() { Schema = template, Xslt = transformationFile }; CreateDocument(controller, filename, xmlTemplate, transformationFile, data, view); System.IO.FileInfo fileInfo = new System.IO.FileInfo(xmlTemplate.Ouput); controller.UpdateDocumentRow(view, pk, fieldName, fileInfo.Name, command); return(filename); }