Esempio n. 1
0
        public List <BenchmarkResult> DoBenchmark(params Model.Modules.Types.BenchmarkType[] BenchmarkTypes)
        {
            if (BenchmarkTypes == null)
            {
                throw new Exception("BenchmarkType could not be empty");
            }

            List <BenchmarkResult> BenchmarkResultList = new List <BenchmarkResult>();
            int percentage = 0;

            for (int i = 0; i < BenchmarkTypes.Length; i++)
            {
                var benchmarkModule = Factory.Main.GetModuleByType(BenchmarkTypes[i], this._ConfigurationParameters);

                AttachEvents(ref benchmarkModule, true);
                var benchmarkResultPartial = benchmarkModule.DoBenchmark();
                benchmarkResultPartial.BenchmarkType = BenchmarkTypes[i];
                BenchmarkResultList.Add(benchmarkResultPartial);
                AttachEvents(ref benchmarkModule, false);

                OnProgressChanged.DynamicInvoke(Math.Round(((double)(i + 1) / (double)BenchmarkTypes.Length) * 100, 2));
            }


            return(BenchmarkResultList);
        }
 public AudioControlPanel()
 {
     InitializeComponent();
     MusicProgress.OnProgressChanged += x => OnProgressChanged?.Invoke(x);
     VolumeBar.OnValueChanged        += x =>
     {
         if (x >= 25 && x < 75)
         {
             VolumeAdj.Content = FindResource("Volume_025");
         }
         else if (x >= 75)
         {
             VolumeAdj.Content = FindResource("Volume_075");
         }
         else if (x >= 1)
         {
             VolumeAdj.Content = FindResource("Volume_0");
         }
         else
         {
             VolumeAdj.Content = FindResource("Volume_off");
         }
         OnVolumeChanged?.Invoke(x);
     };
 }
Esempio n. 3
0
        private void FFmpegProcess_Process_Output(string data)
        {
            if (data == null)
            {
                return;
            }
            try
            {
                receivedMessagesLog.AppendLine(data);

                ConversionCompleteEventArgs convertCompleteEvent;
                ConvertProgressEventArgs    progressEvent;

                if ((progressEvent = RegexEngine.IsProgressData(data)) != null)
                {
                    progressEvent.TotalDuration = metadata.Duration;
                    progress = progressEvent.ProcessedDuration.TotalSeconds / progressEvent.TotalDuration.TotalSeconds * 100.0;
                    OnProgressChanged?.Invoke(this, progressEvent);
                }
            }
            catch (Exception ex)
            {
                Stop();
            }
        }
Esempio n. 4
0
 private void QueueInvokeProgressChanged(ISampleProvider sampleProvider, float progress)
 {
     eventInvokeQueue.Enqueue(() =>
                              OnProgressChanged?.Invoke(this,
                                                        new ProgressChangedEventArgs(sampleProvider, progress))
                              );
 }
Esempio n. 5
0
        public void OpenFastfile(string path)
        {
            OnProgressChanged?.Invoke(20);
            ffData = GetFFData(path);

            OnProgressChanged?.Invoke(40);
            zoneData = GetZoneData();

            OnProgressChanged?.Invoke(60);
            assetData = GetAssetData();

            OnProgressChanged?.Invoke(80);
            foreach (RawFileData r in assetData.RawFiles)
            {
                OnRawfileDiscovered?.Invoke(r.Index, r.Name, r.OriginalName, r.OriginalSize);
            }

            OnProgressChanged?.Invoke(100);
            foreach (LocalizedStringData ls in assetData.LocalizedString)
            {
                OnLocalizedStringDiscovered?.Invoke(ls.Index, ls.Prefix, ls.Key);
            }

            OnProgressChanged?.Invoke(0);
        }
Esempio n. 6
0
        //-----------------------------

        protected void invokeProgressChanged(double progress)
        {
            if (OnProgressChanged != null)
            {
                OnProgressChanged.Invoke(progress);
            }
        }
