private bool AddExistingLibrary(CancelEventArgs e) { string libraryPath = ValidateLibraryPath(); if (libraryPath == null) { e.Cancel = true; return(false); } var peptideLibraries = DocumentContainer.Document.Settings.PeptideSettings.Libraries; var docLibSpec = peptideLibraries.LibrarySpecs.FirstOrDefault(spec => spec.FilePath == libraryPath); if (docLibSpec == null) { docLibSpec = Settings.Default.SpectralLibraryList.FirstOrDefault(spec => spec.FilePath == libraryPath); if (docLibSpec == null) { var existingNames = new HashSet <string>(); existingNames.UnionWith(Settings.Default.SpectralLibraryList.Select(spec => spec.Name)); existingNames.UnionWith(peptideLibraries.LibrarySpecs.Select(spec => spec.Name)); string libraryName = Helpers.GetUniqueName(Path.GetFileNameWithoutExtension(libraryPath), existingNames); docLibSpec = LibrarySpec.CreateFromPath(libraryName, libraryPath); Settings.Default.SpectralLibraryList.SetValue(docLibSpec); } } if (!LoadPeptideSearchLibrary(docLibSpec)) { return(false); } DocumentContainer.ModifyDocumentNoUndo(doc => ImportPeptideSearch.AddDocumentSpectralLibrary(doc, docLibSpec)); return(true); }
/// <summary> /// Method used for changing the Layout for the MDI elements. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Layout_Click(object sender, RoutedEventArgs e) { //Changing Document Containter Layout Button c = (Button)sender; string g = c.Content.ToString(); switch (c.Name) { case "Cascade": DocContainer.SetLayout(MDILayout.Cascade); DocumentContainer.SetCanDrag(firstdoc, true); DocumentContainer.SetCanDrag(seconddoc, true); DocumentContainer.SetCanDrag(ThirdDoc, true); break; case "THorizontal": DocContainer.SetLayout(MDILayout.Horizontal); DocumentContainer.SetCanDrag(firstdoc, false); DocumentContainer.SetCanDrag(seconddoc, false); DocumentContainer.SetCanDrag(ThirdDoc, false); break; case "TVertical": DocContainer.SetLayout(MDILayout.Vertical); DocumentContainer.SetCanDrag(firstdoc, false); DocumentContainer.SetCanDrag(seconddoc, false); DocumentContainer.SetCanDrag(ThirdDoc, false); break; } }
private void documentcontainer_Loaded(object parameter) { clientdockingManager = parameter as DockingManager; DocumentContainer documentcontainer = clientdockingManager.DocContainer as DocumentContainer; documentcontainer.Loaded += Documentcontainer_Loaded; }
public static IQueryPipelineStage Create( DocumentContainer documentContainer, CosmosQueryContext cosmosQueryContext, InputParameters inputParameters, ITrace trace) { if (cosmosQueryContext == null) { throw new ArgumentNullException(nameof(cosmosQueryContext)); } if (inputParameters == null) { throw new ArgumentNullException(nameof(inputParameters)); } if (trace == null) { throw new ArgumentNullException(nameof(trace)); } NameCacheStaleRetryQueryPipelineStage nameCacheStaleRetryQueryPipelineStage = new NameCacheStaleRetryQueryPipelineStage( cosmosQueryContext: cosmosQueryContext, queryPipelineStageFactory: () => { // Query Iterator requires that the creation of the query context is deferred until the user calls ReadNextAsync AsyncLazy <TryCatch <IQueryPipelineStage> > lazyTryCreateStage = new AsyncLazy <TryCatch <IQueryPipelineStage> >( valueFactory: (trace, innerCancellationToken) => CosmosQueryExecutionContextFactory.TryCreateCoreContextAsync( documentContainer, cosmosQueryContext, inputParameters, trace, innerCancellationToken)); LazyQueryPipelineStage lazyQueryPipelineStage = new LazyQueryPipelineStage(lazyTryCreateStage: lazyTryCreateStage, cancellationToken: default);
internal override async Task <IDocumentContainer> CreateDocumentContainerAsync( int numItems, FlakyDocumentContainer.FailureConfigs failureConfigs = default) { Documents.PartitionKeyDefinition partitionKeyDefinition = new Documents.PartitionKeyDefinition() { Paths = new System.Collections.ObjectModel.Collection <string>() { "/pk" }, Kind = Documents.PartitionKind.Hash, Version = Documents.PartitionKeyDefinitionVersion.V2, }; IMonadicDocumentContainer monadicDocumentContainer = new InMemoryContainer(partitionKeyDefinition); if (failureConfigs != null) { monadicDocumentContainer = new FlakyDocumentContainer(monadicDocumentContainer, failureConfigs); } DocumentContainer documentContainer = new DocumentContainer(monadicDocumentContainer); for (int i = 0; i < 3; i++) { IReadOnlyList <FeedRangeInternal> ranges = await documentContainer.GetFeedRangesAsync( trace : NoOpTrace.Singleton, cancellationToken : default);
private void WriteDefaultTextStyle(PowerpointDocument ppt, DocumentContainer documentRecord) { this._writer.WriteStartElement("p", "defaultTextStyle", OpenXmlNamespaces.PresentationML); this._writer.WriteStartElement("a", "defPPr", OpenXmlNamespaces.DrawingML); this._writer.WriteStartElement("a", "defRPr", OpenXmlNamespaces.DrawingML); this._writer.WriteAttributeString("lang", "en-US"); this._writer.WriteEndElement(); //defRPr this._writer.WriteEndElement(); //defPPr var defaultStyle = this._ctx.Ppt.DocumentRecord.FirstChildWithType <b2xtranslator.PptFileFormat.Environment>().FirstChildWithType <TextMasterStyleAtom>(); var map = new TextMasterStyleMapping(this._ctx, this._writer, null); for (int i = 0; i < defaultStyle.IndentLevelCount; i++) { map.writepPr(defaultStyle.CRuns[i], defaultStyle.PRuns[i], null, i, false, true); } for (int i = defaultStyle.IndentLevelCount; i < 9; i++) { map.writepPr(defaultStyle.CRuns[0], defaultStyle.PRuns[0], null, i, false, true); } this._writer.WriteEndElement(); //defaultTextStyle }
public MainWindow() { InitializeComponent(); DocumentContainer documentcontainer1 = clientdockingManager.DocContainer as DocumentContainer; documentcontainer1.Loaded += documentcontainer1_Loaded; }
public override FeedIterator <T> GetChangeFeedIterator <T>( ChangeFeedStartFrom changeFeedStartFrom, ChangeFeedMode changeFeedMode, ChangeFeedRequestOptions changeFeedRequestOptions = null) { if (changeFeedStartFrom == null) { throw new ArgumentNullException(nameof(changeFeedStartFrom)); } if (changeFeedMode == null) { throw new ArgumentNullException(nameof(changeFeedMode)); } NetworkAttachedDocumentContainer networkAttachedDocumentContainer = new NetworkAttachedDocumentContainer( this, this.queryClient, Guid.NewGuid(), changeFeedRequestOptions: changeFeedRequestOptions); DocumentContainer documentContainer = new DocumentContainer(networkAttachedDocumentContainer); ChangeFeedIteratorCore changeFeedIteratorCore = new ChangeFeedIteratorCore( documentContainer: documentContainer, changeFeedStartFrom: changeFeedStartFrom, changeFeedMode: changeFeedMode, changeFeedRequestOptions: changeFeedRequestOptions, clientContext: this.ClientContext); return(new FeedIteratorCore <T>( changeFeedIteratorCore, responseCreator: this.ClientContext.ResponseFactory.CreateChangeFeedUserTypeResponse <T>)); }
/// <summary> /// Helper method to create a stream feed iterator. /// It decides if it is a query or read feed and create /// the correct instance. /// </summary> public override FeedIteratorInternal GetItemQueryStreamIteratorInternal( SqlQuerySpec sqlQuerySpec, bool isContinuationExcpected, string continuationToken, FeedRangeInternal feedRange, QueryRequestOptions requestOptions) { requestOptions ??= new QueryRequestOptions(); if (requestOptions.IsEffectivePartitionKeyRouting) { if (feedRange != null) { throw new ArgumentException(nameof(feedRange), ClientResources.FeedToken_EffectivePartitionKeyRouting); } requestOptions.PartitionKey = null; } if (sqlQuerySpec == null) { NetworkAttachedDocumentContainer networkAttachedDocumentContainer = new NetworkAttachedDocumentContainer( this, this.queryClient, diagnosticsContext: null, requestOptions); DocumentContainer documentContainer = new DocumentContainer(networkAttachedDocumentContainer); return(new ReadFeedIteratorCore( documentContainer: documentContainer, queryRequestOptions: requestOptions, continuationToken: continuationToken, pageSize: requestOptions.MaxItemCount ?? int.MaxValue, cancellationToken: default));
public void Intialize(Control control, DocumentContainer container, ErrorProvider provider) { var c = control as CustomCheckbox; c.DocumentLoaded = true; c.Initialize(container); }
public override FeedIterator GetChangeFeedStreamIterator( ChangeFeedStartFrom changeFeedStartFrom, ChangeFeedMode changeFeedMode, ChangeFeedRequestOptions changeFeedRequestOptions = null) { if (changeFeedStartFrom == null) { throw new ArgumentNullException(nameof(changeFeedStartFrom)); } if (changeFeedMode == null) { throw new ArgumentNullException(nameof(changeFeedMode)); } NetworkAttachedDocumentContainer networkAttachedDocumentContainer = new NetworkAttachedDocumentContainer( this, this.queryClient, Guid.NewGuid(), changeFeedRequestOptions: changeFeedRequestOptions); DocumentContainer documentContainer = new DocumentContainer(networkAttachedDocumentContainer); return(new ChangeFeedIteratorCore( documentContainer: documentContainer, changeFeedStartFrom: changeFeedStartFrom, changeFeedMode: changeFeedMode, changeFeedRequestOptions: changeFeedRequestOptions, clientContext: this.ClientContext)); }
public void Intialize(Control control, DocumentContainer container, ErrorProvider provider) { var c = control as ICustomControlWithText; c.DocumentLoaded = true; c.Initialize(container, provider); }
///<summary> ///Partially updates the vertex ///</summary> ///<param name="document">Representation of the patch document</param> ///<param name="keepNull">For remove any attributes from the existing document that are contained in the patch document with an attribute value of null</param> ///<param name="waitForSync">Wait until document has been synced to disk</param> ///<returns>Document identifiers</returns> public async Task <IDocumentIdentifierResult> UpdateAsync(object document, bool?waitForSync = null, bool?keepNull = null, Action <BaseResult> baseResult = null) { if (db.Setting.DisableChangeTracking == true) { throw new InvalidOperationException("Change tracking is disabled, use UpdateById() instead"); } DocumentContainer container = null; JObject jObject = null; var changed = db.ChangeTracker.GetChanges(document, out container, out jObject); if (changed.Count != 0) { BaseResult bResult = null; var result = await UpdateByIdAsync(container.Id, changed, waitForSync, keepNull, (b) => bResult = b).ConfigureAwait(false); if (!bResult.Error) { container.Rev = result.Rev; container.Document = jObject; db.SharedSetting.IdentifierModifier.FindIdentifierMethodFor(document.GetType()).SetRevision(document, result.Rev); } return(result); } else { return new DocumentIdentifierWithoutBaseResult() { Id = container.Id, Key = container.Key, Rev = container.Rev } }; }
public static T CreateMDIChild <T>(this DockingManager dm) where T : UserControl, new() { T mdiChild = null; //check if mdi child is already open..select it foreach (var form in dm.Children) { if (form is T) { mdiChild = (form as T); } } //if mdi child is not open...open it if (mdiChild == null) { mdiChild = new T(); DocumentContainer.SetMDIBounds(mdiChild, new Rect(10, 10, 600, 600)); DockingManager.SetState(mdiChild, DockState.Document); dm.Children.Add(mdiChild); } dm.ActiveWindow = mdiChild; return(mdiChild); }
/// <summary> /// Capture the actual page (document) /// </summary> /// <param name="documentContainer">The document wrapped in a container</param> /// <returns>Bitmap with the page content as an image</returns> private static Bitmap capturePage(DocumentContainer documentContainer, ICapture capture, Size pageSize) { WindowDetails contentWindowDetails = documentContainer.ContentWindow; //Create a target bitmap to draw into with the calculated page size Bitmap returnBitmap = new Bitmap(pageSize.Width, pageSize.Height, PixelFormat.Format24bppRgb); using (Graphics graphicsTarget = Graphics.FromImage(returnBitmap)) { // Clear the target with the backgroundcolor Color clearColor = documentContainer.BackgroundColor; LOG.DebugFormat("Clear color: {0}", clearColor); graphicsTarget.Clear(clearColor); // Get the base document & draw it drawDocument(documentContainer, contentWindowDetails, graphicsTarget); // Loop over the frames and clear their source area so we don't see any artefacts foreach (DocumentContainer frameDocument in documentContainer.Frames) { using (Brush brush = new SolidBrush(clearColor)) { graphicsTarget.FillRectangle(brush, frameDocument.SourceRectangle); } } // Loop over the frames and capture their content foreach (DocumentContainer frameDocument in documentContainer.Frames) { drawDocument(frameDocument, contentWindowDetails, graphicsTarget); } } return(returnBitmap); }
public MainWindow() { InitializeComponent(); try { uint colourdword = GetImmersiveColorFromColorSetEx((uint)GetImmersiveUserColorSetPreference(false, false), GetImmersiveColorTypeFromName(Marshal.StringToHGlobalUni("ImmersiveStartSelectionBackground")), false, 0); Color colour = Color.FromArgb((byte)((0xFF000000 & colourdword) >> 24), (byte)(0x000000FF & colourdword), (byte)((0x0000FF00 & colourdword) >> 8), (byte)((0x00FF0000 & colourdword) >> 16)); this.Screen1.Background = new SolidColorBrush(colour); this.Screen2.Background = new SolidColorBrush(colour); } catch (Exception) { } loaclpath = Directory.GetParent(path).ToString(); string loaclpath1 = loaclpath.Replace("bin", "Images\\screen1.png"); string localpath2 = loaclpath.Replace("bin", "Images\\screen1.png"); this.img.Source = new BitmapImage(new Uri(loaclpath1, UriKind.Absolute)); this.img1.Source = new BitmapImage(new Uri(localpath2, UriKind.Absolute)); this.Loaded += MainWindow_Loaded; this.Activated += MainWindow_Activated; DocumentContainer1 = dockingManager1.DocContainer as DocumentContainer; DocumentContainer1.Loaded += DocumentContainer1_Loaded; DocumentContainer1.ActiveDocumentChanged += new PropertyChangedCallback(DocumentContainer1_ActiveDocumentChanged); dockingManager1.TouchDown += dockingManager1_TouchDown; }
/// <summary> /// Helper method to create a stream feed iterator. /// It decides if it is a query or read feed and create /// the correct instance. /// </summary> public override FeedIteratorInternal GetItemQueryStreamIteratorInternal( SqlQuerySpec sqlQuerySpec, bool isContinuationExcpected, string continuationToken, FeedRangeInternal feedRange, QueryRequestOptions requestOptions) { requestOptions ??= new QueryRequestOptions(); if (requestOptions.IsEffectivePartitionKeyRouting) { if (feedRange != null) { throw new ArgumentException(nameof(feedRange), ClientResources.FeedToken_EffectivePartitionKeyRouting); } requestOptions.PartitionKey = null; } if (sqlQuerySpec == null) { NetworkAttachedDocumentContainer networkAttachedDocumentContainer = new NetworkAttachedDocumentContainer( this, this.queryClient, requestOptions); DocumentContainer documentContainer = new DocumentContainer(networkAttachedDocumentContainer); ReadFeedPaginationOptions.PaginationDirection?direction = null; if ((requestOptions.Properties != null) && requestOptions.Properties.TryGetValue(HttpConstants.HttpHeaders.EnumerationDirection, out object enumerationDirection)) { direction = (byte)enumerationDirection == (byte)RntbdConstants.RntdbEnumerationDirection.Reverse ? ReadFeedPaginationOptions.PaginationDirection.Reverse : ReadFeedPaginationOptions.PaginationDirection.Forward; } ReadFeedPaginationOptions readFeedPaginationOptions = new ReadFeedPaginationOptions( direction, pageSizeHint: requestOptions.MaxItemCount ?? int.MaxValue); return(new ReadFeedIteratorCore( documentContainer, continuationToken, readFeedPaginationOptions, requestOptions, cancellationToken: default)); } return(QueryIterator.Create( containerCore: this, client: this.queryClient, clientContext: this.ClientContext, sqlQuerySpec: sqlQuerySpec, continuationToken: continuationToken, feedRangeInternal: feedRange, queryRequestOptions: requestOptions, resourceLink: this.LinkUri, isContinuationExpected: isContinuationExcpected, allowNonValueAggregateQuery: true, forcePassthrough: false, partitionedQueryExecutionInfo: null)); }
public static void InitializeControl( CustomCheckbox custom, DocumentContainer container, ErrorProvider provider) { custom.DocumentLoaded = true; custom.Initialize(container); }
public static void InitializeControl( object _, DocumentContainer container, ErrorProvider provider) { // do nothing if the control is neither a // ICustomControlWithText nor a CustomCheckbox }
public static void InitializeControl( ICustomControlWithText controlWithTextBase, DocumentContainer container, ErrorProvider provider) { controlWithTextBase.DocumentLoaded = true; controlWithTextBase.Initialize(container, provider); }
/// <summary> /// Add page at specified index. /// </summary> /// <param name="project">The project instance.</param> /// <param name="document">The document instance.</param> /// <param name="page">The page instance.</param> /// <param name="index">The page index.</param> public static void AddPageAt(this ProjectContainer project, DocumentContainer document, PageContainer page, int index) { if (document != null && page != null && index >= 0) { var previous = document.Pages; var next = document.Pages.Insert(index, page); project?.History?.Snapshot(previous, next, (p) => document.Pages = p); document.Pages = next; } }
private void WriteSizeInfo(PowerpointDocument ppt, DocumentContainer documentRecord) { DocumentAtom doc = documentRecord.FirstChildWithType <DocumentAtom>(); // Write slide size and type WriteSlideSizeInfo(doc); // Write notes size WriteNotesSizeInfo(doc); }
/// <summary> /// Remove document object from project <see cref="ProjectContainer.Documents"/> collection. /// </summary> /// <param name="project">The project instance.</param> /// <param name="document">The document object to remove from project <see cref="ProjectContainer.Documents"/> collection.</param> public static void RemoveDocument(this ProjectContainer project, DocumentContainer document) { if (project?.Documents != null && document != null) { var previous = project.Documents; var next = project.Documents.Remove(document); project?.History?.Snapshot(previous, next, (p) => project.Documents = p); project.Documents = next; } }
/// <summary> /// Add document at specified index. /// </summary> /// <param name="project">The project instance.</param> /// <param name="document">The document instance.</param> /// <param name="index">The document index.</param> public static void AddDocumentAt(this ProjectContainer project, DocumentContainer document, int index) { if (project?.Documents != null && document != null && index >= 0) { var previous = project.Documents; var next = project.Documents.Insert(index, document); project?.History?.Snapshot(previous, next, (p) => project.Documents = p); project.Documents = next; } }
/// <summary> /// Add page. /// </summary> /// <param name="project">The project instance.</param> /// <param name="document">The document instance.</param> /// <param name="page">The page instance.</param> public static void AddPage(this ProjectContainer project, DocumentContainer document, PageContainer page) { if (document != null && page != null) { var previous = document.Pages; var next = document.Pages.Add(page); project?.History?.Snapshot(previous, next, (p) => document.Pages = p); document.Pages = next; } }
/// <inheritdoc/> void IProjectExporter.Save(string path, DocumentContainer document) { _outputPath = System.IO.Path.GetDirectoryName(path); var dxf = new DxfDocument(DxfVersion.AutoCad2010); Add(dxf, document); dxf.Save(path); ClearCache(isZooming: false); }
public override FeedIteratorInternal GetReadFeedIterator( QueryDefinition queryDefinition, QueryRequestOptions queryRequestOptions, string resourceLink, ResourceType resourceType, string continuationToken, int pageSize) { queryRequestOptions ??= new QueryRequestOptions(); NetworkAttachedDocumentContainer networkAttachedDocumentContainer = new NetworkAttachedDocumentContainer( this, this.queryClient, queryRequestOptions, resourceLink: resourceLink, resourceType: resourceType); DocumentContainer documentContainer = new DocumentContainer(networkAttachedDocumentContainer); FeedIteratorInternal feedIterator; if (queryDefinition != null) { feedIterator = QueryIterator.Create( containerCore: this, client: this.queryClient, clientContext: this.ClientContext, sqlQuerySpec: queryDefinition.ToSqlQuerySpec(), continuationToken: continuationToken, feedRangeInternal: FeedRangeEpk.FullRange, queryRequestOptions: queryRequestOptions, resourceLink: resourceLink, isContinuationExpected: false, allowNonValueAggregateQuery: true, forcePassthrough: false, partitionedQueryExecutionInfo: null); } else { ReadFeedPaginationOptions.PaginationDirection?direction = null; if ((queryRequestOptions.Properties != null) && queryRequestOptions.Properties.TryGetValue(HttpConstants.HttpHeaders.EnumerationDirection, out object enumerationDirection)) { direction = (byte)enumerationDirection == (byte)RntbdConstants.RntdbEnumerationDirection.Reverse ? ReadFeedPaginationOptions.PaginationDirection.Reverse : ReadFeedPaginationOptions.PaginationDirection.Forward; } ReadFeedPaginationOptions readFeedPaginationOptions = new ReadFeedPaginationOptions( direction, pageSizeHint: queryRequestOptions.MaxItemCount ?? int.MaxValue); feedIterator = new ReadFeedIteratorCore( documentContainer: documentContainer, queryRequestOptions: queryRequestOptions, continuationToken: continuationToken, readFeedPaginationOptions: readFeedPaginationOptions, cancellationToken: default);
private void WriteSlides(PowerpointDocument ppt, DocumentContainer documentRecord) { _writer.WriteStartElement("p", "sldIdLst", OpenXmlNamespaces.PresentationML); foreach (SlideMapping sMapping in this.SlideMappings) { WriteSlide(sMapping); } _writer.WriteEndElement(); }
public void SetCurrentDocument_Sets_CurrentDocument() { var target = new ProjectContainer(); var document = DocumentContainer.Create(); target.Documents = target.Documents.Add(document); target.SetCurrentDocument(document); Assert.Equal(document, target.CurrentDocument); }
public void Setting_Selected_Should_Call_SetSelected() { var target = new ProjectContainer(); var document = DocumentContainer.Create(); target.Documents = target.Documents.Add(document); target.Selected = document; Assert.Equal(document, target.CurrentDocument); }
public ActionResult _CreateDocuments(DocumentContainer entityKind, int id) { if (Request.Files.Count == 0) return HTTPStatus(HttpStatusCode.BadRequest, "Es wurden keine Dateien empfangen."); if (id <= 0) return HTTPStatus(HttpStatusCode.BadRequest, "Die Dateien können keinem Ziel zugeordnet werden."); Topic topic = null; if (entityKind == DocumentContainer.Topic) { topic = db.Topics.Find(id); if (IsTopicLocked(id)) return HTTPStatus(HttpStatusCode.Forbidden, "Da das Thema gesperrt ist, können Sie keine Dateien hochladen."); if (topic.IsReadOnly) { return HTTPStatus(HttpStatusCode.Forbidden, "Da das Thema schreibgeschützt ist, können Sie keine Dateien bearbeiten."); } } var statusMessage = new StringBuilder(); int successful = 0; for (int i = 0; i < Request.Files.Count; i++) { HttpPostedFileBase file = Request.Files[i]; if (file == null) continue; if (string.IsNullOrWhiteSpace(file.FileName)) { statusMessage.AppendLine("Eine Datei hat einen ungültigen Dateinamen."); continue; } string fullName = Path.GetFileName(file.FileName); if (file.ContentLength == 0) { statusMessage.AppendFormat("Datei \"{0}\" hat keinen Inhalt.", fullName).AppendLine(); continue; } string filename = Path.GetFileNameWithoutExtension(file.FileName); string fileext = Path.GetExtension(file.FileName); if (!string.IsNullOrEmpty(fileext)) fileext = fileext.Substring(1); var revision = new Revision { SafeName = InvalidChars.Replace(filename, ""), FileSize = file.ContentLength, UploaderID = GetCurrentUserID(), Extension = fileext, GUID = Guid.NewGuid(), Created = DateTime.Now }; Document document = new Document(revision) { Deleted = null, DisplayName = fullName }; switch (entityKind) { case DocumentContainer.Topic: document.TopicID = id; break; case DocumentContainer.EmployeePresentation: document.EmployeePresentationID = id; break; default: throw new InvalidEnumArgumentException("entityKind", (int)entityKind, typeof(DocumentContainer)); } try { db.Documents.Add(document); db.SaveChanges(); // Damit die Revision die ID bekommt. Diese wird anschließend im Dateinamen hinterlegt document.LatestRevision = revision; db.SaveChanges(); string path = Path.Combine(Serverpath, revision.FileName); file.SaveAs(path); successful++; } catch (DbEntityValidationException ex) { var message = ErrorMessageFromException(ex); statusMessage.AppendFormat("Datei \"{0}\" konnte nicht in der Datenbank gespeichert werden.\n{1}", fullName, message) .AppendLine(); } catch (IOException) { statusMessage.AppendFormat("Datei \"{0}\" konnte nicht gespeichert werden.", fullName).AppendLine(); } } statusMessage.AppendFormat( successful == 1 ? "Eine Datei wurde erfolgreich verarbeitet." : "{0} Dateien wurden erfolgreich verarbeitet.", successful); // Ungelesen-Markierung aktualisieren if (topic != null && successful > 0) MarkAsUnread(topic); ViewBag.StatusMessage = statusMessage.ToString(); return _List(id, entityKind); }
// GET: Attachments public PartialViewResult _List(int id, DocumentContainer entityKind, bool makeList = false, bool showActions = true) { var documents = db.Documents .Where(a => a.Deleted == null) .OrderBy(a => a.DisplayName) .Include(a => a.Revisions) .Include(a => a.LatestRevision) .Include(a => a.LatestRevision.Uploader); if (entityKind == DocumentContainer.Topic) documents = documents.Where(a => a.TopicID == id); else if (entityKind == DocumentContainer.EmployeePresentation) documents = documents.Where(a => a.EmployeePresentationID == id); KnownExtensions = new HashSet<string>( from path in Directory.GetFiles(Server.MapPath("~/img/fileicons"), "*.png") select Path.GetFileNameWithoutExtension(path)); ViewBag.EntityID = id; ViewBag.KnownExtensions = KnownExtensions; ViewBag.OfficeExtensions = OfficeExtensions; ViewBag.SeamlessEnabled = isInternetExplorer; if (makeList) return PartialView("_AttachmentList", documents.ToList()); else { return showActions ? PartialView("_AttachmentTable", documents.ToList()) : PartialView("~/Areas/Session/Views/Finalize/_ReportAttachments.cshtml", documents.ToList()); } }
public ActionResult _UploadForm(int id, DocumentContainer entityKind) { if (entityKind == DocumentContainer.Topic && IsTopicLocked(id)) return Content("<div class=\"panel-footer\">Da das Thema gesperrt ist, können Sie keine Dateien hochladen.</div>"); else return PartialView("_DocumentCreateForm", Tuple.Create(entityKind, id)); }