Beispiel #1
0
        private long LoginRSA()
        {
            long lLoginError;

            try
            {
                // creo la struttura dei parametri
                m_UserSession = new Archiva.ArchivaASP_LOGIN();
                m_UserSession.SessionId = 0;
                m_UserSession.Application = txtApplication.Text;
                m_UserSession.User = txtUser.Text;
                m_UserSession.Password = txtPassWord.Text;

                // creo una index list vuota
                ArchivaASP_INDEXLIST IndexList = new ArchivaASP_INDEXLIST();

                // Crypto service
                ArchivaASP_CRY Crypto = new ArchivaASP_CRY();

                // cripto la descrizione XML dei parametri
                byte[] abXmlUserSession = Crypto.EncryptXML(m_UserSession, m_UserSession.GetType(), m_RSA_Server);
                // cripto la chiave del client XML dei parametri
                byte[] abXmlUserKey = Crypto.EncryptXML(m_UserKey, m_UserKey.GetType(), m_RSA_Server);

                byte[] abXmlIndexList = null;

                // effettuo il login
                this.Cursor = Cursors.WaitCursor;
                lLoginError = m_ArchivaASP.Login(ref abXmlUserSession, abXmlUserKey, out abXmlIndexList);
                this.Cursor = Cursors.Default;

                // decripto le info di login
                if (lLoginError == 0)
                {
                    m_UserSession = (ArchivaASP_LOGIN)Crypto.DecryptXML(abXmlUserSession, typeof(ArchivaASP_LOGIN), m_RSA_Client);
                    IndexList = (ArchivaASP_INDEXLIST)Crypto.DecryptXML(abXmlIndexList, typeof(ArchivaASP_INDEXLIST), m_RSA_Client);

                    txtSessionId.Text = m_UserSession.SessionId.ToString();

                    lstIndex.Items.Clear();
                    for (int l = 0; l < IndexList.Indexes.Count; l++)
                        lstIndex.Items.Add((String)IndexList.Indexes[l]);
                }

                return lLoginError;
            }
            catch (Exception E)
            {
                MessageBox.Show(E.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return -1;
            }
        }
Beispiel #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            _service = new biz.archiva.servizi.ArchivaASP {Timeout = 60*60*1000};

            long mRsaKeyLength = 0;

            //=========================================================================
            // OGGETTI PER CRITTOGRAFIA
            //=========================================================================
            // ottengo la chiave pubblica del server
            var sKey = "";
            if (_service.GetKey(ref sKey, ref mRsaKeyLength) != 0)
                return;

            // creo il servizio RSA per il server
            _mRsaServer = new RSACryptoServiceProvider((int)mRsaKeyLength);
            var serverKey = (ArchivaASP_KEY)ArchivaASP_SERIALIZER.DeserializeObject(sKey, typeof(ArchivaASP_KEY));
            var serverParameters = new RSAParameters {Exponent = serverKey.Exp, Modulus = serverKey.Mod};
            _mRsaServer.ImportParameters(serverParameters);

            //=========================================================================
            // LOGIN
            //=========================================================================

            // creo il servizio RSA per il client
            _mRsaClient = new RSACryptoServiceProvider((int)mRsaKeyLength);
            var rsaParam = _mRsaClient.ExportParameters(false);
            _mUserKey = new ArchivaASP_KEY {Mod = rsaParam.Modulus, Exp = rsaParam.Exponent};

            // creo la struttura dei parametri
            _mUserSession = new ArchivaASP_LOGIN { SessionId = 0, Application = "STUDIOZENITHWEB", User = "******", Password = "******" };

            // creo una index list vuota
            var indexList = new ArchivaASP_INDEXLIST();

            // Crypto service
            var crypto = new ArchivaASP_CRY();

            // cripto la descrizione XML dei parametri
            byte[] abXmlUserSession = crypto.EncryptXML(_mUserSession, _mUserSession.GetType(), _mRsaServer);
            // cripto la chiave del client XML dei parametri
            byte[] abXmlUserKey = crypto.EncryptXML(_mUserKey, _mUserKey.GetType(), _mRsaServer);

            byte[] abXmlIndexList;

            // effettuo il login
            long lLoginError = _service.Login(ref abXmlUserSession, abXmlUserKey, out abXmlIndexList);

            // decripto le info di login
            if (lLoginError == 0)
            {
                _mUserSession = (ArchivaASP_LOGIN)crypto.DecryptXML(abXmlUserSession, typeof(ArchivaASP_LOGIN), _mRsaClient);
                indexList = (ArchivaASP_INDEXLIST)crypto.DecryptXML(abXmlIndexList, typeof(ArchivaASP_INDEXLIST), _mRsaClient);
            }

            //=========================================================================
            // ESECUZIONE DELLA RICERCA - I PARAMETRI DEVONO SELEZIONARE UN SOLO DOCUMENTO
            //=========================================================================

            // cripto la descrizione XML dei parametri
            abXmlUserSession = crypto.EncryptXML(_mUserSession, typeof(ArchivaASP_LOGIN), _mRsaServer);
            // cripto la index list XML dei parametri
            indexList.Indexes.Clear();
            indexList.Indexes.Add("CONTRATTI");
            abXmlIndexList = crypto.EncryptXML(indexList, typeof(ArchivaASP_INDEXLIST), _mRsaServer);

            // campi da visualizzare
            var fieldList = new ArchivaASP_FIELDLIST();
            fieldList.Fields.Add("IDENTIFICATIVO UNIVOCO");

            // TODO: Impostare qui i parametri di ricerca
            string parameters = "=(IDENTIFICATIVO UNIVOCO, #ZETH0000200005#)";

            // cripto la condizione XML dei parametri
            byte[] abXmlFieldCondition = crypto.EncryptXML(parameters, typeof(String), _mRsaServer);
            // cripto la lista dei campi fornibili XML dei parametri
            byte[] abXmlFieldName = crypto.EncryptXML(fieldList, typeof(ArchivaASP_FIELDLIST), _mRsaServer);

            byte[] abXmlResultNum;

            var lSearchError = _service.SearchDocument(abXmlUserSession, abXmlIndexList, abXmlFieldCondition, abXmlFieldName, out abXmlResultNum);

            //=========================================================================
            // LETTURA DEL CODICE DOCUMENTO CHE DEVE ESSERE APERTO
            //=========================================================================
            
            // numero di documenti per pagina
            const int nPageSize = 10;
            // numero di pagina
            const int nPageNum = 0;


            // campi risultanti
            var FieldResult = new ArchivaASP_FIELDVALUE();

            // cripto la descrizione XML dei parametri
            abXmlUserSession = crypto.EncryptXML(_mUserSession, typeof(ArchivaASP_LOGIN), _mRsaServer);
            // cripto la index list XML dei parametri
            byte[] abXmlPageNum = crypto.EncryptXML(nPageNum, typeof(Int32), _mRsaServer);
            // cripto la condizione XML dei parametri
            byte[] abXmlPageSize = crypto.EncryptXML(nPageSize, typeof(Int32), _mRsaServer);

            byte[] abXmlFieldResult;

            lSearchError = _service.GetSearchDocument(abXmlUserSession, abXmlPageNum, abXmlPageSize, out abXmlFieldResult);
            
            string sError = ""; 
            if (lSearchError != 0)
            {
                _service.GetErrorDescription(lSearchError, ref sError);
                string errore = sError;
            }

            // decripto le info 
            FieldResult = (ArchivaASP_FIELDVALUE)crypto.DecryptXML(abXmlFieldResult, typeof(ArchivaASP_FIELDVALUE), _mRsaClient);

            var codDoc = (string)((ArchivaASP_FIELDLIST)FieldResult.FieldValues[0]).Fields[0];

            //=========================================================================
            // LETTURA DOCUMENTO
            //=========================================================================

            byte[] abDocumentBuffer;

            // creo una index list con la lista selezionata
            indexList.Indexes.Clear();
            indexList.Indexes.Add("CONTRATTI");

            // cripto la descrizione XML dei parametri
            abXmlUserSession = crypto.EncryptXML(_mUserSession, typeof(ArchivaASP_LOGIN), _mRsaServer);
            // cripto il codice del documento in XML
            var abXmlDocumentCode = crypto.EncryptXML(codDoc, typeof(String), _mRsaServer);
            // cripto la index list XML dei parametri
            abXmlIndexList = crypto.EncryptXML(indexList, typeof(ArchivaASP_INDEXLIST), _mRsaServer);

            lSearchError = _service.GetDocument(abXmlUserSession, abXmlDocumentCode, out abDocumentBuffer);

            if (!_service.DocumentAccessibility(abXmlUserSession, abXmlDocumentCode))
                return;

            if (lSearchError != 0)
            {
                sError = "";
                _service.GetErrorDescription(lSearchError, ref sError);

                return;
            }
            // decripto le info 
            abDocumentBuffer = (byte[])crypto.DecryptXML(abDocumentBuffer, abDocumentBuffer.GetType(), _mRsaClient);

            Response.Clear();
            Response.ContentType = "application/pdf";
            Response.BinaryWrite(abDocumentBuffer);
            Response.End();
        }