Esempio n. 7
0
        public ValidationResults Validate(CRMSolution solution)
        {
            ValidationResults allValidatorsResult = new ValidationResults();

            if (Validators == null || Validators.Count == 0)
            {
                throw new InvalidOperationException("No Validators exist, please change the validation settings first");
            }

            //publish all customizations first if the settings allow it
            if (MySettings.AlwaysPublish)
            {
                OnProgressChanged?.Invoke(this, new ProgressEventArgs("Publishing customizations"));
                PublishAllXmlRequest publishRequest = new PublishAllXmlRequest();
                CRMService.Execute(publishRequest);
            }

            // start the validators
            foreach (IValidator validator in Validators)
            {
                validator.OnValidatorError += (s, e) =>
                {
                    OnError?.Invoke(s, e);
                };
                validator.OnValidatorProgress += (s, e) =>
                {
                    OnProgressChanged?.Invoke(s, new ProgressEventArgs(e.Message));
                };

                ValidationResults validatorResult = validator.Validate();
                allValidatorsResult.AddResultSet(validatorResult);
            }

            return(allValidatorsResult);
        }
Esempio n. 8
0
        bool HashFiles()
        {
            foreach (var fileSystemItem in fileSystemItems)
            {
                OnProgressChanged?.Invoke(this, fileSystemItem.name);
                manualResetEvent.WaitOne();
                if (backgroundWorker.CancellationPending)
                {
                    return(false);
                }

                if (fileSystemItem.type == FileSystemItemType.Directory || FileSystemItemAccess.Default != fileSystemItem.access)
                {
                    hashWriter.WriteResultLine(new HashedFileSystemItem(fileSystemItem, hash: null));
                }
                else
                {
                    if (!HashAndAddToResult(fileSystemItem))
                    {
                        return(false);
                    }
                }
            }

            hashWriter.CloseFile();
            return(true);
        }
Esempio n. 9
0
        private void _downloadProgressChanged(object sender, long bytesReceived)
        {
            _downloadedAmount = bytesReceived;
            var progress = (int)((_totalDownloadedAmount + _downloadedAmount) / (double)TotalAmountToDownload * 100);

            OnProgressChanged?.Invoke(this, progress);
        }
