示例#1
0
        /// <summary>
        /// Публикует рабочий пакет - выдает рабочий пакет на перрон
        /// </summary>
        /// <param name="wp"></param>
        /// <param name="date"></param>
        /// <param name="remarks"></param>
        public void Publish <T, TV>(T wp, DateTime date, string remarks)
            where T : AbstractDirectivePackage <TV>, new()
            where TV : BaseDirectivePackageRecord, new()
        {
            if (wp.Status != WorkPackageStatus.Closed)
            {
                wp.Status         = WorkPackageStatus.Published;
                wp.PublishingDate = date;
                wp.PublishedBy    = _casEnvironment.IdentityUser.Login;
                wp.Remarks        = remarks;
            }
            else
            {
                LoadDirectivePackageItems <T, TV>(wp);

                foreach (IDirective item in wp.PackageRecords.Where(pr => pr.Task != null).Select(pr => pr.Task))
                {
                    var records = new List <AbstractPerformanceRecord>(item.PerformanceRecords.OfType <AbstractPerformanceRecord>().ToArray());
                    foreach (AbstractPerformanceRecord record in records)
                    {
                        if (record.DirectivePackageId == wp.ItemId)
                        {
                            _casEnvironment.Manipulator.Delete(record);
                        }
                    }
                }

                wp.Status         = WorkPackageStatus.Published;
                wp.PublishingDate = date;
                wp.PublishedBy    = _casEnvironment.IdentityUser.Login;
                wp.ClosedBy       = "";
            }

            _newKeeper.Save(wp);
        }
示例#2
0
        /// <summary>
        /// Добавляет чек обслуживания на воздушное судно
        /// </summary>
        /// <param name="check"></param>
        /// <param name="aircraft"></param>
        public void AddMaintenanceCheck(MaintenanceCheck check, Aircraft aircraft)
        {
            if (aircraft.ItemId <= 0)
            {
                throw new Exception("0947: Can not save check to not existing aircraft");
            }

            check.ParentAircraft   = aircraft;
            check.ParentAircraftId = aircraft.ItemId;
            // Сохраняем базовый агрегат
            _newKeeper.Save(check);
        }
示例#3
0
        public void RegisterAircraft(Aircraft aircraft, int operatorId)
        {
            if (operatorId <= 0)
            {
                throw new Exception("1650: Can not add aircraft to not existing operator");
            }

            // Сохраняем воздушное судно в базе
            aircraft.OperatorId = operatorId;
            _newKeeper.Save(aircraft);

            _aircrafts.Add(aircraft);
        }
示例#4
0
文件: DocumentCore.cs 项目: jecus/Cas
 public void SaveDocumentsList(BaseEntityObject parent, IList <Document> unsavedDocuments)
 {
     foreach (var unsavedDocument in unsavedDocuments)
     {
         _newKeeper.Save(unsavedDocument);
     }
 }
示例#5
0
        public void CreateCopyFromExistPlan(FlightPlanOps currentPlanOps)
        {
            var records = loadOpsRecordsByPlanOpsId(currentPlanOps.ItemId);

            var copyPlanOps = currentPlanOps.GetCopyUnsaved();

            _newKeeper.Save(copyPlanOps);

            var newRecords = CalculateTripForPeriod(copyPlanOps);

            foreach (var newRecord in newRecords)
            {
                var track = records.FirstOrDefault(i => i.FlightTrackRecordId == newRecord.FlightTrackRecordId);
                if (track != null)
                {
                    newRecord.AircraftId         = track.AircraftId;
                    newRecord.AircraftExchangeId = track.AircraftExchangeId;
                }
                _newKeeper.Save(newRecord);
            }
        }
示例#6
0
        /// <summary>
        /// Добавляет DamageChart на воздушное судно
        /// </summary>
        /// <param name="damageDocument"></param>
        public void AddDamageDocument(DamageDocument damageDocument)
        {
            // Дополняем необходимые свойства и сохраняем в базе данных
            _newKeeper.Save(damageDocument);

            List <DamageSector> sectorsToDelete = new List <DamageSector>();

            foreach (DamageSector damageSector in damageDocument.DamageSectors)
            {
                _newKeeper.Save(damageSector);

                if (damageSector.IsDeleted)
                {
                    sectorsToDelete.Add(damageSector);
                }
            }

            foreach (DamageSector sector in sectorsToDelete)
            {
                damageDocument.DamageSectors.Remove(sector);
            }
        }
示例#7
0
        /// <summary>
        /// Удаление TransferRecord
        /// </summary>
        /// <param name="transferRecord"></param>
        public void Delete(TransferRecord transferRecord)
        {
            // Ограничение - если у агрегата только одна transfer record - мы не можем ее удалить ...
            // Добавление & удаление transfer record влияет на математический аппарат
            // Обнуляем математический аппарат
            if (transferRecord.ParentComponent != null)
            {
                if (transferRecord.ParentComponent.TransferRecords.Count == 1)
                {
                    throw new Exception("1153: Can not delete single transfer record");
                }

                if (transferRecord.ConsumableId > 0)
                {
                    //Поиск комплектующего, часть которого была перемещена данной записью
                    Entities.General.Accessory.Component fromConsumable = _componentCore.GetBaseComponentById(transferRecord.ConsumableId)
                                                                          ?? _componentCore.GetComponentById(transferRecord.ConsumableId);
                    if (fromConsumable != null)
                    {
                        //комплектующее найдено
                        //Проверка, находится ли то комплектующее, часть которого была перемещена
                        //на той же локации, с которой была перемещена данная часть
                        TransferRecord consumLocation = fromConsumable.TransferRecords.GetLast();
                        if (consumLocation != null &&
                            ((consumLocation.DestinationObjectType == SmartCoreType.BaseComponent &&
                              consumLocation.DestinationObjectId == transferRecord.FromBaseComponentId) ||
                             (consumLocation.DestinationObjectType == SmartCoreType.Aircraft &&
                              consumLocation.DestinationObjectId == transferRecord.FromAircraftId) ||
                             (consumLocation.DestinationObjectType == SmartCoreType.Store &&
                              consumLocation.DestinationObjectId == transferRecord.FromStoreId)))
                        {
                            //Если последняя точка назначения исходного комплектующего
                            //совпадает с отправной точкой данной части исходного комплектующего
                            //то необходимо удалить данную часть комплектующуго, а кол-во
                            //перемещенных единиц добавить к исходному комплектующему
                            transferRecord.ParentComponent.IsDeleted = true;
                            _newKeeper.Delete(transferRecord.ParentComponent, true, false);

                            fromConsumable.Quantity += transferRecord.ParentComponent.Quantity > 0
                                                                                                                   ? transferRecord.ParentComponent.Quantity
                                                                                                                   : 1;
                            _componentCore.Save(fromConsumable);
                        }
                        else
                        {
                            // Иначе, если не найдена последняя запись о перемещении
                            // исходного расходника или
                            // если исходный расходник был перемещен с отправной точки данной части
                            // то нужно произвести простой откат данной записи о перемещении

                            // Сохраняем запись
                            transferRecord.IsDeleted = true;
                            _newKeeper.Save(transferRecord);
                            transferRecord.ParentComponent.TransferRecords.Remove(transferRecord);

                            // Обновляем состояние объекта
                            _componentCore.SetDestinations(transferRecord.ParentComponent);

                            if (transferRecord.ParentComponent is BaseComponent)
                            {
                                _calculator.ResetMath((BaseComponent)transferRecord.ParentComponent);
                            }
                        }
                    }
                    else
                    {
                        // если исходный расходник не найден
                        // то нужно произвести простой откат данной записи о перемещении

                        // Сохраняем запись
                        transferRecord.IsDeleted = true;
                        _newKeeper.Save(transferRecord);
                        transferRecord.ParentComponent.TransferRecords.Remove(transferRecord);

                        // Обновляем состояние объекта
                        _componentCore.SetDestinations(transferRecord.ParentComponent);

                        if (transferRecord.ParentComponent is BaseComponent)
                        {
                            _calculator.ResetMath((BaseComponent)transferRecord.ParentComponent);
                        }
                    }
                }
                else
                {
                    // Сохраняем запись
                    transferRecord.IsDeleted = true;
                    _newKeeper.Save(transferRecord);
                    transferRecord.ParentComponent.TransferRecords.Remove(transferRecord);

                    // Обновляем состояние объекта
                    _componentCore.SetDestinations(transferRecord.ParentComponent);

                    if (transferRecord.ParentComponent is BaseComponent)
                    {
                        _calculator.ResetMath((BaseComponent)transferRecord.ParentComponent);
                    }
                }
            }
            else
            {
                throw new Exception("1000: Failed to specify tranfer record parent type");
            }
        }