Beispiel #3
0
        public DocumentInfo GetDocument(string id, int idAzienda, TipoDocumentoArchiviazione tipoDocumento)
        {
            try
            {
                if (!string.IsNullOrEmpty(id))
                {
                    string anno = string.Empty;
                    if (id.Contains(" - "))
                        anno = id.Split('-')[2].Trim();
                    else if(id.Length >= 13)
                        anno = id.Substring(10, 4);
                    
                    id = id.Replace(" - ", "");

                    // ========================================================================================
                    // Recupero anno di riferimento --> ANNO SPEDIZIONE
                    // ========================================================================================
                    if (tipoDocumento == TipoDocumentoArchiviazione.FatturaPassiva)
                    {
                        var spesa = _spesaService.GetByIdentificativo(idAzienda, id);
                        if (spesa != null)
                            anno = spesa.AnnoArchiviazioneOttica.GetValueOrDefault().ToString();
                        else
                        {
                            var testataMovimento = _movimentiContabiliService.GetByIdentificativo(idAzienda, id);
                            if (testataMovimento != null)
                                anno = testataMovimento.AnnoArchiviazioneOttica.GetValueOrDefault().ToString();
                        }
                    }

                    var document = _documentService.GetDocument(id, idAzienda, tipoDocumento);
                    if (document.Body == null)
                    {
                        var impostazioni = _daoFactory.GetImpostazioniAziendaDao().GetByAzienda(idAzienda);
                        if (impostazioni != null &&
                            !string.IsNullOrEmpty(impostazioni.NomeApplicazioneArchiviazioneOttica) &&
                            !string.IsNullOrEmpty(impostazioni.UtenteArchiviazioneOttica) &&
                            !string.IsNullOrEmpty(impostazioni.PasswordArchiviazioneOttica) &&
                            !string.IsNullOrEmpty(impostazioni.IndiceContrattiArchiviazioneOttica))
                        {
                            _service = new ArchivaASP.ArchivaASP {Timeout = 60*60*10000};

                            long mRsaKeyLength = 0;

                            //=========================================================================
                            // OGGETTI PER CRITTOGRAFIA
                            //=========================================================================
                            // ----------------------------------------------------
                            //  Richiesta della chiave pubblica al server
                            // ----------------------------------------------------
                            var sKey = "";
                            if (_service.GetKey(ref sKey, ref mRsaKeyLength) != 0)
                            {
                                _log.ErrorFormat("Errore dal web service archiva - CHIAVE PUBBLICA DAL SERVER - {0} - application:{1} - user:{2} - password:{3} - id:{4}", Library.Utility.GetMethodDescription(), impostazioni.NomeApplicazioneArchiviazioneOttica, impostazioni.UtenteArchiviazioneOttica, impostazioni.PasswordArchiviazioneOttica, id);
                                return new DocumentInfo(new byte[0], id, null, null);
                            }

                            // creo il servizio RSA per il server
                            _mRsaServer = new RSACryptoServiceProvider((int) mRsaKeyLength);
                            var serverKey = (ArchivaASP_KEY) ArchivaASP_SERIALIZER.DeserializeObject(sKey, typeof (ArchivaASP_KEY));
                            var serverParameters = new RSAParameters {Exponent = serverKey.Exp, Modulus = serverKey.Mod};
                            _mRsaServer.ImportParameters(serverParameters);

                            //=========================================================================
                            // LOGIN
                            //=========================================================================

                            // creo il servizio RSA per il client
                            _mRsaClient = new RSACryptoServiceProvider((int) mRsaKeyLength);
                            var rsaParam = _mRsaClient.ExportParameters(false);
                            _mUserKey = new ArchivaASP_KEY {Mod = rsaParam.Modulus, Exp = rsaParam.Exponent};

                            // creo la struttura dei parametri
                            _mUserSession = new ArchivaASP_LOGIN
                            {
                                SessionId = 0,
                                Application = impostazioni.NomeApplicazioneArchiviazioneOttica,
                                User = impostazioni.UtenteArchiviazioneOttica,
                                Password = impostazioni.PasswordArchiviazioneOttica
                            };

                            // creo una index list vuota
                            var indexList = new ArchivaASP_INDEXLIST();

                            // Crypto service
                            var crypto = new ArchivaASP_CRY();

                            // cripto la descrizione XML dei parametri
                            var abXmlUserSession = crypto.EncryptXML(_mUserSession, _mUserSession.GetType(), _mRsaServer);
                            // cripto la chiave del client XML dei parametri
                            var abXmlUserKey = crypto.EncryptXML(_mUserKey, _mUserKey.GetType(), _mRsaServer);

                            byte[] abXmlIndexList;

                            // effettuo il login
                            var lLoginError = _service.Login(ref abXmlUserSession, abXmlUserKey, out abXmlIndexList);

                            // decripto le info di login
                            if (lLoginError == 0)
                            {
                                _mUserSession = (ArchivaASP_LOGIN)crypto.DecryptXML(abXmlUserSession, typeof(ArchivaASP_LOGIN), _mRsaClient);
                                indexList = (ArchivaASP_INDEXLIST)crypto.DecryptXML(abXmlIndexList, typeof(ArchivaASP_INDEXLIST), _mRsaClient);
                            }
                            else
                            {
                                _log.ErrorFormat("Errore dal web service archiva - LOGIN ERROR - {0} - application:{1} - user:{2} - password:{3} - id:{4}", Library.Utility.GetMethodDescription(), impostazioni.NomeApplicazioneArchiviazioneOttica, impostazioni.UtenteArchiviazioneOttica, impostazioni.PasswordArchiviazioneOttica, id);
                            }

                            //=========================================================================
                            // ESECUZIONE DELLA RICERCA - I PARAMETRI DEVONO SELEZIONARE UN SOLO DOCUMENTO
                            //=========================================================================

                            // ---------------------------------------------------
                            //  Parametri di Login - abXmlUserSession
                            // ---------------------------------------------------
                            // cripto la descrizione XML dei parametri
                            abXmlUserSession = crypto.EncryptXML(_mUserSession, typeof (ArchivaASP_LOGIN), _mRsaServer);

                            // ---------------------------------------------------
                            //  Lista degli indice selezionati - abXmlIndexList
                            // ---------------------------------------------------
                            // cripto la index list XML dei parametri
                            indexList.Indexes.Clear();
                            if (tipoDocumento == TipoDocumentoArchiviazione.Contratto)
                                indexList.Indexes.Add(impostazioni.IndiceContrattiArchiviazioneOttica);
                            else
                                // TODO: Calcolare l'anno corretto
                                indexList.Indexes.Add(impostazioni.IndiceFattureArchiviazioneOttica + " " + anno);
                            abXmlIndexList = crypto.EncryptXML(indexList, typeof (ArchivaASP_INDEXLIST), _mRsaServer);

                            // ---------------------------------------------------
                            //  Lista dei campi selezionati - abXmlFieldName
                            // ---------------------------------------------------
                            // campi da visualizzare
                            var fieldList = new ArchivaASP_FIELDLIST();
                            fieldList.Fields.Add("IDENTIFICATIVO UNIVOCO");

                            // cripto la lista dei campi fornibili XML dei parametri
                            var abXmlFieldName = crypto.EncryptXML(fieldList, typeof(ArchivaASP_FIELDLIST), _mRsaServer);

                            // ---------------------------------------------------
                            //  Condizioni di ricerca - abXmlFieldCondition
                            // ---------------------------------------------------
                            // TODO: Impostare qui i parametri di ricerca
                            var parameters = "=(IDENTIFICATIVO UNIVOCO, $" + id + "$)";

                            // cripto la condizione XML dei parametri
                            var abXmlFieldCondition = crypto.EncryptXML(parameters, typeof (String), _mRsaServer);

                            // ----------------------------------------------------------------
                            //  Esecuzione della ricerca ritorna direttamente il documento PDF
                            // ----------------------------------------------------------------
                            byte[] abDocumentBuffer;
                            var lSearchError = _service.SearchDocumentWithUniqueData(abXmlUserSession, abXmlIndexList, abXmlFieldCondition, abXmlFieldName, out abDocumentBuffer);
                            if (lSearchError != 0)
                            {
                                var sError = "";
                                _service.GetErrorDescription(lSearchError, ref sError);
                                
                                _log.ErrorFormat("Errore dal web service archiva - LETTURA DOCUMENTO - {0} - codice:{1} - descrizione:{2} - id:{3}", Library.Utility.GetMethodDescription(), lSearchError, sError, id);

                                _service.Logout(ref abXmlUserSession);

                                return new DocumentInfo(new byte[0], id, sError, null);
                            }

                            document = new DocumentInfo(abDocumentBuffer, id, "Archiva", ".pdf");
                            _documentService.SaveDocument(document.Body, id + ".pdf", ".pdf", id, idAzienda);

                            // Logout dal servizio
                            _service.Logout(ref abXmlUserSession);
                        }
                    }
                    else
                        document.FileName = "Archiva";

                    return document;
                }
                return new DocumentInfo(new byte[0], id, null, null);
            }
            catch(OutOfMemoryException ex)
            {
                _log.ErrorFormat("Errore inaspettato nel metodo - OUT OF MEMORY - {0} - id:{1}", ex, Library.Utility.GetMethodDescription(), id);
                return new DocumentInfo(new byte[0], id, "Il documento in questo momento non è disponibile di prega di riprovare più tardi", null);
            }
            catch (Exception ex)
            {
                _log.ErrorFormat("Errore inaspettato nel metodo - {0} - id:{1}", ex, Library.Utility.GetMethodDescription(), id);
                throw;
            }
        }
