public async Task HandleDeleteDocument(DeleteDocument command) { var aggregate = await _eventStreamReader.GetAggregate <DocumentAggregate>(command.StreamId); var @event = aggregate.DeleteDocument(command); await aggregate.Save(@event); }
public DocumentDeleted DeleteDocument(DeleteDocument command) { return(new DocumentDeleted { EventType = typeof(DocumentDeleted).Name, Timstamp = DateTime.UtcNow }); }
public override async Task Run(DeleteDocument <TDocument> action, IContext context) { await Data.Context.DeleteAsync <TDocument>(action.Id); await context.Emit(new DeleteDocumentResult <TDocument> { Id = action.Id }); }
public ActionResult Delete(int id) { DeleteDocument model = new DeleteDocument(id); if (model.Document == null) { ErrorModel errModel = new ErrorModel(2); errModel.ErrorMessage = string.Format("Document {0} has been deleted, please raise a help desk call if you think this has been deleted in error.", id); TempData["ErrorModel"] = errModel; return(RedirectToAction("IndexByModel", "Error", new { area = "", model = errModel ?? null })); } return(View(model)); }
public async Task <IActionResult> DeleteDocumentAsync([FromRoute] int documentId) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var command = new DeleteDocument { Id = documentId }; await service.Execute(command); return(Ok()); }
private void btnDeleteDocument_Click(object sender, RoutedEventArgs e) { if (Collection != null) { var result = MessageBox.Show(MainService.MainWindow, "El documento seleccionado será eliminado de forma permanente.\n¿Esta seguro que desea eliminar este documento?", "Confirmar eliminación", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { SqlServices.DeleteDocument((BsonDocument)Document, Collection); stpLinesContainer.Children.Remove(this); } } else { DeleteDocument?.Invoke(this, new EventArgs()); } }
public static DeleteDocumentDto ToDto(this DeleteDocument deleteDocument) { if (deleteDocument == null) { return(null); } if (string.IsNullOrEmpty(deleteDocument.Id)) { throw new ArgumentException("A Document with no Id was passed!"); } if (string.IsNullOrEmpty(deleteDocument.Domain)) { throw new ArgumentException("A Document with no Domain was passed!"); } return(new DeleteDocumentDto(deleteDocument.Id, deleteDocument.Domain)); }
public ActionResult DeleteConfirmed(DeleteDocument model) { model.Document = db.Documents.Find(model.DeleteModelID); int tipstaffRecordID = model.Document.tipstaffRecordID; string controller = genericFunctions.TypeOfTipstaffRecord(tipstaffRecordID); db.Documents.Remove(model.Document); db.SaveChanges(); string recDeleted = model.DeleteModelID.ToString(); AuditEvent AE = db.AuditEvents.Where(a => a.auditEventDescription.AuditDescription == "Document deleted" && a.RecordChanged == recDeleted).OrderByDescending(a => a.EventDate).Take(1).Single(); //add a deleted reason AE.DeletedReasonID = model.DeletedReasonID; //and save again db.SaveChanges(); return(RedirectToAction("Details", controller, new { id = tipstaffRecordID })); }
public IApiResult Delete(DeleteDocument operation) { var result = operation.ExecuteAsync().Result; if (result is ValidationsOutput) { return(new ApiResult <List <ValidationItem> >() { Data = ((ValidationsOutput)result).Errors }); } else { return(new ApiResult <object>() { Status = ApiResult <object> .ApiStatus.Success }); } }
public async Task Execute(DeleteDocument command) { var outbreakDocument = await writeContext.OutbreakDocument.FindAsync(command.Id); var epiDocument = await writeContext.EpiDocument.FindAsync(command.Id); if (outbreakDocument == null) { throw new EntityNotFoundException(typeof(OutbreakDocument), new { command.Id }); } if (epiDocument == null) { throw new EntityNotFoundException(typeof(EpiDocument), new { command.Id }); } writeContext.OutbreakDocument.Remove(outbreakDocument); writeContext.EpiDocument.Remove(epiDocument); await writeContext.SaveChangesAsync(); }
public void Can_add_and_delete_document() { var service = new SolrIntegrationService(new SolrSettings()); var document = new AddDocument("Im_gone", "test") { Fields = new List <Field>() { new Field("Kite", "4life") } }; service.CanConnect().Should().BeTrue(); service.HandleDocuments(new List <IDocument>() { document }); var delDoc = new DeleteDocument(document.Id, document.Domain); service.HandleDocuments(new List <IDocument>() { delDoc }); }
private void button1_Click(object sender, EventArgs e) { if (!Directory.Exists(logExcluirDocumentos)) { Directory.CreateDirectory(logExcluirDocumentos); } //Variaveis searchDocumentReturn searchDocumentReturn = new searchDocumentReturn(); SEClient SeachDoc = Conection.GetConnection(); var texto = ""; var CampoText = textBoxCateg.Text.Replace(" ", ""); if (Categoria.Checked) { try { listBox1DelDoc.Visible = true; listBox1DelDoc.Items.Clear(); if (CampoText != "" && CampoText != null) { searchDocumentFilter searchDocumentFilter = new searchDocumentFilter { IDCATEGORY = CampoText }; searchDocumentReturn = SeachDoc.searchDocument(searchDocumentFilter, null, null); foreach (var item in (searchDocumentReturn.RESULTS)) { listBox1DelDoc.Items.Add(item.IDDOCUMENT + " - " + item.NMTITLE); } int total = searchDocumentReturn.RESULTS.Count(); DialogResult dr = MessageBox.Show("Total de arquivos " + total + ", Deseja realmente excluir? ", "..:: Atenção ::..", MessageBoxButtons.YesNo); switch (dr) { case DialogResult.No: break; case DialogResult.Yes: if (searchDocumentReturn.RESULTS.Count() > 0) { foreach (var item in (searchDocumentReturn.RESULTS)) { texto = @"Total de Registros: " + total + " Excluindo ... " + item.IDDOCUMENT; sendText(texto); string RetornDelete = DeleteDocument.DeletDocument(CampoText, item.IDDOCUMENT); total = total - 1; } MessageBox.Show("Concluido!", ".:: Alerta ::.", MessageBoxButtons.OK, MessageBoxIcon.Information); textBoxCateg.Text = ""; sendText(""); } else { MessageBox.Show("Sem registro para excluir! \n ou \n Categoria Digitado errado", ".:: Atenção ::.", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } break; } } else { MessageBox.Show("Categoria não digitada!", ".:: Atenção ::.", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } catch (Exception ex) { File.AppendAllText(logExcluirDocumentos + @"\" + "log_erro_ExcluirDocumentos.txt", "\r\n" + DateTime.Now + @" |" + ex.Message.ToString() + @";"); MessageBox.Show(ex.Message, ".:: Atenção ::.", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else if (Matricula.Checked) { if (CampoText != "" && CampoText != null) { try { listBox1DelDoc.Visible = true; listBox1DelDoc.Items.Clear(); var fileNameArray = Path.GetFileName(CampoText).ToString().Split(new char[] { Convert.ToChar(",") }); documentDataReturn documentDataReturn = new documentDataReturn(); foreach (var item in (fileNameArray)) { documentDataReturn = SeachDoc.viewDocumentData(item, "", "", ""); listBox1DelDoc.Items.Add(documentDataReturn.IDDOCUMENT + " - " + documentDataReturn.NMTITLE); } if (documentDataReturn.IDDOCUMENT != "" && documentDataReturn.IDDOCUMENT != null) { DialogResult dr = MessageBox.Show("Deseja realmente excluir? ", "..:: Atenção ::..", MessageBoxButtons.YesNo); switch (dr) { case DialogResult.No: break; case DialogResult.Yes: foreach (var item in (fileNameArray)) { var IdDoc = documentDataReturn.IDDOCUMENT; var IdCat = documentDataReturn.IDCATEGORY; texto = @" Excluindo ... " + IdDoc + @" - " + documentDataReturn.NMTITLE; sendText(texto); string RetornDelete = DeleteDocument.DeletDocument(IdCat, item); sendText(""); } MessageBox.Show("Concluido!", ".:: Alerta ::.", MessageBoxButtons.OK, MessageBoxIcon.Information); break; } listBox1DelDoc.Items.Clear(); ////if (RetornDelete == true) { // MessageBox.Show("Concluido!", ".:: Alerta ::.", MessageBoxButtons.OK, MessageBoxIcon.Information); ////} } else { listBox1DelDoc.Visible = false; MessageBox.Show("\n Sem registro para Excluir! \n ou \n Registro Digitado errado!", ".:: Atenção ::.", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } catch (Exception ex) { File.AppendAllText(logExcluirDocumentos + @"\" + "log_erro_ExcluirDocumentos.txt", "\r\n" + DateTime.Now + @" |" + ex.Message.ToString() + @";"); MessageBox.Show(ex.Message, ".:: Atenção ::.", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("Registro não digitado!", ".:: Atenção ::.", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } }
async Task <CommandResult> HandleAsync(DeleteDocument command) { var documentTypeUri = command.ProjectId.ToKotoriDocumentTypeUri(command.DocumentType, command.DocumentTypeId); var projectUri = command.ProjectId.ToKotoriProjectUri(); var documentUri = command.ProjectId.ToKotoriDocumentUri(command.DocumentType, command.DocumentTypeId, command.DocumentId, command.Index); var project = await FindProjectAsync(command.Instance, projectUri).ConfigureAwait(false); if (project == null) { throw new KotoriProjectException(command.ProjectId, "Project does not exist.") { StatusCode = System.Net.HttpStatusCode.NotFound } } ; if (command.DocumentType == Enums.DocumentType.Data) { if (!command.Index.HasValue) { throw new KotoriDocumentException(command.DocumentId, "Data document cannot be deleted without index."); } } var document = await FindDocumentByIdAsync ( command.Instance, projectUri, documentUri, null ).ConfigureAwait(false); if (document == null) { throw new KotoriDocumentException(command.DocumentId, "Document does not exist.") { StatusCode = System.Net.HttpStatusCode.NotFound } } ; if (command.DocumentType == Enums.DocumentType.Data) { var sql = DocumentDbHelpers.CreateDynamicQueryForDocumentSearch ( command.Instance, projectUri, documentTypeUri, null, "count(1) as number", null, null, true, true ); var count = await CountDocumentsAsync(sql).ConfigureAwait(false); var result = await DeleteDocumentAsync(document).ConfigureAwait(false); if (!result) { throw new KotoriDocumentException(command.DocumentId, "Document has not been deleted."); } if (command.Index.HasValue && command.Index.Value != count - 1) { var reindexTasks = new List <Task>(); for (var i = command.Index.Value + 1; i < count; i++) { var durl = command.ProjectId.ToKotoriDocumentUri(command.DocumentType, command.DocumentTypeId, command.DocumentId, i); var d = await FindDocumentByIdAsync(command.Instance, projectUri, durl, null).ConfigureAwait(false); if (d != null) { reindexTasks.Add(ReindexDocumentAsync(d, i - 1)); } } Task.WaitAll(reindexTasks.ToArray()); } if (result) { return(new CommandResult()); } } else { if (await DeleteDocumentAsync(document).ConfigureAwait(false)) { var sql = DocumentDbHelpers.CreateDynamicQueryForDocumentSearch ( command.Instance, projectUri, documentTypeUri, null, "count(1) as number", null, null, true, true ); return(new CommandResult()); } } throw new KotoriDocumentException(command.DocumentId, "Document has not been deleted."); } } }
private static async Task Main(string[] args) { IoC.RegisterServices(); var commandHandler = new CommandHandler((IEventStreamReader)IoC.ServiceProvider.GetService(typeof(IEventStreamReader))); var streamId = Guid.Parse("e8512419-0183-42c9-b6df-0c4ea603ad00"); Guid documentId; var quit = false; while (!quit) { var key = UI(); switch (key) { case "1": var command = new CreateDocument { StreamId = streamId, Artifacts = new Dictionary <string, string>(), Name = Guid.NewGuid().ToString() }; await commandHandler.HandleCreateDocument(command); Console.WriteLine(); Console.WriteLine("Document created."); Console.WriteLine(); break; case "2": Console.WriteLine(); Console.WriteLine("Please, inform the new name of the dcocument:"); var name = Console.ReadLine(); var commandRename = new RenameDocument { StreamId = streamId, Name = name }; await commandHandler.HandleRenameDocument(commandRename); Console.WriteLine(); Console.WriteLine($"Document renamed"); Console.WriteLine(); break; case "3": Console.WriteLine(); var commandUpdate = new UpdateArtifacts { StreamId = streamId, AddArtifacts = new Dictionary <string, string> { { Guid.NewGuid().ToString(), Guid.NewGuid().ToString() } }, RemoveArtifacts = new List <string>() }; await commandHandler.HandleUpdateArtifacts(commandUpdate); Console.WriteLine(); Console.WriteLine($"Artifacts Updated!"); Console.WriteLine(); break; case "4": Console.WriteLine(); Console.WriteLine("Please, inform the approver name"); var approverName = Console.ReadLine(); var commandApprove = new ApproveDocument { StreamId = streamId, Approver = approverName }; await commandHandler.HandleApproveDocument(commandApprove); Console.WriteLine(); Console.WriteLine($"Document approved"); Console.WriteLine(); break; case "5": Console.WriteLine(); Console.WriteLine("Please, inform the approver name"); var rejecterName = Console.ReadLine(); var commandReject = new RejectDocument { StreamId = streamId, Rejecter = rejecterName }; await commandHandler.HandleRejectDocument(commandReject); Console.WriteLine(); Console.WriteLine($"Document rejected"); Console.WriteLine(); break; case "6": Console.WriteLine(); var commandDelete = new DeleteDocument { StreamId = streamId }; await commandHandler.HandleDeleteDocument(commandDelete); Console.WriteLine(); Console.WriteLine($"Document deleted"); Console.WriteLine(); break; case "Q": quit = true; break; case "q": quit = true; break; default: Console.WriteLine(); Console.WriteLine("Invalid option, chose a valid command"); Console.WriteLine(); break; } } }
public string Delete([FromBody] DeleteDocument document) { var jobId = BackgroundJob.Enqueue <Deployment>(x => x.DeleteSync(document.deploymentLog, document.accountDetails)); return(jobId); }
protected override void Execute(CodeActivityContext executionContext) { EntityReference DocumentTemplateIdValue = DocumentTemplateId.Get(executionContext); Boolean EnableLoggingValue = EnableLogging.Get(executionContext); string ProductUriValue = ProductUri.Get(executionContext); string AppSIDValue = AppSID.Get(executionContext); string AppKeyValue = AppKey.Get(executionContext); Boolean DeleteTemplateValue = DeleteTemplate.Get(executionContext); Boolean DeleteDocumentValue = DeleteDocument.Get(executionContext); OutputAttachmentId.Set(executionContext, new EntityReference("annotation", Guid.Empty)); CloudAppConfig config = new CloudAppConfig(); config.ProductUri = ProductUriValue; config.AppSID = AppSIDValue; config.AppKey = AppKeyValue; IWorkflowContext context = executionContext.GetExtension <IWorkflowContext>(); IOrganizationServiceFactory serviceFactory = executionContext.GetExtension <IOrganizationServiceFactory>(); IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId); try { if (EnableLoggingValue) { Log("WorkFlow Started", service); } string PrimaryEntityName = context.PrimaryEntityName; Guid PrimaryEntityId = context.PrimaryEntityId; if (EnableLoggingValue) { Log("Retrieving Attachment From Template", service); } QueryExpression RetrieveNoteQuery = new QueryExpression("annotation"); RetrieveNoteQuery.ColumnSet = new ColumnSet(new string[] { "filename", "documentbody", "mimetype" }); RetrieveNoteQuery.Criteria.AddCondition(new ConditionExpression("objectid", ConditionOperator.Equal, DocumentTemplateIdValue.Id)); EntityCollection TemplateAttachments = service.RetrieveMultiple(RetrieveNoteQuery); if (EnableLoggingValue) { Log("Attachment Retrieved Successfully", service); } if (TemplateAttachments != null && TemplateAttachments.Entities.Count > 0) { Entity AttachmentTemplate = TemplateAttachments.Entities[0]; if (AttachmentTemplate.Contains("mimetype") && AttachmentTemplate.Contains("documentbody")) { string FileName = ""; if (AttachmentTemplate.Contains("filename")) { FileName = AttachmentTemplate["filename"].ToString(); } config.FileName = FileName; byte[] DocumentBody = Convert.FromBase64String(AttachmentTemplate["documentbody"].ToString()); MemoryStream fileStream = new MemoryStream(DocumentBody); if (EnableLoggingValue) { Log("Upload Template on Storage", service); } UploadFileOnStorage(config, fileStream); if (EnableLoggingValue) { Log("Get Fields List", service); } string[] Fields = GetFieldsName(config).ToArray(); if (EnableLoggingValue) { Log("Retrieving Fields Values From CRM", service); } Entity PrimaryEntity = service.Retrieve(PrimaryEntityName, PrimaryEntityId, new ColumnSet(Fields)); string[] Values = new string[Fields.Length]; if (PrimaryEntity != null) { for (int i = 0; i < Fields.Length; i++) { if (PrimaryEntity.Contains(Fields[i])) { if (PrimaryEntity[Fields[i]].GetType() == typeof(OptionSetValue)) { Values[i] = PrimaryEntity.FormattedValues[Fields[i]].ToString(); } else if (PrimaryEntity[Fields[i]].GetType() == typeof(EntityReference)) { Values[i] = ((EntityReference)PrimaryEntity[Fields[i]]).Name; } else { Values[i] = PrimaryEntity[Fields[i]].ToString(); } } else { Values[i] = ""; } } } if (EnableLoggingValue) { Log("Generating Xml", service); } string Xml = GenerateXML(Fields, Values); if (EnableLoggingValue) { Log("Executing MailMerge", service); } string OutputFileName = ExecuteMailMerge(config, Xml); if (EnableLoggingValue) { Log("Downloading File From Cloud", service); } MemoryStream OutputFile = DownloadFile(config, OutputFileName); if (EnableLoggingValue) { Log("Generating CRM Attachment", service); } byte[] byteData = OutputFile.ToArray(); string encodedData = System.Convert.ToBase64String(byteData); Entity NewNote = new Entity("annotation"); NewNote.Attributes.Add("objectid", new EntityReference(PrimaryEntityName, PrimaryEntityId)); NewNote.Attributes.Add("subject", FileName); NewNote.Attributes.Add("documentbody", encodedData); NewNote.Attributes.Add("mimetype", @"application/vnd.openxmlformats-officedocument.wordprocessingml.document"); NewNote.Attributes.Add("notetext", "Document Created using Aspose Cloud"); NewNote.Attributes.Add("filename", FileName); Guid NewNoteId = service.Create(NewNote); if (EnableLoggingValue) { Log("Removing Documents from Storage", service); } if (DeleteTemplateValue) { DeleteDocumentFromStorage(config, FileName); } if (DeleteDocumentValue) { DeleteDocumentFromStorage(config, OutputFileName); } OutputAttachmentId.Set(executionContext, new EntityReference("annotation", NewNoteId)); } else { if (EnableLoggingValue) { Log("Attachment Doesnot contain any document", service); } } } else { if (EnableLoggingValue) { Log("No Attachments in the Template Provided", service); } } if (EnableLoggingValue) { Log("Workflow Executed Successfully", service); } } catch (Exception ex) { Log(ex.Message, service); throw ex; } }
private void button3_Click(object sender, EventArgs e) { try { int cont = 0; var categ = textBox1categ.Text.Replace(" ", ""); if (categ != "" && categ != null) { listBox1PSTsemDOC.Items.Clear(); sendText2(""); searchDocumentReturn searchDocumentReturn = new searchDocumentReturn(); searchDocumentFilter searchDocumentFilter = new searchDocumentFilter { IDCATEGORY = categ }; SEClient SeachDoc = Conection.GetConnection(); searchDocumentReturn = SeachDoc.searchDocument(searchDocumentFilter, null, null); if (searchDocumentReturn.RESULTS.Count() > 0) { foreach (var item in (searchDocumentReturn.RESULTS)) { //documentDataReturn searchDocumentReturn2 = new documentDataReturn(); //SEClient SeachDoc2 = Conection.GetConnection(); searchDocumentReturn2 = SeachDoc2.viewDocumentData(item.IDDOCUMENT, "", "", ""); sendText2("Pesquisando... " + item.IDDOCUMENT); if (searchDocumentReturn2.ELECTRONICFILE.Count() == 0) { listBox1PSTsemDOC.Items.Add(item.IDDOCUMENT + " - " + item.NMTITLE); cont++; } } sendText2("Total de Documentos: " + cont); if (cont > 0) { DialogResult dr = MessageBox.Show("Deseja realmente excluir? ", "..:: Atenção ::..", MessageBoxButtons.YesNo); switch (dr) { case DialogResult.No: break; case DialogResult.Yes: foreach (var item in (searchDocumentReturn.RESULTS)) { searchDocumentReturn2 = SeachDoc2.viewDocumentData(item.IDDOCUMENT, "", "", ""); if (searchDocumentReturn2.ELECTRONICFILE.Count() == 0) { sendText3("Excluindo... " + searchDocumentReturn2.IDDOCUMENT + " - " + searchDocumentReturn2.NMTITLE); var RetornDelete = DeleteDocument.DeletDocument(searchDocumentReturn2.IDCATEGORY, searchDocumentReturn2.IDDOCUMENT); } } break; } MessageBox.Show("Finalizado Exclusão!", ".:: Alerta ::.", MessageBoxButtons.OK, MessageBoxIcon.Information); sendText3(""); } } } else { MessageBox.Show("Digite a categoria !", ".:: Atenção ::.", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } catch (Exception ex) { MessageBox.Show("Erro: " + ex.Message, ".:: Atenção ::.", MessageBoxButtons.OK, MessageBoxIcon.Information); } }