Ejemplo n.º 1
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            try
            {
                using (var profileSelect = _manager........("GENERIC"))
                    using (var profileSearch = _manager........("GENERIC"))
                    {
                        //Prendiamo 30 righe al massimo
                        profileSelect.MaxRowCount = 30;

                        //Prendiamo il campo DOCNUMBER e diciamo:
                        //1) Mostriamolo in output
                        //2) Nella lista sarà l'elemento di posizione "0"
                        //3) Inidichiamo che l'elemento è il primo da ordinare
                        //4) Indichiamo che l'elemento sia ordinato in modo ascendente
                        profileSelect.DOCNUMBER.Selected          = true;
                        profileSelect.DOCNUMBER.Index             = 0;
                        profileSelect.DOCNUMBER.OrderBy.Index     = 0;
                        profileSelect.DOCNUMBER.OrderBy.Direction = EOrderByDirection.Ascending;

                        //Prendiamo il campo DOCNAME e diciamo:
                        //1) Mostriamolo in output
                        //2) Nella lista sarà l'elemento di posizione "1"
                        //3) Inidichiamo che l'elemento è il secondo da ordinare
                        //4) Indichiamo che l'elemento sia ordinato in modo ascendente
                        profileSelect.DOCNAME.Selected          = true;
                        profileSelect.DOCNAME.Index             = 1;
                        profileSelect.DOCNAME.OrderBy.Index     = 1;
                        profileSelect.DOCNAME.OrderBy.Direction = EOrderByDirection.Descending;

                        //Prendiamo il campo ORIGINALE e diciamo:
                        //1) Mostriamolo in output
                        //2) Nella lista sarà l'elemento di posizione "2"
                        profileSelect.ORIGINALE.Selected = true;
                        profileSelect.ORIGINALE.Index    = 2;

                        //Gestiamo i campi aggiuntivi
                        foreach (Aggiuntivo_Selected campoAggiuntivo in profileSelect.Aggiuntivi)
                        {
                            if (campoAggiuntivo........("CodiceProtocollo") == true)
                            {
                                campoAggiuntivo.Selected          = true;
                                campoAggiuntivo.Index             = 3;
                                campoAggiuntivo.OrderBy.Index     = 3;
                                campoAggiuntivo.OrderBy.Direction = EOrderByDirection.Ascending;
                            }
                        }

                        //Chiediamo all'utente quale range di valore "CodiceProtocollo" deve ricercare
                        int codiceProtocolloMinimoScelta = Int32.Parse(
                            Interaction.InputBox("Quali profili con valore minimo di CodiceProtocollo cerchi?", "Ricerche con WCF", "Immetti un valore"));
                        int codiceProtocolloMassimoScelta = Int32.Parse(
                            Interaction.InputBox("Quali profili con valore massimo di CodiceProtocollo cerchi?", "Ricerche con WCF", "Immetti un valore"));


                        Field_Int campoAggiuntivoCodiceProtocolloScelta =
                            profileSearch.Aggiuntivi.FirstOrDefault(
                                x => String.Equals(x...., ..., StringComparison.CurrentCultureIgnoreCase)) as Field_Int;
                        //Ma questo campo aggiuntivo esiste?
                        if (campoAggiuntivoCodiceProtocolloScelta == null)
                        {
                            throw new Exception("Campo \'CodiceProtocollo\' non trovato!");
                        }
                        else
                        {
                            campoAggiuntivoCodiceProtocolloScelta.SetFilter(
                                .......,
                                codiceProtocolloMinimoScelta,
                                codiceProtocolloMassimoScelta);
                        }

                        //Esecuzione della ricerca, mostrando il risultato nella DataGridLayout
                        using (var ds = _manager........(profileSearch, profileSelect, 0))
                        {
                            dgSearch.DataSource = ds.GetDataTable(0);
                        }
                    }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                Cursor = Cursors.Default;
            }
        }
