public static IIntelliFlowItem Create(Domain.IntelliFlowItem item, IDataContext context) { var fac = _itemFac[(Enums.IntelliFlowItemType)item.ItemTypeId]; var newItem = fac.Create(item.ItemTypeId); IDataRepository <Domain.IntelliFlowItem> itemRepos = new EFDataRepository <Domain.IntelliFlowItem>(context); IDataRepository <Domain.Expression> exprRepos = new EFDataRepository <Domain.Expression>(context); var childItems = itemRepos.Query(x => x.ParentItemId == (long)item.Id).ToArray(); if (!childItems.IsNullOrEmpty()) { var childItemList = new List <IIntelliFlowItem>(); foreach (var child in childItems) { var newChild = _Create(child, context, true); childItemList.Add(newChild); } newItem.Children = new IntelliFlowIterator <IIntelliFlowItem>(childItemList.ToArray()); } if (item.ParentItemId.HasValue) { var parent = itemRepos.Get(item.ParentItemId.Value); var newParent = _Create(parent, context, false); newItem.Parent = newParent; } if (!item.Data.IsNullOrEmpty()) { newItem.Input.Data = BinarySerializer.Deserialize((NEMILTEC.Shared.Enums.Data.DataType)item.DataTypeId, item.Data); } var itemExp = exprRepos.Query(x => x.ParentItemId == (long)item.Id).ToArray(); if (!itemExp.IsNullOrEmpty()) { var paramList = new List <IntelliFlowItemInputParameter>(); foreach (var exp in itemExp) { var param = new IntelliFlowItemInputParameter(); var newExp = ExpressionFactory.Create(exp, context); if (newExp is ValueExpression) { var valExp = newExp as ValueExpression; param.Value = valExp.Value; } param.Expression = newExp; paramList.Add(param); } newItem.Input.Parameters = paramList; } return(newItem); }
public static Stream GetStream(long docId, IDataContext context) { IDataRepository <Domain.Document> docRepos = new EFDataRepository <Domain.Document>(context); var document = docRepos.Get(docId); var stream = new MemoryStream(document.Data); stream.Position = 0; return(stream); }
/// <summary> /// generates an existing report from a set of known JSON parameters /// </summary> /// <param name="parameters"></param> /// <returns></returns> public static Stream Generate(long reportId, string connectionString, IDataContext context) { IDataRepository <Domain.Report> reportRepos = new EFDataRepository <Domain.Report>(context); //fetch report data var report = reportRepos.Get(reportId); var newReport = ReportFactory.CreateReport(report, context); var reportDocument = ReportFactory.CreateDocument((NEMILTEC.Interfaces.Service.Reporting.Enums.ReportOutputType)report.OutputType.Id); var reportStream = new MemoryStream(); newReport.TemplateFileStream.CopyTo(reportStream); reportDocument.Load(reportStream); foreach (var element in newReport.Elements) { var elemParams = element.Parameters; var elemParamDic = new Dictionary <string, object>(); if (!elemParams.IsNullOrEmpty()) { elemParamDic = element.Parameters.ToDictionary(e => e.Name, e => e.Value); } element.Import(connectionString, elemParamDic); element.Export(reportDocument); } var outStream = reportDocument.Save(); outStream.Position = 0; return(outStream); }