private void DocumentOpen(Word.Document Doc) { if (!IsTracking) { return; } TrackingListManager.Reload(); var trackingItem = TrackingListManager.GetByPath(Doc.FullName); if (trackingItem == null) { return; //Not tracked by DokuFlex yet! } var ticket = Session.GetTikect(); if (String.IsNullOrWhiteSpace(ticket)) { return; } var documentMetadata = DokuFlexService.GetDocumentMetadada(ticket, trackingItem.FileId); if (documentMetadata == null) { return; } if (trackingItem.ModifiedTime < documentMetadata.dateModified) { if (MessageBox.Show(String.Format("Existe una versión más reciente de {0} en DokuFlex.\n\n{1}", Doc.Name.ToUpperInvariant(), "¿Desea actualizar el documento con la versión de DokuFlex?"), Globals.ThisAddIn.Application.Name, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { var currentPath = Doc.FullName; Doc.Close(false); try { File.Delete(currentPath); } catch (Exception) { return; } using (var form = new TransferProgressForm()) { if (form.DownloadFile(ticket, trackingItem.FileId, currentPath)) { TrackOff(); Globals.ThisAddIn.Application.Documents.Open(currentPath); TrackOn(); trackingItem.ModifiedTime = documentMetadata.dateModified; TrackingListManager.Save(); } } } } }