private GeneralResultDTO SubmitRequestAccessFormInternal(string email)
        {
            var requestAccessForm = BizFormInfoProvider.GetBizFormInfo(_RequestAccessFormCodeName, SiteContext.CurrentSiteID);

            if (requestAccessForm != null)
            {
                var    requestAccessFormClass     = DataClassInfoProvider.GetDataClassInfo(requestAccessForm.FormClassID);
                string requestAccessFormClassName = requestAccessFormClass.ClassName;

                BizFormItem newFormItem = BizFormItem.New(requestAccessFormClassName);

                newFormItem.SetValue("Email", email);
                newFormItem.SetValue("Site", SiteContext.CurrentSite.DisplayName);
                newFormItem.SetValue("FormInserted", DateTime.Now);
                newFormItem.SetValue("FormUpdated", DateTime.Now);

                newFormItem.Insert();

                SendFormEmail(newFormItem);

                return(new GeneralResultDTO {
                    success = true
                });
            }
            else
            {
                return(new GeneralResultDTO {
                    success = false, errorMessage = ResHelper.GetString("Kadena.ForgottenPassword.ForgottenPasswordRepositoryNotFound", LocalizationContext.CurrentCulture.CultureCode)
                });
            }
        }
Ejemplo n.º 2
0
    /// <summary>
    /// Click event - updates new values.
    /// </summary>
    /// <param name="sender">Sender</param>
    /// <param name="e">Params</param>
    protected void nameElem_Click(object sender, EventArgs e)
    {
        // Check 'EditForm' permission
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.form", "EditForm"))
        {
            RedirectToCMSDeskAccessDenied("cms.form", "EditForm");
        }

        // Code name validation
        string err = new Validator().IsIdentificator(nameElem.CodeName, GetString("general.erroridentificatorformat")).Result;

        if (err != String.Empty)
        {
            lblError.Visible = true;
            lblError.Text    = err;
            lblInfo.Visible  = false;
            return;
        }

        // Validate form id
        AlternativeFormInfo afi = AlternativeFormInfoProvider.GetAlternativeFormInfo(altFormId);

        EditedObject = afi;
        if (afi == null)
        {
            return;
        }

        // Checking for duplicate items
        DataSet ds = AlternativeFormInfoProvider.GetAlternativeForms("FormName='" + SqlHelperClass.GetSafeQueryString(nameElem.CodeName, false) +
                                                                     "' AND FormClassID=" + afi.FormClassID, null);

        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            if (!((ds.Tables.Count == 1) && (ds.Tables[0].Rows.Count == 1) && (
                      ValidationHelper.GetInteger(ds.Tables[0].Rows[0]["FormID"], 0) == altFormId)))
            {
                lblError.Visible = true;
                lblError.Text    = GetString("general.codenameexists");
                lblInfo.Visible  = false;
                return;
            }
        }

        afi.FormDisplayName = nameElem.DisplayName;
        afi.FormName        = nameElem.CodeName;
        AlternativeFormInfoProvider.SetAlternativeFormInfo(afi);

        // Required to log staging task, alternative form is not binded to bizform as child
        using (CMSActionContext context = new CMSActionContext())
        {
            context.CreateVersion = false;

            // Log synchronization
            BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo(formId);
            SynchronizationHelper.LogObjectChange(bfi, TaskTypeEnum.UpdateObject);
        }

        URLHelper.Redirect("AlternativeForms_Edit_General.aspx?altformid=" + altFormId + "&formid=" + formId + "&saved=1");
    }
Ejemplo n.º 3
0
    void layoutElem_OnAfterSave(object sender, EventArgs e)
    {
        // Log synchronization
        BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo(bizFormId);

        SynchronizationHelper.LogObjectChange(bfi, TaskTypeEnum.UpdateObject);
    }
Ejemplo n.º 4
0
    protected void Page_Init(object sender, EventArgs e)
    {
        // Check permissions
        if (!QueryHelper.ValidateHash("hash"))
        {
            return;
        }

        int bizId = QueryHelper.GetInteger("bizid", 0);
        int recId = QueryHelper.GetInteger("recid", 0);

        if ((bizId > 0) && (recId > 0))
        {
            var bfi = BizFormInfoProvider.GetBizFormInfo(bizId);

            if (bfi == null)
            {
                return;
            }

            bizRecord.ItemID   = recId;
            bizRecord.SiteName = SiteInfoProvider.GetSiteName(bfi.FormSiteID);
            bizRecord.FormName = bfi.FormName;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        CurrentMaster.PanelContent.CssClass = string.Empty;

        // Check 'ReadForm' permission
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.form", "ReadForm"))
        {
            RedirectToCMSDeskAccessDenied("cms.form", "ReadForm");
        }

        bizFormId                 = QueryHelper.GetInteger("formid", 0);
        layoutElem.FormType       = CMSModules_AdminControls_Controls_Class_Layout.FORMTYPE_BIZFORM;
        layoutElem.ObjectID       = bizFormId;
        layoutElem.ObjectType     = FormObjectType.BIZFORM;
        layoutElem.ObjectCategory = MetaFileInfoProvider.OBJECT_CATEGORY_LAYOUT;
        layoutElem.IsLiveSite     = false;
        layoutElem.OnBeforeSave  += layoutElem_OnBeforeSave;
        layoutElem.OnAfterSave   += layoutElem_OnAfterSave;

        // Load CSS style sheet to editor area
        if (CMSContext.CurrentSite != null)
        {
            int cssId = CMSContext.CurrentSite.SiteDefaultEditorStylesheet;
            if (cssId == 0) // Use default site CSS if none editor CSS is specified
            {
                cssId = CMSContext.CurrentSite.SiteDefaultStylesheetID;
            }
            layoutElem.CssStyleSheetID = cssId;
        }

        BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo(bizFormId);

        EditedObject = bfi;
    }
Ejemplo n.º 6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check permissions
        if (ActivityHelper.AuthorizedReadActivity(CMSContext.CurrentSiteID, true))
        {
            if (!QueryHelper.ValidateHash("hash"))
            {
                return;
            }

            int bizId = QueryHelper.GetInteger("bizid", 0);
            int recId = QueryHelper.GetInteger("recid", 0);

            if ((bizId > 0) && (recId > 0))
            {
                BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo(bizId);

                if (bfi == null)
                {
                    return;
                }

                bizRecord.ItemID   = recId;
                bizRecord.SiteName = SiteInfoProvider.GetSiteName(bfi.FormSiteID);
                bizRecord.FormName = bfi.FormName;
            }

            CurrentMaster.Title.TitleText  = GetString("om.activitydetals.viewrecorddetail");
            CurrentMaster.Title.TitleImage = GetImagePath("Objects/OM_Activity/object.png");
        }
    }
Ejemplo n.º 7
0
    /// <summary>
    /// On chkSendToEmail checked event handler.
    /// </summary>
    protected void chkSendToEmail_CheckedChanged(object sender, EventArgs e)
    {
        txtFromEmail.Enabled  = chkSendToEmail.Checked;
        txtToEmail.Enabled    = chkSendToEmail.Checked;
        txtSubject.Enabled    = chkSendToEmail.Checked;
        chkAttachDocs.Enabled = chkSendToEmail.Checked;
        if (chkSendToEmail.Checked)
        {
            chkCustomLayout.Visible = true;
            if (chkCustomLayout.Checked)
            {
                pnlCustomLayout.Visible = true;

                // Reload HTML editor content
                BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo(formId);
                if (bfi != null && bfi.FormEmailTemplate != null)
                {
                    htmlEditor.ResolvedValue = bfi.FormEmailTemplate;
                }
            }
        }
        else
        {
            chkCustomLayout.Visible = false;
            pnlCustomLayout.Visible = false;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check 'ReadForm' permission
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.form", "ReadForm"))
        {
            RedirectToCMSDeskAccessDenied("cms.form", "ReadForm");
        }

        int altFormId = QueryHelper.GetInteger("altformid", 0);
        int formId    = QueryHelper.GetInteger("formid", 0);

        bfi          = BizFormInfoProvider.GetBizFormInfo(formId);
        EditedObject = bfi;

        if (bfi == null)
        {
            ShowError(GetString("general.invalidid"));
            altFormFieldEditor.Visible = false;
            return;
        }

        CurrentMaster.BodyClass += " FieldEditorBody";
        altFormFieldEditor.AlternativeFormID = altFormId;
        altFormFieldEditor.Mode = FieldEditorModeEnum.BizFormDefinition;
        altFormFieldEditor.DisplayedControls = FieldEditorControlsEnum.Bizforms;
        altFormFieldEditor.OnBeforeSave     += altFormFieldEditor_OnBeforeSave;
        altFormFieldEditor.OnAfterSave      += altFormFieldEditor_OnAfterSave;
    }
        public List <FormEntry> GetFormEntries(string formName)
        {
            List <FormEntry> entries    = new List <FormEntry>();
            BizFormInfo      formObject = BizFormInfoProvider.GetBizFormInfo(formName, SiteContext.CurrentSiteID);

            if (formObject == null)
            {
                throw new InvalidOperationException("The requested checkin form does not exist.");
            }
            // Gets the class name of the form
            DataClassInfo formClass = DataClassInfoProvider.GetDataClassInfo(formObject.FormClassID);
            string        className = formClass.ClassName;

            // Loads the form's data
            ObjectQuery <BizFormItem> data = BizFormItemProvider.GetItems(className);

            // Checks whether the form contains any records
            if (!DataHelper.DataSourceIsEmpty(data))
            {
                // Loops through the form's data records
                foreach (BizFormItem item in data)
                {
                    FormEntry entry = new FormEntry();
                    entry.ID = item.ItemID;

                    foreach (var columnName in item.ColumnNames)
                    {
                        entry.FormValues.Add(columnName.ToLower(), item.GetStringValue(columnName, ""));
                    }
                    entries.Add(entry);
                }
            }
            return(entries);
        }
        public void Submit(IForm form)
        {
            try
            {
                var formInfo = BizFormInfoProvider.GetBizFormInfo(form.Name, SiteContext.CurrentSiteID);
                if (formInfo == null)
                {
                    throw new InvalidOperationException("The requested checkin form does not exist.");
                }
                var dataClassInfo = DataClassInfoProvider.GetDataClassInfo(formInfo.FormClassID);
                var item          = new BizFormItem(dataClassInfo.ClassName);

                SetFormValues(form, item);

                item.SetValue("FormInserted", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                item.SetValue("FormUpdated", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));

                BizFormItemProvider.SetItem(item);
                BizFormInfoProvider.RefreshDataCount(formInfo.FormName, formInfo.FormSiteID);

                if (form.Notification != null)
                {
                    SendNotificationEmail(formInfo, form, item);
                }

                if (!String.IsNullOrEmpty(form.Autoresponder?.Sender))
                {
                    SendAcknowledgementEmail(formInfo, item, form.Controls);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("There was a problem saving the form. Please contact our support team.", ex);
            }
        }
Ejemplo n.º 11
0
        private void GenerateActivities(
            string campaignName,
            IReadOnlyDictionary <string, IEnumerable <ActivityDataParameters> > conversionHits,
            int contactsCount)
        {
            var siteName     = _mSite.SiteName;
            var campaignInfo = CampaignInfoProvider.GetCampaignInfo(campaignName, siteName);
            var posterPath   = CampaignDataGeneratorHelpers.GetDocument(PagePathAmericasCoffeePoster);
            var colombiaPath = CampaignDataGeneratorHelpers.GetDocument(PagePathColombia);
            var bizFormInfo  = BizFormInfoProvider.GetBizFormInfo(TryFreeSampleFormCodeName, _mSite.SiteID);

            CampaignDataGeneratorHelpers.DeleteOldActivities(campaignInfo.CampaignUTMCode);
            var contactsIDs = new ContactsIdData(_contactEmailPostfix, contactsCount);

            CampaignDataGeneratorHelpers.GenerateActivities(conversionHits[ConversionPagevisitColombia], campaignInfo,
                                                            "pagevisit",
                                                            contactsIDs, colombiaPath.NodeID);

            CampaignDataGeneratorHelpers.GenerateActivities(conversionHits[ConversionPagevisitAmericasCoffeePoster],
                                                            campaignInfo,
                                                            "pagevisit", contactsIDs, posterPath.NodeID);

            CampaignDataGeneratorHelpers.GenerateActivities(conversionHits[ConversionUserregistration], campaignInfo,
                                                            "userregistration", contactsIDs);

            CampaignDataGeneratorHelpers.GenerateActivities(conversionHits[ConversionFormsubmissionTryFreeSample],
                                                            campaignInfo,
                                                            "bizformsubmit", contactsIDs, bizFormInfo.FormID);
        }
Ejemplo n.º 12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check 'ReadForm' permission
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.form", "ReadForm"))
        {
            RedirectToCMSDeskAccessDenied("cms.form", "ReadForm");
        }

        formId       = QueryHelper.GetInteger("formid", 0);
        bfi          = BizFormInfoProvider.GetBizFormInfo(formId);
        EditedObject = bfi;

        if (bfi == null)
        {
            ShowError(GetString("general.invalidid"));
            return;
        }

        // Init alternative forms listing
        listElem.FormClassID = bfi.FormClassID;
        listElem.OnEdit     += listElem_OnEdit;
        listElem.OnDelete   += listElem_OnDelete;

        // New item link
        string[,] actions = new string[1, 6];
        actions[0, 0]     = HeaderActions.TYPE_HYPERLINK;
        actions[0, 1]     = GetString("altforms.newformlink");
        actions[0, 2]     = null;
        actions[0, 3]     = ResolveUrl("AlternativeForms_New.aspx?formid=" + formId.ToString());
        actions[0, 4]     = null;
        actions[0, 5]     = GetImageUrl("Objects/CMS_AlternativeForm/add.png");
        CurrentMaster.HeaderActions.Actions = actions;
    }
Ejemplo n.º 13
0
    /// <summary>
    /// On chkSendToEmail checked event handler.
    /// </summary>
    protected void chkSendToEmail_CheckedChanged(object sender, EventArgs e)
    {
        txtFromEmail.Enabled  = chkSendToEmail.Checked;
        txtToEmail.Enabled    = chkSendToEmail.Checked;
        txtSubject.Enabled    = chkSendToEmail.Checked;
        chkAttachDocs.Enabled = chkSendToEmail.Checked;
        if (chkSendToEmail.Checked)
        {
            chkCustomLayout.Visible = true;
            if (chkCustomLayout.Checked)
            {
                pnlCustomLayout.Visible = true;
                lnkSave.OnClientClick   = "";

                // Reload HTML editor content
                BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo(formId);
                if (bfi != null && bfi.FormEmailTemplate != null)
                {
                    htmlEditor.ResolvedValue = bfi.FormEmailTemplate;
                }
            }
        }
        else
        {
            chkCustomLayout.Visible = false;
            pnlCustomLayout.Visible = false;

            // Add delete confirmation
            if (IsLayoutSet)
            {
                lnkSave.OnClientClick = "return ConfirmDelete();";
            }
        }
    }
Ejemplo n.º 14
0
    protected void btnOk_Click(object sender, EventArgs e)
    {
        // Check 'EditForm' permission
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.form", "EditForm"))
        {
            RedirectToCMSDeskAccessDenied("cms.form", "EditForm");
        }

        BizFormInfo form = BizFormInfoProvider.GetBizFormInfo(formId);

        if (form != null)
        {
            if (radAllUsers.Checked)
            {
                form.FormAccess = FormAccessEnum.AllBizFormUsers;
                BizFormInfoProvider.RemoveAllRolesFromForm(formId);
                form.ClearAuthorizedRoles();
                lstRoles.Items.Clear();
            }
            else
            {
                form.FormAccess = FormAccessEnum.OnlyAuthorizedRoles;
            }
            BizFormInfoProvider.SetBizFormInfo(form);

            lblInfo.Visible = true;
            lblInfo.Text    = GetString("General.Changessaved");
        }
    }
Ejemplo n.º 15
0
    private object UniGrid_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        switch (sourceName.ToLowerCSafe())
        {
        case "edit":
        case "moveup":
        case "movedown":
        case "delete":
            (sender as ImageButton).Visible = AllowEdit;
            return(sender);

        case "answerenabled":
            return(UniGridFunctions.ColoredSpanYesNo(parameter));

        case "answerisopenended":
            return(String.IsNullOrEmpty(ValidationHelper.GetString(parameter, string.Empty)) ? GetString("polls.AnswerTypeStandard") : GetString("polls.AnswerTypeOpenEnded"));

        case "answerform":
            if (sender is ImageButton)
            {
                ImageButton imageButton = sender as ImageButton;
                GridViewRow gvr         = parameter as GridViewRow;

                if (!CMSContext.CurrentUser.IsAuthorizedPerResource("CMS.Form", "ReadData"))
                {
                    imageButton.Visible = false;
                }
                else if (gvr != null)
                {
                    DataRowView drv = gvr.DataItem as DataRowView;
                    if (drv != null)
                    {
                        string formName = ValidationHelper.GetString(drv["AnswerForm"], null);
                        if (String.IsNullOrEmpty(formName))
                        {
                            imageButton.Visible = false;
                        }
                        else
                        {
                            BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo(formName, CMSContext.CurrentSiteID);
                            if ((bfi != null) && bizFormsAvailable)
                            {
                                imageButton.OnClientClick = "modalDialog('" + ResolveUrl("~/CMSModules/Polls/Tools/Polls_Answer_Results.aspx") + "?formid=" + bfi.FormID + "&dialogmode=1', 'AnswerForm', '1000', '700'); return false;";
                            }
                            else
                            {
                                imageButton.Visible = false;
                            }
                        }
                    }
                }
            }
            return(sender);
        }
        return(parameter);
    }
Ejemplo n.º 16
0
        private GeneralResultDTO SubmitBidInternal(string name, string description, string requestType, string biddingWay, int numberOfBidings, List <HttpPostedFile> files, DateTime productionDate, DateTime?selectionDate)
        {
            var bidForm = BizFormInfoProvider.GetBizFormInfo(_BidFormCodeName, SiteContext.CurrentSiteID);

            if (bidForm != null)
            {
                var    bidFormClass     = DataClassInfoProvider.GetDataClassInfo(bidForm.FormClassID);
                string bidFormClassName = bidFormClass.ClassName;

                BizFormItem newFormItem = BizFormItem.New(bidFormClassName);

                newFormItem.SetValue("Name", name);
                newFormItem.SetValue("Description", description);
                newFormItem.SetValue("RequestType", requestType);
                newFormItem.SetValue("BiddingWayText", biddingWay);
                newFormItem.SetValue("BiddingWayNumber", numberOfBidings);

                newFormItem.SetValue("ProductionDate", productionDate);
                if (selectionDate.HasValue)
                {
                    newFormItem.SetValue("SelectionDate", selectionDate);
                }

                newFormItem.SetValue("FormInserted", DateTime.Now);
                newFormItem.SetValue("FormUpdated", DateTime.Now);

                newFormItem.SetValue("Site", SiteContext.CurrentSite.DisplayName);

                if (files.Count > 0)
                {
                    for (int i = 0; files.Count > i; i++)
                    {
                        string extension           = System.IO.Path.GetExtension(files[i].FileName);
                        string fileName            = new FormsHelper().GetNewGuidName(extension);
                        string formFilesFolderPath = FormHelper.GetBizFormFilesFolderPath(SiteContext.CurrentSiteName);
                        string fileNameString      = fileName + "/" + Path.GetFileName(files[i].FileName);
                        new FormsHelper().SaveFileToDisk(files[i], fileName, formFilesFolderPath);
                        newFormItem.SetValue(string.Format("File{0}", i + 1), (object)fileNameString);
                    }
                }
                newFormItem.Insert();

                new FormsHelper().SendFormEmail(newFormItem, files.Count);

                return(new GeneralResultDTO {
                    success = true
                });
            }
            else
            {
                return(new GeneralResultDTO {
                    success = false, errorMessage = ResHelper.GetString("Kadena.NewBidRequest.RepositoryNotFound", LocalizationContext.CurrentCulture.CultureCode)
                });
            }
        }
