예제 #1
0
        public string CreateSeriesWithClassificationSystem(string fondsId)
        {
            Console.WriteLine($"Create a Series with a classification system and one class.");
            NoarkClient client = this.documasterClients.GetNoarkClient();

            //When new objects are initialized, a temporary Id is assigned to them.
            Klassifikasjonssystem classificationSystem = new Klassifikasjonssystem("Oppkvest");
            Klasse   klass  = new Klasse("01", "Tilbud");
            Arkivdel series = new Arkivdel("Barnehage");

            TransactionResponse transactionResponse = client.Transaction()
                                                      .Save(series)
                                                      .Link(series.LinkArkiv(fondsId))
                                                      .Save(classificationSystem)
                                                      .Link(series.LinkPrimaerKlassifikasjonssystem(classificationSystem))
                                                      .Save(klass)
                                                      .Link(klass.LinkKlassifikasjonssystem(classificationSystem))
                                                      .Commit();

            //transactionResponse.Saved contains a mapping between the temporary id's and the saved objects with their permanent id's
            Klassifikasjonssystem savedClassificationSystem =
                transactionResponse.Saved[classificationSystem.Id] as Klassifikasjonssystem;
            Klasse   savedClass  = transactionResponse.Saved[klass.Id] as Klasse;
            Arkivdel savedSeries = transactionResponse.Saved[series.Id] as Arkivdel;

            Console.WriteLine(
                $"New classification system '{savedClassificationSystem.Tittel}' created. Temporary Id: {classificationSystem.Id}. Permanent Id: {savedClassificationSystem.Id}.");
            Console.WriteLine(
                $"New class '{savedClass.Tittel}' created. Temporary Id: {klass.Id}. Permanent Id: {savedClass.Id}.");
            Console.WriteLine(
                $"New series '{savedSeries.Tittel}' created. Temporary Id: {series.Id}. Permanent Id: {savedSeries.Id}.");

            return(savedSeries.Id);
        }
        public void FinalizeObjectsInArchive(string seriesId,
                                             string folderId,
                                             string basicRecordId,
                                             string documentDescriptionId
                                             )
        {
            NoarkClient client = this.documasterClients.GetNoarkClient();

            // Note that currently finalizing objects will not finalize child objects!
            // We first finalize the objects in the bottom of the hierarchy, and then finalize parent objects up to Series.

            // Finalize series by setting changing the series status to Closed Period (P).
            Arkivdel series = GetNoarkEntityById <Arkivdel>(seriesId);

            series.Arkivdelstatus = Arkivdelstatus.AVSLUTTET_PERIODE;

            // Finalize folder by setting the finalized date field.
            Mappe folder = GetNoarkEntityById <Mappe>(folderId);

            folder.AvsluttetDato = DateTime.Now;

            // Finalize basic record by setting the finalized date field.
            Basisregistrering basicRecord = GetNoarkEntityById <Basisregistrering>(basicRecordId);

            basicRecord.AvsluttetDato = DateTime.Now;

            // Finalize document description by changing the document status to Finalized (F).
            Dokument documentDescription = GetNoarkEntityById <Dokument>(documentDescriptionId);

            documentDescription.Dokumentstatus = Dokumentstatus.DOKUMENTET_ER_FERDIGSTILT;

            client.Transaction()
            .Save(documentDescription)
            .Save(basicRecord)
            .Save(folder)
            .Save(series)
            .Commit();
        }
        public void FinalizeObjectsInJournal(string seriesId,
                                             string caseFileId,
                                             string registryEntryId,
                                             string documentDescriptionId
                                             )
        {
            NoarkClient client = this.documasterClients.GetNoarkClient();

            // Note that currently finalizing objects will not finalize child objects!
            // We first finalize the objects in the bottom of the hierarchy, and then finalize parent objects up to Series.

            // Finalize series by setting changing the series status to Closed Period (P).
            Arkivdel series = GetNoarkEntityById <Arkivdel>(seriesId);

            series.Arkivdelstatus = Arkivdelstatus.AVSLUTTET_PERIODE;

            // Finalize case file by changing the case file status to Finalized (A).
            Saksmappe caseFile = GetNoarkEntityById <Saksmappe>(caseFileId);

            caseFile.Saksstatus = Saksstatus.AVSLUTTET;

            // Finalized registry entry by changing the record status to Archived (A).
            Journalpost registryEntry = GetNoarkEntityById <Journalpost>(registryEntryId);

            registryEntry.Journalstatus = Journalstatus.ARKIVERT;

            // Finalize document description by changing the document status to Finalized (F).
            Dokument documentDescription = GetNoarkEntityById <Dokument>(documentDescriptionId);

            documentDescription.Dokumentstatus = Dokumentstatus.DOKUMENTET_ER_FERDIGSTILT;

            client.Transaction()
            .Save(documentDescription)
            .Save(registryEntry)
            .Save(caseFile)
            .Save(series)
            .Commit();
        }
