Пример #1
0
        private static void RebuildAll(CancellationToken ct)
        {
            Bricks.Clear();

            using (var content = new LifContentWrapper(Source, SourcePath))
            {
                var primitiveFiles = content.GetPrimitiveFiles();
                var partIDs        = primitiveFiles.Select(x => x.PartID).Distinct();
                CurrentProgress = new ProgressInfo(partIDs.Count(), 0);

                foreach (int partID in partIDs)
                {
                    if (ct.IsCancellationRequested)
                    {
                        break;
                    }
                    try
                    {
                        var partInfo  = content.GetPart(partID);
                        var brickInfo = new BrickInfo(partInfo)
                        {
                            Validated  = true,
                            LastUpdate = DateTime.Now
                        };
                        Bricks.Add(brickInfo);
                    }
                    catch { }

                    CurrentProgress.TotalValidated++;
                }
            }
        }
Пример #2
0
        public void Start(IProgress <ProgressInfo> progress, List <TestData> complexList, CancellationToken cancelToken, PauseToken pauseToken)
        {
            var total   = complexList.Count;
            var counter = 0;
            var pInfo   = new ProgressInfo();

            foreach (var row in complexList)
            {
                if (cancelToken.IsCancellationRequested)
                {
                    cancelToken.ThrowIfCancellationRequested(); //throw OperationCanceledException
                }

                pauseToken.WaitWhilePausedAsync().GetAwaiter().GetResult(); //pause if IsPaused = true

                //Report progress
                counter++;
                pInfo.Percent = (int)Math.Round((counter / (double)total) * 100.00, MidpointRounding.AwayFromZero);
                if (progress != null)
                {
                    progress.Report(pInfo);
                }

                //Do main job
                var myString = row.MyString;
                var myNumber = row.MyNumber;
                Thread.Sleep(2000);
            }
        }
        /// <summary>
        /// Gets the current dependencies of the package.
        /// </summary>
        /// <param name="package">The package.</param>
        /// <returns>a list of the current package dependencies</returns>
        private static DependingPackageList CurrentDependencies(Package package)
        {
            ProgressInfo.Info = Resources.stateListConnectors;
            DependingPackageList dpList     = new DependingPackageList();
            List <Connector>     connectors = Manipulation.GetAllPackageConnectors(package);

            ProgressInfo.Reset(Resources.stateSearchCurDep, 0, connectors.Count);

            foreach (Connector connector in connectors)
            {
                ProgressInfo.Next();
                if (connector.Stereotype.Equals(appSettings.Stereotype))
                {
                    Element clientPackage   = pRepository.GetElementByID(connector.ClientID);
                    Element supplierPackage = pRepository.GetElementByID(connector.SupplierID);

                    //string client = connector.ClientID.ToString();
                    //string supplier = connector.SupplierID.ToString();

                    if ((supplierPackage != null) && (clientPackage != null))
                    {
                        if (clientPackage.ElementID != supplierPackage.ElementID)
                        {
                            if (!dpList.IsInList(supplierPackage.ElementID, clientPackage.ElementID))
                            {
                                dpList.AddNew(supplierPackage, clientPackage, connector.Direction, connector);
                            }
                        }
                    }
                }
            }
            ProgressInfo.Reset();
            return(dpList);
        }
Пример #4
0
        /// <summary>
        /// Add folder and it´s subfolders.
        /// </summary>
        /// <param name="folder">Path to folder to add.</param>
        /// <param name="progressInfo">Returns information about progress.</param>
        void AddSubFolders(string folder, ref ProgressInfo progressInfo)
        {
            AddFolder(folder, ref progressInfo);

            string[] subFolders = Directory.GetDirectories(folder);

            for (int i = 0; i < subFolders.Length; i++)
            {
                string currentSubFolder = subFolders[i];
                try
                {
                    if (Directory.GetDirectories(currentSubFolder).Length > 0)
                    {
                        AddSubFolders(currentSubFolder, ref progressInfo);
                    }
                    else
                    {
                        AddFolder(currentSubFolder, ref progressInfo);
                    }
                }
                catch (Exception)
                {
                    //TODO: Tell user he did not get all subfolders.
                    //Some windows hidden folders throw this exception.
                }

                if (progressInfo.IsStopping())
                {
                    progressInfo.ActivityEnded();
                    break;
                }
            }
        }
