Ejemplo n.º 1
0
 public AuditForm(CAAAudit audit) : this()
 {
     _audit = audit;
     _animatedThreadWorker.DoWork             += AnimatedThreadWorkerDoLoad;
     _animatedThreadWorker.RunWorkerCompleted += BackgroundWorkerRunWorkerLoadCompleted;
     _animatedThreadWorker.RunWorkerAsync();
 }
Ejemplo n.º 2
0
        private void AnimatedThreadWorkerDoLoad(object sender, DoWorkEventArgs e)
        {
            if (_audit == null)
            {
                return;
            }

            _operators = GlobalObjects.CaaEnvironment.AllOperators;

            _updateChecks.Clear();
            _addedChecks.Clear();

            _addedChecks = GlobalObjects.CaaEnvironment.NewLoader
                           .GetObjectListAll <RoutineAuditDTO, SmartCore.CAA.RoutineAudits.RoutineAudit>(new List <Filter>()
            {
                new Filter("OperatorId", _audit.OperatorId),
            }, loadChild: true).ToList();

            if (_audit.ItemId > 0)
            {
                _audit = GlobalObjects.CaaEnvironment.NewLoader.GetObjectById <CAAAuditDTO, CAAAudit>(_audit.ItemId);

                _records = GlobalObjects.CaaEnvironment.NewLoader
                           .GetObjectListAll <CAAAuditRecordDTO, CAAAuditRecord>(new Filter("AuditId", _audit.ItemId), loadChild: true).ToList();

                var ids = _records.Select(i => i.RoutineAuditId);
                _updateChecks.AddRange(_addedChecks.Where(i => ids.Contains(i.ItemId)));

                foreach (var check in _updateChecks)
                {
                    _addedChecks.Remove(check);
                }
            }
        }
Ejemplo n.º 3
0
        public int Compare(Group <GridViewRowInfo> x, Group <GridViewRowInfo> y)
        {
            var xx = x.GetItems().FirstOrDefault()?.Tag;
            var yy = y.GetItems().FirstOrDefault()?.Tag;

            if (xx != null && yy != null)
            {
                CAAAudit xxx = null;
                CAAAudit yyy = null;

                if (xx is CAAAudit)
                {
                    xxx = xx as CAAAudit;
                }
                if (yy is CAAAudit)
                {
                    yyy = yy as CAAAudit;
                }

                var xParts = (int)xxx.Settings.Status;
                var yParts = (int)yyy.Settings.Status;;

                if (xParts == yParts)
                {
                    return(0);
                }

                return(xParts < yParts ? -1 : 1);
            }
            return(-1);
        }
Ejemplo n.º 4
0
 public CheckListAuditPublishListView(CAAAudit audit, int operatorId, CheckListAuditType type)
 {
     _audit              = audit;
     _operatorId         = operatorId;
     _type               = type;
     SortDirection       = SortDirection.Desc;
     OldColumnIndex      = 0;
     EnableCustomSorting = true;
     InitializeComponent();
 }
Ejemplo n.º 5
0
        private void AnimatedThreadWorkerDoLoad(object sender, DoWorkEventArgs e)
        {
            _operators = GlobalObjects.CaaEnvironment.AllOperators;
            _audit     = GlobalObjects.CaaEnvironment.NewLoader.GetObjectById <CAAAuditDTO, CAAAudit>(_auditId);

            var ids = _audit.Settings.Extations.Select(i => i.DocumenttId).Distinct();

            if (ids.Any())
            {
                var documents = GlobalObjects.CaaEnvironment.NewLoader.GetObjectList <CAADocumentDTO, SmartCore.Entities.General.Document>(new Filter("ItemId", ids));
                foreach (var extation in _audit.Settings.Extations)
                {
                    extation.Document = documents.FirstOrDefault(i => i.ItemId == extation.DocumenttId);
                }
            }
        }
