当前位置: 首页>>代码示例>>C#>>正文


C# ProgressBar.Report方法代码示例

本文整理汇总了C#中ProgressBar.Report方法的典型用法代码示例。如果您正苦于以下问题:C# ProgressBar.Report方法的具体用法?C# ProgressBar.Report怎么用?C# ProgressBar.Report使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProgressBar的用法示例。


在下文中一共展示了ProgressBar.Report方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            String filepath = @"F:\Images\";
            var deleteFolderPath = @"F:\DeleteImages\";
            var logFile = new StreamWriter(filepath + "results.log");
            DirectoryInfo di = new DirectoryInfo(filepath);
            double i = 0;
            using (ProgressBar pb = new ProgressBar())
            {
                double files = di.GetFiles().Length;

                Console.Write("Counting files in folder :");
                foreach (var fileInfo in di.GetFiles())
                {
                    pb.Report((i/files));
                    if ((i/files) < 0.95)
                    {
                        i++;
                        continue;
                    }

                    if (fileInfo.Extension != ".jpg" && fileInfo.Extension != ".jpeg" && fileInfo.Extension != ".bmp" && fileInfo.Extension != ".png")
                    {
                        i++;
                        continue;
                    }

                    var bitmap = Image.FromFile(fileInfo.FullName);
                    var a = bitmap.Size;//ImageHelper.GetDimensions(fileInfo.FullName);
                    bitmap.Dispose();

                    try
                    {
                        if (a.Height > 2000 && a.Width < 2000)
                        {
                            File.Move(fileInfo.FullName, deleteFolderPath + fileInfo.Name);
                        }
                        else if (a.Height < 2000 && a.Width < 2000)
                        {
                            File.Move(fileInfo.FullName, deleteFolderPath + fileInfo.Name);
                        }
                    }
                    catch (Exception ex)
                    {
                        logFile.WriteLineAsync("Error");
                    }

                    i++;
                }
            }

            logFile.Close();
            Console.WriteLine();
            Console.WriteLine("Task Completed.");
            var throwaway = Console.ReadLine();
        }
开发者ID:Beaverkilla,项目名称:SmallBackgroundMover,代码行数:56,代码来源:Program.cs