예제 #4
0
        private static void JournalingSample()
        {
            Console.WriteLine($"Journaling example {Environment.NewLine}");

            //Create a new Arkiv with an Arkivskaper
            //When new objects are initialized, a temporary Id is assigned to them.
            var newArkivskaper = new Arkivskaper("B7-23-W5", "John Smith");
            var newArkiv       = new Arkiv("Arkiv");

            var transactionResponse = client.Transaction()
                                      .Save(newArkiv)
                                      .Save(newArkivskaper)
                                      .Link(newArkiv.LinkArkivskaper(newArkivskaper))
                                      .Commit();

            //When the transaction is committed, the transaction response contains a map with saved objects.
            //One can access the saved Arkiv by providing its temporary Id as a key to the map.
            //Notice that arkiv.Id is the permanent Id of the Arkiv.
            var arkiv = transactionResponse.Saved[newArkiv.Id] as Arkiv;

            Console.WriteLine(
                $"Created Arkiv: Id={arkiv.Id}, Tittel={arkiv.Tittel}, OpprettetDato={arkiv.OpprettetDato}");

            //Update the description of the Arkiv and create a new Arkivdel in it
            //Create a new Klassifikasjonssystem with one Klasse
            //Set the new Klassifikasjonssystem as the primary Klassifikasjonssystem for the Arkivdel
            arkiv.Beskrivelse = "Barnehage Arkiv";
            var newArkivdel = new Arkivdel("2007/8");
            var newKlassifikasjonssystem = new Klassifikasjonssystem("Barnehage");
            var newKlasse = new Klasse("01", "Tilbud");

            transactionResponse = client.Transaction()
                                  .Save(arkiv)
                                  .Save(newArkivdel)
                                  .Link(newArkivdel.LinkArkiv(arkiv))
                                  .Save(newKlassifikasjonssystem)
                                  .Link(newArkivdel.LinkPrimaerKlassifikasjonssystem(newKlassifikasjonssystem))
                                  .Save(newKlasse)
                                  .Link(newKlasse.LinkKlassifikasjonssystem(newKlassifikasjonssystem))
                                  .Commit();

            arkiv = transactionResponse.Saved[arkiv.Id] as Arkiv;
            Console.WriteLine($"Updated Arkiv: Id={arkiv.Id}, Beskrivelse={arkiv.Beskrivelse}");

            var arkivdel = transactionResponse.Saved[newArkivdel.Id] as Arkivdel;

            Console.WriteLine($"Created Arkivdel: Id={arkivdel.Id}, Tittel={arkivdel.Tittel}");

            var klassifikasjonssystemId = transactionResponse.Saved[newKlassifikasjonssystem.Id].Id;
            var klasseId = transactionResponse.Saved[newKlasse.Id].Id;

            //Create a screening code
            Skjerming newSkjerming = new Skjerming(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), "Description",
                                                   "Authority");
            Skjerming skjerming = client.PutCodeListValue(newSkjerming);

            //Screen the Arkivdel
            arkivdel.Skjerming  = skjerming;
            transactionResponse = client.Transaction()
                                  .Save(arkivdel)
                                  .Commit();

            //Find the Arkivdel by id
            //By default the service will return null values for all screened fields of screened objects
            //To see the values of screened fields call SetPublicUse(false)
            var queryResults = client.Query <Arkivdel>("id=@arkivdelId", 10)
                               .AddQueryParam("@arkivdelId", arkivdel.Id)
                               .Execute();

            Console.WriteLine($"Found {queryResults.Results.Count()} Arkivdel object(s) with Id {arkivdel.Id}");

            //Print a screened field:
            arkivdel = queryResults.Results.First();
            Console.WriteLine($"Tittel of Arkivdel is masked: {arkivdel.Tittel}");

            //For convenience, objects in query and transaction responses contain the id's of many-to-one reference fields
            Console.WriteLine($"Arkivdel.RefArkiv: {arkivdel.RefArkiv}");
            Console.WriteLine($"Arkivdel.RefPrimaerKlassifikasjonssystem: {arkivdel.RefPrimaerKlassifikasjonssystem}");

            //Create two other Klassifikasjonssystem objects and link them to the Arkivdel as secondary Klassifikasjonssystem
            var sekundaerKlassifikasjonssystemSkole         = new Klassifikasjonssystem("Skole");
            var klasseInSekundaerKlassifikasjonssystemSkole = new Klasse("07", "Report");
            var sekundaerKlassifikasjonssystem2             = new Klassifikasjonssystem("EOP");

            transactionResponse = client.Transaction()
                                  .Save(sekundaerKlassifikasjonssystemSkole)
                                  .Save(klasseInSekundaerKlassifikasjonssystemSkole)
                                  .Link(sekundaerKlassifikasjonssystemSkole.LinkKlasse(klasseInSekundaerKlassifikasjonssystemSkole))
                                  .Save(sekundaerKlassifikasjonssystem2)
                                  .Link(arkivdel.LinkSekundaerKlassifikasjonssystem(sekundaerKlassifikasjonssystemSkole,
                                                                                    sekundaerKlassifikasjonssystem2))
                                  .Commit();

            //We need the id of the saved Klasse for the next transactions
            var sekundaerKlasseId =
                transactionResponse.Saved[klasseInSekundaerKlassifikasjonssystemSkole.Id].Id;

            //Create a new administrativEnhet value
            AdministrativEnhet newAdministrativEnhet =
                new AdministrativEnhet(Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
            AdministrativEnhet administrativEnhet = client.PutCodeListValue(newAdministrativEnhet);

            //Create a new Saksmappe in the Arkivdel
            //The new Saksmappe needs to have a Klasse in the primary Klassifikasjonssystem of the Arkivdel
            //Also link the Saksmappe to a secondary Klasse
            var newSaksmappe = new Saksmappe("Tilbud (Smith, John)", administrativEnhet);
            var newSakspart  = new Sakspart("Alice", "internal");

            var savedObjects = client.Transaction()
                               .Save(newSaksmappe)
                               .Link(newSaksmappe.LinkArkivdel(arkivdel))
                               .Link(newSaksmappe.LinkPrimaerKlasse(klasseId))
                               .Link(newSaksmappe.LinkSekundaerKlasse(sekundaerKlasseId))
                               .Save(newSakspart)
                               .Link(newSaksmappe.LinkSakspart(newSakspart))
                               .Commit()
                               .Saved;

            var saksmappe = savedObjects[newSaksmappe.Id] as Saksmappe;

            Console.WriteLine($"Created Saksmappe: Id={saksmappe.Id}, Saksdato: {saksmappe.Saksdato}");

            //Create another Klasse
            //Unlink the Saksmappe from its Klasse and link it to the new Klasse
            var anotherKlasse = new Klasse("02", "Klage");

            client.Transaction()
            .Save(anotherKlasse)
            .Link(anotherKlasse.LinkKlassifikasjonssystem(klassifikasjonssystemId))
            .Unlink(saksmappe.UnlinkPrimaerKlasse(klasseId))
            .Link(saksmappe.LinkPrimaerKlasse(anotherKlasse))
            .Commit();
            Console.WriteLine(
                $"Unlinked Saksmappe wiht Id {saksmappe.Id} from Klasse '{newKlasse.Tittel}' and linked it to Klasse '{anotherKlasse.Tittel}'");

            //Find all available codes for journalstatus in Journalpost
            var journalstatusCodeList = client.CodeLists(type: "Journalpost", field: "journalstatus").First();

            Console.WriteLine($"CodeList list for {journalstatusCodeList.Type}.{journalstatusCodeList.Field}:");
            foreach (var code in journalstatusCodeList.Values)
            {
                Console.WriteLine($"    Code={code.Code}, Name={code.Name}");
            }

            //Create a new Journalpost in the Saksmappe
            //Create an EksternId object and link it to the Journalpost
            //Create a new Korrespondansepart and link it to the Journalpost
            //Create a Noekkelord (keyword) object and link it to the Journalpost
            var newJournalpost = new Journalpost("Tilbud (Smith, John, Godkjent)", Journalposttype.UTGAAENDE_DOKUMENT)
            {
                Journalaar           = 2007,
                Journalsekvensnummer = 46
            };

            var newEksternId          = new EksternId("External System", Guid.NewGuid().ToString());
            var newKorrespondansepart = new Korrespondansepart(Korrespondanseparttype.INTERN_MOTTAKER, "John Smith");
            var newNoekkelord         = new Noekkelord("keyword");

            savedObjects = client.Transaction()
                           .Save(newJournalpost)
                           .Link(newJournalpost.LinkMappe(saksmappe))
                           .Save(newEksternId)
                           .Link(newJournalpost.LinkEksternId(newEksternId))
                           .Save(newKorrespondansepart)
                           .Link(newJournalpost.LinkKorrespondansepart(newKorrespondansepart))
                           .Save(newNoekkelord)
                           .Link(newNoekkelord.LinkRegistrering(newJournalpost))
                           .Commit()
                           .Saved;

            var journalPost = savedObjects[newJournalpost.Id] as Journalpost;

            Console.WriteLine(
                $"Created Journalpost: Id={journalPost.Id}, Tittel={journalPost.Tittel}, Journalstatus={journalPost.Journalstatus.Code}");

            //Find the Journalpost by the eksternID value
            var journalpstQueryResults = client.Query <Journalpost>("refEksternId.eksternID=@eksternId", 10)
                                         .AddQueryParam("@eksternId", newEksternId.EksternID)
                                         .Execute();

            Console.WriteLine(
                $"Found {journalpstQueryResults.Results.Count()} Journalpost objects with eksternID {newEksternId.EksternID}");

            //Upload a file
            Dokumentfil dokumentfil;

            using (var inputStream = File.OpenRead(testDoc))
            {
                dokumentfil = client.Upload(inputStream, "godkjenning.pdf");
            }
            Console.WriteLine($"Uploaded file {testDoc}");

            //Create a new value for Dokumenttype
            Dokumenttype newDokumenttype = new Dokumenttype(Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
            Dokumenttype dokumenttype    = client.PutCodeListValue(newDokumenttype);

            //Create a new Dokument and Dokumentversjon using the uploaded file
            var newDokument = new Dokument(dokumenttype, "Tilbud (Smith, John, Godkjent)",
                                           TilknyttetRegistreringSom.HOVEDDOKUMENT);
            var newDokumentversjon = new Dokumentversjon(Variantformat.PRODUKSJONSFORMAT, ".pdf", dokumentfil);

            savedObjects = client.Transaction()
                           .Save(newDokument)
                           .Link(newDokument.LinkRegistrering(journalPost))
                           .Save(newDokumentversjon)
                           .Link(newDokumentversjon.LinkDokument(newDokument))
                           .Commit()
                           .Saved;

            var dokumentversjon = savedObjects[newDokumentversjon.Id] as Dokumentversjon;

            Console.WriteLine(
                $"Created Dokumentversjon: Id={dokumentversjon.Id}, Versjonsnummer: {dokumentversjon.Versjonsnummer}, Filstoerrelse: {dokumentversjon.Filstoerrelse}");

            //Download the Dokumentversjon file
            var downloadPath = Path.GetTempFileName();

            using (var outputStream = File.Create(downloadPath))
            {
                client.Download(dokumentversjon.Dokumentfil, outputStream);
            }
            Console.WriteLine($"Downloaded file {downloadPath}");

            //Find all dokument objects in a Saksmappe called "Tilbud (Smith, John)"
            //Results should be ordered by creation date in descending order
            var queryResponse = client.Query <Dokument>("refRegistrering.refMappe.tittel=@saksmappeTittel", 50)
                                .AddQueryParam("@saksmappeTittel", "Tilbud (Smith, John)")
                                .AddSortOrder("opprettetDato", Order.Descending)
                                .Execute();

            Console.WriteLine(
                $"Query returned {queryResponse.Results.Count()} Dokument objects in Saksmappe objects called 'Tilbud (Smith, John)'");
            Console.WriteLine($"More results available: {queryResponse.HasMore}");

            //Delete the DokumentVersjon by id
            client.Transaction().Delete <Dokumentversjon>(dokumentversjon.Id).Commit();
            Console.WriteLine($"Deleted Dokumentversjon with Id {dokumentversjon.Id}");
            Console.WriteLine();
        }
예제 #5
0
        private static void BusinessSpecificMetadataSample()
        {
            string GROUP_ID        = $"gr-{Guid.NewGuid().ToString()}";
            string STRING_FIELD_ID = $"f-{Guid.NewGuid().ToString()}";
            string DOUBLE_FIELD_ID = $"f-{Guid.NewGuid().ToString()}";
            string LONG_FIELD_ID   = $"f-{Guid.NewGuid().ToString()}";

            //Create a business-specific metadata group
            MetadataGroupInfo newGroup   = new MetadataGroupInfo(GROUP_ID, "BSM Group Name", "BSM Group Description");
            MetadataGroupInfo savedGroup = client.PutBsmGroup(newGroup);

            Console.WriteLine(
                $"Created new group: GroupId={savedGroup.GroupId}, GroupDescription={savedGroup.GroupDescription}, GroupName={savedGroup.GroupName}");
            Console.WriteLine();

            //Create a new string field with predefined values "value 1", "value 2" and "value 3"
            MetadataFieldInfo newFieldStr = new MetadataFieldInfo(STRING_FIELD_ID, "BSM Field String",
                                                                  "BSM Field Description", FieldType.String, new List <object>()
            {
                "value 1", "value 2", "value 3"
            });
            MetadataFieldInfo savedFieldStr = client.PutBsmField(GROUP_ID, newFieldStr);

            Console.WriteLine(
                $"Created new field: FieldId={savedFieldStr.FieldId}, FieldType={savedFieldStr.FieldType}, FieldName={savedFieldStr.FieldName}, FieldValues={string.Join(",", savedFieldStr.FieldValues)}");
            Console.WriteLine();

            //Create a new long field with predefined values 1 and 2
            MetadataFieldInfo newFieldLong = new MetadataFieldInfo(LONG_FIELD_ID, "BSM Field Long",
                                                                   "BSM Field Description", FieldType.Long, new List <object>()
            {
                1L, 2L
            });
            MetadataFieldInfo savedFieldLong = client.PutBsmField(GROUP_ID, newFieldLong);

            Console.WriteLine(
                $"Created new field: FieldId={savedFieldLong.FieldId}, FieldType={savedFieldLong.FieldType}, FieldName={savedFieldLong.FieldName}, FieldValues={string.Join(",", savedFieldLong.FieldValues)}");

            //Create a new double field with no predefined values
            MetadataFieldInfo newFieldDouble = new MetadataFieldInfo(DOUBLE_FIELD_ID, "BSM Field Double",
                                                                     "BSM Field Description", FieldType.Double);
            MetadataFieldInfo savedFielDouble = client.PutBsmField(GROUP_ID, newFieldDouble);

            Console.WriteLine(
                $"Created new field: FieldId={newFieldDouble.FieldId}, FieldType={newFieldDouble.FieldType}, FieldName={newFieldDouble.FieldName}");
            Console.WriteLine();

            //Update string field - add new field value, remove an old one
            savedFieldStr.FieldValues.Add("value 4");
            savedFieldStr.FieldValues.Remove("value 3");
            MetadataFieldInfo updatedField = client.PutBsmField(GROUP_ID, savedFieldStr);

            Console.WriteLine(
                $"Updated field: FieldId={updatedField.FieldId}, FieldType={updatedField.FieldType}, FieldName={updatedField.FieldName}, FieldValues={string.Join(",", updatedField.FieldValues)}");
            Console.WriteLine();

            //Get the business-specific metadata registry for a specific group
            BusinessSpecificMetadataInfo metadataInfo = client.BsmRegistry(GROUP_ID);

            Console.WriteLine("BusinessSpecificMetadataInfo:");
            //Print the registry for this group
            foreach (MetadataGroupInfo groupInfo in metadataInfo.Groups)
            {
                Console.WriteLine(
                    $"GroupInfo: GroupId={groupInfo.GroupId}, GroupName={groupInfo.GroupName}");
                foreach (MetadataFieldInfo fieldInfo in groupInfo.Fields)
                {
                    Console.WriteLine(
                        $" ---- FieldInfo: FieldId={fieldInfo.FieldId}, FieldType={fieldInfo.FieldType}, FieldName={fieldInfo.FieldName}");
                }
            }
            Console.WriteLine("--------------------------------------------------------------------------");
            Console.WriteLine();

            //Create an Arkiv, Arkivdel and one Mappe
            //Set VirksomhetsspesifikkeMetadata for the Mappe
            var arkivskaper = new Arkivskaper("B67", "Jack Smith");
            var arkiv       = new Arkiv("Arkiv - VirksomhetsspesifikkeMetadata Example");
            var arkivdel    = new Arkivdel("Arkivdel - VirksomhetsspesifikkeMetadata Example");

            var mappe = new Mappe("Mappe with VirksomhetsspesifikkeMetadata");

            //Add three meta-data fields to the Mappe:
            mappe.VirksomhetsspesifikkeMetadata.AddBsmFieldValues(GROUP_ID, STRING_FIELD_ID, "value 1",
                                                                  "value 2");
            mappe.VirksomhetsspesifikkeMetadata.AddBsmFieldValues(GROUP_ID, DOUBLE_FIELD_ID, 1.2);
            mappe.VirksomhetsspesifikkeMetadata.AddBsmFieldValues(GROUP_ID, LONG_FIELD_ID, 2L);

            var transactionResponse = client.Transaction()
                                      .Save(arkiv)
                                      .Save(arkivskaper)
                                      .Link(arkiv.LinkArkivskaper(arkivskaper))
                                      .Save(arkivdel)
                                      .Link(arkivdel.LinkArkiv(arkiv))
                                      .Save(mappe)
                                      .Link(mappe.LinkArkivdel(arkivdel))
                                      .Commit();

            //Get the saved Mappe
            mappe = transactionResponse.Saved[mappe.Id] as Mappe;

            //Print the VirksomhetsspesifikkeMetadata of the Mappe
            Console.WriteLine("Added VirksomhetsspesifikkeMetadata to folder:");
            BsmGroupsMap groupsMap = mappe.VirksomhetsspesifikkeMetadata;

            foreach (var groupId in groupsMap.Keys)
            {
                BsmFieldsMap fieldsMap = mappe.VirksomhetsspesifikkeMetadata[groupId];
                foreach (var fieldId in fieldsMap.Keys)
                {
                    BsmFieldValues values = fieldsMap[fieldId];
                    Console.WriteLine(
                        $"GroupId={groupId}, FieldId={fieldId}, ValueType={values.Type}, Values=[{string.Join(",", values.Values)}]");
                }
            }
            Console.WriteLine();

            //Update the VirksomhetsspesifikkeMetadata of the Mappe

            //Add one more string value to the string field

            //To add a new field value, simply add it to the set of values of the particular field
            //Use the "AddBsmFieldValues" method, if you want to override the existing set of values with a new one
            mappe.VirksomhetsspesifikkeMetadata[GROUP_ID][STRING_FIELD_ID].Values.Add("value 4");

            //Remove one of the values of the double field
            mappe.VirksomhetsspesifikkeMetadata.DeleteBsmFieldValue(GROUP_ID, DOUBLE_FIELD_ID, 2.6);

            //Completely remove the long field
            mappe.VirksomhetsspesifikkeMetadata.DeleteBsmField(GROUP_ID, LONG_FIELD_ID);

            //It is also possible to remove a whole group:
            //mappe.VirksomhetsspesifikkeMetadata.DeleteBsmGroup(groupIdentfier);
            transactionResponse = client.Transaction()
                                  .Save(mappe)
                                  .Commit();

            //Make query to fetch the Mappe

            QueryResponse <Mappe> queryResponse = client.Query <Mappe>("id=@id", 1)
                                                  .AddQueryParam("@id", mappe.Id)
                                                  .Execute();

            mappe = queryResponse.Results.First();

            //Print the new VirksomhetsspesifikkeMetadata
            Console.WriteLine("Updated VirksomhetsspesifikkeMetadata of folder:");
            groupsMap = mappe.VirksomhetsspesifikkeMetadata;
            foreach (var groupId in groupsMap.Keys)
            {
                BsmFieldsMap fieldsMap = mappe.VirksomhetsspesifikkeMetadata[groupId];
                foreach (var fieldId in fieldsMap.Keys)
                {
                    BsmFieldValues values = fieldsMap[fieldId];
                    Console.WriteLine(
                        $"GroupId={groupId}, FieldId={fieldId}, ValueType={values.Type}, Values=[{string.Join(",", values.Values)}]");
                }
            }

            Console.WriteLine();


            //Delete field
            client.DeleteBsmField(GROUP_ID, LONG_FIELD_ID);
            Console.WriteLine($"Deleted field with  FieldId={LONG_FIELD_ID}");
            Console.WriteLine();

            //Delete folder
            client.Transaction().Delete(mappe).Commit();
            Console.WriteLine($"Deleted folder");
            Console.WriteLine();

            //Delete group
            client.DeleteBsmGroup(GROUP_ID);
            Console.WriteLine($"Deleted group with GroupId={GROUP_ID}");
            Console.WriteLine();
        }
예제 #6
0
        private static void MeetingAndBoardHandlingDataSample()
        {
            Console.WriteLine($"Meeting and board handling data example {Environment.NewLine}");

            //Create a new Arkiv with an Arkivskaper
            //Create a new Arkivdel in the Arkiv
            var newArkivskaper = new Arkivskaper("B7-23-W5", "John Smith");
            var newArkiv       = new Arkiv("Arkiv");
            var newArkivdel    = new Arkivdel("2007/8");

            var transactionResponse = client.Transaction()
                                      .Save(newArkiv)
                                      .Save(newArkivskaper)
                                      .Save(newArkivdel)
                                      .Link(newArkiv.LinkArkivskaper(newArkivskaper))
                                      .Link(newArkivdel.LinkArkiv(newArkiv))
                                      .Commit();

            var arkiv = transactionResponse.Saved[newArkiv.Id] as Arkiv;

            Console.WriteLine(
                $"Created Arkiv: Id={arkiv.Id}, Arkivstatus={arkiv.Arkivstatus.Code}, OpprettetDato={arkiv.OpprettetDato}");

            var arkivdel = transactionResponse.Saved[newArkivdel.Id] as Arkivdel;

            Console.WriteLine($"Created Arkivdel: Id={arkivdel.Id}, Arkivdelstatus={arkivdel.Arkivdelstatus.Code}");

            //Create a new Moetemappe and Moetedeltaker
            Moetemappe    newMappe      = new Moetemappe("Moetemappe Tittel", "Moetenummer", "Utvalg");
            Moetedeltaker moetedeltaker = new Moetedeltaker("Moetedeltaker Navn");

            transactionResponse = client.Transaction()
                                  .Save(newMappe)
                                  .Link(newMappe.LinkArkivdel(arkivdel))
                                  .Save(moetedeltaker)
                                  .Link(moetedeltaker.LinkMappe(newMappe))
                                  .Commit();

            var mappe = transactionResponse.Saved[newMappe.Id] as Moetemappe;

            Console.WriteLine($"Created Mappe: Id={mappe.Id}, Tittel={mappe.Tittel}");
            Console.WriteLine($"Created Moetedeltaker: Navn={moetedeltaker.Navn}");

            //Create a new AdministrativEnhett code list value
            AdministrativEnhet newAdministrativEnhet =
                new AdministrativEnhet(Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
            AdministrativEnhet administrativEnhet = client.PutCodeListValue(newAdministrativEnhet);

            //Create a new Moeteregistrering
            Moeteregistrering newMoeteregistrering = new Moeteregistrering("Tittel", "Saksbehandler",
                                                                           administrativEnhet, Moeteregistreringstype.MOETEINNKALLING);

            transactionResponse = client.Transaction()
                                  .Save(newMoeteregistrering)
                                  .Link(newMoeteregistrering.LinkMappe(mappe))
                                  .Commit();

            var moeteregistrering = transactionResponse.Saved[newMoeteregistrering.Id] as Moeteregistrering;

            Console.WriteLine(
                $"Created Moeteregistrering: Id={moeteregistrering.Id}, Tittel={moeteregistrering.Tittel}");
            ;

            //Upload a file
            Dokumentfil dokumentfil;

            using (var inputStream = File.OpenRead(testDoc))
            {
                dokumentfil = client.Upload(inputStream, "godkjenning.pdf");
            }
            Console.WriteLine($"Uploaded file {testDoc}");

            //Create a new Dokumenttype code list value
            Dokumenttype newDokumenttype = new Dokumenttype(Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
            Dokumenttype dokumenttype    = client.PutCodeListValue(newDokumenttype);

            //Link the Dokument to the Moeteregistrering
            var newDokument = new Dokument(dokumenttype, "Tilbud (Smith, John, Godkjent)",
                                           TilknyttetRegistreringSom.HOVEDDOKUMENT);
            var newDokumentversjon = new Dokumentversjon(Variantformat.PRODUKSJONSFORMAT, ".pdf", dokumentfil);

            transactionResponse = client.Transaction()
                                  .Save(newDokument)
                                  .Link(newDokument.LinkRegistrering(moeteregistrering))
                                  .Save(newDokumentversjon)
                                  .Link(newDokumentversjon.LinkDokument(newDokument))
                                  .Commit();

            var dokumentversjon = transactionResponse.Saved[newDokumentversjon.Id] as Dokumentversjon;

            Console.WriteLine(
                $"Created Dokumentversjon: Id={dokumentversjon.Id}, Versjonsnummer: {dokumentversjon.Versjonsnummer}, Filstoerrelse: {dokumentversjon.Filstoerrelse}");
            Console.WriteLine();
        }
예제 #7
0
        private static void ArchiveSample()
        {
            Console.WriteLine($"Archive example {Environment.NewLine}");

            //Create a new Arkiv with an Arkivskaper
            //Create a new Arkivdel in the Arkiv
            var newArkivskaper = new Arkivskaper("B7-23-W5", "John Smith");
            var newArkiv       = new Arkiv("Arkiv");
            var newArkivdel    = new Arkivdel("2007/8");

            var transactionResponse = client.Transaction()
                                      .Save(newArkiv)
                                      .Save(newArkivskaper)
                                      .Save(newArkivdel)
                                      .Link(newArkiv.LinkArkivskaper(newArkivskaper))
                                      .Link(newArkivdel.LinkArkiv(newArkiv))
                                      .Commit();

            var arkiv = transactionResponse.Saved[newArkiv.Id] as Arkiv;

            Console.WriteLine(
                $"Created Arkiv: Id={arkiv.Id}, Arkivstatus={arkiv.Arkivstatus.Code}, OpprettetDato={arkiv.OpprettetDato}");

            var arkivdel = transactionResponse.Saved[newArkivdel.Id] as Arkivdel;

            Console.WriteLine($"Created Arkivdel: Id={arkivdel.Id}, Arkivdelstatus={arkivdel.Arkivdelstatus.Code}");

            //Get all available values for the Mappetype code list
            var mappetypeList = client.CodeLists("Mappe", "mappetype").First();

            if (mappetypeList.Values.Count == 0)
            {
                Console.WriteLine(
                    "Can not create an instance of Mappe because there are not available values in the Mappetype code list!");
                return;
            }
            var mappetypeCode = mappetypeList.Values.First().Code;

            //Create a new Mappe
            var newMappe = new Mappe("Barnehage Tilbud")
            {
                Beskrivelse = "Mappe Beskrivelse",
                Mappetype   = new Mappetype(mappetypeCode)
            };

            transactionResponse = client.Transaction()
                                  .Save(newMappe)
                                  .Link(newMappe.LinkArkivdel(arkivdel))
                                  .Commit();

            var mappe = transactionResponse.Saved[newMappe.Id] as Mappe;

            Console.WriteLine($"Created Mappe: Id={mappe.Id}, Tittel: {mappe.Tittel}");

            //Create a child Mappe in the Mappe
            var newBarnMappe = new Mappe("Tilbud (Smith, John)");

            var savedObjects = client.Transaction()
                               .Save(newBarnMappe)
                               .Link(newBarnMappe.LinkForelderMappe(mappe))
                               .Commit()
                               .Saved;

            var barnMappe = savedObjects[newBarnMappe.Id] as Mappe;

            Console.WriteLine(
                $"Created a new Mappe (Id={barnMappe.Id}, Tittel={barnMappe.Tittel}) in Mappe with Id {mappe.Id}");

            //Find all children of the Mappe
            var queryResults = client.Query <Mappe>("refForelderMappe.id=@forelderMappeId", 10)
                               .AddQueryParam("@forelderMappeId", mappe.Id)
                               .Execute();

            Console.WriteLine($"Found {queryResults.Results.Count()} Mappe objects in Mappe with Id {mappe.Id}");

            //Create a new Basisregistrering in the child Mappe
            //Link one Korrespondansepart to the Basisregistrering
            var newBasisregistrering  = new Basisregistrering("Tilbud (Smith, John, Godkjent)");
            var newKorrespondansepart = new Korrespondansepart(Korrespondanseparttype.MOTTAKER, "John Smith");

            savedObjects = client.Transaction()
                           .Save(newBasisregistrering)
                           .Save(newKorrespondansepart)
                           .Link(newBasisregistrering.LinkMappe(barnMappe))
                           .Link(newBasisregistrering.LinkKorrespondansepart(newKorrespondansepart))
                           .Commit()
                           .Saved;

            var basisregistrering = savedObjects[newBasisregistrering.Id] as Basisregistrering;

            Console.WriteLine(
                $"Created Basisregistrering: Id={basisregistrering.Id}, Tittel={basisregistrering.Tittel}");

            //Upload a file
            Dokumentfil dokumentfil;

            using (var inputStream = File.OpenRead(testDoc))
            {
                dokumentfil = client.Upload(inputStream, "godkjenning.pdf");
            }
            Console.WriteLine($"Uploaded file {testDoc}");

            //Get available values for the Dokumenttype code list
            var dokumenttypeList = client.CodeLists("Dokument", "dokumenttype").First();

            if (dokumenttypeList.Values.Count == 0)
            {
                Console.WriteLine(
                    "Can not create an instance of Dokument because there are not available values in the Dokumenttype code list!");
                return;
            }
            var dokumenttypeCode = dokumenttypeList.Values.First().Code;

            //Create a new Dokument and Dokumentversjon using the uploaded file
            //Link the Dokument to the Basisregistrering
            var newDokument = new Dokument(new Dokumenttype(dokumenttypeCode), "Tilbud (Smith, John, Godkjent)",
                                           TilknyttetRegistreringSom.HOVEDDOKUMENT);
            var newDokumentversjon = new Dokumentversjon(Variantformat.PRODUKSJONSFORMAT, ".pdf", dokumentfil);

            savedObjects = client.Transaction()
                           .Save(newDokument)
                           .Link(newDokument.LinkRegistrering(basisregistrering))
                           .Save(newDokumentversjon)
                           .Link(newDokumentversjon.LinkDokument(newDokument))
                           .Commit()
                           .Saved;

            var dokumentversjon = savedObjects[newDokumentversjon.Id] as Dokumentversjon;

            Console.WriteLine(
                $"Created Dokumentversjon: Id={dokumentversjon.Id}, Versjonsnummer: {dokumentversjon.Versjonsnummer}, Filstoerrelse: {dokumentversjon.Filstoerrelse}");
        }
예제 #8
0
        public void Execute()
        {
            #region Set sample values

            string seriesTitle             = "Skole";
            string primaryClassTitle       = "Tilbud";
            string secondaryClassTitle     = "John Smith";
            string secondaryClassId        = "45-67771344-7";
            string administrativeUnit      = "Privat GSK";
            string screeningCode           = "UOFF";
            string documentType            = "Rapport";
            string caseFileTitle           = "John Smith - Test Skole";
            string caseFileExternalId      = "4551-54555";
            string caseResponsibleName     = "Maria Doe";
            string caseResponsibleId       = "3445555";
            string registryEntryTitle      = "Half-year report - 2019 - John Smith";
            string registryEntryExternalId = "45-67771344-7";

            #endregion

            // We assume that a series and a primary class already exist and we will just fetch them.
            // SystemInitializationSample.cs shows how to create these objects.
            Arkivdel series = GetSeriesByTitle(seriesTitle);

            if (series == null)
            {
                Console.WriteLine($"Did not find a series with title {seriesTitle}!");
                return;
            }

            Klasse primaryClass = GetClassByTitle(series.RefPrimaerKlassifikasjonssystem, primaryClassTitle);

            if (primaryClass == null)
            {
                Console.WriteLine($"Could not find a class with title {primaryClassTitle}!");
                return;
            }

            /* Now, we are going to fetch or create a secondary class.
             * A secondary class id and title might be a person's number and name, such as 12356 John Doe.
             * To fetch the secondary class we need to know in which secondary classification system the class resides.
             * A series can be linked to more than one secondary classification systems.
             * For simplicity, in this example we will randomly pick one of the series's secondary classification systems.
             */

            Klassifikasjonssystem secondaryClassificationSystem = GetSecondaryClassificationSystem(series.Id);

            if (secondaryClassificationSystem == null)
            {
                Console.WriteLine("Series does not have a secondary classification system!");
                return;
            }

            Klasse secondaryClass = GetClassByTitle(secondaryClassificationSystem.Id, secondaryClassTitle)
                                    ??
                                    CreateClass(secondaryClassificationSystem.Id, secondaryClassId,
                                                secondaryClassTitle);


            // We also need to find the code values used for the creation of an Archive structure.
            // SystemInitializationSample.cs shows how to create these code values.
            CodeValue administrativeUnitCodeValue = GetAdministrativeUnitByName(administrativeUnit);
            CodeValue screeningCodeValue          = GetScreeningCodeByName(screeningCode);
            CodeValue documentTypeCodeValue       = GetDocumentTypeByName(documentType);

            if (administrativeUnitCodeValue == null)
            {
                Console.WriteLine($"Could not find an administrative unit code value '{administrativeUnit}'!");
                return;
            }

            if (screeningCodeValue == null)
            {
                Console.WriteLine($"Could not find an screening code value '{seriesTitle}'!");
                return;
            }

            if (documentTypeCodeValue == null)
            {
                Console.WriteLine($"Could not find an document type code value '{documentType}'!");
                return;
            }

            SubmitData(series,
                       primaryClass,
                       secondaryClass,
                       new AdministrativEnhet(administrativeUnitCodeValue.Code),
                       new Skjerming(screeningCodeValue.Code),
                       new Dokumenttype(documentTypeCodeValue.Code),
                       caseFileTitle,
                       caseFileExternalId,
                       caseResponsibleName,
                       caseResponsibleId,
                       registryEntryTitle,
                       registryEntryExternalId);
        }
예제 #9
0
        private void SubmitData(
            Arkivdel series,
            Klasse primaryClass,
            Klasse secondaryClass,
            AdministrativEnhet administrativeUnit,
            Skjerming screeningCode,
            Dokumenttype documentType,
            string caseFileTitle,
            string caseFileExternalId,
            string caseResponsibleName,
            string caseResponsibleId,
            string registryEntryTitle,
            string registryEntryExternalId)
        {
            #region Case file

            Saksmappe caseFile = new Saksmappe(caseFileTitle, administrativeUnit)
            {
                Saksansvarlig            = caseResponsibleName,
                SaksansvarligBrukerIdent = caseResponsibleId
            };

            EksternId caseFileExternalIdObj = new EksternId(EXTERNAL_SYSTEM, caseFileExternalId);

            #endregion Case file

            #region Registry entry

            Journalpost registryEntry = new Journalpost(registryEntryTitle, Journalposttype.UTGAAENDE_DOKUMENT)
            {
                Skjerming = screeningCode
            };

            registryEntry.VirksomhetsspesifikkeMetadata.AddBsmFieldValues("gr-1", "f-string", "value 1");

            EksternId registryEntryExternalIdObj = new EksternId(EXTERNAL_SYSTEM, registryEntryExternalId);

            Korrespondansepart correspondenceParty =
                new Korrespondansepart(Korrespondanseparttype.AVSENDER, "John Smith");

            #endregion Registry entry

            #region Documents

            //Upload two files

            Dokumentfil mainFile       = UploadDocument(this.testFile1);
            Dokumentfil attachmentFile = UploadDocument(this.testFile2);

            //Link the first document description to the registry entry as main document (HOVEDDOKUMENT).
            //Subsequent document descriptions will be linked as attachments (VEDLEGG).

            Dokument mainDocumentDescription =
                new Dokument("Main Document", TilknyttetRegistreringSom.HOVEDDOKUMENT)
            {
                Dokumenttype = documentType,
            };

            Dokumentversjon mainDocumentVersion =
                new Dokumentversjon(Variantformat.ARKIVFORMAT, ".pdf", mainFile);

            Dokument attachmentDocumentDescription =
                new Dokument("Attachment", TilknyttetRegistreringSom.VEDLEGG)
            {
                Dokumenttype = documentType     //here might as well be used another type
            };

            Dokumentversjon attachmentDocumentVersion =
                new Dokumentversjon(Variantformat.ARKIVFORMAT, ".pdf", attachmentFile);

            #endregion Documents

            NoarkClient client = this.documasterClients.GetNoarkClient();

            TransactionResponse transactionResponse = client.Transaction()
                                                      .Save(caseFile)
                                                      .Link(caseFile.LinkArkivdel(series))
                                                      .Link(caseFile.LinkPrimaerKlasse(primaryClass))
                                                      .Link(caseFile.LinkSekundaerKlasse(secondaryClass))
                                                      .Save(caseFileExternalIdObj)
                                                      .Link(caseFileExternalIdObj.LinkMappe(caseFile))
                                                      .Save(registryEntry)
                                                      .Link(registryEntry.LinkMappe(caseFile))
                                                      .Save(correspondenceParty)
                                                      .Link(correspondenceParty.LinkRegistrering(registryEntry))
                                                      .Save(registryEntryExternalIdObj)
                                                      .Link(registryEntryExternalIdObj.LinkRegistrering(registryEntry))
                                                      .Save(mainDocumentDescription)
                                                      .Link(mainDocumentDescription.LinkRegistrering(registryEntry))
                                                      .Save(mainDocumentVersion)
                                                      .Link(mainDocumentVersion.LinkDokument(mainDocumentDescription))
                                                      .Save(attachmentDocumentDescription)
                                                      .Link(attachmentDocumentDescription.LinkRegistrering(registryEntry))
                                                      .Save(attachmentDocumentVersion)
                                                      .Link(attachmentDocumentVersion.LinkDokument(attachmentDocumentDescription))
                                                      .Commit();

            // When new objects are initialized, a temporary Id is assigned to them.
            // transactionResponse.Saved contains a mapping between the temporary id's and the saved objects with their permanent id's
            Dictionary <string, INoarkEntity> savedObjects = transactionResponse.Saved;

            string template = "{0}: Temporary Id: {1} Permanent Id: {2}";

            Console.WriteLine(String.Format(template, "Case file", caseFile.Id, savedObjects[caseFile.Id].Id));
            Console.WriteLine(String.Format(template, "Registry entry", registryEntry.Id,
                                            savedObjects[registryEntry.Id].Id));
            Console.WriteLine(String.Format(template, "Main document description", mainDocumentDescription.Id,
                                            savedObjects[mainDocumentDescription.Id].Id));
            Console.WriteLine(String.Format(template, "Attachment document description",
                                            attachmentDocumentDescription.Id, savedObjects[attachmentDocumentDescription.Id].Id));
        }