예제 #1
0
        public async Task GetBladeHealthReport(Guid nodeId, NodeType nodeType, Guid taskId)
        {
            if (nodeType != NodeType.Site && nodeType != NodeType.Turbine && nodeType != NodeType.Blade)
            {
                throw new NotSupportedException($@"Node type {nodeType} is not supported for report generation.");
            }

            if (nodeType == NodeType.Blade)
            {
                var blade = _bladeService.GetBlade(nodeId);
                if (blade != null)
                {
                    nodeId   = blade.TurbineId;
                    nodeType = NodeType.Turbine;
                }
                else
                {
                    throw new Exception($@"There is no report for the selected tree nodeId: {nodeId} and nodeType: {nodeType}!");
                }
            }

            var defects = _defectService.GetDefectsForNodeLastInspection(nodeId, nodeType);

            if (!defects.Any())
            {
                throw new Exception($@"There is no report for the selected tree nodeId: {nodeId} and nodeType: {nodeType}!");
            }

            string bladeMapImagePath = HttpContext.Current.Server.MapPath("~/App_Data/blade_outline.png");
            string reportTemplate    = HttpContext.Current.Server.MapPath("~/App_Data/SiemensBladeHealthReport.docx");

            await _reportGeneratorManagerService.GenerateBladeHealthReport(
                defects.ToList(),
                bladeMapImagePath,
                reportTemplate,
                taskId,
                nodeType,
                nodeId);
        }