Пример #5
0
 private void MenuItemClick(object sender, EventArgs e)
 {
     try
     {
         CheckHostAndRepository();
         EA.Package package = IAHost.Repository.GetTreeSelectedPackage();
         if (!Equals(package, null))
         {
             //RSManipulation.Manipulation.GetAllElements(repository);
             ProgressInfo.Show(Resources.captionProgress, Resources.stateCheckStType);
             DependencyChecker.CheckPackageDependencies(IAHost.Repository, package);
             DependencyChecker.GenerateDiagram(IAHost.Repository, package);
             ProgressInfo.Close();
         }
         else
         {
             Messages.Message(Resources.msgNoPackageSelected, Resources.msgNoPackageSelectedCaption,
                              System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
         }
     }
     catch (Exception ex)
     {
         ProgressInfo.Close();
         Messages.ErrorMemo(Resources.msgUnknownError, ex.Message);
     }
     ProgressInfo.Close();
 }
Пример #6
0
        public void Start(string value, IProgress <ProgressInfo> progress, CancellationToken cancelToken, PauseToken pauseToken)
        {
            var total = 10;

            var note = "";

            for (var i = 0; i < total; i++)
            {
                if (cancelToken.IsCancellationRequested)
                {
                    cancelToken.ThrowIfCancellationRequested(); //throw OperationCanceledException
                }

                pauseToken.WaitWhilePausedAsync().GetAwaiter().GetResult();

                note += i + " - " + value + "<br/> \n";

                var pInfo = new ProgressInfo();
                pInfo.Percent = (int)Math.Round(((i + 1) / (double)total) * 100.00, MidpointRounding.AwayFromZero);;
                pInfo.Note    = note;
                if (progress != null)
                {
                    progress.Report(pInfo);
                }

                Thread.Sleep(1000);
            }

            return;
        }
Пример #7
0
            }             // proc WriteLine

            public override void WriteProgress(long sourceId, ProgressRecord record)
            {
                ProgressInfo pi;

                if (record.RecordType == ProgressRecordType.Completed)
                {
                    if (progress.TryGetValue(sourceId, out pi))
                    {
                        pi.AppendTime();
                        WriteVerboseLine(pi.ProgressText);
                        host.PowerShell.ProgressCompleted?.Invoke(host.PowerShell, EventArgs.Empty);
                    }
                }
                else
                {
                    if (progress.TryGetValue(sourceId, out pi))
                    {
                        pi.UpdateActivity(record.Activity);
                    }
                    else
                    {
                        progress[sourceId] = pi = new ProgressInfo(record.Activity);
                    }

                    pi.UpdateStatusText(record.CurrentOperation);

                    host.PowerShell.Progress?.Invoke(host.PowerShell, new DynamicPowerShellProgressArgs(record));
                }
            }             // proc WriteProgress
Пример #8
0
        private void ProgressCallback(ProgressInfo progressInfo)
        {
            this.CurrentProgressState.StatusText = progressInfo.Message;
            this.CurrentProgressState.Progress   = progressInfo.Progress;

            this.notificationsMessageHandler.ProgressUpdate(progressInfo.Message, progressInfo.Progress).Wait();
        }
Пример #9
0
        public async Task StartAsync(IProgress <ProgressInfo> progress, List <int> simpleList, CancellationToken cancelToken, PauseToken pauseToken)
        {
            var total   = simpleList.Count;
            var counter = 0;
            var pInfo   = new ProgressInfo();

            foreach (var number in simpleList)
            {
                if (cancelToken.IsCancellationRequested)
                {
                    cancelToken.ThrowIfCancellationRequested(); //throw OperationCanceledException
                }

                await pauseToken.WaitWhilePausedAsync(); //pause if IsPaused = true

                //Report progress
                counter++;
                pInfo.Percent = (int)Math.Round((counter / (double)total) * 100.00, MidpointRounding.AwayFromZero);
                if (progress != null)
                {
                    progress.Report(pInfo);
                }

                //Do main job
                var newnumber = number + 1;
                Thread.Sleep(2000);
            }
        }
Пример #10
0
        /// <summary>
        /// Zu allen Einträge in einem Dateisystemverzeichnis (Dateien und Unterverzeichnisse)
        /// werden DirEntryDeskriptoren angelegt. Danach werden diese in TreeNodes verpackt und
        /// als Kindelemente dem übergebenen Elternknoten hinzugefügt.
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="path"></param>
        public void ViewAsChildnodes(Wfm.TreeNode parent, string path)
        {
            var          dgCreateList = new DgCreateDirEntryList(CreateDirEntryList);
            IAsyncResult ares         = dgCreateList.BeginInvoke(path, null, null);

            while (!ares.IsCompleted)
            {
                // Die Verarbeitung von Nachrichten aus der Nachrichtenwarteschlange der Anwendung wird fortgesetz
                // Hierdurch wird ein Blockieren der Oberfläche vermieden
                System.Windows.Forms.Application.DoEvents();

                // Der aktuelle Prozessfortschritt wird angezeigt. Das Event wird im
                // UI- Thread der Anwendung gefeuert, wodurch auch Winform- Steuerelemente
                // im Eventhandler problemlos aktualisiert werden können (diese sind nicht
                // Threadsafe !)
                if (ProgressInfoEvent != null)
                {
                    var pinfo = new ProgressInfo()
                    {
                        AllEntriesCount = this.AllEntriesCount, ProcessedEntriesCount = this.ProcessedEntriesCount
                    };
                    ProgressInfoEvent(pinfo);
                }
            }

            // Das zeitaufwendige Einlesen der Informationen zu den Filesystementries ist beendet
            var list = dgCreateList.EndInvoke(ares);

            // Der Treeview wird aufgebaut
            ViewAsChildnodesImpl(parent, list);
        }