Ejemplo n.º 6
0
        public CheckListAuditPublishListScreen(Operator currentOperator, int operatorId, CAAAudit selectedItem, CheckListAuditType type)
        {
            _operatorId   = operatorId;
            _selectedItem = selectedItem;
            _type         = type;
            InitializeComponent();

            if (currentOperator == null)
            {
                throw new ArgumentNullException("currentOperator");
            }
            aircraftHeaderControl1.Operator = currentOperator;

            _auditId = selectedItem.ItemId;
            InitListView();

            labelTitle.Text = $"Audit Status : {selectedItem.StatusName}";
            AnimatedThreadWorker.RunWorkerAsync();
        }
Ejemplo n.º 7
0
        private void AnimatedThreadWorkerDoLoad(object sender, DoWorkEventArgs e)
        {
            pelSpec.Clear();
            specialists.Clear();

            var records = GlobalObjects.CaaEnvironment.NewLoader.GetObjectListAll <AuditPelRecordDTO, AuditPelRecord>(new Filter("AuditId", _auditId));

            _audit = GlobalObjects.CaaEnvironment.NewLoader.GetObjectById <CAAAuditDTO, CAAAudit>(_auditId);

            specialists.AddRange(GlobalObjects.CaaEnvironment.NewLoader.GetObjectListAll <CAASpecialistDTO, Specialist>(new Filter("OperatorId", new [] { _audit.OperatorId, -1, _operatorId }.Distinct()), loadChild: true));

            pelSpec.AddRange(GlobalObjects.CaaEnvironment.NewLoader.GetObjectList <PelSpecialistDTO, PelSpecialist>(new Filter("AuditId", _auditId)));

            foreach (var specialist in specialists)
            {
                specialist.Operator = GlobalObjects.CaaEnvironment.AllOperators.FirstOrDefault(i => i.ItemId == specialist.OperatorId) ?? AllOperators.Unknown;
            }

            foreach (var pel in pelSpec)
            {
                pel.Specialist = specialists.FirstOrDefault(i => i.ItemId == pel.SpecialistId);
            }


            foreach (var rec in records)
            {
                var item = _addedChecks.FirstOrDefault(i => i.ItemId == rec.CheckListId);
                if (item == null)
                {
                    continue;
                }

                rec.CheckList = item;
                rec.Auditor   = pelSpec.FirstOrDefault(i => i.ItemId == rec.AuditorId)?.Specialist ?? Specialist.Unknown;
                rec.Auditee   = pelSpec.FirstOrDefault(i => i.ItemId == rec.AuditeeId)?.Specialist ?? Specialist.Unknown;
                _addedChecks.Remove(item);
                _updateChecks.Add(rec);
            }
        }
Ejemplo n.º 8
0
 public ExtationControl(Extation record, CAAAudit caaAudit) : this()
 {
     Record = record;
     _audit = caaAudit;
     UpdateInformation();
 }
