예제 #1
0
        private void buttonArchive_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;

            try
            {
                Dm_Profile_ForInsert insert = _manager.ARX_DATI.Dm_Profile_ForInsert_Get_New_Instance_ByDocumentTypeCodice("TEST.DEV");
                insert.Aoo     = "DEMO";
                insert.DocName = "My C# Application";
                insert.InOut   = DmProfileInOut.Interno;
                insert.Stato   = "VALID";
                insert.DataDoc = DateTime.Now.Date; // new DateTime(2018,04,30);
                //insert.ProtocolloInterno = "AR\\0019";
                //insert.AssocDoc.IDERP = "989";


                // Mi - De - Cc
                insert.From = GetDatiProfilo("ABLETECH", Dm_DatiProfilo_Campo.MI);
                insert.To.Add(GetDatiProfilo("MAURO BIAGGIO", Dm_DatiProfilo_Campo.DE));
                insert.To.Add(GetDatiProfilo("GIULIANO ROVERSI", Dm_DatiProfilo_Campo.DE));
                insert.To.Add(GetDatiProfilo("YARI MELZANI", Dm_DatiProfilo_Campo.DE));

                //-----------------------------------------
                // Aggiuntivi -----------------------------
                //-----------------------------------------

                //Campo data acquisto
                Aggiuntivo_String aggTarga = insert.Aggiuntivi.FirstOrDefault(
                    x => string.Equals(x.ExternalId, "TARGA", StringComparison.CurrentCultureIgnoreCase)) as Aggiuntivo_String;
                if (aggTarga == null)
                {
                    throw new Exception("External id 'TARGA' not found");
                }
                aggTarga.Valore = "ZR009IU"; //DEMO VALUE

                // Campo data
                Aggiuntivo_DateTime agData = insert.Aggiuntivi.FirstOrDefault(
                    x => string.Equals(x.ExternalId, "DATAA", StringComparison.CurrentCultureIgnoreCase)) as Aggiuntivo_DateTime;
                if (agData == null)
                {
                    throw new Exception("External id 'DATAA' not found");
                }
                agData.Valore = DateTime.Now.Date;

                // Campo importo
                Aggiuntivo_Double agImporto = insert.Aggiuntivi.FirstOrDefault(
                    x => string.Equals(x.ExternalId, "IMPORTO", StringComparison.CurrentCultureIgnoreCase)) as Aggiuntivo_Double;
                if (agImporto == null)
                {
                    throw new Exception("External id 'IMPORTO' not found");
                }
                agImporto.Valore = 1200;

                // Campo finanziamento
                Aggiuntivo_Bool agFinanziamento = insert.Aggiuntivi.FirstOrDefault(
                    x => string.Equals(x.ExternalId, "CONFINANZIAMENTO", StringComparison.CurrentCultureIgnoreCase)) as Aggiuntivo_Bool;
                if (agFinanziamento == null)
                {
                    throw new Exception("External id 'CONFINANZIAMENTO' not found");
                }
                agFinanziamento.Valore = true;

                // Campo agente (Nell'esempio è un campo combo con LimitToList -> Il valore indicato DEVE esistere)
                Aggiuntivo_String aggAgente = insert.Aggiuntivi.FirstOrDefault(
                    x => string.Equals(x.ExternalId, "COD_AGENTE", StringComparison.CurrentCultureIgnoreCase)) as Aggiuntivo_String;
                if (aggAgente == null)
                {
                    throw new Exception("External id 'COD_AGENTE' not found");
                }
                aggAgente.Valore = "AG_002";

                // Campo Tags
                Aggiuntivo_MultiValue aggTags = insert.Aggiuntivi.FirstOrDefault(
                    x => string.Equals(x.ExternalId, "TAGS", StringComparison.CurrentCultureIgnoreCase)) as Aggiuntivo_MultiValue;
                if (aggTags == null)
                {
                    throw new Exception("External id 'TAGS' not found");
                }
                aggTags.Values = new EntitiesCollection <string> {
                    "C#", "DEV", "CORSO"
                };


                //File del profilo
                insert.File = new Arx_File(@"C:\Temp\test.txt");
                var dmProfileResult = _manager.ARX_DATI.Dm_Profile_Insert(insert);

                /* E se volessimo fare un'achiviazione per il ciclo passivo ?
                 * è sufficiente eseguire
                 *      Dm_Profile_Insert_For_Barcode
                 * al posto di
                 *      Dm_Profile_Insert
                 * il parametro barcode è opzione, se non viene indicato ARXivar utilizza le sue regole per creare un codice barcode
                 */

                //var dmProfileResult = _manager.ARX_DATI.Dm_Profile_Insert_For_Barcode(insert, "");

                if (dmProfileResult.EXCEPTION != Security_Exception.Nothing)
                {
                    MessageBox.Show(
                        dmProfileResult.MESSAGE,
                        "Store",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                }
                else
                {
                    // Recuperaro il fascicolo Dev1
                    int idFolder = 0;

                    using (var folderSelect = new Dm_Fascicoli_Select())
                        using (var folderSearch = new Dm_Fascicoli_Search())
                        {
                            folderSelect.ID.Selected = true;

                            folderSearch.NOME.SetFilter(Dm_Base_Search_Operatore_String.Uguale, "DEV2");
                            folderSearch.NOME.forceCaseInsensitive = true;

                            using (var dsFolder = _manager.ARX_SEARCH.Dm_Fascicoli_GetData(folderSearch, folderSelect))
                            {
                                var dtFolder = dsFolder.GetDataTable(0);
                                if (dtFolder.Rows.Count == 0)
                                {
                                    throw new Exception("Non ho trovato il fascicolo DEV2");
                                }

                                idFolder = System.Convert.ToInt32(dtFolder.Rows[0]["ID"]);
                            }
                        }

                    // Inserisco il documento nel fascicolo
                    _manager.ARX_DATI.Dm_FileInFolder_Insert(idFolder, dmProfileResult.PROFILE.DOCNUMBER);


                    MessageBox.Show(
                        "Store Ok. SystemId: " + dmProfileResult.PROFILE.DOCNUMBER,
                        "Store",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Information);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
            finally
            {
                Cursor = Cursors.Default;
            }
        }
예제 #2
0
        private void buttonArchive_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;

            try
            {
                Dm_Profile_ForInsert insert = _manager.ARX_DATI.Dm_Profile_ForInsert_Get_New_Instance_ByDocumentTypeCodice("TEST.DEV");
                insert.Aoo     = "DEMO";                 // Area organizzativa
                insert.DocName = "My C# Application";    // oggetto
                insert.InOut   = DmProfileInOut.Interno; // origine
                insert.Stato   = "VALID";                // Stato (usare codice non descrizione)
                insert.DataDoc = DateTime.Now.Date;      // new DateTime(2018,04,30);
                //insert.ProtocolloInterno = "AR\\0019";


                insert.AssocDoc.IDERP = "my_ext_id_00001";

                // Mi - De - Cc
                insert.From = GetDatiProfilo("ABLETECH", Dm_DatiProfilo_Campo.MI);
                insert.To.Add(GetDatiProfilo("MAURO BIAGGIO", Dm_DatiProfilo_Campo.DE));
                insert.To.Add(GetDatiProfilo("GIULIANO ROVERSI", Dm_DatiProfilo_Campo.DE));
                insert.To.Add(GetDatiProfilo("YARI MELZANI", Dm_DatiProfilo_Campo.DE));

                //-----------------------------------------
                // Aggiuntivi -----------------------------
                //-----------------------------------------

                //Campo data acquisto
                Aggiuntivo_String aggTarga = insert.Aggiuntivi.FirstOrDefault(
                    x => string.Equals(x.ExternalId, "TARGA", StringComparison.CurrentCultureIgnoreCase)) as Aggiuntivo_String;
                if (aggTarga == null)
                {
                    throw new Exception("External id 'TARGA' not found");
                }
                aggTarga.Valore = "ZR009IU"; //DEMO VALUE

                // Campo data
                Aggiuntivo_DateTime agData = insert.Aggiuntivi.FirstOrDefault(
                    x => string.Equals(x.ExternalId, "DATAA", StringComparison.CurrentCultureIgnoreCase)) as Aggiuntivo_DateTime;
                if (agData == null)
                {
                    throw new Exception("External id 'DATAA' not found");
                }
                agData.Valore = new DateTime(2016, 5, 5);

                // Campo importo
                Aggiuntivo_Double agImporto = insert.Aggiuntivi.FirstOrDefault(
                    x => string.Equals(x.ExternalId, "IMPORTO", StringComparison.CurrentCultureIgnoreCase)) as Aggiuntivo_Double;
                if (agImporto == null)
                {
                    throw new Exception("External id 'IMPORTO' not found");
                }
                agImporto.Valore = 1200;

                // Campo finanziamento
                Aggiuntivo_Bool agFinanziamento = insert.Aggiuntivi.FirstOrDefault(
                    x => string.Equals(x.ExternalId, "CONFINANZIAMENTO", StringComparison.CurrentCultureIgnoreCase)) as Aggiuntivo_Bool;
                if (agFinanziamento == null)
                {
                    throw new Exception("External id 'CONFINANZIAMENTO' not found");
                }
                agFinanziamento.Valore = true;

                // Campo agente (Nell'esempio è un campo combo con LimitToList -> Il valore indicato DEVE esistere)
                Aggiuntivo_String aggAgente = insert.Aggiuntivi.FirstOrDefault(
                    x => string.Equals(x.ExternalId, "COD_AGENTE", StringComparison.CurrentCultureIgnoreCase)) as Aggiuntivo_String;
                if (aggAgente == null)
                {
                    throw new Exception("External id 'COD_AGENTE' not found");
                }
                aggAgente.Valore = "AG_002";

                // Campo Tags
                Aggiuntivo_MultiValue aggTags = insert.Aggiuntivi.FirstOrDefault(
                    x => string.Equals(x.ExternalId, "TAGS", StringComparison.CurrentCultureIgnoreCase)) as Aggiuntivo_MultiValue;
                if (aggTags == null)
                {
                    throw new Exception("External id 'TAGS' not found");
                }
                aggTags.Values = new EntitiesCollection <string> {
                    "C#", "DEV", "CORSO"
                };


                //File del profilo
                insert.File = new Arx_File(@"C:\Temp\test.txt");
                Dm_Profile_Result dmProfileResult = _manager.ARX_DATI.Dm_Profile_Insert(insert);


                /* E se volessimo fare un'achiviazione per il ciclo passivo ?
                 * è sufficiente eseguire
                 *      Dm_Profile_Insert_For_Barcode
                 * al posto di
                 *      Dm_Profile_Insert
                 * il parametro barcode è opzione, se non viene indicato ARXivar utilizza le sue regole per creare un codice barcode
                 */

                //var dmProfileResult = _manager.ARX_DATI.Dm_Profile_Insert_For_Barcode(insert, "");

                if (dmProfileResult.EXCEPTION != Security_Exception.Nothing)
                {
                    MessageBox.Show(
                        dmProfileResult.MESSAGE,
                        "Store",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show(
                        "Store Ok. SystemId: " + dmProfileResult.PROFILE.DOCNUMBER,
                        "Store",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Information);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
            finally
            {
                Cursor = Cursors.Default;
            }
        }