Ejemplo n.º 17
0
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        CurrentMaster.DisplayControlsPanel = true;

        // Check 'ReadData' permission
        if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.form", "ReadData"))
        {
            RedirectToAccessDenied("cms.form", "ReadData");
        }
        // Check 'EditData' permission
        else if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.form", "EditData"))
        {
            RedirectToAccessDenied("cms.form", "EditData");
        }

        // Get form id from url
        formId = QueryHelper.GetInteger("formid", 0);
        if (formId > 0)
        {
            // Get form record id
            formRecordId = QueryHelper.GetInteger("formrecordid", 0);

            if (!RequestHelper.IsPostBack())
            {
                chkSendNotification.Checked  = (formRecordId <= 0);
                chkSendAutoresponder.Checked = (formRecordId <= 0);
            }

            bfi          = BizFormInfoProvider.GetBizFormInfo(formId);
            EditedObject = bfi;

            if (!RequestHelper.IsPostBack())
            {
                // Get form info
                if (bfi != null)
                {
                    // Set form
                    formElem.FormName          = bfi.FormName;
                    formElem.ItemID            = formRecordId;
                    formElem.ShowPrivateFields = true;
                }
            }

            formElem.FormRedirectToUrl  = String.Empty;
            formElem.FormDisplayText    = String.Empty;
            formElem.FormClearAfterSave = false;
            // Submit image button is based on ImageButton which does not have implemented automatic registration of Save header action in UI.
            // Hide image button in UI even if path to image is configured
            formElem.ShowImageButton = false;

            formElem.OnBeforeSave += formElem_OnBeforeSave;
        }
    }
Ejemplo n.º 18
0
    /// <summary>
    /// Loads all the fields from form selected in the first dropdown (selectForm) into the second dropdown (drpFields).
    /// </summary>
    private void LoadFields()
    {
        string className = ValidationHelper.GetString(selectForm.Value, null);

        if (className == null)
        {
            return;
        }

        var form = BizFormInfoProvider.GetBizFormInfo(className, SiteContext.CurrentSiteID);

        if (form == null)
        {
            return;
        }

        var classInfo = DataClassInfoProvider.GetDataClassInfo(form.FormClassID);

        if (classInfo == null)
        {
            return;
        }

        var formInfo = FormHelper.GetFormInfo(classInfo.ClassName, false);

        if (formInfo == null)
        {
            return;
        }

        drpFields.Items.Clear();
        drpFields.Enabled = false;

        IEnumerable <FormFieldInfo> fields;

        if (FieldsDataType != FieldDataType.Unknown)
        {
            fields = formInfo.GetFields(FieldsDataType).Where(x => x.Visible);
        }
        else
        {
            fields = formInfo.GetFields(true, true);
        }

        foreach (var fieldInfo in fields)
        {
            drpFields.Items.Add(new ListItem(fieldInfo.GetDisplayName(MacroResolver.GetInstance()), fieldInfo.Name));
        }

        if (drpFields.Items.Count > 0)
        {
            drpFields.Enabled = true;
        }
    }
