Exemple #1
0
        /// <summary>
        /// 字段绑定事件
        /// </summary>
        protected void RepeaterFields_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                DNNGo_PowerForms_Field FieldItem = e.Item.DataItem as DNNGo_PowerForms_Field;

                if (FieldItem != null && FieldItem.ID > 0)
                {
                    Literal liFieldType = e.Item.FindControl("liFieldType") as Literal;
                    liFieldType.Text = EnumHelper.GetEnumTextVal(FieldItem.FieldType, typeof(EnumViewControlType));

                    Literal liName = e.Item.FindControl("liName") as Literal;
                    liName.Text = WebHelper.leftx(FieldItem.Name, 30, "...");

                    if (FieldItem.GroupID > 0)
                    {
                        DNNGo_PowerForms_Group Group = DNNGo_PowerForms_Group.FindByKeyForEdit(FieldItem.GroupID);
                        if (Group != null && Group.ID > 0)
                        {
                            Literal liGroup = e.Item.FindControl("liGroup") as Literal;
                            liGroup.Text = WebHelper.leftx(Group.Name, 20, "...");
                        }
                    }
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// 设置数据项
        /// </summary>
        private void SetDataItem()
        {
            //查询出当前字段的列表
            String jsonFields = WebHelper.GetStringParam(Request, nestable_output.UniqueID, "");

            if (!String.IsNullOrEmpty(jsonFields))
            {
                JavaScriptSerializer          json        = new JavaScriptSerializer();
                List <DNNGo_PowerForms_Field> json_fields = json.Deserialize <List <DNNGo_PowerForms_Field> >(jsonFields);
                if (json_fields != null && json_fields.Count > 0)
                {
                    List <DNNGo_PowerForms_Field> FieldLists = FieldList;

                    for (int i = 0; i < json_fields.Count; i++)
                    {
                        DNNGo_PowerForms_Field DBField = FieldLists.Find(r => r.ID == json_fields[i].ID);
                        if (DBField != null && DBField.ID > 0 && DBField.Sort != i)
                        {
                            DBField.Sort = i;
                            DBField.Update();
                        }
                    }
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// 列表上的项删除事件
        /// </summary>
        protected void btnRemove_Click(object sender, EventArgs e)
        {
            try
            {
                LinkButton btnRemove = (LinkButton)sender;

                if (btnRemove != null && !String.IsNullOrEmpty(btnRemove.CommandArgument))
                {
                    DNNGo_PowerForms_Field Field = DNNGo_PowerForms_Field.FindByKeyForEdit(btnRemove.CommandArgument);

                    if (Field != null && Field.ID > 0)
                    {
                        mTips.IsPostBack = true;
                        if (Field.Delete() > 0)
                        {
                            //操作成功
                            mTips.LoadMessage("DeleteFieldSuccess", EnumTips.Success, this, new String[] { Field.Alias });
                        }
                        else
                        {
                            //操作失败
                            mTips.LoadMessage("DeleteFieldError", EnumTips.Success, this, new String[] { Field.Alias });
                        }

                        BindDataList();
                    }
                }
            }
            catch (Exception ex)
            {
                ProcessModuleLoadException(ex);
            }
        }
        protected void cmdUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                Int32 ArticleStatus = -1;
                DNNGo_PowerForms_Field fieldItem = new DNNGo_PowerForms_Field();
                Int32 SaveResult = SetDataItem(ArticleStatus, out fieldItem);



                if (SaveResult > 0)
                {
                    mTips.LoadMessage("SaveFieldSuccess", EnumTips.Success, this, new String[] { fieldItem.Name });
                    Response.Redirect(xUrl("FieldID", fieldItem.ID.ToString(), "AddNewField"), false);
                }
                else if (SaveResult == -1)
                {
                    mTips.IsPostBack = true;
                    mTips.LoadMessage("AddFieldOverlap", EnumTips.Error, this, new String[] { fieldItem.Name });
                }
                else
                {
                    mTips.IsPostBack = true;
                    mTips.LoadMessage("SaveFieldError", EnumTips.Error, this, new String[] { "" });
                }
            }
            catch (Exception ex)
            {
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex);
            }
        }
        /// <Description>
        /// 绑定树分类
        /// </Description>
        private void BindTreeGroups(DNNGo_PowerForms_Field Article)
        {
            List <Int32> SelectList = new List <Int32>();


            //绑定所有分类到页面
            QueryParam qp = new QueryParam();

            qp.Orderfld  = DNNGo_PowerForms_Group._.Sort;
            qp.OrderType = 0;
            int RecordCount = 0;

            qp.Where.Add(new SearchParam(DNNGo_PowerForms_Group._.ModuleId, ModuleId, SearchType.Equal));
            List <DNNGo_PowerForms_Group> lst = DNNGo_PowerForms_Group.FindAll(qp, out RecordCount);

            StringBuilder GroupListContent = new StringBuilder();

            foreach (var Group in lst)
            {
                GroupListContent.AppendFormat("{0}:{1}", Group.Name, Group.ID).AppendLine();
            }

            //拼接顶级分类的方法
            ControlHelper ctl = new ControlHelper(this);

            SettingEntity GroupControl = new SettingEntity();

            GroupControl.Name         = "GroupControl";
            GroupControl.Alias        = "GroupControl";
            GroupControl.ControlType  = EnumViewControlType.RadioButtonList.ToString();
            GroupControl.DefaultValue = Article.GroupID.ToString();
            GroupControl.ListContent  = GroupListContent.ToString();

            PHGroups.Controls.Add((Control)ctl.ViewControl(GroupControl));
        }
        protected void cmdDelete_Click(object sender, EventArgs e)
        {
            try
            {
                //查出相关的信息,然后修改状态
                DNNGo_PowerForms_Field ExtendFieldItem = DNNGo_PowerForms_Field.FindByKeyForEdit(FieldID);
                if (ExtendFieldItem != null && ExtendFieldItem.ID > 0)
                {
                    if (ExtendFieldItem.Delete() > 0)
                    {
                        //字段删除成功
                        mTips.LoadMessage("DeleteFieldSuccess", EnumTips.Success, this, new String[] { ExtendFieldItem.Name });
                    }
                    else
                    {
                        //字段删除失败
                        mTips.LoadMessage("DeleteFieldError", EnumTips.Error, this, new String[] { ExtendFieldItem.Name });
                    }
                }



                Response.Redirect(xUrl("FieldList"));
            }
            catch (Exception ex)
            {
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex);
            }
        }
        protected void Page_Init(System.Object sender, System.EventArgs e)
        {
            try
            {
                if (!IsPostBack)
                {
                    //检测是否安装过默认字段 显示名,邮箱,消息
                    if (!InstallationDefault)//没有安装过进入
                    {
                        UpdateModuleSetting("PowerForms_InstallationDefault", "true");

                        //并且里面不存在任何字段的
                        if (DNNGo_PowerForms_Field.FindCount(DNNGo_PowerForms_Field._.ModuleId, ModuleId) == 0)
                        {
                            DNNGo_PowerForms_Field.InstallField("Name", this);
                            DNNGo_PowerForms_Field.InstallField("Email", this);
                            DNNGo_PowerForms_Field.InstallField("Messages", this);
                            Response.Redirect(Globals.NavigateURL());
                        }
                    }
                }



                //绑定容器内的子控件
                BindContainer();
            }
            catch (Exception exc) //Module failed to load
            {
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Exemple #8
0
        /// <summary>
        /// 显示内容值
        /// </summary>
        /// <param name="ContentItem"></param>
        /// <returns></returns>
        public static String ViewContentValue(List <DNNGo_PowerForms_Field> fieldList, DNNGo_PowerForms_ContentItem ItemInfo, DNNGo_PowerForms_Content ContentItem)
        {
            if (!String.IsNullOrEmpty(ItemInfo.ContentValue))
            {
                String LiContentValue = ItemInfo.ContentValue;

                DNNGo_PowerForms_Field fielditem = fieldList.Find(r => r.ID == ItemInfo.FieldID);

                if (fielditem != null && fielditem.ID > 0 && fielditem.FieldType == (Int32)EnumViewControlType.TextBox)
                {
                    LiContentValue = HttpUtility.HtmlEncode(ItemInfo.ContentValue);
                }
                else if (ItemInfo.ContentValue.IndexOf("Url://") >= 0)
                {
                    LiContentValue = String.Format("/Portals/{0}/PowerForms/{1}/{2}", ContentItem.PortalId, ContentItem.ModuleId, ItemInfo.ContentValue.Replace("Url://", ""));

                    //看看是否需要加http
                    if (LiContentValue.ToLower().IndexOf("http://") < 0 && LiContentValue.ToLower().IndexOf("https://") < 0)
                    {
                        LiContentValue = string.Format("http://{0}{1}", WebHelper.GetHomeUrl(), LiContentValue);
                    }
                }
                else
                {
                    LiContentValue = ItemInfo.ContentValue;
                }
                return(LiContentValue);
            }
            return(String.Empty);
        }
Exemple #9
0
        protected void lbSort_Click(object sender, EventArgs e)
        {
            LinkButton ImgbutSort = (LinkButton)sender;

            if (ImgbutSort != null)
            {
                //查出当前要排序的字段
                DNNGo_PowerForms_Field objC = DNNGo_PowerForms_Field.FindByKeyForEdit(ImgbutSort.CommandArgument);

                mTips.IsPostBack = true;//回发时就要触发
                if (ImgbutSort.ToolTip == "up")
                {
                    DNNGo_PowerForms_Field.MoveField(objC, EnumMoveType.Up, ModuleId);
                    //字段上移成功
                    mTips.LoadMessage("UpMoveFieldSuccess", EnumTips.Success, this, new String[] { "" });
                }
                else
                {
                    DNNGo_PowerForms_Field.MoveField(objC, EnumMoveType.Down, ModuleId);
                    //字段下移成功

                    mTips.LoadMessage("DownMoveFieldSuccess", EnumTips.Success, this, new String[] { "" });
                }
                //绑定一下
                BindDataList();
            }
        }
Exemple #10
0
        /// <summary>
        /// 自定义字段转XML实体
        /// </summary>
        /// <param name="fieldItem"></param>
        /// <returns></returns>
        public DNNGo_PowerForms_Field XmlToEntity(FieldEntity fieldItem)
        {
            DNNGo_PowerForms_Field fileEntity = new DNNGo_PowerForms_Field();

            fileEntity.Name         = fieldItem.Name;
            fileEntity.Alias        = fieldItem.Alias;
            fileEntity.DefaultValue = fieldItem.DefaultValue;
            fileEntity.Description  = fieldItem.Description;
            fileEntity.Direction    = fieldItem.Direction;
            fileEntity.FieldType    = fieldItem.FieldType;
            fileEntity.FiledList    = fieldItem.FiledList;
            fileEntity.Required     = fieldItem.Required;
            fileEntity.Rows         = fieldItem.Rows;
            fileEntity.Sort         = fieldItem.Sort;
            fileEntity.Status       = fieldItem.Status;
            fileEntity.ToolTip      = fieldItem.ToolTip;
            fileEntity.Verification = fieldItem.Verification;
            fileEntity.Width        = fieldItem.Width;

            fileEntity.WidthSuffix  = fieldItem.WidthSuffix;
            fileEntity.ListColumn   = fieldItem.ListColumn;
            fileEntity.Options      = fieldItem.Options;
            fileEntity.StartTime    = fieldItem.StartTime;
            fileEntity.EndTime      = fieldItem.EndTime;
            fileEntity.Per_AllUsers = fieldItem.Per_AllUsers;
            fileEntity.Per_Roles    = fieldItem.Per_Roles;



            if (!String.IsNullOrEmpty(fieldItem.Group))
            {
                DNNGo_PowerForms_Group GroupItem = DNNGo_PowerForms_Group.FindByName(fieldItem.Group, ModuleID);
                if (!(GroupItem != null && GroupItem.ID > 0))
                {
                    GroupItem = new DNNGo_PowerForms_Group();

                    GroupItem.Name = fieldItem.Group;

                    GroupItem.Status = fileEntity.Status;
                    GroupItem.Sort   = fileEntity.Sort;

                    GroupItem.LastIP   = WebHelper.UserHost;
                    GroupItem.LastTime = DateTime.Now;
                    GroupItem.LastUser = UserId;

                    GroupItem.ModuleId = ModuleID;
                    GroupItem.PortalId = portalInfo.PortalID;

                    GroupItem.Insert();
                }

                fileEntity.GroupID = GroupItem.ID;
            }

            fileEntity.ModuleId = ModuleID;
            fileEntity.PortalId = portalInfo.PortalID;

            return(fileEntity);
        }
Exemple #11
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// ImportModule implements the IPortable ImportModule Interface
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name="ModuleID">The ID of the Module being imported</param>
        /// <param name="Content">The Content being imported</param>
        /// <param name="Version">The Version of the Module Content being imported</param>
        /// <param name="UserID">The UserID of the User importing the Content</param>
        /// <history>
        /// </history>
        /// -----------------------------------------------------------------------------

        public void ImportModule(int ModuleID, string Content, string Version, int UserId)
        {
            //先清除原有的字段列表
            QueryParam qp          = new QueryParam();
            Int32      RecordCount = 0;

            qp.Where.Add(new SearchParam("ModuleId", ModuleID, SearchType.Equal));
            List <DNNGo_PowerForms_Field> fieldList = DNNGo_PowerForms_Field.FindAll(qp, out RecordCount);

            foreach (DNNGo_PowerForms_Field fieldItem in fieldList)
            {
                fieldItem.Delete();
            }


            ImportExportHelper ieHelper = new ImportExportHelper();

            ieHelper.ModuleID = ModuleID;
            ieHelper.UserId   = UserId;

            if (!String.IsNullOrEmpty(Content))
            {
                //将XML转换为实体
                XmlFormat xf = new XmlFormat();
                xf.XmlDoc.LoadXml(Content);
                List <FieldEntity>           XmlFieldList   = xf.ToList <FieldEntity>();
                List <GallerySettingsEntity> XmlSettingList = xf.ToList <GallerySettingsEntity>();

                Int32 InsertResult = 0;
                foreach (FieldEntity XmlField in XmlFieldList)
                {
                    DNNGo_PowerForms_Field FieldItem = ieHelper.XmlToEntity(XmlField);

                    FieldItem.CreateUser = UserId;
                    FieldItem.CreateTime = DateTime.Now;

                    FieldItem.LastIP   = WebHelper.UserHost;
                    FieldItem.LastTime = DateTime.Now;
                    FieldItem.LastUser = UserId;

                    if (FieldItem.Insert() > 0)
                    {
                        InsertResult++;
                    }
                }

                //插入设置的记录
                foreach (GallerySettingsEntity XmlSettingItem in XmlSettingList)
                {
                    if (!String.IsNullOrEmpty(XmlSettingItem.SettingName) && !String.IsNullOrEmpty(XmlSettingItem.SettingValue))
                    {
                        ieHelper.UpdateModuleSetting(XmlSettingItem.SettingName, XmlSettingItem.SettingValue);
                    }
                }
            }
        }
Exemple #12
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// ExportModule implements the IPortable ExportModule Interface
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name="ModuleID">The Id of the module to be exported</param>
        /// <history>
        /// </history>
        /// -----------------------------------------------------------------------------

        public string ExportModule(int ModuleID)
        {
            string strXML = String.Empty;

            ImportExportHelper ieHelper = new ImportExportHelper();

            ieHelper.ModuleID = ModuleID;

            //查询字段的数据,填充待导出的XML实体
            QueryParam qp          = new QueryParam();
            Int32      RecordCount = 0;

            qp.Orderfld  = DNNGo_PowerForms_Field._.Sort;
            qp.OrderType = 0;
            qp.Where.Add(new SearchParam("ModuleId", ModuleID, SearchType.Equal));
            List <DNNGo_PowerForms_Field> fieldList      = DNNGo_PowerForms_Field.FindAll(qp, out RecordCount);
            List <FieldEntity>            xmlFieldList   = new List <FieldEntity>();
            List <GallerySettingsEntity>  xmlSettingList = new List <GallerySettingsEntity>();

            foreach (DNNGo_PowerForms_Field fieldItem in fieldList)
            {
                xmlFieldList.Add(ieHelper.EntityToXml(fieldItem));
            }

            if (xmlFieldList != null && xmlFieldList.Count > 0)
            {
                //查询出所有的配置项
                List <SettingEntity> EffectSettingDB = ieHelper.Setting_EffectSettingDB;
                if (EffectSettingDB != null && EffectSettingDB.Count > 0)
                {
                    foreach (SettingEntity SettingItem in EffectSettingDB)
                    {
                        String SettingValue = ieHelper.ViewXmlSetting(SettingItem.Name, SettingItem.DefaultValue).ToString();
                        xmlSettingList.Add(new GallerySettingsEntity(ieHelper.EffectSettingsFormat(ieHelper.Settings_EffectName, SettingItem.Name), SettingValue));
                    }

                    foreach (String key in ieHelper.PowerForms_Settings.Keys)
                    {
                        if (!xmlSettingList.Exists(r1 => r1.SettingName == key) && key.IndexOf("Gallery") != 0)
                        {
                            xmlSettingList.Add(new GallerySettingsEntity(key, Convert.ToString(ieHelper.PowerForms_Settings[key])));
                        }
                    }
                }


                XmlFormat xf = new XmlFormat(HttpContext.Current.Server.MapPath(String.Format("{0}Resource/xml/FieldEntity.xml", "~/DesktopModules/DNNGo_PowerForms/")));
                strXML = xf.ToXml <FieldEntity>(xmlFieldList, xmlSettingList);
            }
            else
            {
            }

            return(strXML);
        }
Exemple #13
0
        /// <summary>
        /// 绑定列表
        /// </summary>
        private void BindDataList()
        {
            QueryParam qp = new QueryParam();

            qp.OrderType = OrderType;
            if (!String.IsNullOrEmpty(Orderfld))
            {
                qp.Orderfld = Orderfld;
            }
            else
            {
                qp.Orderfld = DNNGo_PowerForms_Field._.Sort;
            }

            #region "分页的一系列代码"


            int RecordCount = 0;
            int pagesize    = qp.PageSize = 10;
            qp.PageIndex = PageIndex;


            #endregion

            //查询的方法
            qp.Where = BindSearch();

            List <DNNGo_PowerForms_Field> Fields = DNNGo_PowerForms_Field.FindAll(qp, out RecordCount);
            qp.RecordCount      = RecordCount;
            RecordPages         = qp.Pages;
            lblRecordCount.Text = String.Format("{0} {2} / {1} {3}", RecordCount, RecordPages, ViewResourceText("Title_Items", "Items"), ViewResourceText("Title_Pages", "Pages"));

            hlAllFields.Text       = String.Format("{1} ({0})", DNNGo_PowerForms_Field.FindCountByStatus(ModuleId, -1), ViewResourceText("hlAllFields", "All"));
            hlActivationField.Text = String.Format("{1} ({0})", DNNGo_PowerForms_Field.FindCountByStatus(ModuleId, (Int32)EnumStatus.Activation), ViewResourceText("hlActivationField", "Activation"));
            hlHideField.Text       = String.Format("{1} ({0})", DNNGo_PowerForms_Field.FindCountByStatus(ModuleId, (Int32)EnumStatus.Hide), ViewResourceText("hlHideField", "Hide"));



            //ctlPagingControl.TotalRecords = RecordCount;

            //if (RecordCount <= pagesize)
            //{
            //    ctlPagingControl.Visible = false;

            //}

            gvFieldList.DataSource = Fields;
            gvFieldList.DataBind();
            BindGridViewEmpty <DNNGo_PowerForms_Field>(gvFieldList, new DNNGo_PowerForms_Field());
            gvFieldList.Columns[7].Visible = false;                  //屏蔽排序的列
            gvFieldList.Columns[2].Visible = Setting_EffectDB.Group; //分组展现
        }
Exemple #14
0
        /// <summary>
        /// 导出数据到XML
        /// </summary>
        protected void cmdExportToXml_Click(object sender, EventArgs e)
        {
            ImportExportHelper ieHelper = new ImportExportHelper();

            ieHelper.ModuleID = ModuleId;

            //查询字段的数据,填充待导出的XML实体
            QueryParam qp          = new QueryParam();
            Int32      RecordCount = 0;

            qp.Orderfld  = DNNGo_PowerForms_Field._.Sort;
            qp.OrderType = 0;
            qp.Where.Add(new SearchParam("ModuleId", ModuleId, SearchType.Equal));
            List <DNNGo_PowerForms_Field> fieldList      = DNNGo_PowerForms_Field.FindAll(qp, out RecordCount);
            List <FieldEntity>            xmlFieldList   = new List <FieldEntity>();
            List <GallerySettingsEntity>  xmlSettingList = new List <GallerySettingsEntity>();

            foreach (DNNGo_PowerForms_Field fieldItem in fieldList)
            {
                xmlFieldList.Add(ieHelper.EntityToXml(fieldItem));
            }

            //查询出所有的配置项
            List <SettingEntity> EffectSettingDB = ieHelper.Setting_EffectSettingDB;

            if (EffectSettingDB != null && EffectSettingDB.Count > 0)
            {
                foreach (SettingEntity SettingItem in EffectSettingDB)
                {
                    String SettingValue = ieHelper.ViewXmlSetting(SettingItem.Name, SettingItem.DefaultValue).ToString();
                    xmlSettingList.Add(new GallerySettingsEntity(ieHelper.EffectSettingsFormat(ieHelper.Settings_EffectName, SettingItem.Name), SettingValue));
                }

                foreach (String key in ieHelper.PowerForms_Settings.Keys)
                {
                    if (!xmlSettingList.Exists(r1 => r1.SettingName == key) && key.IndexOf("Gallery") != 0)
                    {
                        xmlSettingList.Add(new GallerySettingsEntity(key, Convert.ToString(ieHelper.PowerForms_Settings[key])));
                    }
                }
            }

            XmlFormat xf = new XmlFormat(MapPath(String.Format("{0}Resource/xml/FieldEntity.xml", ModulePath)));
            //将字段列表转换成XML的实体
            String XmlContent  = xf.ToXml <FieldEntity>(xmlFieldList, xmlSettingList);
            String XmlFilePath = FileSystemUtils.SaveXmlToFile(String.Format("FieldListEntity_{0}_{1}.xml", ModuleId, xUserTime.UtcTime().ToString("yyyyMMddHHmmssffff")), XmlContent, this);

            FileSystemUtils.DownloadFile(XmlFilePath, "FieldListEntity.xml");
        }
        /// <summary>
        /// 验证字段名是否重复
        /// </summary>
        /// <returns></returns>
        private String ValidationCustomFieldName(string validateId, string validateValue, string validateError)
        {
            String validateJSON = "true";

            Int32 ModuleID = WebHelper.GetIntParam(Request, "ModuleID", 0);


            QueryParam qp = new QueryParam();

            qp.Where.Add(new SearchParam(DNNGo_PowerForms_Field._.Name, validateValue, SearchType.Equal));
            qp.Where.Add(new SearchParam(DNNGo_PowerForms_Field._.ModuleId, ModuleID, SearchType.Equal));

            if (DNNGo_PowerForms_Field.FindCount(qp) > 0)
            {
                validateJSON = "false";
            }

            return(validateJSON);
        }
Exemple #16
0
        /// <summary>
        /// 状态应用按钮事件
        /// </summary>
        protected void btnApply_Click(object sender, EventArgs e)
        {
            try
            {
                Int32 Status = WebHelper.GetIntParam(Request, ddlStatus.UniqueID, -1);

                if (Status >= 0)
                {
                    string   Checkbox_Value       = WebHelper.GetStringParam(Request, "Checkbox", "");
                    string[] Checkbox_Value_Array = Checkbox_Value.Split(',');
                    Int32    IDX = 0;
                    mTips.IsPostBack = true;
                    for (int i = 0; i < Checkbox_Value_Array.Length; i++)
                    {
                        if (Int32.TryParse(Checkbox_Value_Array[i], out IDX))
                        {
                            DNNGo_PowerForms_Field Field = DNNGo_PowerForms_Field.FindByKeyForEdit(IDX);
                            if (Field != null && Field.ID > 0)
                            {
                                Field.Status = Status;
                                if (Field.Update() > 0)
                                {
                                    //操作成功
                                    mTips.LoadMessage("UpdateFieldSuccess", EnumTips.Success, this, new String[] { Field.Alias });
                                }
                                else
                                {
                                    //操作失败
                                    mTips.LoadMessage("UpdateFieldError", EnumTips.Success, this, new String[] { Field.Alias });
                                }
                            }
                        }
                    }

                    BindDataList();
                }
            }
            catch (Exception ex)
            {
                ProcessModuleLoadException(ex);
            }
        }
Exemple #17
0
        /// <summary>
        /// 查找Eamil字段
        /// </summary>
        /// <param name="FieldList"></param>
        /// <returns></returns>
        public String ViewEmailField(List <DNNGo_PowerForms_Field> FieldList)
        {
            //验证类型为邮箱的
            DNNGo_PowerForms_Field fieldItem = FieldList.Find(r1 => r1.ID > 0 && (r1.Verification == (Int32)EnumVerification.email || r1.FieldType == (Int32)EnumViewControlType.DropDownList_SendEmail));

            if (fieldItem != null && fieldItem.ID > 0)
            {
                return(fieldItem.Name);
            }

            //先找出首选项为email的
            fieldItem = FieldList.Find(r1 => r1.Name.IndexOf("Email", StringComparison.CurrentCultureIgnoreCase) >= 0);
            if (fieldItem != null && fieldItem.ID > 0 && fieldItem.Verification == (Int32)EnumVerification.email)
            {
                return("Email");
            }


            return("");
        }
        /// <summary>
        /// 验证字段名是否重复
        /// </summary>
        /// <returns></returns>
        private String ValidationFieldName(string validateId, string validateValue, string validateError)
        {
            String validateJSON = String.Empty;

            Int32 ModuleID = WebHelper.GetIntParam(Request, "ModuleID", 0);

            QueryParam qp = new QueryParam();

            qp.Where.Add(new SearchParam(DNNGo_PowerForms_Field._.Name, validateValue, SearchType.Equal));
            qp.Where.Add(new SearchParam(DNNGo_PowerForms_Field._.ModuleId, ModuleID, SearchType.Equal));

            if (DNNGo_PowerForms_Field.FindCount(qp) > 0)
            {
                validateJSON = "{\"jsonValidateReturn\":[\"" + validateId + "\",\"" + validateError + "\",false]}";//验证不通过
            }
            else
            {
                validateJSON = "{\"jsonValidateReturn\":[\"" + validateId + "\",\"" + validateError + "\",true]}";//验证通过
            }
            return(validateJSON);
        }
Exemple #19
0
        /// <summary>
        /// 自定义字段转XML实体
        /// </summary>
        /// <param name="fieldItem"></param>
        /// <returns></returns>
        public FieldEntity EntityToXml(DNNGo_PowerForms_Field fieldItem)
        {
            FieldEntity filexml = new FieldEntity();

            filexml.Name         = fieldItem.Name;
            filexml.Alias        = fieldItem.Alias;
            filexml.DefaultValue = fieldItem.DefaultValue;
            filexml.Description  = fieldItem.Description;
            filexml.Direction    = fieldItem.Direction;
            filexml.FieldType    = fieldItem.FieldType;
            filexml.FiledList    = fieldItem.FiledList;
            filexml.Required     = fieldItem.Required;
            filexml.Rows         = fieldItem.Rows;
            filexml.Sort         = fieldItem.Sort;
            filexml.Status       = fieldItem.Status;
            filexml.ToolTip      = fieldItem.ToolTip;
            filexml.Verification = fieldItem.Verification;
            filexml.Width        = fieldItem.Width;

            filexml.WidthSuffix  = fieldItem.WidthSuffix;
            filexml.ListColumn   = fieldItem.ListColumn;
            filexml.Options      = fieldItem.Options;
            filexml.StartTime    = fieldItem.StartTime;
            filexml.EndTime      = fieldItem.EndTime;
            filexml.Per_AllUsers = fieldItem.Per_AllUsers;
            filexml.Per_Roles    = fieldItem.Per_Roles;


            if (fieldItem.GroupID > 0)
            {
                DNNGo_PowerForms_Group Group = DNNGo_PowerForms_Group.FindByID(fieldItem.GroupID);

                if (Group != null && Group.ID > 0)
                {
                    filexml.Group = Group.Name;
                }
            }

            return(filexml);
        }
Exemple #20
0
        /// <summary>
        /// 导出表格
        /// </summary>
        /// <param name="SchedulerItem"></param>
        /// <returns></returns>
        public String ExportExcel(DNNGo_PowerForms_Scheduler SchedulerItem, Int32 index)
        {
            String Attachment = String.Empty;
            List <DNNGo_PowerForms_Content> DataList  = DNNGo_PowerForms_Content.FindAllByModuleId(SchedulerItem.ModuleId);
            List <DNNGo_PowerForms_Field>   FieldList = DNNGo_PowerForms_Field.FindAllByModuleId(SchedulerItem.ModuleId);

            if (DataList != null && DataList.Count > 0)
            {
                if (FieldList != null && FieldList.Count > 0)
                {
                    String FileName = SchedulerItem.ExcelName;
                    FileName = Common.ReplaceNoCase(FileName, "{yyyy}", DateTime.Now.ToString("yyyy"));
                    FileName = Common.ReplaceNoCase(FileName, "{mm}", DateTime.Now.ToString("MM"));
                    FileName = Common.ReplaceNoCase(FileName, "{dd}", DateTime.Now.ToString("dd"));
                    FileName = Common.ReplaceNoCase(FileName, "{time}", DateTime.Now.ToString("HHmmss"));
                    FileName = Common.ReplaceNoCase(FileName, "{ModuleID}", SchedulerItem.ModuleId.ToString());

                    Attachment = String.Format("{0}temp\\PowerForms\\{1}.xls", HttpRuntime.AppDomainAppPath, FileName);

                    try
                    {
                        CsvHelper.SaveAsToFile(FieldList, DataList, Attachment, false);
                    }
                    catch (Exception exc)
                    {
                        this.ScheduleHistoryItem.AddLogNote(exc.Source);
                    }
                }
                else
                {
                    this.ScheduleHistoryItem.AddLogNote(String.Format("task {0},field list is empty,Has ignored. time:{1}<br />", index, DateTime.Now.ToString()));
                }
            }
            else
            {
                this.ScheduleHistoryItem.AddLogNote(String.Format("task {0},History records is empty,Has ignored. time:{1}<br />", index, DateTime.Now.ToString()));
            }
            return(Attachment);
        }
Exemple #21
0
        /// <summary>
        /// 绑定数据
        /// </summary>
        private void BindDataToPage()
        {
            //发件人邮箱
            txtSenderEmail.Text = Settings["PowerForms_SenderEmail"] != null && !string.IsNullOrEmpty(Settings["PowerForms_SenderEmail"].ToString()) ? Convert.ToString(Settings["PowerForms_SenderEmail"]) : Host.HostEmail;

            #region "邮件设置"
            txtAdminEmail.Text         = Settings["PowerForms_AdminEmail"] != null && !string.IsNullOrEmpty(Settings["PowerForms_AdminEmail"].ToString()) ? Convert.ToString(Settings["PowerForms_AdminEmail"]) : Host.HostEmail;
            cbSendToAdmin.Checked      = Settings["PowerForms_SendToAdmin"] != null && !string.IsNullOrEmpty(Settings["PowerForms_SendToAdmin"].ToString()) ? Convert.ToBoolean(Settings["PowerForms_SendToAdmin"]) : true;
            cbSendToSubmitUser.Checked = Settings["PowerForms_SendToSubmitUser"] != null && !string.IsNullOrEmpty(Settings["PowerForms_SendToSubmitUser"].ToString()) ? Convert.ToBoolean(Settings["PowerForms_SendToSubmitUser"]) : true;
            //cbReplaceSender.Checked = Settings["PowerForms_ReplaceSender"] != null && !string.IsNullOrEmpty(Settings["PowerForms_ReplaceSender"].ToString()) ? Convert.ToBoolean(Settings["PowerForms_ReplaceSender"]) : false;
            cbReplyTo.Checked = Settings["PowerForms_ReplyTo"] != null?Convert.ToBoolean(Settings["PowerForms_ReplyTo"]) : true;

            WebHelper.BindList <DNNGo_PowerForms_Field>(ddlSubmitUserEmail, DNNGo_PowerForms_Field.FindAllByView(ModuleId, EnumVerification.email), DNNGo_PowerForms_Field._.Alias, DNNGo_PowerForms_Field._.Name);
            WebHelper.SelectedListByValue(ddlSubmitUserEmail, Settings["PowerForms_SubmitUserEmail"] != null && !string.IsNullOrEmpty(Settings["PowerForms_SubmitUserEmail"].ToString()) ? Convert.ToString(Settings["PowerForms_SubmitUserEmail"]) : "Email");


            DotNetNuke.Security.Roles.RoleController rc = new DotNetNuke.Security.Roles.RoleController();
            WebHelper.BindList(cblAdminEmailRoles, rc.GetPortalRoles(PortalId), "RoleName", "RoleName");
            WebHelper.SelectedListMultiByValue(cblAdminEmailRoles, Settings["PowerForms_AdminEmailRoles"] != null ? Convert.ToString(Settings["PowerForms_AdminEmailRoles"]) : "");


            //需要读取模版的设置
            DNNGo_PowerForms_Template Template = DNNGo_PowerForms_Template.FindByModuleId(ModuleId);

            txtSendAdminTitle.Text        = !String.IsNullOrEmpty(Template.ReceiversSubject) ? Template.ReceiversSubject : Localization.GetString("PowerForms_ReceiversSubject", this.LocalResourceFile);
            txtSendAdminContent.Text      = !String.IsNullOrEmpty(Template.ReceiversTemplate) ? Server.HtmlDecode(Template.ReceiversTemplate) : Localization.GetString("PowerForms_ReceiversTemplate", this.LocalResourceFile);
            txtSendSubmitUserTitle.Text   = !String.IsNullOrEmpty(Template.ReplySubject) ? Template.ReplySubject : Localization.GetString("PowerForms_ReplySubject", this.LocalResourceFile);
            txtSendSubmitUserContent.Text = !String.IsNullOrEmpty(Template.ReplyTemplate) ? Server.HtmlDecode(Template.ReplyTemplate) : Localization.GetString("PowerForms_ReplyTemplate", this.LocalResourceFile);
            #endregion

            #region "定时邮件设置"
            DNNGo_PowerForms_Scheduler SchedulerItem = DNNGo_PowerForms_Scheduler.FindSettings(this);
            txtScheduleSenderEmail.Text = !String.IsNullOrEmpty(SchedulerItem.SenderEmail) ? SchedulerItem.SenderEmail: Host.HostEmail;
            txtExcelName.Text           = !String.IsNullOrEmpty(SchedulerItem.ExcelName) ? SchedulerItem.ExcelName : "Bulk_{yyyy}_{mm}_{dd}_{time}_{ModuleID}";
            cbScheduleEnable.Checked    = SchedulerItem.Enable != 0;

            #endregion
        }
Exemple #22
0
        /// <summary>
        /// 从XML导入数据
        /// </summary>
        protected void cmdImportFormXml_Click(object sender, EventArgs e)
        {
            try
            {
                HttpPostedFile hpfile = fuImportFormXml.PostedFile;

                if (hpfile.ContentLength > 0)
                {
                    if (Path.GetExtension(hpfile.FileName).IndexOf(".xml", StringComparison.CurrentCultureIgnoreCase) >= 0)
                    {
                        ImportExportHelper ieHelper = new ImportExportHelper();
                        ieHelper.ModuleID = ModuleId;
                        ieHelper.UserId   = UserId;

                        //先清除原有的字段列表
                        QueryParam qp          = new QueryParam();
                        Int32      RecordCount = 0;
                        qp.Where.Add(new SearchParam("ModuleId", ModuleId, SearchType.Equal));
                        List <DNNGo_PowerForms_Field> fieldList = DNNGo_PowerForms_Field.FindAll(qp, out RecordCount);
                        foreach (DNNGo_PowerForms_Field fieldItem in fieldList)
                        {
                            fieldItem.Delete();
                        }

                        //构造需要上传的路径
                        String   XmlFilePath = String.Format("{0}PowerForms\\Import\\{1}_{2}", PortalSettings.HomeDirectoryMapPath, xUserTime.UtcTime().ToString("yyyyMMddHHmmssffff"), fuImportFormXml.FileName);
                        FileInfo XmlFile     = new FileInfo(XmlFilePath);
                        //判断文件夹是否存在
                        if (!XmlFile.Directory.Exists)
                        {
                            XmlFile.Directory.Create();
                        }
                        //保存文件
                        fuImportFormXml.SaveAs(XmlFilePath);

                        XmlFormat xf = new XmlFormat(XmlFilePath);

                        List <FieldEntity> XmlFieldList = xf.ToList <FieldEntity>();


                        Int32 InsertResult = 0;
                        foreach (FieldEntity XmlField in XmlFieldList)
                        {
                            DNNGo_PowerForms_Field FieldItem = ieHelper.XmlToEntity(XmlField);


                            FieldItem.CreateUser = UserId;
                            FieldItem.CreateTime = xUserTime.UtcTime();

                            FieldItem.ModuleId = ModuleId;
                            FieldItem.PortalId = PortalId;

                            FieldItem.LastIP   = WebHelper.UserHost;
                            FieldItem.LastTime = xUserTime.UtcTime();
                            FieldItem.LastUser = UserId;

                            if (FieldItem.Insert() > 0)
                            {
                                InsertResult++;
                            }
                        }

                        //提示
                        mTips.LoadMessage("ImportFieldSuccess", EnumTips.Success, this, new String[] { InsertResult.ToString() });

                        //跳转
                        Response.Redirect(xUrl("FieldList"));
                    }
                    else
                    {
                        //上传文件的后缀名错误
                        mTips.IsPostBack = true;
                        mTips.LoadMessage("UploadFieldExtensionError", EnumTips.Warning, this, new String[] { "xml" });
                    }
                }
                else
                {
                    //为上传任何数据
                    mTips.IsPostBack = true;
                    mTips.LoadMessage("ImportFieldNullError", EnumTips.Success, this, new String[] { "" });
                }
            }
            catch (Exception ex)
            {
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex);
            }
        }
        /// <summary>
        /// 绑定方案项
        /// </summary>
        private void BindDataItem()
        {
            //取出当前的方案实体,并绑定到相应的控件上
            DNNGo_PowerForms_Field fieldItem = FieldItem;

            if (fieldItem == null)
            {
                fieldItem = new DNNGo_PowerForms_Field();
            }

            if (fieldItem.ID > 0)
            {
                //更新方案
                //需要将几个控件设置为不可操作状态
                txtName.Enabled        = false;
                ddlControlType.Enabled = false;
            }
            else
            {
                //新增方案
            }

            //绑定字段类型
            //BindFieldTypeView(fieldItem.FieldType);


            EffectDB EffectDB = Setting_EffectDB;

            divGroup.Visible = EffectDB.Group;
            if (EffectDB.Group)
            {
                BindTreeGroups(fieldItem);
            }

            //增加权限用户
            DotNetNuke.Security.Roles.RoleController rc = new DotNetNuke.Security.Roles.RoleController();
            WebHelper.BindList(cblPermissionsRoles, rc.GetPortalRoles(PortalId), "RoleName", "RoleName");
            WebHelper.SelectedListMultiByValue(cblPermissionsRoles, fieldItem.Per_Roles);

            cbPermissionsAllUsers.Checked = fieldItem.Per_AllUsers == 0 ? true : false;

            WebHelper.BindList(ddlControlType, typeof(EnumViewControlType));
            WebHelper.SelectedListByValue(ddlControlType, fieldItem.FieldType);

            WebHelper.BindList(ddlVerification, typeof(EnumVerification));
            WebHelper.SelectedListByValue(ddlVerification, fieldItem.Verification);

            WebHelper.BindList(rblFTDirection, typeof(EnumControlDirection));
            WebHelper.SelectedListByValue(rblFTDirection, fieldItem.Direction);



            List <DNNGo_PowerForms_Field> FieldControls = DNNGo_PowerForms_Field.FindAllByModuleId(ModuleId);

            WebHelper.BindList <DNNGo_PowerForms_Field>(ddlFTEqualsControl, FieldControls, "Name", "ID");
            WebHelper.BindItem(ddlFTEqualsControl, ViewResourceText("lblDDRSelect", "==Please select=="), "0");
            WebHelper.SelectedListByValue(ddlFTEqualsControl, fieldItem.EqualsControl);

            WebHelper.BindList <DNNGo_PowerForms_Field>(ddlFTAssociatedControl, FieldControls.FindAll(r => r.FieldType == (Int32)EnumViewControlType.DropDownList_Country), "Name", "ID");
            WebHelper.BindItem(ddlFTAssociatedControl, ViewResourceText("lblDDRSelect", "==Please select=="), "0");
            WebHelper.SelectedListByValue(ddlFTAssociatedControl, fieldItem.AssociatedControl);


            txtName.Text                = fieldItem.Name;
            txtDescription.Text         = fieldItem.Description;
            txtAlias.Text               = fieldItem.Alias;
            txtToolTip.Text             = fieldItem.ToolTip;
            txtFTDefaultValue.Text      = fieldItem.DefaultValue;
            txtTinymceDefaultValue.Text = fieldItem.DefaultValue;
            txtFTListCollection.Text    = fieldItem.FiledList;
            txtFTRows.Text              = fieldItem.Rows.ToString();
            WebHelper.SelectedListByValue(rblFTDirection, fieldItem.Direction);
            txtFTListColumn.Text = fieldItem.ListColumn.ToString();

            txtFTInputLength.Text = fieldItem.InputLength.ToString();

            txtFTWidth.Text = fieldItem.Width.ToString();
            WebHelper.BindList(ddlFTWidth, typeof(EnumWidthSuffix));
            WebHelper.SelectedListByValue(ddlFTWidth, fieldItem.WidthSuffix);



            //文章状态
            cbStatus.Checked = fieldItem.Status == (Int32)EnumStatus.Activation;
            //是否必填
            cbRequired.Checked = fieldItem.Required == 1;

            //发布时间和结束时间
            if (FieldID > 0 && fieldItem != null && fieldItem.ID > 0)
            {
                liStartDateTime.Text   = fieldItem.StartTime.ToString("MM/dd/yyyy hh:mm tt", new CultureInfo("en-US", false)); //Thread.CurrentThread.CurrentCulture
                liDisableDateTime.Text = fieldItem.EndTime.ToString("MM/dd/yyyy hh:mm tt", new CultureInfo("en-US", false));   //Thread.CurrentThread.CurrentCulture
            }
            txtStartDate.Text = fieldItem.StartTime.ToString("MM/dd/yyyy", new CultureInfo("en-US", false));
            txtStartTime.Text = fieldItem.StartTime.ToString("hh:mm tt", new CultureInfo("en-US", false));

            txtDisableDate.Text = fieldItem.EndTime.ToString("MM/dd/yyyy", new CultureInfo("en-US", false));
            txtDisableTime.Text = fieldItem.EndTime.ToString("hh:mm tt", new CultureInfo("en-US", false));
        }
        /// <summary>
        /// 设置方案项
        /// </summary>
        private Int32 SetDataItem(Int32 ArticleStatus, out DNNGo_PowerForms_Field fieldItem)
        {
            fieldItem = FieldItem;

            //权限
            fieldItem.Per_AllUsers = cbPermissionsAllUsers.Checked ? 0 : 1;

            String textStr, idStr = String.Empty;

            WebHelper.GetSelected(cblPermissionsRoles, out textStr, out idStr);
            fieldItem.Per_Roles = idStr;


            if (ddlControlType.Enabled)
            {
                fieldItem.FieldType = WebHelper.GetIntParam(Request, ddlControlType.UniqueID, (Int32)EnumViewControlType.TextBox);
            }

            fieldItem.ToolTip     = txtToolTip.Text;
            fieldItem.Alias       = txtAlias.Text;
            fieldItem.Description = txtDescription.Text;
            fieldItem.Required    = cbRequired.Checked ? 1 : 0;



            fieldItem.Options = SetItemSettings();


            if (divGroup.Visible)
            {
                SettingEntity GroupControl = new SettingEntity();
                GroupControl.Name = "GroupControl";
                Int32 GroupID = 0;
                if (int.TryParse(ControlHelper.GetWebFormValue(GroupControl, this), out GroupID))
                {
                }
                fieldItem.GroupID = GroupID;
            }

            fieldItem.FiledList = txtFTListCollection.Text;

            if (fieldItem.FieldType == (Int32)EnumViewControlType.Html || fieldItem.FieldType == (Int32)EnumViewControlType.RichTextBox)
            {
                fieldItem.DefaultValue = txtTinymceDefaultValue.Text;
            }
            else
            {
                fieldItem.DefaultValue = txtFTDefaultValue.Text;
            }
            fieldItem.Rows         = WebHelper.GetIntParam(Request, txtFTRows.UniqueID, 1);
            fieldItem.Verification = WebHelper.GetIntParam(Request, ddlVerification.UniqueID, 0);
            fieldItem.Direction    = WebHelper.GetIntParam(Request, rblFTDirection.UniqueID, 0);
            fieldItem.ListColumn   = WebHelper.GetIntParam(Request, txtFTListColumn.UniqueID, 1);

            fieldItem.Width       = WebHelper.GetIntParam(Request, txtFTWidth.UniqueID, 100);
            fieldItem.WidthSuffix = WebHelper.GetIntParam(Request, ddlFTWidth.UniqueID, 0);

            fieldItem.EqualsControl     = WebHelper.GetIntParam(Request, ddlFTEqualsControl.UniqueID, 0);
            fieldItem.AssociatedControl = WebHelper.GetIntParam(Request, ddlFTAssociatedControl.UniqueID, 0);
            fieldItem.InputLength       = WebHelper.GetIntParam(Request, txtFTInputLength.UniqueID, 2000);

            fieldItem.LastTime = xUserTime.UtcTime();
            fieldItem.LastUser = UserId;
            fieldItem.LastIP   = WebHelper.UserHost;

            //发布状态和时间
            DateTime oTime = xUserTime.LocalTime();

            string[] expectedFormats = { "G", "g", "f", "F" };
            string   StartDate       = WebHelper.GetStringParam(Request, txtStartDate.UniqueID, oTime.ToString("MM/dd/yyyy"));
            string   StartTime       = WebHelper.GetStringParam(Request, txtStartTime.UniqueID, oTime.ToString("hh:mm tt"));

            if (DateTime.TryParseExact(String.Format("{0} {1}", StartDate, StartTime), "MM/dd/yyyy hh:mm tt", new CultureInfo("en-US", false), DateTimeStyles.AllowWhiteSpaces, out oTime))
            {
                fieldItem.StartTime = oTime;
            }
            //发布状态和时间
            DateTime EndTime     = xUserTime.LocalTime().AddYears(10);
            string   DisableDate = WebHelper.GetStringParam(Request, txtDisableDate.UniqueID, EndTime.ToString("MM/dd/yyyy"));
            string   DisableTime = WebHelper.GetStringParam(Request, txtDisableTime.UniqueID, EndTime.ToString("hh:mm tt"));

            if (DateTime.TryParseExact(String.Format("{0} {1}", DisableDate, DisableTime), "MM/dd/yyyy hh:mm tt", new CultureInfo("en-US", false), DateTimeStyles.AllowWhiteSpaces, out EndTime))
            {
                fieldItem.EndTime = EndTime;
            }

            if (ArticleStatus == -1)//如果没有指定状态就取控件的
            {
                fieldItem.Status = cbStatus.Checked ? (Int32)EnumStatus.Activation : (Int32)EnumStatus.Hide;
            }
            else
            {
                fieldItem.Status = ArticleStatus;
            }


            Int32 SaveResult = 0;

            if (fieldItem.ID > 0)
            {
                SaveResult = fieldItem.Update();
            }
            else
            {
                fieldItem.Name = txtName.Text;

                QueryParam qp = new QueryParam();
                qp.Where.Add(new SearchParam(DNNGo_PowerForms_Field._.ModuleId, ModuleId, SearchType.Equal));
                qp.Where.Add(new SearchParam(DNNGo_PowerForms_Field._.Name, fieldItem.Name, SearchType.Equal));
                if (DNNGo_PowerForms_Field.FindCount(qp) == 0)
                {
                    fieldItem.ModuleId = ModuleId;
                    fieldItem.PortalId = PortalId;


                    QueryParam Sqp = new QueryParam();
                    Sqp.ReturnFields = Sqp.Orderfld = DNNGo_PowerForms_Field._.Sort;
                    Sqp.OrderType    = 1;
                    Sqp.Where.Add(new SearchParam(DNNGo_PowerForms_Field._.ModuleId, ModuleId, SearchType.Equal));
                    fieldItem.Sort = Convert.ToInt32(DNNGo_PowerForms_Field.FindScalar(Sqp)) + 2;



                    //构造默认的验证方式
                    if (fieldItem.FieldType == (Int32)EnumViewControlType.DatePicker)
                    {
                        fieldItem.Verification = (Int32)EnumVerification.date;
                    }
                    else if (fieldItem.FieldType == (Int32)EnumViewControlType.FileUpload)
                    {
                    }
                    else if (fieldItem.FieldType == (Int32)EnumViewControlType.TextBox_Email)
                    {
                        fieldItem.Verification = (Int32)EnumVerification.email;
                    }


                    SaveResult = fieldItem.Insert();
                }
                else
                {
                    SaveResult = -1;
                }
            }

            return(SaveResult);
        }
Exemple #25
0
        /// <summary>
        /// 获取Form传值
        /// </summary>
        /// <param name="fieldItem"></param>
        /// <returns></returns>
        public String GetWebFormValue(DNNGo_PowerForms_Field fieldItem)
        {
            String WebFormValue = String.Empty;

            //创建控件的Name和ID
            TemplateFormat xf          = new TemplateFormat(this);
            String         ControlName = xf.ViewControlName(fieldItem);
            String         ControlID   = xf.ViewControlID(fieldItem);


            if (fieldItem.FieldType == (Int32)EnumViewControlType.CheckBox)
            {
                WebFormValue = WebHelper.GetStringParam(Request, ControlName, "");
                WebFormValue = !String.IsNullOrEmpty(WebFormValue) && WebFormValue == "on" ? "true" : "false";
            }
            else if (fieldItem.FieldType == (Int32)EnumViewControlType.FileUpload)
            {
                if (Request.Files != null && Request.Files.Count > 0)
                {
                    HttpPostedFile hpFile = Request.Files.Get(ControlName);
                    if (hpFile != null && hpFile.ContentLength > 0)
                    {
                        //To verify that if the suffix name of the uploaded files meets the DNN HOST requirements
                        Boolean retValue = FileSystemUtils.CheckValidFileName(hpFile.FileName);
                        if (retValue)
                        {
                            WebFormValue = String.Format("Url://{0}", FileSystemUtils.UploadFile(hpFile, this));//存放到目录中,并返回
                        }
                    }
                }
            }
            else if (fieldItem.FieldType == (Int32)EnumViewControlType.MultipleFilesUpload)
            {
                String WebUploads = WebHelper.GetStringParam(Request, ControlName, "");
                if (!String.IsNullOrEmpty(WebUploads) && WebUploads != "[]")
                {
                    List <Resource_FilesStatus> Uploads = jsSerializer.Deserialize <List <Resource_FilesStatus> >(WebUploads);
                    if (Uploads != null && Uploads.Count > 0)
                    {
                        List <String> fileurls = new List <string>();
                        foreach (var UploadFile in Uploads)
                        {
                            fileurls.Add(String.Format("Url://{0}", FileSystemUtils.CopyFile(UploadFile, this)));
                        }
                        WebFormValue = Common.GetStringByList(fileurls, "<|>");
                    }
                }
            }
            else if (fieldItem.FieldType == (Int32)EnumViewControlType.DropDownList_Country)
            {
                var tempWebFormValue = WebHelper.GetStringParam(HttpContext.Current.Request, ControlName, "");

                var Countrys = new ListController().GetListEntryInfoItems("Country");
                foreach (var Country in Countrys)
                {
                    if (Country.Value == tempWebFormValue)
                    {
                        WebFormValue = Country.Text;
                        break;
                    }
                }
            }
            else
            {
                WebFormValue = WebHelper.GetStringParam(Request, ControlName, "");

                if (!(fieldItem.FieldType == (Int32)EnumViewControlType.RichTextBox))
                {
                    //非富文本框时,需要过滤掉XSS特殊字符
                    WebFormValue = Common.LostXSS(WebFormValue);
                }

                //如果提示的值和输入的值一样的情况,就过滤掉该值 *** 有点争议的地方
                if (WebFormValue == fieldItem.ToolTip && fieldItem.DefaultValue != WebFormValue)
                {
                    WebFormValue = string.Empty;
                }
            }

            return(WebFormValue);
        }
Exemple #26
0
        /// <summary>
        /// 提交表单信息到数据库
        /// </summary>
        public void SubmitFormToDB()
        {
            DNNGo_PowerForms_Content SubmitContent = new DNNGo_PowerForms_Content();

            //读取需要载入的参数
            List <DNNGo_PowerForms_ContentItem> ContentList = new List <DNNGo_PowerForms_ContentItem>();


            Boolean SubmitValue = false;

            if (FieldList != null && FieldList.Count > 0)
            {
                foreach (DNNGo_PowerForms_Field fieldItem in FieldList)
                {
                    DNNGo_PowerForms_ContentItem ContentItem = new DNNGo_PowerForms_ContentItem();
                    ContentItem.FieldID      = fieldItem.ID;
                    ContentItem.FieldName    = fieldItem.Name;
                    ContentItem.FieldAlias   = fieldItem.Alias;
                    ContentItem.Sort         = fieldItem.Sort;
                    ContentItem.ContentValue = GetWebFormValue(fieldItem);
                    ContentItem.Group        = DNNGo_PowerForms_Group.FindNameByKeyForEdit(fieldItem.GroupID);
                    if (!String.IsNullOrEmpty(ContentItem.ContentValue))
                    {
                        SubmitValue = true;
                    }

                    ContentList.Add(ContentItem);
                }
            }

            //是否添加额外跟踪属性
            if (Settings_ExtraTracking)
            {
                ContentList.AddRange(GetExtraTracking());
            }


            if (SubmitValue)
            {
                //判断是否需要隐藏IP
                String  UserHost = WebHelper.UserHost;
                Boolean HideIp   = Settings["PowerForms_HideIp"] != null?Convert.ToBoolean(Settings["PowerForms_HideIp"]) : false;

                if (HideIp)
                {
                    UserHost = Common.HideIpAddress(UserHost);
                }

                SubmitContent.VerifyString = WebHelper.GetStringParam(Request, hfVerifyString.UniqueID, "");
                SubmitContent.LastIP       = UserHost;
                SubmitContent.LastTime     = xUserTime.LocalTime();
                SubmitContent.LastUser     = UserId;
                SubmitContent.ModuleId     = ModuleId;
                SubmitContent.PortalId     = PortalId;
                SubmitContent.CultureInfo  = System.Globalization.CultureInfo.CurrentCulture.Name;
                SubmitContent.FormVersion  = ViewSettingT <String>("PowerForms_FormVersion", "");


                //默认是当前登录用户的邮箱
                if (UserId > 0 && UserInfo != null && !String.IsNullOrEmpty(UserInfo.Email) && Mail.IsValidEmailAddress(UserInfo.Email, Null.NullInteger))
                {
                    SubmitContent.UserName = UserInfo.Username;
                    SubmitContent.Email    = UserInfo.Email;
                }


                if (!String.IsNullOrEmpty(Settings_SubmitUserEmail))
                {
                    //如果没有填写邮箱时
                    DNNGo_PowerForms_ContentItem EmailItem = ContentList.Find(r1 => r1.FieldName == Settings_SubmitUserEmail);
                    //if (EmailItem != null && !String.IsNullOrEmpty(EmailItem.ContentValue) && Mail.IsValidEmailAddress(EmailItem.ContentValue, Null.NullInteger))
                    if (EmailItem != null && !String.IsNullOrEmpty(EmailItem.ContentValue))
                    {
                        SubmitContent.Email = EmailItem.ContentValue;
                    }
                }


                //如果没有填写姓名时
                DNNGo_PowerForms_Field DisplayNameField = FieldList.Find(r => r.FieldType == (Int32)EnumViewControlType.TextBox_DisplayName);
                if (DisplayNameField != null && DisplayNameField.ID > 0)
                {
                    DNNGo_PowerForms_ContentItem DisplayNameItem = ContentList.Find(r1 => r1.FieldName == DisplayNameField.Name);
                    if (DisplayNameItem != null && !String.IsNullOrEmpty(DisplayNameItem.ContentValue))
                    {
                        SubmitContent.UserName = DisplayNameItem.ContentValue;
                    }
                }



                //序列化收集到的提交值列表
                if (ContentList != null && ContentList.Count > 0)
                {
                    SubmitContent.ContentValue = Common.Serialize <List <DNNGo_PowerForms_ContentItem> >(ContentList);
                }

                SubmitContent.Status = (Int32)EnumStatus.Activation;

                //是否需要保存记录
                Boolean SaveRecords = ViewSettingT <bool>("PowerForms_SaveRecords", true);
                //不保存记录 或 保存记录
                if (!SaveRecords || (SaveRecords && SubmitContent.Insert() > 0))
                {
                    //提交成功发邮件的方法
                    SendMail(SubmitContent, ContentList, FieldList);

                    //推送数据到第三方URL
                    Boolean Push_Enable = Settings["PowerForms_Push_Enable"] != null && !string.IsNullOrEmpty(Settings["PowerForms_Push_Enable"].ToString()) ? Convert.ToBoolean(Settings["PowerForms_Push_Enable"]) : false;
                    if (Push_Enable)
                    {
                        PushForm push = new PushForm(this);
                        push.ContentList   = ContentList;
                        push.SubmitContent = SubmitContent;
                        push.Push();
                    }


                    if (iFrame.IndexOf("iFrame", StringComparison.CurrentCultureIgnoreCase) >= 0)
                    {
                        if (!String.IsNullOrEmpty(Settings_RedirectPage))
                        {
                            Response.Write(String.Format("<script> window.parent.location = '{0}';</script>", RedirectPage(SubmitContent)));
                        }
                        else
                        {
                            //提交成功跳转的页面
                            Response.Redirect(RedirectPage(SubmitContent));
                        }
                    }
                    else
                    {
                        //提交成功跳转的页面
                        Response.Redirect(RedirectPage(SubmitContent));
                    }
                }
                else
                {
                    //新增表单失败
                }
            }
            else
            {
                //提交的内容是空的,没任何信息
            }
        }
Exemple #27
0
        /// <summary>
        /// 列表行绑定
        /// </summary>
        protected void gvFieldList_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //还原出数据
                DNNGo_PowerForms_Field Fielditem = e.Row.DataItem as DNNGo_PowerForms_Field;

                if (Fielditem != null && Fielditem.ID > 0)
                {
                    #region "编辑&删除按钮"
                    HyperLink  hlEdit          = e.Row.FindControl("hlEdit") as HyperLink;
                    HyperLink  hlMobileEdit    = e.Row.FindControl("hlMobileEdit") as HyperLink;
                    LinkButton btnRemove       = e.Row.FindControl("btnRemove") as LinkButton;
                    LinkButton btnMobileRemove = e.Row.FindControl("btnMobileRemove") as LinkButton;
                    //设置按钮的CommandArgument
                    btnRemove.CommandArgument = btnMobileRemove.CommandArgument = Fielditem.ID.ToString();
                    //设置删除按钮的提示
                    //if (Field.Status == (Int32)EnumFieldStatus.Recycle)
                    //{
                    btnRemove.Attributes.Add("onClick", "javascript:return confirm('" + Localization.GetString("DeleteItem") + "');");
                    btnMobileRemove.Attributes.Add("onClick", "javascript:return confirm('" + Localization.GetString("DeleteItem") + "');");
                    //}
                    //else
                    //{
                    //    btnRemove.Attributes.Add("onClick", "javascript:return confirm('" + ViewResourceText("DeleteRecycleItem", "Are you sure to move it to recycle bin?") + "');");
                    //    btnMobileRemove.Attributes.Add("onClick", "javascript:return confirm('" + ViewResourceText("DeleteRecycleItem", "Are you sure to move it to recycle bin?") + "');");
                    //}

                    hlEdit.NavigateUrl = hlMobileEdit.NavigateUrl = xUrl("FieldID", Fielditem.ID.ToString(), "AddNewField");


                    #endregion


                    #region "移动分类按钮"
                    LinkButton lbSortUp         = e.Row.FindControl("lbSortUp") as LinkButton;
                    LinkButton lbSortDown       = e.Row.FindControl("lbSortDown") as LinkButton;
                    LinkButton lbMobileSortUp   = e.Row.FindControl("lbMobileSortUp") as LinkButton;
                    LinkButton lbMobileSortDown = e.Row.FindControl("lbMobileSortDown") as LinkButton;
                    lbSortUp.CommandArgument                     =
                        lbSortDown.CommandArgument               =
                            lbMobileSortUp.CommandArgument       =
                                lbMobileSortDown.CommandArgument = Fielditem.ID.ToString();
                    #endregion


                    e.Row.Cells[4].Text = EnumHelper.GetEnumTextVal(Fielditem.FieldType, typeof(EnumViewControlType));

                    //获取用户名称
                    DotNetNuke.Entities.Users.UserInfo uInfo = new DotNetNuke.Entities.Users.UserController().GetUser(PortalId, Fielditem.LastUser);
                    e.Row.Cells[7].Text = uInfo != null && uInfo.UserID > 0 ?  uInfo.Username:"******";

                    e.Row.Cells[8].Text = EnumHelper.GetEnumTextVal(Fielditem.Status, typeof(EnumStatus));

                    if (Fielditem.GroupID > 0)
                    {
                        DNNGo_PowerForms_Group Group = DNNGo_PowerForms_Group.FindByKeyForEdit(Fielditem.GroupID);
                        if (Group != null && Group.ID > 0)
                        {
                            e.Row.Cells[3].Text = Group.Name;
                        }
                        else
                        {
                            e.Row.Cells[3].Text = String.Empty;
                        }
                    }
                    else
                    {
                        e.Row.Cells[3].Text = String.Empty;
                    }
                }
            }
        }