Exemplo n.º 1
0
        /// <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;
        }
Exemplo n.º 2
0
 public void MyTestInitialize()
 {
     var kernel = NinjectWebCommon.CreatePublicKernel();
     serviceTempFile = kernel.Get<ITempFileService>();
     serviceUser = kernel.Get<IUserService>();
     repoAuthCredential = kernel.Get<IAuthCredentialRepository>();
 }
Exemplo n.º 3
0
        // 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;
        }
Exemplo n.º 4
0
 public OutlookMailSender(IViewModelFactory vmf, ITempFileService tmpService)
 {
     if (vmf == null) throw new ArgumentNullException("vmf");
     if (tmpService == null) throw new ArgumentNullException("tmpService");
     _vmf = vmf;
     _tmpService = tmpService;
 }
Exemplo n.º 5
0
        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;
 }
Exemplo n.º 7
0
 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;
 }
Exemplo n.º 8
0
 /// <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;
 }
Exemplo n.º 9
0
        public DtoPrinter(IFileOpener fileOpener, ITempFileService tmpService)
        {
            if (fileOpener == null) throw new ArgumentNullException("fileOpener");
            if (tmpService == null) throw new ArgumentNullException("tmpService");

            _fileOpener = fileOpener;
            _tmpService = tmpService;
        }
Exemplo n.º 10
0
 public ImageSerializationService(ITempFileService tempFileService)
 {
     if (tempFileService == null)
     {
         throw new ArgumentNullException("tempFileService");
     }
     _tempFileService = tempFileService;
 }
Exemplo n.º 11
0
        public static string NewFile(ITempFileService tempFileService = null)
        {
            if (tempFileService == null)
            {
                tempFileService = new TempFileService();
            }

            return(tempFileService.NewFile());
        }
Exemplo n.º 12
0
 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();
 }
Exemplo n.º 13
0
 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;
 }
Exemplo n.º 14
0
 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)
 {
 }
Exemplo n.º 15
0
 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)
 {
 }
Exemplo n.º 17
0
 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)
 {
 }
Exemplo n.º 18
0
 public OutlookMailSender(IViewModelFactory vmf, ITempFileService tmpService)
 {
     if (vmf == null)
     {
         throw new ArgumentNullException("vmf");
     }
     if (tmpService == null)
     {
         throw new ArgumentNullException("tmpService");
     }
     _vmf        = vmf;
     _tmpService = tmpService;
 }
Exemplo n.º 19
0
        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;
        }
Exemplo n.º 20
0
        public DtoPrinter(IFileOpener fileOpener, ITempFileService tmpService)
        {
            if (fileOpener == null)
            {
                throw new ArgumentNullException("fileOpener");
            }
            if (tmpService == null)
            {
                throw new ArgumentNullException("tmpService");
            }

            _fileOpener = fileOpener;
            _tmpService = tmpService;
        }
Exemplo n.º 21
0
 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;
 }
Exemplo n.º 22
0
 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;
 }
Exemplo n.º 23
0
 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;
 }
Exemplo n.º 24
0
 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;
 }
Exemplo n.º 25
0
        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);
        }
Exemplo n.º 26
0
 public CheckRunController(ILogger <CheckRunController> logger, ITempFileService tempFileService, ICheckRunSubmissionService checkRunSubmissionService, ITelemetryService telemetryService)
     : base(logger, tempFileService)
 {
     _checkRunSubmissionService = checkRunSubmissionService;
     _telemetryService          = telemetryService;
 }
Exemplo n.º 27
0
        /// <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);
        }
Exemplo n.º 28
0
 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>();
 }
Exemplo n.º 29
0
 public PostgreSqlResetter(ZetboxConfig config, ISchemaProvider schemaManager, ITempFileService tmpService)
 {
     this.config = config;
     this.schemaManager = schemaManager;
     this.tmpService = tmpService;
 }
Exemplo n.º 30
0
 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>();
 }
Exemplo n.º 31
0
 public DtoTabbedViewModel(IViewModelDependencies dependencies, IZetboxContext dataCtx, ViewModel parent, IFileOpener fileOpener, ITempFileService tmpService, object debugInfo)
     : base(dependencies, dataCtx, parent, fileOpener, tmpService, debugInfo)
 {
 }
Exemplo n.º 32
0
 /// <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)
 {
 }
Exemplo n.º 34
0
 /// <summary>
 /// Creates a new reporting host
 /// </summary>
 public AbstractReportingHost(IFileOpener fileOpener, ITempFileService tempFileService, IReportingErrorReporter errorReporter)
     : this(null, null, fileOpener, tempFileService, errorReporter)
 {
 }
Exemplo n.º 35
0
        /// <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);
        }
Exemplo n.º 36
0
 public ReportScreenViewModel(IViewModelDependencies appCtx, 
     IZetboxContext dataCtx, ViewModel parent, NavigationScreen screen, IFileOpener fileOpener, ITempFileService tmpService)
     : base(appCtx, dataCtx, parent, screen, fileOpener, tmpService)
 {
 }
Exemplo n.º 37
0
        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);
        }
Exemplo n.º 38
0
 /// <summary>
 /// Creates a new reporting host
 /// </summary>
 public ReportingHost(IFileOpener fileOpener, ITempFileService tempFileService, IReportingErrorReporter errorReporter)
     : base(null, null, fileOpener, tempFileService, errorReporter)
 {
 }
Exemplo n.º 39
0
        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()));
            }
        }
Exemplo n.º 40
0
 /// <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;
 }
Exemplo n.º 42
0
        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));
            }
        }
Exemplo n.º 43
0
 /// <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)
 {
 }
Exemplo n.º 44
0
        /// <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);
        }
Exemplo n.º 45
0
 public ReportScreenViewModel(IViewModelDependencies appCtx,
                              IZetboxContext dataCtx, ViewModel parent, NavigationScreen screen, IFileOpener fileOpener, ITempFileService tmpService)
     : base(appCtx, dataCtx, parent, screen, fileOpener, tmpService)
 {
 }
Exemplo n.º 46
0
 // 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));
 }
Exemplo n.º 47
0
 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;
 }
Exemplo n.º 48
0
        /// <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);
        }
Exemplo n.º 49
0
        //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)
 {
 }
Exemplo n.º 52
0
 public DtoTabbedViewModel(IViewModelDependencies dependencies, IZetboxContext dataCtx, ViewModel parent, IFileOpener fileOpener, ITempFileService tmpService, object debugInfo)
     : base(dependencies, dataCtx, parent, fileOpener, tmpService, debugInfo)
 {
 }