public void Execute()
        {
            try
            {
                viewModel.Data = repo.GetPipelineElements(
                    viewModel.PipeNumber,
                    viewModel.CheckedPipeTypes.Select <PipeMillSizeType, string>(x => x.Type).ToArray <string>());

                if (viewModel.Data == null || viewModel.Data.Rows.Count <= 0)
                {
                    log.Warn(string.Format("Data Table for Pipe Report (pipe #{0}) report is NULL or empty", viewModel.PipeNumber));
                }

                var report = new PipeConstructionXtraReport();

                report.DataSource        = viewModel.PipeReportDataList;
                report.FootersVisibility = viewModel.IsFooterVisible;
                report.CreateDocument();
                viewModel.PreviewSource = report;

                RefreshVisualStateEvent();
            }
            catch (RepositoryException ex)
            {
                log.Warn(this.GetType().Name + " | " + ex.ToString());
                notify.ShowWarning(Program.LanguageManager.GetString(StringResources.Notification_Error_Db_Message),
                                   Program.LanguageManager.GetString(StringResources.Notification_Error_Db_Header));
            }
        }
        public ConstructionReportViewModel(
            IMillReportsRepository repo,
            IJointRepository repoJoint,
            IUserNotify notify)
        {
            this.repo   = repo;
            this.notify = notify;

            this.data = repo.GetPipelineElements(SQLProvider.GetQuery(SQLProvider.SQLStatic.GetWeldedParts).ToString());
            if (this.data == null || this.data.Rows.Count <= 0)
            {
                log.Warn("Report at Construction: Data Table of Pieces is NULL or empty.");
            }

            this.partDataList = FormWeldedParts(data);

            this.Joints = repoJoint.GetAll()
                          .Where <construct.Joint>(x => x.FirstElement != null && x.SecondElement != null)
                          .ToList <construct.Joint>();
            if (this.Joints == null || this.Joints.Count <= 0)
            {
                log.Warn("Report at Construction: List of Joints is NULL or empty.");
            }


            createCommand = ViewModelSource
                            .Create <CreateReportCommand>(() => new CreateReportCommand(this, repo, notify));

            previewCommand = ViewModelSource
                             .Create <PreviewReportCommand>(() => new PreviewReportCommand(this, repo, notify));

            reportCommand = ViewModelSource
                            .Create <ReportCommand>(() => new ReportCommand(this, repo, notify));
        }
Beispiel #3
0
        public void Execute()
        {
            viewModel.Data = repo.GetPipelineElements(viewModel.WeldDateFrom, viewModel.WeldDateTo);
            if (viewModel.Data == null || viewModel.Data.Rows.Count <= 0)
            {
                log.Warn("Construction report: Data Table for Weld by Date report is NULL or empty");
            }

            var report = new WeldDateXtraReport();

            report.DataSource = viewModel.WeldDateReportDataList;
            report.CreateDocument();
            viewModel.PreviewSource = report;

            RefreshVisualStateEvent();
        }
Beispiel #4
0
        public void Execute()
        {
            viewModel.Data = repo.GetPipelineElements(viewModel.WeldDateFrom, viewModel.WeldDateTo);
            if (viewModel.Data == null || viewModel.Data.Rows.Count <= 0)
            {
                log.Warn("Construction report: Data Table for Weld by Date report is NULL or empty");
            }

            var report = new WeldDateXtraReport();

            report.DataSource = viewModel.WeldDateReportDataList;
            var tool = new ReportPrintTool(report);

            tool.AutoShowParametersPanel = false;
            tool.ShowPreview();

            RefreshVisualStateEvent();
        }
Beispiel #5
0
        public void Execute()
        {
            viewModel.Data = repo.GetPipelineElements(
                viewModel.PipeNumber,
                viewModel.CheckedPipeTypes.Select <PipeMillSizeType, string>(x => x.Type).ToArray <string>());

            if (viewModel.Data == null || viewModel.Data.Rows.Count <= 0)
            {
                log.Warn(string.Format("Data Table for Pipe Report (pipe #{0}) report is NULL or empty", viewModel.PipeNumber));
            }

            var report = new PipeConstructionXtraReport();

            report.DataSource = viewModel.PipeReportDataList;
            report.CreateDocument();
            viewModel.PreviewSource = report;

            RefreshVisualStateEvent();
        }
Beispiel #6
0
        public void Execute()
        {
            viewModel.Data = repo.GetPipelineElements(
                viewModel.PipeNumber,
                viewModel.CheckedPipeTypes.Select <PipeMillSizeType, string>(x => x.Type).ToArray <string>());

            if (viewModel.Data == null || viewModel.Data.Rows.Count <= 0)
            {
                log.Warn(string.Format("Data Table for Pipe Report (pipe #{0}) report is NULL or empty", viewModel.PipeNumber));
            }

            var report = new PipeConstructionXtraReport();

            report.DataSource = viewModel.PipeReportDataList;
            var tool = new ReportPrintTool(report);

            tool.AutoShowParametersPanel = false;
            tool.ShowPreview();

            RefreshVisualStateEvent();
        }
        public void Execute()
        {
            try
            {
                if (Prizm.Main.Common.DateExtension.CheckDiapason(viewModel.WeldDateFrom, viewModel.WeldDateTo))
                {
                    viewModel.Data = repo.GetPipelineElements(viewModel.WeldDateFrom, viewModel.WeldDateTo);
                    if (viewModel.Data == null || viewModel.Data.Rows.Count <= 0)
                    {
                        log.Warn("Construction report: Data Table for Weld by Date report is NULL or empty");
                    }

                    var report = new WeldDateXtraReport();

                    report.DataSource        = viewModel.WeldDateReportDataList;
                    report.FootersVisibility = viewModel.IsFooterVisible;
                    var tool = new ReportPrintTool(report);
                    tool.AutoShowParametersPanel = false;
                    tool.ShowPreview();

                    RefreshVisualStateEvent();
                }
                else
                {
                    notify.ShowInfo(Program.LanguageManager.GetString(StringResources.Message_FailureReportDate),
                                    Program.LanguageManager.GetString(StringResources.Message_FailureReportDateHeader));
                    log.Warn("Date limits not valid!" + "Diapason: start date= "
                             + viewModel.WeldDateFrom.ToString() + " end date= " + viewModel.WeldDateTo.ToString());
                }
            }
            catch (RepositoryException ex)
            {
                log.Warn(this.GetType().Name + " | " + ex.ToString());
                notify.ShowWarning(Program.LanguageManager.GetString(StringResources.Notification_Error_Db_Message),
                                   Program.LanguageManager.GetString(StringResources.Notification_Error_Db_Header));
            }
        }
