使用c#修改WFFM信息 [英] Modifying WFFM Information Using c#

查看:82
本文介绍了使用c#修改WFFM信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已经使用Sitecore 6.4.0网站上的面向营销人员的Web表单"设置了一个简单表单.该表单可以很好地记录信息,并且我们已经编写了一个页面,允许最终用户使用

We have setup a simple form using Web Forms For Marketers on our Sitecore 6.4.0 site. The form is logging information just fine, and we have written a page to allow end-users to view the results, using the code from http://r-coding-sitecoreblog.blogspot.com/2011/11/extracting-data-from-sitecore-wffm.html mainly.

进度的下一步是允许用户批准/拒绝提交,并将该表单提交的信息传递给方法,或者一起删除该表单提交.

The next step in the progression is to allow a user to approve/reject a submission, and to either pass that form submission's information to a method, or to delete that form submission all together.

是否可以使用c#从WFFM数据库中删除表单提交?我试过Sitecore.Forms.Data.DataManager.DeleteForms()方法很不幸,我怀疑它会删除整个表单,而不仅仅是单个表单提交.

Is there a way to delete a form submission from the WFFM database using c#? I have tried the Sitecore.Forms.Data.DataManager.DeleteForms() method with no luck, and I suspect it deletes the entire form, not just the individual form submission.

此外,我什至可以在单个表单提交上设置一个标志,将其标记为已批准/已拒绝,并且只处理代码中的显示/隐藏逻辑.因此,为特定的表单提交设置值也可以.

Additionally, I could handle even setting a flag on the individual form submission, marking it as approved/rejected, and just handling the show/hide logic in my code. So setting a value on a particular form submission would also work.

推荐答案

我们也随时欢迎您在我的博客上发表与使用我的代码示例有关的问题:-)

You are always welcome to post questions related to the use of my code examples on my blog also :-)

使用Datamanager类使您处在正确的轨道上. 这是一个示例(一个一个地)删除表单的所有记录/提交的示例.

You are on the right tracks with using the Datamanager class. Here's an example that deletes all records/submits for a form (one by one).

它不会自行删除表格.仅提交数据库条目.

It will NOT delete the form it self. Only submitted database entries.

        string formID = ConfigurationManager.AppSettings["FormDataUploadID"].ToString(); 

        List<GridFilter> args = new List<Sitecore.Web.UI.Grids.GridFilter>();
        args.Add(new GridFilter("storageName", string.Empty, GridFilter.FilterOperator.Contains));
        args.Add(new GridFilter("dataKey", formID, GridFilter.FilterOperator.Contains));

        var submits = Sitecore.Forms.Data.DataManager.GetForms().GetPage(new PageCriteria(0, 0x7ffffffe), null, args);

        /// Create a Collection to Loop
        List<IForm> formlist = submits.ToList();

        /// Loop all forms from Database and delete each entry.
        foreach (IForm frm in formlist)
        {
            Sitecore.Forms.Data.DataManager.DeleteForms(new Sitecore.Data.ID(frm.FormItemId), frm.StorageName);
        }

这篇关于使用c#修改WFFM信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