public virtual void TemplateUpdate(Template entity)
 {
     TraceCallEnterEvent.Raise();
       try
       {
     m_DataContext.BeginNestedTran();
     try
     {
       int count;
       m_DataContext.ndihdTemplateUpdate(entity.ID,
                                     entity.Name,
                                     entity.PublicityLevel,
                                     entity.IsActive, out count);
       if (count == 0) throw new ServiceUpdateException();
       m_DataContext.CommitNested();
     }
     catch
     {
       m_DataContext.RollbackNested();
       throw;
     }
     TraceCallReturnEvent.Raise();
     return;
       }
       catch (Exception ex)
       {
     ExceptionManager.Publish(ex);
     TraceCallReturnEvent.Raise(false);
     throw;
       }
 }
Example #2
0
 // -------------------------------------------------------------------------------------
 /// <summary>
 /// Form load event. If CurrentID is specified we are in update mode, so we must init
 /// then control's values.
 /// </summary>
 // -------------------------------------------------------------------------------------
 private void frmTemplateEdit_Load(object sender, EventArgs e)
 {
     LoadCombos();
       if (!m_CurrentTemplateID.IsNull)
       {
     ITemplateService templSrv = ServiceFactory.GetTemplateService();
     m_Template = templSrv.TemplateSelect(m_CurrentTemplateID);
     RetrieveData();
     FillDetailsGrid(DBString.Null);
     FillPagesGrid(DBInt.Null);
     grpCategory.Enabled = false;
       }
       else
       {
     m_CurrentTemplateID = Guid.NewGuid();
     m_Template = new Template(m_CurrentTemplateID);
     btnPageModify.Enabled = false;
     btnPageDelete.Enabled = false;
     btnNewDetail.Enabled = false;
     btnModifyDetail.Enabled = false;
     btnPreview.Enabled = false;
       }
 }
 public virtual void TemplateInsert(Template entity)
 {
     TraceCallEnterEvent.Raise();
       try
       {
     m_DataContext.BeginNestedTran();
     try
     {
       m_DataContext.ndihdTemplateInsert(entity.ID,
                                     entity.Name,
                                     entity.PublicityLevel,
                                     entity.IsActive);
       m_DataContext.CommitNested();
     }
     catch
     {
       m_DataContext.RollbackNested();
       throw;
     }
     TraceCallReturnEvent.Raise();
     return;
       }
       catch (Exception ex)
       {
     ExceptionManager.Publish(ex);
     TraceCallReturnEvent.Raise(false);
     throw;
       }
 }
 public virtual Template TemplateSelect(DBGuid IDVal)
 {
     TraceCallEnterEvent.Raise();
       try
       {
     Template result = null;
     DataSet entitySet = m_DataContext.ndihdTemplateSelect(IDVal);
     if (entitySet.Tables[0].Rows.Count != 0)
     {
       result = new Template(entitySet);
     }
     TraceCallReturnEvent.Raise();
     return result;
       }
       catch (Exception ex)
       {
     ExceptionManager.Publish(ex);
     TraceCallReturnEvent.Raise(false);
     throw;
       }
 }
 public frmTemplatePreview(Template template)
 {
     // Required for Windows Form Designer support
       InitializeComponent();
       m_Template = template;
 }
        /// <summary>
        /// Programs the question form validate priv.
        /// </summary>
        /// <param name="org">The org.</param>
        /// <param name="prog">The prog.</param>
        /// <param name="referenceDate">The reference date.</param>
        /// <param name="refreshNum">The refresh num.</param>
        /// <param name="service">if set to <c>true</c> [service].</param>
        /// <returns></returns>
        private string ProgramQuestionFormValidatePriv(Organisation org, Program prog, DateTime referenceDate, int refreshNum, bool service)
        {
            string organisationState = org.ValidationState ?? "";
              var filter = new Template(DBGuid.Null)
                     {
                       PublicityLevel = 1,
                       FilterOnIsActive = 1,
                       FilterOnCategory = prog.ProgramCategoryRef
                     };

              //IOrganisationService organisationService = ServiceFactory.GetOrganisationService();
              ProgramService programService =  new ProgramService();
              PendingQuestionFormService pqfService = new PendingQuestionFormService();
              TemplateService templateSrv = new TemplateService();
              ProgramPendingQuestionFormContainer qfPendings =
            programService.SelectChildrenByPendingQuestionFormOfProgram(prog.ID);

              //Ezek azok a kérdőívek, amiknek ki kellene töltve lennie a programhoz
              TemplateContainer templSelectedOrg = templateSrv.TemplateSelectFiltered(filter);
              foreach (Template template in templSelectedOrg.All)
              {
            bool isFilled = false;
            var allPendingsToTemplate = new PendingQuestionFormContainer();
            // ebben a konténerben lesznek az ehhez a templatehez tartozó pendingek

            //megnézem van-e ilyen a szervezethez
            //ezek vannak kitöltve a szervezethez
            foreach (ProgramPendingQuestionForm qf in qfPendings.All)
            {
              //Az organisationhoz tartozóak a pendingben

              PendingQuestionForm pqf = pqfService.PendingQuestionFormSelect(qf.PendingQuestionFormRef);
              if (pqf != null && pqf.TemplateRef == template.ID /*&& pqf.Status != QuestionFormStatus.Updated_SendBack && pqf.Status != QuestionFormStatus.New_SendBack*/) // ki van töltve
              {
              //invaild státuszok
              if (pqf.Status.Equals(QuestionFormStatus.New) || pqf.Status.Equals(QuestionFormStatus.New_Rejected) ||
                  pqf.Status.Equals(QuestionFormStatus.New_SendBack) ||
                  pqf.Status.Equals(QuestionFormStatus.Updated) ||
                  pqf.Status.Equals(QuestionFormStatus.Updated_Rejected) ||
                  pqf.Status.Equals(QuestionFormStatus.Updated_SendBack))
              {
                  isFilled = false;
                  // Nincs kitöltve neki
                  if (organisationState == OrganisationValidate.IsValid || organisationState == "")
                  {
                      organisationState = OrganisationValidate.NoQuestionForm;
                  }
                  else
                  {
                      if (organisationState.IndexOf(OrganisationValidate.NoQuestionForm) < 0) //még nem írtam be ezt a hibát
                          organisationState += " " + OrganisationValidate.NoQuestionForm;
                  }
                  continue; //tovább a ciklusban, mert ezt elég egyszer beírni a státuszba
              }

                  isFilled = true;
                  //nincs még ilyen
                  if (allPendingsToTemplate[pqf.HashString()] == null)
                      allPendingsToTemplate.Add(pqf);

              }
            } // amikor ideérek, akkor az isFilled true, ha van ilyen kérdőív kitöltve a szervezethez
            //és a allPendingsToTemplate -ben benne van az összes pending ehhez a template-hez

            //amikor itt tartunk megvan az összes szervezethez  tartozó pendibgünk, ehhez a template-hoz
            if (allPendingsToTemplate.AllCount > 0)
            {
              //Ebből ki kell vennünk a legutolsót
              ArrayList allSorted = allPendingsToTemplate.All.SortBy("SentDate");
              //Itt egy sorrendezett listánk van
              //Kiveszem az utolsót, mert dátum szerint ezt kell nézni
              var validable = (PendingQuestionForm)allSorted[allSorted.Count - 1];
              //Mindig csak az utolsót kell validálni
              if (validable != null)
              {
            if (validable.Status.Equals(QuestionFormStatus.New_WaitingForDecision) ||
                validable.Status.Equals(QuestionFormStatus.Updated_WaitingForDecision))
            {
              continue; // végeztünk, mert jóváhagyásra váró kérdőíve van ehhez a template-hez
            }
            //megnézzük hogy jóváhagyottja van-e
            if (validable.Status.Equals(QuestionFormStatus.New_Accepted) ||
                validable.Status.Equals(QuestionFormStatus.Updated_Accepted))
            {
              if (service)
              {
                //van jóváhagyottja, akkor meg kell nézni, hogy az utplsó módosíás dátuma nem túl régi-e
                //if (referenceDate < (DateTime) validable.SentDate)
                {
                  // Túl régi ehhez a template-hoz
                  if (organisationState == OrganisationValidate.IsValid || organisationState == "")
                  {
                    organisationState = OrganisationValidate.NoQuestionFormRefresh;
                  }
                  else
                  {
                    if (organisationState.IndexOf(OrganisationValidate.NoQuestionFormRefresh) < 0)
                      //még nem írtam be ezt a hibát
                      organisationState += " " + OrganisationValidate.NoQuestionFormRefresh;
                  }
                }
              }
              else
              {
                //van jóváhagyottja, akkor meg kell nézni, hogy az utplsó módosíás dátuma nem túl régi-e
                if (referenceDate.AddDays(-(int)refreshNum) > (DateTime)validable.SentDate)
                {
                  // Túl régi ehhez a template-hoz
                  if (organisationState == OrganisationValidate.IsValid || organisationState == "")
                  {
                    organisationState = OrganisationValidate.NoQuestionFormRefresh;
                  }
                  else
                  {
                    if (organisationState.IndexOf(OrganisationValidate.NoQuestionFormRefresh) < 0)
                      //még nem írtam be ezt a hibát
                      organisationState += " " + OrganisationValidate.NoQuestionFormRefresh;
                  }
                }
              }
            }

            ////invaild státuszok
            //if (validable.Status.Equals(QuestionFormStatus.New) || validable.Status.Equals(QuestionFormStatus.New_Rejected) ||
            //    validable.Status.Equals(QuestionFormStatus.New_SendBack) ||
            //    validable.Status.Equals(QuestionFormStatus.Updated) ||
            //    validable.Status.Equals(QuestionFormStatus.Updated_Rejected) ||
            //    validable.Status.Equals(QuestionFormStatus.Updated_SendBack))
            //{
            //  isFilled = false;
            //}
              }
            }
            //nincs kitöltve
            if (!isFilled)
              if (organisationState == OrganisationValidate.IsValid || organisationState == "")
              {
            organisationState = OrganisationValidate.NoQuestionForm;
              }
              if (organisationState.IndexOf(OrganisationValidate.NoQuestionForm) < 0)
            //még nem írtam be ezt a hibát
            organisationState += " " + OrganisationValidate.NoQuestionForm;
              }
              //Mindig csak a legutolsó pendinget kell megnéznem. Ennek a státusza számít

              return organisationState;
        }
