private void fillParameters(IBaseEntityObject firstItem, IBaseEntityObject secondItem) { FirstItemId = firstItem.ItemId; FirtsItemTypeId = firstItem.SmartCoreObjectType.ItemId; SecondItemId = secondItem.ItemId; SecondItemTypeId = secondItem.SmartCoreObjectType.ItemId; }
public int GetHashCode(IBaseEntityObject lifelength) { if (ReferenceEquals(lifelength, null) == true) { return(0); } int itemTypeHash = SmartCoreObjectType.ItemId.GetHashCode(); int itemIdHash = ItemId.GetHashCode(); return(itemTypeHash ^ itemIdHash); }
/// <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"); }
/// <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"); }
/// <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"); }
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); }
/// <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)); }
/// <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"); } }
/// <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"); } }
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); }
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); }
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); }
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); }
private bool GetItemEnabled(IBaseEntityObject obj) { return(GetItemFile(obj) != null); }
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())); }
public void FillParameters(IBaseEntityObject firstItem, IBaseEntityObject secondItem, WorkItemsRelationType workItemsRelationType) { fillParameters(firstItem, secondItem); RelationTypeId = workItemsRelationType; }
public void FillParameters(IBaseEntityObject firstItem, IBaseEntityObject secondItem) { fillParameters(firstItem, secondItem); }
/// <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); }
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"); }