public void OrganisationKefUpdate(Organisation org, KefEventContainer kefEvents, DataTable kefMembers) { // check permission: Writer or Admin string writerRole = org.ID.Value.ToString() + ".Writer"; PrincipalPermission permWriter = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, writerRole); PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator"); permWriter.Union(permAdmin).Demand(); TraceCallEnterEvent.Raise(); try { // check required fields: if (org.Name.Length == 0) throw new ArgumentNullException("Organisation.Name", "A szervezet neve nincs megadva."); if (org.PostCode.Length == 0) throw new ArgumentNullException("Organisation.PostCode", "A szervezet címének irányítószáma nincs megadva."); if (org.City.Length == 0) throw new ArgumentNullException("Organisation.City", "A szervezet címének települése nincs megadva."); if (org.Address.Length == 0) throw new ArgumentNullException("Organisation.Address", "A szervezet címének utca, házszám része nincs megadva."); if (org.OrganisationFormRef.Length == 0) throw new ArgumentNullException("Organisation.OrganisationFormRef", "A szervezeti forma kódja nincs megadva."); if (org.WorkingAreaRef.Length == 0) throw new ArgumentNullException("Organisation.WorkingAreaRef", "A mûködési terület nincs megadva."); // logical checks: Organisation selected = base.OrganisationSelect(org.ID); if (selected == null) throw new ApplicationException("Ezzel az azonosítóval nem létezik szervezet."); NdiPrincipal principal = (NdiPrincipal) Thread.CurrentPrincipal; if (!selected.IsActive && !principal.IsInRole("Administrator")) throw new ApplicationException("A szervezet nem aktív."); // save data: org.IsActive = selected.IsActive; try { //elmentjük a szervezet módosított adatokat base.OrganisationUpdate(org); m_DataContext.BeginNestedTran(); //töröljük az összes kapcsolódó eseményt ... OrganisationService srvOrg = new OrganisationService(m_DataContext); KefEventService srvKefEvent = new KefEventService(m_DataContext); srvOrg.DeleteChildrenByOrganisationOfKefEvent(org.ID); //majd beszúrjuk az újakat foreach (KefEvent item in kefEvents.Current) { srvKefEvent.KefEventInsert(item); } //töröljük az összes kapcsolódó tagot ... srvOrg.DeleteChildrenByKefOrgOfOrg(org.ID); OrgMemberOfOrgService srvKefMember = new OrgMemberOfOrgService(m_DataContext); //majd beszúrjuk az újakat foreach (DataRow row in kefMembers.Rows) { OrgMemberOfOrg member = new OrgMemberOfOrg(Guid.NewGuid()); member.OrganisationKefRef = new Guid(row["uOrganisationKefRef"].ToString()); member.OrganisationMemberRef = new Guid(row["uOrganisationMemberRef"].ToString()); member.ContactName = row["cContactName"].ToString(); member.ContactInstitution = row["cContactInstitution"].ToString(); member.ContactZipCode = row["cContactZipCode"].ToString(); member.ContactTownShip = row["cContactTownShip"].ToString(); member.ContactAddress = row["cContactAddress"].ToString(); member.ContactPhone1 = row["cContactPhone1"].ToString(); member.ContactPhone2 = row["cContactPhone2"].ToString(); member.ContactPhone3 = row["cContactPhone3"].ToString(); member.ContactFax = row["cContactFax"].ToString(); member.ContactPosition = row["cContactPosition"].ToString(); member.ContactPositionInKef = row["cContactPositionInKef"].ToString(); member.ContactEmail1 = row["cContactEmail1"].ToString(); member.ContactEmail2 = row["cContactEmail2"].ToString(); member.ContactEmail3 = row["cContactEmail3"].ToString(); member.ContactQualification = row["cContactQualification"].ToString(); member.KefContactTypeRef = row["cKefContactTypeRef"].ToString(); srvKefMember.OrgMemberOfOrgInsert(member); } //elmentjük a szervezethez tartozó feltöltött fileokat OrganisationAttachmentService srvOrgAtt = new OrganisationAttachmentService(m_DataContext); // Clear old files: OrganisationAttachmentContainer oldFiles = base.SelectChildrenByAttachmentOfOrganisation(org.ID); foreach (OrganisationAttachment oldFile in oldFiles.All) { srvOrgAtt.OrganisationAttachmentDelete(oldFile); } foreach (OrganisationAttachment file in org.OrgAttachments.Current) { if(file.DownloadData != null) srvOrgAtt.OrganisationAttachmentInsert(file); } m_DataContext.CommitNested(); } catch { m_DataContext.RollbackNested(); throw; } BusinessAuditEvent.Success( new EventParameter("OrganisationID", org.ID.ToString()), new EventParameter("OrganisationName", org.Name) ); TraceCallReturnEvent.Raise(); return; } catch (Exception ex) { ExceptionManager.Publish(ex); BusinessAuditEvent.Fail( new EventParameter("Exception", ex.ToString()), new EventParameter("OrganisationID", org.ID.ToString()), new EventParameter("OrganisationName", org.Name) ); TraceCallReturnEvent.Raise(false); throw; } }
public virtual KefEventContainer KefEventSelectAll() { TraceCallEnterEvent.Raise(); try { KefEventContainer result; DataSet entitySet = m_DataContext.ndihdKefEventSelectAll(); result = new KefEventContainer(entitySet.Tables[0]); TraceCallReturnEvent.Raise(); return result; } catch (Exception ex) { ExceptionManager.Publish(ex); TraceCallReturnEvent.Raise(false); throw; } }
public KefEventContainer KefEventSelectFiltered(DBInt IsActive, Guid OrganisationRef) { TraceCallEnterEvent.Raise(); try { KefEventContainer result; DataSet entitySet = m_DataContext.ndihdKefEventSelectFiltered(IsActive, OrganisationRef); result = new KefEventContainer(entitySet.Tables[0]); TraceCallReturnEvent.Raise(); return result; } catch (Exception ex) { ExceptionManager.Publish(ex); TraceCallReturnEvent.Raise(false); throw; } }
public virtual KefEventContainer SelectChildrenByOrganisationOfKefEvent(DBGuid IDVal) { TraceCallEnterEvent.Raise(); try { KefEventContainer result; DataSet entitySet = m_DataContext.ndihdOrganisationOfKefEventSelectBy(IDVal); result = new KefEventContainer(entitySet.Tables[0]); TraceCallReturnEvent.Raise(); return result; } catch (Exception ex) { ExceptionManager.Publish(ex); TraceCallReturnEvent.Raise(false); throw; } }
// ------------------------------------------------------------------------------------- /// <summary> /// Fill edit window controls /// </summary> // ------------------------------------------------------------------------------------- private void RetrieveData() { try { // Get data IOrganisationService srv = ServiceFactory.GetOrganisationService(); IOrganisationAttachmentService srvOrgAtt = ServiceFactory.GetOrganisationAttachmentService(); Organisation org = srv.OrganisationSelect(CurrentID); #region KEF adatok txtOrganisationName.Text = org.Name; //txtPostCode.Text = org.PostCode; //txtCity.Text = org.City; //txtAddress.Text = org.Address; txtHomePage.Text = org.HomePage; txtEmail1.Text = org.Email1; txtEstYear.Text = org.EstablishmentYear.Trim(); txtEstMonth.Text = org.EstablishmentMonth.Trim(); cmbWorkingArea.SelectedValue = org.WorkingAreaRef.ToString(); cmbDistrictSearch.SelectedValue = org.DistrictSearchCodeRef.ToString(); cmbRegion.SelectedValue = org.RegionRef.ToString(); string regSearchCode = GetRegionSearchCode(org.RegionRef.ToString()); string regSearchDesc = ""; IRegionSearchService srvRegSearch = ServiceFactory.GetRegionSearchService(); RegionSearch regSearch = srvRegSearch.RegionSearchSelect(regSearchCode); txtRegionSearch.Text = GetRegionSearchCode(org.RegionRef.ToString()); regSearchDesc = regSearch.RegionDescription.Trim(); txtRegionSearch.Text = regSearchDesc; bIsActive = org.IsActive; cbxActivate.Checked = bIsActive; m_IsKef = org.IsKef; txtKefIntroduce.Text = org.IntroduceText; txtKefDrogStrategy.Text = org.DrogStrategyDescription; txtKefAreaDescription.Text = org.AreaDescription; txtAreaHomePage.Text = org.AreaHomePage.Trim(); #endregion #region KEF események m_CurrentKefEvents = srv.SelectChildrenByOrganisationOfKefEvent(org.ID); FillKefEventsDatagrid(DBGuid.Null); #endregion #region KEF tagok IOrgMemberOfOrgService srvKefMembers = ServiceFactory.GetOrgMemberOfOrgService(); m_CurrentKefMembers = srvKefMembers.KefOrgOfOrgSelectFiltered(org.ID, DBInt.Null); FillKefMembersDatagrid(); #endregion #region KEF drog stratégia - file-ok m_CurrentOrganisation = srv.OrganisationSelect(org.ID); m_CurrentOrganisation.OrgAttachments = srvOrgAtt.OrganisationAttachmentSelectFiltered(org.ID, true, true, false); foreach (OrganisationAttachment file in m_CurrentOrganisation.OrgAttachments.All) { OrganisationAttachment fileData = srvOrgAtt.OrganisationAttachmentSelectFile(file.ID); file.DownloadData = fileData.DownloadData; } FillKefFilesDatagrid(DBGuid.Null); #endregion } catch (Exception ex) { // --- Log exception ExceptionManager.Publish(ex); // --- Display Exception ErrorHandler.DisplayError("Hiba lépett fel az adatok lekérdezése során", ex); // --- invisible btnOk button btnOk.Visible = false; } }