示例#8
0
 /// <summary>
 /// Публикует закупочный акт
 /// </summary>
 /// <param name="po"></param>
 /// <param name="date"></param>
 public void Publish(PurchaseOrder po, DateTime date)
 {
     if (po.Status != WorkPackageStatus.Closed)
     {
         po.Status         = WorkPackageStatus.Published;
         po.PublishingDate = date;
     }
     else
     {
         po.Status  = WorkPackageStatus.Published;
         po.Remarks = "";
     }
     _newKeeper.Save(po);
 }
示例#9
0
文件: KitsCore.cs 项目: mgladilov/Cas
        ///<summary>
        /// Проставляет товар и стандарт для комплектующего
        ///</summary>
        ///<returns>true - если удалось определеить и проставить продукт и стандарт для комплектующего</returns>
        public bool SetStandartAndProduct(AbstractAccessory accessory,
                                          string standartName, string partialNumber, string description, string remarks, string manufacturer,
                                          GoodsClass goodsClass, Measure measure,
                                          double costNew, double costOverhaul, double costServiceable,
                                          IEnumerable <Supplier> suppliers)
        {
            if (accessory == null)
            {
                throw new ArgumentException("must be not null", "accessory");
            }

            if (accessory.Product != null && accessory.Product.ItemId > 0)
            {
                return(true);
            }

            string       standart            = standartName.Replace(" ", "").ToLower();
            string       partNumber          = partialNumber.Replace(" ", "").ToLower();
            bool         needToSaveAccessory = false;
            bool         result       = true;
            GoodStandart goodStandart = null;

            List <GoodStandart> goodStandarts = _loader.GetObjectList <GoodStandart>();
            List <Product>      products;

            if (accessory is Entities.General.Accessory.Component)
            {
                products = new List <Product>(_loader.GetObjectList <ComponentModel>(loadChild: true).ToArray());
            }
            else
            {
                products = _loader.GetObjectList <Product>(loadChild: true);
            }
            if (goodStandarts != null && !string.IsNullOrEmpty(standart))
            {
                goodStandart = goodStandarts
                               .FirstOrDefault(ad => ad.PartNumber.Replace(" ", "").ToLower() == partNumber &&
                                               ad.FullName.Replace(" ", "").ToLower() == standart);
                if (goodStandart == null)
                {
                    goodStandart = new GoodStandart
                    {
                        GoodsClass  = goodsClass,
                        PartNumber  = partialNumber,
                        Description = description,
                        FullName    = standartName,
                        //CostNew = costNew,
                        //CostServiceable = costServiceable,
                        //CostOverhaul = costOverhaul,
                        Remarks = remarks,
                        //Measure = measure
                    };

                    _newKeeper.Save(goodStandart);
                }
                accessory.Standart = goodStandart;

                needToSaveAccessory = true;
            }
            if ((manufacturer != "" || suppliers != null && suppliers.Any()) && products != null)
            {
                Product product = products
                                  .FirstOrDefault(p => p.PartNumber.Replace(" ", "").ToLower() == partNumber &&
                                                  p.Standart != null && p.Standart.FullName.Replace(" ", "").ToLower() == standart);
                if (product == null)
                {
                    if (accessory is Entities.General.Accessory.Component)
                    {
                        ComponentModel dm = new ComponentModel
                        {
                            BatchNumber     = "",
                            CostNew         = costNew,
                            CostOverhaul    = costOverhaul,
                            CostServiceable = costServiceable,
                            Description     = description,
                            GoodsClass      = goodsClass,
                            Manufacturer    = manufacturer,
                            Measure         = measure,
                            PartNumber      = partNumber,
                            Remarks         = remarks,
                        };
                        product = dm;
                    }
                    else
                    {
                        product = new Product
                        {
                            GoodsClass      = goodsClass,
                            PartNumber      = partialNumber,
                            Description     = description,
                            Manufacturer    = manufacturer,
                            Standart        = goodStandart,
                            CostNew         = costNew,
                            CostServiceable = costServiceable,
                            CostOverhaul    = costOverhaul,
                            Remarks         = remarks,
                            Measure         = measure
                        };
                    }

                    _newKeeper.Save(product);

                    if (goodStandart != null && goodStandart.DefaultProductId <= 0)
                    {
                        goodStandart.DefaultProductId = product.ItemId;
                        _newKeeper.Save(goodStandart);
                    }

                    product.SupplierRelations.Clear();
                    foreach (KitSuppliersRelation ksr in accessory.SupplierRelations)
                    {
                        if (ksr.SupplierId != 0)
                        {
                            product.SupplierRelations.Add(ksr);
                            ksr.KitId        = product.ItemId;
                            ksr.ParentTypeId = product.SmartCoreObjectType.ItemId;

                            _newKeeper.Save(ksr);
                        }
                    }
                }

                Entities.General.Accessory.Component component = accessory as Entities.General.Accessory.Component;
                if (component != null)
                {
                    component.Model = product as ComponentModel;
                }
                else
                {
                    accessory.Product = product;
                }

                needToSaveAccessory = true;
            }
            else
            {
                accessory.Product = null;
                result            = false;
            }

            if (needToSaveAccessory)
            {
                _newKeeper.Save(accessory);
            }

            return(result);
        }
