Пример #1
0
        public void GetData(Shared.Models.User user)
        {
            try
            {
                DrawingEnumerator SelectedDrawings = CourretDrawingHandler.GetDrawingSelector().GetSelected();

                logger.Info("Чертежи успешно получены");

                Drawings = new List <Shared.Models.Drawing>();

                Errors = new List <StringErrorBindingModel>();

                while (SelectedDrawings.MoveNext())
                {
                    try
                    {
                        if (SelectedDrawings.Current is AssemblyDrawing)
                        {
                            String Number = "";

                            Assembly assembly = model.SelectModelObject(((SelectedDrawings.Current as AssemblyDrawing)).AssemblyIdentifier) as Assembly;

                            if (!ChechedDate(assembly))
                            {
                                assembly.GetReportProperty("CUSTOM.Zakaz", ref Number);
                                Errors.Add(new StringErrorBindingModel {
                                    Data = $"Заказ: {Number}, Марка: {SelectedDrawings.Current.Mark}", Error = "Не заполнено поле \"Дата\""
                                });
                                continue;
                            }

                            GetDrawing(assembly, SelectedDrawings.Current as AssemblyDrawing);
                        }
                    }
                    catch (Exception E)
                    {
                        String   Number   = "";
                        String   List     = "";
                        Assembly assembly = model.SelectModelObject(((SelectedDrawings.Current as AssemblyDrawing)).AssemblyIdentifier) as Assembly;
                        assembly.GetReportProperty("CUSTOM.Zakaz", ref Number);
                        assembly.GetReportProperty("CUSTOM.Drw_SheetRev", ref List);
                        logger.Error(E.ToString());
                        Errors.Add(new StringErrorBindingModel {
                            Data = $"Заказ: {Number}, Лист: {List}", Error = E.Message
                        });
                    }
                }

                logger.Info("Чертежи добавлены");

                ModelInfo modelInfo = model.GetInfo();
                Model = new Shared.Models.Model {
                    DateCreate = DateTime.Now, Path = modelInfo.ModelPath, Drawings = Drawings
                };

                notify.Close();

                if (Errors.Count > 0)
                {
                    ReportErrors Report = new ReportErrors();
                    Report.Report_DGV.AutoGenerateColumns = false;
                    Report.Report_DGV.DataSource          = Errors;

                    Report.ShowDialog();
                }

                if (Model.Drawings.Count() > 0)
                {
                    logger.Info("Начат показ чертежей");

                    Operations operations = new Operations();
                    operations.ShowData(Model, user);
                }
            }
            catch (Exception E)
            {
                maillogger.SendErrorLog(E.ToString());
                logger.Error(E.ToString());
                MessageBox.Show("Ошибка операции", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }