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


C# ProgressCallback.OnProgressUpdate方法代码示例

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


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

示例1: CreateInterimPdfs

		internal Dictionary<string, PageSelection> CreateInterimPdfs(List<WorkbookItem> workbookItems, ProgressCallback progress)
		{
			Dictionary<string, PageSelection> interimPdfFiles = new Dictionary<string, PageSelection>();

			// Need to ensure the DocumentPublisher is disposed after the Pdfs are created otherwise
			// application instances are left in memory until the Combine exe closes. This can cause
			// issues with using Word automation while Combine exe is still open (see DE7973).
			using (DocumentPublisher documentPublisher = DocumentPublisher.Instance())
			{
				foreach (WorkbookItem wfm in workbookItems)
				{
					if (progress != null)
					{
						progress.OnProgressUpdate(wfm, CombineStage.BeforeConvert, true);
					}

					try
					{
						if (string.IsNullOrEmpty(wfm.Pdf))
						{
                            var encryptionManager = new Workshare.Policy.ContentEncryption.ContentEncryptionManager();
                            var decryptedFilePath=string.Empty;
                            var encryptResult = encryptionManager.DecryptFile(wfm.FileName, wfm.DocumentId,encryptionUI, out decryptedFilePath);
                            
                            switch (encryptResult)
                            {
                                case Policy.ContentEncryption.Interfaces.DecryptResult.Ok:
                                    {
                                        wfm.TempCopy = decryptedFilePath;
                                        CleanDocumentIfRequired(wfm);

                                        if (wfm.PageSelection == null)
                                        {
                                            wfm.Pdf = documentPublisher.Print(wfm);
                                        }
                                        else
                                        {
                                            wfm.Pdf = documentPublisher.PrintRange(wfm, wfm.PageSelection);
                                        }
                                        break;
                                    }
                                case Policy.ContentEncryption.Interfaces.DecryptResult.Cancel: return new Dictionary<string, PageSelection>();
                                case Policy.ContentEncryption.Interfaces.DecryptResult.Skip: continue;
                            }
						}
                        else
                        {
                            if (Workshare.Pdf.Security.HasOpenPassword(wfm.Pdf) &&
                                !Utilities.RemovePassword(wfm))
                            {
                                continue; 
                            }

                            if (wfm.PageSelection != null) 
                            {
                                Workshare.Pdf.Edit.DeletePages(wfm.Pdf, Utilities.GetPageNumbersToDelete(wfm));
                            }
                        }

						// Powerpoint or Excel documents with no content generate zero byte Pdfs
						// which then cause exceptions in the TronReader.  Pick up zero byte pdfs
						// here and do not include them.
						FileInfo infoPDF = new FileInfo(wfm.Pdf);
						if (!infoPDF.Exists || infoPDF.Length <= 0)
						{
							if (progress != null)
							{
								progress.OnProgressUpdate(wfm, CombineStage.AfterConvert, false);
							}

							string message = wfm.DisplayName + " is an empty document.\n\nDo you wish to continue?";
							if (WsMessage.ShowMessage(IntPtr.Zero, message, MessageButtons.WsYesNo, MessageBranding.WsDefault) == MessageResult.WsResultNo)
							{
                                return GetEmptyResult();
							}
							continue;
						}

						interimPdfFiles.Add(wfm.Pdf, wfm.PageSelection);
					}
					catch (Exception ex)
					{
						if (progress != null)
						{
							progress.OnProgressUpdate(wfm, CombineStage.AfterConvert, false);
						}

						// Use the filename part of DocumentId, but if empty then use DisplayName.
						// Reason: Depending on the file format and method of loading, the DisplayName may *not*
						// include the file extension. (...or even match the file name at all!)
						string sFilename;
                        if (string.IsNullOrEmpty(wfm.DocumentId))
                        {
                            sFilename = wfm.DisplayName;
                        }
                        else
                        {
                            sFilename = System.IO.Path.GetFileName(wfm.DocumentId);
                        }

//.........这里部分代码省略.........
开发者ID:killbug2004,项目名称:WSProf,代码行数:101,代码来源:PdfCombiner.cs


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