コード例 #1
0
        public void RecalculateProjectByCount(Drawing drawing, IClassDataManager<Drawing> drawDataManager)
        {
            var parentDraw = drawDataManager.GetDocument(drawing.ParentId);

            drawing.CountAll = drawing.Count * parentDraw?.CountAll ?? drawing.Count;

            var childrens = drawDataManager.GetListCollection(x => x.ParentId == drawing.Id);
            if (childrens.Any())
            {
                decimal sumWeight = 0;
                foreach (var children in childrens)
                {
                    RecalculateProjectByCount(children, drawDataManager);
                    sumWeight += children.WeightAll;
                }

                drawing.WeightAll = sumWeight;
                drawing.Weight = drawing.CountAll > 0 ? drawing.WeightAll / drawing.CountAll : 0;
            }
            else
            {
                RecalculateProjectByWeight(drawing, drawDataManager);
            }

            drawDataManager.Update(drawing);
        }
コード例 #2
0
 public TempDrawingsStorage ConvertSiemensProjectToDomainModel(SiemensProject siemensProject)
 {
     var drawSotrage = new TempDrawingsStorage();
     var project = new Drawing { Count = 1, CountAll = 1 };
     LoadFromArticle(siemensProject, project, drawSotrage);
     return drawSotrage;
 }
コード例 #3
0
ファイル: OrderListController.cs プロジェクト: ctukc-nt/UPPY
        public void Save(Order order)
        {
            if (order.DrawingId == null)
            {
                var drawing = new Drawing();
                _drawingDataManager.Insert(drawing);
                order.DrawingId = drawing.Id;
            }

            _orderDataManager.InsertOrUpdate(order);
        }
コード例 #4
0
 public void LoadFilesFromDrawingsAndConvertPath(Drawing drawing, bool drawingIsParent)
 {
     foreach (var uppyFileInfo in drawing.Files)
     {
         if (File.Exists(uppyFileInfo.FileName))
         {
             // rename file name
             var fileInfo = _filesRepository.PutFile(uppyFileInfo.FileName);
             uppyFileInfo.FileName = fileInfo.FileName;
         }
     }
 }
コード例 #5
0
        public void LoadFilesFromDrawingsAndConvertPathTest()
        {
            Mock<IFilesRepository> repoMock = new Mock<IFilesRepository>();
            repoMock.Setup(x => x.PutFile(It.IsAny<string>())).Returns<string>(x => new UppyFileInfo() { FileName = "AAA" });
            FilesLoaderToRepository loader = new FilesLoaderToRepository(repoMock.Object);

            var drawing = new Drawing() {Designation = "Y53 00 186-01", Name = "ДНО БАКА"};
            drawing.Files.Add(new UppyFileInfo() {FileName = @"D:\Siemens\Y53_00_146 - 01_B_Бак\Bom\Y53_00_186_01_A.pdf" });
            drawing.Files.Add(new UppyFileInfo() { FileName = @"D:\Siemens\Y53_00_146-01_B_Бак\Doc\Y53_00_186_IZ_Z;_Sh.01_(A).pdf" });
            drawing.Files.Add(new UppyFileInfo() { FileName = @"D:\Siemens\Y53_00_146-01_B_Бак\Doc\Y53_00_186_IZ_Z;_Sh.02_(A).pdf" });

            var fileName = loader.GetFileName(drawing, true, true, @"D:\Siemens\Y53_00_146-01_B_Бак\Doc\Y53_00_186_IZ_Z;_Sh.02_(A).pdf");
            Debug.WriteLine(fileName);
        }
コード例 #6
0
        public void LoadFilesFromDrawingsAndConvertPath(Drawing drawing, bool drawingIsParent)
        {
            var multiSheets = drawing.Files.Count(x => x.FileName.ToLowerInvariant().Contains("sh.")) > 1;

            foreach (var uppyFileInfo in drawing.Files)
            {
                if (File.Exists(uppyFileInfo.FileName))
                {
                    // rename file name

                    var name = GetFileName(drawing, drawingIsParent, multiSheets, uppyFileInfo.FileName);
                    var fileInfo = _filesRepository.PutFile(uppyFileInfo.FileName, name);
                    uppyFileInfo.FileName = fileInfo.FileName;
                }
            }
        }
