Example #1
0
        public void WriteToDrawingsStandartsRates(Drawing drawing, StandartDrawing standart)
        {
            if (standart != null)
            {
                var drawsRatesDm = _dataManagersFactory.GetDataManager<WorkHourDrawing>();
                var drawsStandartRatesDm = _dataManagersFactory.GetDataManager<WorkHourStandartDrawing>();

                var rates = drawsStandartRatesDm.GetListCollection().Where(x => x.StandartDrawingId == standart.Id);
                foreach (var rate in rates)
                {
                    var drawRate = new WorkHourDrawing();
                    drawRate.TechOperationId = rate.TechOperationId;
                    drawRate.DrawingId = drawing.Id.Value;
                    drawRate.WorkHour = rate.WorkHour;
                    drawRate.Type = TypeWorkHourDrawing.Ssi;
                    drawsRatesDm.Insert(drawRate);
                }
            }
        }
        public WorkHourDrawing InsertWorkHourDrawing(TicketAutUser ticket, WorkHourDrawing doc)
        {
            _logger.Trace("Trace method Insert for document: {0}. User: {1}", typeof(WorkHourDrawing).Name, ticket);
            var filterDrawing = Builders <BsonDocument> .Filter.Eq("DrawingId", doc.DrawingId);

            var filtetTechOper = Builders <BsonDocument> .Filter.Eq("TechOperationId", doc.TechOperationId);

            var filter = Builders <BsonDocument> .Filter.And(filterDrawing, filtetTechOper);

            _dataManagers.Delete(doc.GetType(), filter);
            if (doc.WorkHour > 0)
            {
                _dataManagers.Insert(doc, ticket);
            }
            else
            {
                doc.Id = null;
            }

            return(doc);
        }
 public void DeleteWorkHourDrawing(TicketAutUser ticket, WorkHourDrawing doc)
 {
     _logger.Trace("Trace method Delete for document: {0}. Id: {2}. User: {1}", typeof(WorkHourDrawing).Name, ticket, doc.Id);
     _dataManagers.Delete(doc, ticket);
 }
 public List <HistoryRecord <WorkHourDrawing> > GetHistoryDocWorkHourDrawing(WorkHourDrawing doc)
 {
     _logger.Trace("Trace method GetHistoryList for document: {0}", typeof(WorkHourDrawing).Name);
     return(_historyManager.GetHistoryDoc(doc));
 }
        public void RefreshRatesByProfiles(int? drawingId)
        {
            var dataManager = _dataManagersFactory.GetDrawingsHierClassDataManager();
            var profileWorkHour = _dataManagersFactory.GetDataManager<ProfileWorkHour>();
            var profileWorkHours = profileWorkHour.GetListCollection();
            var drawsRatesDm = _dataManagersFactory.GetDataManager<WorkHourDrawing>();
            var techRoutesDm = _dataManagersFactory.GetDataManager<TechRoute>();

            var childrens = dataManager.GetListAllChildrens(drawingId);
            var profilesComparer = new ProfileComparer();
            var standartSizeSplitter = new StandartSizeSplitter();

            foreach (var drawing in childrens.Where(x=>x.TechRouteId != null))
            {
                var techRoute = techRoutesDm.GetDocument(drawing.TechRouteId);
                if (techRoute == null)
                    continue;

                foreach (var techOper in techRoute.TechOperations)
                {
                    // ищем расчитываемые профиля по тех. операции и названию профиля
                    var profiles = profileWorkHours.Where(x => x.TechOperationId == techOper.Id && profilesComparer.Compare(x.Profile, drawing.Profile) == 0).ToList();
                    if (profiles.Count == 0)
                        continue;

                    var profilesByStandartSize = profiles.Where(x => x.StandartSizesList.Any(y => drawing.StandartSize.StartsWith(y))).ToList();

                    if (profilesByStandartSize.Count == 0)
                        continue;

                    if (profilesByStandartSize.All(x => x.Gosts != null && x.Gosts.Count > 0))
                    {
                        var gostsProfiles = profilesByStandartSize.FirstOrDefault(x => x.Gosts.Any(y => y.Name == drawing.GostOnSort));
                        if (gostsProfiles != null)
                        {
                            var drawRate = new WorkHourDrawing();
                            drawRate.TechOperationId = techOper.Id.Value;
                            drawRate.DrawingId = drawing.Id.Value;
                            drawRate.WorkHour = gostsProfiles.WorkHour;
                            drawRate.Type = TypeWorkHourDrawing.Calculated;
                            drawsRatesDm.Insert(drawRate);
                        }
                    }
                    else
                    {
                        var profileRate = profilesByStandartSize.FirstOrDefault(x => x.Gosts == null || x.Gosts.Count == 0);
                        var drawRate = new WorkHourDrawing();
                        drawRate.TechOperationId = techOper.Id.Value;
                        drawRate.DrawingId = drawing.Id.Value;
                        drawRate.WorkHour = profileRate.WorkHour;
                        drawRate.Type = TypeWorkHourDrawing.Calculated;
                        drawsRatesDm.Insert(drawRate);
                    }

                }
            }
        }
 public void RemoveRateWorkHour(int drawId, int toId)
 {
     var workHourDrawing = new WorkHourDrawing {DrawingId = drawId, TechOperationId = toId};
     _workHoursDataManager.Insert(workHourDrawing);
     _workHoursDataManager.Delete(workHourDrawing);
 }
 public void CreateRateWorkHour(WorkHourDrawing workHourDrawing)
 {
     _workHoursDataManager.InsertOrUpdate(workHourDrawing);
 }