Beispiel #4
0
        private void lstResult_DoubleClick(object sender, EventArgs e)
        {
            if (lstResult.Items.Count == 0)
                return;

            try
            {
                long lSearchError = 0;

                // codice del documento
                String sDocumentCode = lstResult.SelectedItems[0].Text;
                // documento pdf
                byte[] abDocumentBuffer = null;

                // creo una index list con la lista selezionata
                ArchivaASP_INDEXLIST IndexList = new ArchivaASP_INDEXLIST();
                IndexList.Indexes.Add(lstIndex.SelectedItems[0].Text);

                // creo il crypto service
                ArchivaASP_CRY Crypto = new ArchivaASP_CRY();

                // cripto la descrizione XML dei parametri
                byte[] abXmlUserSession = Crypto.EncryptXML(m_UserSession, typeof(ArchivaASP_LOGIN), m_RSA_Server);
                // cripto il codice del documento in XML
                byte[] abXmlDocumentCode = Crypto.EncryptXML(sDocumentCode, typeof(String), m_RSA_Server);
                // cripto la index list XML dei parametri
                byte[] abXmlIndexList = Crypto.EncryptXML(IndexList, typeof(ArchivaASP_INDEXLIST), m_RSA_Server);

                this.Cursor = Cursors.WaitCursor;

                lSearchError = m_ArchivaASP.GetDocument(abXmlUserSession, abXmlDocumentCode, out abDocumentBuffer);

                //if (!m_ArchivaASP.DocumentAccessibility(abXmlUserSession, abXmlDocumentCode))
                //    return;

                this.Cursor = Cursors.Default;

                if (lSearchError != 0)
                {
                    string sError = "";
                    m_ArchivaASP.GetErrorDescription(lSearchError, ref sError);

                    MessageBox.Show(sError, "GetDocument Fault", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    // decripto le info 
                    this.Cursor = Cursors.WaitCursor;
                    abDocumentBuffer = (byte[])Crypto.DecryptXML(abDocumentBuffer, abDocumentBuffer.GetType(), m_RSA_Client);
                    this.Cursor = Cursors.Default;

                    // salvo il file
                    SaveFileDialog SaveDialog = new SaveFileDialog();
                    SaveDialog.Title = "Save Document";
                    SaveDialog.Filter = "PDF files (*.PDF)|*.PDF|All files (*.*)|*.*";
                    SaveDialog.FilterIndex = 1; 

                    if (SaveDialog.ShowDialog() == DialogResult.OK)
                    {
                        File.WriteAllBytes(SaveDialog.FileName, abDocumentBuffer);
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("GetDocument Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Beispiel #5
0
        private void btnGetPage_Click(object sender, EventArgs e)
        {
            long lSearchError;

            if (lstIndex.Items.Count == 0)
                return;

            try
            {
                // numero di documenti per pagina
                Int32 nPageSize = Int32.Parse(txtPageSize.Text);
                // numero di pagina
                Int32 nPageNum = Int32.Parse(txtPageNum.Text);

                // creo il crypto service
                ArchivaASP_CRY Crypto = new ArchivaASP_CRY();

                // campi risultanti
                ArchivaASP_FIELDVALUE FieldResult = new ArchivaASP_FIELDVALUE();

                // cripto la descrizione XML dei parametri
                byte[] abXmlUserSession = Crypto.EncryptXML(m_UserSession, typeof(ArchivaASP_LOGIN), m_RSA_Server);
                // cripto la index list XML dei parametri
                byte[] abXmlPageNum = Crypto.EncryptXML(nPageNum, typeof(Int32), m_RSA_Server);
                // cripto la condizione XML dei parametri
                byte[] abXmlPageSize = Crypto.EncryptXML(nPageSize, typeof(Int32), m_RSA_Server);

                byte[] abXmlFieldResult = null;

                this.Cursor = Cursors.WaitCursor;
                lSearchError = m_ArchivaASP.GetSearchDocument(abXmlUserSession, abXmlPageNum, abXmlPageSize, out abXmlFieldResult);
                this.Cursor = Cursors.Default;
                if (lSearchError != 0)
                {
                    string sError = "";
                    m_ArchivaASP.GetErrorDescription(lSearchError, ref sError);

                    MessageBox.Show(sError, "GetSearchDocument Fault", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    // decripto le info 
                    this.Cursor = Cursors.WaitCursor;
                    FieldResult = (ArchivaASP_FIELDVALUE)Crypto.DecryptXML(abXmlFieldResult, typeof(ArchivaASP_FIELDVALUE), m_RSA_Client);

                    // layout
                    lstResult.Clear();
                    lstResult.Columns.Clear();
                    for (int i = 0; i < FieldResult.FieldNames.Fields.Count; i++)
                    {
                        ColumnHeader chTmp = new ColumnHeader();

                        chTmp.Text = (String)FieldResult.FieldNames.Fields[i];
                        chTmp.TextAlign = HorizontalAlignment.Left;
                        //chTmp.Width = lstResult.Width / FieldResult.FieldName.Fields.Count;
                        chTmp.Width = 100;

                        lstResult.Columns.Add(chTmp);
                    }

                    // visualizzo i record
                    lstResult.Items.Clear();
                    for (int l = 0; l < FieldResult.FieldValues.Count; l++)
                    {
                        ArchivaASP_FIELDLIST tmp = (ArchivaASP_FIELDLIST)FieldResult.FieldValues[l];

                        string[] sValues = new string[FieldResult.FieldNames.Fields.Count];
                        for (int u = 0; u < FieldResult.FieldNames.Fields.Count; u++)
                            sValues[u] = (string)tmp.Fields[u];

                        lstResult.Items.Add(new ListViewItem(sValues));
                    }
                    this.Cursor = Cursors.Default;
                }
            }
            catch (Exception)
            {
                MessageBox.Show("GetSearchDocument Exception", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Beispiel #6
0
        private void btnExec_Click(object sender, EventArgs e)
        {
            long lSearchError;

            if (lstIndex.Items.Count == 0)
                return;

            try
            {
                // Svuoto la lista dei risultati
                lstResult.Items.Clear();

                // creo una index list con la lista selezionata
                ArchivaASP_INDEXLIST IndexList = new ArchivaASP_INDEXLIST();
                IndexList.Indexes.Add(lstIndex.SelectedItems[0].Text);

                // creo una espressione criptata sui campi
                String sExp = txtCondition.Text;

                // numero di documenti risultanti dalla ricerca
                Int32 lResultCount = 0;

                // creo il crypto service
                ArchivaASP_CRY Crypto = new ArchivaASP_CRY();

                // campi da visualizzare
                ArchivaASP_FIELDLIST FieldList = new ArchivaASP_FIELDLIST();
                for (int lIndex = 0; lIndex < lstField.SelectedItems.Count; lIndex++)
                    FieldList.Fields.Add(lstField.SelectedItems[lIndex].Text);

                // cripto la descrizione XML dei parametri
                byte[] abXmlUserSession = Crypto.EncryptXML(m_UserSession, typeof(ArchivaASP_LOGIN), m_RSA_Server);
                // cripto la index list XML dei parametri
                byte[] abXmlIndexList = Crypto.EncryptXML(IndexList, typeof(ArchivaASP_INDEXLIST), m_RSA_Server);
                // cripto la condizione XML dei parametri
                byte[] abXmlFieldCondition = Crypto.EncryptXML(sExp, typeof(String), m_RSA_Server);
                // cripto la lista dei campi fornibili XML dei parametri
                byte[] abXmlFieldName = Crypto.EncryptXML(FieldList, typeof(ArchivaASP_FIELDLIST), m_RSA_Server);
                
                byte[] abXmlResultNum = null;

                this.Cursor = Cursors.WaitCursor;
                lSearchError = m_ArchivaASP.SearchDocument(abXmlUserSession, abXmlIndexList, abXmlFieldCondition, abXmlFieldName, out abXmlResultNum);
                this.Cursor = Cursors.Default;
                if (lSearchError != 0)
                {
                    string sError = "";
                    m_ArchivaASP.GetErrorDescription(lSearchError, ref sError);

                    MessageBox.Show(sError, "SearchDocument Fault", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    // decripto le info 
                    lResultCount = (Int32)Crypto.DecryptXML(abXmlResultNum, typeof(Int32), m_RSA_Client);
                    txtResultNum.Text = lResultCount.ToString();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("SearchDocument Exception", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Beispiel #7
0
        private void lstIndex_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
        {
            long lSdtError;

            if (lstIndex.Items.Count == 0)
                return;

            try
            {
                // creo una index list con la lista selezionata
                ArchivaASP_INDEXLIST IndexList = new ArchivaASP_INDEXLIST();
                IndexList.Indexes.Add(lstIndex.Items[e.ItemIndex].Text);

                // creo una field list vuota
                ArchivaASP_FIELDLIST FieldList = new ArchivaASP_FIELDLIST();

                // creo il crypto service
                ArchivaASP_CRY Crypro = new ArchivaASP_CRY();

                // cripto la descrizione XML dei parametri
                byte[] abXmlUserSession = Crypro.EncryptXML(m_UserSession, m_UserSession.GetType(), m_RSA_Server);
                // cripto la index list XML dei parametri
                byte[] abXmlIndexList = Crypro.EncryptXML(IndexList, IndexList.GetType(), m_RSA_Server);

                byte[] abXmlFieldList = null;

                this.Cursor = Cursors.WaitCursor;
                lSdtError = m_ArchivaASP.GetFieldList(abXmlUserSession, abXmlIndexList, out abXmlFieldList);
                this.Cursor = Cursors.Default;
                if (lSdtError != 0)
                {
                    string sError = "";
                    m_ArchivaASP.GetErrorDescription(lSdtError, ref sError);

                    MessageBox.Show(sError, "GetFieldList Fault", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    // decripto le info 
                    FieldList = (ArchivaASP_FIELDLIST)Crypro.DecryptXML(abXmlFieldList, FieldList.GetType(), m_RSA_Client);

                    lstField.Items.Clear();
                    for (int l = 0; l < FieldList.Fields.Count; l++)
                        lstField.Items.Add((String)FieldList.Fields[l]);
                }
            }
            catch(Exception)
            {
                MessageBox.Show("GetFieldList Exception", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Beispiel #8
0
        private long LogoutRSA()
        {
            try
            {
                // creo il crypto service
                ArchivaASP_CRY Crypto = new ArchivaASP_CRY();

                // cripto la descrizione XML dei parametri
                byte[] abXmlUserSession = Crypto.EncryptXML(m_UserSession, m_UserSession.GetType(), m_RSA_Server);

                // effettuo il login
                this.Cursor = Cursors.WaitCursor;
                long lResult = m_ArchivaASP.Logout(ref abXmlUserSession);
                this.Cursor = Cursors.Default;

                return lResult;
            }
            catch (Exception E)
            {
                MessageBox.Show(E.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return -1;
            }
        }