Example #7
0
 // -------------------------------------------------------------------------------------
 /// <summary>
 /// Copy constructor.
 /// </summary>
 /// <param name="IDVal">Value of 'uID' field</param>
 /// <param name="origInstance">Original document data to copy.</param>
 // -------------------------------------------------------------------------------------
 public Template(DBGuid IDVal,
             Template origInstance)
     : base(IDVal, origInstance)
 {
 }
        private void SetTemplateCombo()
        {
            Template filter = new Template(Guid.NewGuid());
              filter.FilterOnCategory = cmbCategory1.SelectedValue;
              filter.FilterOnIsActive = 1;
              filter.PublicityLevel = PublicityLevel.Public;
              if (Context.User.Identity.IsAuthenticated)
              {
            filter.PublicityLevel = PublicityLevel.RegisteredOnly;
              }
              ITemplateService srv = ServiceFactory.GetTemplateService();
              TemplateContainer data = srv.TemplateSelectFiltered(filter);
              ArrayList sortableList = data.All.SortBy("Name");
              cmbTemplate.DataSource = sortableList;
              cmbTemplate.DataValueField = "ID";
              cmbTemplate.DataTextField = "Name";
              cmbTemplate.DataBind();
              bool autoselect = false;
              if(data.AllCount == 1)
              {
            autoselect = true;
              }

              ListItem liAll = new ListItem("-- Válasszon --", "");
              cmbTemplate.Items.Insert(0, liAll);
              if(autoselect)
              {
            cmbTemplate.SelectedIndex = 1;
              }
        }
