public FQDNN_FormFiling GetCurrentFormFilingFromViewState(FQDNN_Form Form)
 {
     FQDNN_FormFiling FormFiling = null;
     if (ViewState["FormFiling_" + Form.FormID.ToString() + "_" + ModuleId.ToString()] != null)
     {
         FormFiling = (FQDNN_FormFiling)ViewState["FormFiling_" + Form.FormID.ToString() + "_" + ModuleId.ToString()];
     }
     return FormFiling;
 }
예제 #2
0
        private void SetupPage(FQDNN_Form oForm, FQDNN_FormPage oCurrentPage)
        {
            this.FindControl(oCurrentPage.GetControlID()).Visible = true;

            foreach (FQDNN_FormControl oPageControl in oCurrentPage.FQDNN_FormControl)
            {
                SetupPageControl(oPageControl);
            }

            //set previous and next page button's visibility
            FormSettings oFormSettings = new FormSettings();
            bool bUserCanNavigateBackInTheForm = oFormSettings.UserCanNavigateBack(oForm.FQDNN_FormSetting.ToList());

            if (bUserCanNavigateBackInTheForm)
            {
                ((Button)this.FindControl(oCurrentPage.GetPreviousPageControlID())).Click += PreviousPage;
            }
            ((Button)this.FindControl(oCurrentPage.GetNextPageControlID())).Click += NextPage;

            if (PageNumber == 1 || !bUserCanNavigateBackInTheForm)
            {
                this.FindControl(oCurrentPage.GetPreviousPageControlID()).Visible = false;
            }
            if (PageNumber == TotalPages)
            {
                this.FindControl(oCurrentPage.GetNextPageControlID()).Visible = false;
            }
        }
        //check settings and return whether the current user is allowed to file the form
        public bool UserCanFileForm(UserInfo User, FQDNN_Form Form)
        {
            CommonLogic oCommonLogic = new CommonLogic();
            List<FQDNN_FormSetting> Settings = Form.FQDNN_FormSetting.ToList();
            FormSettings oFormSettings = new FormSettings();
            bool bFormAccessIsFiltered = oFormSettings.GetAccessIsFiltered(Settings);
            bool result = !bFormAccessIsFiltered;

            string listOfUsersAbleToFileForm = oFormSettings.GetListOfUsersAbleToFileForm(Settings);
            string listOfUserRolesAbleToFileForm = oFormSettings.GetListOfUserRolesAbleToFileForm(Settings);
            string listOfUsersNotAbleToFileForm = oFormSettings.GetListOfUsersNotAbleToFileForm(Settings);
            string listOfUserRolesNotAbleToFileForm = oFormSettings.GetListOfUserRolesNotAbleToFileForm(Settings);

            if (bFormAccessIsFiltered)
            {
                //if there are any allow rules then user is not allowed by default and then check if the user matches the rules.
                if (!String.IsNullOrEmpty(listOfUsersAbleToFileForm) || !String.IsNullOrEmpty(listOfUserRolesAbleToFileForm))
                {
                    result = false;
                    if (User != null)
                    {
                        if (!String.IsNullOrEmpty(listOfUsersAbleToFileForm))
                        {
                            if (oCommonLogic.IntIsInList(User.UserID, listOfUsersAbleToFileForm))
                            {
                                result = true;
                            }
                        }
                        if (!String.IsNullOrEmpty(listOfUserRolesAbleToFileForm))
                        {
                            if (oCommonLogic.UserIsInListOfRoles(User, listOfUserRolesAbleToFileForm))
                            {
                                result = true;
                            }
                        }
                    }
                }

                if (result == false)
                {
                    return false;
                }

                if (!String.IsNullOrEmpty(listOfUsersNotAbleToFileForm) || !String.IsNullOrEmpty(listOfUserRolesNotAbleToFileForm))
                {
                    if (User != null)
                    {
                        if (!String.IsNullOrEmpty(listOfUsersNotAbleToFileForm))
                        {
                            if (oCommonLogic.IntIsInList(User.UserID, listOfUsersNotAbleToFileForm))
                            {
                                result = false;
                            }
                        }
                        if (!String.IsNullOrEmpty(listOfUserRolesNotAbleToFileForm))
                        {
                            if (oCommonLogic.UserIsInListOfRoles(User, listOfUserRolesNotAbleToFileForm))
                            {
                                result = false;
                            }
                        }
                    }
                }
            }

            bool bUserCanFileMultipleTimes = oFormSettings.GetUserCanFileMultipleTimes(Settings);
            if (!bUserCanFileMultipleTimes)
            {
                DataAccess oDataAccess = new DataAccess();

                FQDNN_FormFiling oPreviousFormFiling = oDataAccess.GetLastFiling(User.UserID, oCommonLogic.GetUserIPAddress(), Form.FormID);

                if (oPreviousFormFiling != null)
                {
                    result = false;

                    bool bUserCanResumeFiling = oFormSettings.GetUserCanResumeFiling(Settings);
                    int iUserCanResumeInHours = oFormSettings.GetUserCanResumeInHours(Settings);

                    if (bUserCanResumeFiling)
                    {
                        DateTime Now = DateTime.Now;

                        if (Now > oPreviousFormFiling.DateCreated)
                        {
                            int hoursSincePreviousFiling = (Now - oPreviousFormFiling.DateCreated).Hours;
                            if (iUserCanResumeInHours > hoursSincePreviousFiling)
                            {
                                result = true;
                            }
                        }
                    }
                }
            }

            return result;
        }
 public void SetCurrentFormFilingInViewState(FQDNN_FormFiling FormFiling, FQDNN_Form Form)
 {
     ViewState["FormFiling_" + Form.FormID.ToString() + "_" + ModuleId.ToString()] = FormFiling;
 }