Exemple #1
0
        private void buttonImport_Click(object sender, EventArgs e)
        {
            var bufferApi  = new IO.Swagger.Api.BufferApi(Configuration);
            var profileApi = new IO.Swagger.Api.ProfilesApi(Configuration);
            var statesApi  = new IO.Swagger.Api.StatesApi(Configuration);

            var aooApi = new IO.Swagger.Api.BusinessUnitsApi(Configuration);
            var aoo    = aooApi.BusinessUnitsGet();

            var docTypesApi = new IO.Swagger.Api.DocumentTypesApi(Configuration);
            var doctypes    = docTypesApi.DocumentTypesGet(1, aoo.First().Code);


            var fo = new OpenFileDialog();

            if (fo.ShowDialog() == DialogResult.OK)
            {
                var stream   = fo.OpenFile();
                var bufferId = bufferApi.BufferInsert(stream);

                var profileDto   = profileApi.ProfilesGet_0();
                var classeGneric = doctypes.FirstOrDefault(i => i.Key.Equals("GENERIC", StringComparison.CurrentCultureIgnoreCase));
                var status       = statesApi.StatesGet_0();
                ((StateFieldDTO)profileDto.Fields.FirstOrDefault(i => i.Name.Equals("Stato", StringComparison.CurrentCultureIgnoreCase))).Value = status.First().Id;
                ((DocumentTypeFieldDTO)profileDto.Fields.FirstOrDefault(i => i.Name.Equals("DocumentType"))).Value = classeGneric.Id;
                ((OriginFieldDTO)profileDto.Fields.FirstOrDefault(i => i.Name.Equals("Origine", StringComparison.CurrentCultureIgnoreCase))).Value = 0;
                profileDto.Document = new FileDTO(bufferId);

                var additional = profileApi.ProfilesGetAdditionalByClasse(classeGneric.DocumentType, classeGneric.Type2, classeGneric.Type3, "AbleBS");
                profileDto.Fields.AddRange(additional);

                ((SubjectFieldDTO)profileDto.Fields.FirstOrDefault(i => i.Name.Equals("DOCNAME", StringComparison.CurrentCultureIgnoreCase))).Value = "Oggeto nuovo";
                var result = profileApi.ProfilesPost(new ProfileDTO()
                {
                    Fields   = profileDto.Fields,
                    Document = new FileDTO()
                    {
                        BufferIds = bufferId
                    },
                    Attachments            = new List <string>(),
                    AuthorityData          = new AuthorityDataDTO(),
                    Notes                  = new List <NoteDTO>(),
                    PaNotes                = new List <string>(),
                    PostProfilationActions = new List <PostProfilationActionDTO>()
                });

                MessageBox.Show(result.DocNumber.ToString());
            }
        }
Exemple #2
0
        private void buttonImport_Click(object sender, EventArgs e)
        {
            //Preambolo
            String messaggio;
            var    businessApi = new IO.Swagger.Api.BusinessUnitsApi(Configuration);
            var    bufferApi   = new IO.Swagger.Api.BufferApi(Configuration);
            var    profileApi  = new IO.Swagger.Api.ProfilesApi(Configuration);
            var    statesApi   = new IO.Swagger.Api.StatesApi(Configuration);
            var    aooApi      = new IO.Swagger.Api.BusinessUnitsApi(Configuration);
            var    aoo         = aooApi.BusinessUnitsGet();
            var    docTypesApi = new IO.Swagger.Api.DocumentTypesApi(Configuration);
            var    doctypes    = docTypesApi.DocumentTypesGet_0(1, aoo.First().Code);


            var fo = new OpenFileDialog();

            if (fo.ShowDialog() == DialogResult.OK)
            {
                //Mi apro il file e prendo il suo contenuto
                var stream   = fo.OpenFile();
                var bufferId = bufferApi.BufferInsert(stream);

                //Quale AOO devo utilizzare?
                messaggio = "Quale AOO devo utilizzare?\n";
                var listaAoo = businessApi.BusinessUnitsGet(1, "CODICE");
                foreach (BusinessUnitDTO bu in listaAoo)
                {
                    messaggio += string.Format("{0}: {1}\n", bu.Code, bu.Name);
                }
                var buScelta = Interaction.InputBox(messaggio, "Creazione profilo", "Immetti valore");

                //Il mio profilo andrà nella classe GENERIC
                var profileDto   = profileApi.ProfilesGet_0();
                var classeGneric = doctypes.FirstOrDefault(i => i.Key.Equals("GENERIC", StringComparison.CurrentCultureIgnoreCase));
                var status       = statesApi.StatesGet_0();

                //Definisco lo stato documentale
                messaggio = "Quale stato documentale vuoi utilizzare?\n";
                foreach (StateBaseDto stato in status)
                {
                    messaggio += string.Format("{0}: {1}\n", stato.Id, stato.Description);
                }
                String statoDocumentaleScelto = Interaction.InputBox(messaggio, "Creazione profilo", "Immetti valore");
                ((StateFieldDTO)profileDto.Fields.FirstOrDefault(i => i.Name.Equals(..., StringComparison.CurrentCultureIgnoreCase))).Value = statoDocumentaleScelto;

                //Gestiamo il DocumentType
                ((DocumentTypeFieldDTO)profileDto.Fields.FirstOrDefault(i => i.Name.Equals(...))).Value = classeGneric.Id;

                //Gestiamo l'origine del documento
                ((OriginFieldDTO)profileDto.Fields.FirstOrDefault(i => i.Name.Equals(..., StringComparison.CurrentCultureIgnoreCase))).Value = 0;

                //Impostiamo l'AOO
                ((BusinessUnitFieldDTO)profileDto.Fields.FirstOrDefault(i => i.Name.Equals(..., StringComparison.CurrentCultureIgnoreCase))).Value = buScelta;

                //Impostiamo l'oggetto
                ((SubjectFieldDTO)profileDto.Fields.FirstOrDefault(i => i.Name.Equals(..., StringComparison.CurrentCultureIgnoreCase))).Value = ...;


                //Ci mettiamo il file nel profilo
                profileDto.Document = new FileDTO(bufferId);

                //Campo aggiuntivi: ricerchiamoli e popoliamoli
                var additional = profileApi....(classeGneric.DocumentType, classeGneric.Type2, classeGneric.Type3, buScelta);
                ((AdditionalFieldStringDTO)additional.FirstOrDefault(i => i.Description.Equals("StringaProtocollo", StringComparison.CurrentCultureIgnoreCase))).Value = "api00x";
                ((AdditionalFieldIntDTO)additional.FirstOrDefault(i => i.Description.Equals("CodiceProtocollo", StringComparison.CurrentCultureIgnoreCase))).Value     = 9876;
                ((AdditionalFieldDateTimeDTO)additional.FirstOrDefault(i => i.Description.Equals("DataProtocollo", StringComparison.CurrentCultureIgnoreCase))).Value  = new DateTime(2021, 01, 01);
                profileDto.Fields....(additional);

                //Creazione del profilo, annesso metadati e documento
                var result = profileApi.ProfilesPost(new ProfileDTO()
                {
                    Fields   = profileDto.Fields,
                    Document = new FileDTO()
                    {
                        BufferIds = bufferId
                    },
                    Attachments            = new List <string>(),
                    AuthorityData          = new AuthorityDataDTO(),
                    Notes                  = new List <NoteDTO>(),
                    PaNotes                = new List <string>(),
                    PostProfilationActions = new List <PostProfilationActionDTO>()
                });

                MessageBox.Show("Profilo creato con numero: " + result.DocNumber.ToString());
            }
        }