Ejemplo n.º 1
0
        public ActionResult ViewAwardRDV(Guid id)
        {
            return(ActionResultHelper.TryCatchWithLogger(() =>
            {
                AwardBatch awardBatch = _preservationService.GetAwardBatch(id);
                if (awardBatch.IdRDVDocument.HasValue)
                {
                    using (DocumentsClient client = new DocumentsClient())
                    {
                        DocumentContent content = client.GetDocumentContentById(awardBatch.IdRDVDocument.Value);
                        if (content != null)
                        {
                            return View(new WindowFileContentViewModel()
                            {
                                Content = System.Text.Encoding.UTF8.GetString(content.Blob)
                            });
                        }
                    }
                    _loggerService.Warn(string.Format("ViewAwardRDV -> nessun documento trovato con Id {0}.", awardBatch.IdRDVDocument));
                }

                WindowFileContentViewModel model = new WindowFileContentViewModel()
                {
                    Content = string.Empty
                };
                return View(model);
            }, _loggerService));
        }
Ejemplo n.º 2
0
 private void UcLoadFileOnStorage_Load(object sender, EventArgs e)
 {
     try
     {
         waitForm.Show();
         BackgroundWorker bcw = new BackgroundWorker();
         bcw.DoWork += delegate(object sender1, DoWorkEventArgs e1)
         {
             using (DocumentsClient client = new DocumentsClient("Binding_Documents"))
                 archives = client.GetArchives();
         };
         bcw.RunWorkerCompleted += delegate(object sender1, RunWorkerCompletedEventArgs e1)
         {
             waitForm.Close();
             if (e1.Error != null)
             {
                 MessageBox.Show(e1.Error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             else
             {
                 ddlArchives.DisplayMember = "Name";
                 ddlArchives.ValueMember   = "IdArchive";
                 ddlArchives.DataSource    = archives;
             }
         };
         bcw.RunWorkerAsync();
     }
     catch (Exception ex)
     {
         waitForm.Close();
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 3
0
 private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
 {
     using (DocumentsClient client = new DocumentsClient("Binding_Documents"))
     {
         attributes = client.GetAttributesDefinition(archiveName);
     }
 }
Ejemplo n.º 4
0
        private bool verifyConnection(string url)
        {
            bool isOk = false;

            try
            {
                using (var svc = new DocumentsClient(DOCUMENT_SERVICE_NAME, this.getServiceEndpointAddress(url, true)))
                {
                    isOk = svc.IsAlive();
                }

                if (isOk)
                {
                    using (var svc = new ContentSearchClient(CONTENT_SEARCH_NAME, this.getServiceEndpointAddress(url, false)))
                    {
                        isOk = svc.IsAlive();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "Impossibile stabilire una connessione.", TITOLO, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(isOk);
        }
Ejemplo n.º 5
0
 private void ddlArchives_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (ddlArchives.SelectedValue != null)
     {
         CurrentArchive = archives[ddlArchives.SelectedIndex];
         if (CurrentArchive != null)
         {
             BackgroundWorker bcw = new BackgroundWorker();
             bcw.DoWork += delegate(object sender1, DoWorkEventArgs e1)
             {
                 using (DocumentsClient client = new DocumentsClient("Binding_Documents"))
                 {
                     attributes = client.GetAttributesDefinition(CurrentArchive.Name);
                 }
             };
             bcw.RunWorkerCompleted += delegate(object sender1, RunWorkerCompletedEventArgs e1)
             {
                 waitForm.Close();
                 waitForm.Close();
                 if (e1.Error == null)
                 {
                     gwAttributes.DataSource = attributes;
                 }
                 else
                 {
                     MessageBox.Show(e1.Error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             };
             bcw.RunWorkerAsync();
         }
     }
 }
Ejemplo n.º 6
0
 public DocumentBiblosDS(ILogger logger, IParameterEnvService parameterEnvService)
 {
     _instanceId          = Guid.NewGuid();
     _logger              = logger;
     _parameterEnvService = parameterEnvService;
     _documentsClient     = new DocumentsClient();
 }
Ejemplo n.º 7
0
 internal static DocumentAttribute[] GetBiblosDSMetadataStructure(Guid idArchive)
 {
     using (var client = new DocumentsClient())
     {
         return(client.GetMetadataStructure(idArchive));
     }
 }
Ejemplo n.º 8
0
        private void radComboBoxStorage_SelectedIndexChanged(object sender, EventArgs e)
        {
            waitForm = new WaitForm();
            waitForm.Show();
            BackgroundWorker bcw = new BackgroundWorker();

            bcw.DoWork += delegate(object sender1, DoWorkEventArgs e1)
            {
                using (DocumentsClient client = new DocumentsClient())
                    if (Storage != null)
                    {
                        storageAreas = client.GetStorageAreas(Storage);
                    }
            };
            bcw.RunWorkerCompleted += delegate(object sender1, RunWorkerCompletedEventArgs e1)
            {
                waitForm.Close();
                if (e1.Error != null)
                {
                    MessageBox.Show(e1.Error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    radComboBoxStorageArea.DisplayMember = "Name";
                    radComboBoxStorageArea.ValueMember   = "IdStorageArea";
                    radComboBoxStorageArea.DataSource    = storageAreas;
                }
            };
            bcw.RunWorkerAsync();
        }
Ejemplo n.º 9
0
 private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
 {
     using (DocumentsClient client = new DocumentsClient())
     {
         documents = client.GetChainInfoDetails((Guid)e.Argument, null, null, null);
     }
 }
Ejemplo n.º 10
0
        public ActionResult ViewAwardPDV(Guid id)
        {
            return(ActionResultHelper.TryCatchWithLogger(() =>
            {
                AwardBatch awardBatch = _preservationService.GetAwardBatch(id);
                if (awardBatch.IdPDVDocument.HasValue)
                {
                    using (DocumentsClient client = new DocumentsClient())
                    {
                        DocumentContent content = client.GetDocumentContentById(awardBatch.IdPDVDocument.Value);
                        if (content != null)
                        {
                            return View(new WindowFileContentViewModel()
                            {
                                Content = System.Text.Encoding.UTF8.GetString(content.Blob)
                            });
                        }
                        _loggerService.Warn(string.Format("ViewAwardPDV -> nessun documento trovato con Id {0}. Si procede con una nuova generazione del pacchetto di versamento.", awardBatch.IdPDVDocument));
                    }
                }

                string pdv = _preservationService.CreateAwardBatchPDVXml(awardBatch);
                SavePDVXml(pdv, awardBatch);
                WindowFileContentViewModel model = new WindowFileContentViewModel()
                {
                    Content = pdv
                };
                return View(model);
            }, _loggerService));
        }
Ejemplo n.º 11
0
        void documentoCheckOut_Click(object sender, EventArgs e)
        {
            try
            {
                var currentDoc = radGridView2.SelectedRows.First().DataBoundItem as ServiceReferenceDocument.Document;

                if (currentDoc != null && !currentDoc.IsLatestVersion)
                {
                    RadMessageBox.Show(this, "Impossibile mettere in check-out una versione precedente del documento.", "", MessageBoxButtons.OK, RadMessageIcon.Exclamation);
                    return;
                }

                if (RadMessageBox.Show("Sei sicuro di volere estrarre il documento?", "Check-Out", MessageBoxButtons.YesNo, Telerik.WinControls.RadMessageIcon.Question) == DialogResult.Yes)
                {
                    ServiceReferenceDocument.Document document = new BiblosDs.Document.AdminCentral.ServiceReferenceDocument.Document();
                    Guid             id   = (Guid)radGridView2.SelectedRows[0].Cells["IdDocument"].Value;
                    string           user = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
                    BackgroundWorker bcw  = new BackgroundWorker();
                    waitForm = new WaitForm();
                    waitForm.Show();
                    bcw.DoWork += delegate(object sender1, DoWorkEventArgs e1)
                    {
                        using (DocumentsClient client = new DocumentsClient("Binding_Documents"))
                        {
                            document = client.CheckOutDocument(id, user, ContentFormat.Bynary, null);
                        }
                    };
                    bcw.RunWorkerCompleted += delegate(object sender1, RunWorkerCompletedEventArgs e1)
                    {
                        waitForm.Close();
                        if (e1.Error != null)
                        {
                            MessageBox.Show(e1.Error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            saveFileDialog1 = new SaveFileDialog();
                            radGridView2.SelectedRows[0].Cells["IsCheckOut"].Value     = true;
                            radGridView2.SelectedRows[0].Cells["IdUserCheckOut"].Value = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
                            if (document.Content != null && saveFileDialog1.ShowDialog() == DialogResult.OK)
                            {
                                File.WriteAllBytes(saveFileDialog1.FileName, document.Content.Blob);
                            }
                        }
                    };
                    bcw.RunWorkerAsync();
                }
            }
            catch (Exception ex)
            {
                RadMessageBox.Show(ex.Message, "Errore", MessageBoxButtons.OK, Telerik.WinControls.RadMessageIcon.Error);
            }
        }
Ejemplo n.º 12
0
 private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
 {
     try
     {
         using (DocumentsClient client = new DocumentsClient("Binding_Documents"))
         {
             attributes = client.GetAttributesDefinition(radComboBoxArchive.Text);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 13
0
 void documentoCheckIn_Click(object sender, EventArgs e)
 {
     try
     {
         ServiceReferenceDocument.Document document = (ServiceReferenceDocument.Document)radGridView2.SelectedRows[0].DataBoundItem;
         if (MessageBox.Show("Si vuole modificare il contenuto del file?", "Modificare il file?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             if (openFileDialog1.ShowDialog() == DialogResult.OK)
             {
                 document.Content      = new Content();
                 document.Content.Blob = File.ReadAllBytes(openFileDialog1.FileName);
             }
         }
         Forms.AttributeEdit attrEdit = new AttributeEdit(document.Archive.Name, document.AttributeValues);
         if (attrEdit.ShowDialog() == DialogResult.OK)
         {
             document.AttributeValues = attrEdit.GetAttributeValue();
             BackgroundWorker bcw = new BackgroundWorker();
             waitForm = new WaitForm();
             waitForm.Show();
             string user = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
             bcw.DoWork += delegate(object sender1, DoWorkEventArgs e1)
             {
                 using (DocumentsClient client = new DocumentsClient("Binding_Documents"))
                 {
                     client.CheckInDocument(document, user, ContentFormat.Bynary, null);
                 }
             };
             bcw.RunWorkerCompleted += delegate(object sender1, RunWorkerCompletedEventArgs e1)
             {
                 waitForm.Close();
                 if (e1.Error != null)
                 {
                     MessageBox.Show(e1.Error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
                 else
                 {
                     radGridView2.SelectedRows[0].Cells["IsCheckOut"].Value     = true;
                     radGridView2.SelectedRows[0].Cells["IdUserCheckOut"].Value = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
                     radGridView1_CurrentRowChanged();
                 }
             };
             bcw.RunWorkerAsync();
         }
     }
     catch (Exception ex)
     {
         RadMessageBox.Show(ex.Message, "Errore", MessageBoxButtons.OK, Telerik.WinControls.RadMessageIcon.Error);
     }
 }
Ejemplo n.º 14
0
        public ActionResult ExportPDD(string data)
        {
            return(ActionResultHelper.TryCatchWithLogger(() =>
            {
                ICollection <Guid> ids = JsonConvert.DeserializeObject <ICollection <Guid> >(HttpUtility.UrlDecode(data));
                Guid processId = Guid.NewGuid();
                string path = Path.Combine(ConfigurationHelper.GetAppDataPath(), processId.ToString());
                Directory.CreateDirectory(path);
                try
                {
                    foreach (Guid id in ids)
                    {
                        Document document = DocumentService.GetDocument(id);
                        using (DocumentsClient client = new DocumentsClient())
                        {
                            document.Content = client.GetDocumentContentById(id);
                        }

                        //Copied from preservation logic
                        document.AttributeValues = AttributeService.GetAttributeValues(document.IdDocument);
                        var fileName = string.Concat(_preservationService.PreservationDocumentFileName(document), (Path.GetExtension(document.Name)));
                        System.IO.File.WriteAllBytes(Path.Combine(path, fileName), document.Content.Blob);

                        if (document.IdPreservation.HasValue)
                        {
                            Preservation preservation = _preservationService.GetPreservation(document.IdPreservation.Value, false);
                            string[] files = Directory.GetFiles(preservation.Path).Where(x => x.Contains("INDICE_") || x.Contains("CHIUSURA_") || x.Contains("IPDA_") || x.Contains("LOTTI_")).ToArray();
                            foreach (string file in files.Where(f => !System.IO.File.Exists(Path.Combine(path, Path.GetFileName(f)))))
                            {
                                System.IO.File.Copy(file, Path.Combine(path, Path.GetFileName(file)), true);
                            }
                        }
                    }
                    string zipPath = CreatePDDZip(path);
                    return File(System.IO.File.ReadAllBytes(zipPath), System.Net.Mime.MediaTypeNames.Application.Zip);
                }
                finally
                {
                    if (Directory.Exists(path))
                    {
                        Directory.Delete(path, true);
                    }
                }
            }, _loggerService));
        }
Ejemplo n.º 15
0
        private void backgroundWorker2_DoWork(object sender, DoWorkEventArgs e)
        {
            DocumentsClient client = null;

            try
            {
                client   = new DocumentsClient("Binding_Documents");
                archives = client.GetArchives();
                if (archives != null)
                {
                    archives = new BindingList <Archive>(archives.OrderBy(x => x.Name).ToList());
                }
            }
            finally
            {
                try
                {
                    client.Close();
                }
                catch { }
            }
        }
Ejemplo n.º 16
0
        public ActionResult CloseAwardBatch(Guid id)
        {
            return(ActionResultHelper.TryCatchWithLogger(() =>
            {
                AwardBatch awardBatch = _preservationService.GetAwardBatch(id);
                if (awardBatch.IsOpen)
                {
                    _preservationService.CloseAwardBatch(awardBatch);
                    string xml = string.Empty;
                    if (awardBatch.IdPDVDocument.HasValue)
                    {
                        using (DocumentsClient client = new DocumentsClient())
                        {
                            DocumentContent content = client.GetDocumentContentById(awardBatch.IdPDVDocument.Value);
                            if (content != null)
                            {
                                xml = Encoding.UTF8.GetString(content.Blob);
                            }
                            _loggerService.Warn(string.Format("CloseAwardBatch -> nessun documento trovato con Id {0}. Si procede con una nuova generazione del pacchetto di versamento.", awardBatch.IdPDVDocument));
                        }
                    }

                    if (string.IsNullOrEmpty(xml))
                    {
                        xml = _preservationService.CreateAwardBatchPDVXml(awardBatch);
                        SavePDVXml(xml, awardBatch);
                    }

                    DocumentArchive archive = ArchiveService.GetArchive(awardBatch.IdArchive);
                    if (!archive.Name.Equals(ConfigurationHelper.RDVArchiveName, StringComparison.InvariantCultureIgnoreCase))
                    {
                        SaveRDVXml(xml, awardBatch);
                    }
                }
                return Content(string.Empty);
            }, _loggerService));
        }
Ejemplo n.º 17
0
        private void btnAddChain_Click(object sender, EventArgs e)
        {
            ServiceReferenceDocument.Document document = new ServiceReferenceDocument.Document();
            document.Archive = CurrentArchive;

            try
            {
                waitForm = new WaitForm();
                waitForm.Show();
                BackgroundWorker bcw = new BackgroundWorker();
                bcw.DoWork += delegate(object sender1, DoWorkEventArgs e1)
                {
                    using (DocumentsClient client = new DocumentsClient("Binding_Documents"))
                    {
                        document.IdDocument = client.CreateDocumentChain(CurrentArchive.Name, new BindingList <AttributeValue>());
                    }
                };
                bcw.RunWorkerCompleted += delegate(object sender1, RunWorkerCompletedEventArgs e1)
                {
                    waitForm.Close();
                    if (e1.Error != null)
                    {
                        MessageBox.Show(e1.Error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        WriteChainToFile(document, false);
                    }
                };
                bcw.RunWorkerAsync();
            }
            catch (Exception ex)
            {
                waitForm.Close();
                MessageBox.Show(ex.Message, "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 18
0
 void metadataView_Click(object sender, EventArgs e)
 {
     waitForm = new WaitForm();
     waitForm.Show();
     try
     {
         DocumentsClient client = new DocumentsClient("Binding_Documents");
         client.GetDocumentInfoCompleted += (object o, GetDocumentInfoCompletedEventArgs args) =>
         {
             waitForm.Close();
             if (args.Error != null)
             {
                 MessageBox.Show(args.Error.ToString());
             }
             else
             {
                 var doc = args.Result.Where(x => x.IdDocument == (Guid)args.UserState).FirstOrDefault();
                 if (doc != null)
                 {
                     Forms.MetaDataView metadata = new Forms.MetaDataView();
                     metadata.Attributes = doc.AttributeValues;
                     metadata.ShowDialog();
                 }
                 else
                 {
                     MessageBox.Show("Nessun documento presente con l'id cercato.");
                 }
             }
         };
         client.GetDocumentInfoAsync((Guid)radGridView2.SelectedRows[0].Cells["IdDocument"].Value, null, true, (Guid)radGridView2.SelectedRows[0].Cells["IdDocument"].Value);
     }
     catch (Exception ex)
     {
         waitForm.Close();
         MessageBox.Show(ex.ToString());
     }
 }
Ejemplo n.º 19
0
        private string CreateRDVToSignZipToDownload(ICollection <Guid> awardBatchIds)
        {
            string destination       = Path.Combine(ConfigurationHelper.GetAppDataPath(), string.Format("RDVToSign_{0:yyyyMMddHHmmss}.zip", DateTime.Now));
            string folderDestination = Path.Combine(ConfigurationHelper.GetAppDataPath(), Guid.NewGuid().ToString());

            try
            {
                Directory.CreateDirectory(folderDestination);
                using (IWritableArchive archive = ArchiveFactory.Create(ArchiveType.Zip))
                    using (DocumentsClient client = new DocumentsClient())
                    {
                        Parallel.ForEach(awardBatchIds, (idAwardBatch) =>
                        {
                            AwardBatch awardBatch = _preservationService.GetAwardBatch(idAwardBatch);
                            if (!awardBatch.IdRDVDocument.HasValue)
                            {
                                _logger.WarnFormat("CreateRDVToSignZipToDownload -> RDV document not found for award batch {0}", idAwardBatch);
                                return;
                            }

                            DocumentContent content = client.GetDocumentContentById(awardBatch.IdRDVDocument.Value);
                            System.IO.File.WriteAllBytes(Path.Combine(folderDestination, string.Concat(idAwardBatch, "_", UtilityService.GetSafeFileName(content.Description))), content.Blob);
                        });
                        archive.AddAllFromDirectory(folderDestination);
                        archive.SaveTo(destination, CompressionType.Deflate);
                    }
            }
            finally
            {
                if (Directory.Exists(folderDestination))
                {
                    Directory.Delete(folderDestination, true);
                }
            }
            return(destination);
        }
Ejemplo n.º 20
0
        void signExpireDate_Click(object sender, EventArgs e)
        {
            try
            {
                string result = null;

                //    Content content;
                //    // Metodo nuovo
                BindingList <Certificate> certificates;
                using (DocumentsClient client = new DocumentsClient("Binding_Documents"))
                {
                    certificates = client.GetDocumentSigned((Guid)radGridView2.SelectedRows[0].Cells["IdDocument"].Value);
                }
                if (certificates != null)
                {
                    result = "<signatures>";
                    foreach (var crtlo in certificates)
                    {
                        result += "<signature level=\"" + crtlo.Level + "\" type=\"" + crtlo.Type
                                  + "\" expiry=\"" + crtlo.DateExpiration
                                  + "\" fiscalcode=\"" + crtlo.FiscalCode
                                  + "\" validfrom=\"" + crtlo.DateValidFrom
                                  + "\" name=\"" + "-" + "\""
                                  + " issuer=\"" + crtlo.Issuer + "\""
                                  + " email=\"" + crtlo.Email + "\""
                                  + " role=\"" + crtlo.Role + "\"><![CDATA[" + crtlo.Description + "]]></signature>";
                    }
                    result += "</signatures>";
                }
                new UcDocumentViewer(result).Show();
            }
            catch (Exception ex)
            {
                RadMessageBox.Show(ex.Message, "Errore", MessageBoxButtons.OK, Telerik.WinControls.RadMessageIcon.Error);
            }
        }
Ejemplo n.º 21
0
        private void btnUpload_Click(object sender, EventArgs e)
        {
            try
            {
                if (!Directory.Exists(txtPath.Text))
                {
                    MessageBox.Show("Directory not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                this.radGridStatus.Rows.Clear();
                DocumentsClient client  = new DocumentsClient("Binding_Documents");
                string[]        files   = Directory.GetFiles(txtPath.Text, "*.xml");
                string          pathOut = Path.Combine(txtPath.Text, "OUT");
                if (!Directory.Exists(pathOut))
                {
                    Directory.CreateDirectory(pathOut);
                }
                string pathErr = Path.Combine(txtPath.Text, "ERR");
                if (!Directory.Exists(pathErr))
                {
                    Directory.CreateDirectory(pathErr);
                }
                foreach (var file in files)
                {
                    string[]      xmlRow = File.ReadAllLines(file);
                    StringBuilder xml    = new StringBuilder();
                    foreach (var str in xmlRow)
                    {
                        if (!str.StartsWith("<!-- "))
                        {
                            xml.AppendLine(str);
                        }
                    }
                    XElement settingsDoc = XElement.Parse(xml.ToString());
                    var      dictionary  = from element in settingsDoc.Descendants("Zone")
                                           select new
                    {
                        Name  = element.Attribute("Name").Value,
                        Value = element.Value
                    };
                    var tmpName = Path.GetFileNameWithoutExtension(settingsDoc.Attributes("DocumentFileName").FirstOrDefault().Value) + txtSuffix.Text + Path.GetExtension(settingsDoc.Attributes("DocumentFileName").FirstOrDefault().Value);
                    BindingList <AttributeValue> attributeValues = new BindingList <AttributeValue>();
                    foreach (var attribute in attributes)
                    {
                        if (dictionary.Where(x => x.Name == attribute.Name).FirstOrDefault() != null)
                        {
                            object val = null;
                            string obj = dictionary.Where(x => x.Name == attribute.Name).FirstOrDefault().Value;
                            switch (attribute.AttributeType)
                            {
                            case "System.String":
                                val = obj;
                                break;

                            case "System.Int64":
                                val = int.Parse(obj);
                                break;

                            case "System.Double":
                                val = Double.Parse(obj);
                                break;

                            case "System.DateTime":
                                val = DateTime.Parse(obj);
                                break;

                            default:
                                break;
                            }
                            attributeValues.Add(new AttributeValue {
                                Attribute = attribute, Value = val
                            });
                        }
                    }
                    ServiceReferenceDocument.Document document = new ServiceReferenceDocument.Document();
                    document.Name            = Path.GetFileName(tmpName);
                    document.Content         = new Content();
                    document.Content.Blob    = File.ReadAllBytes(Path.Combine(txtPath.Text, tmpName));
                    document.AttributeValues = attributeValues;
                    document.Archive         = CurrentArchive;
                    try
                    {
                        client.AddDocumentToChainAsync(document, null, ContentFormat.Bynary, new string[] { txtPath.Text, file, tmpName });
                        client.AddDocumentToChainCompleted += new EventHandler <AddDocumentToChainCompletedEventArgs>(client_AddDocumentToChainCompleted);
                    }
                    catch (Exception exx)
                    {
                        this.radGridStatus.Rows.Add(new string[] {
                            document.Name,
                            "EXC",
                            exx.Message
                        });
                        continue;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 22
0
 public SaveRDVXmlInteractor(ILogger logger)
 {
     _logger              = logger;
     _documentsClient     = new DocumentsClient();
     _preservationService = new PreservationService();
 }
Ejemplo n.º 23
0
        public static CreaLegameDocumentiChiaveResponse CreaLegameDocumentiChiave(CreaLegameDocumentiChiaveRequest request)
        {
            var response = new CreaLegameDocumentiChiaveResponse();

            try
            {
                logger.DebugFormat("CreaLegameDocumentiChiave request:{0}", request.ToString());
                response.TokenInfo = Helpers.ValidaToken(request);
                if (response.TokenInfo == null)
                {
                    response.CodiceEsito = CodiceErrore.TokenNonValidoOScaduto;
                }
                else
                {
                    //Verifico che la request sia corretta
                    var checkRequestResult = request.CheckRequest(response);
                    if (checkRequestResult != CodiceErrore.NessunErrore)
                    {
                        response.CodiceEsito = checkRequestResult;
                        response.Eseguito    = false;
                    }
                    else
                    {
                        CodiceErrore error;
                        var          idDocumento     = Helpers.GetDocumentByChiave(request.TipoDocumento, request.IdCliente, request.Chiave, out error);
                        Guid?        idDocumentoLink = null;
                        if (idDocumento.HasValue && error == CodiceErrore.NessunErrore)
                        {
                            idDocumentoLink = Helpers.GetDocumentByChiave(request.TipoDocumentoLink, request.IdCliente, request.ChiaveDocumentoLink, out error);
                        }
                        if (!idDocumento.HasValue || !idDocumentoLink.HasValue || error != CodiceErrore.NessunErrore)
                        {
                            response.CodiceEsito = error == CodiceErrore.NessunErrore ? CodiceErrore.DocumentoNonDefinito : error;
                            response.Eseguito    = false;
                        }
                        else
                        {
                            using (var client = new DocumentsClient())
                            {
                                try
                                {
                                    client.AddDocumentLink(idDocumento.Value, idDocumentoLink.Value);
                                    response.Eseguito = true;
                                }
                                catch (FaultException <BiblosDsException> faultEx)
                                {
                                    logger.Error(faultEx);
                                    response.Eseguito = false;
                                    ParseBiblosDSFaultException(response, faultEx);
                                }
                                catch (Exception ex)
                                {
                                    logger.Error(ex);
                                    response.Eseguito        = false;
                                    response.CodiceEsito     = CodiceErrore.ErroreChiamataAlServizioRemoto;
                                    response.MessaggioErrore = ex.StackTrace;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                response.Eseguito        = false;
                response.CodiceEsito     = CodiceErrore.ErroreGenerico;
                response.MessaggioErrore = ex.ToString();
            }
            response.CheckResponse();
            logger.DebugFormat("CreaLegameDocumentiChiave response:{0}", response.ToString());
            return(response);
        }
Ejemplo n.º 24
0
        public static InfoLegameDocumentoResponse InfoLegameDocumento(InfoLegameDocumentoRequest request)
        {
            var response = new InfoLegameDocumentoResponse();

            try
            {
                logger.DebugFormat("InfoLegameDocumento request:{0}", request.ToString());
                response.TokenInfo = Helpers.ValidaToken(request);
                if (response.TokenInfo == null)
                {
                    response.CodiceEsito = CodiceErrore.TokenNonValidoOScaduto;
                }
                else
                {
                    //Verifico che la request sia corretta
                    var checkRequestResult = request.CheckRequest(response);
                    if (checkRequestResult != CodiceErrore.NessunErrore)
                    {
                        response.CodiceEsito = checkRequestResult;
                        response.Eseguito    = false;
                    }
                    else
                    {
                        if (request.IdDocumento == Guid.Empty)
                        {
                            response.CodiceEsito = CodiceErrore.IdDocumentoNonValido;
                            response.Eseguito    = false;
                        }
                        else
                        {
                            using (var client = new DocumentsClient())
                            {
                                try
                                {
                                    var links = client.GetDocumentLinks(request.IdDocumento);
                                    response.Documenti = links.Select(x => new DocumentoItem {
                                        IdDocumento = x.IdDocument, Nome = x.Name, Chiavi = GetMetadati(x), Stato = Operazione.Default
                                    }).ToList();
                                    response.Eseguito = true;
                                }
                                catch (FaultException <BiblosDsException> faultEx)
                                {
                                    logger.Error(faultEx);
                                    response.Eseguito = false;
                                    ParseBiblosDSFaultException(response, faultEx);
                                }
                                catch (Exception ex)
                                {
                                    logger.Error(ex);
                                    response.Eseguito        = false;
                                    response.CodiceEsito     = CodiceErrore.ErroreChiamataAlServizioRemoto;
                                    response.MessaggioErrore = ex.StackTrace;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                response.Eseguito        = false;
                response.CodiceEsito     = CodiceErrore.ErroreGenerico;
                response.MessaggioErrore = ex.ToString();
            }
            response.CheckResponse();
            logger.DebugFormat("InfoLegameDocumento response:{0}", response.ToString());
            return(response);
        }
Ejemplo n.º 25
0
        public static InfoLegameDocumentoChiaveResponse InfoLegameDocumentoChiave(InfoLegameDocumentoChiaveRequest request)
        {
            InfoLegameDocumentoChiaveResponse response = new InfoLegameDocumentoChiaveResponse();

            //Recupero il Documento
            try
            {
                logger.DebugFormat("InfoLegameDocumentoChiave request:{0}", request.ToString());
                CodiceErrore error;
                var          idDocumento = Helpers.GetDocumentByChiave(request, request.Chiave, out error);

                if (!idDocumento.HasValue)
                {
                    response.CodiceEsito = CodiceErrore.DocumentoNonDefinito;
                    response.Eseguito    = false;
                }
                else if (error != CodiceErrore.NessunErrore)
                {
                    response.CodiceEsito = error;
                    response.Eseguito    = false;
                }
                else
                {
                    using (var client = new DocumentsClient())
                    {
                        try
                        {
                            var links = client.GetDocumentLinks(idDocumento.Value);
                            response.Documenti = links.Select(x => new DocumentoItem {
                                IdDocumento = x.IdDocument, Nome = x.Name, Chiavi = GetMetadati(x), Stato = Operazione.Default
                            }).ToList();
                            response.Eseguito = true;
                        }
                        catch (FaultException <BiblosDsException> faultEx)
                        {
                            logger.Error(faultEx);
                            response.Eseguito = false;
                            ParseBiblosDSFaultException(response, faultEx);
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex);
                            response.Eseguito        = false;
                            response.CodiceEsito     = CodiceErrore.ErroreChiamataAlServizioRemoto;
                            response.MessaggioErrore = ex.StackTrace;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                response.Eseguito        = false;
                response.CodiceEsito     = CodiceErrore.ErroreGenerico;
                response.MessaggioErrore = ex.ToString();
            }

            response.CheckResponse();
            logger.DebugFormat("InfoLegameDocumentoChiave response:{0}", response.ToString());
            return(response);
        }
Ejemplo n.º 26
0
        public static CancellaLegameDocumentiResponse CancellaLegameDocumenti(CancellaLegameDocumentiRequest request)
        {
            var response = new CancellaLegameDocumentiResponse();

            try
            {
                logger.DebugFormat("CancellaLegameDocumenti request:{0}", request.ToString());
                response.TokenInfo = Helpers.ValidaToken(request);
                if (response.TokenInfo == null)
                {
                    response.CodiceEsito = CodiceErrore.TokenNonValidoOScaduto;
                }
                else
                {
                    //Verifico che la request sia corretta
                    var checkRequestResult = request.CheckRequest(response);
                    if (checkRequestResult != CodiceErrore.NessunErrore)
                    {
                        response.CodiceEsito = checkRequestResult;
                        response.Eseguito    = false;
                    }
                    else
                    {
                        if (request.IdDocumento == Guid.Empty || request.IdDocumentoLink == Guid.Empty)
                        {
                            response.CodiceEsito = CodiceErrore.IdDocumentoNonValido;
                            response.Eseguito    = false;
                        }
                        else
                        {
                            using (var client = new DocumentsClient())
                            {
                                try
                                {
                                    response.Eseguito = client.DeleteDocumentLink(request.IdDocumento, request.IdDocumentoLink);
                                }
                                catch (FaultException <BiblosDsException> faultEx)
                                {
                                    logger.Error(faultEx);
                                    response.Eseguito = false;
                                    ParseBiblosDSFaultException(response, faultEx);
                                }
                                catch (Exception ex)
                                {
                                    logger.Error(ex);
                                    response.Eseguito        = false;
                                    response.CodiceEsito     = CodiceErrore.ErroreChiamataAlServizioRemoto;
                                    response.MessaggioErrore = ex.StackTrace;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                response.Eseguito        = false;
                response.CodiceEsito     = CodiceErrore.ErroreGenerico;
                response.MessaggioErrore = ex.ToString();
            }
            response.CheckResponse();
            logger.DebugFormat("CancellaLegameDocumenti response:{0}", response.ToString());
            return(response);
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Metodo per cancellare un allegato del documento dato il suo ID.
        /// </summary>
        /// <remarks>
        /// E' possibile cancellare un allegato UNICAMENTE usando il suo apposito identificativo (membro "IdAllegato" della request): non
        /// lo si può infatti eliminare sfruttando la chiave del documento cui appartiene.
        /// </remarks>
        /// <param name="request">
        /// I parametri obbligatori perchè la richiesta risulti corretta sono:
        ///     - IdClient
        ///     - IdCliente
        ///     - TipoDocumento
        ///     - Token
        ///     - IdAllegato
        /// </param>
        /// <returns></returns>
        /// <example>
        /// var request = new CancellaAllegatoDocumentoRequest
        ///    {
        ///        IdClient = "Terasoftware",
        ///        IdCliente = "TeraSoftware",
        ///        TipoDocumento = "DDT_ATH_TEST2",
        ///        Token = Token = DocumentoFacade.Login(new LoginRequest { UserName = "******", Password = "******", IdCliente = "TeraSoftware" }).TokenInfo.Token,
        ///        IdDocumento = new Guid("e3afd62f-0a23-4257-9e09-3c19ea8c497c")
        ///        IdAllegato = new Guid("057136A3-7B5E-4658-A144-774F86021D38"),
        ///    };
        ///
        /// try {
        ///     var response = CancellaAllegatoDocumento(request);
        ///     if(!response.Eseguito || response.CodiceEsito != CodiceErrore.NessunErrore)
        ///         throw new Exception("Cancellazione allegato non eseguita. Identificativo allegato: " + request.IdAllegato);
        /// } catch(Exception exx) {
        ///     //Qualcosa è andato storto.
        ///     //TODO: Eventuale gestione eccezioni (per esempio loggare il messaggio d'errore).
        ///     throw; //Rilancia l'eccezione.
        /// }
        /// </example>
        public static CancellaAllegatoDocumentoResponse CancellaAllegatoDocumento(CancellaAllegatoDocumentoRequest request)
        {
            var response = new CancellaAllegatoDocumentoResponse();

            try
            {
                logger.DebugFormat("CancellaAllegatoDocumento request:{0}", request.ToString());
                response.TokenInfo = Helpers.ValidaToken(request);
                if (response.TokenInfo == null)
                {
                    response.CodiceEsito = CodiceErrore.TokenNonValidoOScaduto;
                }
                else
                {
                    //Verifico che la request sia corretta
                    var checkRequestResult = request.CheckRequest(response);
                    if (checkRequestResult != CodiceErrore.NessunErrore)
                    {
                        response.CodiceEsito = checkRequestResult;
                        response.Eseguito    = false;
                    }
                    else
                    {
                        if (request.IdAllegato == Guid.Empty)
                        {
                            response.CodiceEsito = CodiceErrore.IdDocumentoNonValido;
                            response.Eseguito    = false;
                        }
                        else
                        {
                            //TODO Verifica che l'id documento appartenga al cliente.
                            //se non appartiene errore:
                            //1027	Il documento identificato dal parametro IdDocumento non corrisponde alla chiave fornita
                            using (var client = new DocumentsClient())
                            {
                                try
                                {
                                    var allegati = client.GetDocumentAttachs(request.IdDocumento);
                                    if (allegati.Any(x => x.IdDocumentAttach == request.IdAllegato))
                                    {
                                        client.SetVisibleDocumentAttach(request.IdAllegato, false);
                                        response.Eseguito = true;
                                    }
                                    else
                                    {
                                        response.CodiceEsito = CodiceErrore.IdAllegatoNonValido;
                                        response.Eseguito    = false;
                                    }
                                }
                                catch (FaultException <BiblosDsException> faultEx)
                                {
                                    logger.Error(faultEx);
                                    response.Eseguito = false;
                                    ParseBiblosDSFaultException(response, faultEx);
                                }
                                catch (Exception ex)
                                {
                                    logger.Error(ex);
                                    response.Eseguito        = false;
                                    response.CodiceEsito     = CodiceErrore.ErroreChiamataAlServizioRemoto;
                                    response.MessaggioErrore = ex.StackTrace;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                response.Eseguito        = false;
                response.CodiceEsito     = CodiceErrore.ErroreGenerico;
                response.MessaggioErrore = ex.ToString();
            }
            logger.DebugFormat("CancellaAllegatoDocumento response:{0}", response.ToString());
            response.CheckResponse();
            return(response);
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Contenuto (byte array) dell'allegato a partire dall'idattch
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static ImmagineAllegatoDocumentoResponse ImmagineAllegatoDocumento(ImmagineAllegatoDocumentoRequest request)
        {
            var response = new ImmagineAllegatoDocumentoResponse();

            try
            {
                logger.DebugFormat("ImmagineAllegatoDocumento request:{0}", request.ToString());
                response.TokenInfo = Helpers.ValidaToken(request);
                if (response.TokenInfo == null)
                {
                    response.CodiceEsito = CodiceErrore.TokenNonValidoOScaduto;
                }
                else
                {
                    //Verifico che la request sia corretta
                    var checkRequestResult = request.CheckRequest(response);
                    if (checkRequestResult != CodiceErrore.NessunErrore)
                    {
                        response.CodiceEsito = checkRequestResult;
                        response.Eseguito    = false;
                    }
                    else
                    {
                        if (request.IdAllegato == Guid.Empty)
                        {
                            response.CodiceEsito = CodiceErrore.IdDocumentoNonValido;
                            response.Eseguito    = false;
                        }
                        else
                        {
                            //TODO Verifica che l'id documento appartenga al cliente.
                            //se non appartiene errore:
                            //1027	Il documento identificato dal parametro IdDocumento non corrisponde alla chiave fornita
                            using (var client = new DocumentsClient())
                            {
                                try
                                {
                                    var res = client.GetDocumentAttachContent(request.IdAllegato);
                                    response.File = new FileItem {
                                        Blob = res.Blob, Nome = res.Description
                                    };
                                    response.Eseguito = true;
                                    response.Allegato = new AllegatoItem {
                                        IdAllegato = request.IdAllegato, Nome = res.Description, Stato = Operazione.Default
                                    };
                                }
                                catch (FaultException <BiblosDsException> faultEx)
                                {
                                    logger.Error(faultEx);
                                    response.Eseguito = false;
                                    ParseBiblosDSFaultException(response, faultEx);
                                }
                                catch (Exception ex)
                                {
                                    logger.Error(ex);
                                    response.Eseguito        = false;
                                    response.CodiceEsito     = CodiceErrore.ErroreChiamataAlServizioRemoto;
                                    response.MessaggioErrore = ex.StackTrace;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                response.Eseguito        = false;
                response.CodiceEsito     = CodiceErrore.ErroreGenerico;
                response.MessaggioErrore = ex.ToString();
            }
            logger.DebugFormat("ImmagineAllegatoDocumento response:{0}", response.ToString());
            response.CheckResponse();
            return(response);
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Metodo che torna gli archivi associati ad un cliente con i relativi metadati
        /// </summary>
        /// <param name="request"><see cref="GetArchiviRequest">GetProfiliRequest</see></param>
        /// <example>
        /// GetProfiliRequest request = new GetProfiliRequest {  Token = token.TokenInfo.Token, IdCliente = token.TokenInfo.IdCliente };
        /// GetProfiliResponse actual = DocumentoFacade.GetProfili(request);
        /// </example>
        /// <remarks>
        /// Il Token è recuperato della chiamata al metodo Login
        /// </remarks>
        /// <returns>
        /// Risposta <see cref="GetArchiviResponse">GetProfiliResponse</see> con i profili configurati per il cliente
        /// </returns>
        public static GetArchiviResponse GetProfili(GetArchiviRequest request)
        {
            GetArchiviResponse response = new GetArchiviResponse();

            try
            {
                logger.DebugFormat("GetProfili request:{0}", request.ToString());
                response.TokenInfo = Helpers.ValidaToken(request);
                if (response.TokenInfo == null)
                {
                    response.CodiceEsito = CodiceErrore.TokenNonValidoOScaduto;
                }
                else
                {
                    using (var db = new BiblosDS2010APIEntities())
                    {
                        var archiviAbillitati = db.CustomerKeys.Where(x => x.IdCustomer == response.TokenInfo.IdCliente);
                        using (var client = new DocumentsClient())
                        {
                            foreach (var item in archiviAbillitati)
                            {
                                try
                                {
                                    var             metadata     = client.GetMetadataStructure(item.IdArchive);
                                    DocumentArchive archive      = null;
                                    string          nomeArchivio = string.Empty;
                                    if (metadata.Count() > 0)
                                    {
                                        archive      = metadata.First().Archive;
                                        nomeArchivio = archive == null ? "ND" : archive.Name;
                                    }
                                    response.Archivi.Add(new Archivio {
                                        Descrizione = item.Description, TipoDocumento = item.DocumentClass, Nome = nomeArchivio, Metadati = metadata.Select(x => new MetadatoItem {
                                            Name = x.Name, Tipo = x.AttributeType, Posizione = x.ConservationPosition.GetValueOrDefault(), Obbligatorio = x.IsRequired
                                        }).ToList()
                                    });
                                    response.Eseguito = true;
                                    logger.DebugFormat("GetProfili response:{0}", response.ToString());
                                }
                                catch (FaultException <BiblosDsException> faultEx)
                                {
                                    logger.Error(faultEx);
                                    response.Eseguito = false;
                                    ParseBiblosDSFaultException(response, faultEx);
                                }
                                catch (Exception ex)
                                {
                                    logger.Error(ex);
                                    response.CodiceEsito     = CodiceErrore.ErroreChiamataAlServizioRemoto;
                                    response.MessaggioErrore = ex.ToString();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                response.CodiceEsito     = CodiceErrore.ErroreGenerico;
                response.MessaggioErrore = ex.ToString();
            }
            response.CheckResponse();
            return(response);
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Richiede il file che rappresenta il documento a partire dalla chiave che identifica quest'ultimo.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static ImmagineDocumentoChiaveResponse ImmagineDocumentoChiave(ImmagineDocumentoChiaveRequest request)
        {
            var response = new ImmagineDocumentoChiaveResponse();

            try
            {
                logger.DebugFormat("GetImmagineDocumentoChiavi request:{0}", request.ToString());
                response.TokenInfo = Helpers.ValidaToken(request);
                if (response.TokenInfo == null)
                {
                    response.CodiceEsito = CodiceErrore.TokenNonValidoOScaduto;
                }
                else
                {
                    //Verifico che la request sia corretta
                    var checkRequestResult = request.CheckRequest(response);
                    if (checkRequestResult != CodiceErrore.NessunErrore)
                    {
                        response.CodiceEsito = checkRequestResult;
                        response.Eseguito    = false;
                    }
                    else
                    {
                        //Recupero il Documento
                        CodiceErrore error;
                        var          idDocumento = Helpers.GetDocumentByChiave(request, request.Chiave, out error);
                        if (!idDocumento.HasValue)
                        {
                            response.CodiceEsito = CodiceErrore.DocumentoNonDefinito;
                            response.Eseguito    = false;
                        }
                        else if (error != CodiceErrore.NessunErrore)
                        {
                            response.CodiceEsito = error;
                            response.Eseguito    = false;
                        }
                        else
                        {
                            using (var client = new DocumentsClient())
                            {
                                try
                                {
                                    var res = client.GetDocumentContentById(idDocumento.Value);
                                    response.File = new FileItem {
                                        Blob = res.Blob, Nome = res.Description
                                    };
                                    response.Eseguito  = true;
                                    response.Documento = new DocumentoItem {
                                        IdDocumento = idDocumento.Value, Nome = res.Description, Stato = Operazione.Default
                                    };
                                }
                                catch (FaultException <BiblosDsException> faultEx)
                                {
                                    logger.Error(faultEx);
                                    response.Eseguito = false;
                                    ParseBiblosDSFaultException(response, faultEx);
                                }
                                catch (Exception ex)
                                {
                                    logger.Error(ex);
                                    response.Eseguito        = false;
                                    response.CodiceEsito     = CodiceErrore.ErroreChiamataAlServizioRemoto;
                                    response.MessaggioErrore = ex.StackTrace;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                response.Eseguito        = false;
                response.CodiceEsito     = CodiceErrore.ErroreGenerico;
                response.MessaggioErrore = ex.ToString();
            }
            logger.DebugFormat("GetImmagineDocumentoChiavi response:{0}", response.ToString());
            response.CheckResponse();
            return(response);
        }