Ejemplo n.º 9
0
        protected override void AnimatedThreadWorkerDoWork(object sender, DoWorkEventArgs e)
        {
            _initialDocumentArray.Clear();
            _resultDocumentArray.Clear();

            AnimatedThreadWorker.ReportProgress(0, "load directives");

            _audit = GlobalObjects.CaaEnvironment.NewLoader.GetObjectById <CAAAuditDTO, CAAAudit>(_parentId);
            var records = GlobalObjects.CaaEnvironment.NewLoader
                          .GetObjectListAll <CAAAuditRecordDTO, CAAAuditRecord>(new Filter("AuditId", _parentId), loadChild: true).ToList();

            _currentRoutineId = records.Select(i => i.RoutineAuditId).FirstOrDefault();
            _routineAudit     = GlobalObjects.CaaEnvironment.NewLoader.GetObjectById <RoutineAuditDTO, SmartCore.CAA.RoutineAudits.RoutineAudit>(_currentRoutineId.Value);
            var manuals = GlobalObjects.CaaEnvironment.NewLoader.GetObjectList <StandartManualDTO, SmartCore.CAA.StandartManual.StandartManual>(new []
            {
                new Filter("OperatorId", new [] { _operatorId, -1 }.Distinct()),
                new Filter("ProgramTypeId", _routineAudit.Settings.TypeId),
            });

            _manual = manuals.FirstOrDefault();

            var routines = GlobalObjects.CaaEnvironment.NewLoader
                           .GetObjectListAll <RoutineAuditRecordDTO, RoutineAuditRecord>(new Filter("RoutineAuditId", _currentRoutineId), loadChild: true).ToList();

            var ids = new List <int>();

            if (_type == CheckListAuditType.Admin)
            {
                if (_audit.Settings.Status == RoutineStatus.Published)
                {
                    var ds = GlobalObjects.CaaEnvironment.NewLoader.Execute($@"select CheckListId from dbo.AuditChecks 
where AuditId in ({_parentId}) and IsDeleted = 0 and WorkflowStageId = {_stage.Value}");

                    var dt = ds.Tables[0];
                    ids.AddRange(from DataRow dr in dt.Rows select(int) dr[0]);
                }
                else
                {
                    ids = routines.Select(i => i.CheckListId).Distinct().ToList();
                }
            }
            else
            {
                var condition = _stage.HasValue ? $" and ac.WorkflowStageId = {_stage}" : "";

                var ds = GlobalObjects.CaaEnvironment.NewLoader.Execute($@"SELECT rec.CheckListId
   FROM [AuditPelRecords] rec
   cross apply
   (
		select SpecialistId as Auditor from  [dbo].[PelSpecialist] where ItemId = rec.AuditorId
   ) as auditor
   cross apply
   (
		select SpecialistId as Auditee from  [dbo].[PelSpecialist] where ItemId = rec.AuditeeId
   ) as auditee
   cross apply
   (
		select JSON_VALUE(SettingsJSON, '$.WorkflowStageId') as WorkflowStageId   from  [dbo].AuditChecks 
		where AuditId = rec.AuditId and CheckListId = rec.CheckListId
   ) as ac
   where rec.AuditId in ({_parentId}) and rec.IsDeleted = 0  {condition} 
   and (auditor.Auditor = {GlobalObjects.CaaEnvironment.IdentityUser.PersonnelId} or auditee.Auditee = {GlobalObjects.CaaEnvironment.IdentityUser.PersonnelId})");

                var dt = ds.Tables[0];

                ids.AddRange(from DataRow dr in dt.Rows select(int) dr[0]);
            }


            if (ids.Any())
            {
                var filter = new List <Filter>()
                {
                    new Filter("CheckListId", ids),
                    new Filter("AuditId", _audit.ItemId)
                };

                if (_stage.HasValue)
                {
                    filter.Add(new Filter("WorkflowStageId", _stage.Value));
                }

                var auditChecks = GlobalObjects.CaaEnvironment.NewLoader
                                  .GetObjectListAll <AuditCheckDTO, AuditCheck>(filter, loadChild: true).ToList();

                _initialDocumentArray.AddRange(GlobalObjects.CaaEnvironment.NewLoader.GetObjectListAll <CheckListDTO, CheckLists>(new Filter("ItemId", ids), loadChild: true, true));

                var revisions = new List <CheckListRevision>();
                var revedIds  = _initialDocumentArray.Where(i => i.RevisionId.HasValue).Select(i => i.RevisionId.Value).Distinct().ToList();
                revedIds.AddRange(_initialDocumentArray.Select(i => i.EditionId).Distinct());
                if (revedIds.Any())
                {
                    revisions.AddRange(GlobalObjects.CaaEnvironment.NewLoader.GetObjectList <CheckListRevisionDTO, CheckListRevision>(new List <Filter>()
                    {
                        new Filter("ItemId", values: revedIds),
                    }));
                }

                foreach (var check in _initialDocumentArray)
                {
                    check.AuditCheck     = auditChecks.FirstOrDefault(i => i.CheckListId == check.ItemId);
                    check.RevisionNumber = revisions.FirstOrDefault(i => i.ItemId == check.RevisionId)?.Number.ToString() ?? "";
                    check.EditionNumber  = revisions.FirstOrDefault(i => i.ItemId == check.RevisionId)?.Number.ToString() ?? "";
                }
            }


            var pelRecords = GlobalObjects.CaaEnvironment.NewLoader
                             .GetObjectListAll <AuditPelRecordDTO, AuditPelRecord>(new Filter("AuditId", _parentId));

            if (records.Any())
            {
                var pelSpec = GlobalObjects.CaaEnvironment.NewLoader.GetObjectList <PelSpecialistDTO, PelSpecialist>(new Filter("AuditId", _parentId));

                var specIds     = pelSpec.Select(i => i.SpecialistId);
                var specialists = GlobalObjects.CaaEnvironment.NewLoader
                                  .GetObjectListAll <CAASpecialistDTO, Specialist>(new Filter("ItemId", specIds),
                                                                                   loadChild: true);

                foreach (var specialist in specialists)
                {
                    specialist.Operator = GlobalObjects.CaaEnvironment.AllOperators.FirstOrDefault(i => i.ItemId == specialist.OperatorId) ?? AllOperators.Unknown;
                }

                foreach (var pel in pelSpec)
                {
                    pel.Specialist = specialists.FirstOrDefault(i => i.ItemId == pel.SpecialistId);
                }


                var dsTransfer = GlobalObjects.CaaEnvironment.NewLoader.Execute($@";WITH cte AS
(
   SELECT *,
         ROW_NUMBER() OVER (PARTITION BY CheckListId ORDER BY Created DESC) AS rn
   FROM [CheckListTransfer] where AuditId = {_parentId}
)
SELECT CheckListId, [From], [To]
FROM cte
WHERE rn = 1 and  IsDeleted = 0");

                var transfers = dsTransfer.Tables[0].Rows.OfType <DataRow>().Select(i => new
                {
                    CheckListId = (int)i[0],
                    From        = (int)i[1],
                    To          = (int)i[2],
                });

                foreach (var rec in pelRecords)
                {
                    rec.CheckList = _initialDocumentArray.FirstOrDefault(i => i.ItemId == rec.CheckListId);
                    rec.Auditor   = pelSpec.FirstOrDefault(i => i.ItemId == rec.AuditorId)?.Specialist ?? Specialist.Unknown;
                    rec.Auditee   = pelSpec.FirstOrDefault(i => i.ItemId == rec.AuditeeId)?.Specialist ?? Specialist.Unknown;

                    var tr = transfers.FirstOrDefault(i => i.CheckListId == rec.CheckListId);
                    if (tr != null)
                    {
                        rec.CurrentAuditor = pelSpec.FirstOrDefault(i => i.SpecialistId == tr.To)?.Specialist ?? Specialist.Unknown;
                    }
                }
            }


            var levels = GlobalObjects.CaaEnvironment.NewLoader.GetObjectList <FindingLevelsDTO, FindingLevels>(new []
            {
                new Filter("OperatorId", _operatorId),
                new Filter("ProgramTypeId", _manual.ProgramTypeId),
            });

            foreach (var check in _initialDocumentArray)
            {
                check.PelRecord = pelRecords.FirstOrDefault(i => i.CheckListId == check.ItemId);

                if (check.PelRecord?.CurrentAuditor?.ItemId == GlobalObjects.CaaEnvironment.IdentityUser.PersonnelId)
                {
                    check.IsEditable = true;
                }


                if (check.CheckUIType == CheckUIType.Iosa)
                {
                    check.Level = levels.FirstOrDefault(i => i.ItemId == check.Settings.LevelId) ??
                                  FindingLevels.Unknown;
                }
                else if (check.CheckUIType == CheckUIType.Safa)
                {
                    check.Level = levels.FirstOrDefault(i => i.ItemId == check.SettingsSafa.LevelId) ??
                                  FindingLevels.Unknown;
                }
                else if (check.CheckUIType == CheckUIType.Icao)
                {
                    check.Level = levels.FirstOrDefault(i => i.ItemId == check.SettingsIcao.LevelId) ??
                                  FindingLevels.Unknown;
                }
                check.Remains   = Lifelength.Null;
                check.Condition = ConditionState.Satisfactory;
            }


            AnimatedThreadWorker.ReportProgress(40, "filter directives");

            AnimatedThreadWorker.ReportProgress(70, "filter directives");

            FilterItems(_initialDocumentArray, _resultDocumentArray);

            AnimatedThreadWorker.ReportProgress(100, "Complete");
        }