Пример #11
0
            private void bw_DoWork(object sender, DoWorkEventArgs e)
            {
                Thread.Sleep(1000);
                ProgressInfo progressInfo = new ProgressInfo();
                int          progress, elapsed;
                DateTime     time;

                while (!bw.CancellationPending)
                {
                    time = FastDateTime.Now;
                    try
                    {
                        progressInfo.ParseResponse(sendSpace.SendRequest(HttpMethod.POST, url));
                        if (progressInfo.Status != "fail" && !string.IsNullOrEmpty(progressInfo.Meter))
                        {
                            if (int.TryParse(progressInfo.Meter, out progress))
                            {
                                //sendSpace.OnProgressChanged(0, 0);
                            }
                        }
                    }
                    catch
                    {
                    }
                    elapsed = (int)(FastDateTime.Now - time).TotalMilliseconds;
                    if (elapsed < interval)
                    {
                        Thread.Sleep(interval - elapsed);
                    }
                }
            }
Пример #12
0
        private void ProgressNotificationHandler(ProgressInfo info)
        {
            switch (info.State)
            {
            case ProgressState.Start:
                StartNotificationHandler(info);
                break;

            case ProgressState.PerformStep:
                PerformStepNotificationHandler(info);
                break;

            case ProgressState.Complete:
                CompleteNotificationHandler(info);
                break;

            case ProgressState.Cancel:
                CancelNotificationHandler(info);
                break;

            case ProgressState.Error:
                ErrorNotificationHandler(info);
                break;
            }
        }
Пример #13
0
        protected void UpdateProgress(IProgress <ProgressInfo> progress, string progressActionText, int totalItemCount, int progressedItemCount)
        {
            if (progress != null)
            {
                int currentProgressPercentage = 0;
                if (totalItemCount > 0)
                {
                    currentProgressPercentage = progressedItemCount * 100 / totalItemCount;
                }

                if (_progressPercentage != currentProgressPercentage)
                {
                    _progressPercentage = currentProgressPercentage;

                    ProgressInfo progressInfoInfo = new ProgressInfo
                    {
                        ActionText       = progressActionText,
                        TotalItemCount   = totalItemCount,
                        CurrentItemCount = progressedItemCount,
                        ItemType         = "items",
                        Percentage       = currentProgressPercentage,
                        Done             = totalItemCount == progressedItemCount
                    };

                    progress.Report(progressInfoInfo);
                }
            }
        }
Пример #14
0
 public override void WriteStructureAfterData(IDatabaseStructure db)
 {
     if (ProgressInfo != null)
     {
         ProgressInfo.SetCurWork("s_creating_references");
     }
     if (m_db.DatabaseCaps.ExecuteSql && !m_db.Dialect.DialectCaps.UncheckedReferences)
     {
         m_db.InvokeScript(dmp =>
         {
             foreach (var table in db.Tables)
             {
                 foreach (var cnt in table.GetConstraints <IForeignKey, IConstraint>())
                 {
                     try
                     {
                         dmp.CreateConstraint(cnt);
                     }
                     catch (Exception err)
                     {
                         ProgressInfo.LogMessageDetail("REFERENCE", LogLevel.Error, Texts.Get("s_error_creating_reference$fk", "fk", cnt.Name), err.ToString());
                     }
                 }
             }
         }, ProgressInfo);
     }
     //foreach (var table in m_dbStruct.Tables)
     //{
     //    var tdst = m_db.GetTable(table.FullName);
     //    tdst.CreateConstraints(table.GetConstraints<IForeignKey, IConstraint>());
     //}
 }
Пример #15
0
 void SetCurWork(string title)
 {
     if (ProgressInfo != null)
     {
         ProgressInfo.SetCurWork(title);
     }
 }
Пример #16
0
        public IEnumerable<ProgressInfo> AbstractCopy(AbstractFolder nodeElement)
        {
            var count = h_countFiles(this);

            var progressInfo = new ProgressInfo
            {
                All = count
            };

            Directory.CreateDirectory(nodeElement.AbstractPath);

            foreach (var item in FilesList)
            {
                var destination = nodeElement.AbstractCreateFile(item.AbstractName);
                item.AbstractCopy(destination);
                progressInfo.Current++;

                yield return progressInfo;
            }
            foreach (var item in DirectoriesList)
            {
                var createdFolder = nodeElement.AbstractCreateFolder(item.AbstractName);
                foreach (var innerItem in item.AbstractCopy(createdFolder))
                {
                    yield return innerItem;
                }
                progressInfo.Current++;

                yield return progressInfo;
            }
        }
 public ProgressStatusEventArgs(string status, int current, int total) : this(status)
 {
     Status   = status;
     Progress = new ProgressInfo {
         Current = current, Total = total
     };
 }
Пример #18
0
 protected override void DoRead(IDataQueue queue)
 {
     try
     {
         using (CsvReader cr = CreateReader())
         {
             ITableStructure        format = GetStructure(cr);
             IEnumerable <string[]> reader = cr;
             foreach (string[] row in reader)
             {
                 queue.PutRecord(new ArrayDataRecord(format, row));
             }
             queue.PutEof();
         }
     }
     catch (Exception e)
     {
         ProgressInfo.LogError(e);
         queue.PutError(e);
     }
     finally
     {
         queue.CloseWriting();
     }
     FinalizeBulkCopy();
 }