Beispiel #8
0
        private void PipelineTracing()
        {
            try
            {
                usedProductList = new List <PartData>();
                if (joints == null)
                {
                    this.joints = repoJoint.GetJointsForTracing().ToList <construct.Joint>();
                    if (this.joints == null || this.joints.Count <= 0)
                    {
                        log.Warn("Report at Construction: List of Joints is NULL or empty.");
                    }
                }
                if (partDataList == null)
                {
                    var data = repo.GetPipelineElements(SQLProvider.GetQuery(SQLProvider.SQLStatic.GetWeldedParts).ToString());
                    if (data == null || data.Rows.Count <= 0)
                    {
                        log.Warn("Report at Construction: Data Table of Pieces is NULL or empty.");
                    }

                    this.partDataList = this.FormWeldedParts(data);
                }

                graph           = new PipelineGraph(partDataList.Count);
                tracingDataList = new List <TracingData>();

                if (partDataList != null)
                {
                    foreach (var partData in partDataList)
                    {
                        graph.AddPipelineVertex(partData);
                    }
                    foreach (var joint in this.joints)
                    {
                        graph.AddJointEdge(joint);
                    }

                    construct.Joint startJoint = null;
                    construct.Joint endJoint   = null;

                    if (viewModel.TracingMode == TracingModeEnum.TracingByKP &&
                        viewModel.AllKP.Contains(viewModel.StartPK) &&
                        viewModel.AllKP.Contains(viewModel.EndPK))
                    {
                        startJoint = joints.First <construct.Joint>(
                            x => x.NumberKP == viewModel.StartPK && x.DistanceFromKP == joints
                            .Where <construct.Joint>(y => y.NumberKP == viewModel.StartPK)
                            .Min <construct.Joint>(z => z.DistanceFromKP));

                        endJoint = joints.Last <construct.Joint>(
                            x => x.NumberKP == viewModel.EndPK && x.DistanceFromKP == joints
                            .Where <construct.Joint>(y => y.NumberKP == viewModel.EndPK)
                            .Max <construct.Joint>(z => z.DistanceFromKP));
                    }

                    if (endJoint == null && startJoint == null)
                    {
                        startJoint = joints.First <construct.Joint>(x => x.Id == viewModel.StartJoint.Id);
                        endJoint   = joints.First <construct.Joint>(x => x.Id == viewModel.EndJoint.Id);
                    }

                    var paths = graph.Pathfinder(startJoint.FirstElement, endJoint.FirstElement);

                    if (paths.Count != 0)
                    {
                        path = graph.ShortestPath(paths);

                        path = graph.RemovalExternalComponents(startJoint, endJoint, path);

                        for (int i = path.Count - 1; i > 0; --i)
                        {
                            var tracingDataItem = new TracingData(path[i].Data, path[i - 1].Data);

                            var commonJoint = path[i].GetCommonJoint(path[i - 1]);

                            tracingDataItem.JointNumber = commonJoint.Data.Number;
                            tracingDataItem.WeldingDate = GetWeldDate(commonJoint.Data);

                            tracingDataList.Add(tracingDataItem);
                        }

                        for (int i = 0; i < path.Count; ++i)
                        {
                            usedProductList.Add(path[i].Data);
                        }

                        PartData firstElement = partDataList.Where(_ => _.Id == startJoint.FirstElement.Id).FirstOrDefault();

                        PartData secondElement = partDataList.Where(_ => _.Id == endJoint.SecondElement.Id).FirstOrDefault();

                        var firstTracingDataItem = new TracingData(firstElement, path.Last().Data);
                        firstTracingDataItem.JointNumber = startJoint.Number;
                        firstTracingDataItem.WeldingDate = GetWeldDate(startJoint);
                        tracingDataList.Insert(0, firstTracingDataItem);

                        usedProductList.Add(firstElement);

                        var lastTracingDataItem = new TracingData(path.First().Data, secondElement);
                        lastTracingDataItem.JointNumber = endJoint.Number;
                        lastTracingDataItem.WeldingDate = GetWeldDate(endJoint);
                        tracingDataList.Add(lastTracingDataItem);

                        usedProductList.Add(secondElement);

                        PipelineLenghtCalculation();
                    }
                }
                else
                {
                    log.Warn(string.Format("List of Pipeline elements is NULL for construction report type: {0}", viewModel.ReportType));
                }
            }
            catch (RepositoryException ex)
            {
                log.Warn(this.GetType().Name + " | " + ex.ToString());
                notify.ShowWarning(Program.LanguageManager.GetString(StringResources.Notification_Error_Db_Message),
                                   Program.LanguageManager.GetString(StringResources.Notification_Error_Db_Header));
            }
        }