public void ProgramAttachmentInactivate(DBGuid IdVal) { // check permission: admin PrincipalPermission permReg = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Registered"); PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator"); permReg.Union(permAdmin).Demand(); ProgramAttachment selected = base.ProgramAttachmentSelect(IdVal); if (selected == null) throw new ApplicationException("A megadott azonosítóval nem létezik csatolt fájl."); ProgramService progSrv = new ProgramService(); Program selectedProgram = progSrv.ProgramSelect(selected.ProgramRef); if (selectedProgram == null) throw new ApplicationException("A megadott azonosítóval nem létezik program."); string writerRole = selectedProgram.OrganisationRef.Value.ToString() + ".Writer"; PrincipalPermission permWriter = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, writerRole); permWriter.Union(permAdmin).Demand(); TraceCallEnterEvent.Raise(); try { // save data selected.IsActive = false; base.ProgramAttachmentUpdate(selected); BusinessAuditEvent.Success( new EventParameter("ProgramAttachmentID", IdVal.ToString()), new EventParameter("ProgramAttachmentName", selected.Name), new EventParameter("ProgramID", selected.ProgramRef.ToString()) ); TraceCallReturnEvent.Raise(); return; } catch (Exception ex) { ExceptionManager.Publish(ex); BusinessAuditEvent.Fail( new EventParameter("Exception", ex.ToString()), new EventParameter("ProgramAttachmentID", IdVal.ToString()) ); TraceCallReturnEvent.Raise(false); throw; } }
public new void ProgramPartnerDelete(ProgramPartner entity) { TraceCallEnterEvent.Raise(); try { // logical checks: ProgramService progSrv = new ProgramService(); Program selected = progSrv.ProgramSelect(entity.ProgramRef); if (selected == null) throw new ApplicationException("Ezzel az azonosítóval nem létezik program."); if (!selected.IsActive) throw new ApplicationException("A program nem aktív."); // check permission: Writer or Admin string writerRole = selected.OrganisationRef.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(); // save data: base.ProgramPartnerDelete(entity); BusinessAuditEvent.Success( new EventParameter("ProgramID", entity.ProgramRef.ToString()), new EventParameter("OrganisationID", entity.OrganisationRef.ToString()) ); TraceCallReturnEvent.Raise(); return; } catch (Exception ex) { ExceptionManager.Publish(ex); BusinessAuditEvent.Fail( new EventParameter("Exception", ex.ToString()), new EventParameter("ProgramID", entity.ProgramRef.ToString()), new EventParameter("OrganisationID", entity.OrganisationRef.ToString()) ); TraceCallReturnEvent.Raise(false); throw; } }
public new void ProgramAttachmentUpdate(ProgramAttachment entity) { // check permission: admin, writer PrincipalPermission permReg = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Registered"); PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator"); permReg.Union(permAdmin).Demand(); TraceCallEnterEvent.Raise(); try { ProgramService progSrv = new ProgramService(); Program selectedProgram = progSrv.ProgramSelect(entity.ProgramRef); if (selectedProgram == null) throw new ApplicationException("A megadott azonosítóval nem létezik program."); string writerRole = selectedProgram.OrganisationRef.Value.ToString() + ".Writer"; PrincipalPermission permWriter = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, writerRole); permWriter.Union(permAdmin).Demand(); // check required fields: if (entity.Name.Length == 0) throw new ArgumentNullException("ProgramAttachment.Name", "A csatolt fájl neve nincs megadva."); if (entity.Description.Length == 0) throw new ArgumentNullException("ProgramAttachment.Description", "A csatolt fájl leírása nincs megadva."); ProgramAttachment selected = base.ProgramAttachmentSelect(entity.ID); if (selected == null) throw new ApplicationException("A csatolt dokumentum nem létezik."); if (!selected.IsActive) throw new ApplicationException("A csatolt dokumentum nem aktív."); // save data if (entity.FileData != null && entity.FileData.Length > 0) { if (entity.Path.Length == 0 || entity.Path == DBString.Null) throw new ArgumentNullException("ProgramAttachment.Path", "A fájlnév nincs megadva."); ProgramAttachment newAttachment = new ProgramAttachment(Guid.NewGuid(), entity); string fileName = newAttachment.ID.Value.ToString() + Path.GetExtension(newAttachment.Path); FileDataContext fileDataContext = new FileDataContext(); fileDataContext.ProgramAttachmentInsert(newAttachment.ProgramRef, fileName, entity.FileData); newAttachment.CreatedDate = DBDateTime.Now; newAttachment.IsActive = true; newAttachment.FileSize = entity.FileData.Length; selected.IsActive = false; m_DataContext.BeginNestedTran(); try { base.ProgramAttachmentInsert(newAttachment); base.ProgramAttachmentUpdate(selected); m_DataContext.CommitNested(); } catch { m_DataContext.RollbackNested(); throw; } } else { selected.Name = entity.Name; selected.Description = entity.Description; selected.Author = entity.Author; selected.Publisher = entity.Publisher; selected.PublishedYear = entity.PublishedYear; selected.Keywords = entity.Keywords; base.ProgramAttachmentUpdate(selected); } BusinessAuditEvent.Success( new EventParameter("ProgramAttachmentID", entity.ID.ToString()), new EventParameter("ProgramAttachmentName", entity.Name), new EventParameter("ProgramID", entity.ProgramRef.ToString()) ); TraceCallReturnEvent.Raise(); return; } catch (Exception ex) { ExceptionManager.Publish(ex); BusinessAuditEvent.Fail( new EventParameter("Exception", ex.ToString()), new EventParameter("ProgramAttachmentID", entity.ID.ToString()), new EventParameter("ProgramAttachmentName", entity.Name), new EventParameter("ProgramID", entity.ProgramRef.ToString()) ); TraceCallReturnEvent.Raise(false); throw; } }
public void PendingQuestionFormInsertForProgram(PendingQuestionForm entity) { TraceCallEnterEvent.Raise(); try { if (entity.ProgramID.IsNull) throw new ArgumentNullException("PendingQuestionForm.ProgramID", "A program azonosítója nincs megadva."); ProgramService programSrv = new ProgramService(m_DataContext); Program program = programSrv.ProgramSelect(entity.ProgramID); if (program == null) throw new ApplicationException("A megadott azonosítóval nem létezik program."); string writerRole = program.OrganisationRef.Value.ToString() + ".Writer"; PrincipalPermission permWriter = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, writerRole); permWriter.Demand(); // required: if (entity.TemplateRef.IsNull) throw new ArgumentNullException("PendingQuestionForm.TemplateRef", "A sablon azonosítója nincs megadva."); if (entity.Status.Length == 0) throw new ArgumentNullException("PendingQuestionForm.Status", "A státusz nincs megadva."); /* TODO módosításnál ez is kötelezõ: if(entity.QuestionFormRef.IsNull) throw new ArgumentNullException("PendingQuestionForm.QuestionFormRef", "Az eredeti kérdõív azonosítója nincs megadva."); */ // logical check: TemplateCategoryService templCatSrv = new TemplateCategoryService(m_DataContext); TemplateCategory templCat = templCatSrv.TemplateCategorySelect(entity.TemplateRef, program.ProgramCategoryRef); if (templCat == null) throw new ApplicationException("A megadott programhoz nem tölthetõ ki ez a sablon."); // ellenõrizzük, hogy nincs folyamatban ilyen kérdõív kitöltése: TemplateService srv = new TemplateService(m_DataContext); Template tmplCurrentPending = srv.TemplateSelectOfProgramPendingQuestionFormByTemplateID(program.ID, entity.TemplateRef); if (!tmplCurrentPending.Status.IsNull) { throw new ApplicationException("A kérdõív nem módosítható, mert a módosítás már folyamatban van."); } // set data: entity.SentBy = Thread.CurrentPrincipal.Identity.Name; entity.SentDate = DBDateTime.Now; entity.LastModifiedByUser = DBDateTime.Now; if (entity.Status == "UWD" || entity.Status == "NWD") entity.IsActual = true; else { entity.IsActual = false; } ProgramPendingQuestionForm programPending = new ProgramPendingQuestionForm(program.ID, entity.ID); PendingQuestionFormDetailService detailService = new PendingQuestionFormDetailService(m_DataContext); ProgramPendingQuestionFormService programPendingSrv = new ProgramPendingQuestionFormService(m_DataContext); m_DataContext.BeginNestedTran(); try { base.PendingQuestionFormInsert(entity); foreach (PendingQuestionFormDetail detail in entity.Details.All) { detailService.PendingQuestionFormDetailInsert(detail); } programPendingSrv.ProgramPendingQuestionFormInsert(programPending); m_DataContext.CommitNested(); } catch { m_DataContext.RollbackNested(); throw; } // Log success BusinessAuditEvent.Success( new EventParameter("PendingQuestionFormID", entity.ID.ToString()), new EventParameter("ProgramID", entity.ProgramID.ToString()) ); TraceCallReturnEvent.Raise(); return; } catch (Exception ex) { ExceptionManager.Publish(ex); BusinessAuditEvent.Fail( new EventParameter("Exception", ex.ToString()), new EventParameter("PendingQuestionFormID", entity.ID.ToString()), new EventParameter("ProgramID", entity.ProgramID.ToString()) ); TraceCallReturnEvent.Raise(false); throw; } }
public new void ProgramAttachmentInsert(ProgramAttachment entity) { // check permission: admin PrincipalPermission permReg = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Registered"); PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator"); permReg.Union(permAdmin).Demand(); TraceCallEnterEvent.Raise(); try { ProgramService progSrv = new ProgramService(); Program selectedProgram = progSrv.ProgramSelect(entity.ProgramRef); if (selectedProgram == null) throw new ApplicationException("A megadott azonosítóval nem létezik program."); string writerRole = selectedProgram.OrganisationRef.Value.ToString() + ".Writer"; PrincipalPermission permWriter = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, writerRole); permWriter.Union(permAdmin).Demand(); // check required fields: if (entity.Name.Length == 0) throw new ArgumentNullException("ProgramAttachment.Name", "A csatolt fájl neve nincs megadva."); if (entity.Description.Length == 0) throw new ArgumentNullException("ProgramAttachment.Description", "A csatolt fájl leírása nincs megadva."); if (entity.Path.Length == 0 || entity.Path == DBString.Null) throw new ArgumentNullException("ProgramAttachment.Path", "A fájlnév nincs megadva."); if (entity.FileData == null || entity.FileData.Length == 0) throw new ArgumentNullException("ProgramAttachment.FileData", "A fájl tartalma nincs megadva."); string fileName = entity.ID.Value.ToString() + Path.GetExtension(entity.Path); // save data FileDataContext fileDataContext = new FileDataContext(); fileDataContext.ProgramAttachmentInsert(entity.ProgramRef, fileName, entity.FileData); entity.CreatedDate = DBDateTime.Now; entity.IsActive = true; entity.FileSize = entity.FileData.Length; base.ProgramAttachmentInsert(entity); BusinessAuditEvent.Success( new EventParameter("ProgramAttachmentID", entity.ID.ToString()), new EventParameter("ProgramAttachmentName", entity.Name), new EventParameter("ProgramID", entity.ProgramRef.ToString()) ); TraceCallReturnEvent.Raise(); return; } catch (Exception ex) { ExceptionManager.Publish(ex); BusinessAuditEvent.Fail( new EventParameter("Exception", ex.ToString()), new EventParameter("ProgramAttachmentID", entity.ID.ToString()), new EventParameter("ProgramAttachmentName", entity.Name), new EventParameter("ProgramID", entity.ProgramRef.ToString()) ); TraceCallReturnEvent.Raise(false); throw; } }
public void PendingQuestionFormUpdateForProgram(PendingQuestionForm entity) { TraceCallEnterEvent.Raise(); try { if (entity.ProgramID.IsNull) throw new ArgumentNullException("PendingQuestionForm.ProgramID", "A program azonosítója nincs megadva."); ProgramService programSrv = new ProgramService(m_DataContext); Program program = programSrv.ProgramSelect(entity.ProgramID); if (program == null) throw new ApplicationException("A megadott azonosítóval nem létezik program."); string writerRole = program.OrganisationRef.Value.ToString() + ".Writer"; PrincipalPermission permWriter = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, writerRole); permWriter.Demand(); // required: if (entity.TemplateRef.IsNull) throw new ArgumentNullException("PendingQuestionForm.TemplateRef", "A sablon azonosítója nincs megadva."); if (entity.Status.Length == 0) throw new ArgumentNullException("PendingQuestionForm.Status", "A státusz nincs megadva."); // logical check: TemplateCategoryService templCatSrv = new TemplateCategoryService(m_DataContext); TemplateCategory templCat = templCatSrv.TemplateCategorySelect(entity.TemplateRef, program.ProgramCategoryRef); if (templCat == null) throw new ApplicationException("A megadott programhoz nem tölthetõ ki ez a sablon."); PendingQuestionForm selectedPending = base.PendingQuestionFormSelect(entity.ID); if (selectedPending == null) throw new ApplicationException("A módosítani kívánt kérdõív nem létezik."); // set data: entity.SentBy = Thread.CurrentPrincipal.Identity.Name; entity.SentDate = DBDateTime.Now; entity.LastModifiedByUser = DBDateTime.Now; if (entity.Status == "UWD" || entity.Status == "NWD") entity.IsActual = true; else { entity.IsActual = false; } PendingQuestionFormDetailService detailService = new PendingQuestionFormDetailService(m_DataContext); ProgramPendingQuestionFormService programPendingSrv = new ProgramPendingQuestionFormService(m_DataContext); m_DataContext.BeginNestedTran(); try { base.PendingQuestionFormUpdate(entity); base.DeleteChildrenByDetailOfPendingQuestionForm(entity.ID); foreach (PendingQuestionFormDetail detail in entity.Details.All) { detailService.PendingQuestionFormDetailInsert(detail); } m_DataContext.CommitNested(); } catch { m_DataContext.RollbackNested(); throw; } // Log success BusinessAuditEvent.Success( new EventParameter("PendingQuestionFormID", entity.ID.ToString()), new EventParameter("ProgramID", entity.ProgramID.ToString()) ); TraceCallReturnEvent.Raise(); return; } catch (Exception ex) { ExceptionManager.Publish(ex); BusinessAuditEvent.Fail( new EventParameter("Exception", ex.ToString()), new EventParameter("PendingQuestionFormID", entity.ID.ToString()), new EventParameter("ProgramID", entity.ProgramID.ToString()) ); TraceCallReturnEvent.Raise(false); throw; } }
public TemplateContainer TemplateSelectOfProgramQuestionFormOwn(DBGuid ProgramIdVal, DBGuid OrganisationIdVal) { TraceCallEnterEvent.Raise(); try { ProgramService progSrv = new ProgramService(m_DataContext); Program selectedProg = progSrv.ProgramSelect(ProgramIdVal); if (selectedProg == null) throw new ApplicationException("A megadott azonosítóval nem létezik program."); if (!selectedProg.IsActive) throw new ApplicationException("A program nem aktív."); TemplateContainer result; DataSet entitySet = m_DataContext.ndihdTemplateSelectOfProgramQuestionFormOwn( ProgramIdVal, OrganisationIdVal); result = new TemplateContainer(entitySet.Tables[0]); TraceCallReturnEvent.Raise(); return result; } catch (Exception ex) { ExceptionManager.Publish(ex); TraceCallReturnEvent.Raise(false); throw; } }
/// <summary> /// /// </summary> /// <param name="programID"></param> /// <param name="templateID"></param> /// <returns></returns> public string GetQuestionFormAsXML(DBGuid programID, DBGuid templateID) { TraceCallEnterEvent.Raise(); try { string result = ""; ProgramService programService = new ProgramService(m_DataContext); Program program = programService.ProgramSelect(programID); if (program == null) throw new ApplicationException("Ezzel az azonosítóval nem létezik program."); TemplateContainer availableTemplates = TemplateSelectOfProgramPendingQuestionForm(programID); Template currentTemplate = (Template) availableTemplates[templateID.ToString()]; if (currentTemplate == null) throw new ApplicationException("Ezzel az azonosítóval nem létezik kérdõív a megadott programhoz."); if (currentTemplate.Status.Equals("NWD") || currentTemplate.Status.Equals("UWD")) { throw new ApplicationException("A megadott kérdõív jóváhagyásra vár, nem módosítható."); } Template extendedTemplate = TemplateSelect(currentTemplate.ID); // feltöltjük a válaszokat PendingQuestionFormService pendingQuestionFormService = new PendingQuestionFormService(m_DataContext); QuestionFormService questionFormService = new QuestionFormService(m_DataContext); if (!currentTemplate.PendingQuestionFormID.IsNull) { PendingQuestionFormDetailContainer pendingAnswers = pendingQuestionFormService.SelectChildrenByDetailOfPendingQuestionForm(currentTemplate.PendingQuestionFormID); foreach (TemplateDetail d in extendedTemplate.Details.All) { string hash = currentTemplate.PendingQuestionFormID.ToString() + "<#>" + d.ID.ToString() + "<#>" + d.TemplateRef.ToString(); PendingQuestionFormDetail answer = (PendingQuestionFormDetail) pendingAnswers[hash]; if (answer != null) { d.Answer = answer.Answer; } } } else { if (!currentTemplate.QuestionFormID.IsNull) { QuestionFormDetailContainer acceptedAnswers = questionFormService.SelectChildrenByDetailOfQuestionForm(currentTemplate.QuestionFormID); foreach (TemplateDetail d in extendedTemplate.Details.All) { string hash = currentTemplate.QuestionFormID.ToString() + "<#>" + d.ID.ToString() + "<#>" + d.TemplateRef.ToString(); QuestionFormDetail answer = (QuestionFormDetail) acceptedAnswers[hash]; if (answer != null) { d.Answer = answer.Answer; } } } } // Build XML StringWriter sw = new StringWriter(); XmlTextWriter xtw = new XmlTextWriter(sw); xtw.WriteStartElement("QuestionForm"); xtw.WriteElementString("QuestionFormID", currentTemplate.QuestionFormID.AsXmlString); xtw.WriteElementString("PendingQuestionFormID", currentTemplate.PendingQuestionFormID.AsXmlString); xtw.WriteElementString("Status", currentTemplate.Status.AsXmlString); // --- program paramétereinek beállítása ProgramCategoryService pcs = new ProgramCategoryService(m_DataContext); if (!program.ProgramCategoryRef.IsNull) { ProgramCategory pc = pcs.ProgramCategorySelect(program.ProgramCategoryRef); if (pc != null) program.ProgramCategoryName = pc.Name; } OrganisationService os = new OrganisationService(m_DataContext); if (!program.OrganisationRef.IsNull) { Organisation org = os.OrganisationSelect(program.OrganisationRef); if (org != null) program.OrganisationName = org.Name; } xtw.WriteRaw(program.AsXmlString); string templateXML = ConvertTemplateToXML(extendedTemplate); xtw.WriteRaw(templateXML); xtw.WriteEndElement(); result = sw.ToString(); TraceCallReturnEvent.Raise(); return result; } catch (Exception ex) { ExceptionManager.Publish(ex); TraceCallReturnEvent.Raise(false); throw; } }
public Template TemplateSelectOfProgramPendingQuestionFormByTemplateID(DBGuid ProgramIdVal, DBGuid TemplateIdVal) { TraceCallEnterEvent.Raise(); try { ProgramService progSrv = new ProgramService(m_DataContext); Program selectedProg = progSrv.ProgramSelect(ProgramIdVal); if (selectedProg == null) throw new ApplicationException("A megadott azonosítóval nem létezik program."); string writerRole = selectedProg.OrganisationRef.Value.ToString() + ".Writer"; string readerRole = selectedProg.OrganisationRef.Value.ToString() + ".Reader"; PrincipalPermission permWriter = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, writerRole); PrincipalPermission permReader = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, readerRole); permWriter.Union(permReader).Demand(); if (!selectedProg.IsActive) throw new ApplicationException("A program nem aktív."); DataSet entitySet = m_DataContext.ndihdTemplateSelectOfProgramPendingQuestionFormByTemplateID(ProgramIdVal, TemplateIdVal); Template retTempl = new Template(entitySet); TraceCallReturnEvent.Raise(); return retTempl; } catch (Exception ex) { ExceptionManager.Publish(ex); TraceCallReturnEvent.Raise(false); throw; } }
public void SaveProgram(Guid progID) { TraceCallEnterEvent.Raise(); Program entity = null; try { //lekérdezzük a program ID alapján a programot ProgramService srvProg = new ProgramService(); entity = srvProg.ProgramSelect(progID); //logical check if (entity == null) throw new ApplicationException("Ezzel az azonosítóval nem létezik program."); //megnézzük hogy van e már hozzá megadott keresõ szöveg .. mert akkor azt update -eljük GlobalSearch search = base.GlobalSearchSelect(entity.ID, "PROGRAM"); if (search != null) { search.SearchText = entity.Name.ToString() + " " + entity.Description.ToString(); //lekérdezzük a hozzá tartozó összes kérdõív adatait és hozzáadjuk a SearchText -hez search.SearchText = search.SearchText + AddProgramRelated(entity.ID); //ha van ilyen UPDATE base.GlobalSearchUpdate(search); } else //ha még nincs ilyen INSERT { search = new GlobalSearch(entity.ID, "PROGRAM"); search.SearchText = entity.Name.ToString() + " " + entity.Description.ToString(); //lekérdezzük a hozzá tartozó összes kérdõív adatait és hozzáadjuk a SearchText -hez search.SearchText = search.SearchText + AddProgramRelated(entity.ID); base.GlobalSearchInsert(search); } } catch (Exception ex) { ExceptionManager.Publish(ex); BusinessAuditEvent.Fail( new EventParameter("Exception", ex.ToString()), new EventParameter("IDRef", entity.ID.ToString()), new EventParameter("SearchCategory", "PROGRAM") ); TraceCallReturnEvent.Raise(false); throw; } }