Пример #19
0
        public void Upload()
        {
            using (var db = new ATTDbContext()) {
                var msgIds = db.MsgIDs.Include(m => m.ProAwsys).Where(m => m.TaskId == _data.TaskId &&
                                                                      m.IsNeedTransform == true &&
                                                                      m.IsSend == false &&
                                                                      m.ProAwsysId != null).ToList();
                var          iDocTypeIds   = msgIds.GroupBy(g => g.IDocTypeId).Select(g => g.Key).ToList();
                var          SourceIds     = msgIds.GroupBy(g => g.ProAwsys.SourceId).Select(g => g.Key).ToList();
                var          senderConfigs = db.SenderConfigs.Where(c => iDocTypeIds.Contains(c.IDocTypeId) && SourceIds.Contains(c.SourceId)).ToList();
                ProgressInfo info          = new ProgressInfo(1, msgIds.Count, "");
                foreach (var item in msgIds)
                {
                    var    senderConfig = senderConfigs.Where(c => c.IDocTypeId == item.IDocTypeId && c.SourceId == item.ProAwsys.SourceId).First();
                    string msg          = $"MsgID:{item.MsgId} sent to interface:{senderConfig.senderinterface} component:{senderConfig.itgsendercomponent}";
                    ATTPayLoadsLog.Write(_data.GetLog(msg, LogType.Normal));

                    send(item, senderConfig);
                    item.IsSend = true;
                    item.SentDt = DateTime.UtcNow;
                    info.Msg    = item.MsgId;
                    _stepReporter.Report(info);
                    info.Current++;
                    ATTPayLoadsLog.Write(_data.GetLog(msg, LogType.Success));
                }

                ATTPayLoadsLog.Write(_data.GetLog(_data.UpdateMsgLog, LogType.Normal));

                db.SaveChanges();
                ATTPayLoadsLog.Write(_data.GetLog(_data.UpdateMsgLog, LogType.Success));
            }
        }
Пример #20
0
        /// <summary>
        /// 获取某一月的数据
        /// </summary>
        /// <param name="date"></param>
        /// <returns></returns>
        public List <Position> GetPositionsOfMonths(DateTime date, int monthCount, Func <ProgressInfo, bool> progressCallback)
        {
            List <Position>         pos     = new List <Position>();
            List <List <Position> > posList = new List <List <Position> >();

            for (int i = 0; i < monthCount; i++)
            {
                var             dateNew = date.AddMonths(-i);
                List <Position> list    = GetPositionsOfMonth(dateNew);
                posList.Add(list);
                pos.AddRange(list);
                if (progressCallback != null)
                {
                    ProgressInfo progress = new ProgressInfo(list);
                    progress.Index = i + 1;
                    progress.Total = monthCount;
                    progress.Count = list.Count;
                    progress.Date  = dateNew;
                    if (progressCallback(progress) == false)
                    {
                        break;
                    }
                }
            }
            return(pos);
        }
Пример #21
0
        private void UpdateProgress(IProgress <ProgressInfo> progress)
        {
            if (progress != null)
            {
                int totalItemCount      = _totalElementCount + _totalRelationCount;
                int progressedItemCount = _progressedElementCount + _progressedRelationCount;

                int currentProgressPercentage = 0;
                if (totalItemCount > 0)
                {
                    currentProgressPercentage = progressedItemCount * 100 / totalItemCount;
                }

                if (_progressPercentage != currentProgressPercentage)
                {
                    _progressPercentage = currentProgressPercentage;

                    ProgressInfo progressInfoInfo = new ProgressInfo
                    {
                        ActionText       = _progressActionText,
                        Percentage       = currentProgressPercentage,
                        TotalItemCount   = totalItemCount,
                        CurrentItemCount = progressedItemCount,
                        ItemType         = "items",
                        Done             = totalItemCount == progressedItemCount
                    };

                    progress.Report(progressInfoInfo);
                }
            }
        }
Пример #22
0
        static void stressTester_Progress(ProgressInfo progress)
        {
            if (progress.SecondsProcessed < 1)
            {
                return;
            }

            string text = progress.RequestsProcessed.ToString("n0") +
                          " requests, " + progress.RequestsFailed.ToString("n0") + " failed | " +
                          progress.SecondsProcessed + " of " +
                          progress.TotalSecondsToProcessed + " secs " +
                          "| " + (progress.RequestsProcessed / progress.SecondsProcessed).ToString("n0") + " requests/sec ";

            lock (consoleLock2)
            {
                if (progress.RequestsFailed > lastFailed)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                }

                Console.WriteLine(text);

                if (progress.RequestsFailed > lastFailed)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    lastFailed = progress.RequestsFailed;
                }
            }
        }
Пример #23
0
        public void ChangeProgress(ProgressInfo info)
        {
            if (info.MaxValue == info.Value || info.IsHaveCancel)
            {
                Close();
            }

            if (info.IsArchivation)
            {
                textForDescription.Text = "Выполняется архивация";
            }
            else
            {
                textForDescription.Text = "Выполняется разархивация";
            }

            if (info.CurrentFile != null)
            {
                textForCurrentFile.Text = "Обрабатываемый файл/папка " + info.CurrentFile;
            }

            if (info.MaxValue != -1)
            {
                progressBar.Maximum = info.MaxValue;
            }

            if (info.Value != -1)
            {
                progressBar.Value = info.Value;
            }
        }
