/// <summary>
        /// 初始话CNVelocity模块
        /// </summary>
        public void Init(basePortalModule _bpm, String _path = "Effect")
        {
            //创建VelocityEngine实例对象
            velocity = new VelocityEngine();


            //使用设置初始化VelocityEngine
            ExtendedProperties props = new ExtendedProperties();

            props.AddProperty(RuntimeConstants.RESOURCE_LOADER, "file");

            if (_path != "Effect")
            {
                props.AddProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, HttpContext.Current.Server.MapPath(String.Format("{0}{1}s/{2}/", _bpm.ModulePath, _path, _bpm.Settings_ResultName)));
            }
            else
            {
                props.AddProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, HttpContext.Current.Server.MapPath(String.Format("{0}{1}s/{2}/", _bpm.ModulePath, _path, _bpm.Settings_EffectName)));
            }
            //props.AddProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, Path.GetDirectoryName(HttpContext.Current.Request.PhysicalPath));
            props.AddProperty(RuntimeConstants.INPUT_ENCODING, "utf-8");
            props.AddProperty(RuntimeConstants.OUTPUT_ENCODING, "utf-8");

            //模板的缓存设置
            props.AddProperty(RuntimeConstants.FILE_RESOURCE_LOADER_CACHE, false);              //是否缓存
            props.AddProperty("file.resource.loader.modificationCheckInterval", (Int64)600);    //缓存时间(秒)

            velocity.Init(props);

            //为模板变量赋值
            context = new VelocityContext();
        }
        public VelocityHelper(basePortalModule _bpm, EffectDB _Theme, String _path = "Effect")
        {
            Theme = _Theme;
            bpm   = _bpm;

            Init(_bpm, _path);
        }
Exemplo n.º 3
0
 /// <summary>
 /// 初始化常用的东西
 /// </summary>
 /// <param name="BPM">模块的基类</param>
 public WebClientX(basePortalModule BPM)
 {
     Headers[HttpRequestHeader.Accept]         = BPM.Settings["PowerForms_RequestHeader_Accept"] != null && !string.IsNullOrEmpty(BPM.Settings["PowerForms_RequestHeader_Accept"].ToString()) ? Convert.ToString(BPM.Settings["PowerForms_RequestHeader_Accept"]) : "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
     Headers[HttpRequestHeader.AcceptLanguage] = BPM.Settings["PowerForms_RequestHeader_AcceptLanguage"] != null && !string.IsNullOrEmpty(BPM.Settings["PowerForms_RequestHeader_AcceptLanguage"].ToString()) ? Convert.ToString(BPM.Settings["PowerForms_RequestHeader_AcceptLanguage"]) : "en-US";
     Headers[HttpRequestHeader.AcceptEncoding] = BPM.Settings["PowerForms_RequestHeader_AcceptEncoding"] != null && !string.IsNullOrEmpty(BPM.Settings["PowerForms_RequestHeader_AcceptEncoding"].ToString()) ? Convert.ToString(BPM.Settings["PowerForms_RequestHeader_AcceptEncoding"]) : "gzip, deflate";
     Headers[HttpRequestHeader.UserAgent]      = BPM.Settings["PowerForms_RequestHeader_UserAgent"] != null && !string.IsNullOrEmpty(BPM.Settings["PowerForms_RequestHeader_UserAgent"].ToString()) ? Convert.ToString(BPM.Settings["PowerForms_RequestHeader_UserAgent"]) : "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)";
 }
Exemplo n.º 4
0
        /// <summary>
        /// 输出XML
        /// </summary>
        /// <returns></returns>
        public String ToXml(basePortalModule pmb)
        {
            //读取XML的模版
            XmlFormat xf = new XmlFormat(pmb.MapPath(String.Format("{0}Resource/xml/EffectDB.xml", pmb.ModulePath)));

            //将字段列表转换成XML的实体
            return(xf.ToXml <EffectDB>(this));
        }
Exemplo n.º 5
0
        /// <summary>
        /// 查找当前模块的设置
        /// </summary>
        /// <param name="baseModule"></param>
        /// <returns></returns>
        public static DNNGo_PowerForms_Scheduler FindSettings(basePortalModule baseModule)
        {
            QueryParam qp          = new QueryParam();
            int        RecordCount = 0;

            qp.Where.Add(new SearchParam(DNNGo_PowerForms_Scheduler._.PortalId, baseModule.PortalId, SearchType.Equal));
            qp.Where.Add(new SearchParam(DNNGo_PowerForms_Scheduler._.ModuleId, baseModule.ModuleId, SearchType.Equal));
            return(DNNGo_PowerForms_Scheduler.FindItem(qp, out RecordCount));
        }
