public IEnumerable <Party> GetCaseParties(int CaseID) { List <Party> partyList = new List <Party>(); foreach (AcadreServiceV7.PartyType partyType in this.caseService.GetCase(CaseID.ToString()).Party) { AcadreServiceV7.PersonType2 contact = (AcadreServiceV7.PersonType2)contactService.GetContact(partyType.ContactReference); partyList.Add(new Party() { isPrimary = partyType.IsPrimarySpecified && partyType.IsPrimary, comment = partyType.PartyComment ?? "", contactGUI = partyType.ContactReference, role = partyType.PartyRelationTypeLiteral ?? "", CPR = contact.PersonCivilRegistrationIdentifier, name = string.Join(" ", ((IEnumerable <string>)contact.PersonNameStructure.PersonGivenName).Concat(contact.PersonNameStructure.PersonMiddleName).Concat(contact.PersonNameStructure.PersonSurnameName).Where(x => x != "")) }); } return(partyList); }
private AcadreServiceV7.ContactSearchResponseType GetCreateAcadreContact(string CPR) { var Contact = new AcadreServiceV7.ContactSearchResponseType(); Contact.ContactTypeName = "Person"; var searchContactCriterion = new AcadreServiceV7.SearchContactCriterionType2(); searchContactCriterion.ContactTypeName = "Person"; searchContactCriterion.SearchTerm = CPR; var foundContacts = contactService.SearchContacts(searchContactCriterion); if (foundContacts.Length > 0) { // contact already exists, read GUID and name Contact = foundContacts.First(); } else { // forsøger at finde CPR i CPR Broker SimplePerson simplePerson; try { simplePerson = CPRBrokerService.GetSimplePersonByCPR(CPR); } catch (Exception e) { throw new Exception("CPR-nummeret (" + CPR + ") kunne ikke findes i CPR-registret", e); } // contact doesn't exist - create it and assign GUID var contact = new AcadreServiceV7.PersonType2(); contact.PersonCivilRegistrationIdentifierStatusCode = "0"; contact.PersonCivilRegistrationIdentifier = CPR; contact.PersonNameForAddressingName = Contact.ContactTitle = simplePerson.FullName; Contact.GUID = contactService.CreateContact(contact); } return(Contact); }
/// <summary> /// /// </summary> /// <param name="personNameForAddressingName"></param> /// <param name="personCivilRegistrationNumber"></param> /// <param name="caseFileTypeCode"></param> /// <param name="accessCode"></param> /// <param name="caseFileTitleText"></param> /// <param name="journalizingCode"></param> /// <param name="facet"></param> /// <param name="caseResponsible"></param> /// <param name="administrativeUnit"></param> /// <param name="caseContent"></param> /// <param name="caseFileDisposalCode"></param> /// <param name="deletionCode"></param> /// <param name="caseRestrictedFromPublicText"></param> /// <returns></returns> public static string CreateCase( /* Case party's name */ string personNameForAddressingName, /* Case party's CPR number */ string personCivilRegistrationNumber, /* Case type. One of the following: * "EMSAG" (emnesag) * "BGSAG" (borgersag) * "EJSAG" (ejendomssag) * "PERSAG" (personalesag) * "BYGGESAG" (byggesag) */ string caseFileTypeCode, /* Security code. One of the following: * "BO" (borgersag) * "KK" (kommunekode) * "LP" (lukket punkt) * "PP" (personpunkt) */ string accessCode, /* Case title */ string caseFileTitleText, /* KLE journalizing code (http://www.kle-online.dk/emneplan/00/) */ string journalizingCode, /* KLE facet for the specified journalizing code */ string facet, /* Username of the user creating this case; get from Active Directory * (the AcadreServiceFactory.GetConfigurationService7().GetUserList(...) method will * return a full list) */ string caseResponsible, /* Identifier of the administrative unit; should probably be "80" for "Løn og personale" * (the AcadreServiceFactory.GetConfigurationService7().GetAdminUnitList(...) method * will return a full list) */ string administrativeUnit, /* Case content */ string caseContent, /* Discard code. One of the following(?): * "B" (bevares), * "K" (kasseres), * "K5" (kasseres efter 5 år), * "K10" (kasseres efter 10 år) * "K20" (kasseres efter 20 år) */ string caseFileDisposalCode, /* Deletion code; "P1800D" seems to be the standard value here */ string deletionCode, string caseRestrictedFromPublicText ) { var caseService = Acadre.AcadreServiceFactory.GetCaseService7(); var contactService = Acadre.AcadreServiceFactory.GetContactService7(); var configurationService = Acadre.AcadreServiceFactory.GetConfigurationService7(); // look up contact by cprnumber var searchContactCriterion = new AcadreServiceV7.SearchContactCriterionType2(); searchContactCriterion.ContactTypeName = "Person"; searchContactCriterion.SearchTerm = personCivilRegistrationNumber; AcadreServiceV7.ContactSearchResponseType[] foundContacts = contactService.SearchContacts(searchContactCriterion); string contactGUID; if (foundContacts.Length > 0) { // contact already exists, read GUID and name contactGUID = foundContacts.First().GUID; } else { // contact doesn't exist - create it and assign GUID var contact = new AcadreServiceV7.PersonType2(); contact.PersonCivilRegistrationIdentifierStatusCode = "0"; contact.PersonCivilRegistrationIdentifier = personCivilRegistrationNumber; contact.PersonNameForAddressingName = personNameForAddressingName; contactGUID = contactService.CreateContact(contact); } // create the case var createCaseRequest = new AcadreServiceV7.CreateCaseRequestType(); AcadreServiceV7.CaseFileType3 caseFile = new AcadreServiceV7.CaseFileType3(); caseFile.CaseFileTypeCode = caseFileTypeCode; caseFile.Year = DateTime.Now.Year.ToString(); caseFile.CreationDate = DateTime.Now; caseFile.CaseFileTitleText = personCivilRegistrationNumber; // must be set to contact cpr number for BGSAG caseFile.TitleUnofficialIndicator = false; caseFile.TitleAlternativeText = personNameForAddressingName; // must be set to contact name for BGSAG caseFile.RestrictedFromPublicText = caseRestrictedFromPublicText; caseFile.CaseFileStatusCode = "B"; caseFile.CaseFileDisposalCode = caseFileDisposalCode; caseFile.DeletionCode = deletionCode; caseFile.AccessCode = accessCode; caseFile.AdministrativeUnit = new AcadreServiceV7.AdministrativeUnitType[] { new AcadreServiceV7.AdministrativeUnitType() { AdministrativeUnitReference = administrativeUnit } }; caseFile.CustomFieldCollection = new AcadreServiceV7.CustomField[] { new AcadreServiceV7.CustomField() { Name = "df1", Value = caseContent } , new AcadreServiceV7.CustomField() { Name = "df25", Value = contactGUID } }; caseFile.Classification = new AcadreServiceV7.ClassificationType { Category = new AcadreServiceV7.CategoryType[] { new AcadreServiceV7.CategoryType() { Principle = "KL Koder", Literal = journalizingCode } , new AcadreServiceV7.CategoryType() { Principle = "Facetter", Literal = facet } } }; caseFile.Party = new AcadreServiceV7.PartyType[] { new AcadreServiceV7.PartyType() { CreationDate = DateTime.Now , ContactReference = contactGUID , PublicAccessLevelReference = "3" , IsPrimary = true } }; var userList = configurationService.GetUserList( new AcadreServiceV7.EmptyRequestType()).ToList(); var user = userList.SingleOrDefault(u => u.Initials == caseResponsible); if (user != null) { caseFile.CaseFileManagerReference = user.Id; } createCaseRequest.CaseFile = caseFile; var createCaseResponse = caseService.CreateCase(createCaseRequest); // check for multicase (samlesag) response. if (createCaseResponse.CreateCaseAndAMCResult == AcadreServiceV7.CreateCaseAndAMCResultType.CaseNotCreatedAndListAMCReceived) { // create the case in all the multicases createCaseRequest.MultiCaseIdentifiers = createCaseResponse.MultiCaseIdentifiers; createCaseResponse = createCaseResponse = caseService.CreateCase(createCaseRequest); } return(createCaseResponse.CaseFileIdentifier); }