Пример #24
0
        public List <PositionList> GetPositionsCountOfDays(DateTime date, int dayCount, Func <ProgressInfo, bool> progressCallback)
        {
            List <PositionList> pos = new List <PositionList>();

            for (int i = 0; i < dayCount; i++)
            {
                var          dateNew = date.AddDays(-i);
                PositionList list    = GetPositionsCountOfDay(dateNew);
                pos.Add(list);
                if (progressCallback != null)
                {
                    ProgressInfo progress = new ProgressInfo(list);
                    progress.Index = i + 1;
                    progress.Total = dayCount;
                    progress.Count = list.Count;
                    progress.Date  = dateNew;
                    if (progressCallback(progress) == false)
                    {
                        break;
                    }
                }
            }

            return(pos);
        }
Пример #25
0
            private void DoWork(CancellationToken ct)
            {
                Thread.Sleep(1000);
                ProgressInfo progressInfo = new ProgressInfo();
                DateTime     time;

                while (!ct.IsCancellationRequested)
                {
                    time = DateTime.Now;
                    try
                    {
                        string response = sendSpace.SendRequest(HttpMethod.POST, url);

                        progressInfo.ParseResponse(response);

                        if (progressInfo.Status != "fail" && !string.IsNullOrEmpty(progressInfo.Meter))
                        {
                            if (int.TryParse(progressInfo.Meter, out int progress))
                            {
                                //sendSpace.OnProgressChanged(0, 0);
                            }
                        }
                    }
                    catch
                    {
                    }
                    int elapsed = (int)(DateTime.Now - time).TotalMilliseconds;
                    if (elapsed < interval)
                    {
                        Thread.Sleep(interval - elapsed);
                    }
                }
            }
Пример #26
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "Player")
     {
         ProgressInfo.ChangeLevel(true, 1);                  //Increments the level by one
     }
 }
        public async Task <IActionResult> ProgressAsync()
        {
            try
            {
                string dataDir          = tumbleBitManager.TumblingState.NodeSettings.DataDir;
                string tumbleBitDataDir = FullNodeTumblerClientConfiguration.GetTumbleBitDataDir(dataDir);

                string filename = Path.Combine(tumbleBitDataDir, ProgressInfo.TumbleProgressFileName);
                if (System.IO.File.Exists(filename) == false)
                {
                    return(this.Json(string.Empty));
                }
                else
                {
                    string progress = await System.IO.File.ReadAllTextAsync(filename).ConfigureAwait(false);

                    ProgressInfo progressInfo = JsonConvert.DeserializeObject <ProgressInfo>(progress);
                    return(this.Json(progressInfo));
                }
            }
            catch (Exception e)
            {
                return(Client.ErrorHelpers.BuildErrorResponse(HttpStatusCode.BadRequest, $"Could not get progress.", e.ToString()));
            }
        }
Пример #28
0
        public override void Decompress(string path, IProgress <ProgressInfo> onProgressArchivationChanged) //не используется, не обработан случай, если распакованный файл уже есть
        {
            using (FileStream zip = new FileStream(path, FileMode.Open))
            {
                using (ZipArchive archive = new ZipArchive(zip, ZipArchiveMode.Read))
                {
                    string       pathToExtract = Path.GetDirectoryName(path);
                    ProgressInfo info          = new ProgressInfo(0, archive.Entries.Count, false);
                    foreach (var file in archive.Entries)
                    {
                        string test = "";
                        if (file.FullName.Contains("/"))
                        {
                            test = Path.Combine(pathToExtract, Path.GetDirectoryName(file.FullName));
                            if (!Directory.Exists(Path.Combine(pathToExtract, Path.GetDirectoryName(file.FullName))))
                            {
                                Directory.CreateDirectory(Path.Combine(pathToExtract, Path.GetDirectoryName(file.FullName)));
                            }
                        }
                        if (Path.HasExtension(file.FullName))
                        {
                            test = Path.Combine(pathToExtract, file.FullName);
                            //
                            file.ExtractToFile(Path.Combine(pathToExtract, file.FullName));
                        }

                        info.Value++;
                        onProgressArchivationChanged.Report(info);
                    }
                }
            }
        }
Пример #29
0
        protected override void AfterWriteAction(string file)
        {
            base.AfterWriteAction(file);

            var         cfg  = GlobalSettings.Pages.Email();
            MailMessage mail = new MailMessage();

            mail.From = cfg.GetFromAddress();
            foreach (string addr in To.Split(';'))
            {
                mail.To.Add(addr);
            }
            mail.Subject    = NameTemplateEngine.Eval(Subject);
            mail.Body       = Body;
            mail.IsBodyHtml = false;
            using (var fr = new FileInfo(file).OpenRead())
            {
                var att = new Attachment(fr, Path.ChangeExtension(AttachmentName, Path.GetExtension(file)));
                mail.Attachments.Add(att);

                SmtpClient smtp = cfg.GetClient();
                ProgressInfo.Info("Sending mail to " + To);
                smtp.Send(mail);
            }
        }