示例2: ExportAll

            private void ExportAll(List<SwiftContainerModel> containers, string path, Dictionary<string, string> queryParams = null)
            {
                foreach (var container in containers)
                {
                    listQueue.Enqueue(new ContainerRequest
                    {
                        Container = container.Container,
                        Query = queryParams
                    });
                }

                while (!listQueue.IsEmpty)
                {
                    ContainerRequest request = null;

                    if (listQueue.TryDequeue(out request))
                    {
                        var containerData = client.GetContainer(request.Container, null, request.Query).Result;
                        if (containerData.IsSuccess)
                        {
                            if (containerData.Objects.Count > 0)
                            {
                                if (containerData.Objects.Count < containerData.ObjectsCount)
                                {
                                    var marker = containerData.Objects.OrderByDescending(x => x.Object).Select(x => x.Object).FirstOrDefault();

                                    var newRequest = new ContainerRequest()
                                    {
                                        Container = request.Container,
                                        Query = request.Query
                                    };

                                    if (newRequest.Query == null)
                                    {
                                        newRequest.Query = new Dictionary<string, string>();
                                    }

                                    newRequest.Query["marker"] = marker;

                                    listQueue.Enqueue(newRequest);
                                }

                                var target = Path.Combine(path, request.Container);

                                if (!Directory.Exists(target))
                                {
                                    Directory.CreateDirectory(target);
                                }

                                EnqueueObjects(request.Container, containerData.Objects, target);
                            }
                            
                        }
                    }
                }

                if (downloadBag.Any())
                {
                    Console.Write("Exporting... ");

                    var objCount = downloadBag.Count;

                    var progress = new ProgressBar();

                    Parallel.For(0, objCount - 1, new ParallelOptions { MaxDegreeOfParallelism = 10 },
                      i =>
                      {
                          var downloadObj = downloadBag.ElementAt(i);

                          try
                          {
                              var response = ExportObject(downloadObj).Result;

                              Interlocked.Increment(ref counter);

                              if (!response.IsSuccess)
                              {
                                  ManageFailed(new FailedObject
                                  {
                                      Container = downloadObj.Container,
                                      Message = response.Message,
                                      Object = downloadObj.Object
                                  });
                              }
                          }
                          catch (Exception ex)
                          {
                              ManageFailed(new FailedObject
                              {
                                  Container = downloadObj.Container,
                                  Message = ex.Message,
                                  Object = downloadObj.Object
                              });
                          }

                          progress.Report((double)counter / objCount);
                      });

                    progress.Report(1);
                    progress.Dispose();
//.........这里部分代码省略.........
开发者ID:vtfuture,项目名称:SwiftClient,代码行数:101,代码来源:ExportCommand.cs

示例3: PutObjects

            public void PutObjects()
            {
                var dirs = Directory.GetDirectories(rootPath);

                foreach(var dir in dirs)
                {
                    var files = Directory.GetFiles(dir);

                    foreach(var file in files)
                    {
                        uploadBag.Add(new UploadObject
                        {
                            Container = new DirectoryInfo(dir).Name,
                            Object = PathEscaper.Unescape(Path.GetFileName(file)),
                            Path = file
                        });
                    }
                }

                if (uploadBag.Any())
                {
                    Console.Write("Importing... ");

                    var objCount = uploadBag.Count;

                    var progress = new ProgressBar();

                    Parallel.For(0, objCount - 1, new ParallelOptions { MaxDegreeOfParallelism = 10 },
                      i =>
                      {
                          var uploadObj = uploadBag.ElementAt(i);

                          try
                          {
                              var response = ImportObject(uploadObj).Result;

                              Interlocked.Increment(ref counter);

                              if (!response.IsSuccess)
                              {
                                  ManageFailed(new FailedObject
                                  {
                                      Container = uploadObj.Container,
                                      Message = response.Message,
                                      Object = uploadObj
                                  });
                              }
                          }
                          catch (Exception ex)
                          {
                              ManageFailed(new FailedObject
                              {
                                  Container = uploadObj.Container,
                                  Message = ex.Message,
                                  Object = uploadObj
                              });
                          }

                          progress.Report((double)counter / objCount);
                      });

                    progress.Report(1);
                    progress.Dispose();
                    Console.WriteLine(" Done.");
                }
            }
开发者ID:vtfuture,项目名称:SwiftClient,代码行数:66,代码来源:ImportCommand.cs

示例4: Main


//.........这里部分代码省略.........
                                Console.Write(Output.Generate(volumes, volumeCount));

                                break;
                            };
                        case CommandNames.GetRemovableVolumes :
                            {
                                RemovableVolumeInfoArray volumes;
                                ushort volumeCount;

                                Api.GetRemovableVolumes(out volumes, out volumeCount);

                                Console.Write(Output.Generate(volumes, volumeCount));

                                break;
                            };
                        case CommandNames.AllocateSwapStorage:
                            {
                                var deviceName = commandLine.GetArgAsString(1);
                                var storageSize = commandLine.GetArgAsInt64(2);
                                var securityToken = commandLine.GetArgAsStringOrEmpty(3);

                                Api.StartSwapStorageAllocation(securityToken, deviceName, ref storageSize);

                                Console.Write("Allocating... ");

                                FixedVolumeSwapStorageInfo swapStorageInfo;

                                using (var progress = new ProgressBar())
                                {
                                    do 
                                    { 
                                        Api.GetSwapStorageInfo(deviceName, out swapStorageInfo);
                                        
                                        progress.Report((double)swapStorageInfo.size / (storageSize * 1024 * 1024));
                                        
                                        Thread.Sleep(50);
                                    }
                                    while (swapStorageInfo.status == FixedVolumeSwapStorageStatus.Allocating);                                    
                                }

                                Console.SetCursorPosition(0, Console.CursorTop);
                                Console.WriteLine("Success                             ");

                                break;
                            };
                        case CommandNames.RemoveSwapStorage :
                            {
                                var deviceName = commandLine.GetArgAsString(1);
                                var securityToken = commandLine.GetArgAsStringOrEmpty(2);

                                Api.RemoveSwapStorage(securityToken, deviceName);
                                
                                Console.WriteLine("Success");

                                break;
                            };
                        case CommandNames.RemoveSwapStorages :
                            {
                                var deviceName = commandLine.GetArgAsString(1);

                                Api.RemoveSwapStorages(deviceName);
                                
                                Console.WriteLine("Success");

                                break;
                            };
开发者ID:stuebersystems,项目名称:sherlock.console,代码行数:67,代码来源:Program.cs

示例5: GetAllTestPlanInfo

 /// <summary>
 /// Main work method.
 /// </summary>
 /// <param name="newTestPlans">All test plans inside the team project.</param>
 /// <param name="plansJSONPath">The path to write the audit .json to</param>
 /// <param name="logPath">The path to write errors etc.</param>
 /// <param name="csvPath">The path to write the audit .csv to</param>
 private static void GetAllTestPlanInfo(ITestPlanCollection newTestPlans, string plansJSONPath, string logPath, string csvPath)
 {
     List<MigrationTestPlan> testPlans = new List<MigrationTestPlan>();
     foreach (ITestPlan testPlan in newTestPlans)
     {
         // Check to see if we want to work on this plan
         bool collectLinks = YesNoInput("\nCollect links and perform alignment for Test Plan \"" + testPlan.Name + " (" + testPlan.Id + ")\"?\n\t" + "Enter y/n:");
         if (collectLinks)
         {                    
             List<MigrationWorkItem> migratedWorkItems = new List<MigrationWorkItem>();
             List<ITestCase> allTestCases = GetTestCases(testPlan);
             int i = 1;
             int numTestCases = allTestCases.Count;
             if (numTestCases > 0)
             {
                 Trace.Write("Processing all links in Plan \"" + testPlan.Name + " (" + testPlan.Id + ")\"...\n\t");
             }
             using (var progress = new ProgressBar())
             {
                 foreach (var testCase in allTestCases)
                 {
                     ProcessLinks(migratedWorkItems, testCase);
                     progress.Report((double)i / numTestCases);
                     i++;
                 }                        
             }
             testPlans.Add(new MigrationTestPlan()
             {
                 TestPlanName = testPlan.Name,
                 ID = testPlan.Id,
                 TestCases = migratedWorkItems
             });
         }                
     }
     PerformAlignment(logPath, testPlans);
     WritePlansAndAllLinks(plansJSONPath, csvPath, testPlans);
 }
开发者ID:Ryanman,项目名称:CustomTools.AlignMigration,代码行数:44,代码来源:AlignMigration.cs

示例6: PerformAlignment

        /// <summary>
        /// Updates the new test cases with information from the old test cases, using the MigrationWorkItem structure.
        /// Writes errors to log files, located in path defined in App.config
        /// </summary>
        /// <param name="logPath">Path to the log file, used to write area inconsistencies</param>
        /// <param name="testPlans">A collection of test plans, each with MigrationWorkItems inside</param>
        private static void PerformAlignment(string logPath, List<MigrationTestPlan> testPlans)
        {
            Trace.WriteLine("\nPreparing to perform alignment for saved test cases.");
            Console.WriteLine("\tPress Enter to Continue.");
            Console.ReadLine();
            string newItemAreaPath, oldItemAreaPath;
            HashSet<string> badAreas = new HashSet<string>();
            List<string> unalignedTestCases = new List<string>();
            foreach (var testPlan in testPlans)
            {
                int i = 1;
                int numTestCases = testPlan.TestCases.Count;
                if (numTestCases > 0) 
                {
                    Trace.WriteLine("\nWriting information to copied test cases in Plan \"" + testPlan.TestPlanName + " (" + testPlan.ID + ")\"...\t");
                    using (var progress = new ProgressBar())
                    {
                        foreach (var testCase in testPlan.TestCases)
                        {
                            WorkItem newItem = workItemStore.GetWorkItem(int.Parse(testCase.NewID));
                            newItemAreaPath = newItem.AreaPath;
                            try
                            {
                                newItem.History = testCase.OldHistory;
                                newItem.Fields["System.Description"].Value = testCase.OldTestSummary;
                                
                                newItem.Save();
                            }
                            catch (Exception e)
                            {
                                unalignedTestCases.Add("Test ID: " + newItem.Id.ToString() + " \tException: " + e.Message);
                            }
                            try
                            {
                                int oldRootIndex = testCase.OldItemAreaPath.IndexOf("\\");
                                int newRootIndex = newItem.AreaPath.IndexOf("\\");                                
                                if (oldRootIndex > -1) 
                                {
                                    // add path to new root
                                    oldItemAreaPath = testCase.OldItemAreaPath.Substring(oldRootIndex);
                                    if (newRootIndex > -1) 
                                    {
                                        // There are other elements after the root in the new path - let's fix them to match the old test case
                                        newItemAreaPath = newItem.AreaPath.Substring(0, newRootIndex) + oldItemAreaPath;
                                    }
                                    else 
                                    {
                                        // The new test case's area is a root area. Let's just add whatever path comes after the root from the old test case.
                                        newItemAreaPath = newItem.AreaPath + oldItemAreaPath;
                                    }                                    
                                }
                                newItem.AreaPath = newItemAreaPath;
                                newItem.Save();
                            }
                            catch (Exception e)
                            {
                                // Saving the path encountered an error. Write test case to log, and prepare to write area path to log.
                                badAreas.Add(newItemAreaPath);
                                unalignedTestCases.Add("Test Case: " + newItem.Id.ToString() + " - " + newItem.Title + " \tException: " + e.Message);
                            }
                            progress.Report((double)i / numTestCases);
                            i++;                            
                        }                        
                    }

                    // Write collected errors/bad areas to logfile
                    if (unalignedTestCases.Count > 0)
                    {
                        Trace.Write("\n\nErrors encountered in alignment for Test Plan \"" + testPlan.TestPlanName + "\":");
                        foreach (string testcase in unalignedTestCases)
                        {
                            Trace.Write("\n" + testcase);
                        }
                        unalignedTestCases.Clear();
                    }
                    if (badAreas.Count > 0)
                    {
                        Trace.Write("\n\nErrors encountered in alignment for Test Plan \"" + testPlan.TestPlanName + "\":");
                        foreach (string badArea in badAreas)
                        {
                            Trace.Write("\n" + badArea);
                        }
                        badAreas.Clear();
                    }
                }
            }            
        }
开发者ID:Ryanman,项目名称:CustomTools.AlignMigration,代码行数:93,代码来源:AlignMigration.cs

示例7: GetTestCases

 /// <summary>
 /// Retrieves all the test cases in a given test plan
 /// </summary>
 /// <param name="testPlan">The test plan with test cases we wish to retrieve</param>
 /// <returns>a list of type ITestCase containing all test cases in testPlan</returns>
 private static List<ITestCase> GetTestCases(ITestPlan testPlan)
 {
     List<ITestCase> testCases = new List<ITestCase>();
     testPlan.Refresh();
     Trace.WriteLine("\nGetting all Test Cases in Test Plan \"" + testPlan.Name + " (" + testPlan.Id + ")\"...\n\t");
     int i = 1;
     int numTestCases = testPlan.RootSuite.AllTestCases.Count;
     using (var progress = new ProgressBar())
     {
         foreach (ITestCase x in testPlan.RootSuite.AllTestCases)
         {
             progress.Report((double)i / numTestCases);
             testCases.Add(x);
             i++; 
         }
     }
     return testCases;
 }
开发者ID:Ryanman,项目名称:CustomTools.AlignMigration,代码行数:23,代码来源:AlignMigration.cs

示例8: xcopy

        public void xcopy(Command cmd)
        {
            if (cmd.HasHelp)
            {
                stdio.WriteLine("xcopy large size records, support table/database name wildcards");
                stdio.WriteLine("   table must have same structure");
                stdio.WriteLine("xcopy database1 [database2]");
                stdio.WriteLine("xcopy table1 [table2]");
                stdio.WriteLine("       /col:c1[=d1],c2[=d2],...         copy selected columns (mapping)");
                stdio.WriteLine("       /s                               compare table schema");
                stdio.WriteLine("note that: to xcopy selected records of table, mkdir locator first, example:");
                stdio.WriteLine(@"  \local\NorthWind\Products> md ProductId<2000");
                stdio.WriteLine(@"  \local\NorthWind\Products> xcopy 1 \local\db");
                return;
            }

            CancelableWork.CanCancel(cts =>
            {
                PathBothSide both = new PathBothSide(mgr, cmd);
                var dname2 = mgr.GetPathFrom<DatabaseName>(both.ps2.Node);
                if (both.ps1.MatchedTables == null)
                    return;

                foreach (var tname1 in both.ps1.MatchedTables)
                {
                    if (cts.IsCancellationRequested)
                        return;

                    TableName tname2 = mgr.GetPathFrom<TableName>(both.ps2.Node);
                    if (tname2 == null)
                        tname2 = new TableName(dname2, tname1.SchemaName, tname1.ShortName);

                    if (cmd.IsSchema)
                    {
                        string result = Compare.TableSchemaDifference(CompareSideType.compare, tname1, tname2);
                        if (!string.IsNullOrEmpty(result))
                        {
                            stdio.ErrorFormat("destination table is not compatible or doesn't exist");
                            continue;
                        }
                    }

                    List<SqlBulkCopyColumnMapping> maps = new List<SqlBulkCopyColumnMapping>();
                    if (cmd.Columns.Length > 0)
                    {
                        SqlBulkCopyColumnMapping mapping;
                        foreach (var column in cmd.Columns)
                        {
                            string[] items = column.Split('=');
                            if (items.Length == 2)
                                mapping = new SqlBulkCopyColumnMapping(items[0], items[1]);
                            else
                                mapping = new SqlBulkCopyColumnMapping(column, column);

                            maps.Add(mapping);
                        }
                    }

                    TableReader tableReader;
                    if (both.ps1.Node.Item is Locator)
                    {
                        Locator locator = mgr.GetCombinedLocator(both.ps1.Node);
                        string where = locator.Path;
                        tableReader = new TableReader(tname1, where.Inject());
                    }
                    else
                        tableReader = new TableReader(tname1);

                    int count = tableReader.Count;

                    stdio.Write("copying {0}", tname1.Name);
                    using (var progress = new ProgressBar { Count = count })
                    {
                        TableBulkCopy bulkCopy = new TableBulkCopy(tableReader);
                        bulkCopy.CopyTo(tname2, maps.ToArray(), cts, progress);

                        if (cts.IsCancellationRequested)
                            progress.Report(count);
                    }

                    if (!cts.IsCancellationRequested)
                        stdio.WriteLine(", Done.");
                }
            });
        }
开发者ID:fjiang2,项目名称:sqlcon,代码行数:85,代码来源:Commandee.cs


注:本文中的ProgressBar.Report方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。