コード例 #7
0
        public string GetFileName(Drawing drawing, bool drawingIsParent, bool multiSheet, string filePath)
        {
            var name = drawing.Name;
            var designation = drawing.Designation;
            var docsName = GetFileNameToFind(designation);

            if (filePath.ToLowerInvariant().Contains("sh."))
            {
                // это файл сименсовского чертежа
                string formatFileName = multiSheet ? "{0}{1}{2} {3} л. {4}" : "{0}{1}{2} {3}";
                return RenameDoc(designation, docsName, name, filePath, formatFileName, drawingIsParent ? " СБ" : string.Empty);
            }
            else
            {
                // это файл спецификации
                return RenameBOM(designation, docsName, name, " СП");
            }
        }
コード例 #8
0
        public void RecalculateProjectByWeight(Drawing drawing, IClassDataManager<Drawing> drawDataManager)
        {
            var childrens = drawDataManager.GetListCollection(x => x.ParentId == drawing.Id);
            if (childrens.Any())
            {
                var sum = childrens.Sum(x => x.WeightAll);
                drawing.WeightAll = sum;
                drawing.Weight = drawing.CountAll != 0 ? drawing.WeightAll / drawing.CountAll : 0;
            }
            else
            {
                drawing.RecalculateWeightAll();
            }

            drawDataManager.Update(drawing);

            if (drawing.ParentId != null)
            {
                var parentDrawing = drawDataManager.GetDocument(drawing.ParentId);
                if (parentDrawing != null)
                    RecalculateProjectByWeight(parentDrawing, drawDataManager);
            }
        }