Пример #30
0
        private void UpdateProgress(ProgressInfo info)
        {
            // Update scores and chart.
            if ((info.Data != null) && !Op.IsCanceled)
            {
                _diskScores[0].Data = info.Data;

                UpdateScores();
                _mainWindow.DrawChart(DrawMode.DrawNewChart);
            }

            // Update status.
            if (info.Status != null)
            {
                Status = info.Status;
            }

            // Update inner status.
            if (info.InnerStatus != null)
            {
                InnerStatus = info.IsInnerStatusRenewed
                                        ? info.InnerStatus
                                        : InnerStatus.Insert(0, info.InnerStatus + Environment.NewLine);
            }
        }
Пример #31
0
        public IPAddressVModel()
        {
            Progress = new ProgressInfo(0, false);
            IPListOC = new ObservableCollection <IPProfile>(IPManager.IPList);

            //http://msdn.microsoft.com/en-us/library/hh198861.aspx
            System.Windows.Data.BindingOperations.EnableCollectionSynchronization(IPListOC, lock_sync);
        }
        protected override void Process(ProgressInfo rpProgress, BattleInfo rpBattle, RawBattleResult rpResult)
        {
            if (!rpBattle.IsBossBattle)
                return;

            var rSortie = SortieInfo.Current;
            if (MapIDs.Contains(rSortie.Map.ID) && rpResult.Rank >= LowestRank)
                rpProgress.Progress++;
        }
        void UpdatePercentage(ProgressInfo rpProgress, BitVector32 rpBits)
        {
            var rPercent = 0.0;
            rPercent += Math.Min(rpBits[r_Sections[0]] / (double)36, 1.0);
            rPercent += Math.Min(rpBits[r_Sections[1]] / (double)6, 1.0);
            rPercent += Math.Min(rpBits[r_Sections[2]] / (double)24, 1.0);
            rPercent += Math.Min(rpBits[r_Sections[3]] / (double)12, 1.0);

            rpProgress.Percentage = rPercent;
        }
Пример #34
0
        internal void UpdatePercentage(ProgressInfo rpProgress, BitVector32 rpBits)
        {
            var rPercent = .0;

            rPercent += Math.Min(rpBits[r_Sections[0]] / 36.0, 1.0);
            rPercent += Math.Min(rpBits[r_Sections[1]] / 6.0, 1.0);
            rPercent += Math.Min(rpBits[r_Sections[2]] / 24.0, 1.0);
            rPercent += Math.Min(rpBits[r_Sections[3]] / 12.0, 1.0);

            rpProgress.Percentage = rPercent * .25;
        }
        protected override void Process(ProgressInfo rpProgress, BattleInfo rpBattle, RawBattleResult rpResult)
        {
            var rBits = new BitVector32(rpProgress.Progress);

            if (rpResult.Rank >= BattleRank.S)
                rBits[r_Sections[1]] = Math.Min(rBits[r_Sections[1]] + 1, 6);
            if (rpBattle.IsBossBattle)
                rBits[r_Sections[2]] = Math.Min(rBits[r_Sections[2]] + 1, 24);
            if (rpBattle.IsBossBattle && rpResult.Rank >= BattleRank.B)
                rBits[r_Sections[3]] = Math.Min(rBits[r_Sections[3]] + 1, 12);

            rpProgress.Progress = rBits.Data;
            UpdatePercentage(rpProgress, rBits);
        }
Пример #36
0
		private void OnCurrentProgressChanged(ProgressInfo oldInfo, ProgressInfo newInfo)
		{
			if (oldInfo != null)
			{
				oldInfo.ProgressUpdated -= OnProgressUpdated;
			}

			if (newInfo != null)
			{
				newInfo.ProgressUpdated += OnProgressUpdated;
			}

			OnProgressUpdated();
		}
Пример #37
0
 public void StartProgress(object sender, Framework.EventArguments.ProgressEventArgs e)
 {
     _cancelled = false;
     buttonCancel.Text = Utils.LanguageSupport.Instance.GetTranslation("Cancel");
     buttonCancel.Visible = e.CanCancel;
     buttonCancel.Enabled = true;
     ProgressInfo pi = new ProgressInfo();
     pi.ActionText = Utils.LanguageSupport.Instance.GetTranslation(e.ActionText);
     pi.ActionTitle = Utils.LanguageSupport.Instance.GetTranslation(e.ActionTitle);
     pi.Max = e.Max;
     pi.Pos = e.Position;
     _progressStack.Add(pi);
     UpdateProgressInfo(pi);
 }
Пример #38
0
 private void UpdateProgressInfo(ProgressInfo pi)
 {
     try
     {
         this.Text = pi.ActionTitle;
         this.labelProgressTitle.Text = pi.ActionText;
         this.progressBar1.Maximum = pi.Max;
         this.progressBar1.Value = Math.Min(pi.Pos, pi.Max);
         this.labelMin.Text = "1";
         this.labelMax.Text = pi.Max.ToString();
         this.labelPos.Text = pi.Pos.ToString();
     }
     catch
     {
     }
 }
