private void AddDocumentHistory(List<WorkbookItem> workbookItems) { var proxy = new DocumentProviderProxy(); foreach (var item in workbookItems) { // only add 'combined to PDF' history for the document // if it has been successfully converted if (item.Status == WorkbookItem.itemStatus.Converted) { proxy.AddHistoryEvent(item.DocumentId); } } }
private static void AddWsDocToWorkbookItemList(tagWSDOCUMENT wsdoc, List<WorkbookItem> items) { string file = wsdoc.bstrLocalFile; if (!IsSupportedFileType(file)) { // If the file is not supported, remove its temp copy from AppData. // Resolve the filename back to the doc ID using the appropriate // doc provider, and then close the document (delete it) Logger.LogInfo(string.Format("File \"{0}\" is unsupported, not adding it.", file)); DocumentProviderProxy docprov = new DocumentProviderProxy(); docprov.Resolve(ref wsdoc); docprov.CloseDocument(ref wsdoc, 0); return; } if (IsWorkbook(file)) { items.AddRange(ResolveWorkbookItemsFromWorkbook(file)); } else { items.Add(new WorkbookItem(wsdoc)); } }
public static List<WorkbookItem> ResolveWorkbookItemsFromWorkbook(string filename) { Workbook workbook = new Workbook(); workbook.Open(filename); List<WorkbookItem> unresolvedWorkbookItems = workbook.GetWorkbookItems(); List<WorkbookItem> resolvedWorkbookItems = new List<WorkbookItem>(); if (unresolvedWorkbookItems.Count > 0) { DocumentProviderProxy docprov = new DocumentProviderProxy(); foreach (WorkbookItem item in unresolvedWorkbookItems) { try { tagWSDOCUMENT wsdoc = docprov.GetDocument(item.DocumentId); WorkbookItem newItem = new WorkbookItem(wsdoc) { PageSelection = item.PageSelection, PdfSecurityOptions = item.PdfSecurityOptions }; resolvedWorkbookItems.Add(newItem); } catch (System.Runtime.InteropServices.COMException e) { string error = docprov.GetErrorDescription(e.ErrorCode) ; error = string.IsNullOrEmpty(error) ? "Failed to resolve document in workbook: " + Environment.NewLine + "[" + e.Message + "]" : error; error += Environment.NewLine + Environment.NewLine + "Document: " + item.DocumentId; WsMessage.ShowMessage(IntPtr.Zero, error, MessageButtons.WsOK, MessageBranding.WsDefault, MessageType.WsErrorIcon, "", -1); } } } return resolvedWorkbookItems; }
public static List<WorkbookItem> ConvertStringArrayToWorkbookItemList(string[] files, out ArrayList problemfiles) { problemfiles = null; DocumentProviderProxy docprov = new DocumentProviderProxy(); List<WorkbookItem> items = new List<WorkbookItem>(); foreach (string file in files) { try { string resolvedFile = file; if (file.IndexOf("::odma", StringComparison.InvariantCultureIgnoreCase) != -1) { resolvedFile = DocumentProviderProxy.TranslateOdmaId(file); } tagWSDOCUMENT wsDoc = docprov.GetDocument(resolvedFile); AddWsDocToWorkbookItemList(wsDoc, items); } catch (Exception) { if (problemfiles == null) { problemfiles = new ArrayList(); } problemfiles.Add(file); } } return items; }