コード例 #9
0
        private void LoadFromArticle(SiemensProject siemensProject, Drawing drawing, TempDrawingsStorage drawStorage)
        {
            var childrenProject = new List<Drawing>();

            drawing.Name = $"{siemensProject.Article.Head.ARTName} {siemensProject.Article.Head.ARTNameRem}".Trim();
            drawing.Designation = siemensProject.Article.Head.ARTPartID.Trim();
            //drawing.Dimension = string.Empty;
            drawing.GostOnMaterial = string.Empty;
            drawing.GostOnSort = string.Empty;
            drawing.MarkSteal = string.Empty;
            drawing.StandartSize = string.Empty;
            drawing.Profile = string.Empty;
            drawing.Files = siemensProject.FileNames.Select(x => new UppyFileInfo() { FileName = x }).ToList();

            if (siemensProject.Article.BOM.Length == 1 && siemensProject.Article.BOM[0].ARTARTPartID.Contains("#"))
            {
                //для проектов состоящих из одного подпроекта, являющегося терминальным - загоняем всю инфу в проект
                var position = siemensProject.Article.BOM[0];

                drawing.Weight = Convert.ToDecimal(siemensProject.Article.Head.ARTWeight) /
                               Convert.ToInt32(position.ARTARTQuant) / 1000;
                drawing.CountAll = drawing.CountAll * Convert.ToInt32(position.ARTARTQuant);
                drawing.WeightAll = drawing.Weight * drawing.CountAll;
                drawing.Count = Convert.ToInt32(position.ARTARTQuant) * drawing.Count;

                try
                {
                    drawing.Length = MaterialParser.GetLength(position);
                    drawing.Width = MaterialParser.GetWidth(position);
                }
                catch (Exception ex)
                {
                    AppendMessageToLog(new LogMessage("Ошибка парсиинга длина и/или ширины.", drawing, TypeMessage.Error));
                }

                drawing.GostOnSort = Normalizer.SetEmptySpacesGost(MaterialParser.GetGOSTS(position));
                drawing.StandartSize = MaterialParser.GetStandartSize(position);
                drawing.Designation = MaterialParser.GetDesignation(position) == string.Empty ? drawing.Designation : MaterialParser.GetDesignation(position);
                drawing.MarkSteal = MaterialParser.GetMarkSteal(position);
                drawing.Profile = NameMaterialSearch.GetNameMaterialByGost(drawing.GostOnSort);
                drawing.MarkSteal = Normalizer.RemoveUnUseInfoAboutMarkSteal(drawing.MarkSteal);

                drawStorage.Add(drawing);
            }
            else
            {
                drawStorage.Add(drawing);

                foreach (var position in siemensProject.Article.BOM.Where(x => (ExcluderProject != null && !ExcluderProject.IsNeedExclude(x)) || ExcluderProject == null))
                {
                    var subProject = new Drawing
                    {
                        ParentId = drawing.Id,
                        Count = Convert.ToInt32(position.ARTARTQuant),
                        Note = string.Empty,
                        NumberOnSpec = Normalizer.NormalizePositionNumber(position.ARTARTPosNo),
                        Profile = string.Empty
                    };

                    subProject.CountAll = subProject.Count * drawing.CountAll;

                    if (position.ARTARTPartID.Contains("#"))
                    {
                        //дальше лезть не надо
                        subProject.Name = position.ARTARTPosName.Trim();
                        subProject.Designation = position.ARTARTSZNo.Trim();

                        if (subProject.Designation == string.Empty)
                        {
                            subProject.Designation = $"{drawing.Designation} поз. {subProject.NumberOnSpec}".Trim();
                        }

                        try
                        {
                            subProject.Length = MaterialParser.GetLength(position);
                            subProject.Width = MaterialParser.GetWidth(position);
                        }
                        catch (Exception ex)
                        {
                            AppendMessageToLog(new LogMessage("Ошибка парсиинга длина и/или ширины.", drawing, TypeMessage.Error));
                        }

                        subProject.GostOnSort = Normalizer.SetEmptySpacesGost(MaterialParser.GetGOSTS(position));
                        subProject.StandartSize = MaterialParser.GetStandartSize(position);
                        subProject.Designation = MaterialParser.GetDesignation(position) == string.Empty ? subProject.Designation : MaterialParser.GetDesignation(position);
                        subProject.MarkSteal = MaterialParser.GetMarkSteal(position);
                        subProject.Profile = NameMaterialSearch.GetNameMaterialByGost(subProject.GostOnSort);
                        //subProject.Dimension = string.Empty;
                        subProject.GostOnMaterial = string.Empty;
                        subProject.Weight = Convert.ToDecimal(position.ARTARTPosWeight) / 1000 / subProject.Count;
                        subProject.WeightAll = subProject.CountAll * subProject.Weight;
                        subProject.MarkSteal = Normalizer.RemoveUnUseInfoAboutMarkSteal(subProject.MarkSteal);

                        childrenProject.Add(subProject);
                        drawStorage.Add(subProject);
                    }
                    else
                    {
                        //ищем следующий файл
                        if (!string.IsNullOrWhiteSpace(position.ARTARTPartID))
                        {
                            var subSiemensProject =
                                siemensProject.Positions.FirstOrDefault(
                                    x => x.Article.Head.ARTPartID.Contains(position.ARTARTPartID));

                            LoadFromArticle(subSiemensProject, subProject, drawStorage);

                            childrenProject.Add(subProject);
                        }
                        else
                        {
                            subProject.Note = position.ARTARTPosNo + "_ERROR!!!!";
                            subProject.Name = position.Items.Aggregate((x, y) => x.Trim() + " " + y.Trim()).Trim();
                            subProject.Designation = string.Empty;
                            //subProject.Dimension = string.Empty;
                            subProject.GostOnMaterial = string.Empty;
                            subProject.GostOnSort = string.Empty;
                            subProject.MarkSteal = string.Empty;
                            subProject.StandartSize = string.Empty;
                            drawStorage.Add(subProject);

                            AppendMessageToLog(new LogMessage("Ошибка поиска следующего файла.", subProject, TypeMessage.Warning));

                            childrenProject.Add(subProject);
                        }
                    }
                }

                drawing.WeightAll = childrenProject.Sum(x => x.WeightAll);
            }

            if (Math.Round(drawing.WeightAll) == 0)
            {
                drawing.WeightAll = Convert.ToDecimal(siemensProject.Article.Head.ARTWeight) * drawing.CountAll / 1000;
            }

            drawing.Weight = drawing.WeightAll / drawing.CountAll;
        }
