コード例 #1
0
        /// <summary>
        /// Перерисовака графика
        /// </summary>
        private void CreateChart()
        {
            int WidthDifference  = pbChart.Location.X + chart.Indent + 5;
            int HeightDifference = pbChart.Location.Y + chart.Indent + 10;

            pbChart.Size = new Size(this.Size.Width - WidthDifference, this.Size.Height - HeightDifference);
            StateClass stateClass =
                CalculationDefectsController.GetCurrentStateClass(StateClassController.GetShaft(cbMachines.SelectedItem as Machine),
                                                                  (cbMachines.SelectedItem as Machine).Head);
            List <ResultDiagnostics> resultDiagnostics = new List <ResultDiagnostics>();
            List <Repairs>           repairs           = RepairsController.GetRepairs((cbMachines.SelectedItem as Machine));
            List <ResultForecast>    forecasts         = new List <ResultForecast>();

            if (rbBearing.Checked)
            {
                resultDiagnostics = DiagnosticResultController.GetBearingResult(cbMachines.SelectedItem as Machine);
            }
            else
            {
                resultDiagnostics = DiagnosticResultController.GetShaftResult(cbMachines.SelectedItem as Machine);
            }
            if (rbStandartForecast.Checked)
            {
                forecasts =
                    ForecastController.GetStandartForecast(resultDiagnostics,
                                                           stateClass,
                                                           (cbMachines.SelectedItem as Machine));
            }
            else
            {
                forecasts =
                    ForecastController.GetSimpleForecast(resultDiagnostics,
                                                         stateClass,
                                                         (cbMachines.SelectedItem as Machine));
            }

            chart = new Chart(pbChart.ClientRectangle, resultDiagnostics, forecasts, stateClass, repairs);
            pbChart.Invalidate();
        }
コード例 #2
0
        public static void CreateReport(string pathToTemplate, Machine machine)
        {
            WordDocument wordDoc = null;

            try
            {
                // ЗАПОЛНЯЕМ ОБЩУЮ ИНФОРМАЦИЮ
                wordDoc = new WordDocument(pathToTemplate);
                // Заполняем маркировку
                wordDoc.SetSelectionToText(SearchWord.MachineMarking);
                wordDoc.Selection.Text = machine.Marking;
                //заполняем номер машины
                wordDoc.SetSelectionToText(SearchWord.MachineNumber);
                wordDoc.Selection.Text = machine.Number;

                //wordDoc.SetSelectionToText("@@machineArea");
                //wordDoc.Selection.Text = machine.Marking;
                //заполняем напор машины
                wordDoc.SetSelectionToText(SearchWord.MachineHead);
                wordDoc.Selection.Text = machine.Head.ToString();

                //заполняем классы состояния

                StateClass ShaftStateClass =
                    CalculationDefectsController.GetCurrentStateClass(StateClassController.GetShaft(machine),
                                                                      machine.Head);

                StateClass BearingStateClass =
                    CalculationDefectsController.GetCurrentStateClass(StateClassController.GetBearing(machine),
                                                                      machine.Head);

                wordDoc.SetSelectionToText(SearchWord.MachineNicelyShaft);
                wordDoc.Selection.Text = ShaftStateClass.nicely.ToString();

                wordDoc.SetSelectionToText(SearchWord.MachineAcceptablyShaft);
                wordDoc.Selection.Text = ShaftStateClass.acceptably.ToString();

                wordDoc.SetSelectionToText(SearchWord.MachineLimitedShaft);
                wordDoc.Selection.Text = ShaftStateClass.limited.ToString();

                wordDoc.SetSelectionToText(SearchWord.MachineNicelyBearing);
                wordDoc.Selection.Text = BearingStateClass.nicely.ToString();

                wordDoc.SetSelectionToText(SearchWord.MachineAcceptablyBearing);
                wordDoc.Selection.Text = BearingStateClass.acceptably.ToString();

                wordDoc.SetSelectionToText(SearchWord.MachineLimitedBearing);
                wordDoc.Selection.Text = BearingStateClass.limited.ToString();

                //Заполняем результаты предыдущих диагностик

                List <ResultDiagnostics> ShaftResults   = DiagnosticResultController.GetShaftResult(machine);
                List <ResultDiagnostics> BearingResults = DiagnosticResultController.GetBearingResult(machine);
                List <ResultDiagnostics> EngineResults  = DiagnosticResultController.GetEngineResult(machine);

                for (int i = 1; i <= ShaftResults.Count; i++)
                {
                    wordDoc.SetSelectionToText(SearchWord.MachineShaftDiagnosticsResult + i.ToString());
                    wordDoc.Selection.Text = ShaftResults[i - 1].value.ToString();
                }

                for (int i = 1; i <= BearingResults.Count; i++)
                {
                    wordDoc.SetSelectionToText(SearchWord.MachineBearingDiagnosticsResult + i.ToString());
                    wordDoc.Selection.Text = BearingResults[i - 1].value.ToString();
                }

                for (int i = 1; i <= EngineResults.Count; i++)
                {
                    wordDoc.SetSelectionToText(SearchWord.MachineEngineDiagnosticsResult + i.ToString());
                    wordDoc.Selection.Text = EngineResults[i - 1].value.ToString();
                }

                //
            }
            catch (Exception error)
            {
                if (wordDoc != null)
                {
                    wordDoc.Close();
                }
                MessageBox.Show("Ошибка при замене текста на метке в документе  Word. Подробности " + error.Message);
                return;
            }
            wordDoc.Visible = true;
        }