Example #9
0
 // -------------------------------------------------------------------------------------
 /// <summary>
 /// Copy constructor.
 /// </summary>
 /// <param name="origInstance">Original document data to copy.</param>
 // -------------------------------------------------------------------------------------
 public Template(Template origInstance)
     : base(origInstance)
 {
 }
Example #10
0
        private string ConvertTemplateToXML(Template template)
        {
            StringWriter sw = new StringWriter();
              XmlTextWriter xtw = new XmlTextWriter(sw);
              xtw.WriteStartElement("Template");
              xtw.WriteAttributeString("ID", template.ID.AsXmlString);
              xtw.WriteStartElement("Name");
              xtw.WriteCData(template.Name.AsXmlString);
              xtw.WriteEndElement();
              xtw.WriteElementString("PublicityLevel", template.PublicityLevel.AsXmlString);
              xtw.WriteElementString("IsActive", template.IsActive.ToString());

              xtw.WriteStartElement("Details");
              foreach (TemplateDetail d in template.Details.All)
              {
            string detailXML = ConvertTemplateDetailToXML(d);
            xtw.WriteRaw(detailXML);
              }
              xtw.WriteEndElement();

              xtw.WriteStartElement("Pages");
              foreach (TemplatePage p in template.Pages.All)
              {
            xtw.WriteRaw(p.AsXmlString);
              }
              xtw.WriteEndElement();

              xtw.WriteEndElement();
              return sw.ToString();
        }