Ejemplo n.º 2
0
        private void buttonSearchProfile2_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;

            try
            {
                //Dm_AllegatiDoc_Search allegatiSearch = new Dm_AllegatiDoc_Search();
                //Dm_AllegatiDoc_Select allegatiSelect = new Dm_AllegatiDoc_Select();

                //allegatiSelect.ID.Selected = true;
                //allegatiSelect.NOMEFILE.Selected = true;

                //allegatiSearch.DOCNUMBER.SetFilter(Dm_Base_Search_Operatore_Numerico.Uguale, 19);

                //using (var dsAllegati = _manager.ARX_SEARCH.Dm_AllegatiDoc_GetData(allegatiSearch, allegatiSelect))
                //{
                //    var dtAllegati = dsAllegati.GetDataTable(0);
                //    var idAllegato = System.Convert.ToInt32(dtAllegati.Rows[0]["ID"]);
                //    var arxFileAllegato = _manager.ARX_DOCUMENTI.Dm_AllegatiDoc_GetDocument(idAllegato);
                //}


                using (var profileSelect = _manager.ARX_SEARCH.Dm_Profile_Select_Get_New_Instance_By_TipiDocumentoCodice("TEST.DEV"))
                    using (var profileSearch = _manager.ARX_SEARCH.Dm_Profile_Search_Get_New_Instance_By_TipiDocumentoCodice("TEST.DEV"))
                    {
                        profileSelect.MaxRowCount = 30;

                        profileSelect.DOCNUMBER.Selected          = true;
                        profileSelect.DOCNUMBER.Index             = 0;
                        profileSelect.DOCNUMBER.OrderBy.Index     = 0;
                        profileSelect.DOCNUMBER.OrderBy.Direction = EOrderByDirection.Ascending;

                        profileSelect.DOCNAME.Selected          = true;
                        profileSelect.DOCNAME.Index             = 1;
                        profileSelect.DOCNAME.OrderBy.Index     = 1;
                        profileSelect.DOCNAME.OrderBy.Direction = EOrderByDirection.Descending;

                        profileSelect.ORIGINALE.Selected = true;
                        profileSelect.ORIGINALE.Index    = 2;

                        profileSelect.CREATION_DATE.Selected = true;
                        profileSelect.CREATION_DATE.Index    = 3;

                        var lastIndex = 3;
                        for (int i = 0; i < profileSelect.Aggiuntivi.Length; i++)
                        {
                            if (profileSelect.Aggiuntivi[i].Nome.StartsWith("MULTI"))
                            {
                                continue;
                            }

                            lastIndex++;
                            profileSelect.Aggiuntivi[i].Selected = true;
                            profileSelect.Aggiuntivi[i].Index    = lastIndex;
                        }



                        // Ricerca su campo numerico
                        Field_Double fDouble = profileSearch.Aggiuntivi.FirstOrDefault(x => String.Equals(x.ExternalId, "IMPORTO", StringComparison.CurrentCultureIgnoreCase)) as Field_Double;
                        if (fDouble == null)
                        {
                            throw new Exception("Campo con externalId 'IMPORTO' non trovato");
                        }
                        fDouble.SetFilter(Dm_Base_Search_Operatore_Numerico.Maggiore, 1000);


                        /*
                         *
                         *
                         * // Ricerca su campo stringa
                         * Field_String fString = profileSearch.Aggiuntivi.FirstOrDefault(x => String.Equals(x.ExternalId, "TARGA", StringComparison.CurrentCultureIgnoreCase)) as Field_String;
                         * if (fString == null)
                         * {
                         * throw new Exception("Campo con externalId 'TARGA' non trovato");
                         * }
                         * fString.SetFilter(Dm_Base_Search_Operatore_String.Contiene, "zr");
                         * fString.forceCaseInsensitive = true;
                         *
                         *
                         * // Ricerca su campo stringa
                         * Field_String fStringAgente = profileSearch.Aggiuntivi.FirstOrDefault(x => String.Equals(x.ExternalId, "COD_AGENTE", StringComparison.CurrentCultureIgnoreCase)) as Field_String;
                         * if (fStringAgente == null)
                         * {
                         * throw new Exception("Campo con externalId 'COD_AGENTE' non trovato");
                         * }
                         * fStringAgente.SetFilter(Dm_Base_Search_Operatore_String.Uguale, "AG_004");
                         * fStringAgente.forceCaseInsensitive = true;
                         *
                         */


                        // Ricerca su campo data
                        Field_DateTime fData = profileSearch.Aggiuntivi.FirstOrDefault(x => String.Equals(x.ExternalId, "DATAA", StringComparison.CurrentCultureIgnoreCase)) as Field_DateTime;
                        if (fData == null)
                        {
                            throw new Exception("Campo con externalId 'DATAA' non trovato");
                        }
                        DateTime dtFrom = new DateTime(2016, 05, 05, 0, 0, 0);
                        DateTime dtTo   = new DateTime(2016, 05, 05, 23, 59, 59);
                        fData.SetFilter(Dm_Base_Search_Operatore_Numerico.Compreso, dtFrom, dtTo);


                        // Ricerca su campo boolean
                        Field_Int fIntBool = profileSearch.Aggiuntivi.FirstOrDefault(x => String.Equals(x.ExternalId, "CONFINANZIAMENTO", StringComparison.CurrentCultureIgnoreCase)) as Field_Int;
                        if (fIntBool == null)
                        {
                            throw new Exception("Campo con externalId 'CONFINANZIAMENTO' non trovato");
                        }
                        fIntBool.SetFilter(Dm_Base_Search_Operatore_Numerico.Uguale, 1); // Da notare che il campo bool si cerca come un INT con valori 0 / 1

                        // Ricerca su campo Multivalue
                        Field_MultiValue fMv = profileSearch.Aggiuntivi.FirstOrDefault(x => String.Equals(x.ExternalId, "TAGS", StringComparison.CurrentCultureIgnoreCase)) as Field_MultiValue;
                        if (fMv == null)
                        {
                            throw new Exception("Campo con externalId 'TAGS' non trovato");
                        }
                        fMv.AddValue("C#", Dm_Base_Search_Operatore_String.Uguale);
                        fMv.AddValue("DEV", Dm_Base_Search_Operatore_String.Uguale);



                        using (var ds = _manager.ARX_SEARCH.Dm_Profile_GetData(profileSearch, profileSelect, 0))
                        {
                            dgSearch.DataSource = ds.GetDataTable(0);
                        }
                    }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                Cursor = Cursors.Default;
            }
        }