Ejemplo n.º 1
0
        protected override void Initialize()
        {
            base.Initialize();
            if (coreConfiguration.PickerDestinations == null)
            {
                coreConfiguration.PickerDestinations = new List <string>();
            }

            if (coreConfiguration.PickerDestinations.Count > 0)
            {
                // Show selected (and active) destinations
                foreach (string designation in coreConfiguration.PickerDestinations)
                {
                    IDestination destination = DestinationHelper.GetDestination(designation);
                    if ("Picker".Equals(destination.Designation))
                    {
                        continue;
                    }
                    selectedDestinations.Add(destination);
                }
                foreach (IDestination destination in DestinationHelper.GetAllDestinations())
                {
                    // Skip picker
                    if ("Picker".Equals(destination.Designation))
                    {
                        continue;
                    }
                    if (!coreConfiguration.PickerDestinations.Contains(destination.Designation))
                    {
                        availableDestinations.Add(destination);
                    }
                }
            }
            else
            {
                foreach (IDestination destination in DestinationHelper.GetAllDestinations())
                {
                    // Skip picker
                    if ("Picker".Equals(destination.Designation))
                    {
                        continue;
                    }
                    selectedDestinations.Add(destination);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Export the capture with the destination picker
        /// </summary>
        /// <param name="manuallyInitiated">Did the user select this destination?</param>
        /// <param name="surface">Surface to export</param>
        /// <param name="captureDetails">Details of the capture</param>
        /// <returns>true if export was made</returns>
        public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails)
        {
            List <IDestination> destinations = new List <IDestination>();

            if (conf.PickerDestinations != null && conf.PickerDestinations.Count > 0)
            {
                // Show selected (and active) destinations
                foreach (string designation in conf.PickerDestinations)
                {
                    IDestination destination = DestinationHelper.GetDestination(designation);
                    if (DESIGNATION.Equals(destination.Designation))
                    {
                        continue;
                    }
                    if (!destination.IsActive)
                    {
                        continue;
                    }
                    destinations.Add(destination);
                }
            }
            else
            {
                // Show active destinations
                foreach (IDestination destination in DestinationHelper.GetAllDestinations())
                {
                    if ("Picker".Equals(destination.Designation))
                    {
                        continue;
                    }
                    if (!destination.IsActive)
                    {
                        continue;
                    }
                    destinations.Add(destination);
                }
            }


            // No Processing, this is done in the selected destination (if anything was selected)
            return(ShowPickerMenu(true, surface, captureDetails, destinations));
        }
Ejemplo n.º 3
0
        protected override void BackgroundWorkerDoWork(object sender, DoWorkEventArgs e)
        {
            backgroundWorker.ReportProgress(50);

            try
            {
                Invoke(new Action(() => listViewCompliance.Items.Clear()));
            }
            catch (Exception)
            {
            }

            if (_currentComponent == null)
            {
                e.Cancel = true;
                return;
            }
            var parentAircraft   = GlobalObjects.AircraftsCore.GetParentAircraft(_currentComponent);
            var lastRecords      = new List <AbstractRecord>();
            var nextPerformances = new List <NextPerformance>();

            var allWorkPackagesIncludedTask     = new CommonCollection <WorkPackage>();
            var openPubWorkPackagesIncludedTask = new CommonCollection <WorkPackage>();
            var closedWorkPackages           = new CommonCollection <WorkPackage>();
            var taskThatIncludeInWorkPackage = new List <IDirective>();

            lastRecords.AddRange(_currentComponent.TransferRecords.ToArray());
            lastRecords.AddRange(_currentComponent.ChangeLLPCategoryRecords.ToArray());
            lastRecords.AddRange(_currentComponent.ActualStateRecords.ToArray());

            //Объекты для в котороые будет извлекаться информация
            //из записеи о перемещении
            var lastDestination = "";
            //прогнозируемый ресурс
            //если известна родительская деталь данной директивы,
            //то ее текущая наработка и средняя утилизация
            //используются в качестве ресурсов прогноза
            //для расчета всех просроченных выполнений
            var forecastData = new ForecastData(DateTime.Now,
                                                GlobalObjects.AverageUtilizationCore.GetAverageUtillization(_currentComponent),
                                                GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(_currentComponent));

            foreach (var directive in _currentComponent.ComponentDirectives)
            {
                if (directive.IsAffect().GetValueOrDefault(true))
                {
                    //расчет след. выполнений директивы.
                    //если известен ресурс прогноза, то будут расчитаны все просрочнные выполнения
                    //если неизвестне, то только первое
                    //GlobalObjects.PerformanceCalculator.GetNextPerformance(directive, forecastData);
                    nextPerformances.AddRange(directive.NextPerformances);
                    lastRecords.AddRange(directive.PerformanceRecords.ToArray());

                    if (backgroundWorker.CancellationPending)
                    {
                        e.Cancel = true;
                        return;
                    }
                    taskThatIncludeInWorkPackage.Add(directive);
                }
                else
                {
                    var bindedItems = GlobalObjects.BindedItemsCore.GetBindedItemsFor(parentAircraft.ItemId, directive);
                    foreach (var bindedItem in bindedItems)
                    {
                        if (bindedItem is MaintenanceDirective)
                        {
                            var mpd = (MaintenanceDirective)bindedItem;
                            //прогнозируемый ресурс
                            //если известна родительская деталь данной директивы,
                            //то ее текущая наработка и средняя утилизация
                            //используются в качестве ресурсов прогноза
                            //для расчета всех просроченных выполнений
                            //расчет след. выполнений директивы.
                            //если известен ресурс прогноза, то будут расчитаны все просрочнные выполнения
                            //если неизвестне, то только первое
                            GlobalObjects.PerformanceCalculator.GetNextPerformance(mpd, forecastData);
                            nextPerformances.AddRange(mpd.NextPerformances);
                            lastRecords.AddRange(mpd.PerformanceRecords.ToArray());

                            taskThatIncludeInWorkPackage.Add(mpd);
                        }
                    }
                }
            }

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

            //загрузка рабочих пакетов для определения
            _openPubWorkPackages.AddRange(GlobalObjects.WorkPackageCore.GetWorkPackagesLite(parentAircraft, WorkPackageStatus.Opened));
            _openPubWorkPackages.AddRange(GlobalObjects.WorkPackageCore.GetWorkPackagesLite(parentAircraft, WorkPackageStatus.Published));

            allWorkPackagesIncludedTask.AddRange(GlobalObjects.WorkPackageCore.GetWorkPackagesLite(parentAircraft, WorkPackageStatus.All, taskThatIncludeInWorkPackage));

            #region Добавление в список просроченных выполнений

            //и сравнение их с открытыми и опубликованными рабочими пакетами
            openPubWorkPackagesIncludedTask.AddRange(
                allWorkPackagesIncludedTask.Where(wp => wp.Status == WorkPackageStatus.Opened ||
                                                  wp.Status == WorkPackageStatus.Published));
            //сбор всех записей рабочих пакетов для удобства фильтрации
            var openPubWpRecords =
                openPubWorkPackagesIncludedTask.SelectMany(wp => wp.WorkPakageRecords).ToList();
            //LINQ запрос для сортировки записей по дате
            var sortNextRecords = (from record in nextPerformances
                                   orderby GetDate(record) descending
                                   select record).ToList();
            for (int i = 0; i < sortNextRecords.Count; i++)
            {
                if (backgroundWorker.CancellationPending)
                {
                    allWorkPackagesIncludedTask.Clear();
                    openPubWorkPackagesIncludedTask.Clear();
                    closedWorkPackages.Clear();

                    e.Cancel = true;
                    return;
                }

                //поиск записи в рабочих пакетах по данному чеку
                //чей номер группы выполнения (по записи) совпадает с расчитанным
                var parentDirective = sortNextRecords[i].Parent;
                //номер выполнения
                int parentCountPerf;
                if (parentDirective.LastPerformance != null)
                {
                    parentCountPerf = parentDirective.LastPerformance.PerformanceNum <= 0
                                                ? 1
                                                : parentDirective.LastPerformance.PerformanceNum;
                }
                else
                {
                    parentCountPerf = 0;
                }
                parentCountPerf += parentDirective.NextPerformances.IndexOf(sortNextRecords[i]);
                parentCountPerf += 1;

                var wpr = openPubWpRecords.FirstOrDefault(r => r.PerformanceNumFromStart == parentCountPerf &&
                                                          r.WorkPackageItemType == parentDirective.SmartCoreObjectType.ItemId &&
                                                          r.DirectiveId == parentDirective.ItemId);
                if (wpr != null)
                {
                    var wp = openPubWorkPackagesIncludedTask.GetItemById(wpr.WorkPakageId);
                    //запись о выполнении блокируется найденым пакетом
                    sortNextRecords[i].BlockedByPackage = wp;
                    //последующие записи о выполнении так же должны быть заблокированы
                    for (int j = i - 1; j >= 0; j--)
                    {
                        //блокировать нужно все рабочие записи, или до первой записи,
                        //заблокированной другим рабочим пакетом
                        if (sortNextRecords[j].BlockedByPackage != null ||
                            sortNextRecords[j].Condition != ConditionState.Overdue)
                        {
                            break;
                        }
                        if (sortNextRecords[j].Parent == parentDirective)
                        {
                            sortNextRecords[j].BlockedByPackage = wp;
                            Invoke(new Action <int, Color>(SetItemColor), j, Color.FromArgb(Highlight.GrayLight.Color));
                        }
                    }
                }
                Invoke(new Action <NextPerformance>(AddListViewItem), sortNextRecords[i]);
            }

            #endregion

            #region Добавление в список записей о произведенных выполнениях

            //и сравнение их с закрытыми рабочими пакетами
            closedWorkPackages.AddRange(allWorkPackagesIncludedTask.Where(wp => wp.Status == WorkPackageStatus.Closed));

            //LINQ запрос для сортировки записей по дате
            var sortLastRecords = (from record in lastRecords
                                   orderby record.RecordDate ascending
                                   select record).ToList();

            var items = new List <KeyValuePair <AbstractRecord, string[]> >();

            for (int i = 0; i < sortLastRecords.Count; i++)
            {
                if (backgroundWorker.CancellationPending)
                {
                    allWorkPackagesIncludedTask.Clear();
                    openPubWorkPackagesIncludedTask.Clear();
                    closedWorkPackages.Clear();

                    e.Cancel = true;
                    return;
                }

                string[] subs;
                if (sortLastRecords[i] is DirectiveRecord)
                {
                    var directiveRecord = (DirectiveRecord)sortLastRecords[i];
                    subs = new[]
                    {
                        directiveRecord.WorkType,
                        UsefulMethods.NormalizeDate(directiveRecord.RecordDate),
                        directiveRecord.OnLifelength != null
                                                                        ? directiveRecord.OnLifelength.ToString()
                                                                        : "",
                        "",
                        "",
                        directiveRecord.Remarks
                    };
                }
                else if (sortLastRecords[i] is TransferRecord)
                {
                    TransferRecord transferRecord = (TransferRecord)sortLastRecords[i];

                    string currentDestination, destinationObject;
                    DestinationHelper.GetDestination(transferRecord, out currentDestination, out destinationObject);

                    subs = new[]
                    {
                        lastDestination != ""
                                                                        ? "Transfered " + destinationObject + " from " + lastDestination + " to " + currentDestination
                                                                        : "Transfered " + destinationObject + " to " + currentDestination,
                        UsefulMethods.NormalizeDate(transferRecord.TransferDate),
                        transferRecord.OnLifelength.ToString(),
                        "",
                        "",
                        transferRecord.Remarks,
                    };
                    lastDestination = currentDestination;
                }
                else if (sortLastRecords[i] is ComponentLLPCategoryChangeRecord)
                {
                    ComponentLLPCategoryChangeRecord llpRecord  = (ComponentLLPCategoryChangeRecord)sortLastRecords[i];
                    LLPLifeLimitCategory             toCategory = llpRecord.ToCategory;
                    subs = new[]
                    {
                        "Changed to " + toCategory,
                        UsefulMethods.NormalizeDate(llpRecord.RecordDate),
                        llpRecord.OnLifelength.ToString(),
                        "",
                        "",
                        llpRecord.Remarks,
                    };
                }
                else if (sortLastRecords[i] is ActualStateRecord)
                {
                    ActualStateRecord actualStateRecord = (ActualStateRecord)sortLastRecords[i];
                    subs = new[]
                    {
                        "Actual state:",
                        UsefulMethods.NormalizeDate(actualStateRecord.RecordDate.Date),
                        actualStateRecord.OnLifelength != null
                                                                        ? actualStateRecord.OnLifelength.ToString()
                                                                        : "",
                        "",
                        "",
                        actualStateRecord.Remarks,
                    };
                }
                else
                {
                    subs = new[]
                    {
                        "Unknown record ",
                        UsefulMethods.NormalizeDate(sortLastRecords[i].RecordDate),
                        sortLastRecords[i].OnLifelength.ToString(),
                        "",
                        "",
                        sortLastRecords[i].Remarks,
                    };
                }
                items.Add(new KeyValuePair <AbstractRecord, string[]>(sortLastRecords[i], subs));
            }

            #endregion

            for (int i = items.Count - 1; i >= 0; i--)
            {
                WorkPackage workPackage = null;
                if (items[i].Key is AbstractPerformanceRecord)
                {
                    var apr = items[i].Key as AbstractPerformanceRecord;
                    workPackage = closedWorkPackages.FirstOrDefault(wp => wp.ItemId == apr.DirectivePackageId);
                }
                Invoke(new Action <AbstractRecord, string[], WorkPackage>(AddListViewItem), items[i].Key, items[i].Value, workPackage);
            }

            allWorkPackagesIncludedTask.Clear();
            openPubWorkPackagesIncludedTask.Clear();
            closedWorkPackages.Clear();

            backgroundWorker.ReportProgress(100);
        }
Ejemplo n.º 4
0
        public MainForm(CopyDataTransport dataTransport)
        {
            instance = this;

            // Make sure we never capture the mainform
            WindowDetails.RegisterIgnoreHandle(this.Handle);
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();
            this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon();

            IniConfig.IniChanged += new FileSystemEventHandler(ReloadConfiguration);

            tooltip = new ToolTip();

            UpdateUI();

            // Do loading on a different Thread to shorten the startup
            Thread pluginInitThread = new Thread(delegate()
            {
                // Load all the plugins
                PluginHelper.instance.LoadPlugins(this);

                // Check destinations, remove all that don't exist
                foreach (string destination in conf.OutputDestinations.ToArray())
                {
                    if (DestinationHelper.GetDestination(destination) == null)
                    {
                        conf.OutputDestinations.Remove(destination);
                    }
                }

                // we should have at least one!
                if (conf.OutputDestinations.Count == 0)
                {
                    conf.OutputDestinations.Add(Destinations.EditorDestination.DESIGNATION);
                }
                BeginInvoke((MethodInvoker) delegate
                {
                    // Do after all plugins & finding the destination, otherwise they are missing!
                    InitializeQuickSettingsMenu();
                });
            });

            pluginInitThread.Name         = "Initialize plug-ins";
            pluginInitThread.IsBackground = true;
            pluginInitThread.Start();

            SoundHelper.Initialize();

            // Create a new instance of the class: copyData = new CopyData();
            copyData = new CopyData();

            // Assign the handle:
            copyData.AssignHandle(this.Handle);
            // Create the channel to send on:
            copyData.Channels.Add("Greenshot");
            // Hook up received event:
            copyData.CopyDataReceived += new CopyDataReceivedEventHandler(CopyDataDataReceived);

            if (dataTransport != null)
            {
                HandleDataTransport(dataTransport);
            }
        }