Пример #39
0
        private void WriteSafe(string message, Progress progress)
        {
            UpdateProgress();
            AppendText(Environment.NewLine + message);

            if (progress != null)
            {AppendText("".PadLeft(50 - message.Length));

                var info = new ProgressInfo();
                info.Progress = progress;
                info.Start = SelectionStart;
                AppendText("".PadLeft(ProgressInfo.MaxTextLength));
                info.End = SelectionStart;
                info.Update(this);
                ongoingProgresses.Add(info);
            }
        }
Пример #40
0
        public static void DeleteFolderGUI(Control parent, string strFolder, string strTitle)
        {
            if (parent.InvokeRequired)
            {
                parent.Invoke(new DeleteFolderGuiDelegate(DeleteFolderGUI), new object[] { parent, strFolder, strTitle });
            }
            else
            {
                if (!Directory.Exists(strFolder)) return;

                ProgressInfo pi = new ProgressInfo();
                pi.progress = new ProgressWindow();
                pi.strOrigFolder = pi.strFolder = strFolder;
                pi.lCounter = 0;
                pi.lTotalSize = 0;
                pi.progress.Text = strTitle;
                ThreadPool.QueueUserWorkItem(new WaitCallback(DeleteFolderRecursive), pi);
                pi.progress.ShowDialog(parent);
            }
        }
Пример #41
0
		public void Add(ProgressInfo indicator)
		{
			indicators.Insert(0, indicator);
			OnActivitiesChanged();
			DebugLog.Info(GetActivities());
		}
Пример #42
0
 private void bw_DoWork(object sender, DoWorkEventArgs e)
 {
     Thread.Sleep(1000);
     ProgressInfo progressInfo = new ProgressInfo();
     int progress, elapsed;
     DateTime time;
     while (!bw.CancellationPending)
     {
         time = FastDateTime.Now;
         try
         {
             progressInfo.ParseResponse(sendSpace.SendRequest(HttpMethod.POST, url));
             if (progressInfo.Status != "fail" && !string.IsNullOrEmpty(progressInfo.Meter))
             {
                 if (int.TryParse(progressInfo.Meter, out progress))
                 {
                     //sendSpace.OnProgressChanged(0, 0);
                 }
             }
         }
         catch
         {
         }
         elapsed = (int)(FastDateTime.Now - time).TotalMilliseconds;
         if (elapsed < interval)
         {
             Thread.Sleep(interval - elapsed);
         }
     }
 }
Пример #43
0
 private void OnProgress(ProgressInfo progressinfo)
 {
     this.Progress?.Invoke(progressinfo);
 }
 /// <summary>
 /// Controls the set progress changed.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The e.</param>
 private void ControlSetProgressChanged(object sender, ProgressInfo e)
 {
     ReportProgress(e.TotalDocumentCount, e.ProcessedDocumentCount);
 }
 Task StatusChange(Status status, ProgressInfo info) => _eventRaiser(new StatusChanged(status, info));
 /// <summary>
 /// TrainModel progress changed.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The e.</param>
 private void TrainModelProgressChanged(object sender, ProgressInfo e)
 {
     ReportProgress(e.TotalDocumentCount, e.ProcessedDocumentCount);
 }
Пример #47
0
        static void stressTester_Progress(ProgressInfo progress)
        {
            if (progress.SecondsProcessed < 1)
                return;

            string text = progress.RequestsProcessed.ToString("n0") +
                          " requests, " + progress.RequestsFailed.ToString("n0") + " failed | " +
                          progress.SecondsProcessed + " of " +
                          progress.TotalSecondsToProcessed + " secs " +
                            "| " + (progress.RequestsProcessed / progress.SecondsProcessed).ToString("n0") + " requests/sec ";

            lock (consoleLock2)
            {
                if (progress.RequestsFailed > lastFailed)
                    Console.ForegroundColor = ConsoleColor.Red;

                Console.WriteLine(text);

                if (progress.RequestsFailed > lastFailed)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    lastFailed = progress.RequestsFailed;
                }
            }
        }
Пример #48
0
 protected abstract void Process(ProgressInfo rpProgress, BattleInfo rpBattle, RawBattleResult rpResult);
Пример #49
0
		/* Add the progressBar */
		public virtual void addProgress(int nodePosition, ProgressInfo progressInfo)
		{
			List<ProgressInfo> progressInfoList = mNodeInfoList[nodePosition].progressInfoList;
			progressInfoList.Add(progressInfo);

			notifyDataSetChanged();
		}
