public void Create( AttachedDoc attachedDoc, int markId) { if (attachedDoc == null) { throw new ArgumentNullException(nameof(attachedDoc)); } var foundMark = _markRepo.GetById(markId); if (foundMark == null) { throw new ArgumentNullException(nameof(foundMark)); } var uniqueConstraintViolationCheck = _repository.GetByUniqueKey( markId, attachedDoc.Designation); if (uniqueConstraintViolationCheck != null) { throw new ConflictException( uniqueConstraintViolationCheck.Id.ToString()); } attachedDoc.Mark = foundMark; _repository.Add(attachedDoc); foundMark.EditedDate = DateTime.Now; _markRepo.Update(foundMark); }
public Specification Create(int markId) { var foundMark = _markRepo.GetById(markId); if (foundMark == null) { throw new ArgumentNullException(nameof(foundMark)); } var specifications = _repository.GetAllByMarkId(markId); foreach (var s in specifications) { if (s.IsCurrent) { s.IsCurrent = false; _repository.Update(s); } } var newSpecification = new Specification { Mark = foundMark, Num = (Int16)(specifications.Count() == 0 ? 1 : specifications.Max(v => v.Num) + 1), IsCurrent = true, }; _repository.Add(newSpecification); foundMark.EditedDate = DateTime.Now; _markRepo.Update(foundMark); return(newSpecification); }
public void Create( StandardConstruction standardConstruction, int specificationId) { if (standardConstruction == null) { throw new ArgumentNullException(nameof(standardConstruction)); } var foundSpecification = _specificationRepo.GetById(specificationId); if (foundSpecification == null) { throw new ArgumentNullException(nameof(foundSpecification)); } var uniqueConstraintViolationCheck = _repository.GetByUniqueKey( specificationId, standardConstruction.Name); if (uniqueConstraintViolationCheck != null) { throw new ConflictException(nameof(uniqueConstraintViolationCheck)); } standardConstruction.Specification = foundSpecification; _repository.Add(standardConstruction); var foundMark = _markRepo.GetById(foundSpecification.Mark.Id); foundMark.EditedDate = DateTime.Now; _markRepo.Update(foundMark); }
public void Create( Construction construction, int specificationId, int typeId, int?subtypeId, int weldingControlId) { if (construction == null) { throw new ArgumentNullException(nameof(construction)); } var foundSpecification = _specificationRepo.GetById(specificationId); if (foundSpecification == null) { throw new ArgumentNullException(nameof(foundSpecification)); } var uniqueConstraintViolationCheck = _repository.GetByUniqueKey( specificationId, construction.Name, construction.PaintworkCoeff); if (uniqueConstraintViolationCheck != null) { throw new ConflictException(uniqueConstraintViolationCheck.Id.ToString()); } construction.Specification = foundSpecification; var foundType = _constructionTypeRepo.GetById(typeId); if (foundType == null) { throw new ArgumentNullException(nameof(foundType)); } construction.Type = foundType; if (subtypeId != null) { var subtype = _constructionSubtypeRepo.GetById(subtypeId.GetValueOrDefault()); if (subtype == null) { throw new ArgumentNullException(nameof(subtype)); } construction.Subtype = subtype; } var foundWeldingControl = _weldingControlRepo.GetById(weldingControlId); if (foundWeldingControl == null) { throw new ArgumentNullException(nameof(foundWeldingControl)); } construction.WeldingControl = foundWeldingControl; _repository.Add(construction); var foundMark = _markRepo.GetById(foundSpecification.Mark.Id); foundMark.EditedDate = DateTime.Now; _markRepo.Update(foundMark); }
public MemoryStream GetGeneralDataDocument(int markId) { var mark = _markRepo.GetById(markId); if (mark == null) { throw new ArgumentNullException(nameof(mark)); } var markApprovals = _markApprovalRepo.GetAllByMarkId(markId); var subnode = mark.Subnode; var node = subnode.Node; var project = node.Project; var markGeneralDataPoints = _markGeneralDataPointRepo.GetAllByMarkId( markId).OrderByDescending( v => v.Section.OrderNum).ThenByDescending(v => v.OrderNum); var sheets = _docRepo.GetAllByMarkIdAndDocType(markId, _sheetDocTypeId); var path = "D:\\Dev\\Gipromez\\word\\template.docx"; var g = Guid.NewGuid(); string guidString = Convert.ToBase64String(g.ToByteArray()); guidString = guidString.Replace("=", ""); guidString = guidString.Replace("+", ""); var outputPath = $"D:\\Dev\\Gipromez\\word\\{guidString}.docx"; var memory = GetStreamFromTemplate(path); using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(memory, true)) { var markName = MakeMarkName( project.BaseSeries, node.Code, subnode.Code, mark.Code); (var complexName, var objectName) = MakeComplexAndObjectName( project.Name, node.Name, subnode.Name, mark.Name); GeneralDataDocument.AppendList(wordDoc, markGeneralDataPoints); GeneralDataDocument.AppendToSheetTable(wordDoc, sheets.ToList()); GeneralDataDocument.AppendToLinkedAndAttachedDocsTable( wordDoc, _markLinkedDocRepo.GetAllByMarkId(markId).ToList(), _attachedDocRepo.GetAllByMarkId(markId).ToList()); AppendToBigFooterTable( wordDoc, markName, complexName, objectName, sheets.Count(), mark, markApprovals.ToList()); AppendToSmallFooterTable(wordDoc, markName); } memory.Seek(0, SeekOrigin.Begin); return(memory); }
public void Create( MarkGeneralDataPoint markGeneralDataPoint, int markId, int sectionId) { if (markGeneralDataPoint == null) { throw new ArgumentNullException(nameof(markGeneralDataPoint)); } var foundSection = _generalDataSectionRepo.GetById(sectionId); if (foundSection == null) { throw new ArgumentNullException(nameof(foundSection)); } var foundMark = _markRepo.GetById(markId); if (foundMark == null) { throw new ArgumentNullException(nameof(foundMark)); } var uniqueConstraintViolationCheck = _repository.GetByUniqueKey( markId, sectionId, markGeneralDataPoint.Text); if (uniqueConstraintViolationCheck != null) { throw new ConflictException(uniqueConstraintViolationCheck.Id.ToString()); } markGeneralDataPoint.Section = foundSection; markGeneralDataPoint.Mark = foundMark; var currentPoints = _repository.GetAllByMarkAndSectionId(markId, sectionId); if (currentPoints.Count() == 0) { markGeneralDataPoint.OrderNum = 1; } else { markGeneralDataPoint.OrderNum = (Int16)(currentPoints.Max(v => v.OrderNum) + 1); } _repository.Add(markGeneralDataPoint); foundMark.EditedDate = DateTime.Now; _markRepo.Update(foundMark); }
public void PopulateDocument(int markId, MemoryStream memory) { var mark = _markRepo.GetById(markId); if (mark == null) { throw new ArgumentNullException(nameof(mark)); } var subnode = mark.Subnode; var node = subnode.Node; var project = node.Project; var constructionBolts = _constructionBoltRepo.GetAllByMarkId(markId); var boltLengths = new List <BoltLength> { }; foreach (var bolt in constructionBolts) { var arr = _boltLengthRepo.GetAllByDiameterId(bolt.Diameter.Id); var bl = arr.Where( v => v.Length >= bolt.Packet + v.ScrewLength).Aggregate( (i1, i2) => i1.Length < i2.Length ? i1 : i2); boltLengths.Add(bl); } using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(memory, true)) { var markName = MarkHelper.MakeMarkName( project.BaseSeries, node.Code, subnode.Code, mark.Code); AppendToTable(wordDoc, constructionBolts.ToList(), boltLengths); Word.AppendToSmallFooterTable(wordDoc, markName); Word.AppendToMainSmallFooterTable(wordDoc, markName); } }
public void Create( MarkLinkedDoc markLinkedDoc, int markId, int linkedDocId) { if (markLinkedDoc == null) { throw new ArgumentNullException(nameof(markLinkedDoc)); } var foundLinkedDoc = _linkedDocRepo.GetById(linkedDocId); if (foundLinkedDoc == null) { throw new ArgumentNullException(nameof(foundLinkedDoc)); } var foundMark = _markRepo.GetById(markId); if (foundMark == null) { throw new ArgumentNullException(nameof(foundMark)); } var uniqueConstraintViolationCheck = _repository.GetByMarkIdAndLinkedDocId(markId, linkedDocId); if (uniqueConstraintViolationCheck != null) { throw new ConflictException(nameof(uniqueConstraintViolationCheck)); } markLinkedDoc.Mark = foundMark; markLinkedDoc.LinkedDoc = foundLinkedDoc; _repository.Add(markLinkedDoc); }
public void PopulateDocument(int markId, MemoryStream memory) { var mark = _markRepo.GetById(markId); if (mark == null) { throw new ArgumentNullException(nameof(mark)); } var subnode = mark.Subnode; var node = subnode.Node; var project = node.Project; var departmentHead = _employeeRepo.GetByDepartmentIdAndPosition( mark.Department.Id, _appSettings.DepartmentHeadPosId); if (departmentHead == null) { departmentHead = _employeeRepo.GetByDepartmentIdAndPosition( mark.Department.Id, _appSettings.ActingDepartmentHeadPosId); } if (departmentHead == null) { departmentHead = _employeeRepo.GetByDepartmentIdAndPosition( mark.Department.Id, _appSettings.DeputyDepartmentHeadPosId); } if (departmentHead == null) { departmentHead = _employeeRepo.GetByDepartmentIdAndPosition( mark.Department.Id, _appSettings.ActingDeputyDepartmentHeadPosId); } if (departmentHead == null) { throw new ConflictException(); } var constructions = _constructionRepo.GetAllByMarkId(markId); var standardConstructions = _standardConstructionRepo.GetAllByMarkId(markId); using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(memory, true)) { var markName = MarkHelper.MakeMarkName( project.BaseSeries, node.Code, subnode.Code, mark.Code); (var complexName, var objectName) = MarkHelper.MakeComplexAndObjectName( project.Name, node.Name, subnode.Name, mark.Name); AppendConstructionToTable(wordDoc, constructions.ToList(), standardConstructions.ToList()); Word.AppendToMediumFooterTable( wordDoc, markName, complexName, objectName, mark, departmentHead); Word.AppendToSmallFooterTable(wordDoc, markName); } }
public void Update( int markId, List <int> employeeIds) { Log.Information(JsonSerializer.Serialize(employeeIds)); if (employeeIds == null) { throw new ArgumentNullException(nameof(employeeIds)); } var foundMark = _markRepo.GetById(markId); if (foundMark == null) { throw new ArgumentNullException(nameof(foundMark)); } var employees = new List <Employee> { }; foreach (var id in employeeIds) { var employee = _employeeRepo.GetById(id); if (employee == null) { throw new ArgumentNullException(nameof(employee)); } employees.Add(employee); } var markApprovals = _repository.GetAllByMarkId(markId); var currentEmployeeIds = new List <int> { }; foreach (var ma in markApprovals) { if (!employeeIds.Contains(ma.Employee.Id)) { _repository.Delete(ma); } currentEmployeeIds.Add(ma.Employee.Id); } foreach (var(id, i) in employeeIds.WithIndex()) { if (!currentEmployeeIds.Contains(id)) { _repository.Add( new MarkApproval { Mark = foundMark, Employee = employees[i], }); } } foundMark.EditedDate = DateTime.Now; _markRepo.Update(foundMark); }
public void Create( ConstructionElement constructionElement, int constructionId, int profileId, int steelId) { if (constructionElement == null) { throw new ArgumentNullException(nameof(constructionElement)); } var foundConstruction = _constructionRepo.GetById(constructionId); if (foundConstruction == null) { throw new ArgumentNullException(nameof(foundConstruction)); } var foundProfile = _profileRepo.GetById(profileId); if (foundProfile == null) { throw new ArgumentNullException(nameof(foundProfile)); } var foundSteel = _steelRepo.GetById(steelId); if (foundSteel == null) { throw new ArgumentNullException(nameof(foundSteel)); } // var uniqueConstraintViolationCheck = _repository.GetByUniqueConstraint(markId, linkedDocId); // if (uniqueConstraintViolationCheck != null) // throw new ConflictException(nameof(uniqueConstraintViolationCheck)); constructionElement.Construction = foundConstruction; constructionElement.Profile = foundProfile; constructionElement.Steel = foundSteel; _repository.Add(constructionElement); var foundMark = _markRepo.GetById(foundConstruction.Specification.Mark.Id); foundMark.EditedDate = DateTime.Now; _markRepo.Update(foundMark); }
public void Create( ConstructionBolt constructionBolt, int constructionId, int boltDiameterId) { if (constructionBolt == null) { throw new ArgumentNullException(nameof(constructionBolt)); } var foundConstruction = _constructionRepo.GetById(constructionId); if (foundConstruction == null) { throw new ArgumentNullException(nameof(foundConstruction)); } var foundBoltDiameter = _boltDiameterRepo.GetById(boltDiameterId); if (foundBoltDiameter == null) { throw new ArgumentNullException(nameof(foundBoltDiameter)); } var uniqueConstraintViolationCheck = _repository.GetByUniqueKey(constructionId, boltDiameterId); if (uniqueConstraintViolationCheck != null) { throw new ConflictException(nameof(uniqueConstraintViolationCheck)); } constructionBolt.Construction = foundConstruction; constructionBolt.Diameter = foundBoltDiameter; _repository.Add(constructionBolt); var foundMark = _markRepo.GetById(foundConstruction.Specification.Mark.Id); foundMark.EditedDate = DateTime.Now; _markRepo.Update(foundMark); }
public void Create( AdditionalWork additionalWork, int markId, int employeeId) { if (additionalWork == null) { throw new ArgumentNullException(nameof(AdditionalWork)); } var foundMark = _markRepo.GetById(markId); if (foundMark == null) { throw new ArgumentNullException(nameof(foundMark)); } var foundEmployee = _employeeRepo.GetById(employeeId); if (foundEmployee == null) { throw new ArgumentNullException(nameof(foundEmployee)); } var uniqueConstraintViolationCheck = _repository.GetByUniqueKey( markId, employeeId); if (uniqueConstraintViolationCheck != null) { throw new ConflictException( uniqueConstraintViolationCheck.Id.ToString()); } additionalWork.Mark = foundMark; additionalWork.Employee = foundEmployee; _repository.Add(additionalWork); foundMark.EditedDate = DateTime.Now; _markRepo.Update(foundMark); }
public void Update( int markId, EstimateTaskUpdateRequest estimateTask) { if (estimateTask == null) { throw new ArgumentNullException(nameof(estimateTask)); } var foundEstimateTask = _repository.GetByMarkId(markId); if (foundEstimateTask == null) { throw new ArgumentNullException(nameof(foundEstimateTask)); } if (estimateTask.TaskText != null) { foundEstimateTask.TaskText = estimateTask.TaskText; } if (estimateTask.AdditionalText != null) { foundEstimateTask.AdditionalText = estimateTask.AdditionalText; } if (estimateTask.ApprovalEmployeeId != null) { int approvalEmployeeId = estimateTask.ApprovalEmployeeId.GetValueOrDefault(); if (approvalEmployeeId == -1) { foundEstimateTask.ApprovalEmployeeId = null; } else { var approvalEmployee = _employeeRepo.GetById(approvalEmployeeId); if (approvalEmployee == null) { throw new ArgumentNullException(nameof(approvalEmployee)); } foundEstimateTask.ApprovalEmployee = approvalEmployee; } } _repository.Update(foundEstimateTask); var foundMark = _markRepo.GetById(markId); foundMark.EditedDate = DateTime.Now; _markRepo.Update(foundMark); }
public void PopulateDocument(int markId, MemoryStream memory) { var mark = _markRepo.GetById(markId); if (mark == null) { throw new ArgumentNullException(nameof(mark)); } var subnode = mark.Subnode; var node = subnode.Node; var project = node.Project; var sheets = _docService.GetAllSheetsByMarkId(markId).ToList(); var docs = _docService.GetAllAttachedByMarkId(markId).ToList(); var attachedDocs = _attachedDocRepo.GetAllByMarkId(markId).ToList(); var additionalWork = _additionalWorkService.GetAllByMarkId(markId).ToList(); var constructions = _constructionRepo.GetAllByMarkId(markId).ToList(); var standardConstructions = _standardConstructionRepo.GetAllByMarkId(markId).ToList(); using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(memory, true)) { var markName = MarkHelper.MakeMarkName( project.BaseSeries, node.Code, subnode.Code, mark.Code); (var complexName, var objectName) = MarkHelper.MakeComplexAndObjectName( project.Name, node.Name, subnode.Name, mark.Name); Word.ReplaceText(wordDoc, "A", markName); Word.ReplaceText(wordDoc, "B", complexName); Word.ReplaceText(wordDoc, "C", objectName); Word.ReplaceText(wordDoc, "D", mark.Subnode.Node.ChiefEngineer.Name); Word.ReplaceText(wordDoc, "E", mark.GroupLeader.Name); Word.ReplaceText( wordDoc, "F", mark.IssueDate.GetValueOrDefault().ToString("dd.MM.yyyy")); Word.ReplaceText(wordDoc, "G", FindWeight(constructions, standardConstructions).ToStringWithComma()); AppendToSheetsTable(wordDoc, sheets); AppendToDocsTable(wordDoc, docs); AppendToAttachedDocsTable(wordDoc, attachedDocs); AppendToAdditionalWorkTable(wordDoc, additionalWork); Word.AppendToMainSmallFooterTable(wordDoc, markName); Word.AppendToSmallFooterTable(wordDoc, markName); } }
public void PopulateDocument(int markId, MemoryStream memory) { var mark = _markRepo.GetById(markId); if (mark == null) { throw new ArgumentNullException(nameof(mark)); } var subnode = mark.Subnode; var node = subnode.Node; var project = node.Project; using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(memory, true)) { var markName = MarkHelper.MakeMarkName( project.BaseSeries, node.Code, subnode.Code, mark.Code); (var complexName, var objectName) = MarkHelper.MakeComplexAndObjectName( project.Name, node.Name, subnode.Name, mark.Name); AddMarkInfo(wordDoc, complexName, objectName, markName); AddChiefEngineer(wordDoc, mark.Subnode.Node.ChiefEngineer.Name); AddYear(wordDoc); } }
public void Create(MarkOperatingConditions markOperatingConditions, int markId, int envAggressivenessId, int operatingAreaId, int gasGroupId, int constructionMaterialId, int paintworkTypeId, int highTensileBoltsTypeId) { if (markOperatingConditions == null) { throw new ArgumentNullException(nameof(markOperatingConditions)); } var foundMark = _markRepo.GetById(markId); if (foundMark == null) { throw new ArgumentNullException(nameof(foundMark)); } var uniqueConstraintViolationCheck = _repository.GetByMarkId(markId); if (uniqueConstraintViolationCheck != null) { throw new ConflictException(nameof(uniqueConstraintViolationCheck)); } markOperatingConditions.Mark = foundMark; var envAggressiveness = _envAggressivenessRepo.GetById(envAggressivenessId); if (envAggressiveness == null) { throw new ArgumentNullException(nameof(envAggressiveness)); } markOperatingConditions.EnvAggressiveness = envAggressiveness; var operatingArea = _operatingAreaRepo.GetById(operatingAreaId); if (operatingArea == null) { throw new ArgumentNullException(nameof(operatingArea)); } markOperatingConditions.OperatingArea = operatingArea; var gasGroup = _gasGroupRepo.GetById(gasGroupId); if (gasGroup == null) { throw new ArgumentNullException(nameof(gasGroup)); } markOperatingConditions.GasGroup = gasGroup; var constructionMaterial = _constructionMaterialRepo.GetById(constructionMaterialId); if (constructionMaterial == null) { throw new ArgumentNullException(nameof(constructionMaterial)); } markOperatingConditions.ConstructionMaterial = constructionMaterial; var paintworkType = _paintworkTypeRepo.GetById(paintworkTypeId); if (paintworkType == null) { throw new ArgumentNullException(nameof(paintworkType)); } markOperatingConditions.PaintworkType = paintworkType; var highTensileBoltsType = _highTensileBoltsTypeRepo.GetById(highTensileBoltsTypeId); if (highTensileBoltsType == null) { throw new ArgumentNullException(nameof(highTensileBoltsType)); } markOperatingConditions.HighTensileBoltsType = highTensileBoltsType; _repository.Add(markOperatingConditions); foundMark.EditedDate = DateTime.Now; _markRepo.Update(foundMark); }
public void PopulateDocument(int markId, MemoryStream memory) { var mark = _markRepo.GetById(markId); if (mark == null) { throw new ArgumentNullException(nameof(mark)); } var subnode = mark.Subnode; var node = subnode.Node; var project = node.Project; var departmentHead = _employeeRepo.GetByDepartmentIdAndPosition( mark.Department.Id, _appSettings.DepartmentHeadPosId); if (departmentHead == null) { departmentHead = _employeeRepo.GetByDepartmentIdAndPosition( mark.Department.Id, _appSettings.ActingDepartmentHeadPosId); } if (departmentHead == null) { departmentHead = _employeeRepo.GetByDepartmentIdAndPosition( mark.Department.Id, _appSettings.DeputyDepartmentHeadPosId); } if (departmentHead == null) { departmentHead = _employeeRepo.GetByDepartmentIdAndPosition( mark.Department.Id, _appSettings.ActingDeputyDepartmentHeadPosId); } if (departmentHead == null) { throw new ConflictException(); } // Вкл в состав спецификации var constructions = _constructionRepo.GetAllByMarkId(markId); var standardConstructions = _standardConstructionRepo.GetAllByMarkId(markId); var opCond = _markOperatingConditionsRepo.GetByMarkId(markId); if (opCond == null) { throw new ArgumentNullException(nameof(opCond)); } var estTask = _estimateTaskRepo.GetByMarkId(markId); if (estTask == null) { throw new ArgumentNullException(nameof(estTask)); } var markApprovals = new List <MarkApproval> { }; if (estTask.ApprovalEmployee != null) { markApprovals.Add(new MarkApproval { MarkId = markId, Employee = estTask.ApprovalEmployee, }); } using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(memory, true)) { var markName = MarkHelper.MakeMarkName( project.BaseSeries, node.Code, subnode.Code, mark.Code); (var complexName, var objectName) = MarkHelper.MakeComplexAndObjectName( project.Name, node.Name, subnode.Name, mark.Name); AppendText(wordDoc, estTask.TaskText); var arr = new List <ListText> { new ListText { Text = "Изготовление и монтаж конструкций", LevelNum = 0, IsBold = true, WithSuperscript = false, }, new ListText { Text = "Дополнительно учитывать:", LevelNum = 4, IsBold = false, WithSuperscript = false, }, new ListText { Text = $"коэффициент надежности по ответственности: {opCond.SafetyCoeff}", LevelNum = 2, IsBold = false, WithSuperscript = false, }, new ListText { Text = $"среда: {opCond.EnvAggressiveness.Name}", LevelNum = 2, IsBold = false, WithSuperscript = false, }, new ListText { Text = $"расчетная температура эксплуатации: {(opCond.Temperature < 0 ? ("минус " + -opCond.Temperature) : opCond.Temperature)}", LevelNum = 2, IsBold = false, WithSuperscript = false, }, }; AppendList(wordDoc, arr); arr = new List <ListText> { }; double overallInitialWeightSum = 0.0; double overallAreaSum = 0.0; foreach (var construction in constructions) { arr.Add(new ListText { Text = construction.Name, LevelNum = 1, IsBold = false, WithSuperscript = false, }); if (construction.Valuation != null) { arr.Add(new ListText { Text = $"Расценка: {construction.Valuation}", LevelNum = 5, IsBold = false, WithSuperscript = false, }); } if (construction.StandardAlbumCode != null) { arr.Add(new ListText { Text = $"Шифр типового альбома конструкций: {construction.StandardAlbumCode}", LevelNum = 5, IsBold = false, WithSuperscript = false, }); } if (construction.NumOfStandardConstructions != 0) { arr.Add(new ListText { Text = $"Число типовых конструкций: {construction.NumOfStandardConstructions}", LevelNum = 5, IsBold = false, WithSuperscript = false, }); } if (construction.HasEdgeBlunting) { arr.Add(new ListText { Text = "Притупление кромок", LevelNum = 5, IsBold = false, WithSuperscript = false, }); } if (construction.HasDynamicLoad) { arr.Add(new ListText { Text = "Динамическая нагрузка", LevelNum = 5, IsBold = false, WithSuperscript = false, }); } if (construction.HasFlangedConnections) { arr.Add(new ListText { Text = "Фланцевые соединения", LevelNum = 5, IsBold = false, WithSuperscript = false, }); } if (construction.WeldingControl.Id > 1) { arr.Add(new ListText { Text = $"Контроль плотности сварных швов {construction.WeldingControl.Name}", LevelNum = 5, IsBold = false, WithSuperscript = false, }); } var constructionElements = _constructionElementRepo.GetAllByConstructionId(construction.Id); if (constructionElements.Count() > 0) { var groupedSteel = constructionElements.Where( v => v.Steel != null).GroupBy(v => v.Steel).Select( v => new GroupedSteel { Name = v.First().Steel.Name, Length = v.Sum(v => v.Length), Weight = v.Sum(v => v.Profile.Weight), Area = v.Sum(v => v.Profile.Area), }); arr.Add(new ListText { Text = "в том числе по маркам стали:", LevelNum = 5, IsBold = false, WithSuperscript = false, }); double initialWeightSum = 0.0; double areaSum = 0.0; foreach (var s in groupedSteel) { // var initialWeightValue = s.Weight * s.Length * 0.001; // var initialWeightValueRounded = Math.Ceiling(initialWeightValue * 1000) / 1000; var initialWeightValueRounded = Math.Ceiling( s.Weight * s.Length) / 1000; var finalWeightValueRounded = Math.Ceiling( initialWeightValueRounded * 1040) / 1000; arr.Add(new ListText { // Text = $"{s.Name} {initialWeightValueRounded} x 1,04 = {Math.Ceiling(initialWeightValueRounded * 1.04 * 1000) / 1000} т", Text = $"{s.Name} {initialWeightValueRounded.ToStringWithComma()} x 1,04 = {finalWeightValueRounded.ToStringWithComma()} т", LevelNum = 6, IsBold = false, WithSuperscript = false, }); // initialWeightSum += initialWeightValue; initialWeightSum += initialWeightValueRounded; areaSum += s.Area * s.Length; } overallInitialWeightSum += initialWeightSum; var initialWeightSumRounded = Math.Ceiling( initialWeightSum * 1000) / 1000; var finalWeightSumRounded = Math.Ceiling( initialWeightSumRounded * 1040) / 1000; arr.Add(new ListText { // Text = $"Итого масса металла: {initialWeightSumRounded} x 1,04 = {Math.Ceiling(initialWeightSumRounded * 1.04 * 1000) / 1000} т", Text = $"Итого масса металла: {initialWeightSumRounded.ToStringWithComma()} x 1,04 = {finalWeightSumRounded.ToStringWithComma()} т", LevelNum = 5, IsBold = false, WithSuperscript = false, }); var areaSumRounded = Math.Round(areaSum, 3); // overallAreaSum += areaSum; overallAreaSum += areaSumRounded; arr.Add(new ListText { // Text = $"Площадь поверхности для окраски: {Math.Round(areaSum, 3).ToStringWithComma()} x 100 м^2", Text = $"Площадь поверхности для окраски: {areaSumRounded.ToStringWithComma()} x 100 м^2", LevelNum = 5, IsBold = false, WithSuperscript = true, }); arr.Add(new ListText { // Text = $"Относительная площадь окраски: {Math.Round(areaSum * 100 / (initialWeightSum * 1.04), 3).ToStringWithComma()} м^2/т", Text = $"Относительная площадь окраски: {Math.Round(areaSumRounded * 100 / (initialWeightSumRounded * 1.04), 1).ToStringWithComma()} м^2/т", LevelNum = 5, IsBold = false, WithSuperscript = true, }); } } foreach (var standardConstruction in standardConstructions) { arr.Add(new ListText { Text = $"{standardConstruction.Name}: {(Math.Ceiling(standardConstruction.Weight * 1000) / 1000).ToStringWithComma()} т", LevelNum = 1, IsBold = false, WithSuperscript = false, }); } arr.Add(new ListText { Text = "Окраска конструкций", LevelNum = 0, IsBold = true, WithSuperscript = false, }); var overallInitialWeightSumRounded = Math.Ceiling( overallInitialWeightSum * 1000) / 1000; var overallFinalWeightSumRounded = Math.Ceiling( overallInitialWeightSumRounded * 1040) / 1000; arr.Add(new ListText { // Text = $"Масса металла для окраски: {Math.Round(overallInitialWeightSum, 3)} x 1,04 = {Math.Round(Math.Round(overallInitialWeightSum, 3) * 1.04, 3)} т", Text = $"Масса металла для окраски: {overallInitialWeightSumRounded.ToStringWithComma()} x 1,04 = {overallFinalWeightSumRounded.ToStringWithComma()} т", LevelNum = 4, IsBold = false, WithSuperscript = false, }); arr.Add(new ListText { Text = $"Площадь поверхности для окраски: {Math.Round(overallAreaSum, 3).ToStringWithComma()} x 100 м^2", LevelNum = 4, IsBold = false, WithSuperscript = true, }); var points = _markGeneralDataPointRepo.GetAllByMarkAndSectionId( markId, _paintingGeneralDataSectionId); for (int i = 1; i < points.Count(); i++) { var pointText = points.ToList()[i].Text; if (pointText[0] == '#' && pointText[1] == ' ') { pointText = pointText.Substring(2) + "."; } else if (pointText[0] == '-' && pointText[1] == ' ') { pointText = pointText.Substring(2) + "."; } arr.Add(new ListText { Text = pointText, LevelNum = 3, IsBold = false, WithSuperscript = false, }); } if (estTask.AdditionalText != null && estTask.AdditionalText != "") { arr.Add(new ListText { Text = "Дополнительно", LevelNum = 0, IsBold = true, WithSuperscript = false, }); var split = estTask.AdditionalText.Split("\n"); foreach (var splitText in split) { arr.Add(new ListText { Text = splitText, LevelNum = 3, IsBold = false, WithSuperscript = false, }); } } AppendList(wordDoc, arr); Word.AppendToBigFooterTable( wordDoc, markName, complexName, objectName, -1, mark, markApprovals.ToList(), departmentHead); Word.AppendToSmallFooterTable(wordDoc, markName); } }
public Mark GetById(int id) { return(_repository.GetById(id)); }
public void PopulateDocument(int markId, MemoryStream memory) { var mark = _markRepo.GetById(markId); if (mark == null) { throw new ArgumentNullException(nameof(mark)); } var markApprovals = _markApprovalRepo.GetAllByMarkId(markId); var subnode = mark.Subnode; var node = subnode.Node; var project = node.Project; var departmentHead = _employeeRepo.GetByDepartmentIdAndPosition( mark.Department.Id, _appSettings.DepartmentHeadPosId); if (departmentHead == null) { departmentHead = _employeeRepo.GetByDepartmentIdAndPosition( mark.Department.Id, _appSettings.ActingDepartmentHeadPosId); } if (departmentHead == null) { departmentHead = _employeeRepo.GetByDepartmentIdAndPosition( mark.Department.Id, _appSettings.DeputyDepartmentHeadPosId); } if (departmentHead == null) { departmentHead = _employeeRepo.GetByDepartmentIdAndPosition( mark.Department.Id, _appSettings.ActingDeputyDepartmentHeadPosId); } if (departmentHead == null) { throw new ConflictException(); } var opCond = _markOperatingConditionsRepo.GetByMarkId(markId); if (opCond == null) { throw new ArgumentNullException(nameof(opCond)); } var markGeneralDataPoints = _markGeneralDataPointRepo.GetAllByMarkId( markId).OrderByDescending( v => v.Section.OrderNum).ThenByDescending(v => v.OrderNum); var sheets = _docRepo.GetAllByMarkIdAndDocType(markId, _sheetDocTypeId); using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(memory, true)) { var markName = MarkHelper.MakeMarkName( project.BaseSeries, node.Code, subnode.Code, mark.Code); (var complexName, var objectName) = MarkHelper.MakeComplexAndObjectName( project.Name, node.Name, subnode.Name, mark.Name); AppendList(wordDoc, markGeneralDataPoints, opCond); AppendToSheetTable(wordDoc, sheets.ToList()); AppendToLinkedAndAttachedDocsTable( wordDoc, _markLinkedDocRepo.GetAllByMarkId(markId).ToList(), _attachedDocRepo.GetAllByMarkId(markId).ToList()); Word.AppendToBigFooterTable( wordDoc, markName, complexName, objectName, sheets.Count(), mark, markApprovals.ToList(), departmentHead); Word.AppendToSmallFooterTable(wordDoc, markName); } }
public void Create( Doc doc, int markId, int docTypeId, int creatorId, int?inspectorId, int?normContrId) { if (doc == null) { throw new ArgumentNullException(nameof(doc)); } var foundMark = _markRepo.GetById(markId); if (foundMark == null) { throw new ArgumentNullException(nameof(foundMark)); } doc.Mark = foundMark; var foundDocType = _docTypeRepo.GetById(docTypeId); if (foundDocType == null) { throw new ArgumentNullException(nameof(foundDocType)); } doc.Type = foundDocType; var docs = _repository.GetAllByMarkIdAndDocType(markId, docTypeId); int maxNum = 0; foreach (var s in docs) { if (s.Num > maxNum) { maxNum = s.Num; } } doc.Num = (Int16)(maxNum + 1); var creator = _employeeRepo.GetById(creatorId); if (creator == null) { throw new ArgumentNullException(nameof(creator)); } doc.Creator = creator; if (inspectorId != null) { var inspector = _employeeRepo.GetById(inspectorId.GetValueOrDefault()); if (inspector == null) { throw new ArgumentNullException(nameof(inspector)); } doc.Inspector = inspector; } if (normContrId != null) { var normContr = _employeeRepo.GetById(normContrId.GetValueOrDefault()); if (normContr == null) { throw new ArgumentNullException(nameof(normContr)); } doc.NormContr = normContr; } _repository.Add(doc); foundMark.EditedDate = DateTime.Now; _markRepo.Update(foundMark); }