Esempio n. 1
0
        private void ExportActivityWork(object sender, DoWorkEventArgs e)
        {
            _worker.ReportProgress(0, "load Activity");
            _worker.ReportProgress(0, "Generate file! Please wait....");

            _exportProvider = new ExcelExportProvider();
            _exportProvider.ExportActivity(_result.ToList());
        }
Esempio n. 2
0
 public CheckListRevisionEditForm(int operatorId, CheckListRevision parent, CommonCollection <CheckLists> added, SmartCore.CAA.StandartManual.StandartManual manual)
 {
     _operatorId = operatorId;
     _parent     = parent;
     _manual     = manual;
     _updateChecks.AddRange(added.ToList());
     InitializeComponent();
     _animatedThreadWorker.DoWork             += AnimatedThreadWorkerDoLoad;
     _animatedThreadWorker.RunWorkerCompleted += BackgroundWorkerRunWorkerLoadCompleted;
     _animatedThreadWorker.RunWorkerAsync();
 }
Esempio n. 3
0
        protected override void AnimatedThreadWorkerDoWork(object sender, DoWorkEventArgs e)
        {
            var initialZeroMaintenanceDirectives = new CommonCollection <MaintenanceDirective>();
            var initialMaintenanceDirectives     = new CommonCollection <MaintenanceDirective>();

            _result.Clear();
            _initial.Clear();
            _groupLifelengths.Clear();
            _groupLifelengthsForZeroCheck.Clear();

            if (!_isFirstLoad)
            {
                AnimatedThreadWorker.ReportProgress(0, "load checks");

                var checks = GlobalObjects.CasEnvironment.NewLoader.GetObjectListAll <MTOPCheckDTO, MTOPCheck>(new Filter("ParentAircraftId", CurrentAircraft.ItemId), true).ToList();

                foreach (var check in checks)
                {
                    foreach (var record in check.PerformanceRecords)
                    {
                        record.Parent = check;
                    }
                }

                if (AnimatedThreadWorker.CancellationPending)
                {
                    e.Cancel = true;
                    return;
                }

                AnimatedThreadWorker.ReportProgress(10, "load MPDs");

                initialMaintenanceDirectives.AddRange(GlobalObjects.MaintenanceCore.GetMaintenanceDirectives(CurrentAircraft));

                var bindedItemsDict = GlobalObjects.BindedItemsCore.GetBindedItemsFor(CurrentAircraft.ItemId,
                                                                                      initialMaintenanceDirectives.Where(m => m.WorkItemsRelationType == WorkItemsRelationType.CalculationDepend));

                CalculateMaintenanceDirectives(initialMaintenanceDirectives.ToList(), bindedItemsDict);

                if (AnimatedThreadWorker.CancellationPending)
                {
                    e.Cancel = true;
                    return;
                }


                AnimatedThreadWorker.ReportProgress(50, "calculation");


                if (checks.Count > 0)
                {
                    //Берем утилизацию с Frame
                    var frame = GlobalObjects.CasEnvironment.BaseComponents.FirstOrDefault(i =>
                                                                                           i.ParentAircraftId == CurrentAircraft.ItemId && Equals(i.BaseComponentType, BaseComponentType.Frame));
                    var avg = _currentForecast.ForecastDatas[0].AverageUtilization;

                    var lastCompliance = checks.SelectMany(i => i.PerformanceRecords).OrderByDescending(i => i.RecordDate)
                                         .FirstOrDefault();

                    GlobalObjects.MTOPCalculator.CalculateMtopChecks(checks, avg);

                    _groupLifelengths = GlobalObjects.MTOPCalculator.CalculateGroupNew(checks.Where(i => !i.Thresh.IsNullOrZero() && !i.IsZeroPhase).ToList());

                    GlobalObjects.MTOPCalculator.CalculateNextPerformance(checks.Where(i => !i.IsZeroPhase).ToList(),
                                                                          frame.StartDate, _groupLifelengths, CurrentAircraft, avg, lastCompliance);

                    GlobalObjects.MTOPCalculator.CalculatePhaseWithPerformance(initialMaintenanceDirectives, checks.Where(i => !i.Thresh.IsNullOrZero() && !i.IsZeroPhase).ToList(), avg, _currentForecast.ForecastDatas[0].LowerLimit, _currentForecast.ForecastDatas[0].ForecastDate);


                    var maintenanceZeroChecks = checks.Where(i => i.IsZeroPhase).ToList();

                    var lowerZeroCheck = maintenanceZeroChecks.Where(i => !i.Thresh.IsNullOrZero()).OrderBy(i => i.Thresh)
                                         .FirstOrDefault();
                    if (lowerZeroCheck != null)
                    {
                        GlobalObjects.MTOPCalculator.CalculateMtopChecks(maintenanceZeroChecks, avg);

                        _groupLifelengthsForZeroCheck = GlobalObjects.MTOPCalculator.CalculateGroupNew(checks.Where(i => !i.Thresh.IsNullOrZero() && i.IsZeroPhase).ToList());

                        GlobalObjects.MTOPCalculator.CalculateNextPerformance(maintenanceZeroChecks, frame.StartDate,
                                                                              _groupLifelengthsForZeroCheck, CurrentAircraft, avg, lastCompliance);

                        initialZeroMaintenanceDirectives.AddRange(initialMaintenanceDirectives
                                                                  .Where(i => i.MTOPPhase?.FirstPhase == 0).ToArray());

                        GlobalObjects.MTOPCalculator.CalculatePhaseWithPerformance(initialZeroMaintenanceDirectives, maintenanceZeroChecks, avg, _currentForecast.ForecastDatas[0].LowerLimit, _currentForecast.ForecastDatas[0].ForecastDate, true);
                    }

                    foreach (var d in initialZeroMaintenanceDirectives)
                    {
                        initialMaintenanceDirectives.Remove(d);
                    }


                    _initial.AddRange(initialMaintenanceDirectives.SelectMany(i => i.MtopNextPerformances));
                    _initial.AddRange(initialZeroMaintenanceDirectives.SelectMany(i => i.MtopNextPerformances));
                }

                #region Фильтрация директив

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

                FilterItems(_initial, _result);

                if (AnimatedThreadWorker.CancellationPending)
                {
                    e.Cancel = true;
                    return;
                }
                #endregion

                #region Load WP

                AnimatedThreadWorker.ReportProgress(75, "filter Work Packages");

                if (AnimatedThreadWorker.CancellationPending)
                {
                    e.Cancel = true;
                    return;
                }

                if (_openPubWorkPackages == null)
                {
                    _openPubWorkPackages = new CommonCollection <WorkPackage>();
                }
                _openPubWorkPackages.Clear();
                _openPubWorkPackages.AddRange(GlobalObjects.WorkPackageCore.GetWorkPackagesLite(CurrentAircraft, WorkPackageStatus.Opened));
                _openPubWorkPackages.AddRange(GlobalObjects.WorkPackageCore.GetWorkPackagesLite(CurrentAircraft, WorkPackageStatus.Published));
                //сбор всех записей рабочих пакетов для удобства фильтрации
                List <WorkPackageRecord> openWPRecords = new List <WorkPackageRecord>();
                foreach (WorkPackage openWorkPackage in _openPubWorkPackages)
                {
                    openWPRecords.AddRange(openWorkPackage.WorkPakageRecords);
                }


                #endregion

                #region Загрузка Котировочных ордеров

                AnimatedThreadWorker.ReportProgress(95, "Load Quotations");

                //загрузка рабочих пакетов для определения
                //перекрытых ими выполнений задач
                if (_openPubQuotations == null)
                {
                    _openPubQuotations = new CommonCollection <RequestForQuotation>();
                }

                BaseEntityObject parent = CurrentAircraft ?? (BaseEntityObject)CurrentOperator;
                _openPubQuotations.Clear();
                _openPubQuotations.AddRange(GlobalObjects.PurchaseCore.GetRequestForQuotation(parent, new[] { WorkPackageStatus.Opened, WorkPackageStatus.Published }));

                if (AnimatedThreadWorker.CancellationPending)
                {
                    e.Cancel = true;
                    return;
                }
                #endregion

                AnimatedThreadWorker.ReportProgress(100, "Completed");
            }
        }