コード例 #10
0
 protected virtual void OnDrawingCountChanged(Drawing drawing)
 {
     DrawingCountChanged?.Invoke(drawing);
 }
コード例 #11
0
 public void Delete(Drawing document)
 {
     _drawingsDataManager.Delete(document);
     OnDataRefreshed();
 }
コード例 #12
0
 public void CreateStandartByDrawing(Drawing drawing)
 {
     var converterController = _controllersFactory.GetDrawingsToStandartController();
     converterController.ShowView(drawing);
 }
コード例 #13
0
 public void ChangeDrawingWeight(Drawing drawing)
 {
     var quantHelper = _controllersFactory.GetDrawingBulkChangesHelper();
     quantHelper.RecalculateProjectByWeight(drawing);
     OnDataRefreshed();
 }
コード例 #14
0
 public void ShowFilesViewer(Drawing drawing)
 {
     FilesViewForm filesViewForm = new FilesViewForm(new FilesRepository());
     filesViewForm.Files = drawing.Files;
     filesViewForm.ShowDialog();
 }
コード例 #15
0
ファイル: ProjectExcluder.cs プロジェクト: ctukc-nt/UPPY
        //public bool IsNeedExclude(Project project)
        //{
        //    if (project == null)
        //        return false;

        //    return dkData.ProjectExceptionSet.Any(projectException => projectException.Mark == project.GOSTS || (project.Name != null && project.Name.Contains(projectException.Mark)));

        //    //if (Enumerable.Any(dkData.ProjectExceptionSet, exc => aggrName.Contains(exc.Mark)))
        //    //{
        //    //    return true;
        //    //}
        //}

        public bool IsNeedExclude(Drawing project)
        {
            return false;
        }
コード例 #16
0
 public void Add(Drawing drawing)
 {
     _drawings.Add(drawing);
     drawing.Id = _count++;
 }
コード例 #17
0
ファイル: Drawing.cs プロジェクト: ctukc-nt/UPPY
 public int CompareByStandartSize(Drawing doc2)
 {
     return 0;
 }