Esempio n. 10
0
        public async Task CopyAsync()
        {
            const int bufferSize = 1024 * 1024;
            var       buffer     = new byte[bufferSize];

            foreach (var fileInfo in _sourceFiles)
            {
                var sourceFilePath      = fileInfo.FullName;
                var referenceSourcePath = sourceFilePath.Replace(_sourcePath, "");
                var checkChars          = new[] { @"\", "/" };
                if (checkChars.Any(x => referenceSourcePath.StartsWith(x)))
                {
                    referenceSourcePath = referenceSourcePath.Substring(1);
                }
                var targetFilePath = Path.Combine(_targetPath, referenceSourcePath);

                var prevCopiedSize = 0L;
                var fileCopy       = new FileCopy(sourceFilePath, targetFilePath);
                fileCopy.OnProgressChanged += (copiedSize, totalSize, progress) =>
                {
                    Interlocked.Add(ref TotalCopiedSize, copiedSize - prevCopiedSize);
                    OnProgressChanged?.Invoke(TotalCopiedSize, TotalSize, TotalProgress);
                    prevCopiedSize = copiedSize;
                };
                await fileCopy.CopyAsync();
            }

            OnComplete?.Invoke();
        }
Esempio n. 11
0
        public void Copy()
        {
            byte[] buffer = new byte[1024 * 1024]; // 1MB buffer
            bool   cancel = false;

            using (FileStream oldFile = new FileStream(oldPath, FileMode.Open, FileAccess.Read))
            {
                long fileLength = oldFile.Length;
                using (FileStream newFile = new FileStream(newPath, FileMode.CreateNew, FileAccess.Write))
                {
                    long totalBytes       = 0;
                    int  currentBlockSize = 0;

                    while ((currentBlockSize = oldFile.Read(buffer, 0, buffer.Length)) > 0)
                    {
                        totalBytes += currentBlockSize;
                        double persentage = (double)totalBytes * 100.0 / fileLength;

                        newFile.Write(buffer, 0, currentBlockSize);
                        cancel = false;

                        OnProgressChanged?.Invoke(persentage, ref cancel);

                        if (cancel)
                        {
                            break;
                        }
                    }

                    OnComplete?.Invoke();
                }
            }
        }
Esempio n. 12
0
        public void BeginProcessing()
        {
            OnProgressChanged?.Invoke(0);
            //Read and load excel to json objects
            var reader = new OpenXmlLoader(spreadSheetFilePath);

            reader.LoadExcelDataToJsonFile();
            OnProgressChanged?.Invoke(20);

            var pdf = new PdfGeneratorEngine();

            pdf.GenerateSalarySlipsPdfs();
            OnProgressChanged?.Invoke(50);

            var poster = new EmailPoster();

            poster.OnProgressChanged += (d) =>
            {
                var progress = 50 + d;
                OnProgressChanged?.Invoke(progress);
            };
            poster.SendEmails();
            OnProgressFinished?.Invoke(this, new SendEmailsFinishedEventArgs()
            {
                FailedEmails = poster.ErrorEmails, SuccessEmails = poster.SuccessEmails
            });
        }
Esempio n. 13
0
        private void Copy(string sourcePath, string destinationPath)
        {
            byte[] buffer = new byte[1024 * 1024]; // 1MB buffer

            using (FileStream source = new FileStream(sourcePath, FileMode.Open, FileAccess.Read))
            {
                using (FileStream dest = new FileStream(destinationPath, FileMode.CreateNew, FileAccess.Write))
                {
                    int currentBlockSize;

                    while ((currentBlockSize = source.Read(buffer, 0, buffer.Length)) > 0)
                    {
                        _totalBytes += currentBlockSize;
                        double persentage = _totalBytes * 100.0 / _totalLength;

                        dest.Write(buffer, 0, currentBlockSize);

                        var cancelFlag = false;
                        OnProgressChanged?.Invoke(persentage, ref cancelFlag);

                        if (cancelFlag)
                        {
                            // Delete dest file here
                            break;
                        }
                    }
                }
            }
            CopyCompleted();
        }
Esempio n. 14
0
 public void Increment()
 {
     if (_currentValue + 1 <= _maxValue)
     {
         Interlocked.Increment(ref _currentValue);
         OnProgressChanged?.Invoke(this, null);
     }
 }
Esempio n. 15
0
 private void _workerProgressChanged(object sender, ProgressChangedEventArgs e)
 {
     if (e.ProgressPercentage == 100)
     {
         OnDownloadComplete?.Invoke(this);
     }
     OnProgressChanged?.Invoke(this, e.ProgressPercentage);
 }
Esempio n. 16
0
        private void ReportMissingItem(HashedFileSystemItem hashedFileSystemItemA, string file)
        {
            string result = hashedFileSystemItemA.name + "," + hashedFileSystemItemA.type + ",MISSING_FROM," + file;

            if (WriteOutputToFile)
            {
                output.WriteLine(result);
            }
            OnProgressChanged?.Invoke(this, hashedFileSystemItemA.name + "(" + hashedFileSystemItemA.type + ")" + " missing from " + file);
        }
Esempio n. 17
0
 private void OnProgressChangedInternal(int progress, int maxProgress)
 {
     try
     {
         OnProgressChanged?.Invoke((double)_Progress / _MaxProgress);
     }
     catch (Exception exception)
     {
         _Log.WriteException(exception);
     }
 }
Esempio n. 18
0
        protected void IncrementProgress(int percentage)
        {
            log.Debug($"Task '{Title}' (Id: {TaskId}) - Progression: {ProgressionPercentage}");
            ProgressionPercentage = percentage;
            OnProgressChanged?.Invoke(this, percentage);

            if (percentage == 100)
            {
                OnTaskFinished?.Invoke(this, System.EventArgs.Empty);
            }
        }
Esempio n. 19
0
        public FileDownloader(string downloadUrl, string savePath)
        {
            DownloadUrl = downloadUrl;
            SavePath    = savePath;

            _downloadClient.DownloadFileCompleted += (s, e) =>
            {
                OnDownloadCompleted?.Invoke(!e.Cancelled && e.Error == null);
            };
            _downloadClient.DownloadProgressChanged += (sender, args) =>
                                                       OnProgressChanged?.Invoke(args.ProgressPercentage, "Downloading...");
        }
Esempio n. 20
0
        public void SaveFastfile()
        {
            OnProgressChanged?.Invoke(33);
            WriteAssetData();

            OnProgressChanged?.Invoke(66);
            WriteZoneData();

            OnProgressChanged?.Invoke(100);
            WriteFastFile();

            OnProgressChanged?.Invoke(0);
        }
Esempio n. 21
0
 private void NotifySubscribers(int totalUnits, int currentProgress, string description)
 {
     if (OnProgressChanged != null)
     {
         OnProgressChanged.Invoke(this, new ProgressEventArgs
         {
             Type            = ProgressEventArgs.ProcessorType.ModelBuilder,
             Description     = description,
             CurrentProgress = currentProgress,
             TotalUnits      = totalUnits
         });
     }
 }
Esempio n. 22
0
        public void CompressZlibArchive(string input, string output)
        {
            OnProgressChanged?.Invoke(10);
            byte[] data = File.ReadAllBytes(input);

            OnProgressChanged?.Invoke(90);
            data = ZlibInflate(data);

            OnProgressChanged?.Invoke(100);
            File.WriteAllBytes(output, data);

            OnProgressChanged?.Invoke(0);
        }
Esempio n. 23
0
        public void ExtractAllRawfiles(string baseDir)
        {
            for (int i = 0; i < assetData.RawFiles.Count; ++i)
            {
                string filePath = baseDir + "\\" + assetData.RawFiles[i].Name.Replace('/', '\\');

                int progress = (i * 100) / assetData.RawFiles.Count;
                OnProgressChanged?.Invoke(progress + 1);
                OnProgressChanged?.Invoke(progress);

                ExtractRawFile(filePath, i);
            }
        }
Esempio n. 24
0
 private void ProcessOnProgressChanged(ProgressEventArgs e)
 {
     if (OnProgressChanged != null)
     {
         OnProgressChanged.Invoke(this, new ProgressEventArgs
         {
             Type            = e.Type,
             Description     = e.Description,
             CurrentProgress = e.CurrentProgress,
             TotalUnits      = e.TotalUnits
         });
     }
 }
Esempio n. 25
0
 private void setProgress(int currentIndex, string currentFileName, int totalNumberOfFiles)
 {
     if (totalNumberOfFiles == 0 || currentIndex > totalNumberOfFiles)
     {
         OnProgressChanged?.Invoke(totalNumberOfFiles, String.Empty, totalNumberOfFiles, 100);
         OnCompleted?.Invoke();
     }
     else
     {
         var perc = (((float)currentIndex / (float)totalNumberOfFiles) * 100);
         var perv = (float)Math.Round(perc, 0);
         OnProgressChanged?.Invoke(currentIndex, currentFileName, totalNumberOfFiles, perc);
     }
 }
Esempio n. 26
0
        private void exporter_BatchExported(object sender, BatchExportedEventArgs e)
        {
            TotalExported  = e.TotalExported;
            TotalProcessed = e.TotalProcessed;

            if (OnProgressChanged != null)
            {
                OnProgressChanged.Invoke(this, new ProgressEventArgs
                {
                    Type            = ProgressEventArgs.ProcessorType.TmExporter,
                    Description     = string.Empty,
                    CurrentProgress = e.TotalExported,
                    TotalUnits      = TotalUnits
                });
            }
        }
Esempio n. 27
0
        public void SaveAsFastfile(string what, string where)
        {
            OnProgressChanged?.Invoke(33);
            byte[] decompressed = File.ReadAllBytes(what);

            OnProgressChanged?.Invoke(66);
            byte[] compressed = ZlibInflate(decompressed);

            OnProgressChanged?.Invoke(100);
            using (FileStream fs = new FileStream(where, FileMode.Create))
            {
                fs.Write(FFData.HeaderIW3Unsigned, 0, FFData.HeaderIW3Unsigned.Length);
                fs.Write(FFData.HeaderIW3VersionUnsigned, 0, FFData.HeaderIW3VersionUnsigned.Length);
                fs.Write(compressed, 0, compressed.Length);
            }
            OnProgressChanged?.Invoke(0);
        }
Esempio n. 28
0
        public void DetectEvents()
        {
            if (Events.Count > 0)
            {
                return;
            }
            OnProgressChanged?.Invoke(0, "Detecting events...");
            double count    = Solution.Entries.Count;
            double progress = 0;
            int    done     = 0;

            UnknownCount = 0;
            foreach (var e in Solution.Entries)
            {
                var message = e.Message ?? e.Error.ParsedMessage;
                if (message == null)
                {
                    throw new NullReferenceException("Message is not defined");
                }

                var s_name = Solution.TryGetSenderNameFromMessage(message);
                var s_id   = Solution.TryGetSenderIdFromMessage(message);
                var t_name = Solution.TryGetTargetNameFromMessage(message);
                var t_id   = Solution.TryGetTargetIdFromMessage(message);

                var source = Solution.TryGetBrokerByNameOrId(s_name, s_id);
                var target = Solution.TryGetBrokerByNameOrId(t_name, t_id);
                if (source == null || target == null)
                {
                    UnknownCount++;
                    Solution.LinkingErrors.Add(new Error()
                    {
                        Message = source == null ? "Unknown source id and name" : "Unknown target id and name", Content = e.Content, DateTime = e.DateTime, Direction = e.Direction, ErrorType = ErrorType.Syntax, Kind = e.Kind, ParsedMessage = message, Index = e.Index, RawLogLine = e.RawLogLine, Exception = new NullReferenceException("Unknown target or source")
                    });
                }

                Events.Add(new Event()
                {
                    Entry = e, Source = source, Target = target
                });

                done++;
                progress = (done / count) * 100;
                OnProgressChanged?.Invoke(progress, "Linking events...");
            }
        }
Esempio n. 29
0
        private void ReportDiff(HashedFileSystemItem hashedFileSystemItemA, HashedFileSystemItem hashedFileSystemItemB)
        {
            string result = hashedFileSystemItemA.name + "," + hashedFileSystemItemA.type + ",HASH_MISMATCH," +
                            File1 + "," + hashedFileSystemItemA.Hash + "," +
                            File2 + "," + hashedFileSystemItemB.Hash;

            if (WriteOutputToFile)
            {
                output.WriteLine(result);
            }
            string message =
                "Hash check failed : " + hashedFileSystemItemA.name + "(" + hashedFileSystemItemA.type + ")" + " : " + "\n" +
                File1 + " : " + hashedFileSystemItemA.Hash + "\n" +
                File2 + " : " + hashedFileSystemItemB.Hash;

            OnProgressChanged?.Invoke(this, message);
        }
Esempio n. 30
0
 private void DownloadNewFiles(List <string> list)
 {
     using (WebClient webClient = new WebClient()
     {
         Encoding = Encoding.UTF8
     })
     {
         list.ForEach(o =>
         {
             TryRun(new Action(() =>
             {
                 Directory.CreateDirectory(Path.Combine(Environment.CurrentDirectory, ".updatemachine", o.Substring(0, o.LastIndexOf('/') <= 0 ? 0 : o.LastIndexOf('/'))));
                 webClient.DownloadFile(Path.Combine(url, o).Replace('\\', '/'), Path.Combine(Environment.CurrentDirectory, ".updatemachine", o));
             }), 3);
             OnProgressChanged?.Invoke(list.IndexOf(o) + 1, list.Count);
         });
     }
 }