示例#10
0
        public void RegisterPerformance(IDirective directive, AbstractPerformanceRecord performance, IDirectivePackage directivePackage = null, bool registerPerformanceForBindedItems = true)
        {
            if ((directive is Entities.General.Accessory.Component))
            {
                Check((Entities.General.Accessory.Component)directive, (TransferRecord)performance);
            }
            else
            {
                Check(directive, performance);
            }

            // Не можем добавить выполнение для не существующей директивы
            if (directive.ItemId <= 0)
            {
                throw new Exception("1033: Can not register performance for not existing directive");
            }

            // Дополняем необходимые данные
            performance.ParentId = directive.ItemId;

            // Выставляем родителя записи о выполнении
            performance.Parent = directive;

            if (directivePackage != null)
            {
                performance.DirectivePackageId = directivePackage.ItemId;
                performance.AttachedFile       = directivePackage.AttachedFile;
            }

            _newKeeper.Save(performance);

            if (directive.PerformanceRecords.GetItemById(performance.ItemId) == null)
            {
                directive.PerformanceRecords.Add(performance);
            }

            if (directive is Entities.General.Accessory.Component)
            {
                var component      = directive as Entities.General.Accessory.Component;
                var transferRecord = performance as TransferRecord;
                //выставление нового родителя
                if (transferRecord.DestinationObjectType == SmartCoreType.Aircraft)
                {
                    component.ParentAircraftId = transferRecord.DestinationObjectId;
                }
                if (component.IsBaseComponent)
                {
                    //обнуление мат аппарата для этой базовой детали
                    _calculator.ResetMath((BaseComponent)component);
                }
            }

            if (!registerPerformanceForBindedItems)
            {
                return;
            }

            if (directive is MaintenanceDirective)
            {
                var mpd = directive as MaintenanceDirective;
                CreateAndSavePerformanceForBindedItems(mpd, performance);
            }
            else if (directive is ComponentDirective)
            {
                var dd = directive as ComponentDirective;
                var dr = performance as DirectiveRecord;
                CreateAndSavePerformanceForBindedItems(dd, dr);
            }
        }