Ejemplo n.º 19
0
 protected void FieldEditor_OnFieldNameChanged(object sender, string oldFieldName, string newFieldName)
 {
     if (formId > 0)
     {
         BizFormInfo formObj = BizFormInfoProvider.GetBizFormInfo(formId);
         if (formObj != null)
         {
             // Rename field in layout(s)
             FormHelper.RenameFieldInFormLayout(formObj.FormClassID, oldFieldName, newFieldName);
         }
     }
 }
        public IForm GetForm(string formName)
        {
            BizFormInfo formObject = BizFormInfoProvider.GetBizFormInfo(formName, SiteContext.CurrentSiteID);

            if (formObject != null)
            {
                var formInfo = _formFactory.Create(formObject);
                return(formInfo);
            }

            return(null);
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get needed IDs
        int formId = QueryHelper.GetInteger("formid", 0);

        bfi = BizFormInfoProvider.GetBizFormInfo(formId);

        altFormEdit.OnBeforeSave += (s, ea) => altFormEdit.EditedObject.FormClassID = bfi.FormClassID;
        altFormEdit.OnAfterSave  += altFormEdit_OnAfterSave;

        altFormEdit.RedirectUrlAfterCreate = String.Empty;
    }
Ejemplo n.º 22
0
        /// <summary>Performs scoring objects and rules generation.</summary>
        public void Generate()
        {
            if (ScoreInfoProvider.GetScores().WhereEquals("ScoreName", "EngagementAndBusinessFit")
                .WhereFalse("ScoreBelongsToPersona").TopN(1).FirstOrDefault() != null)
            {
                return;
            }

            var scoreObj = new ScoreInfo
            {
                ScoreDisplayName = "Engagement and business fit",
                ScoreName        = "EngagementAndBusinessFit",
                ScoreDescription =
                    "Measures the fit and interest of B2B prospects on the site. Fit is measured by demographics and geographics. Interest is measured by behavior on the site that can be tied to B2B activities, such as visiting the 'Partnership' section of the site or providing a phone number.",
                ScoreEnabled           = true,
                ScoreStatus            = ScoreStatusEnum.RecalculationRequired,
                ScoreEmailAtScore      = 20,
                ScoreNotificationEmail = "*****@*****.**"
            };

            ScoreInfoProvider.SetScoreInfo(scoreObj);
            var treeNode = DocumentHelper.GetDocuments().All().Culture("en-US").Path("/Partnership").Columns("NodeID")
                           .OnCurrentSite().TopN(1).FirstOrDefault();

            if (treeNode != null)
            {
                var rule = GenerateRule("Visited the Partnership section", 5, scoreObj.ScoreID,
                                        "<condition>\r\n  <activity name=\"pagevisit\">\r\n    <field name=\"ActivityCreated\">\r\n      <settings>\r\n        <seconddatetime>1/1/0001 12:00:00 AM</seconddatetime>\r\n      </settings>\r\n    </field>\r\n    <field name=\"ActivityNodeID\">\r\n      <value>" +
                                        treeNode.NodeID +
                                        "</value>\r\n    </field>\r\n    <field name=\"ActivityURL\">\r\n      <settings>\r\n        <operator>0</operator>\r\n      </settings>\r\n    </field>\r\n    <field name=\"ActivityTitle\">\r\n      <settings>\r\n        <operator>0</operator>\r\n      </settings>\r\n    </field>\r\n    <field name=\"ActivityComment\">\r\n      <settings>\r\n        <operator>0</operator>\r\n      </settings>\r\n    </field>\r\n    <field name=\"ActivityCampaign\">\r\n      <settings>\r\n        <operator>0</operator>\r\n      </settings>\r\n    </field>\r\n    <field name=\"ActivityURLReferrer\">\r\n      <settings>\r\n        <operator>0</operator>\r\n      </settings>\r\n    </field>\r\n    <field name=\"ActivityABVariantName\">\r\n      <settings>\r\n        <operator>0</operator>\r\n      </settings>\r\n    </field>\r\n    <field name=\"ActivityMVTCombinationName\">\r\n      <settings>\r\n        <operator>0</operator>\r\n      </settings>\r\n    </field>\r\n  </activity>\r\n  <wherecondition>(ActivityType='pagevisit') AND ([ActivityNodeID] = " +
                                        treeNode.NodeID + ")</wherecondition>\r\n</condition>", RuleTypeEnum.Activity, "pagevisit", false);
                rule.RuleIsRecurring = true;
                rule.RuleMaxPoints   = 15;
                RuleInfoProvider.SetRuleInfo(rule);
            }

            var bizFormInfo = BizFormInfoProvider.GetBizFormInfo("BusinessCustomerRegistration", _mSite.SiteID);

            if (bizFormInfo != null)
            {
                GenerateRule("Submitted the business registration form", 15, scoreObj.ScoreID,
                             BuildMacroRuleCondition("{%Rule(\"(Contact.SubmittedForm(\\\"" + bizFormInfo.FormName +
                                                     "\\\", ToInt(0)))\", \"&lt;rules&gt;&lt;r pos=\\\"0\\\" par=\\\"\\\" op=\\\"and\\\" n=\\\"CMSContactHasSubmittedSpecifiedFormInLastXDays\\\" &gt;&lt;p n=\\\"_perfectum\\\"&gt;&lt;t&gt;has&lt;/t&gt;&lt;v&gt;&lt;/v&gt;&lt;r&gt;0&lt;/r&gt;&lt;d&gt;select operation&lt;/d&gt;&lt;vt&gt;text&lt;/vt&gt;&lt;tv&gt;0&lt;/tv&gt;&lt;/p&gt;&lt;p n=\\\"days\\\"&gt;&lt;t&gt;#enter days&lt;/t&gt;&lt;v&gt;0&lt;/v&gt;&lt;r&gt;0&lt;/r&gt;&lt;d&gt;enter days&lt;/d&gt;&lt;vt&gt;text&lt;/vt&gt;&lt;tv&gt;0&lt;/tv&gt;&lt;/p&gt;&lt;p n=\\\"item\\\"&gt;&lt;t&gt;" +
                                                     bizFormInfo.FormName + "&lt;/t&gt;&lt;v&gt;" + bizFormInfo.FormName +
                                                     "&lt;/v&gt;&lt;r&gt;1&lt;/r&gt;&lt;d&gt;select form&lt;/d&gt;&lt;vt&gt;text&lt;/vt&gt;&lt;tv&gt;0&lt;/tv&gt;&lt;/p&gt;&lt;/r&gt;&lt;/rules&gt;\")%}"),
                             RuleTypeEnum.Macro, null, false);
            }

            GenerateRule("Provided phone number", 10, scoreObj.ScoreID,
                         "<condition>\r\n  <attribute name=\"ContactBusinessPhone\">\r\n    <params>\r\n      <ContactBusinessPhoneOperator>9</ContactBusinessPhoneOperator>\r\n    </params>\r\n  </attribute>\r\n  <wherecondition>([ContactBusinessPhone] &lt;&gt; N'' AND [ContactBusinessPhone] IS NOT NULL)</wherecondition>\r\n</condition>",
                         RuleTypeEnum.Attribute, "ContactBusinessPhone");
            RecalculateScores();
        }
        public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            var request = controllerContext.HttpContext.Request;

            var formName = request.Form.Get("formname");
            var formInfo = BizFormInfoProvider.GetBizFormInfo(formName, SiteContext.CurrentSiteID);

            var formFactory = new FormFactory(new Forms.ControlFactory.ControlFactory());
            var form        = formFactory.Create(formInfo);

            foreach (var control in form.Controls)
            {
                if (control is IFileControl)
                {
                    var fileControl = control as IFileControl;
                    fileControl.SubmittedValue = request.Files[control.Name]?.FileName;
                    fileControl.SubmittedData  = request.Files[control.Name]?.InputStream;
                }
                // this (naively) assumes that a checkbox is a single item
                else if (control.Type == ControlType.CheckBox)
                {
                    var value = request.Form.Get(control.Name); // post form values for these types returns either no value or the name, so a value implies true
                    control.SubmittedValue = value?.Equals(control.Name, StringComparison.OrdinalIgnoreCase).ToString() ?? "";
                }
                else
                {
                    var submittedValue = request.Form.Get(control.Name);
                    if (control.Type == ControlType.Calendar)
                    {
                        if (submittedValue == "")
                        {
                            control.SubmittedValue = null;
                        }
                        else
                        {
                            DateTime date;
                            var      enGB = new CultureInfo("en-GB");
                            if (DateTime.TryParseExact(submittedValue, "dd/MM/yyyy", enGB, DateTimeStyles.None, out date))
                            {
                                control.SubmittedValue = date.ToString("yyyy-MM-dd HH:mm:ss");
                            }
                        }
                    }
                    else
                    {
                        control.SubmittedValue = submittedValue;
                    }
                }
            }

            return(form);
        }