Exemplo n.º 6
0
        /// <summary>
        /// 绑定控件到容器
        /// </summary>
        public void BindContainer()
        {
            MenuTabItem _MenuTabItem = InitMenuTabCollection.ContainsKey(Token) ? InitMenuTabCollection[Token] : new MenuTabItem();

            if (_MenuTabItem != null && !String.IsNullOrEmpty(_MenuTabItem.Token) && !this.DesignMode)
            {
                //判断是否为管理员菜单,当前用户是否为管理员
                if (_MenuTabItem.IsAdministrator && !IsAdministrator)
                {
                    phContainer.Visible = false;
                    mTips.MsgType       = EnumTips.Warning;
                    mTips.Content       = ViewResourceText("HasModuleAccess", "You are not permitted to access this page! :(");
                    mTips.Put();
                }
                else
                {
                    //加载相应的控件
                    basePortalModule ManageContent = new basePortalModule();
                    string           ContentSrc    = ResolveClientUrl(string.Format("{0}/{1}", this.TemplateSourceDirectory, _MenuTabItem.Src));

                    if (System.IO.File.Exists(MapPath(ContentSrc)))
                    {
                        ManageContent = (basePortalModule)LoadControl(ContentSrc);
                        ManageContent.ModuleConfiguration = ModuleConfiguration;
                        ManageContent.ID = _MenuTabItem.Token;
                        ManageContent.LocalResourceFile = Localization.GetResourceFile(this, string.Format("{0}.resx", _MenuTabItem.Src));
                        phContainer.Controls.Add(ManageContent);
                    }
                }

                //标题
                Page.Title = String.Format("{0} - {1} - {2}", ViewMenuText(_MenuTabItem), ModuleConfiguration.ModuleTitle, PortalSettings.ActiveTab.LocalizedTabName);
            }
            else if (!String.IsNullOrEmpty(Token) && Token.ToLower() == "error")
            {
                //加载相应的控件
                basePortalModule ManageContent = new basePortalModule();
                string           ContentSrc    = ResolveClientUrl(string.Format("{0}/{1}", this.TemplateSourceDirectory, "Manager_ErrorCatch.ascx"));

                if (System.IO.File.Exists(MapPath(ContentSrc)))
                {
                    ManageContent = (basePortalModule)LoadControl(ContentSrc);
                    ManageContent.ModuleConfiguration = ModuleConfiguration;
                    ManageContent.ID = "ErrorCatch";
                    ManageContent.LocalResourceFile = Localization.GetResourceFile(this, string.Format("{0}.resx", "Manager_ErrorCatch.ascx"));
                    phContainer.Controls.Add(ManageContent);
                }
                //标题
                Page.Title = String.Format("{0} - {1}", "Error", ModuleConfiguration.ModuleTitle);
            }

            //首页地址
            hlHome.NavigateUrl = Globals.NavigateURL(TabId);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 推送参数到这里
        /// </summary>
        /// <param name="baseModule"></param>
        public void PushSettings(basePortalModule baseModule)
        {
            SMTPEnableSSL      = Host.EnableSMTPSSL;
            SMTPServer         = Host.SMTPServer;
            SMTPAuthentication = Host.SMTPAuthentication;
            SMTPUsername       = Host.SMTPUsername;
            SMTPPassword       = Host.SMTPPassword;



            //if (baseModule.SMTPmode)
            //{

            //    if (baseModule.Portal_Settings["SMTPmode"] != null)
            //    {

            //    }else
            //    {
            //        var Portal_Settings = baseModule.Portal_Settings;

            //        SMTPEnableSSL = Portal_Settings["SMTPEnableSSL"] != null && Convert.ToString(Portal_Settings["SMTPEnableSSL"]) == "Y";

            //        SMTPServer = Portal_Settings["SMTPServer"] != null && !String.IsNullOrEmpty(Portal_Settings["SMTPServer"].ToString()) ? Portal_Settings["SMTPServer"].ToString() : "";
            //        SMTPAuthentication = Portal_Settings["SMTPAuthentication"] != null && !String.IsNullOrEmpty(Portal_Settings["SMTPAuthentication"].ToString()) ? Portal_Settings["SMTPAuthentication"].ToString() : "";
            //        SMTPUsername = Portal_Settings["SMTPUsername"] != null && !String.IsNullOrEmpty(Portal_Settings["SMTPUsername"].ToString()) ? Portal_Settings["SMTPUsername"].ToString() : "";
            //        SMTPPassword = Portal_Settings["SMTPPassword"] != null && !String.IsNullOrEmpty(Portal_Settings["SMTPPassword"].ToString()) ? Portal_Settings["SMTPPassword"].ToString() : "";
            //    }



            //} else
            //{
            //    var Host_Settings = Globals.HostSettings;

            //    SMTPEnableSSL = Host.EnableSMTPSSL;
            //    SMTPServer = Host.SMTPServer;
            //    SMTPAuthentication = Host.SMTPAuthentication;
            //    SMTPUsername = Host.SMTPUsername;
            //    SMTPPassword = Host.SMTPPassword;
            //}

            //System.Text.StringBuilder sb = new System.Text.StringBuilder();
            //sb.AppendFormat("SMTPmode:{0}", baseModule.SMTPmode).AppendLine();
            //sb.AppendFormat("SMTPEnableSSL:{0}", SMTPEnableSSL).AppendLine();
            //sb.AppendFormat("SMTPServer:{0}", SMTPServer).AppendLine();
            //sb.AppendFormat("SMTPAuthentication:{0}", SMTPAuthentication).AppendLine();
            //sb.AppendFormat("SMTPUsername:{0}", SMTPUsername).AppendLine();
            //sb.AppendFormat("SMTPPassword:{0}", SMTPPassword).AppendLine();

            //Trace.WriteLine(sb.ToString());
        }
Exemplo n.º 8
0
        /// <summary>
        /// 更新调度器
        /// </summary>
        public void UpdateScheduler(basePortalModule bpm)
        {
            ScheduleItem objScheduleItem = SchedulingProvider.Instance().GetSchedule("DNNGo.Modules.PowerForms.SchedulerHelper,DNNGo.Modules.PowerForms", Null.NullString);

            if (!(objScheduleItem != null && objScheduleItem.ScheduleID > 0))
            {
                //这里需要创建新的调度器
                Int32 ScheduleID = AddScheduler();
                objScheduleItem = SchedulingProvider.Instance().GetSchedule(ScheduleID);
            }


            //if (objScheduleItem != null && objScheduleItem.ScheduleID > 0)
            //{
            //    UpdateSchedule(objScheduleItem);
            //}
        }
        /// <summary>
        /// 安装字段
        /// </summary>
        /// <param name="FieldName"></param>
        /// <param name="bpm"></param>
        public static Int32 InstallField(String FieldName, basePortalModule bpm)
        {
            DNNGo_PowerForms_Field fieldItem = new DNNGo_PowerForms_Field();

            fieldItem.Name = fieldItem.Alias = fieldItem.ToolTip = FieldName;

            if (FieldName.IndexOf("Name", StringComparison.CurrentCultureIgnoreCase) >= 0)
            {
                fieldItem.FieldType = (Int32)EnumViewControlType.TextBox_DisplayName;
                fieldItem.Required  = 1;
            }
            else if (FieldName.IndexOf("Email", StringComparison.CurrentCultureIgnoreCase) >= 0)
            {
                fieldItem.FieldType    = (Int32)EnumViewControlType.TextBox_Email;
                fieldItem.Verification = (Int32)EnumVerification.email;
                fieldItem.Required     = 1;
            }
            else if (FieldName.IndexOf("Messages", StringComparison.CurrentCultureIgnoreCase) >= 0)
            {
                fieldItem.FieldType = (Int32)EnumViewControlType.TextBox;
                fieldItem.Rows      = 4;
            }


            QueryParam qp = new QueryParam();

            qp.Where.Add(new SearchParam(DNNGo_PowerForms_Field._.ModuleId, bpm.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 = bpm.ModuleId;
                fieldItem.PortalId = bpm.PortalId;

                fieldItem.Sort = DNNGo_PowerForms_Field.FindCount(DNNGo_PowerForms_Field._.ModuleId, bpm.ModuleId) + 1;

                fieldItem.Status = 1;

                fieldItem.LastTime = xUserTime.UtcTime();
                fieldItem.LastUser = bpm.UserId;
                fieldItem.LastIP   = WebHelper.UserHost;
                return(fieldItem.Insert());
            }
            return(0);
        }
Exemplo n.º 10
0
        /// <summary>
        /// 更新设置
        /// </summary>
        /// <param name="SchedulerItem"></param>
        /// <returns></returns>
        public static Int32 UpdateSettings(DNNGo_PowerForms_Scheduler SchedulerItem, basePortalModule baseModule)
        {
            Int32 SchedulerID = 0;

            SchedulerItem.LastIP   = WebHelper.UserHost;
            SchedulerItem.LastTime = DateTime.Now;
            SchedulerItem.LastUser = baseModule.UserId;

            if (SchedulerItem.ID > 0)
            {
                SchedulerID = SchedulerItem.Update();
            }
            else
            {
                SchedulerItem.ModuleId = baseModule.ModuleId;
                SchedulerItem.PortalId = baseModule.PortalId;
                SchedulerID            = SchedulerItem.Insert();
            }
            return(SchedulerID);
        }
        /// <summary>
        /// 获取Form传值
        /// </summary>
        /// <param name="fieldItem"></param>
        /// <returns></returns>
        public static String GetWebFormValue(SettingEntity fieldItem, basePortalModule bpm)
        {
            String WebFormValue = String.Empty;

            //创建控件的Name和ID
            ControlHelper ControlItem = new ControlHelper(bpm.ModuleId);
            String        ControlName = ControlItem.ViewControlName(fieldItem);
            String        ControlID   = ControlItem.ViewControlID(fieldItem);

            if (fieldItem.ControlType == EnumControlType.CheckBox.ToString())
            {
                WebFormValue = WebHelper.GetStringParam(HttpContext.Current.Request, ControlName, "");
                WebFormValue = !String.IsNullOrEmpty(WebFormValue) && WebFormValue == "on" ? "true" : "false";
            }
            else if (fieldItem.ControlType == EnumControlType.FileUpload.ToString())
            {
                HttpPostedFile hpFile = HttpContext.Current.Request.Files[ControlName];
                //To verify that if the suffix name of the uploaded files meets the DNN HOST requirements
                Boolean retValue = FileSystemUtils.CheckValidFileName(hpFile.FileName);
                if (retValue)
                {
                    if (hpFile != null && hpFile.ContentLength > 0)
                    {
                        WebFormValue = String.Format("Url://{0}", FileSystemUtils.UploadFile(hpFile, bpm));                                                            //存放到目录中,并返回
                    }
                }
            }
            else if (fieldItem.ControlType == EnumControlType.Urls.ToString())
            {
                String ClientName = GetRichUrlsName(fieldItem);
                if (bpm.HttpContext.Items.Contains(ClientName))
                {
                    WebFormValue = Convert.ToString(bpm.HttpContext.Items[ClientName]);
                }
            }
            else
            {
                WebFormValue = WebHelper.GetStringParam(HttpContext.Current.Request, ControlName, "");
            }
            return(WebFormValue);
        }
Exemplo n.º 12
0
        public static Dictionary <String, Object> Validate(string EncodedResponse, basePortalModule baseModule)
        {
            JavaScriptSerializer        jsSerializer    = new JavaScriptSerializer();
            Dictionary <String, Object> captchaResponse = new Dictionary <string, Object>();



            string PrivateKey = baseModule.ViewSettingT <String>("PowerForms_Recaptcha_v3_SecretKey", "");

            try
            {
                using (var client = new System.Net.WebClient())
                {
                    client.Headers[System.Net.HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";

                    //if (baseModule.IsSSL)
                    //{
                    //    client.Headers[System.Net.HttpRequestHeader.KeepAlive] = "true";
                    //    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11;
                    //}

                    client.Headers[System.Net.HttpRequestHeader.KeepAlive] = "true";
                    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11;



                    //var GoogleReply = client.DownloadString(string.Format("https://www.google.com/recaptcha/api/siteverify?secret={0}&response={1}&remoteip={2}", PrivateKey, EncodedResponse, WebHelper.UserHost));
                    var GoogleReply = client.UploadString("https://www.google.com/recaptcha/api/siteverify", "POST", string.Format("secret={0}&response={1}&remoteip={2}", PrivateKey, EncodedResponse, WebHelper.UserHost));
                    //captchaResponse.Add("error-net",  string.Format("secret={0}&response={1}&remoteip={2}", PrivateKey, EncodedResponse, WebHelper.UserHost));
                    captchaResponse = jsSerializer.Deserialize <Dictionary <String, Object> >(GoogleReply);
                    XTrace.WriteLine(GoogleReply);
                }
            }
            catch (Exception exc)
            {
                captchaResponse.Add("error-net", exc.Message);
                return(captchaResponse);
            }

            return(captchaResponse);
        }
Exemplo n.º 13
0
        /// <summary>
        /// 绑定列表数据到容器
        /// </summary>
        private void BindContainer()
        {
            //加载相应的控件
            basePortalModule ManageContent = new basePortalModule();
            String           ModuleSrc     = String.Empty;

            if (Token.IndexOf(String.Format("Result{0}", ModuleId), StringComparison.CurrentCultureIgnoreCase) >= 0)
            {
                ModuleSrc = "View_Result.ascx";
            }
            else
            {
                ModuleSrc = "View_Form.ascx";
            }

            ManageContent.ID = Token;
            String ContentSrc = ResolveClientUrl(string.Format("{0}/{1}", this.TemplateSourceDirectory, ModuleSrc));

            ManageContent = (basePortalModule)LoadControl(ContentSrc);
            ManageContent.ModuleConfiguration = this.ModuleConfiguration;
            ManageContent.LocalResourceFile   = Localization.GetResourceFile(this, string.Format("{0}.resx", ModuleSrc));
            phPlaceHolder.Controls.Add(ManageContent);
        }
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="pmb">集成模块的对象</param>
 public VelocityHelper(basePortalModule _bpm, String _path = "Effect")
 {
     bpm = _bpm;
     Init(_bpm, _path);
 }
Exemplo n.º 15
0
        public static bool SaveAsToFile(List <DNNGo_PowerForms_Field> fieldList, List <DNNGo_PowerForms_Content> DataList, out string FullName, basePortalModule bpm)
        {
            Int32  EnumExportExtension = bpm.Settings["PowerForms_ExportExtension"] != null && !string.IsNullOrEmpty(bpm.Settings["PowerForms_ExportExtension"].ToString()) ? Convert.ToInt32(bpm.Settings["PowerForms_ExportExtension"]) : (Int32)EnumExport.Excel;
            String FileExtension       = "xls";

            switch (EnumExportExtension)
            {
            case (Int32)EnumExport.CSV: FileExtension = "csv"; break;

            case (Int32)EnumExport.Doc: FileExtension = "doc"; break;

            case (Int32)EnumExport.Html: FileExtension = "html"; break;

            case (Int32)EnumExport.TextFile: FileExtension = "txt"; break;

            case (Int32)EnumExport.Xml: FileExtension = "xml"; break;

            default: FileExtension = "xls"; break;
            }

            FullName = bpm.Server.MapPath(String.Format("{0}PowerForms/Export/PowerForms_{1}_{2}.{3}", bpm.PortalSettings.HomeDirectory, bpm.ModuleId, DateTime.Now.ToString("yyyyMMddHHmmssffff"), FileExtension));

            bool ExtraTracking = bpm.ViewSettingT <bool>("PowerForms_ExportExtraTracking", false);

            return(SaveAsToFile(fieldList, DataList, FullName, EnumExportExtension, ExtraTracking));
        }
 public ControlHelper(basePortalModule __baseModule)
 {
     ModuleId   = __baseModule.ModuleId;
     BaseModule = __baseModule;
 }
Exemplo n.º 17
0
 /// <summary>
 /// 获取资源文件夹中的内容
 /// </summary>
 /// <param name="PathName">文件夹名</param>
 /// <param name="FileName">文件名</param>
 /// <param name="pmb">当前模块对象</param>
 /// <returns></returns>
 public static String Resource(String PathName, String FileName, basePortalModule pmb)
 {
     return(String.Format("{0}{1}/{2}", pmb.ModulePath, PathName, FileName));
 }
Exemplo n.º 18
0
        /// <summary>
        /// 上传文件
        /// </summary>
        /// <param name="hpFile"></param>
        /// <param name="pmb"></param>
        /// <returns></returns>
        public static String UploadFileByCustom(HttpPostedFile httpFile, EffectDB DB, basePortalModule pmb)
        {
            String FileName = httpFile.FileName.Replace(" ", "_");

            if (FileName.IndexOf(@"\") >= 0)
            {
                FileName = FileName.Substring(FileName.LastIndexOf(@"\"), FileName.Length - FileName.LastIndexOf(@"\")).Replace(@"\", "");
            }

            String Extension = Path.GetExtension(FileName).Replace(".", "");


            //构造保存路径
            String   FileUrl = FileName;
            FileInfo file    = new FileInfo(pmb.MapPath(String.Format("{0}Effects/{1}/{2}", pmb.ModulePath, DB.Name, FileName)));

            if (!file.Directory.Exists)
            {
                file.Directory.Create();
            }

            int ExistsCount = 1;

            //检测文件名是否存在
            while (file.Exists)
            {
                FileUrl = String.Format("{0}_{1}.{2}", FileName.Replace("." + Extension, ""), ExistsCount, Extension);
                file    = new FileInfo(pmb.MapPath(String.Format("{0}Effects/{1}/{2}", pmb.PortalId, DB.Name, FileUrl)));
                ExistsCount++;
            }

            //保存文件到文件夹
            httpFile.SaveAs(file.FullName);

            return(FileUrl);
        }
 /// <summary>
 /// 封装构造
 /// </summary>
 public PushForm(basePortalModule _BPM)
 {
     BPM  = _BPM;
     webX = new WebClientX(_BPM);
 }