Esempio n. 4
0
 private void LinkReportDisplayerRequested(object sender, ReferenceEventArgs e)
 {
     e.TypeOfReflection = ReflectionTypes.DisplayInNew;
     e.DisplayerText    = "Air International. Air Fleet.";
     e.RequestedEntity  = new ReportScreen(new AirFleetBuilder(_itemsCollection.ToList()));
 }
Esempio n. 5
0
        protected override void AnimatedThreadWorkerDoWork(object sender, DoWorkEventArgs e)
        {
            _initialDocumentArray.Clear();
            _resultDocumentArray.Clear();


            if (_type == CheckListAuditType.Admin)
            {
                var ds = GlobalObjects.CaaEnvironment.NewLoader.Execute($@"
DECLARE @count INT
DECLARE @countNotSatis INT
DECLARE @countNotSatisRCA INT
SELECT
@count =  COUNT(*),
@countNotSatis = Sum(case when IsSatisfactory = 0 then 1 else 0 end),
@countNotSatisRCA = Sum(case when IsSatisfactory = 0 and WorkflowStageId in (4) then 1 else 0 end)
FROM [dbo].[AuditChecks]  where AuditId = {_auditId} and IsDeleted = 0


select 
 WorkflowStageId as WorkflowStageId,
 case when WorkflowStageId in(2,3,6) then @count else @countNotSatis end as AllTask,
 case when WorkflowStageId in (4) then @countNotSatisRCA
 else Count(*) end as TaskInProgress
 from dbo.AuditChecks 
 where AuditId = {_auditId} and IsDeleted = 0
 group by WorkflowStageId
");

                var dtC = ds.Tables[0];
                foreach (DataRow dr in dtC.Rows)
                {
                    _initialDocumentArray.Add(new AuditPublish()
                    {
                        WorkFlowStageId = int.Parse(dr[0].ToString()),
                        AllTask         = int.Parse(dr[1].ToString()),
                        TaskInProgress  = int.Parse(dr[2].ToString()),
                    });
                }
            }
            else
            {
                var ds = GlobalObjects.CaaEnvironment.NewLoader.Execute($@"
DECLARE @countNotSatis INT
declare @T table(
WorkflowStageId int,
Auditor int,
Auditee int,
IsSatisfactory bit);


;WITH cte AS
(
   SELECT rec.*, auditor.Auditor ,auditee.Auditee, ac.*, ROW_NUMBER() OVER (PARTITION BY rec.CheckListId ORDER BY rec.ItemId DESC) AS rn
   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 WorkflowStageId,  WorkflowStatusId, IsSatisfactory   from  [dbo].AuditChecks 
		where AuditId = rec.AuditId and CheckListId = rec.CheckListId
   ) as ac
   where rec.AuditId in ({_auditId}) and rec.IsDeleted = 0
)

insert into @T(WorkflowStageId, Auditor, Auditee, IsSatisfactory)
select WorkflowStageId, Auditor, Auditee , IsSatisfactory
from cte
where  rn = 1;

SELECT
@countNotSatis = Sum(case when IsSatisfactory = 0 then 1 else 0 end)
FROM @T

SELECT 
WorkflowStageId as WorkflowStageId,
case when WorkflowStageId in(2,3,6) then Count(*) else @countNotSatis end as AllTask,
Sum(case when ([Auditor] = {GlobalObjects.CaaEnvironment.IdentityUser.PersonnelId}  or [Auditee] = {GlobalObjects.CaaEnvironment.IdentityUser.PersonnelId} ) then 1 else 0 end) as TaskInProgress 
FROM @T
group by WorkflowStageId



");

                var dtC = ds.Tables[0];
                foreach (DataRow dr in dtC.Rows)
                {
                    _initialDocumentArray.Add(new AuditPublish()
                    {
                        WorkFlowStageId = int.Parse(dr[0].ToString()),
                        AllTask         = int.Parse(dr[1].ToString()),
                        TaskInProgress  = int.Parse(dr[2].ToString()),
                    });
                }
            }


            foreach (var i in _initialDocumentArray.OrderBy(i => i.WorkFlowStageId))
            {
                if (i.WorkFlowStageId == WorkFlowStage.Evaluation.ItemId ||
                    i.WorkFlowStageId == WorkFlowStage.RCA.ItemId ||
                    i.WorkFlowStageId == WorkFlowStage.CAP.ItemId)
                {
                    var res = ((double)(i.AllTask - i.TaskInProgress) / i.AllTask) * 100;
                    i.Persent = (int)Math.Round(res);
                }
                else if (i.WorkFlowStageId == WorkFlowStage.CAR.ItemId)
                {
                    if (_type == CheckListAuditType.Admin)
                    {
                        var eval = _initialDocumentArray.FirstOrDefault(q => q.WorkFlowStageId == WorkFlowStage.Evaluation.ItemId);
                        var res  = ((double)(i.AllTask - (i.TaskInProgress + eval.TaskInProgress)) / i.AllTask) * 100;
                        i.Persent = (int)Math.Round(res);
                    }
                    else
                    {
                        var res = ((double)(i.AllTask - i.TaskInProgress) / i.AllTask) * 100;
                        i.Persent = (int)Math.Round(res);
                    }
                }
                else if (i.WorkFlowStageId == WorkFlowStage.Closed.ItemId)
                {
                    var res = (double)(i.TaskInProgress / i.AllTask) * 100;
                    i.Persent = (int)Math.Round(res);
                }
            }


            _resultDocumentArray.AddRange(_initialDocumentArray.ToList());

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