예제 #1
0
        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;
        }
예제 #2
0
        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;
        }