/** * Create an InputStream from the specified DocumentEntry * * @param document the DocumentEntry to be read * * @exception IOException if the DocumentEntry cannot be opened (like, maybe it has * been deleted?) */ public DocumentInputStream(DocumentEntry document) { if (!(document is DocumentNode)) { throw new IOException("Cannot open internal document storage"); } DocumentNode documentNode = (DocumentNode)document; DirectoryNode parentNode = (DirectoryNode)document.Parent; if (documentNode.Document != null) { delegate1 = new ODocumentInputStream(document); } else if (parentNode.FileSystem != null) { delegate1 = new ODocumentInputStream(document); } else if (parentNode.NFileSystem != null) { delegate1 = new NDocumentInputStream(document); } else { throw new IOException("No FileSystem bound on the parent, can't read contents"); } }
protected void assertContentsMatches(byte[] expected, DocumentEntry doc) { NDocumentInputStream inp = new NDocumentInputStream(doc); byte[] contents = new byte[doc.Size]; Assert.AreEqual(doc.Size, inp.Read(contents)); inp.Close(); if (expected != null) Assert.That(expected, new EqualConstraint(contents)); }
protected void setUp() { fs = new POIFSFileSystem(); dirA = fs.CreateDirectory("DirA"); dirB = fs.CreateDirectory("DirB"); dirAA = dirA.CreateDirectory("DirAA"); eRoot = fs.Root.CreateDocument("Root", new ByteArrayInputStream(new byte[] { })); eA = dirA.CreateDocument("NA", new ByteArrayInputStream(new byte[] { })); eAA = dirAA.CreateDocument("NAA", new ByteArrayInputStream(new byte[] { })); }
//public DocumentReader CreateDocumentReader(string documentName) //{ // try // { // return CreateDocumentReader(GetEntry(documentName)); // } // catch(IOException ex) // { // throw ex; // } //} //public DocumentReader CreateDocumentReader(Entry document) //{ // if (!document.IsDirectoryEntry) // { // throw new IOException("Entry '" + document.Name + "' is not a DocumentEntry"); // } // DocumentEntry entry = (DocumentEntry)document; // return new DocumentReader(entry); //} public DocumentInputStream CreateDocumentInputStream(Entry document) { if (!document.IsDocumentEntry) { throw new IOException("Entry '" + document.Name + "' is not a DocumentEntry"); } DocumentEntry entry = (DocumentEntry)document; return(new DocumentInputStream(entry)); }
/// <summary> /// Create an InputStream from the specified DocumentEntry /// </summary> /// <param name="document">the DocumentEntry to be read</param> public POIFSDocumentReader(DocumentEntry document) { this._current_offset = 0; this._document_size = document.Size; this._closed = false; this._tiny_buffer = null; if (!(document is DocumentNode)) { throw new IOException("Cannot open internal document storage"); } this._document = ((DocumentNode)document).Document; }
private void downloadDirectory(DocumentEntry folder, string downloadTo) { if (cancel()) { return; } string currentFolderName = Path.Combine(downloadTo, folder.Title.Text); Directory.CreateDirectory(currentFolderName); reportProgress("Dowloaded/Updated " + folder.Title.Text); FolderQuery contentQuery = new FolderQuery(folder.ResourceId); contentQuery.ShowFolders = true; DocumentsFeed contents = m_service.Query(contentQuery); foreach (DocumentEntry entry in contents.Entries) { if (cancel()) { return; } if (!entry.IsFolder) { if (m_fileFilters.ContainsKey(Path.GetExtension(entry.Title.Text))) { string downloadUrl = entry.Content.Src.Content; if (cancel()) { return; } Stream stream = m_service.Query(new Uri(downloadUrl)); if (cancel()) { return; } string fileName = Path.Combine(currentFolderName, entry.Title.Text); FileStream outputFileStream = new FileStream(fileName, FileMode.Create); stream.CopyTo(outputFileStream); outputFileStream.Close(); reportProgress("Downloaded/Updated " + entry.Title.Text); if (cancel()) { return; } } } else { downloadDirectory(entry, currentFolderName); } } }
public void ToggleDone(FormDocument <TodoForm> document, DocumentEntry entry) { var id = Guid.Parse(entry.GetArgument("LM")); var item = items.Find(i => i.Id == id); if (item == null) { return; } item.Done = !item.Done; document.Reload(); }
protected void assertContentsMatches(byte[] expected, DocumentEntry doc) { NDocumentInputStream inp = new NDocumentInputStream(doc); byte[] contents = new byte[doc.Size]; Assert.AreEqual(doc.Size, inp.Read(contents)); inp.Close(); if (expected != null) { Assert.That(expected, new EqualConstraint(contents)); } }
public void Delete(FormDocument <TodoForm> document, DocumentEntry entry) { var id = Guid.Parse(entry.GetArgument("LM")); var item = items.Find(i => i.Id == id); if (item == null) { return; } items.Remove(item); document.Reload(); }
private int countFoldersAndFiles(string downloadFrom) { DocumentEntry parentFolder = locateFolder(downloadFrom, null); if (cancel()) { return(0); } if (!string.IsNullOrWhiteSpace(downloadFrom) && parentFolder == null) { return(0); } return(countFoldersAndFiles(parentFolder)); }
private void RunTest(FileStream file) { /* Read a Test document <em>doc</em> into a POI filesystem. */ POIFSFileSystem poifs = new POIFSFileSystem(file); DirectoryEntry dir = poifs.Root; DocumentEntry dsiEntry = null; try { dsiEntry = (DocumentEntry)dir.GetEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME); } catch (FileNotFoundException) { /* * A missing document summary information stream is not an error * and therefore silently ignored here. */ } /* * If there is a document summry information stream, Read it from * the POI filesystem, else Create a new one. */ DocumentSummaryInformation dsi; if (dsiEntry != null) { DocumentInputStream dis = new DocumentInputStream(dsiEntry); PropertySet ps = new PropertySet(dis); dsi = new DocumentSummaryInformation(ps); } else { dsi = PropertySetFactory.CreateDocumentSummaryInformation(); } CustomProperties cps = dsi.CustomProperties; if (cps == null) { /* The document does not have custom properties. */ return; } foreach (var de in cps) { CustomProperty cp = (CustomProperty)de.Value; Assert.IsNotNull(cp.Name); Assert.IsNotNull(cp.Value); } }
private void downloadDirectory(string downloadFrom, string downloadTo) { DocumentEntry parentFolder = locateFolder(downloadFrom, null); if (cancel()) { return; } if (!string.IsNullOrWhiteSpace(downloadFrom) && parentFolder == null) { return; } downloadDirectory(parentFolder, downloadTo); }
/** * Create an OutputStream from the specified DocumentEntry. * The specified entry will be emptied. * * @param document the DocumentEntry to be written */ public NDocumentOutputStream(DocumentEntry document) { if (!(document is DocumentNode)) { throw new IOException("Cannot open internal document storage, " + document + " not a Document Node"); } _document_size = 0; _closed = false; _property = (DocumentProperty)((DocumentNode)document).Property; _document = new NPOIFSDocument((DocumentNode)document); _document.Free(); }
private void OnGoogleNoteCreated(object sender, AsyncOperationCompletedEventArgs e) { DocumentEntry entry = e.Entry as DocumentEntry; Assert.IsNotNull(entry); Logger.Log("Created Google note", EventType.Information); //Now update the same entry //Instantiate the ResumableUploader component. ResumableUploader uploader = new ResumableUploader(); uploader.AsyncOperationCompleted += new AsyncOperationCompletedEventHandler(OnGoogleNoteUpdated); uploader.UpdateAsync(_authenticator, entry, e.UserState); }
public void SaveMetaData(DocumentEntry documentEntry) { //Code to insert the content into the database. try { //Call DAL's Save Metadata RepositoryDataAccess objRepositoryDataAccess = new RepositoryDataAccess(); objRepositoryDataAccess.SaveMetaData(documentEntry); } catch { throw; } }
private WorksheetEntry createSpreadSheet(string sheetName) { DocumentsService docService = new DocumentsService(this.googleAppName); docService.RequestFactory = GoogleOauthAccess.getRequestFactory(this.googleAppName, this.parameters); DocumentEntry entry = new DocumentEntry(); entry.Title.Text = sheetName; entry.Categories.Add(DocumentEntry.SPREADSHEET_CATEGORY); DocumentEntry newEntry = docService.Insert(DocumentsListQuery.documentsBaseUri, entry); return(this.searchForSpreadsheet(entry.Title.Text)); }
public void GoogleDocs() { int publicationId = 606; //Comm.Services.GoogleDocsService = new G string path = "C:\\Users\\gianpiero\\Desktop\\rating.txt"; DocumentsService myService = new DocumentsService("exampleCo-exampleApp-1"); myService.setUserCredentials("gianpieroradano", ""); DocumentEntry newEntry = myService.UploadDocument(path, "New Document Title.txt"); Console.WriteLine("Now accessible at: " + newEntry.AlternateUri.ToString()); }
/** * Create an OutputStream to create the specified new Entry * * @param parent Where to create the Entry * @param name Name of the new entry */ public NDocumentOutputStream(DirectoryEntry parent, String name) { if (!(parent is DirectoryNode)) { throw new IOException("Cannot open internal directory storage, " + parent + " not a Directory Node"); } _document_size = 0; _closed = false; // Have an empty one Created for now DocumentEntry doc = parent.CreateDocument(name, new MemoryStream(new byte[0])); _property = (DocumentProperty)((DocumentNode)doc).Property; _document = new NPOIFSDocument((DocumentNode)doc); }
/// <summary> /// Check if the current document is a new document or not. /// </summary> /// <param name="entry">The current document entry.</param> /// <returns>True if the current document is newly created.</returns> private static bool VerifyNewDocuments(DocumentEntry entry) { bool isDocumentNew = true; for (int i = 0; i < entry.Categories.Count(); i++) { //New documents will not be labelled as "viewed" in Google feeds. if (entry.Categories[i].Label.Equals("viewed")) { isDocumentNew = false; break; } } return(isDocumentNew); }
internal static void GoToLine(DocumentEntry item) { if (MainViewModel.Current == null) { MainViewModel.GoToFile(item.Path); } if (MainViewModel.Current.Model.File.Path != item.Path) { MainViewModel.Current.GoToFileAndLine(item.Path, item.iLine); } else { MainViewModel.Current.GoToLine(item.iLine); } }
/// <summary> /// Opens the currently selected document in the form's ListView /// in the default browser. /// </summary> private void OpenSelectedDocument() { if (DocList.SelectedItems.Count > 0) { DocumentEntry entry = (DocumentEntry)DocList.SelectedItems[0].Tag; try { Process.Start(entry.AlternateUri.ToString()); } catch (Win32Exception) { //nothing is registered to handle URLs, so let's use IE! Process.Start("IExplore.exe", entry.AlternateUri.ToString()); } } }
/** * Checks to see if two Documents have the same name * and the same contents. (Their parent directories are * not checked) */ public static bool AreDocumentsIdentical(DocumentEntry docA, DocumentEntry docB) { if (!docA.Name.Equals(docB.Name)) { // Names don't match, not the same return(false); } if (docA.Size != docB.Size) { // Wrong sizes, can't have the same contents return(false); } bool matches = true; DocumentInputStream inpA = null, inpB = null; try { inpA = new DocumentInputStream(docA); inpB = new DocumentInputStream(docB); int readA, readB; do { readA = inpA.Read(); readB = inpB.Read(); if (readA != readB) { matches = false; break; } } while (readA != -1 && readB != -1); } finally { if (inpA != null) { inpA.Close(); } if (inpB != null) { inpB.Close(); } } return(matches); }
public void TestAreDocumentsIdentical() { POIFSFileSystem fs = new POIFSFileSystem(); DirectoryEntry dirA = fs.CreateDirectory("DirA"); DirectoryEntry dirB = fs.CreateDirectory("DirB"); DocumentEntry entryA1 = dirA.CreateDocument("Entry1", new ByteArrayInputStream(dataSmallA)); DocumentEntry entryA1b = dirA.CreateDocument("Entry1b", new ByteArrayInputStream(dataSmallA)); DocumentEntry entryA2 = dirA.CreateDocument("Entry2", new ByteArrayInputStream(dataSmallB)); DocumentEntry entryB1 = dirB.CreateDocument("Entry1", new ByteArrayInputStream(dataSmallA)); // Names must match Assert.AreEqual(false, entryA1.Name.Equals(entryA1b.Name)); Assert.AreEqual(false, EntryUtils.AreDocumentsIdentical(entryA1, entryA1b)); // Contents must match Assert.AreEqual(false, EntryUtils.AreDocumentsIdentical(entryA1, entryA2)); // Parents don't matter if contents + names are the same Assert.AreEqual(false, entryA1.Parent.Equals(entryB1.Parent)); Assert.AreEqual(true, EntryUtils.AreDocumentsIdentical(entryA1, entryB1)); // Can work with NPOIFS + POIFS //ByteArrayOutputStream tmpO = new ByteArrayOutputStream(); MemoryStream tmpO = new MemoryStream(); fs.WriteFileSystem(tmpO); ByteArrayInputStream tmpI = new ByteArrayInputStream(tmpO.ToArray()); NPOIFSFileSystem nfs = new NPOIFSFileSystem(tmpI); DirectoryEntry dN1 = (DirectoryEntry)nfs.Root.GetEntry("DirA"); DirectoryEntry dN2 = (DirectoryEntry)nfs.Root.GetEntry("DirB"); DocumentEntry eNA1 = (DocumentEntry)dN1.GetEntry(entryA1.Name); DocumentEntry eNA2 = (DocumentEntry)dN1.GetEntry(entryA2.Name); DocumentEntry eNB1 = (DocumentEntry)dN2.GetEntry(entryB1.Name); Assert.AreEqual(false, EntryUtils.AreDocumentsIdentical(eNA1, eNA2)); Assert.AreEqual(true, EntryUtils.AreDocumentsIdentical(eNA1, eNB1)); Assert.AreEqual(false, EntryUtils.AreDocumentsIdentical(eNA1, entryA1b)); Assert.AreEqual(false, EntryUtils.AreDocumentsIdentical(eNA1, entryA2)); Assert.AreEqual(true, EntryUtils.AreDocumentsIdentical(eNA1, entryA1)); Assert.AreEqual(true, EntryUtils.AreDocumentsIdentical(eNA1, entryB1)); }
public async Task <DocumentEntry> UpdateAsync(DocumentEntry document) { var id = await InsertUpdateInternal( document.Id, document.Type, document.Value, document.CreatedDate, document.CreatedUserId, document.ModifiedDate, document.ModifiedUserId); if (id > 0) { return(await GetAsync(id)); } return(null); }
/// <summary> /// Perform the follwoing actions to those new or unread updated documents: /// 1. Check if the document is the newest among all; /// 2. Update GUI in order to add the document to the listView; /// 3. Increase the count of number of unviewed documents. /// </summary> /// <param name="entry">The document entry.</param> /// <param name="isNewUpdate">Indicator specifying if the documents is the newest among all.</param> /// <param name="latestEditedTime">The latest edited time of the newest document.</param> /// <param name="latestEditedTitle">The title of the newest document.</param> /// <param name="unviewedDocuments">The count of number of unviewed documents.</param> private void HandleNewOrUnreadUpdatedDocuments( DocumentEntry entry, ref bool isNewUpdate, ref DateTime latestEditedTime, ref string latestEditedTitle, ref int unviewedDocuments) { //Check if the document is the newest among all the documents. if (CheckIfDocumentIsNewest(entry, ref latestEditedTime, ref latestEditedTitle)) { isNewUpdate = true; } //Inform the GUI to add the new document entry to the listView. AddNewEntryToListView(entry); //Count the number of unviewed documents. unviewedDocuments++; }
public string getSpreadsheetURL(string sheetName) { DocumentsService docService = new DocumentsService(this.googleAppName); docService.RequestFactory = GoogleOauthAccess.getRequestFactory(this.googleAppName, this.parameters); Google.GData.Spreadsheets.SpreadsheetQuery query = new Google.GData.Spreadsheets.SpreadsheetQuery(); DocumentsListQuery docQuery = new DocumentsListQuery(); docQuery.Title = sheetName; DocumentsFeed feed = docService.Query(docQuery); DocumentEntry entry = (DocumentEntry)feed.Entries[0]; return("https://docs.google.com/spreadsheet/ccc?key=" + entry.ResourceId.Replace("spreadsheet:", "")); }
private DocumentEntry findFolder(string folderName, DocumentEntry parentFolder = null) { if (cancel()) { return(null); } FolderQuery query = (parentFolder == null ? new FolderQuery() : new FolderQuery(parentFolder.ResourceId)); query.TitleExact = true; query.Title = folderName; DocumentsFeed feed = m_service.Query(query); if (feed.Entries.Count == 0) { return(null); } return((DocumentEntry)feed.Entries[0]); }
private DocumentEntry locateFolder(string path, DocumentEntry parentFolder = null) { string[] directories = path.Split(Path.DirectorySeparatorChar); foreach (string directory in directories) { if (cancel()) { return(null); } parentFolder = findFolder(directory, parentFolder); if (parentFolder == null) { IndianBridge.Common.Utilities.showErrorMessage("Cannot find Folder " + directory + " in Google Collections List"); return(null); } } return(parentFolder); }
/** * Create an InputStream from the specified DocumentEntry * * @param document the DocumentEntry to be read * * @exception IOException if the DocumentEntry cannot be opened (like, maybe it has * been deleted?) */ public ODocumentInputStream(DocumentEntry document) { if (!(document is DocumentNode)) { throw new IOException("Cannot open internal document storage"); } DocumentNode documentNode = (DocumentNode)document; if (documentNode.Document == null) { throw new IOException("Cannot open internal document storage"); } _current_offset = 0; _marked_offset = 0; _document_size = document.Size; _closed = false; _document = documentNode.Document; _currentBlock = GetDataInputBlock(0); }
/** * <p>Creates the most specific {@link PropertySet} from an entry * in the specified POIFS Directory. This is preferrably a {@link * DocumentSummaryInformation} or a {@link SummaryInformation}. If * the specified entry does not contain a property Set stream, an * exception is thrown. If no entry is found with the given name, * an exception is thrown.</p> * * @param dir The directory to find the PropertySet in * @param name The name of the entry Containing the PropertySet * @return The Created {@link PropertySet}. * @if there is no entry with that name * @if the stream does not * contain a property Set. * @if some I/O problem occurs. * @exception EncoderFallbackException if the specified codepage is not * supported. */ public static PropertySet Create(DirectoryEntry dir, string name) { Stream inp = null; try { DocumentEntry entry = (DocumentEntry)dir.GetEntry(name); inp = new DocumentInputStream(entry); try { return(Create(inp)); } catch (MarkUnsupportedException) { return(null); } } finally { if (inp != null) { inp.Dispose(); } } }
private void DeleteMenuItem_Click(object sender, EventArgs e) { if (DocList.SelectedItems.Count > 0) { DocumentEntry entry = (DocumentEntry)DocList.SelectedItems[0].Tag; DialogResult result = MessageBox.Show("Are you sure you want to delete " + entry.Title.Text + "?", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { try { entry.Delete(); UpdateDocList(); } catch (Exception ex) { MessageBox.Show("Error when deleting: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
[Test] public void CreateSpreadsheetTest() { //set up a text/csv file string tempFile = Directory.GetCurrentDirectory(); tempFile = tempFile + Path.DirectorySeparatorChar + "docs_live_test.csv"; //Console.WriteLine("Creating temporary document at: " + tempFile); using (StreamWriter sw = File.CreateText(tempFile)) { sw.WriteLine("foo,bar,baz"); sw.WriteLine("1,2,3"); sw.Close(); } DocumentsService service = new DocumentsService(this.ApplicationName); if (this.userName != null) { service.Credentials = new GDataCredentials(this.userName, this.passWord); } service.RequestFactory = this.factory; //pick a unique document name string documentTitle = "Simple " + Guid.NewGuid().ToString(); DocumentEntry entry = service.UploadDocument(tempFile, documentTitle); Assert.IsNotNull(entry, "Should get a valid entry back from the server."); Assert.AreEqual(documentTitle, entry.Title.Text, "Title on document should be what we provided."); Assert.IsTrue(entry.IsSpreadsheet, "What we uploaded should come back as a spreadsheet document type."); //try to delete the document we created entry.Delete(); //clean up the file we created File.Delete(tempFile); }
/** * Create an InputStream from the specified DocumentEntry * * @param document the DocumentEntry to be read * * @exception IOException if the DocumentEntry cannot be opened (like, maybe it has * been deleted?) */ public NDocumentInputStream(DocumentEntry document) { if (!(document is DocumentNode)) { throw new IOException("Cannot open internal document storage, " + document + " not a Document Node"); } _current_offset = 0; _current_block_count = 0; _marked_offset = 0; _marked_offset_count = 0; _document_size = document.Size; _closed = false; DocumentNode doc = (DocumentNode)document; DocumentProperty property = (DocumentProperty)doc.Property; _document = new NPOIFSDocument( property, ((DirectoryNode)doc.Parent).NFileSystem ); _data = _document.GetBlockIterator(); }
async Task <TModel> GetDocumentFromEntryAsync <TModel>(DocumentEntry entry) where TModel : class { if (entry == null) { return(default(TModel)); } if (String.IsNullOrEmpty(entry.Value)) { return(default(TModel)); } var serializable = typeof(TModel) as ISerializable; if (serializable != null) { return(await serializable.DeserializeGenericTypeAsync <TModel>(entry.Value)); } return(await entry.Value.DeserializeAsync <TModel>()); }
public async Task Update(int documentId, string content) { var canEdit = await service.CanEdit(documentId); if (!canEdit) { return; } var id = documentId.ToString(CultureInfo.CurrentCulture); var entry = new DocumentEntry { Content = content, UpdatedBy = UserName }; DocumentContents.AddOrUpdate(id, entry, (key, value) => entry); Clients.OthersInGroup(id).updated( documentId, entry.Content, entry.UpdatedBy); }
Document IDocumentManager.OpenDocument(DocumentProjectItem projectItem, bool readOnly, DocumentViewType initialView) { if (this._documentList != null) { foreach (DocumentEntry entry in this._documentList) { if (projectItem.Equals(entry.document.ProjectItem)) { if (entry.docWindow.ActivateWindow()) { return entry.document; } return null; } } } DocumentType documentType = projectItem.DocumentType; if (documentType != null) { IDocumentFactory factory = documentType.Factory; if (factory != null) { try { DocumentEntry entry2 = new DocumentEntry(); entry2.document = factory.CreateDocument(projectItem, readOnly, this._documentMode, initialView, out entry2.docWindow, out entry2.designerHost); if (this._documentList == null) { this._documentList = new ArrayList(); } this._documentList.Add(entry2); IServiceContainer service = (IServiceContainer) ((IServiceProvider) entry2.designerHost).GetService(typeof(IServiceContainer)); service.AddService(typeof(Document), entry2.document); service.AddService(typeof(DocumentWindow), entry2.docWindow); entry2.docWindow.Activated += new EventHandler(this.OnDocumentWindowActivated); entry2.docWindow.Closed += new EventHandler(this.OnDocumentWindowClosed); try { this.OnDesignerCreated(new DesignerEventArgs(entry2.designerHost)); } catch (Exception) { } try { this.OnDocumentOpened(new DocumentEventArgs(entry2.document)); } catch (Exception) { } if (entry2.docWindow.ShowWindow()) { return entry2.document; } } catch (Exception exception) { ((IMxUIService) this._serviceProvider.GetService(typeof(IMxUIService))).ReportError(exception, "Unable to open the document", false); } } } return null; }
/** * Checks to see if two Documents have the same name * and the same contents. (Their parent directories are * not checked) */ public static bool AreDocumentsIdentical(DocumentEntry docA, DocumentEntry docB) { if (!docA.Name.Equals(docB.Name)) { // Names don't match, not the same return false; } if (docA.Size != docB.Size) { // Wrong sizes, can't have the same contents return false; } bool matches = true; DocumentInputStream inpA = null, inpB = null; try { inpA = new DocumentInputStream(docA); inpB = new DocumentInputStream(docB); int readA, readB; do { readA = inpA.Read(); readB = inpB.Read(); if (readA != readB) { matches = false; break; } } while (readA != -1 && readB != -1); } finally { if (inpA != null) inpA.Close(); if (inpB != null) inpB.Close(); } return matches; }
private void OnDocumentWindowActivated(object sender, EventArgs e) { DocumentEntry entry = this._activeDocument; DocumentEntry entry2 = null; foreach (DocumentEntry entry3 in this._documentList) { if (entry3.docWindow == sender) { entry2 = entry3; break; } } if (entry != entry2) { IDesignerHost oldDesigner = null; IDesignerHost newDesigner = null; Document oldDocument = null; Document newDocument = null; this._activeDocument = entry2; if (this._activeDocument != null) { newDesigner = this._activeDocument.designerHost; newDocument = this._activeDocument.document; ISelectionService service = (ISelectionService) newDesigner.GetService(typeof(ISelectionService)); if (service != null) { service.SelectionChanged += new EventHandler(this.OnDocumentWindowSelectionChanged); } IMultiViewDocumentWindow docWindow = this._activeDocument.docWindow as IMultiViewDocumentWindow; if (docWindow != null) { docWindow.CurrentViewChanged += new EventHandler(this.OnDocumentWindowViewChanged); } } if (entry != null) { oldDesigner = entry.designerHost; oldDocument = entry.document; ISelectionService service2 = (ISelectionService) oldDesigner.GetService(typeof(ISelectionService)); if (service2 != null) { service2.SelectionChanged -= new EventHandler(this.OnDocumentWindowSelectionChanged); } IMultiViewDocumentWindow window2 = entry.docWindow as IMultiViewDocumentWindow; if (window2 != null) { window2.CurrentViewChanged -= new EventHandler(this.OnDocumentWindowViewChanged); } } this.OnActiveDesignerChanged(new ActiveDesignerEventArgs(oldDesigner, newDesigner)); this.OnActiveDocumentChanged(new ActiveDocumentEventArgs(oldDocument, newDocument)); if (this._activeDocument != null) { ICommandHandler activeUICommandHandler = (ICommandHandler) sender; ((ICommandManager) this._serviceProvider.GetService(typeof(ICommandManager))).UpdateActiveUICommandHandler(activeUICommandHandler, null); } } }
private void OnDocumentWindowClosed(object sender, EventArgs e) { ((ICommandManager) this._serviceProvider.GetService(typeof(ICommandManager))).UpdateActiveUICommandHandler(null, null); DocumentEntry entry = null; int index = 0; foreach (DocumentEntry entry2 in this._documentList) { if (entry2.docWindow == sender) { entry = entry2; break; } index++; } if (entry != null) { this._documentList.RemoveAt(index); } ISelectionService service = (ISelectionService) ((IServiceProvider) entry.designerHost).GetService(typeof(ISelectionService)); if (service != null) { service.SelectionChanged -= new EventHandler(this.OnDocumentWindowSelectionChanged); } if ((this._activeDocument != null) && (this._activeDocument.docWindow == sender)) { this._activeDocument = null; this.OnActiveDesignerChanged(new ActiveDesignerEventArgs(entry.designerHost, null)); this.OnActiveDocumentChanged(new ActiveDocumentEventArgs(entry.document, null)); } this.OnDocumentClosed(new DocumentEventArgs(entry.document)); this.OnDesignerDisposed(new DesignerEventArgs(entry.designerHost)); }
public void processNode(XmlNode node) { if (node.HasChildNodes) { if (node.Name == ElementNames.Entry) { _EntryBuffer = new DocumentEntry(); _EntryBuffer.ETag = node.Attributes[ElementNames.ETag].Value; } foreach (XmlNode n in node.ChildNodes) processNode(n); if (node.Name == ElementNames.Entry) this.DocumentEntries.Add(_EntryBuffer.ID, _EntryBuffer); return; } XmlNode parentNode = node.ParentNode; if (parentNode.Name == ElementNames.ID) { if (parentNode.ParentNode.Name == ElementNames.Feed) this.ID = node.Value; else if (parentNode.ParentNode.Name == ElementNames.Entry) _EntryBuffer.ID = node.Value; } else if (parentNode.Name == ElementNames.Updated) { DateTime lastUpdate = DateTime.Parse(node.Value); if (parentNode.ParentNode.Name == ElementNames.Feed) this.Updated = lastUpdate; else if (parentNode.ParentNode.Name == ElementNames.Entry) _EntryBuffer.LastUpdated = lastUpdate; } else if (parentNode.Name == ElementNames.Title) { if (parentNode.ParentNode.Name == ElementNames.Feed) this.Title = node.Value; else if (parentNode.ParentNode.Name == ElementNames.Entry) _EntryBuffer.Title = node.Value; } else if (node.Name == ElementNames.Link) { string rel = node.Attributes[ElementNames.LinkRel].Value; if (rel == ElementNames.LinkRelBrowser) this.UserLink = node.Value; else if (rel.Contains(ElementNames.LinkRelResumableUpload)) this.ResumableUploadLink = node.Value; else if (rel == ElementNames.LinkRelNextPage) this.NextPageLink = node.Value; else if (rel.Contains(ElementNames.LinkRelPost)) this.PostLink = node.Value; } else if (parentNode.Name == ElementNames.Name) { if (parentNode.ParentNode.ParentNode.Name == ElementNames.Feed) { this.Author.Name = node.Value; } else if (parentNode.ParentNode.ParentNode.Name == ElementNames.Entry) { if (parentNode.ParentNode.Name == ElementNames.Author) _EntryBuffer.Author.Name = node.Value; else if (parentNode.ParentNode.Name == ElementNames.GdLastModifiedBy) _EntryBuffer.LastModifiedBy.Name = node.Value; } else if (parentNode.ParentNode.Name == ElementNames.GdLastModifiedBy) { _EntryBuffer.LastModifiedBy.Name = node.Value; } } else if (parentNode.Name == ElementNames.Email) { if (parentNode.ParentNode.ParentNode.Name == ElementNames.Feed) { this.Author.Email = node.Value; } else if (parentNode.ParentNode.ParentNode.Name == ElementNames.Entry) { if (parentNode.ParentNode.Name == ElementNames.Author) _EntryBuffer.Author.Email = node.Value; else if (parentNode.ParentNode.Name == ElementNames.GdLastModifiedBy) _EntryBuffer.LastModifiedBy.Email = node.Value; } else if (parentNode.ParentNode.Name == ElementNames.GdLastModifiedBy) { _EntryBuffer.LastModifiedBy.Email = node.Value; } } else if (parentNode.Name == ElementNames.DocsDescription) { _EntryBuffer.Description = node.Value; } else if (parentNode.Name == ElementNames.GdResourceID) { _EntryBuffer.ResourceID = node.Value; } else if (parentNode.Name == ElementNames.Published) { _EntryBuffer.CreationDate = DateTime.Parse(node.Value); } else if (parentNode.Name == ElementNames.AppEdited) { _EntryBuffer.LastUpdatedInBrowserEditor = DateTime.Parse(node.Value); } else if (parentNode.Name == ElementNames.GdLastViewed) { _EntryBuffer.LastViewedDate = DateTime.Parse(node.Value); } else if (node.Name == ElementNames.Category) { if (parentNode.Name == ElementNames.Entry) { string scheme = node.Attributes[ElementNames.CategoryScheme].Value; string label = node.Attributes[ElementNames.CategoryLabel].Value; if (scheme.Contains(ElementNames.Kind)) { if (label == ElementNames.KindDocument) _EntryBuffer.EntryKind = EntryKinds.Document; else if (label == ElementNames.KindDrawing) _EntryBuffer.EntryKind = EntryKinds.Drawing; else if (label == ElementNames.KindFile) _EntryBuffer.EntryKind = EntryKinds.File; else if (label == ElementNames.KindFolder) _EntryBuffer.EntryKind = EntryKinds.Folder; else if (label == ElementNames.KindPdf) _EntryBuffer.EntryKind = EntryKinds.PDF; else if (label == ElementNames.KindPresentation) _EntryBuffer.EntryKind = EntryKinds.Presentation; else if (label == ElementNames.KindSpreadsheet) _EntryBuffer.EntryKind = EntryKinds.Spreadsheet; } else if (scheme.Contains(ElementNames.Labels)) { _EntryBuffer.Labels.Add(label); } } } }
public void Should_Build_Document_Test01() { var document = new DocumentEntry { Author = new Author { Person = new XdsPerson { GivenName = "First", OwnSurname = "XdsKit", Degree = "MD", Prefix = "Dr" }, Institution = new List<XdsOrganization> { new XdsOrganization { Name = "XdsKit Clinic", OrganizationId = "1234567893", UniversalId = "2.16.840.1.113883.4.6" }, new XdsOrganization { Name = "Radiology Department" } }, Role = new List<string> { "Rendering", "Attending" }, Specialty = new List<string> { "Pediatrics", "Cardiology" } }, AvailabilityStatus = StatusType.Approved, Class = new ClassCode { Value = "11506-3", DisplayName = "Progress Note", CodeSystemId = "2.16.840.1.113883.6.1" }, Comments = "This is a new submission", Confidentiality = new List<ConfidentialityCode> { new ConfidentialityCode { Value = "N", DisplayName = "Normal", CodeSystemId = "2.16.840.1.113883.5.25" } }, CreationTime = new DateTimeOffset(2015, 12, 4, 4, 11, 00, TimeSpan.Zero), EntryUuid = "Document01", EventCodes = new List<EventCode> { new EventCode { Value = "1", DisplayName = "First Event", CodeSystemId = "1.1.1.1.1" }, new EventCode { Value = "2", DisplayName = "Second Event", CodeSystemId = "1.2.1.2.1" } }, Format = new FormatCode { Value = "urn:ihe:pcc:xds-ms:2007", DisplayName = "Medical Summaries (XDS-MS)", CodeSystemId = "1.3.6.1.4.1.19376.1.2.3" }, Hash = "da39a3ee5e6b4b0d3255bfef95601890afd80709", HealthCareFacilityType = new HealthcareFacilityTypeCode { Value = "FC01", DisplayName = "Hospital", CodeSystemId = "1.2.3.4.5.6.123" }, HomeCommunityId = "1.2.3.4", LanguageCode = "en-US", LegalAuthenticator = new XdsPerson { GivenName = "Provider", OwnSurname = "XdsKit", Prefix = "Dr" }, MimeType = "application/pdf", PatientId = new XdsIdentifier { Id = "XYZPAT01", UniversalId = "9.0.1.2.3" }, PracticeSetting = new PracticeSettingCode { Value = "PS01", DisplayName = "Practice Setting", CodeSystemId = "1.2.3.4.5.6" }, RepositoryUniqueId = "5.4.3.2.1.0", ServiceStartTime = new DateTimeOffset(2015, 12, 4, 4, 27, 00, TimeSpan.Zero), ServiceStopTime = new DateTimeOffset(2015, 12, 4, 5, 47, 00, TimeSpan.Zero), Size = 1024, SourcePatientId = new XdsIdentifier { Id = "SP00001102", UniversalId = "0.1.2.3.4" }, SourcePatientInfo = new List<string> { "PID-3|SP00001102^^^&0.1.2.3.4&ISO", "PID-5|Patient^XdsKit", "PID-7|1990011", "PID-8|M", "PID-11|123 Sesame Street^^New York^NY^11501" }, Title = "XdsKit Progress Note", Type = new DocumentTypeCode { Value = "NOTE", DisplayName = "Progress Note" }, UniqueId = "1.2.3.4.5.6.78901.2345.6.7", Uri = "http://google.com", ReferenceIds = new List<XdsReferenceIdentifier> { new XdsReferenceIdentifier { Id = "LB0001", IdType = "urn:ihe:iti:xds:2013:accession", UniversalId = "1.2.3.4.5" }, new XdsReferenceIdentifier { Id = "DC0001", IdType = "urn:ihe:iti:xds:2013:uniqueId", UniversalId = "6.6.6" } }, LimitedMetadata = true, DocumentEntryType = "urn:uuid:7edca82f-054d-47f2-a032-9b2a5b5186c1" }; var package = document.ToRegistryObject(); package.ToXml() .AssertByLine(XDocument.Parse(Resource.Get("Resources.Xdsb.DocumentEntry_Test01.xml"))); }