Пример #50
0
		/* Add or Update the progressBar */
		public virtual void setProgressUpdate(string interfaceName, string node, string trId, int fileIndex, int progress, bool bMulti, bool bSend)
		{

			int nodePosition = getNodePosition(interfaceName, node);
			if (nodePosition == -1)
			{
				Log.d(TAG, TAGClass + "setProgressUpdate(fileIdx[" + fileIndex + "]) : no such a node - " + node);
				return;
			}

			int progressPosition = getProgressPosition(nodePosition, fileIndex, trId);

			if (progressPosition == -1)
			{ // Add the progressBar
				if (null != fileCancelHashMap[trId])
				{
					Log.d(TAG, TAGClass + "fileChunk is received/sent after click the cancel button.");
					fileCancelHashMap.Remove(trId);
					return;
				}

				ProgressInfo progressInfo = new ProgressInfo(this, this);
				progressInfo.trId = trId;
				progressInfo.bMulti = bMulti;
				progressInfo.fileIndex = fileIndex;
				progressInfo.progress = progress;
				progressInfo.bSend = bSend;

				addProgress(nodePosition, progressInfo);

			}
			else
			{ // Update the progressBar - save the percentage of the file
					 // transfer
				List<ProgressInfo> progressList = mNodeInfoList[nodePosition].progressInfoList;
				progressList[progressPosition].progress = progress;

				notifyDataSetChanged();
			}
		}
 private void CategorizeAnalysisSetProgressChanged(object sender, ProgressInfo e)
 {
     ReportProgress(e.TotalDocumentCount, e.ProcessedDocumentCount);
 }
Пример #52
0
 public abstract void Invoke(ProgressInfo rpProgressInfo);
Пример #53
0
 private void OnOnBackupFail(ProgressInfo progressinfo)
 {
     var fail = this.Fail;
     fail?.Invoke(progressinfo);
 }
Пример #54
0
		public void Remove(ProgressInfo indicator)
		{
			indicators.Remove(indicator);
			OnActivitiesChanged();
			DebugLog.Info(GetActivities());
		}
 public StatusChanged(Status status, ProgressInfo info) {
     Contract.Requires<ArgumentNullException>(info != null);
     Status = status;
     Info = info;
 }
Пример #56
0
 public ProgressReporter()
 {
     P = new ProgressInfo();
     ts = new TimeSpan();
 }
Пример #57
0
        private void UiWrite(string message, Progress progress, MessageType type)
        {
            UpdateProgress();

            if (progress == null)
            {
                var textBlock = new TextBlock();
                textBlock.Text = message;
                stack.Children.Add(textBlock);

                if (type == MessageType.Error)
                {
                    textBlock.Foreground = Brushes.OrangeRed;
                    textBlock.FontWeight = FontWeights.Bold;
                }
                else if (type == MessageType.Header)
                {
                    textBlock.Foreground = Brushes.SkyBlue;
                    textBlock.Background = Brushes.Gray;
                    textBlock.FontWeight = FontWeights.Bold;
                }
            }
            else
            {
                var s = new StackPanel();
                s.Orientation = Orientation.Horizontal;
                var textBlockMessage = new TextBlock();
                var textBlockProgress = new TextBlock();
                textBlockMessage.Text = message;
                textBlockMessage.MinWidth = 250;
                textBlockProgress.Foreground = Brushes.Blue;

                s.Children.Add(textBlockMessage);
                s.Children.Add(textBlockProgress);

                stack.Children.Add(s);

                var info = new ProgressInfo();
                info.Progress = progress;
                info.Block = textBlockProgress;
                info.Update();
                ongoingProgresses.Add(info);
            }
            scrollViewer.ScrollToEnd();
        }
Пример #58
0
        /*
        public static async Task Busy(Func<Task> act) {
            await StatusChange(Status.Preparing, ProgressInfo.Default).ConfigureAwait(false);
            try {
                await act().ConfigureAwait(false);
            } finally {
                await StatusChange(Status.Synchronized, ProgressInfo.Default).ConfigureAwait(false);
            }
        }

        public static async Task<T> Busy<T>(Func<Task<T>> act) {
            await StatusChange(Status.Preparing, ProgressInfo.Default).ConfigureAwait(false);
            try {
                return await act().ConfigureAwait(false);
            } finally {
                await StatusChange(Status.Synchronized, ProgressInfo.Default).ConfigureAwait(false);
            }
        }
        */

        private static Task StatusChange(Status status, ProgressInfo info) => new StatusChanged(status, info).Raise();
 protected override void Process(ProgressInfo rpProgress, BattleInfo rpBattle, RawBattleResult rpResult)
 {
     rpProgress.Progress += rpBattle.CurrentStage.Enemy.Count(r => r.State == BattleParticipantState.Sunk && TargetType.Contains(r.Participant.Info.Type.ID));
 }
Пример #60
0
			} // proc WriteLine

			public override void WriteProgress(long sourceId, ProgressRecord record)
			{
				ProgressInfo pi;
				if (record.RecordType == ProgressRecordType.Completed)
				{
					if (progress.TryGetValue(sourceId, out pi))
					{
						pi.AppendTime();
						WriteVerboseLine(pi.ProgressText);
						host.PowerShell.ProgressCompleted?.Invoke(host.PowerShell, EventArgs.Empty);
					}
				}
				else
				{
					if (progress.TryGetValue(sourceId, out pi))
						pi.UpdateActivity(record.Activity);
					else
						progress[sourceId] = pi = new ProgressInfo(record.Activity);

					pi.UpdateStatusText(record.CurrentOperation);

					host.PowerShell.Progress?.Invoke(host.PowerShell, new DynamicPowerShellProgressArgs(record));
				}
			} // proc WriteProgress