/// <summary> /// The DocumentSaving callback. This callback checks if at least one new revision has been added, and if not /// shows instructions to the user to deal with the situation. /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private void OnSavingPromptForRevisions(object sender, DocumentSavingEventArgs args) { Document doc = (Document)sender; UIApplication uiApp = new UIDocument(doc).Application; if (doc.IsModified) { // Compare number of revisions with saved count int revisionCount = GetRevisionCount(doc); if (revisionCount <= storedRevisionCount) { // Show dialog with explanation and options TaskDialog td = new TaskDialog("Revisions not created."); td.MainIcon = TaskDialogIcon.TaskDialogIconWarning; td.MainInstruction = "Changes have been made to this document, but no new revision has been created."; td.ExpandedContent = "Because the document has been released, it is typically required to issue a new " + "revision number with any change."; td.AddCommandLink(TaskDialogCommandLinkId.CommandLink1, "Add revision now"); td.AddCommandLink(TaskDialogCommandLinkId.CommandLink2, "Cancel save"); td.AddCommandLink(TaskDialogCommandLinkId.CommandLink3, "Proceed with save (not recommended)."); td.TitleAutoPrefix = false; td.AllowCancellation = false; TaskDialogResult result = td.Show(); switch (result) { case TaskDialogResult.CommandLink1: // Add revision now { // cancel first save args.Cancel(); // add event to hide the default "Document not saved" dialog uiApp.DialogBoxShowing += HideDocumentNotSaved; // post command for editing revisions PromptToEditRevisionsAndResave(uiApp); break; } case TaskDialogResult.CommandLink2: // Cancel save { // cancel saving only args.Cancel(); break; } case TaskDialogResult.CommandLink3: // Proceed with save { // do nothing break; } } } else { storedRevisionCount = revisionCount; } } }
private void OnSavingPromptForRevisions(object sender, DocumentSavingEventArgs args) { Document doc = (Document)sender; UIApplication uiApp = new UIDocument(doc).Application; if (doc.IsModified) { // Compare number of revisions with saved count int revisionCount = GetRevisionCount(doc); if (revisionCount <= storedRevisionCount) { // Show dialog with explanation and options TaskDialog td = new TaskDialog("Revisions not created."); td.MainIcon = TaskDialogIcon.TaskDialogIconWarning; td.MainInstruction = "此文件已经修改,但还未添加新修订。"; td.ExpandedContent = "因为文档已经修改,所以通常需要发布一个新的修订版本号。"; td.AddCommandLink(TaskDialogCommandLinkId.CommandLink1, "添加修订"); td.AddCommandLink(TaskDialogCommandLinkId.CommandLink2, "取消保存"); td.AddCommandLink(TaskDialogCommandLinkId.CommandLink3, "继续保存(不推荐)"); td.TitleAutoPrefix = false; td.AllowCancellation = false; TaskDialogResult result = td.Show(); switch (result) { case TaskDialogResult.CommandLink1: // Add revision now { // cancel first save args.Cancel(); // 注册DialogBoxShowing事件 用于隐藏"Document not saved" dialog uiApp.DialogBoxShowing += HideDocumentNotSaved; // post command for editing revisions PromptToEditRevisionsAndResave(uiApp); break; } case TaskDialogResult.CommandLink2: // Cancel save { // cancel saving only args.Cancel(); break; } case TaskDialogResult.CommandLink3: // Proceed with save { // do nothing break; } } } else { storedRevisionCount = revisionCount; } } }
void OnDocumentAutoSaving(IDocumentInfo documentInfo, DocumentSavingEventArgs e) { try { SaveDocument(documentInfo, false); } finally { e.Handled = true; DataService.CloseUnitOfWork(); } }
public void SavingDocumentEventHandler(object sender, DocumentSavingEventArgs args) { Document doc = args.Document; var check = CheckRebars(doc); if (check.Count > 0) { TaskDialog.Show("Ошибка", "Обновите ведомость деталей"); args.Cancel(); } }
void OnDocumentSaving(object sender, DocumentSavingEventArgs e) { try { Console.WriteLine("savingDoc"); } catch (Exception err) { Console.Write(err.ToString()); } }
protected void ASPxSpreadsheet1_Saving(object source, DocumentSavingEventArgs e) { ASPxSpreadsheet sh = source as ASPxSpreadsheet; try { // SqlDataSource1.Update(); // uncomment to update the data source sh.JSProperties["cpSavingResult"] = "OK"; } catch (Exception ex) { sh.JSProperties["cpSavingResult"] = "ERROR"; } e.Handled = true; }
private static void OnDocumentSaving(object sender, DocumentSavingEventArgs e) { var doc = e.Document; if (doc == null) { return; } try { SchemaUtils.SaveSchema(doc); } catch (Exception ex) { _logger.Fatal(ex); } }
// Saving Document protected void richEdit_Saving(object source, DocumentSavingEventArgs e) { e.Handled = true; if (!Request.IsLocal) // Disable modifying for online demo { return; } string[] idStrs = e.DocumentID.Split('&'); string currentDocumentId = idStrs[0]; long id = long.Parse(currentDocumentId); var item = Utils.CurrentDataProvider.GetDocumentById(id); if (item != null) { Utils.CurrentDataProvider.SetDocumentContent(id, richEdit.SaveCopy(Utils.GetRichEditDocumentFormatByExtension(item.Name))); } }
/// <summary> /// This event is fired whenever a document is saved. /// Update door's information according to door's current geometry. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="args">An DocumentSavingEventArgs that contains the DocumentSaving event data.</param> private void DocumentSavingHandler(Object sender, DocumentSavingEventArgs args) { string message = ""; Transaction tran = null; try { Document doc = args.Document; if (doc.IsModifiable) { if (DoorSwingData.UpdateDoorsInfo(args.Document, false, false, ref message) != Autodesk.Revit.UI.Result.Succeeded) { TaskDialog.Show("Door Swing", message); } } else { tran = new Transaction(doc, "Update parameters in Saving event"); tran.Start(); if (DoorSwingData.UpdateDoorsInfo(args.Document, false, false, ref message) != Autodesk.Revit.UI.Result.Succeeded) { TaskDialog.Show("Door Swing", message); } tran.Commit(); } } catch (Exception ex) { // if there are something wrong, give error information message. TaskDialog.Show("Door Swing", ex.Message); if (null != tran) { if (tran.HasStarted() && !tran.HasEnded()) { tran.RollBack(); } } } }
public void RegisterSaveEvent(object sender, DocumentSavingEventArgs args) { // Tell user what we're doing Document doc = args.Document; TaskDialog td = new TaskDialog("Alert"); td.MainInstruction = "Application 'Automatic element creator' needs to reload changes from central in order to proceed."; td.MainContent = "Are you sure to save this project?"; td.CommonButtons = TaskDialogCommonButtons.Ok | TaskDialogCommonButtons.Cancel; TaskDialogResult result = td.Show(); if (result == TaskDialogResult.Ok) { // There are no currently customizable user options for ReloadLatest. doc.Save(); doc.Close(); } else { doc.Close(); } }
/// <summary> /// Closes the specified document and removes it from the DocumentManager. /// Generates the DocumentClosed event, which should be caught by /// the UI in order to dispose of the document. /// If the document is Dirty, the DirtyDocumentClosing event will be generated /// to give the UI a chance to decide what action should be taken. /// </summary> public bool CloseDocument(IDocument document, bool fromGUI) { // If the document isn't in the list, then we've probably looped back from the GUI. if (!documents.Contains(document)) { return(true); } if (document.DocumentState == DocumentState.Dirty) { if (DirtyDocumentClosing != null) { DocumentSavingEventArgs e = new DocumentSavingEventArgs(SaveAction.SaveChanges); DirtyDocumentClosing(document, e); if (e.Action == SaveAction.Cancel) { return(false); } else if (e.Action == SaveAction.SaveChanges) { document.SaveDocument(); } } } string documentIdentifier = document.DocumentFilename; document.CloseDocument(); documents.Remove(document); if (DocumentClosed != null) { DocumentClosed(documentIdentifier, fromGUI); } return(true); }
static void DocumentManager_DemoAutoSaving(IDocumentInfo documentInfo, DocumentSavingEventArgs e) { e.Handled = true; }
protected void RichEdit_Saving(object source, DocumentSavingEventArgs e) { // Save document with the Ribbon Save button e.Handled = true; SqlDataSource1.Update(); }
private void InstanceOnDocumentSaving(DocumentSavingEventArgs args) { documentSaving = true; }
private void doc_DocumentSaving(object sender, DocumentSavingEventArgs e) { DisplayEvent("Document saving"); }
private static void DocumentManager_AutoSaving(IDocumentInfo documentInfo, DocumentSavingEventArgs e) { }
/// <summary> /// Delegate for document save event, it will update spreadsheet if document was mapped to spreadsheet. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">EventArgs of this event.</param> public void DocumentSaving(object sender, DocumentSavingEventArgs e) { DumpLog("Raised DocumentSaving -> Document: " + Path.GetFileNameWithoutExtension(e.Document.Title)); UpdateMappedSpreadsheet(e.Document); }
/// <summary> /// This event is fired whenever a document is saved. /// Update door's information according to door's current geometry. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="args">An DocumentSavingEventArgs that contains the DocumentSaving event data.</param> private void DocumentSavingHandler(Object sender, DocumentSavingEventArgs args) { string message = ""; Transaction tran = null; try { Document doc = args.Document; if (doc.IsModifiable) { if (DoorSwingData.UpdateDoorsInfo(args.Document, false, false, ref message) != Autodesk.Revit.UI.Result.Succeeded) MessageBox.Show(message, "Door Swing"); } else { tran = new Transaction(doc, "Update parameters in Saving event"); tran.Start(); if (DoorSwingData.UpdateDoorsInfo(args.Document, false, false, ref message) != Autodesk.Revit.UI.Result.Succeeded) MessageBox.Show(message, "Door Swing"); tran.Commit(); } } catch (Exception ex) { // if there are something wrong, give error information message. MessageBox.Show(ex.Message, "Door Swing"); if (null != tran) { if (tran.HasStarted() && !tran.HasEnded()) { tran.RollBack(); } } } }
static void DocumentManager_AutoSaving(IDocumentInfo documentInfo, DocumentSavingEventArgs e) { DocumentsApp.Instance.Document.OnDocumentAutoSaving(documentInfo, e); }
private void InstanceOnDocumentSaving(DocumentSavingEventArgs args) { throw new NotImplementedException(); }