Ejemplo n.º 24
0
    /// <summary>
    /// Custom layout checkbox checked changed.
    /// </summary>
    protected void chkCustomLayout_CheckedChanged(object sender, EventArgs e)
    {
        pnlCustomLayout.Visible = !pnlCustomLayout.Visible;

        if (chkCustomLayout.Checked)
        {
            BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo(formId);
            if (bfi != null && bfi.FormEmailTemplate != null)
            {
                htmlEditor.ResolvedValue = bfi.FormEmailTemplate;
            }
        }
    }
Ejemplo n.º 25
0
    protected void altFormEdit_OnAfterSave(object sender, EventArgs e)
    {
        // Required to log staging task, alternative form is not bound to bizform as a child
        using (CMSActionContext context = new CMSActionContext())
        {
            context.CreateVersion = false;

            // Log synchronization
            int         formId = QueryHelper.GetInteger("formid", 0);
            BizFormInfo bfi    = BizFormInfoProvider.GetBizFormInfo(formId);
            SynchronizationHelper.LogObjectChange(bfi, TaskTypeEnum.UpdateObject);
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get needed IDs
        int formId = QueryHelper.GetInteger("formid", 0);

        bfi = BizFormInfoProvider.GetBizFormInfo(formId);

        altFormEdit.OnBeforeSave += (s, ea) => ((AlternativeFormInfo)altFormEdit.EditedObject).FormClassID = bfi.FormClassID;
        altFormEdit.OnAfterSave  += altFormEdit_OnAfterSave;

        altFormEdit.RedirectUrlAfterCreate     = String.Empty;
        CurrentMaster.Title.Breadcrumbs[0, 1] += "?formid=" + bfi.FormID;
    }
Ejemplo n.º 27
0
        private void CreateFormSubmission(ITreeNode document, string formName, ContactInfo contact)
        {
            var dataClassInfo =
                DataClassInfoProviderBase <DataClassInfoProvider> .GetDataClassInfo(BizFormInfoProvider
                                                                                    .GetBizFormInfo(formName, _mSiteInfo.SiteID).FormClassID);

            var formItem = new BizFormItem(dataClassInfo.ClassName);

            _mFormActivityGenerator.GenerateFormSubmitActivity(formItem, document, contact.ContactID,
                                                               _mSiteInfo.SiteID);
            CopyDataFromContactToForm(contact, dataClassInfo, formItem);
            SetFormSpecificData(formName, contact, formItem);
            formItem.Insert();
        }
Ejemplo n.º 28
0
 protected void FieldEditor_OnAfterDefinitionUpdate(object sender, EventArgs e)
 {
     // Update form to log synchronization
     if (formId > 0)
     {
         BizFormInfo formObj = BizFormInfoProvider.GetBizFormInfo(formId);
         if (formObj != null)
         {
             // Enforce Form property reload next time the data are needed
             formObj.ResetFormInfo();
             BizFormInfoProvider.SetBizFormInfo(formObj);
         }
     }
 }
    /// <summary>
    /// Sets visibility of custom layout form.
    /// </summary>
    private void SetCustomLayoutVisibility(bool visible)
    {
        pnlCustomLayout.Visible = visible;
        attachments.Enabled     = visible;

        if (visible)
        {
            // Reload HTML editor content
            BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo(formId);
            if (bfi != null && bfi.FormConfirmationTemplate != null)
            {
                htmlEditor.ResolvedValue = bfi.FormConfirmationTemplate;
            }
        }
    }
        private GeneralResultDTO SubmitContactUsFormInternal(string fullName, string companyName, string email, string phone, string message, List <HttpPostedFile> files)
        {
            var contactUsForm = BizFormInfoProvider.GetBizFormInfo(_ContactUsFormCodeName, SiteContext.CurrentSiteID);

            if (contactUsForm != null)
            {
                var    contactUsFormClass     = DataClassInfoProvider.GetDataClassInfo(contactUsForm.FormClassID);
                string contactUsFormClassName = contactUsFormClass.ClassName;

                BizFormItem newFormItem = BizFormItem.New(contactUsFormClassName);

                newFormItem.SetValue("FullName", fullName);
                newFormItem.SetValue("CompanyName", companyName);
                newFormItem.SetValue("Email", email);
                newFormItem.SetValue("Phone", phone);
                newFormItem.SetValue("Message", message);
                newFormItem.SetValue("Site", SiteContext.CurrentSite.DisplayName);
                newFormItem.SetValue("User", MembershipContext.AuthenticatedUser.UserName);
                newFormItem.SetValue("FormInserted", DateTime.Now);
                newFormItem.SetValue("FormUpdated", DateTime.Now);

                if (files.Count > 0)
                {
                    for (int i = 0; files.Count > i; i++)
                    {
                        string extension           = System.IO.Path.GetExtension(files[i].FileName);
                        string fileName            = new FormsHelper().GetNewGuidName(extension);
                        string formFilesFolderPath = FormHelper.GetBizFormFilesFolderPath(SiteContext.CurrentSiteName);
                        string fileNameString      = fileName + "/" + Path.GetFileName(files[i].FileName);
                        new FormsHelper().SaveFileToDisk(files[i], fileName, formFilesFolderPath);
                        newFormItem.SetValue(string.Format("File{0}", i + 1), (object)fileNameString);
                    }
                }
                newFormItem.Insert();

                new FormsHelper().SendFormEmail(newFormItem, files.Count);

                return(new GeneralResultDTO {
                    success = true
                });
            }
            else
            {
                return(new GeneralResultDTO {
                    success = false, errorMessage = ResHelper.GetString("Kadena.ContactForm.ContactFormRepositoryNotFound", LocalizationContext.CurrentCulture.CultureCode)
                });
            }
        }