コード例 #18
0
        /// <summary>
        ///     Создать нормы на деталь
        /// </summary>
        /// <param name="headDrawing">Деталь</param>
        /// <param name="dataManager">Дата манагер</param>
        /// <param name="gosts">Список ГОСТов</param>
        /// <returns></returns>
        public Standart CreateStandartByDrawing(Drawing headDrawing, IHierClassDataManager<Drawing> dataManager,
            List<Gost> gosts)
        {
            var allChildrens = dataManager.GetListAllChildrens(headDrawing.Id);
            var allParentId = allChildrens.Select(x => x.ParentId).Distinct();
            var allDetails = allChildrens.AsParallel().Where(x => allParentId.FirstOrDefault(y => y != null && y.Value == x.Id) == null);

            var standart = new Standart();

            foreach (var detail in allDetails)
            {
                var position = new PositionStandart
                {
                    Profile = detail.Profile,
                    StandartSize = detail.StandartSize,
                    GostOnSort = detail.GostOnSort,
                    MarkSteal = detail.MarkSteal,
                    UtilizationRatio = DefaultUtilizationRatio,
                    Weight = 0
                };

                if (string.IsNullOrWhiteSpace(position.Profile))
                    position.Profile = detail.Name;

                var gost =
                    gosts.FirstOrDefault(
                        x =>
                            string.Equals(x.Name.Replace(" ", ""), position.GostOnSort.Replace(" ", ""),
                                StringComparison.CurrentCultureIgnoreCase));

                if (string.IsNullOrWhiteSpace(position.GostOnSort))
                {
                    Log?.AppendMessage("Поле ГОСТ на сортамент не заполнено." + position.GostOnSort, position, TypeMessage.Error);
                    standart.Positions.Add(position);
                    continue;
                }

                if (gost == null)
                {
                    if (ThrowExceptions)
                    {
                        var argEx = new ArgumentException($"Справочник гостов не полный. Отсутствует ГОСТ {position.GostOnSort}.");
                        argEx.Data.Add("detail", detail);
                        throw argEx;
                    }
                    else
                    {
                        position.Note = "Не найден ГОСТ в справочнике, позиция без обработки!";
                        Log?.AppendMessage("Не найден ГОСТ " + position.GostOnSort, position, TypeMessage.Error);
                        standart.Positions.Add(position);
                        continue;
                    }
                }

                switch (gost.TypeExtraDimension)
                {
                        case ExtraDimensions.Meters:
                        case ExtraDimensions.SquareMeter:

                        switch (gost.WeightMethodCalculate)
                        {
                            case WeightMethodCalculate.LengthAndWidth:

                                if (detail.Length.HasValue && detail.Width.HasValue && !string.IsNullOrEmpty(position.StandartSize))
                                {
                                    position.AdditionalMeasurement = (double)(((double)detail.Length * detail.Width) / 1000 / 1000 *
                                                                               detail.CountAll);
                                    position.Weight = position.AdditionalMeasurement * ConvertStandartSize(position.StandartSize) *
                                                      Density;
                                    position.TypeAdditionalMeasurement = gost.TypeExtraDimension;
                                    position.Note = $"{(double)detail.Length} x {(double)detail.Width} x {detail.CountAll}";
                                }
                                else
                                {
                                    Log?.AppendMessage("Поля Длина и/или Ширина и/или Типоразмер не заполнено в соответствии выбранному методу вычисления по типу ГОСТа " + gost.Name);
                                }
                                break;
                            case WeightMethodCalculate.Length:
                                if (detail.Length.HasValue && !string.IsNullOrEmpty(position.StandartSize))
                                {
                                    var dimensions = position.StandartSize.ToUpper().Split(SplittersStandartSize.ToArray());
                                    position.TypeAdditionalMeasurement = gost.TypeExtraDimension;
                                    position.AdditionalMeasurement = ((double)detail.Length) / 1000 * detail.CountAll;
                                    position.Weight = Math.PI * Math.Pow(ConvertStandartSizeByDelim(dimensions[0]), 2) / 4000 *
                                                      position.AdditionalMeasurement * Density;
                                }
                                else
                                {
                                    Log?.AppendMessage("Поля не Длина и/или Ширина и/или Типоразмер не заполнено в соответствии выбранному методу вычисления по типу ГОСТа " + gost.Name);
                                }
                                break;
                            case WeightMethodCalculate.ByTable:
                                if (detail.Length.HasValue && !string.IsNullOrEmpty(position.StandartSize))
                                {
                                    position.TypeAdditionalMeasurement = gost.TypeExtraDimension;
                                    position.AdditionalMeasurement = ((double)detail.Length.Value) / 1000 * detail.CountAll;
                                    var weigthByTable = gost.GetStandartWeight(position.StandartSize);
                                    if (weigthByTable != null)
                                        position.Weight = weigthByTable.Weight * position.AdditionalMeasurement;
                                    else
                                    {
                                        Log?.AppendMessage(
                                            $"Не заполнен табличный типоразмер для ГОСТа {gost.Name} и типоразмера {position.StandartSize}");
                                    }
                                }
                                else
                                {
                                    Log?.AppendMessage("Поле Длина и/или Типоразмер не заполнено в соответствии выбранному методу вычисления по типу ГОСТа " + gost.Name);
                                }
                                break;
                            case WeightMethodCalculate.LengthAndThikness:


                                if (!string.IsNullOrEmpty(position.StandartSize))
                                {
                                    var splStSize = position.StandartSize.ToUpper().Split(SplittersStandartSize.ToArray());
                                    var outerSize = splStSize[0];
                                    var widthWall = splStSize[1];

                                    if (detail.Length.HasValue)
                                    {
                                        if (!string.IsNullOrEmpty(outerSize) && !string.IsNullOrEmpty(widthWall))
                                        {
                                            position.TypeAdditionalMeasurement = gost.TypeExtraDimension;
                                            position.AdditionalMeasurement = ((double)detail.Length) / 1000 * detail.CountAll;
                                            position.Weight = (Convert.ToDouble(outerSize) - Convert.ToDouble(widthWall)) *
                                                              Convert.ToDouble(widthWall) / 40.55 *
                                                              position.AdditionalMeasurement;
                                        }
                                        else
                                        {
                                            Log?.AppendMessage("Поле Типоразмер не заполнено в соответствии выбранному методу вычисления по типу ГОСТа " + gost.Name);
                                        }
                                    }
                                    else
                                    {
                                        Log?.AppendMessage("Поле Длина не заполнено в соответствии выбранному методу вычисления по типу ГОСТа " + gost.Name);
                                    }
                                }
                                else
                                {
                                    Log?.AppendMessage("Поле Типоразмер не заполнено");
                                }


                                break;
                            case WeightMethodCalculate.LengthAndDoubleThikness:

                                if (detail.Length.HasValue && !string.IsNullOrEmpty(position.StandartSize))
                                {
                                    position.TypeAdditionalMeasurement = gost.TypeExtraDimension;
                                    position.AdditionalMeasurement = ((double)detail.Length) / 1000 * detail.CountAll;
                                    position.Weight = position.AdditionalMeasurement * ConvertStandartSize(position.StandartSize) *
                                                      ConvertStandartSize(position.StandartSize) * Density / 1000;
                                }
                                else
                                {
                                    Log?.AppendMessage("Поле Длина и/или Типоразмер не заполнено в соответствии выбранному методу вычисления по типу ГОСТа " + gost.Name);
                                }
                                break;
                        }

                        position.WeightWithWaste = position.Weight / position.UtilizationRatio;
                        position.AdditionalMeasurementWithWaste = position.AdditionalMeasurement /
                                                                  position.UtilizationRatio;

                        break;

                        case ExtraDimensions.Piece:
                        position.Weight = 0;
                        position.WeightWithWaste = 0;
                        position.UtilizationRatio = 1;

                        position.TypeAdditionalMeasurement = gost.TypeExtraDimension;
                        position.AdditionalMeasurement = detail.CountAll;
                        position.AdditionalMeasurementWithWaste = detail.CountAll;
                        break;
                }

                standart.Positions.Add(position);
            }

            return standart;
        }
