Ejemplo n.º 1
0
 private void fillParameters(IBaseEntityObject firstItem, IBaseEntityObject secondItem)
 {
     FirstItemId      = firstItem.ItemId;
     FirtsItemTypeId  = firstItem.SmartCoreObjectType.ItemId;
     SecondItemId     = secondItem.ItemId;
     SecondItemTypeId = secondItem.SmartCoreObjectType.ItemId;
 }
Ejemplo n.º 2
0
        public int GetHashCode(IBaseEntityObject lifelength)
        {
            if (ReferenceEquals(lifelength, null) == true)
            {
                return(0);
            }
            int itemTypeHash = SmartCoreObjectType.ItemId.GetHashCode();
            int itemIdHash   = ItemId.GetHashCode();

            return(itemTypeHash ^ itemIdHash);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// проверяет наличие объекта в списке объект
 /// </summary>
 /// <param name="coreObject"></param>
 bool ICommonCollection.Contains(IBaseEntityObject coreObject)
 {
     if (coreObject == null)
     {
         throw new ArgumentNullException("coreObject", "must be not null");
     }
     if (coreObject is T)
     {
         return(Contains(coreObject as T));
     }
     throw new ArgumentException("must be not of type:" + typeof(T), "coreObject");
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Осуществляет поиск указанного объекта и возвращает отсчитываемый от нуля индекс первого вхождения,
 /// найденного в пределах всего списка.
 /// </summary>
 /// <param name="item"></param>
 int ICommonCollection.IndexOf(IBaseEntityObject item)
 {
     if (item == null)
     {
         throw new ArgumentNullException("item", "must be not null");
     }
     if (item is T)
     {
         return(IndexOf(item as T));
     }
     throw new ArgumentException("must be not of type:" + typeof(T), "item");
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Сравнивает детали имебщиеся в коллекции с добавляемой по их ID
 /// если деталь с подобным ID в коллекции не существует,
 /// то она добавляется в коллекцию и возвращается true
 /// ежели деталь с подобным ID в коллекции есть
 /// то она НЕ добавляется в коллекцию и возвращается false
 /// </summary>
 /// <param name="addedObject"></param>
 bool ICommonCollection.CompareAndAdd(IBaseEntityObject addedObject)
 {
     if (addedObject == null)
     {
         throw new ArgumentNullException("addedObject", "must be not null");
     }
     if (addedObject is T)
     {
         return(CompareAndAdd(addedObject as T));
     }
     throw new ArgumentException("must be not of type:" + typeof(T), "addedObject");
 }
Ejemplo n.º 6
0
        private string GetToolTipString(IBaseEntityObject obj)
        {
            var toolTip = "";
            IBaseEntityObject parent = null;

            if (obj is NextPerformance)
            {
                var nextPerformance = obj as NextPerformance;
                parent = nextPerformance.Parent;
                if (_currentWorkPackage.Status != WorkPackageStatus.Closed)
                {
                    if (nextPerformance.BlockedByPackage != null)
                    {
                        toolTip = $"This performance blocked by work package: {nextPerformance.BlockedByPackage.Title}";
                    }
                }
                else
                {
                    toolTip = "Performance for this directive within this work package is not entered.";
                    if (nextPerformance.BlockedByPackage != null)
                    {
                        toolTip += "\nThis performance blocked by work package:" +
                                   nextPerformance.BlockedByPackage.Title +
                                   "\nFirst, enter the performance of this directive as part of this work package ";
                    }
                }
            }
            else if (obj is AbstractPerformanceRecord)
            {
                parent = ((AbstractPerformanceRecord)obj).Parent;
            }
            else
            {
                parent = obj;
                if (!(obj is NonRoutineJob))
                {
                    toolTip = "Performance for this directive can not be calculated";
                }
            }

            if (parent.IsDeleted)
            {
                if (toolTip.Trim() != "")
                {
                    toolTip += "\n";
                }
                toolTip += $"This {parent.SmartCoreObjectType} is deleted";
            }

            return(toolTip);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Пытается получить Склад для всех типов объектов
        /// </summary>
        /// <param name="parent"></param>
        /// <returns></returns>
        public Store GetParentStore(IBaseEntityObject parent)
        {
            if (parent == null)
            {
                return(null);
            }

            var storeId = -1;

            if (parent is ComponentDirective)
            {
                var componentDirective = parent as ComponentDirective;
                if (componentDirective.ParentComponent != null)
                {
                    storeId = componentDirective.ParentComponent.ParentStoreId;
                }
                else
                {
                    throw new Exception($"0927: Parent object is not set to component directive {componentDirective.ItemId}");
                }
            }
            if (parent is Directive)
            {
                var directive = parent as Directive;
                if (directive.ParentBaseComponent != null)
                {
                    storeId = directive.ParentBaseComponent.ParentStoreId;
                }
                else
                {
                    throw new Exception($"1156: Parent object is not set to directive {directive.ItemId}");
                }
            }
            if (parent is BaseComponent)
            {
                var baseComponent = parent as BaseComponent;
                storeId = baseComponent.ParentStoreId;
            }
            if (parent is Entities.General.Accessory.Component)
            {
                var component = parent as Entities.General.Accessory.Component;
                storeId = component.ParentStoreId;
            }
            if (parent is MaintenanceCheck)
            {
                storeId = -1;
            }

            return(getStoreById(storeId));
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Удаляет объект из списка
 /// </summary>
 /// <param name="removedObject"></param>
 void ICommonCollection.Remove(IBaseEntityObject removedObject)
 {
     if (removedObject == null)
     {
         return;
     }
     if (removedObject is T)
     {
         Remove(removedObject as T);
     }
     else
     {
         throw new ArgumentException("must be not of type:" + typeof(T), "removedObject");
     }
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Добавляет объект в коллекцию
 /// </summary>
 /// <param name="addedObject"></param>
 void ICommonCollection.Add(IBaseEntityObject addedObject)
 {
     if (addedObject == null)
     {
         throw new ArgumentNullException("addedObject", "must be not null");
     }
     if (addedObject is T)
     {
         Add(addedObject as T);
     }
     else
     {
         throw new ArgumentException("must be not of type:" + typeof(T), "addedObject");
     }
 }
Ejemplo n.º 10
0
        private AttachedFile GetItemFile(IBaseEntityObject obj)
        {
            if (obj is Directive)
            {
                return(((Directive)obj).EngineeringOrderFile);
            }
            if (obj is MaintenanceDirective)
            {
                return(((MaintenanceDirective)obj).TaskCardNumberFile);
            }
            if (obj is NonRoutineJob)
            {
                return(((NonRoutineJob)obj).AttachedFile);
            }

            return(null);
        }
Ejemplo n.º 11
0
        public bool Equals(IBaseEntityObject other)
        {
            //Без переопределения метода GetHashCode данный метод не работает
            //Почему? - ХЗ

            //Check whether the compared object is null.
            if (ReferenceEquals(other, null))
            {
                return(false);
            }

            //Check whether the compared object references the same data.
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            //Check whether the products' properties are equal.
            return(SmartCoreObjectType.ItemId == other.SmartCoreObjectType.ItemId && ItemId == other.ItemId);
        }
Ejemplo n.º 12
0
        public bool Equals(IBaseEntityObject x, IBaseEntityObject y)
        {
            //Без переопределения метода GetHashCode(BaseEntityObject) данный метод не работает
            //Почему? - ХЗ

            //Check whether the compared object references the same data.
            if (ReferenceEquals(x, y))
            {
                return(true);
            }

            //Check whether the compared object is null.
            if (ReferenceEquals(x, null) || ReferenceEquals(y, null))
            {
                return(false);
            }

            //Check whether the products' properties are equal.
            return(x.SmartCoreObjectType.ItemId == y.SmartCoreObjectType.ItemId && x.ItemId == y.ItemId);
        }
Ejemplo n.º 13
0
        private string GetParent(NextPerformance np)
        {
            IBaseEntityObject parent = np.Parent;
            var destination          = "";

            if (parent is Directive)
            {
                var dir = (Directive)parent;
                destination = GetDestination(dir.ParentBaseComponent.ParentAircraftId, dir.ParentBaseComponent.ParentStoreId);
            }
            else if (parent is Component)
            {
                var d = (Component)parent;
                destination = GetDestination(d.ParentBaseComponent.ParentAircraftId, d.ParentStoreId);
            }
            else if (parent is ComponentDirective)
            {
                var dd = (ComponentDirective)parent;

                if (dd.ParentComponent != null)
                {
                    destination = GetDestination(dd.ParentBaseComponent.ParentAircraftId, dd.ParentBaseComponent.ParentAircraftId);
                }
            }
            else if (parent is MaintenanceCheck)
            {
                var mc = (MaintenanceCheck)parent;
                destination = $"{mc.ParentAircraft.RegistrationNumber} {mc.ParentAircraft.Model}";//TODO:(Evgenii Babak) заменить на использование AircraftCore
            }
            else if (parent is MaintenanceDirective)
            {
                var md = (MaintenanceDirective)parent;
                destination = GetDestination(md.ParentBaseComponent.ParentAircraftId, md.ParentBaseComponent.ParentStoreId);
            }
            return(destination);
        }
Ejemplo n.º 14
0
 private bool GetItemEnabled(IBaseEntityObject obj)
 {
     return(GetItemFile(obj) != null);
 }
Ejemplo n.º 15
0
        private string GetAccomplich(IEnumerable <WorkPackageRecord> workPakageRecords)
        {
            var groups = new List <string>();

            foreach (var workPackageRecord in workPakageRecords)
            {
                IBaseEntityObject parent = workPackageRecord.Task;

                if (parent is Directive)
                {
                    var directive = (Directive)parent;
                    if (directive is DeferredItem)
                    {
                        groups.Add("Deffred");
                    }
                    else if (directive is DamageItem)
                    {
                        groups.Add("Damage");
                    }
                    else if (directive.DirectiveType == DirectiveType.OutOfPhase)
                    {
                        groups.Add("Out of phase");
                    }
                    else
                    {
                        if (directive.DirectiveType.ItemId == DirectiveType.AirworthenessDirectives.ItemId)
                        {
                            groups.Add("AD");
                        }
                        else if (directive.DirectiveType.ItemId == DirectiveType.EngineeringOrders.ItemId)
                        {
                            groups.Add("EO");
                        }
                        else if (directive.DirectiveType.ItemId == DirectiveType.SB.ItemId)
                        {
                            groups.Add("SB");
                        }
                    }
                }
                else if (parent is BaseComponent)
                {
                    groups.Add("Base Component");
                }
                else if (parent is Component)
                {
                    groups.Add("Component");
                }
                else if (parent is ComponentDirective)
                {
                    groups.Add("Component directive");
                }
                else if (parent is MaintenanceCheck)
                {
                    groups.Add("MC");
                }
                else if (parent is MaintenanceDirective)
                {
                    groups.Add("MPD");
                }
                else if (parent is NonRoutineJob)
                {
                    groups.Add("NRJ");
                }
            }
            return(string.Join("+", groups.Distinct().ToArray()));
        }
Ejemplo n.º 16
0
 public void FillParameters(IBaseEntityObject firstItem, IBaseEntityObject secondItem, WorkItemsRelationType workItemsRelationType)
 {
     fillParameters(firstItem, secondItem);
     RelationTypeId = workItemsRelationType;
 }
Ejemplo n.º 17
0
 public void FillParameters(IBaseEntityObject firstItem, IBaseEntityObject secondItem)
 {
     fillParameters(firstItem, secondItem);
 }
Ejemplo n.º 18
0
        /// <summary>
        /// Пытается получить Aircraft для всех типов объектов
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public Aircraft GetParentAircraft(IBaseEntityObject item)
        {
            if (item == null)
            {
                return(null);
            }

            IBaseEntityObject parent;

            if (item is NextPerformance)
            {
                parent = ((NextPerformance)item).Parent;
            }
            else if (item is AbstractPerformanceRecord)
            {
                parent = ((AbstractPerformanceRecord)item).Parent;
            }
            else
            {
                parent = item;
            }

            if (parent == null)
            {
                return(null);
            }

            if (parent is ComponentDirective)
            {
                // ComponentDirective может ссылаться либо на BaseComponent либо на Component
                var componentDirective = parent as ComponentDirective;
                if (componentDirective.ParentComponent != null)
                {
                    return(_aircrafts.GetItemById(componentDirective.ParentComponent.ParentAircraftId));
                }
                throw new Exception($"0927: Parent object is not set to component directive {componentDirective.ItemId}");
            }
            if (parent is Directive)
            {
                // Directive может ссылаться либо на BaseComponent либо на Component
                var directive = parent as Directive;
                if (directive.ParentBaseComponent != null)
                {
                    return(_aircrafts.GetItemById(directive.ParentBaseComponent.ParentAircraftId));
                }
                throw new Exception($"1156: Parent object is not set to directive {directive.ItemId}");
            }
            if (parent is BaseComponent)
            {
                var baseComponent = parent as BaseComponent;
                return(_aircrafts.GetItemById(baseComponent.ParentAircraftId));
            }
            if (parent is Entities.General.Accessory.Component)
            {
                var component = parent as Entities.General.Accessory.Component;
                return(_aircrafts.GetItemById(component.ParentAircraftId));
            }
            if (parent is MaintenanceCheck)
            {
                // MaintenanceCheck может ссылаться либо на BaseComponent либо на Component
                var mc = parent as MaintenanceCheck;
                return(_aircrafts.GetItemById(mc.ParentAircraftId));
            }
            if (parent is MaintenanceDirective)
            {
                // MaintenanceDirective может ссылаться либо на BaseComponent либо на Component
                var directive = parent as MaintenanceDirective;
                if (directive.ParentBaseComponent != null)
                {
                    return(_aircrafts.GetItemById(directive.ParentBaseComponent.ParentAircraftId));
                }
                throw new Exception($"1156: Parent object is not set to directive {directive.ItemId}");
            }
            return(null);
        }
Ejemplo n.º 19
0
 public string GetCorrector(IBaseEntityObject entity)
 {
     return(Users.ContainsKey(entity.CorrectorId) ?
            $"{Users[entity.CorrectorId]} ({Auxiliary.Convert.GetDateFormat(entity.Updated)} {entity.Updated.TimeOfDay.Hours}:{entity.Updated.TimeOfDay.Minutes}:{entity.Updated.TimeOfDay.Seconds})"
         : "Unknown");
 }