private void ExportMatrixPart(Package package, WfProcessDescriptor processDesc) { var matrix = WfMatrixAdapter.Instance.LoadByProcessKey(processDesc.Key, false); if (matrix == null) { return; } matrix.Loaded = true; Uri partUri = CreatePartUri(this.MatrixCounter.ToString(), PackagePartType.MatrixPart); if (ExistingParts.Contains(partUri.ToString())) { return; } this.MappingInfo.Add(new PackageRelationMapping() { MatrixPath = partUri.ToString(), MatrixDefID = matrix.Definition.Key, ProcessDescriptionID = processDesc.Key }); ExportMatrixDefPart(package, matrix.Definition); PackagePart part = package.CreatePart(partUri, MediaTypeNames.Application.Octet); using (MemoryStream bytes = matrix.ExportToExcel2007(this.IsRoleAsPerson)) { using (var stream = part.GetStream()) { bytes.CopyTo(stream); //stream.Write(bytes, 0, bytes.Length); stream.Flush(); } } ExistingParts.Add(partUri.ToString()); this.MatrixCounter++; }
private void ExportMatrixDefPart(Package package, WfMatrixDefinition matrixDef) { Uri partUri = CreatePartUri(matrixDef.Key, PackagePartType.MatrixDefPart); if (ExistingParts.Contains(partUri.ToString())) { return; } XElement matrixDefXml = XmlFormatter.Serialize(matrixDef); var xDoc = new XDocument(new XDeclaration("1.0", "utf-8", "true"), matrixDefXml); PackagePart part = package.CreatePart(partUri, MediaTypeNames.Text.Xml); using (var stream = part.GetStream()) { xDoc.Save(stream); stream.Flush(); } ExistingParts.Add(partUri.ToString()); }
private void ExportProcessPart(Package package, WfProcessDescriptor processDesc) { Uri partUri = CreatePartUri(processDesc.Key, PackagePartType.ProcessPart); if (ExistingParts.Contains(partUri.ToString())) { return; } XElement xeWfProcess = this.XmlFormatter.Serialize(processDesc); var xDoc = new XDocument(new XDeclaration("1.0", "utf-8", "true"), xeWfProcess); PackagePart part = package.CreatePart(partUri, MediaTypeNames.Text.Xml); using (var stream = part.GetStream()) { xDoc.Save(stream); stream.Flush(); } ExistingParts.Add(partUri.ToString()); }