コード例 #19
0
 public void RecalculateProjectByCount(Drawing drawing)
 {
     DrawingsCalculateHelper drawingsCalculateHelper = new DrawingsCalculateHelper();
     drawingsCalculateHelper.RecalculateProjectByCount(drawing, _dataDataManagersFactory.GetDataManager<Drawing>());
 }
コード例 #20
0
 public void ShowView(Drawing drawing)
 {
     _drawing = drawing;
     var form = new DrawingToStandartForm(this);
     form.ShowDialog();
 }
コード例 #21
0
 public DrawingsToStandartController(IUppyDataManagersFactory dataManagersFactory, Drawing drawing)
 {
     _dataManagersFactory = dataManagersFactory;
     _drawing = drawing;
 }
コード例 #22
0
 public void ShowDrawingInAnotherView(Drawing drawing)
 {
     var controller = _controllersFactory.GetDocumentController<Drawing>();
     controller.Document = drawing;
     controller.ShowViewDialog();
 }
コード例 #23
0
 protected virtual void OnDrawingWeightChanged(Drawing arg)
 {
     DrawingWeightChanged?.Invoke(arg);
 }
コード例 #24
0
 private void LoadFiles(Drawing drawing, List<Drawing> drawings)
 {
     _loaderToRepository?.LoadFilesFromDrawingsAndConvertPath(drawing, drawings.Any(x => x.ParentId == drawing.Id));
 }
コード例 #25
0
 public void Save(Drawing document)
 {
     _drawingsDataManager.InsertOrUpdate(document);
     document.Designation = document.Id.ToString();
     _drawingsDataManager.Update(document);
     OnDataRefreshed();
 }