/// <summary> /// Creates a new reporting host /// </summary> /// <param name="overrideTemplateNamespace">null or empty, if default templates should be used, else a assembly with templates.</param> /// <param name="overrideTemplateAssembly">null, if default templates should be used, else a assembly with templates.</param> /// <param name="fileOpener"></param> /// <param name="tempFileService"></param> /// <param name="errorReporter"></param> public AbstractReportingHost(string overrideTemplateNamespace, Assembly overrideTemplateAssembly, IFileOpener fileOpener, ITempFileService tempFileService, IReportingErrorReporter errorReporter) { if (fileOpener == null) throw new ArgumentNullException("fileOpener"); if (tempFileService == null) throw new ArgumentNullException("tempFileService"); if (errorReporter == null) throw new ArgumentNullException("errorReporter"); _fileOpener = fileOpener; _tempFileService = tempFileService; _errorReporter = errorReporter; var settings = new NameValueCollection(); settings["overrideReportTemplateNamespace"] = overrideTemplateNamespace; settings["overrideReportTemplateAssembly"] = overrideTemplateAssembly != null ? overrideTemplateAssembly.FullName : null; // use this.GetType() to prepare a change: // This class is abstract. Anyone who provides report templates should derive from this class (empty implementation). // This will distinguish between different reports. settings["baseReportTemplateNamespace"] = this.GetType().Namespace; settings["baseReportTemplateAssembly"] = this.GetType().Assembly.FullName; // Default Inititalization Initialize(settings); ErrorsAreFatal = false; }
public void MyTestInitialize() { var kernel = NinjectWebCommon.CreatePublicKernel(); serviceTempFile = kernel.Get<ITempFileService>(); serviceUser = kernel.Get<IUserService>(); repoAuthCredential = kernel.Get<IAuthCredentialRepository>(); }
// TODO: Move that class into a common reporting assembly and create a own derived class with configuration /// <summary> /// Creates a new reporting host /// </summary> /// <param name="overrideTemplateNamespace">null or empty, if default templates should be used, else a assembly with templates.</param> /// <param name="overrideTemplateAssembly">null, if default templates should be used, else a assembly with templates.</param> /// <param name="fileOpener"></param> /// <param name="tmpService"></param> public AbstractReportingHost(string overrideTemplateNamespace, Assembly overrideTemplateAssembly, IFileOpener fileOpener, ITempFileService tmpService) { if (fileOpener == null) { throw new ArgumentNullException("fileOpener"); } if (tmpService == null) { throw new ArgumentNullException("tmpService"); } _fileOpener = fileOpener; _tmpService = tmpService; var settings = new NameValueCollection(); settings["overrideReportTemplateNamespace"] = overrideTemplateNamespace; settings["overrideReportTemplateAssembly"] = overrideTemplateAssembly != null ? overrideTemplateAssembly.FullName : null; // use this.GetType() to prepare a change: // This class should be abstract. Anyone who provides report templates should derive from this class (empty implementation). // This will distinguish between different reports. settings["baseReportTemplateNamespace"] = this.GetType().Namespace; settings["baseReportTemplateAssembly"] = this.GetType().Assembly.FullName; // Default Inititalization Initialize(settings); ErrorsAreFatal = false; }
public OutlookMailSender(IViewModelFactory vmf, ITempFileService tmpService) { if (vmf == null) throw new ArgumentNullException("vmf"); if (tmpService == null) throw new ArgumentNullException("tmpService"); _vmf = vmf; _tmpService = tmpService; }
public void MyTestInitialize() { var kernel = NinjectWebCommon.CreatePublicKernel(); serviceTempFile = kernel.Get <ITempFileService>(); serviceUser = kernel.Get <IUserService>(); repoAuthCredential = kernel.Get <IAuthCredentialRepository>(); }
public NavigationReportScreenViewModel(IViewModelDependencies appCtx, IZetboxContext dataCtx, ViewModel parent, NavigationScreen screen, IFileOpener fileOpener, ITempFileService tmpService) : base(appCtx, dataCtx, parent, screen) { _appCtx = appCtx; _fileOpener = fileOpener; _tmpService = tmpService; }
/// <summary> /// Initializes a new instance of the <see cref="PdfExportService"/> class. /// </summary> public PdfExportService(ITempFileService fileService) { if (fileService == null) { throw new ArgumentNullException("fileService"); } _fileService = fileService; }
public DtoPrinter(IFileOpener fileOpener, ITempFileService tmpService) { if (fileOpener == null) throw new ArgumentNullException("fileOpener"); if (tmpService == null) throw new ArgumentNullException("tmpService"); _fileOpener = fileOpener; _tmpService = tmpService; }
public ImageSerializationService(ITempFileService tempFileService) { if (tempFileService == null) { throw new ArgumentNullException("tempFileService"); } _tempFileService = tempFileService; }
public static string NewFile(ITempFileService tempFileService = null) { if (tempFileService == null) { tempFileService = new TempFileService(); } return(tempFileService.NewFile()); }
public AttachmentModel(MimeEntity mimeEntity, ITempFileService iTempFileService = null, IGetMd5HashService iGetMd5HashService = null) { tempFileService = iTempFileService ?? new TempFileService(); getMd5HashService = iGetMd5HashService ?? new GetMd5HashService(); this.mimeEntity = mimeEntity; Name = GetAttachmentName(); Size = GetAttachmentSize(); Type = GetAttachmentMediaTypeName(); }
public DtoCellViewModel(IViewModelDependencies dependencies, IZetboxContext dataCtx, DtoTableViewModel parent, IFileOpener fileOpener, ITempFileService tmpService, DtoRowViewModel row, DtoColumnViewModel column, GuiGridLocationAttribute location, ViewModel value, object debugInfo) : base(dependencies, dataCtx, parent, fileOpener, tmpService, debugInfo) { this.Parent = parent; this.Row = row; this.Column = column; this._location = location; this._value = value; }
public TreeItemInstanceListViewModel( IViewModelDependencies appCtx, ZetboxConfig config, IFileOpener fileOpener, ITempFileService tmpService, IZetboxContext dataCtx, ViewModel parent, Func <IZetboxContext> workingCtxFactory, ObjectClass type, Func <IQueryable> qry) : base(appCtx, config, fileOpener, tmpService, dataCtx, parent, workingCtxFactory, type, qry) { }
public DtoBaseViewModel(IViewModelDependencies dependencies, IZetboxContext dataCtx, ViewModel parent, IFileOpener fileOpener, ITempFileService tmpService, object debugInfo) : base(dependencies, dataCtx, parent) { var dtoParent = parent as DtoBaseViewModel; if (dtoParent != null) { _background = dtoParent.Background; } _fileOpener = fileOpener; _tmpService = tmpService; this._debugInfo = debugInfo; }
public TreeItemInstanceListViewModel( IViewModelDependencies appCtx, ZetboxConfig config, IFileOpener fileOpener, ITempFileService tmpService, IZetboxContext dataCtx, ViewModel parent, Func<IZetboxContext> workingCtxFactory, ObjectClass type, Func<IQueryable> qry) : base(appCtx, config, fileOpener, tmpService, dataCtx, parent, workingCtxFactory, type, qry) { }
public TreeItemInstanceListViewModel( IViewModelDependencies appCtx, ZetboxConfig config, IFileOpener fileOpener, ITempFileService tmpService, Lazy<IUIExceptionReporter> errorReporter, IZetboxContext dataCtx, ViewModel parent, ObjectClass type, Func<IQueryable> qry) : base(appCtx, config, fileOpener, tmpService, errorReporter, dataCtx, parent, type, qry) { }
public OutlookMailSender(IViewModelFactory vmf, ITempFileService tmpService) { if (vmf == null) { throw new ArgumentNullException("vmf"); } if (tmpService == null) { throw new ArgumentNullException("tmpService"); } _vmf = vmf; _tmpService = tmpService; }
public DtoPrinter(IFileOpener fileOpener, ITempFileService tmpService) { if (fileOpener == null) { throw new ArgumentNullException("fileOpener"); } if (tmpService == null) { throw new ArgumentNullException("tmpService"); } _fileOpener = fileOpener; _tmpService = tmpService; }
public ScheduledTaskService(Cache _cache , ITempFileService tempService , ILogService logService , IActivityService activityService , IUserService userService , IProjectService projectService ) { this.serviceTempFile = tempService; this.serviceLog = logService; this.serviceActivity = activityService; this.serviceProject = projectService; this.serviceUser = userService; this.serviceActivity.ServiceProject = projectService; cache = _cache; }
public FileController(IFileService _fileService , IUserService userService , IProjectService projectService , ITempFileService tempFileService , IDropBoxService dropboxService , IThumbnailService thumbnailService , ILogService logService , ISecurityService securityService ) : base(userService, logService) { serviceFile = _fileService; serviceProject = projectService; serviceTempFile = tempFileService; serviceDropBox = dropboxService; serviceThumbnail = thumbnailService; serviceSecurity = securityService; }
private static bool SaveToTempDatasource(ITempFileService tempFileService, IDatasource ds) { // We can't the resulting shapefile directly, because it was created by background thread // therefore is located in another apartment. This will cause creation of proxies and marshalling // for COM, which in turn no always supported by implementation of particular classes in MapWinGIS. // Therefore the best option we have is to save into temp file, open it, read into memory, delete the source. string filename = tempFileService.GetTempFilename(".shp"); bool saved = SaveDatasource(ds, filename); ds.Dispose(); if (!saved) { Logger.Current.Warn("Failed to save datasource to temp file."); return(false); } return(true); }
public CheckRunController(ILogger <CheckRunController> logger, ITempFileService tempFileService, ICheckRunSubmissionService checkRunSubmissionService, ITelemetryService telemetryService) : base(logger, tempFileService) { _checkRunSubmissionService = checkRunSubmissionService; _telemetryService = telemetryService; }
/// <summary> /// Creates a descriptive grouping of the specified object /// </summary> public static DtoGroupedViewModel BuildGroupFrom(object root, PropertyInfo parentProp, object dto, IViewModelDependencies dependencies, IZetboxContext dataCtx, ViewModel parent, IFileOpener fileOpener, ITempFileService tmpService) { if (dto == null) { // cannot inspect runtime type on null reference return(null); } var debugInfo = parentProp == null ? string.Format("topgroup:{0}", dto.GetType()) : string.Format("group:{0}.{1} = {2}", parentProp.DeclaringType, parentProp.Name, dto.GetType()); var result = new DtoGroupedViewModel(dependencies, dataCtx, parent, fileOpener, tmpService, debugInfo) { Title = ExtractTitle(parentProp, dto), Description = ExtractDescription(parentProp, dto), Background = ExtractBackground(parentProp, dto), Formatting = ExtractFormatting(parentProp, dto), IsPrintableRoot = ExtractIsPrintableRoot(parentProp, dto), Root = root, Data = dto, }; var dataProps = new List <PropertyInfo>(); var percentProps = new Dictionary <string, PropertyInfo>(); ExtractProps(dto.GetType(), dataProps, percentProps); foreach (var prop in dataProps) { var value = dto.GetPropertyValue <object>(prop.Name); var viewModel = BuildFrom(root, prop, value, dependencies, dataCtx, parent, fileOpener, tmpService); if (viewModel == null) { continue; // do not add without content } var valueModel = viewModel as DtoValueViewModel; if (valueModel != null && percentProps.ContainsKey(prop.Name)) { valueModel.AlternateRepresentation = string.Format("{0:0.00} %", 100 * Convert.ToDouble(dto.GetPropertyValue <object>(percentProps[prop.Name].Name))); valueModel.AlternateRepresentationAlignment = ContentAlignment.MiddleRight; } result.Items.Add(viewModel); } return(result); }
public DtoTableViewModel(IViewModelDependencies dependencies, IZetboxContext dataCtx, ViewModel parent, IFileOpener fileOpener, ITempFileService tmpService, object debugInfo) : base(dependencies, dataCtx, parent, fileOpener, tmpService, debugInfo) { Rows = new ObservableCollection<DtoRowViewModel>(); Columns = new ObservableCollection<DtoColumnViewModel>(); Cells = new ObservableCollection<DtoCellViewModel>(); }
public PostgreSqlResetter(ZetboxConfig config, ISchemaProvider schemaManager, ITempFileService tmpService) { this.config = config; this.schemaManager = schemaManager; this.tmpService = tmpService; }
public DtoGroupedViewModel(IViewModelDependencies dependencies, IZetboxContext dataCtx, ViewModel parent, IFileOpener fileOpener, ITempFileService tmpService, object debugInfo) : base(dependencies, dataCtx, parent, fileOpener, tmpService, debugInfo) { Items = new ObservableCollection<DtoBaseViewModel>(); }
public DtoTabbedViewModel(IViewModelDependencies dependencies, IZetboxContext dataCtx, ViewModel parent, IFileOpener fileOpener, ITempFileService tmpService, object debugInfo) : base(dependencies, dataCtx, parent, fileOpener, tmpService, debugInfo) { }
/// <summary> /// Creates a new reporting host /// </summary> /// <param name="fileOpener"></param> /// <param name="tmpService"></param> public ReportingHost(IFileOpener fileOpener, ITempFileService tmpService) : base(null, null, fileOpener, tmpService) { }
public CheckRunControllerStub(ILogger <CheckRunController> logger, ITempFileService tempFileService, Web.Interfaces.ICheckRunSubmissionService checkRunSubmissionService, ITelemetryService telemetryService) : base(logger, tempFileService, checkRunSubmissionService, telemetryService) { }
/// <summary> /// Creates a new reporting host /// </summary> public AbstractReportingHost(IFileOpener fileOpener, ITempFileService tempFileService, IReportingErrorReporter errorReporter) : this(null, null, fileOpener, tempFileService, errorReporter) { }
/// <summary> /// Build a tabbed interface from the specified object. Page oriented output might create new pages for each tab or similar. /// </summary> public static DtoTabbedViewModel BuildTabbedFrom(object root, PropertyInfo parentProp, object dto, IViewModelDependencies dependencies, IZetboxContext dataCtx, ViewModel parent, IFileOpener fileOpener, ITempFileService tmpService) { if (dto == null) { return(null); } var debugInfo = parentProp == null ? string.Format("topTabbed:{0}", dto.GetType()) : string.Format("tabbed:{0}.{1} = {2}", parentProp.DeclaringType, parentProp.Name, dto.GetType()); var result = new DtoTabbedViewModel(dependencies, dataCtx, parent, fileOpener, tmpService, debugInfo) { Title = ExtractTitle(parentProp, dto), Description = ExtractDescription(parentProp, dto), Background = ExtractBackground(parentProp, dto), Formatting = ExtractFormatting(parentProp, dto), IsPrintableRoot = ExtractIsPrintableRoot(parentProp, dto), Root = root, Data = dto, }; // need to extract value from XmlDictionaries var dtoData = dto as IXmlDictionaryDtoData; if (dtoData != null) { foreach (var kvp in dtoData.DtoData.OrderBy(e => e.Key)) { var item = BuildFrom(root, parentProp, kvp.Value, dependencies, dataCtx, result, fileOpener, tmpService); if (item != null) { result.Items.Add(item); } } } else if (typeof(IEnumerable).IsAssignableFrom(dto.GetType())) { foreach (var element in ((IEnumerable)dto)) { var item = BuildFrom(root, parentProp, element, dependencies, dataCtx, result, fileOpener, tmpService); if (item != null) { result.Items.Add(item); } } } else { var dataProps = new List <PropertyInfo>(); var percentProps = new Dictionary <string, PropertyInfo>(); ExtractProps(dto.GetType(), dataProps, percentProps); if (percentProps.Count != 0) { // TODO: fail: cannot display in grid? } foreach (var prop in dataProps) { var val = dto.GetPropertyValue <object>(prop.Name); var item = BuildFrom(root, prop, val, dependencies, dataCtx, result, fileOpener, tmpService); if (item != null) { result.Items.Add(item); } } } return(result); }
public ReportScreenViewModel(IViewModelDependencies appCtx, IZetboxContext dataCtx, ViewModel parent, NavigationScreen screen, IFileOpener fileOpener, ITempFileService tmpService) : base(appCtx, dataCtx, parent, screen, fileOpener, tmpService) { }
private static DtoBaseViewModel FormatValue(object root, PropertyInfo parentProp, object dto, IViewModelDependencies dependencies, IZetboxContext dataCtx, ViewModel parent, IFileOpener fileOpener, ITempFileService tmpService) { if (dto == null) { throw new ArgumentNullException("dto"); } if (parentProp == null) { throw new ArgumentNullException("parentProp"); } DtoBaseViewModel valueModel = null; var propertyType = dto.GetType(); var title = ExtractTitle(parentProp, dto); var description = ExtractDescription(parentProp, dto); var background = ExtractBackground(parentProp, dto); var asPercent = parentProp.GetCustomAttributes(typeof(GuiFormatAsPercentAttribute), true).Length > 0; var formatString = parentProp.GetCustomAttributes(typeof(GuiFormatStringAttribute), true).OfType <GuiFormatStringAttribute>().Select(gfsa => gfsa.FormatString).SingleOrDefault(); if (typeof(long).IsAssignableFrom(propertyType) || typeof(int).IsAssignableFrom(propertyType) || typeof(short).IsAssignableFrom(propertyType)) { valueModel = new DtoValueViewModel(dependencies, dataCtx, parent, fileOpener, tmpService, string.Format("value:{0}.{1} = {2}", parentProp.DeclaringType, parentProp.Name, dto)) { Value = asPercent ? string.Format("{0} %", 100 * Convert.ToInt64(dto)) : string.Format(formatString ?? "{0}", dto), ValueAlignment = ContentAlignment.MiddleRight, Title = title, Description = description, Formatting = ExtractFormatting(parentProp, dto), IsPrintableRoot = ExtractIsPrintableRoot(parentProp, dto), Root = root, Data = dto, }; if (!string.IsNullOrEmpty(background)) { valueModel.Background = background; } } else if (typeof(double).IsAssignableFrom(propertyType) || typeof(decimal).IsAssignableFrom(propertyType) || typeof(float).IsAssignableFrom(propertyType)) { valueModel = new DtoValueViewModel(dependencies, dataCtx, parent, fileOpener, tmpService, string.Format("value:{0}.{1} = {2}", parentProp.DeclaringType, parentProp.Name, dto)) { Value = asPercent ? string.Format("{0:0.00} %", 100 * Convert.ToDouble(dto)) : string.Format(formatString ?? "{0:0.00}", dto), ValueAlignment = ContentAlignment.MiddleRight, Title = title, Description = description, Formatting = ExtractFormatting(parentProp, dto), IsPrintableRoot = ExtractIsPrintableRoot(parentProp, dto), Root = root, Data = dto, }; if (!string.IsNullOrEmpty(background)) { valueModel.Background = background; } } else if (typeof(string).IsAssignableFrom(propertyType)) { valueModel = new DtoValueViewModel(dependencies, dataCtx, parent, fileOpener, tmpService, string.Format("value:{0}.{1} = {2}", parentProp.DeclaringType, parentProp.Name, dto)) { Value = (dto ?? string.Empty).ToString(), Title = title, Description = description, Formatting = ExtractFormatting(parentProp, dto), IsPrintableRoot = ExtractIsPrintableRoot(parentProp, dto), Root = root, Data = dto, }; if (!string.IsNullOrEmpty(background)) { valueModel.Background = background; } } else if (typeof(DateTime).IsAssignableFrom(propertyType)) { valueModel = new DtoValueViewModel(dependencies, dataCtx, parent, fileOpener, tmpService, string.Format("value:{0}.{1} = {2}", parentProp.DeclaringType, parentProp.Name, dto)) { Value = dto != null ? ((DateTime)dto).ToShortDateString() : string.Empty, Title = title, Description = description, Formatting = ExtractFormatting(parentProp, dto), IsPrintableRoot = ExtractIsPrintableRoot(parentProp, dto), Root = root, Data = dto, }; if (!string.IsNullOrEmpty(background)) { valueModel.Background = background; } } else { valueModel = BuildFrom(root, parentProp, dto, dependencies, dataCtx, parent, fileOpener, tmpService); } if (valueModel == null) { Logging.Client.WarnFormat("Unable to format a value from dto '{0}' of type '{1}' contained in property {2}", dto, dto.GetType().Name, string.Format("{0}.{1}", parentProp.DeclaringType.Name, parentProp.Name)); } return(valueModel); }
/// <summary> /// Creates a new reporting host /// </summary> public ReportingHost(IFileOpener fileOpener, ITempFileService tempFileService, IReportingErrorReporter errorReporter) : base(null, null, fileOpener, tempFileService, errorReporter) { }
private static DtoBaseViewModel BuildEmptyFrom(object root, PropertyInfo parentProp, object dto, IViewModelDependencies dependencies, IZetboxContext dataCtx, ViewModel parent, IFileOpener fileOpener, ITempFileService tmpService) { if (dto == null) { // cannot inspect runtime type on null reference return(null); } var isPrintableRoot = ExtractIsPrintableRoot(parentProp, dto); var dataProps = new List <PropertyInfo>(); var percentProps = new Dictionary <string, PropertyInfo>(); ExtractProps(dto.GetType(), dataProps, percentProps); var items = new List <DtoBaseViewModel>(); foreach (var prop in dataProps) { var value = dto.GetPropertyValue <object>(prop.Name); var viewModel = BuildFrom(root, prop, value, dependencies, dataCtx, parent, fileOpener, tmpService); if (viewModel == null) { continue; // do not add without content } var valueModel = viewModel as DtoValueViewModel; if (valueModel != null && percentProps.ContainsKey(prop.Name)) { valueModel.AlternateRepresentation = string.Format("{0:0.00} %", 100 * Convert.ToDouble(dto.GetPropertyValue <object>(percentProps[prop.Name].Name))); valueModel.AlternateRepresentationAlignment = ContentAlignment.MiddleRight; } items.Add(viewModel); } var result = parent as DtoGroupedViewModel; if (result != null) { items.ForEach(result.Items.Add); result.IsPrintableRoot = isPrintableRoot; return(result); } else if (items.Count == 1) { items[0].IsPrintableRoot = isPrintableRoot; return(items[0]); } else { throw new NotSupportedException(string.Format("Cannot GuiSkipViewModel on multi-property class [{0}], when having a non-grouped parent [{1}]", dto.GetType(), parent.GetType())); } }
/// <summary> /// Creates a new reporting host /// </summary> /// <param name="overrideTemplateNamespace">null or empty, if default templates should be used, else a assembly with templates.</param> /// <param name="overrideTemplateAssembly">null, if default templates should be used, else a assembly with templates.</param> /// <param name="fileOpener"></param> /// <param name="tmpService"></param> public ReportingHost(string overrideTemplateNamespace, System.Reflection.Assembly overrideTemplateAssembly, IFileOpener fileOpener, ITempFileService tmpService) : base(overrideTemplateNamespace, overrideTemplateAssembly, fileOpener, tmpService) { }
public LogController(ILogger <LogController> logger, ITempFileService tempFileService, ILogAnalyzerService logAnalyzerService) { _logger = logger; _tempFileService = tempFileService; _logAnalyzerService = logAnalyzerService; }
private static DtoBaseViewModel BuildFrom(object root, PropertyInfo parentProp, object dto, IViewModelDependencies dependencies, IZetboxContext dataCtx, ViewModel parent, IFileOpener fileOpener, ITempFileService tmpService) { if (dto == null) { return(null); } // avoid using the prop's attributes or type if the dto is not assignable to the property, e.g. when working on a list's elements if (parentProp != null && parentProp.PropertyType.IsAssignableFrom(dto.GetType())) { var propertyType = dto.GetType(); if (typeof(byte).IsAssignableFrom(propertyType) || typeof(int).IsAssignableFrom(propertyType) || typeof(uint).IsAssignableFrom(propertyType) || typeof(long).IsAssignableFrom(propertyType) || typeof(ulong).IsAssignableFrom(propertyType) || typeof(double).IsAssignableFrom(propertyType) || typeof(float).IsAssignableFrom(propertyType) || typeof(decimal).IsAssignableFrom(propertyType) || typeof(DateTime).IsAssignableFrom(propertyType) || typeof(byte?).IsAssignableFrom(propertyType) || typeof(int?).IsAssignableFrom(propertyType) || typeof(uint?).IsAssignableFrom(propertyType) || typeof(long?).IsAssignableFrom(propertyType) || typeof(ulong?).IsAssignableFrom(propertyType) || typeof(double?).IsAssignableFrom(propertyType) || typeof(float?).IsAssignableFrom(propertyType) || typeof(decimal?).IsAssignableFrom(propertyType) || typeof(DateTime?).IsAssignableFrom(propertyType) || typeof(string).IsAssignableFrom(propertyType)) { return(FormatValue(root, parentProp, dto, dependencies, dataCtx, parent, fileOpener, tmpService)); } else { var propAttrs = parentProp.GetCustomAttributes(false); foreach (var attr in propAttrs) { if (attr is GuiTabbedAttribute) { return(BuildTabbedFrom(root, parentProp, dto, dependencies, dataCtx, parent, fileOpener, tmpService)); } else if (attr is GuiGridAttribute) { return(BuildGridFrom(root, parentProp, dto, dependencies, dataCtx, parent, fileOpener, tmpService)); } else if (attr is GuiTableAttribute) { return(BuildTableFrom(root, parentProp, dto, dependencies, dataCtx, parent, fileOpener, tmpService)); } } } } var type = dto.GetType(); var skipAttr = type.GetCustomAttributes(typeof(GuiSkipViewModelAttribute), false); if (skipAttr.Length > 0) { return(BuildEmptyFrom(root, parentProp, dto, dependencies, dataCtx, parent, fileOpener, tmpService)); } var attrs = type.GetCustomAttributes(false); foreach (var attr in attrs) { if (attr is GuiTabbedAttribute) { return(BuildTabbedFrom(root, parentProp, dto, dependencies, dataCtx, parent, fileOpener, tmpService)); } else if (attr is GuiGridAttribute) { return(BuildGridFrom(root, parentProp, dto, dependencies, dataCtx, parent, fileOpener, tmpService)); } else if (attr is GuiTableAttribute) { return(BuildTableFrom(root, parentProp, dto, dependencies, dataCtx, parent, fileOpener, tmpService)); } } if (dto.GetType().HasGenericDefinition(typeof(XmlDictionary <,>))) { return(BuildTabbedFrom(root, parentProp, dto, dependencies, dataCtx, parent, fileOpener, tmpService)); } else if (typeof(IEnumerable).IsAssignableFrom(dto.GetType())) { return(BuildTableFrom(root, parentProp, dto, dependencies, dataCtx, parent, fileOpener, tmpService)); } else { return(BuildGroupFrom(root, parentProp, dto, dependencies, dataCtx, parent, fileOpener, tmpService)); } }
/// <summary> /// Arranges the contained Objects in a grid. Use GridLocation to specify where /// </summary> public static DtoTableViewModel BuildGridFrom(object root, PropertyInfo parentProp, object dto, IViewModelDependencies dependencies, IZetboxContext dataCtx, ViewModel parent, IFileOpener fileOpener, ITempFileService tmpService) { if (dto == null) { return(null); } var debugInfo = parentProp == null ? string.Format("topGrid:{0}", dto.GetType()) : string.Format("grid:{0}.{1} = {2}", parentProp.DeclaringType, parentProp.Name, dto.GetType()); var result = new DtoTableViewModel(dependencies, dataCtx, parent, fileOpener, tmpService, debugInfo) { IsDataTable = false, Title = ExtractTitle(parentProp, dto), Description = ExtractDescription(parentProp, dto), Background = ExtractBackground(parentProp, dto), Formatting = ExtractFormatting(parentProp, dto), IsPrintableRoot = ExtractIsPrintableRoot(parentProp, dto), Root = root, Data = dto, }; // TODO: add description var cells = new Dictionary <GuiGridLocationAttribute, ViewModel>(); if (typeof(IEnumerable).IsAssignableFrom(dto.GetType())) { var propertyMsg = parentProp == null ? string.Empty : string.Format(" contained in property {0}.{1}", parentProp.DeclaringType.Name, parentProp.Name); Logging.Client.WarnFormat("Unable to format a list from dto '{0}' of type '{1}'{2}", dto, dto.GetType().Name, propertyMsg); } else { var dataProps = new List <PropertyInfo>(); var percentProps = new Dictionary <string, PropertyInfo>(); ExtractProps(dto.GetType(), dataProps, percentProps); if (percentProps.Count != 0) { // TODO: fail: cannot display in grid? } foreach (var prop in dataProps) { var value = BuildFrom(root, prop, dto.GetPropertyValue <object>(prop.Name), dependencies, dataCtx, result, fileOpener, tmpService); if (value == null) { continue; // do not add without content } // struct initialises to (0,0) by default var gridLocation = prop.GetCustomAttributes(false) .OfType <GuiGridLocationAttribute>() .Single(); // TODO: avoid silent overwriting /* * TODO: might want to consider automatic appending? * That is, given a class with five properties that should be arranged * * A | B | C * D | E | - * * specify * * [GridRow(0)] * int A { get; set; } * int B { get; set; } * int C { get; set; } * [GridRow(1)] * int D { get; set; } * int E { get; set; } * * or even only [GridRowBreak] on D? */ cells[gridLocation] = value; } } var allRows = new Dictionary <int, DtoRowViewModel>(); for (int i = cells.Keys.Select(k => k.Row).Max(); i >= 0; i--) { allRows[i] = new DtoRowViewModel(dependencies, dataCtx, result, fileOpener, tmpService, i, string.Format("gridrow:{0}.[{1}]", dto.GetType(), i)); } var allColumns = new Dictionary <int, DtoColumnViewModel>(); for (int i = cells.Keys.Select(k => k.Column).Max(); i >= 0; i--) { allColumns[i] = new DtoColumnViewModel(dependencies, dataCtx, result, fileOpener, tmpService, i, string.Format("gridcolum:{0}.[][{1}]", dto.GetType(), i)); } foreach (var kvp in cells) { result.Cells.Add(new DtoCellViewModel(dependencies, dataCtx, result, fileOpener, tmpService, allRows[kvp.Key.Row], allColumns[kvp.Key.Column], kvp.Key, kvp.Value, string.Format("gridcell[{0}][{1}]", kvp.Key.Row, kvp.Key.Column))); } allRows.Values.ForEach(result.Rows.Add); allColumns.Values.ForEach(result.Columns.Add); return(result); }
// looks, sounds and smells like fetch? public static DtoBaseViewModel BuildFrom(object root, IViewModelDependencies dependencies, IZetboxContext dataCtx, ViewModel parent, IFileOpener fileOpener, ITempFileService tmpService) { return(BuildFrom(root, null, root, dependencies, dataCtx, parent, fileOpener, tmpService)); }
public DtoRowViewModel(IViewModelDependencies dependencies, IZetboxContext dataCtx, DtoTableViewModel parent, IFileOpener fileOpener, ITempFileService tmpService, int rowIdx, object debugInfo) : base(dependencies, dataCtx, parent, fileOpener, tmpService, debugInfo) { this.Parent = parent; this._row = rowIdx; }
/// <summary> /// Creates a table out of a list of DTOs /// </summary> public static DtoTableViewModel BuildTableFrom(object root, PropertyInfo parentProp, object dto, IViewModelDependencies dependencies, IZetboxContext dataCtx, ViewModel parent, IFileOpener fileOpener, ITempFileService tmpService) { if (dto == null) { return(null); } // skip XmlDictionary to its values if (dto.GetType().HasGenericDefinition(typeof(XmlDictionary <,>))) { dto = dto.GetPropertyValue <object>("Values"); } var debugInfo = parentProp == null ? string.Format("topTable: {0}", dto.GetType()) : string.Format("table:{0}.{1} = {2}", parentProp.DeclaringType, parentProp.Name, dto.GetType()); var result = new DtoTableViewModel(dependencies, dataCtx, parent, fileOpener, tmpService, debugInfo) { IsDataTable = true, Title = ExtractTitle(parentProp, dto), Description = ExtractDescription(parentProp, dto), Background = ExtractBackground(parentProp, dto), AlternateBackground = ExtractAlternateBackground(parentProp, dto), Formatting = ExtractFormatting(parentProp, dto), IsPrintableRoot = ExtractIsPrintableRoot(parentProp, dto), Root = root, Data = dto, }; var dataProps = new List <PropertyInfo>(); var percentProps = new Dictionary <string, PropertyInfo>(); ExtractProps(dto.GetType().FindElementTypes().SingleOrDefault(t => t != typeof(object)) ?? dto.GetType(), dataProps, percentProps); var allColumns = new Dictionary <PropertyInfo, DtoColumnViewModel>(); int columnIdx = 0; foreach (var prop in dataProps) { var column = new DtoColumnViewModel(dependencies, dataCtx, result, fileOpener, tmpService, columnIdx, string.Format("column:{0}.{1}", dto.GetType(), prop.Name)) { Title = ExtractTitle(prop, null), Description = ExtractDescription(prop, null), Background = ExtractBackground(prop, null) }; allColumns[prop] = column; columnIdx += 1; result.Columns.Add(column); } int rowIdx = 0; foreach (var line in (IEnumerable)dto) { var row = new DtoRowViewModel(dependencies, dataCtx, result, fileOpener, tmpService, rowIdx, string.Format("row:{0}[{1}]", dto.GetType(), rowIdx)); if (rowIdx % 2 == 0) { row.Background = result.AlternateBackground; } result.Rows.Add(row); columnIdx = -1; foreach (var prop in dataProps) { var propName = prop.Name; columnIdx += 1; var viewModel = BuildFrom(root, prop, line.GetPropertyValue <object>(propName), dependencies, dataCtx, row, fileOpener, tmpService); if (viewModel == null) { continue; // do not add cell without content } viewModel.Title = null; // do not display title in table var valueModel = viewModel as DtoValueViewModel; if (valueModel != null && percentProps.ContainsKey(propName)) { valueModel.AlternateRepresentation = string.Format("{0:0.00} %", 100 * Convert.ToDouble(dto.GetPropertyValue <object>(percentProps[propName].Name))); valueModel.AlternateRepresentationAlignment = ContentAlignment.MiddleRight; } var cellDebugInfo = parentProp == null ? string.Format("topCell:[{0}].{1}", rowIdx, propName) : string.Format("cell:{0}.{1}[{2}].{3}", parentProp.DeclaringType, parentProp.Name, rowIdx, propName); var cell = new DtoCellViewModel(dependencies, dataCtx, result, fileOpener, tmpService, row, allColumns[prop], new GuiGridLocationAttribute(rowIdx, columnIdx), viewModel, cellDebugInfo); result.Cells.Add(cell); } rowIdx += 1; } return(result); }
//private List<string> _tempDirs = new List<string>(); /// <summary> /// Creates a new reporting host /// </summary> /// <param name="fileOpener"></param> /// <param name="tmpService"></param> public AbstractReportingHost(IFileOpener fileOpener, ITempFileService tmpService) : this(null, null, fileOpener, tmpService) { }
protected MultiPartFormControllerBase(ILogger <TController> logger, ITempFileService tempFileService) { TempFileService = tempFileService; Logger = logger; }
public LogControllerStub(ILogger <LogController> logger, ITempFileService tempFileService, ILogAnalyzerService logAnalyzerService) : base(logger, tempFileService, logAnalyzerService) { }