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; } }
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; } }
private void buttonArchive_Click(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; try { //1) Preambolo String messaggio, classeDocumentaleScelta, buScelta, oggettoProfilo, statoDocumentaleScelto, stringaProtocolloScelta; int origineProfilo, codiceProtocolloScelto; DateTime dataProtocolloScelta; //2) Campi principali: Individuiamo la classe documentale: per esempio GENERIC var listaClassiDocumentali = _manager........( Dm_TipiDocumento_Mode...., "SYSTEM_ID"); messaggio = "In quale classe documentale vuoi creare il profilo? Immetti il suo codice\n"; foreach (Dm_TipiDocumento classeDocumentale in listaClassiDocumentali) { messaggio += string.Format("{0}: {1}\n", classeDocumentale.CODICE, classeDocumentale.DESCRIPTION); } classeDocumentaleScelta = Interaction.InputBox(messaggio, "Store di un profilo", "Immetti il valore"); Dm_Profile_ForInsert insert = _manager........(classeDocumentaleScelta); //3) Campi principali: Definiamo l'AOO var listaBU = _manager........(Dm_Aoo_Mode.Archive, "CODICE"); messaggio = "Su quale BusinessUnit vuoi lavorare?\n"; foreach (Dm_Aoo bu in listaBU) { messaggio += string.Format("{0}: {1}({2})\n", bu.CODICE, bu.DENOMINAZIONE, bu.CODFIS); } buScelta = Interaction.InputBox(messaggio, "Store di un profilo", "Immetti il valore"); insert.Aoo = buScelta; //4) Campi principali: Definiamo l'oggetto del profilo messaggio = "Qual è l\'oggetto del profilo?\n"; oggettoProfilo = Interaction.InputBox(messaggio, "Store di un profilo", "Immetti il valore"); insert.DocName = oggettoProfilo; //5) Campi principali: Origine del profilo: interno, entrata, uscita messaggio = string.Format("Qual è l\'origine del profilo?\n0: {0}\n1: {1}\n2: {2}", ......., ......., .......); origineProfilo = Int32.Parse(Interaction.InputBox(messaggio, "Store di un profilo", "Immetti il valore")); switch (origineProfilo) { case 0: insert.InOut = DmProfileInOut.Uscita; break; case 1: insert.InOut = DmProfileInOut.Entrata; break; case 2: insert.InOut = DmProfileInOut.Interno; break; default: insert.InOut = DmProfileInOut.NonValorizzato; break; } //6) Campi principali: Lista degli stati documentali messaggio = "Quale stato documentale desideri?\n"; var listaStatiDocumentali = _manager........("TRANSLATEDESCRIPTION"); foreach (Dm_Tabelle statoDocumentale in listaStatiDocumentali) { messaggio += string.Format("{0}: {1}\n", statoDocumentale.VALORE, statoDocumentale.TRANSLATEDESCRIPTION); } statoDocumentaleScelto = Interaction.InputBox(messaggio, "Store di un profilo", "Immetti il valore"); insert.Stato = statoDocumentaleScelto; //7) Campi principali: Settiamo la data del documento a oggi insert.DataDoc = DateTime.Now.Date; //8) Campi principali: Settiamo l'IDERP del documento insert.AssocDoc.IDERP = "id_" + DateTime.Now.Millisecond; //9) Campi principali: mittente - destinatario - cc insert.From = GetDatiProfilo("m.rossi", Dm_DatiProfilo_Campo.MI); insert.To.Add(GetDatiProfilo("b.verdi", Dm_DatiProfilo_Campo.DE)); insert.To.Add(GetDatiProfilo("b.bianchi", Dm_DatiProfilo_Campo.CC)); //----------------------------------------- // Aggiuntivi ----------------------------- //----------------------------------------- //10)Campo aggiuntivo: stringaProtocollo messaggio = "Qual è la stringa-protocollo?"; Aggiuntivo_String aggStringaProtocollo = insert........( x => string.Equals(x.Label, "StringaProtocollo", StringComparison.CurrentCultureIgnoreCase)) as Aggiuntivo_String; if (aggStringaProtocollo == null) { throw new Exception("Campo aggiuntivo \'StringaProtocollo\' non trovato!"); } stringaProtocolloScelta = Interaction.InputBox(messaggio, "Store di un profilo", "Immetti il valore"); aggStringaProtocollo.Valore = stringaProtocolloScelta; //11)Campo aggiuntivo: codiceProtocollo messaggio = "Qual è il codice di protocollo?"; Aggiuntivo_Int codiceProtocollo = insert........( x => string.Equals(x.Label, "CodiceProtocollo", StringComparison.CurrentCultureIgnoreCase)) as Aggiuntivo_Int; if (codiceProtocollo == null) { throw new Exception("Campo aggiuntivo \'codiceProtocollo\' non trovato!"); } codiceProtocolloScelto = Int32.Parse(Interaction.InputBox(messaggio, "Store di un profilo", "Immetti il valore")); codiceProtocollo.Valore = codiceProtocolloScelto; //12)Campo aggiuntivo: dataProtocollo messaggio = "Qual è la data-protocollo?"; Aggiuntivo_DateTime dataProtocollo = insert........( x => string.Equals(x.Label, "DataProtocollo", StringComparison.CurrentCultureIgnoreCase)) as Aggiuntivo_DateTime; if (dataProtocollo == null) { throw new Exception("Campo aggiuntivo \'dataProtocollo\' non trovato!"); } dataProtocolloScelta = DateTime.Parse(Interaction.InputBox(messaggio, "Store di un profilo", "2019/05/24")); dataProtocollo.Valore = dataProtocolloScelta; //13)File del profilo insert.File = new Arx_File(@"C:\Temp\test.txt"); //14) Proviamo a creare il profilo e controlliamo l'esito Dm_Profile_Result dmProfileResult = _manager........(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; } }