Example #11
0
        public new void TemplateUpdate(Template entity)
        {
            PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permAdmin.Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            //check required fields:
            if (entity.ID.IsNull) throw new ArgumentNullException("Template.ID", "A sablon azonosítója nincs megadva.");
            if (entity.Name.Length == 0) throw new ArgumentNullException("Template.Name", "A sablon neve nincs megadva.");
            if (entity.PublicityLevel.IsNull)
              throw new ArgumentNullException("Template.PublicityLevel", "A publikussági szint nincs megadva.");

            if (entity.Details == null)
              throw new ArgumentNullException("Template.Details", "A sablonhoz nincs egyetlen kérdés sem megadva.");
            if (entity.Details.CurrentCount == 0)
              throw new ArgumentNullException("Template.Details", "A sablonhoz nincs egyetlen kérdés sem megadva.");

            string p = PublicityLevel.GetNameById(entity.PublicityLevel.ToString());
            if (p == null)
              throw new ApplicationException("Érvénytelen publikussági szint érték.");

            Template selected = base.TemplateSelect(entity.ID);
            if (selected == null)
              throw new ApplicationException("A megadott azonosítóval nem létezik sablon.");

            // TODO: check pages

            //save data
            m_DataContext.BeginNestedTran();
            try
            {
              TemplateDetailService detailService = new TemplateDetailService(m_DataContext);
              TemplatePageService pageService = new TemplatePageService(m_DataContext);
              TemplateDetailContainer originalDetails = SelectChildrenByDetailOfTemplate(entity.ID);

              base.TemplateUpdate(entity);

              foreach (TemplateDetail detail in entity.Details.Current)
              {
            if (originalDetails[detail.HashString()] != null)
            {
              detailService.TemplateDetailUpdate(detail);
            }
            else
            {
              detailService.TemplateDetailInsert(detail);
            }
              }

              // replace pages:
              base.DeleteChildrenByPageOfTemplate(entity.ID);
              foreach (TemplatePage page in entity.Pages.Current)
              {
            pageService.TemplatePageInsert(page);
              }

              # region feltöltjük a szabadszöveges kereséshez a GlobalSearch táblát

              GlobalSearchService srvGlobalSearch = new GlobalSearchService(m_DataContext);

              DataSet ds = TemplateSelectPendingPrograms(entity.ID);
              DataTable dt = ds.Tables[0];

              foreach (DataRow dr in dt.Rows)
              {
            srvGlobalSearch.SaveProgram(new Guid(dr["uID"].ToString()));
              }

              #endregion

              m_DataContext.CommitNested();
            }
            catch
            {
              m_DataContext.RollbackNested();
              throw;
            }

            BusinessAuditEvent.Success(
              new EventParameter("TemplateID", entity.ID.ToString()),
              new EventParameter("TemplateName", entity.Name.ToString())
              );
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("TemplateID", entity.ID.ToString()),
              new EventParameter("TemplateName", entity.Name.ToString())
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
Example #12
0
        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;
              }
        }
Example #13
0
 public TemplateContainer TemplateSelectFiltered(Template filter)
 {
     TraceCallEnterEvent.Raise();
       try
       {
     TemplateContainer result;
     DataSet entitySet = m_DataContext.ndihdTemplateSelectFiltered(
       filter.FilterOnCategory,
       filter.PublicityLevel,
       filter.FilterOnIsActive);
     result = new TemplateContainer(entitySet.Tables[0]);
     TraceCallReturnEvent.Raise();
     return result;
       }
       catch (Exception ex)
       {
     ExceptionManager.Publish(ex);
     TraceCallReturnEvent.Raise(false);
     throw;
       }
 }